Search in sources :

Example 1 with RefreshUserMappingsProtocol

use of org.apache.hadoop.security.RefreshUserMappingsProtocol in project hadoop by apache.

the class HSAdmin method refreshSuperUserGroupsConfiguration.

private int refreshSuperUserGroupsConfiguration() throws IOException {
    // Refresh the super-user groups
    Configuration conf = getConf();
    InetSocketAddress address = conf.getSocketAddr(JHAdminConfig.JHS_ADMIN_ADDRESS, JHAdminConfig.DEFAULT_JHS_ADMIN_ADDRESS, JHAdminConfig.DEFAULT_JHS_ADMIN_PORT);
    RefreshUserMappingsProtocol refreshProtocol = HSProxies.createProxy(conf, address, RefreshUserMappingsProtocol.class, UserGroupInformation.getCurrentUser());
    // Refresh the super-user group mappings
    refreshProtocol.refreshSuperUserGroupsConfiguration();
    return 0;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) InetSocketAddress(java.net.InetSocketAddress) RefreshUserMappingsProtocol(org.apache.hadoop.security.RefreshUserMappingsProtocol)

Example 2 with RefreshUserMappingsProtocol

use of org.apache.hadoop.security.RefreshUserMappingsProtocol in project hadoop by apache.

the class HSAdmin method refreshUserToGroupsMappings.

private int refreshUserToGroupsMappings() throws IOException {
    // Get the current configuration
    Configuration conf = getConf();
    InetSocketAddress address = conf.getSocketAddr(JHAdminConfig.JHS_ADMIN_ADDRESS, JHAdminConfig.DEFAULT_JHS_ADMIN_ADDRESS, JHAdminConfig.DEFAULT_JHS_ADMIN_PORT);
    RefreshUserMappingsProtocol refreshProtocol = HSProxies.createProxy(conf, address, RefreshUserMappingsProtocol.class, UserGroupInformation.getCurrentUser());
    // Refresh the user-to-groups mappings
    refreshProtocol.refreshUserToGroupsMappings();
    return 0;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) InetSocketAddress(java.net.InetSocketAddress) RefreshUserMappingsProtocol(org.apache.hadoop.security.RefreshUserMappingsProtocol)

Example 3 with RefreshUserMappingsProtocol

use of org.apache.hadoop.security.RefreshUserMappingsProtocol in project hadoop by apache.

the class DFSAdmin method refreshUserToGroupsMappings.

/**
   * Refresh the user-to-groups mappings on the {@link NameNode}.
   * @return exitcode 0 on success, non-zero on failure
   * @throws IOException
   */
public int refreshUserToGroupsMappings() 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 refreshUserToGroupsMapings for all NNs if HA is enabled
        String nsId = dfsUri.getHost();
        List<ProxyAndInfo<RefreshUserMappingsProtocol>> proxies = HAUtil.getProxiesForAllNameNodesInNameservice(conf, nsId, RefreshUserMappingsProtocol.class);
        for (ProxyAndInfo<RefreshUserMappingsProtocol> proxy : proxies) {
            proxy.getProxy().refreshUserToGroupsMappings();
            System.out.println("Refresh user to groups mapping successful for " + proxy.getAddress());
        }
    } else {
        // Create the client
        RefreshUserMappingsProtocol refreshProtocol = NameNodeProxies.createProxy(conf, FileSystem.getDefaultUri(conf), RefreshUserMappingsProtocol.class).getProxy();
        // Refresh the user-to-groups mappings
        refreshProtocol.refreshUserToGroupsMappings();
        System.out.println("Refresh user to groups mapping successful");
    }
    return 0;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) ProxyAndInfo(org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo) RefreshUserMappingsProtocol(org.apache.hadoop.security.RefreshUserMappingsProtocol) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) URI(java.net.URI)

Example 4 with RefreshUserMappingsProtocol

use of org.apache.hadoop.security.RefreshUserMappingsProtocol in project hadoop by apache.

the class DFSAdmin method refreshSuperUserGroupsConfiguration.

/**
   * refreshSuperUserGroupsConfiguration {@link NameNode}.
   * @return exitcode 0 on success, non-zero on failure
   * @throws IOException
   */
public int refreshSuperUserGroupsConfiguration() throws IOException {
    // Get the current configuration
    Configuration conf = getConf();
    // for security authorization
    // server principal for this call 
    // should be NAMENODE'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 refreshSuperUserGroupsConfiguration for all NNs if HA is enabled
        String nsId = dfsUri.getHost();
        List<ProxyAndInfo<RefreshUserMappingsProtocol>> proxies = HAUtil.getProxiesForAllNameNodesInNameservice(conf, nsId, RefreshUserMappingsProtocol.class);
        for (ProxyAndInfo<RefreshUserMappingsProtocol> proxy : proxies) {
            proxy.getProxy().refreshSuperUserGroupsConfiguration();
            System.out.println("Refresh super user groups configuration " + "successful for " + proxy.getAddress());
        }
    } else {
        // Create the client
        RefreshUserMappingsProtocol refreshProtocol = NameNodeProxies.createProxy(conf, FileSystem.getDefaultUri(conf), RefreshUserMappingsProtocol.class).getProxy();
        // Refresh the user-to-groups mappings
        refreshProtocol.refreshSuperUserGroupsConfiguration();
        System.out.println("Refresh super user groups configuration successful");
    }
    return 0;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) ProxyAndInfo(org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo) RefreshUserMappingsProtocol(org.apache.hadoop.security.RefreshUserMappingsProtocol) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) URI(java.net.URI)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)4 RefreshUserMappingsProtocol (org.apache.hadoop.security.RefreshUserMappingsProtocol)4 InetSocketAddress (java.net.InetSocketAddress)2 URI (java.net.URI)2 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)2 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)2 ProxyAndInfo (org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo)2