|
@@ -26,7 +26,9 @@ import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.PrintWriter;
|
|
|
+import java.net.InetSocketAddress;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
@@ -46,12 +48,17 @@ import org.apache.hadoop.security.UserGroupInformation;
|
|
|
import org.apache.hadoop.security.authorize.AccessControlList;
|
|
|
import org.apache.hadoop.security.authorize.ProxyUsers;
|
|
|
import org.apache.hadoop.security.authorize.ServiceAuthorizationManager;
|
|
|
+import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
|
|
|
+import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodeLabelsRequest;
|
|
|
+import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodeLabelsResponse;
|
|
|
import org.apache.hadoop.yarn.api.records.DecommissionType;
|
|
|
import org.apache.hadoop.yarn.api.records.NodeId;
|
|
|
+import org.apache.hadoop.yarn.api.records.NodeLabel;
|
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
|
import org.apache.hadoop.yarn.conf.HAUtil;
|
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
|
|
+import org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsRequest;
|
|
|
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsRequest;
|
|
|
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshClusterMaxPriorityRequest;
|
|
|
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesRequest;
|
|
@@ -62,6 +69,7 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshSuperUserGroupsC
|
|
|
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshUserToGroupsMappingsRequest;
|
|
|
import org.apache.hadoop.yarn.server.api.protocolrecords.RemoveFromClusterNodeLabelsRequest;
|
|
|
import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeRequest;
|
|
|
+import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.AddToClusterNodeLabelsRequestPBImpl;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.resource.DynamicResourceConfiguration;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
|
|
@@ -79,6 +87,9 @@ import org.junit.Test;
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
import com.google.common.collect.ImmutableSet;
|
|
|
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
|
|
+import org.apache.hadoop.yarn.ipc.YarnRPC;
|
|
|
+import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AddToClusterNodeLabelsRequestProto;
|
|
|
+
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
|
public class TestRMAdminService {
|
|
@@ -1463,4 +1474,52 @@ public class TestRMAdminService {
|
|
|
e.getMessage().startsWith(HAUtil.BAD_CONFIG_MESSAGE_PREFIX));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Test(timeout = 30000)
|
|
|
+ public void testAdminAddToClusterNodeLabelsWithDeprecatedAPIs()
|
|
|
+ throws Exception, YarnException {
|
|
|
+ configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
|
|
+ "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
|
|
+
|
|
|
+ uploadDefaultConfiguration();
|
|
|
+
|
|
|
+ rm = new MockRM(configuration) {
|
|
|
+ protected ClientRMService createClientRMService() {
|
|
|
+ return new ClientRMService(this.rmContext, scheduler, this.rmAppManager,
|
|
|
+ this.applicationACLsManager, this.queueACLsManager,
|
|
|
+ this.getRMContext().getRMDelegationTokenSecretManager());
|
|
|
+ };
|
|
|
+ };
|
|
|
+ rm.init(configuration);
|
|
|
+ rm.start();
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<String> list = new ArrayList<String>();
|
|
|
+ list.add("a");
|
|
|
+ list.add("b");
|
|
|
+ AddToClusterNodeLabelsRequestProto proto = AddToClusterNodeLabelsRequestProto
|
|
|
+ .newBuilder().addAllDeprecatedNodeLabels(list).build();
|
|
|
+ AddToClusterNodeLabelsRequestPBImpl protoImpl = new AddToClusterNodeLabelsRequestPBImpl(
|
|
|
+ proto);
|
|
|
+ rm.adminService
|
|
|
+ .addToClusterNodeLabels((AddToClusterNodeLabelsRequest) protoImpl);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ fail("Could not update node labels." + ex);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Create a client.
|
|
|
+ Configuration conf = new Configuration();
|
|
|
+ YarnRPC rpc = YarnRPC.create(conf);
|
|
|
+ InetSocketAddress rmAddress = rm.getClientRMService().getBindAddress();
|
|
|
+ ApplicationClientProtocol client = (ApplicationClientProtocol) rpc
|
|
|
+ .getProxy(ApplicationClientProtocol.class, rmAddress, conf);
|
|
|
+
|
|
|
+ // Get node labels collection
|
|
|
+ GetClusterNodeLabelsResponse response = client
|
|
|
+ .getClusterNodeLabels(GetClusterNodeLabelsRequest.newInstance());
|
|
|
+ NodeLabel labelX = NodeLabel.newInstance("a");
|
|
|
+ NodeLabel labelY = NodeLabel.newInstance("b");
|
|
|
+ Assert.assertTrue(
|
|
|
+ response.getNodeLabelList().containsAll(Arrays.asList(labelX, labelY)));
|
|
|
+ }
|
|
|
}
|