Example usage for org.apache.hadoop.hdfs.protocol HdfsConstants LEASE_SOFTLIMIT_PERIOD

List of usage examples for org.apache.hadoop.hdfs.protocol HdfsConstants LEASE_SOFTLIMIT_PERIOD

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.protocol HdfsConstants LEASE_SOFTLIMIT_PERIOD.

Prototype

long LEASE_SOFTLIMIT_PERIOD

To view the source code for org.apache.hadoop.hdfs.protocol HdfsConstants LEASE_SOFTLIMIT_PERIOD.

Click Source Link

Document

For a HDFS client to write to a file, a lease is granted; During the lease period, no other client can write to the file.

Usage

From source file:com.mellanox.r4h.LeaseRenewer.java

License:Apache License

/** Close the given client. */
synchronized void closeClient(final DFSClient dfsc) {
    dfsclients.remove(dfsc);//from  w  w  w  .j  a v a2  s.  com
    if (dfsclients.isEmpty()) {
        if (!isRunning() || isRenewerExpired()) {
            Factory.INSTANCE.remove(LeaseRenewer.this);
            return;
        }
        if (emptyTime == Long.MAX_VALUE) {
            // discover the first time that the client list is empty.
            emptyTime = Time.monotonicNow();
        }
    }

    // update renewal time
    if (renewal == dfsc.getHdfsTimeout() / 2) {
        long min = HdfsConstants.LEASE_SOFTLIMIT_PERIOD;
        for (DFSClient c : dfsclients) {
            if (c.getHdfsTimeout() > 0) {
                final long timeout = c.getHdfsTimeout();
                if (timeout < min) {
                    min = timeout;
                }
            }
        }
        renewal = min / 2;
    }
}