use of org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsResponse in project hadoop by apache.
the class AdminService method addToClusterNodeLabels.
@Override
public AddToClusterNodeLabelsResponse addToClusterNodeLabels(AddToClusterNodeLabelsRequest request) throws YarnException, IOException {
final String operation = "addToClusterNodeLabels";
final String msg = "add labels.";
UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), operation, msg);
AddToClusterNodeLabelsResponse response = recordFactory.newRecordInstance(AddToClusterNodeLabelsResponse.class);
try {
rmContext.getNodeLabelManager().addToCluserNodeLabels(request.getNodeLabels());
RMAuditLogger.logSuccess(user.getShortUserName(), operation, "AdminService");
return response;
} catch (IOException ioe) {
throw logAndWrapException(ioe, user.getShortUserName(), operation, msg);
}
}
use of org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsResponse 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;
}
};
}
Aggregations