Java 8 FileLock - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 FileLock class.

This code example shows how to use the following methods: channel, isValid, release
        } 
        return lock != null;
    } 
 
    public void release() throws Exception {
        if (lock != null && lock.isValid()) {
            LOG.info("Releasing lock " + lockPath.getPath());
            lock.release();
            lock.channel().close();
        } 
        lock = null;
    } 
  
    public boolean isAlive() throws Exception {
        return lock != null && lock.isValid() && lockPath.exists();
    } 
 
    private static File getKarafLock(File lock,Properties props) {
        File rc = null;
 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: channel, isShared, position, size
     * @param position 
     * @param size 
     * @param shared 
     */ 
    public SqlJetFileLock(SqlJetFileLockManager manager, FileLock fileLock) {
        super(fileLock.channel(), fileLock.position(), fileLock.size(), fileLock.isShared());
        this.manager = manager;
        this.fileLock = fileLock;
        this.locksCount = 1;
    } 
 
    /* 
     * (non-Javadoc) 
     *  
     * @see java.nio.channels.FileLock#isValid() 
     */ 
    @Override 
    public boolean isValid() { 
        return fileLock.isValid();
    } 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: release
    } 
 
    public void release() 
    { 
        try { 
            lock.release();
        } 
        catch (IOException e) {
            Throwables.propagate(e);
        } 
        finally { 
            Closeables.closeQuietly(channel);
        } 
    } 
 
    @Override 
    public String toString()
    { 
        StringBuilder sb = new StringBuilder();
        sb.append("DbLock");
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: release
String msg = "hello from" + instanceName + " " + i + LINE_SEPARATOR;
      fos.write(msg.getBytes());
    } finally { 
      if (fileLock != null) {
        fileLock.release();
      } 
    } 
  } 
 
  static void printDotAndSleep(int i) throws InterruptedException {
    if (i % DOT_FREQ == 0) {
      System.out.print(".");
      Thread.sleep(delay);
    } 
    if (i % DOT_WITH_NEW_LINE_FREQ == 0) System.out.println("");
  } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: channel, release
 
        // must call super 
        super.releaseExclusiveReadLock(operations, file, exchange);
 
        if (lock != null) {
            Channel channel = lock.channel();
            try { 
                lock.release();
            } finally { 
                // must close channel first 
                IOHelper.close(channel, "while releasing exclusive read lock for file: " + lockFileName, LOG);
            } 
        } 
    } 
 
    private boolean sleep() { 
        LOG.trace("Exclusive read lock not granted. Sleeping for {} millis.", checkInterval);
        try { 
            Thread.sleep(checkInterval);
            return false; 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 FileLock Questions & Answers:

See Code Examples for Java 8 FileLock Methods: