Start lease recovery

@param f the name of the file to start lease recovery
@return if the file is closed or not
@throws IOException
777699
@Deprecated
  public boolean recoverLease(Path f) throws IOException {
    return dfs.recoverLease(getPathName(f), false);
  }
861845
@Override
    @Trivial
    public ZipFile open() throws IOException {
        String methodName = "open";

        synchronized( zipFileLock ) {
            if ( zipFile == null ) {
                debug(methodName, "Opening");
                if ( zipFileReaper == null ) {
                    zipFile = ZipFileUtils.openZipFile(file); // throws IOException
                } else {
                    zipFile = zipFileReaper.open(path);
                }
            }

            openCount++;
            debug(methodName, "Opened");

            return zipFile;
        }
    }
850733
public void startRecovery() throws Exception {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "startRecovery");

        // Note that _recoverDBLogStarted is always false if we are logging to a filesystem.
        // If we are logging to an RDBMS, then we will start the TM which will spin off a thread
        // to perform recovery processing. Unfortunately, this latter thread, as part of
        // DataSource processing, will also attempt to start the TM as a result of registering
        // ResourceInfo. This flag guards against that eventuality.
        if (!_recoverDBLogStarted) {
            synchronized (this) {
                TMHelper.setTMService(this);

                // Initalize trace
                Tr.reinitializeTracer();

                // Test whether we are logging to an RDBMS
                final ConfigurationProvider cp = ConfigurationProviderManager.getConfigurationProvider();
                if (cp != null && cp.isSQLRecoveryLog()) {
                    _recoverDBLogStarted = true;
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Tran Logging to an RDBMS set recoverDBLogStarted flag");
                }

                if (getState() != TMService.TMStates.INACTIVE && getState() != TMService.TMStates.STOPPED) {
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "start", "Already started");
                    return;
                }

                setResyncException(null);
                _recLogService = new RecLogServiceImpl();

                // Create the Recovery Director
                _recoveryDirector = RecoveryDirectorFactory.createRecoveryDirector();

                // For cloud support, retrieve recovery identity from the configuration if it is defined.
                if (cp != null) {
                    _recoveryIdentity = cp.getRecoveryIdentity();
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "RecoveryIdentity is ", _recoveryIdentity);
                    _recoveryGroup = cp.getRecoveryGroup();
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "recoveryGroup is ", _recoveryGroup);
                }

                //Add this guard to ensure that we have sufficient config to drive recovery.
                boolean allowRecovery = true;
                if (cp == null) {
                    // A null ConfigurationProvider cannot be tolerated.
                    allowRecovery = false;
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Configuration Provider is null");
                } else {
                    String sName = cp.getServerName();
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Retrieved server name " + sName);
                    if (sName == null || sName.isEmpty()) {
                        // An empty string serverName suggests that the Location Service was unavailable
                        allowRecovery = false;
                    }
                }

                if (!allowRecovery) {
                    try {
                        shutdown();
                    } catch (RuntimeException e) {
                        FFDCFilter.processException(e, "com.ibm.tx.jta.util.TxTMHelper.start", "279", this);
                    }

                    final Throwable se = new SystemException();
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "start", se);
                    throw (SystemException) se;
                }

                if (_recoveryIdentity != null && !_recoveryIdentity.isEmpty()) {
                    _recLogService.initialize(_recoveryIdentity);
                } else {
                    String serverName = null;
                    if (cp != null) {
                        serverName = cp.getServerName();
                    }
                    _recLogService.initialize(serverName);
                }

                TxRecoveryAgentImpl txAgent = createRecoveryAgent(_recoveryDirector);

                // For now I'll code such that the presence of a RecoveryIdentity attribute says that we are operating in the Cloud
                if (_recoveryIdentity != null && !_recoveryIdentity.isEmpty()) {
                    _recLogService.setPeerRecoverySupported(true);
                    txAgent.setPeerRecoverySupported(true);
                    // Override the disable2PC property if it has been set
                    TransactionImpl.setDisable2PCDefault(false);
                    Tr.audit(tc, "WTRN0108I: Server with identity " + _recoveryIdentity + " is monitoring its peers for Transaction Peer Recovery");
                }

                //TODO: We don't currently use the recoveryGroup....but in due course we will, so retain this
                // code snippet
                if (_recoveryGroup != null && !_recoveryGroup.isEmpty()) {
                    txAgent.setRecoveryGroup(_recoveryGroup);

                    _recLogService.setRecoveryGroup(_recoveryGroup);
                }

                setRecoveryAgent(txAgent);

                // Fake recovery only mode if we're to wait
                RecoveryManager._waitForRecovery = _waitForRecovery;

                // Kick off recovery
                _recLogService.startRecovery(_recoveryLogFactory);

                // Defect RTC 99071. Don't make the STATE transition until recovery has been fully
                // initialised, after replay completion but before resync completion.
                setState(TMService.TMStates.RECOVERING);

                if (_waitForRecovery) {
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Waiting for completion of asynchronous recovery");
                    _asyncRecoverySemaphore.waitEvent();
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Asynchronous recovery is complete");

                    if (_resyncException != null) {
                        try {
                            shutdown();
                        } catch (RuntimeException e) {
                            FFDCFilter.processException(e, "com.ibm.tx.jta.util.TxTMHelper.start", "137", this);
                        }

                        final Throwable se = new SystemException().initCause(_resyncException);
                        if (tc.isEntryEnabled())
                            Tr.exit(tc, "start", se);
                        throw (SystemException) se;
                    }
                } // eof if waitForRecovery
            } // eof synchronized block
        } // eof if !_recoverDBLogStarted
        else if (tc.isDebugEnabled())
            Tr.debug(tc, "Tran Logging to an RDBMS and START processing is in progress");

        if (tc.isEntryEnabled())
            Tr.exit(tc, "startRecovery");
    }
