Search in sources :

Example 11 with ResourceManagerAdministrationProtocol

use of org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol in project hadoop by apache.

the class RMAdminCLI method refreshUserToGroupsMappings.

private int refreshUserToGroupsMappings() throws IOException, YarnException {
    // Refresh the user-to-groups mappings
    ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
    RefreshUserToGroupsMappingsRequest request = recordFactory.newRecordInstance(RefreshUserToGroupsMappingsRequest.class);
    adminProtocol.refreshUserToGroupsMappings(request);
    return 0;
}
Also used : ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol) RefreshUserToGroupsMappingsRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RefreshUserToGroupsMappingsRequest)

Example 12 with ResourceManagerAdministrationProtocol

use of org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol in project hadoop by apache.

the class TestRMAdminCLI method configure.

@SuppressWarnings("static-access")
@Before
public void configure() throws IOException, YarnException {
    remoteAdminServiceAccessed = false;
    admin = mock(ResourceManagerAdministrationProtocol.class);
    when(admin.addToClusterNodeLabels(any(AddToClusterNodeLabelsRequest.class))).thenAnswer(new Answer<AddToClusterNodeLabelsResponse>() {

        @Override
        public AddToClusterNodeLabelsResponse answer(InvocationOnMock invocation) throws Throwable {
            remoteAdminServiceAccessed = true;
            return AddToClusterNodeLabelsResponse.newInstance();
        }
    });
    haadmin = mock(HAServiceProtocol.class);
    when(haadmin.getServiceStatus()).thenReturn(new HAServiceStatus(HAServiceProtocol.HAServiceState.INITIALIZING));
    final HAServiceTarget haServiceTarget = mock(HAServiceTarget.class);
    when(haServiceTarget.getProxy(any(Configuration.class), anyInt())).thenReturn(haadmin);
    rmAdminCLI = new RMAdminCLI(new Configuration()) {

        @Override
        protected ResourceManagerAdministrationProtocol createAdminProtocol() throws IOException {
            return admin;
        }

        @Override
        protected HAServiceTarget resolveTarget(String rmId) {
            return haServiceTarget;
        }
    };
    initDummyNodeLabelsManager();
    rmAdminCLI.localNodeLabelsManager = dummyNodeLabelsManager;
    YarnConfiguration conf = new YarnConfiguration();
    conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
    conf.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2");
    conf.set(HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS, "rm1"), HOST_A + ":12345");
    conf.set(HAUtil.addSuffix(YarnConfiguration.RM_ADMIN_ADDRESS, "rm1"), HOST_A + ":12346");
    conf.set(HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS, "rm2"), HOST_B + ":12345");
    conf.set(HAUtil.addSuffix(YarnConfiguration.RM_ADMIN_ADDRESS, "rm2"), HOST_B + ":12346");
    rmAdminCLIWithHAEnabled = new RMAdminCLI(conf) {

        @Override
        protected ResourceManagerAdministrationProtocol createAdminProtocol() throws IOException {
            return admin;
        }

        @Override
        protected HAServiceTarget resolveTarget(String rmId) {
            HAServiceTarget target = super.resolveTarget(rmId);
            HAServiceTarget spy = Mockito.spy(target);
            // Override the target to return our mock protocol
            try {
                Mockito.doReturn(haadmin).when(spy).getProxy(Mockito.<Configuration>any(), Mockito.anyInt());
                Mockito.doReturn(false).when(spy).isAutoFailoverEnabled();
            } catch (IOException e) {
                // mock setup doesn't really throw
                throw new AssertionError(e);
            }
            return spy;
        }
    };
}
Also used : AddToClusterNodeLabelsResponse(org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsResponse) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) HAServiceTarget(org.apache.hadoop.ha.HAServiceTarget) IOException(java.io.IOException) ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol) HAServiceProtocol(org.apache.hadoop.ha.HAServiceProtocol) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) InvocationOnMock(org.mockito.invocation.InvocationOnMock) AddToClusterNodeLabelsRequest(org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsRequest) HAServiceStatus(org.apache.hadoop.ha.HAServiceStatus) Before(org.junit.Before)

