Package java.nio.channels

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


        firstLock.release();
        firstLock.channel().close();
      }
      if(secondLock != null) {
        secondLock.release();
        secondLock.channel().close();
      }
    }
    return false;
  }
View Full Code Here


        firstLock.release();
        firstLock.channel().close();
      }
      if(secondLock != null) {
        secondLock.release();
        secondLock.channel().close();
      }
    }
    return false;
  }
View Full Code Here

    String lastExMessage = null;
    FileChannel lockChannel = null;
    while (lockChannel == null && System.currentTimeMillis() - start < config.fileStore.lockWaitTimeoutMillis) {
      try {
        FileLock lock = channel.lock();
        lockChannel = lock.channel();
      } catch (FileLockInterruptionException | OverlappingFileLockException e) {
        lockRetryCount.incrementAndGet();
        lastExMessage = e.getMessage();
        LOG.debug("File lock on '{}' cannot be obtained (retrying operation): {}", histPath, lastExMessage);
        try {
View Full Code Here

          firstLock.release();
          firstLock.channel().close();
        }
        if(secondLock != null) {
          secondLock.release();
          secondLock.channel().close();
        }
      }
      return false;
    }
  }
View Full Code Here

          firstLock.release();
          firstLock.channel().close();
        }
        if(secondLock != null) {
          secondLock.release();
          secondLock.channel().close();
        }
      }
      return false;
    }
  }
View Full Code Here

   * @tests java.nio.channels.FileLock#FileLock(FileChannel, long, long,
   *        boolean)
   */
  public void test_Constructor_Ljava_nio_channels_FileChannelJJZ() {
    FileLock fileLock1 = new MockFileLock(null, 0, 0, false);
    assertNull(fileLock1.channel());

    try {
      new MockFileLock(readWriteChannel, -1, 0, false);
      fail("should throw IllegalArgumentException.");
    } catch (IllegalArgumentException ex) {
View Full Code Here

   * @tests java.nio.channels.FileLock#channel()
   */
  public void test_channel() {
    assertSame(readWriteChannel, mockLock.channel());
    FileLock lock = new MockFileLock(null, 0, 10, true);
    assertNull(lock.channel());
  }

  /**
   * @tests java.nio.channels.FileLock#position()
   */
 
View Full Code Here

        firstLock.release();
        firstLock.channel().close();
      }
      if(secondLock != null) {
        secondLock.release();
        secondLock.channel().close();
      }
    }
    return false;
  }
View Full Code Here

    public void releaseExclusiveReadLock(GenericFileOperations<File> operations,
                                         GenericFile<File> file, Exchange exchange) throws Exception {
        FileLock lock = ExchangeHelper.getMandatoryProperty(exchange, "CamelFileLock", FileLock.class);
        String lockFileName = ExchangeHelper.getMandatoryProperty(exchange, "CamelFileLockName", String.class);
        Channel channel = lock.channel();

        if (LOG.isTraceEnabled()) {
            LOG.trace("Unlocking file: " + lockFileName);
        }
        try {
View Full Code Here

    public void releaseExclusiveReadLock(GenericFileOperations<File> operations,
                                         GenericFile<File> file, Exchange exchange) throws Exception {
        FileLock lock = ExchangeHelper.getMandatoryProperty(exchange, "CamelFileLock", FileLock.class);
        String lockFileName = ExchangeHelper.getMandatoryProperty(exchange, "CamelFileLockName", String.class);
        Channel channel = lock.channel();
        try {
            lock.release();
        } finally {
            // must close channel first
            ObjectHelper.close(channel, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
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.