792631
public OFile unlock(final FileLock iLock) throws IOException {
    if (iLock != null) {
      try {
        iLock.release();
      } catch (ClosedChannelException e) {
      }
    }
    return this;
  }
547629
private FileSystem getFileSystemSafe() throws IOException
    {
        try {
            fs.getFileStatus(new Path("/"));
            return fs;
        }
        catch (NullPointerException e) {
            throw new IOException("file system not initialized");
        }
    }
1171544
public void reportErrorOnFile(File f) {
    // We use getAbsolutePath here instead of getCanonicalPath since we know
    // that there is some IO problem on that drive.
    // getCanonicalPath may need to call stat() or readlink() and it's likely
    // those calls would fail due to the same underlying IO problem.
    String absPath = f.getAbsolutePath();
    for (StorageDirectory sd : storageDirs) {
      String dirPath = sd.getRoot().getAbsolutePath();
      if (!dirPath.endsWith("/")) {
        dirPath += "/";
      }
      if (absPath.startsWith(dirPath)) {
        reportErrorsOnDirectory(sd, null);
        return;
      }
    }
    
  }
325231
public void restoreFromFile(File file) throws IOException
    {
        byte[] rawData = new byte[(int) file.length()];
        ByteBuffer bufData = null;
        FileInputStream fis = null;
        DataInputStream dis = null;
        try {
            fis = new FileInputStream(file);
            dis = new DataInputStream(fis);
            dis.readFully(rawData);
            bufData = ByteBuffer.wrap(rawData);
            restoreFromBuffer(bufData);
        }
        finally {
            if (dis != null) {
                dis.close();
            }
            if (fis != null) {
                fis.close();
            }
        }
    }
1301400
public boolean abandonFile(String src, String holder
      ) throws IOException {
    writeLock();
    try {
      if (NameNode.stateChangeLog.isDebugEnabled()) {
        NameNode.stateChangeLog.debug("FILE* NameSystem.abandonFile: " + src);
      }
      if (isInSafeMode()) {
        throw new SafeModeException("Cannot abandon file " + src, safeMode);
      }
      checkLease(src, holder);
      internalReleaseLeaseOne(leaseManager.getLease(holder), src);
      if (NameNode.stateChangeLog.isDebugEnabled()) {
        NameNode.stateChangeLog.debug("FILE* NameSystem.abandonFile: "
                                        + " has been scheduled for lease recovery");
      }
      return true;
    } finally {
      writeUnlock();
    }
  }
