Package java.nio.channels

Examples of java.nio.channels.FileLock.release()


    }
    if (sharedLockData == null && nonsharedLockData == null) {
      throw new IOException("Given target not held as lock");
    }
   
    lockObj.release();
   
    if (sharedLockData != null) {
      sharedLockData.close();
    } else {
      nonsharedLockData.close();
View Full Code Here


            PrintWriter writer = new PrintWriter(out, false);
            writer.println(DATE_FORMAT.format(date)+" - "+action+" - "+username);
            writer.flush();
            writer.close();
            if(lock.isValid()) {
                lock.release();
            }
        } catch (IOException e) {
            throw new RuntimeException("Unable to write to authentication log file", e);
        }
    }
View Full Code Here

      throw new IOException(msg);
    }
    FileLock secondLock = tryLock(dir);
    if(secondLock != null) {
      LOGGER.warn("Directory "+dir+" does not support locking");
      secondLock.release();
      secondLock.channel().close();
    }
    locks.put(dir.getAbsolutePath(), lock);
  }
View Full Code Here

  private void unlock(File dir) throws IOException {
    FileLock lock = locks.remove(dir.getAbsolutePath());
    if(lock == null) {
      return;
    }
    lock.release();
    lock.channel().close();
    lock = null;
  }
  static class BackgroundWorker extends Thread {
    private static final Logger LOG = LoggerFactory
View Full Code Here

            FileLock lock = channel.lock();
            if (LOG.isTraceEnabled()) {
                LOG.trace("Acquired exclusive read lock: " + lock + " to file: " + file);
            }
            // just release it now we dont want to hold it during the rest of the processing
            lock.release();
        } finally {
            // must close channel
            ObjectHelper.close(channel, "FileConsumer during acquiring of exclusive read lock", LOG);
        }
    }
View Full Code Here

    }
    if (sharedLockData == null && nonsharedLockData == null) {
      throw new IOException("Given target not held as lock");
    }
   
    lockObj.release();
   
    if (sharedLockData != null) {
      sharedLockData.close();
    } else {
      nonsharedLockData.close();
View Full Code Here

          // produce a more specific message for clients
          String specificMessage = NLS.bind(EclipseAdaptorMsg.location_cannotLockNIO, new Object[] {lockFile, ioe.getMessage(), "\"-D" + BasicLocation.PROP_OSGI_LOCKING + "=none\""}); //$NON-NLS-1$ //$NON-NLS-2$
          throw new IOException(specificMessage);
        }
        if (tempLock != null) {
          tempLock.release(); // allow IOException to propagate because that would mean it is still locked
          return false;
        }
        return true;
      } catch (OverlappingFileLockException e) {
        return true;
View Full Code Here

      oldFile.seek(0);
      int oldVersion = oldFile.readInt();
      if (oldVersion < LAST_PRE_UPGRADE_LAYOUT_VERSION)
        return false;
    } finally {
      oldLock.release();
      oldFile.close();
    }
    return true;
  }
View Full Code Here

      {
         return true;
      }
      else
      {
         liveAttemptLock.release();
         return false;
      }
   }
   @Override
   public void releaseBackup() throws Exception
View Full Code Here

            Channel channel = lock.channel();
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unlocking file: " + file);
            }
            try {
                lock.release();
            } finally {
                // must close channel
                ObjectHelper.close(channel, "Closing channel", LOG);

                if (LOG.isTraceEnabled()) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.