Example usage for org.apache.hadoop.hdfs.security.token.block ExportedBlockKeys getTokenLifetime

List of usage examples for org.apache.hadoop.hdfs.security.token.block ExportedBlockKeys getTokenLifetime

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.security.token.block ExportedBlockKeys getTokenLifetime.

Prototype

public long getTokenLifetime() 

Source Link

Usage

From source file:mzb.NameNodeConnector.java

License:Apache License

NameNodeConnector(URI nameNodeUri, Configuration conf) throws IOException {
    this.nameNodeUri = nameNodeUri;

    this.namenode = NameNodeProxies.createProxy(conf, nameNodeUri, NamenodeProtocol.class).getProxy();
    this.client = NameNodeProxies.createProxy(conf, nameNodeUri, ClientProtocol.class).getProxy();
    this.fs = FileSystem.get(nameNodeUri, conf);

    final NamespaceInfo namespaceinfo = namenode.versionRequest();
    this.blockpoolID = namespaceinfo.getBlockPoolID();

    final ExportedBlockKeys keys = namenode.getBlockKeys();
    this.isBlockTokenEnabled = keys.isBlockTokenEnabled();
    if (isBlockTokenEnabled) {
        long blockKeyUpdateInterval = keys.getKeyUpdateInterval();
        long blockTokenLifetime = keys.getTokenLifetime();
        LOG.info(// w  ww . j a  va 2 s  . co  m
                "Block token params received from NN: keyUpdateInterval=" + blockKeyUpdateInterval / (60 * 1000)
                        + " min(s), tokenLifetime=" + blockTokenLifetime / (60 * 1000) + " min(s)");
        String encryptionAlgorithm = conf.get(DFSConfigKeys.DFS_DATA_ENCRYPTION_ALGORITHM_KEY);
        this.blockTokenSecretManager = new BlockTokenSecretManager(blockKeyUpdateInterval, blockTokenLifetime,
                blockpoolID, encryptionAlgorithm);
        this.blockTokenSecretManager.addKeys(keys);
        /*
         * Balancer should sync its block keys with NN more frequently than NN
         * updates its block keys
         */
        this.keyUpdaterInterval = blockKeyUpdateInterval / 4;
        LOG.info(
                "Balancer will update its block keys every " + keyUpdaterInterval / (60 * 1000) + " minute(s)");
        this.keyupdaterthread = new Daemon(new BlockKeyUpdater());
        this.shouldRun = true;
        this.keyupdaterthread.start();
    }
    this.encryptDataTransfer = fs.getServerDefaults(new Path("/")).getEncryptDataTransfer();
    // Check if there is another balancer running.
    // Exit if there is another one running.
    out = checkAndMarkRunningBalancer();
    if (out == null) {
        throw new IOException("Another balancer is running");
    }
}