972112
def startfile(fpath, detatch=True, quote=False, verbose=False, quiet=True):
    
    print('[cplat] startfile(%r)' % fpath)
    fpath = normpath(fpath)
    # print('[cplat] fpath=%s' % fpath)
    if not exists(fpath):
        raise Exception('Cannot start nonexistant file: %r' % fpath)
    #if quote:
    #    fpath = '"%s"' % (fpath,)
    if not WIN32:
        fpath = pipes.quote(fpath)
    if LINUX:
        #out, err, ret = cmd(['xdg-open', fpath], detatch=True)
        outtup = cmd(('xdg-open', fpath), detatch=detatch, verbose=verbose, quiet=quiet)
        #outtup = cmd('xdg-open', fpath, detatch=detatch)
    elif DARWIN:
        outtup = cmd(('open', fpath), detatch=detatch, verbose=verbose, quiet=quiet)
    elif WIN32:
        os.startfile(fpath)
    else:
        raise RuntimeError('Unknown Platform')
    if outtup is not None:
        out, err, ret = outtup
        if not ret:
            raise Exception(out + ' -- ' + err)
    pass
563327
@Override
	public void reopen(FileInputSplit split, Tuple2<Long, Long> state) throws IOException {
		this.open(split);
		this.getOfficeReader().getCurrentParser().setCurrentSheet(state.f0);
		this.getOfficeReader().getCurrentParser().setCurrentRow(state.f1);

	}
942518
public static Symm obtain(File f) throws IOException {
	  FileInputStream fis = new FileInputStream(f);
	  try {
		  return obtain(fis);
	  } finally {
		  fis.close();
	  }
  }
