Package java.nio.channels

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


                    fd.write(String.valueOf(target).getBytes(ENCODING));
                    success = true;
                    return new LocalFileLockObject<T>(target, lockFile, fd, lockEntity);
                } finally {
                    if (success == false) {
                        lockEntity.release();
                    }
                }
            }
        } finally {
            if (success == false) {
View Full Code Here


      try {
        FileLock fileLock = raf.getChannel().tryLock();

        if (fileLock != null) {
          logger.warn("Removing invalid lock {}", getLockedBy());
          fileLock.release();
          revokeLock = true;
        }
      }
      catch (OverlappingFileLockException exc) {
        // lock is still valid
View Full Code Here

    FileChannel fc = new FileOutputStream(f).getChannel();
    FileLock fl = fc.lock();
    try {
      fc.write(ByteBuffer.wrap(data));
    } finally {
      fl.release();
      fc.close();
    }
  }
 
  private byte[] compose() {
View Full Code Here

          output.flush();
        } finally {
          // Unlock
          try {
            if (lock != null) {
              lock.release();
            }
          } catch (ClosedChannelException e) {
          }
        }
      } finally {
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

          output.flush();
        } finally {
          // Unlock
          try {
            if (lock != null) {
              lock.release();
            }
          } catch (ClosedChannelException e) {
          }
        }
      } finally {
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

                   files strings are configured that somehow map to the same file.*/
                final FileLock lock = channel.lock(0, Long.MAX_VALUE, false);
                try {
                    super.write(bytes, offset, length);
                } finally {
                    lock.release();
                }
            } catch (final IOException ex) {
                throw new AppenderRuntimeException("Unable to obtain lock on " + getName(), ex);
            }

View Full Code Here

      oldFile.seek(0);
      int odlVersion = oldFile.readInt();
      if (odlVersion < LAST_PRE_UPGRADE_LAYOUT_VERSION)
        return false;
    } finally {
      oldLock.release();
      oldFile.close();
    }
    // check consistency of the old storage
    File oldDataDir = new File(sd.root, "data");
    if (!oldDataDir.exists())
View Full Code Here

        deleteDir(newDataDir);
      // move "data" to "current"
      rename(oldDataDir, newDataDir);
      // close and unlock old file
    } finally {
      oldLock.release();
      oldFile.close();
    }
    // move old storage file into current dir
    rename(oldF, new File(sd.getCurrentDir(), "storage"));
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.