Search in sources :

Example 1 with RefreshCallQueueProtocol

use of org.apache.hadoop.ipc.RefreshCallQueueProtocol in project hadoop by apache.

the class DFSAdmin method refreshCallQueue.

public int refreshCallQueue() throws IOException {
    // Get the current configuration
    Configuration conf = getConf();
    // for security authorization
    // server principal for this call   
    // should be NN's one.
    conf.set(CommonConfigurationKeys.HADOOP_SECURITY_SERVICE_USER_NAME_KEY, conf.get(DFSConfigKeys.DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY, ""));
    DistributedFileSystem dfs = getDFS();
    URI dfsUri = dfs.getUri();
    boolean isHaEnabled = HAUtilClient.isLogicalUri(conf, dfsUri);
    if (isHaEnabled) {
        // Run refreshCallQueue for all NNs if HA is enabled
        String nsId = dfsUri.getHost();
        List<ProxyAndInfo<RefreshCallQueueProtocol>> proxies = HAUtil.getProxiesForAllNameNodesInNameservice(conf, nsId, RefreshCallQueueProtocol.class);
        for (ProxyAndInfo<RefreshCallQueueProtocol> proxy : proxies) {
            proxy.getProxy().refreshCallQueue();
            System.out.println("Refresh call queue successful for " + proxy.getAddress());
        }
    } else {
        // Create the client
        RefreshCallQueueProtocol refreshProtocol = NameNodeProxies.createProxy(conf, FileSystem.getDefaultUri(conf), RefreshCallQueueProtocol.class).getProxy();
        // Refresh the call queue
        refreshProtocol.refreshCallQueue();
        System.out.println("Refresh call queue successful");
    }
    return 0;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) ProxyAndInfo(org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) URI(java.net.URI) RefreshCallQueueProtocol(org.apache.hadoop.ipc.RefreshCallQueueProtocol)

Aggregations

URI (java.net.URI)1 Configuration (org.apache.hadoop.conf.Configuration)1 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)1 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)1 ProxyAndInfo (org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo)1 RefreshCallQueueProtocol (org.apache.hadoop.ipc.RefreshCallQueueProtocol)1