1188569
protected void fileOpen() throws InternalLogException, LogAllocationException,
                    LogIncompatibleException
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "fileOpen", this);

        final boolean fileColdStarting;

        // Open the file, creating it if it does not already exist.
        try
        {
            try
            {
                final File pFile = new File(_logDirectory, _fileName);

                // Determine if the log file exists or is zero bytes long. In either of
                // these cases, we consider it to be a cold start of the file.
                fileColdStarting = ((!pFile.exists()) || (pFile.length() == 0));

                if (fileColdStarting)
                {
                    Tr.info(tc, "CWRLS0006_RECOVERY_LOG_CREATE", _logDirectory + File.separator + _fileName);
                }

                // Open/Create the file.
                // _fileBuffer = (MappedByteBuffer) AccessController.doPrivileged(
                _fileBuffer = (MappedByteBuffer) Configuration.getAccessController()
                                .doPrivileged(
                                              new java.security.PrivilegedExceptionAction()
                                              {
                                                  @Override
                                                  public java.lang.Object run() throws Exception
                                                  {
                                                      if (tc.isEntryEnabled())
                                                          Tr.entry(tc, "run", this);

//              _file = new RandomAccessFile(pFile, "rw");
                                                      _file = RLSAccessFile.getRLSAccessFile(pFile); // @255605C
                                                      _fileChannel = _file.getChannel();

                                                      // NB - this limits us to a maximum file size
                                                      // of 2GB. This is the max value of an int and
                                                      // is also the maximum amount of data that
                                                      // can be held in a MappedByteBuffer.
                                                      final int fileLength = (int) _file.length();

                                                      final int fileSizeBytes = _fileSize * 1024;

                                                      // In the event that the log file already exists and it's bigger
                                                      // than the required file size ensure that we map the entire
                                                      // contents of the file.             
                                                      final int sizeToMap = fileLength > fileSizeBytes ? fileLength : fileSizeBytes;

                                                      // Feature 731093 default for noMemoryMappedFIles flag is operating system dependent
                                                      String osName = System.getProperty("os.name");
                                                      if (osName != null)
                                                          osName = osName.toLowerCase();
                                                      if (tc.isDebugEnabled())
                                                          Tr.debug(tc, "Working on operating system " + osName);
                                                      // If not specified - default is false
                                                      boolean noMemoryMappedFiles = Boolean.getBoolean("com.ibm.ws.recoverylog.spi.NoMemoryMappedFiles");
                                                      // If Windows and HA enabled, or z/OS (feature 731093) then we want the default to be non-memory mapped
                                                      if (osName != null
                                                          && ((Configuration.HAEnabled() && osName.startsWith("windows")) || osName.startsWith("z/os") || osName.startsWith("os/390")))
                                                      {
                                                          final String propertyValue = System.getProperty("com.ibm.ws.recoverylog.spi.NoMemoryMappedFiles");
                                                          if (propertyValue == null || !(propertyValue.equalsIgnoreCase("false")))
                                                              noMemoryMappedFiles = true;
                                                      }
                                                      if (tc.isDebugEnabled())
                                                          Tr.debug(tc, "NoMemoryMappedFiles flag is " + noMemoryMappedFiles);

                                                      Object fileBuffer = null;

                                                      if (!noMemoryMappedFiles)
                                                      {
                                                          try
                                                          {
                                                              fileBuffer = _fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, sizeToMap);
                                                              _isMapped = true;
                                                          }
                                                          catch (Throwable t)
                                                          {
                                                              if (tc.isEventEnabled())
                                                                  Tr.event(tc, "Mapping of recovery log file failed. Using non-mapped file.", t);
                                                              if (tc.isEventEnabled())
                                                                  Tr.event(tc, "Resetting file Channel position to '0' from :", _fileChannel.position());
                                                              _fileChannel.position(0); //An Exception in the map method can leave an incorrect position (PM14310)
                                                          }
                                                      }
                                                      else
                                                      {
                                                          if (tc.isEventEnabled())
                                                              Tr.event(tc, "Recovery log has been instructed not to use a mapped-file model.");
                                                      }

                                                      if (fileBuffer == null)
                                                      {
                                                          // Either we were instructed not to use a mapped buffer or the
                                                          // attempt to use one failed. Allocate a direct byte buffer
                                                          // and read the FileChannel into the buffer.  write()s to the
                                                          // direct byte buffer will not be reflected by the FileChannel
                                                          // until a force() is made on the LogFileHandle.

                                                          final ByteBuffer directByteBuffer = ByteBuffer.allocateDirect(sizeToMap);

                                                          if (fileColdStarting)
                                                          {
                                                              _fileChannel.write(directByteBuffer, 0);
                                                              _fileChannel.force(true);
                                                          }

                                                          _fileChannel.read(directByteBuffer);
                                                          directByteBuffer.rewind();
                                                          _isMapped = false;

                                                          if (tc.isDebugEnabled())
                                                              Tr.debug(tc, "A direct byte buffer has been allocated successfully.");

                                                          fileBuffer = directByteBuffer;
                                                      }

                                                      if (tc.isEntryEnabled())
                                                          Tr.exit(tc, "run", fileBuffer);
                                                      return fileBuffer;
                                                  }
                                              });
            } catch (java.security.PrivilegedActionException exc)
            {
                FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "338", this);
                throw new LogAllocationException(exc);
            } catch (Throwable exc)
            {
                FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "343", this);
                throw new InternalLogException(exc);
            }
        } catch (LogAllocationException exc)
        {
            FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "351", this);
            _fileBuffer = null;
            if (_file != null)
                fileClose(); // @255605A
            if (tc.isEntryEnabled())
                Tr.exit(tc, "fileOpen", exc);
            throw exc;
        } catch (Throwable exc)
        {
            FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "359", this);
            _fileBuffer = null;
            if (_file != null)
                fileClose(); // @255605A
            if (tc.isEntryEnabled())
                Tr.exit(tc, "fileOpen", "InternalLogException");
            throw new InternalLogException(exc);
        }

        if (fileColdStarting)
        {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Log File " + this._fileName + " is cold starting");

            // The file did not exist when this call was issued and has been created above.
            // Write an empty log header into the file to ensure that it can't be confused
            // with a corrupt log file in the event of a crash before we fully initialize 
            // it.
            try
            {
                writeFileHeader(false);
            } catch (InternalLogException exc)
            {
                FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "388", this);
                fileClose(); // @255605A
                _file = null;
                _fileChannel = null;
                _fileBuffer = null;
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "fileOpen", exc);
                throw exc;
            } catch (Throwable exc)
            {
                FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "396", this);
                fileClose(); // @255605A
                _file = null;
                _fileChannel = null;
                _fileBuffer = null;
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "fileOpen", "InternalLogException");
                throw new InternalLogException(exc);
            }
        }
        else
        {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Log File " + this._fileName + " is warm starting");

            // The file already existed on disk before this method was called. We must load
            // the header information from this file.
            readFileHeader();
        }

        // First check whether invalid. invalid trumps incompatible. 
        if (!_logFileHeader.valid())
        {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Log File " + this._fileName + " is not valid");
            try
            {
//        Dont close channel as it will free a lock - wait until file close
//        _fileChannel.close(); // @255605D
                _file.close();
            } catch (java.io.IOException exc)
            {
                // The file could not even be closed! There is nothing that can be done in this situation.
                // Simply allow the LogIncompatibleException exception to be passed back up the stack.
                FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "423", this);
            } catch (Throwable exc)
            {
                // The file could not even be closed! There is nothing that can be done in this situation.
                // Simply allow the LogIncompatibleException exception to be passed back up the stack.
                FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "429", this);
            }

            _fileBuffer = null;
            _file = null;
            _fileChannel = null;
            _logFileHeader = null;

            if (tc.isEntryEnabled())
                Tr.exit(tc, "fileOpen", "InternalLogException");
            throw new InternalLogException();
        }

        // If the header incompatible (created by an unsupported version of the RLS) then throw an exception.
        if (!_logFileHeader.compatible())
        {
            try
            {
//        Dont close channel as it will free a lock - wait until file close
//        _fileChannel.close(); // @255605D
                _file.close();
            } catch (java.io.IOException exc)
            {
                // The file could not even be closed! There is nothing that can be done in this situation.
                // Simply allow the LogIncompatibleException exception to be passed back up the stack.
                FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "423", this);
            } catch (Throwable exc)
            {
                // The file could not even be closed! There is nothing that can be done in this situation.
                // Simply allow the LogIncompatibleException exception to be passed back up the stack.
                FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "429", this);
            }

            _fileBuffer = null;
            _file = null;
            _fileChannel = null;
            _logFileHeader = null;

            if (tc.isEntryEnabled())
                Tr.exit(tc, "fileOpen", "LogIncompatibleException");
            throw new LogIncompatibleException();
        }

        if (!serviceCompatible())
        {
            try
            {
//        Dont close channel as it will free a lock - wait until file close
//        _fileChannel.close(); // @255605D
                _file.close();
            } catch (java.io.IOException exc)
            {
                // The file could not even be closed! There is nothing that can be done in this situation.
                // Simply allow the LogIncompatibleException exception to be passed back up the stack.
                FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "423", this);
            } catch (Throwable exc)
            {
                // The file could not even be closed! There is nothing that can be done in this situation.
                // Simply allow the LogIncompatibleException exception to be passed back up the stack.
                FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileOpen", "429", this);
            }

            _fileBuffer = null;
            _file = null;
            _fileChannel = null;
            _logFileHeader = null;

            if (tc.isEntryEnabled())
                Tr.exit(tc, "fileOpen", "LogIncompatibleException");
            throw new LogIncompatibleException();
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "fileOpen");
    }