Example 13 with ResourceManagerAdministrationProtocol

use of org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol in project hadoop by apache.

the class RMAdminCLI method refreshSuperUserGroupsConfiguration.

private int refreshSuperUserGroupsConfiguration() throws IOException, YarnException {
    // Refresh the super-user groups
    ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
    RefreshSuperUserGroupsConfigurationRequest request = recordFactory.newRecordInstance(RefreshSuperUserGroupsConfigurationRequest.class);
    adminProtocol.refreshSuperUserGroupsConfiguration(request);
    return 0;
}
Also used : ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol) RefreshSuperUserGroupsConfigurationRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RefreshSuperUserGroupsConfigurationRequest)

Example 14 with ResourceManagerAdministrationProtocol

use of org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol in project hadoop by apache.

the class RMAdminCLI method refreshNodes.

private int refreshNodes(boolean graceful) throws IOException, YarnException {
    // Refresh the nodes
    ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
    RefreshNodesRequest request = RefreshNodesRequest.newInstance(graceful ? DecommissionType.GRACEFUL : DecommissionType.NORMAL);
    adminProtocol.refreshNodes(request);
    return 0;
}
Also used : ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol) RefreshNodesRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesRequest)

Example 15 with ResourceManagerAdministrationProtocol

use of org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol in project hadoop by apache.

the class RMAdminCLI method handleRemoveFromClusterNodeLabels.

private int handleRemoveFromClusterNodeLabels(String[] args, String cmd, boolean isHAEnabled) throws IOException, YarnException, ParseException {
    Options opts = new Options();
    opts.addOption("removeFromClusterNodeLabels", true, "Remove From cluster node labels.");
    opts.addOption("directlyAccessNodeLabelStore", false, "Directly access node label store.");
    int exitCode = -1;
    CommandLine cliParser = null;
    try {
        cliParser = new GnuParser().parse(opts, args);
    } catch (MissingArgumentException ex) {
        System.err.println(NO_LABEL_ERR_MSG);
        printUsage(args[0], isHAEnabled);
        return exitCode;
    }
    Set<String> labels = buildNodeLabelNamesFromStr(cliParser.getOptionValue("removeFromClusterNodeLabels"));
    if (cliParser.hasOption("directlyAccessNodeLabelStore")) {
        getNodeLabelManagerInstance(getConf()).removeFromClusterNodeLabels(labels);
    } else {
        ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
        RemoveFromClusterNodeLabelsRequest request = RemoveFromClusterNodeLabelsRequest.newInstance(labels);
        adminProtocol.removeFromClusterNodeLabels(request);
    }
    return 0;
}
Also used : Options(org.apache.commons.cli.Options) ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol) CommandLine(org.apache.commons.cli.CommandLine) MissingArgumentException(org.apache.commons.cli.MissingArgumentException) GnuParser(org.apache.commons.cli.GnuParser) RemoveFromClusterNodeLabelsRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RemoveFromClusterNodeLabelsRequest)

Aggregations

ResourceManagerAdministrationProtocol (org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol)16 CommandLine (org.apache.commons.cli.CommandLine)2 GnuParser (org.apache.commons.cli.GnuParser)2 MissingArgumentException (org.apache.commons.cli.MissingArgumentException)2 Options (org.apache.commons.cli.Options)2 Configuration (org.apache.hadoop.conf.Configuration)2 NodeId (org.apache.hadoop.yarn.api.records.NodeId)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 AddToClusterNodeLabelsRequest (org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsRequest)2 RefreshNodesRequest (org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesRequest)2 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 HashMap (java.util.HashMap)1 HAServiceProtocol (org.apache.hadoop.ha.HAServiceProtocol)1 HAServiceStatus (org.apache.hadoop.ha.HAServiceStatus)1 HAServiceTarget (org.apache.hadoop.ha.HAServiceTarget)1 NodeLabel (org.apache.hadoop.yarn.api.records.NodeLabel)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1 ResourceOption (org.apache.hadoop.yarn.api.records.ResourceOption)1 YarnRPC (org.apache.hadoop.yarn.ipc.YarnRPC)1