Example usage for org.apache.hadoop.hdfs NameNodeProxies createProxy

List of usage examples for org.apache.hadoop.hdfs NameNodeProxies createProxy

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs NameNodeProxies createProxy.

Prototype

public static <T> ProxyAndInfo<T> createProxy(Configuration conf, URI nameNodeUri, Class<T> xface)
        throws IOException 

Source Link

Document

Creates the namenode proxy with the passed protocol.

Usage

From source file:io.hops.experiments.benchmarks.blockreporting.nn.HadoopNameNodeSelector.java

License:Apache License

HadoopNameNodeSelector(Configuration configuration, URI defaultUri) throws IOException {
    datanodeProto = new DatanodeProtocolClientSideTranslatorPB(NameNode.getAddress(configuration),
            configuration);//w w  w . ja v a2s  .c om
    NameNodeProxies.ProxyAndInfo<ClientProtocol> proxyInfo = NameNodeProxies.createProxy(configuration,
            defaultUri, ClientProtocol.class);
    clientProto = proxyInfo.getProxy();
    host = defaultUri.getHost();
}

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(/*from www.  j  a  v  a  2s  .c  om*/
                "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");
    }
}