713355
public void restore() throws IOException
   {
      SpoolConfig spoolConfig = new SpoolConfig(fileCleaner);

      List<ItemState> listItemState = itemDataChangesLog.getAllStates();
      for (int i = 0; i < this.listFixupStream.size(); i++)
      {
         ItemState itemState = listItemState.get(listFixupStream.get(i).getItemSateId());
         ItemData itemData = itemState.getData();

         PersistedPropertyData propertyData = (PersistedPropertyData)itemData;
         ValueData vd = (propertyData.getValues().get(listFixupStream.get(i).getValueDataId()));

         // re-init the value
         propertyData.getValues().set(listFixupStream.get(i).getValueDataId(),
            new StreamPersistedValueData(vd.getOrderNumber(), listFile.get(i), spoolConfig));
      }

      if (listRandomAccessFile != null)
         for (int i = 0; i < listRandomAccessFile.size(); i++)
            listRandomAccessFile.get(i).close();

      for (int i = 0; i < listFile.size(); i++)
         fileCleaner.addFile(listFile.get(i));
   }
203922
@Override
    public void getLeasesForPeers(final PeerLeaseTable peerLeaseTable, String recoveryGroup) throws Exception {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "getLeasesForPeers", new Object[] { peerLeaseTable, recoveryGroup, this });

        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {

                // We'll start by trying to lock the control file, if we can't do it this time around, then so be it, we
                // assume that someone else is either getting peer leases or deleting peer leases.
                FileChannel theChannel = null;
                FileLock lock = null;
                try {
                    theChannel = new RandomAccessFile(_controlFile, "rw").getChannel();
                } catch (FileNotFoundException e) {
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Caught FileNotFound exception when trying to lock control file");
                    theChannel = null;
                }

                if (theChannel != null) {
                    // Non blocking attempt to acquire the lock on the control file.
                    try {
                        lock = theChannel.tryLock();
                    } catch (IOException e) {
                        if (tc.isDebugEnabled())
                            Tr.debug(tc, "Caught IOException when trying to lock control file - " + e);
                        theChannel = null;
                    }

                    if (lock != null) {

                        File thePeerFiles[] = _leaseLogDirectory.listFiles();
                        // Now process through the peers we need to handle
                        if (thePeerFiles != null) {
                            for (File peerFile : thePeerFiles) {
                                if (!peerFile.isDirectory()) {
                                    final String recoveryId = peerFile.getName();
                                    //Skip over the control file
                                    if (!recoveryId.equals(_controlFile.getName())) {
                                        final long leaseTime = peerFile.lastModified();

                                        if (tc.isEventEnabled()) {
                                            Tr.event(tc, "Lease Table: read recoveryId: " + recoveryId);
                                            Tr.event(tc, "Lease Table: read leaseTime: " + leaseTime);
                                        }

                                        PeerLeaseData pld = new PeerLeaseData(recoveryId, leaseTime, _leaseTimeout);

                                        peerLeaseTable.addPeerEntry(pld);
                                    } else {
                                        if (tc.isDebugEnabled())
                                            Tr.debug(tc, "Exclude the control file from the list");
                                    }
                                }
                            }
                        } else {
                            if (tc.isDebugEnabled())
                                Tr.debug(tc, "No peer servers found");
                        }
                    }
                }

                // Tidy up before we leave
                if (lock != null) {
                    try {
                        lock.release();
                    } catch (IOException e) {
                        if (tc.isDebugEnabled())
                            Tr.debug(tc, "Caught an IOException on lock release");
                    }
                }
                // Close the channel
                if (theChannel != null) {
                    try {
                        theChannel.close();
                    } catch (IOException e) {
                        if (tc.isDebugEnabled())
                            Tr.debug(tc, "Caught an IOException on channel close");
                    }
                }

                return null;
            }
        });

        if (tc.isEntryEnabled())
            Tr.exit(tc, "getLeasesForPeers", this);

    }
56034
public synchronized Lease allocate(@Nonnull FilePath base, Object context) throws InterruptedException {
        for (int i=1; ; i++) {
            FilePath candidate = i==1 ? base : base.withSuffix(COMBINATOR+i);
            Entry e = inUse.get(candidate.getRemote());
            if(e!=null && !e.quick && e.context!=context)
                continue;
            return acquire(candidate,false,context);
        }
    }
1274277
public static void deleteFile(@Nonnull File f) throws IOException {
        newPathRemover(PathRemover.PathChecker.ALLOW_ALL).forceRemoveFile(fileToPath(f));
    }
986611
@Override
    public boolean releasePeerLease(String recoveryIdentity) throws Exception {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "releasePeerLease", new Object[] { recoveryIdentity, this });
        // Release the lock - if it is not null!
        FileLock fLock = null;
        FileChannel fChannel = null;
        if (_peerLeaseLock != null) {
            String recIdentity = _peerLeaseLock.getRecoveryIdentity();
            if (recoveryIdentity.equals(recIdentity)) {
                fLock = _peerLeaseLock.getFileLock();
                if (fLock != null) {
                    fLock.release();
                }
                // Close the channel
                fChannel = _peerLeaseLock.getFileChannel();
                if (fChannel != null)
                    fChannel.close();
                _peerLeaseLock = null;
            } else {
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "The locks identity which was " + recIdentity + " did not match the requested identity which was " + recoveryIdentity);
            }
        } else {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "The lease lock was unexpectedly null");
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "releasePeerLease");
        return true;
    }