diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/ResourceManagerAdministrationProtocol.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/ResourceManagerAdministrationProtocol.java index 852334245ce..89fdd53578b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/ResourceManagerAdministrationProtocol.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/ResourceManagerAdministrationProtocol.java @@ -32,6 +32,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshClusterMaxPriorityRequest; @@ -144,4 +146,10 @@ public CheckForDecommissioningNodesResponse checkForDecommissioningNodes( public RefreshClusterMaxPriorityResponse refreshClusterMaxPriority( RefreshClusterMaxPriorityRequest request) throws YarnException, IOException; + + @Private + @Idempotent + public PlacementConstraintsOperationResponse operatePlacementConstraints( + PlacementConstraintsOperationRequest request) + throws YarnException, IOException; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/AllocationTagsToPlacementConstraint.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/AllocationTagsToPlacementConstraint.java new file mode 100644 index 00000000000..a3e4d76d57b --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/AllocationTagsToPlacementConstraint.java @@ -0,0 +1,68 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.api.protocolrecords; + +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +import java.util.Set; + +/** + * A set of allocation tags to a placement constraint mapping. + */ +public abstract class AllocationTagsToPlacementConstraint { + + @Public + @Unstable + public static AllocationTagsToPlacementConstraint newInstance( + Set tags, String placementConstraintEpr){ + AllocationTagsToPlacementConstraint constraint = + Records.newRecord(AllocationTagsToPlacementConstraint.class); + constraint.setAllocationTags(tags); + constraint.setPlacementConstraintExpr(placementConstraintEpr); + return constraint; + } + + @Public + @Unstable + public static AllocationTagsToPlacementConstraint newInstance( + Set tags){ + AllocationTagsToPlacementConstraint constraint = + Records.newRecord(AllocationTagsToPlacementConstraint.class); + constraint.setAllocationTags(tags); + return constraint; + } + + @Public + @Unstable + public abstract void setAllocationTags(Set allocationTags); + + @Public + @Unstable + public abstract Set getAllocationTags(); + + @Public + @Unstable + public abstract void setPlacementConstraintExpr(String constraintExpr); + + @Public + @Unstable + public abstract String getPlacementConstraintExpr(); +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/PlacementConstraintsOperationRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/PlacementConstraintsOperationRequest.java new file mode 100644 index 00000000000..ac8740144a9 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/PlacementConstraintsOperationRequest.java @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.api.protocolrecords; + +import org.apache.hadoop.yarn.util.Records; + +import java.util.Set; + +import static org.apache.hadoop.classification.InterfaceAudience.Public; +import static org.apache.hadoop.classification.InterfaceStability.Unstable; + +/** + * Add/remove/list placement constraints request. + */ +public abstract class PlacementConstraintsOperationRequest { + + @Public + @Unstable + public static PlacementConstraintsOperationRequest newInstance( + PlacementConstraintsOperationType opt, + Set allocationTags, String constraintExpr) { + PlacementConstraintsOperationRequest request = + Records.newRecord(PlacementConstraintsOperationRequest.class); + AllocationTagsToPlacementConstraint constraint = + AllocationTagsToPlacementConstraint + .newInstance(allocationTags, constraintExpr); + request.setOperationType(opt); + request.setAllocationTagsToPlacementConstraint(constraint); + return request; + } + + @Public + @Unstable + public static PlacementConstraintsOperationRequest newInstance( + PlacementConstraintsOperationType opt, Set tags) { + PlacementConstraintsOperationRequest request = + Records.newRecord(PlacementConstraintsOperationRequest.class); + AllocationTagsToPlacementConstraint tagsToConstraint = + AllocationTagsToPlacementConstraint.newInstance(tags); + request.setOperationType(opt); + request.setAllocationTagsToPlacementConstraint(tagsToConstraint); + return request; + } + + @Public + @Unstable + public static PlacementConstraintsOperationRequest newInstance( + PlacementConstraintsOperationType opt) { + PlacementConstraintsOperationRequest request = + Records.newRecord(PlacementConstraintsOperationRequest.class); + request.setOperationType(opt); + return request; + } + + public abstract void setOperationType(PlacementConstraintsOperationType opt); + + public abstract PlacementConstraintsOperationType getOperationType(); + + public abstract void setAllocationTagsToPlacementConstraint( + AllocationTagsToPlacementConstraint constraint); + + public abstract AllocationTagsToPlacementConstraint + getAllocationTagsToPlacementConstraint(); +} \ No newline at end of file diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/PlacementConstraintsOperationResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/PlacementConstraintsOperationResponse.java new file mode 100644 index 00000000000..5669efadd61 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/PlacementConstraintsOperationResponse.java @@ -0,0 +1,47 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.api.protocolrecords; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +import java.util.Set; + +/** + * Add/remove/list placement constraints response. + */ +public abstract class PlacementConstraintsOperationResponse { + + @Private + @Unstable + public static PlacementConstraintsOperationResponse newInstance() { + return Records.newRecord(PlacementConstraintsOperationResponse.class); + } + + @Private + @Unstable + public abstract void addAllocationTagsToPlacementConstraint( + AllocationTagsToPlacementConstraint constraint); + + @Private + @Unstable + public abstract Set + getAllAllocationTagsToPlacementConstraints(); +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/PlacementConstraintsOperationType.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/PlacementConstraintsOperationType.java new file mode 100644 index 00000000000..77017aaf929 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/PlacementConstraintsOperationType.java @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.api.protocolrecords; + +/** + * Operations to management global placement constraints. + */ +public enum PlacementConstraintsOperationType { + ADD, + REMOVE, + LIST +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/resourcemanager_administration_protocol.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/resourcemanager_administration_protocol.proto index 113462305cd..339842bfe99 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/resourcemanager_administration_protocol.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/resourcemanager_administration_protocol.proto @@ -45,4 +45,5 @@ service ResourceManagerAdministrationProtocolService { rpc replaceLabelsOnNodes(ReplaceLabelsOnNodeRequestProto) returns (ReplaceLabelsOnNodeResponseProto); rpc checkForDecommissioningNodes(CheckForDecommissioningNodesRequestProto) returns (CheckForDecommissioningNodesResponseProto); rpc refreshClusterMaxPriority(RefreshClusterMaxPriorityRequestProto) returns (RefreshClusterMaxPriorityResponseProto); + rpc operatePlacementConstraints(PlacementConstraintsOperationRequestProto) returns (PlacementConstraintsOperationResponseProto); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/yarn_server_resourcemanager_service_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/yarn_server_resourcemanager_service_protos.proto index e8c92d962f3..dfde98f26bc 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/yarn_server_resourcemanager_service_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/yarn_server_resourcemanager_service_protos.proto @@ -130,6 +130,26 @@ enum DecommissionTypeProto { GRACEFUL = 2; FORCEFUL = 3; } + +message PlacementConstraintsOperationRequestProto { + enum OptType { + ADD = 1; + REMOVE = 2; + LIST = 3; + } + + required OptType operationType = 1; + optional AllocationTagsToPlacementConstraintExpressionProto constraint = 2; +} + +message AllocationTagsToPlacementConstraintExpressionProto { + repeated string allocationTags = 1; + optional string placementConstraintExpression = 2; +} + +message PlacementConstraintsOperationResponseProto { + repeated AllocationTagsToPlacementConstraintExpressionProto constraints = 1; +} ////////////////////////////////////////////////////////////////// ///////////// RM Failover related records //////////////////////// ////////////////////////////////////////////////////////////////// diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java index 027a786db33..187753cfad8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.GnuParser; @@ -65,6 +66,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationType; 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; @@ -169,6 +172,10 @@ + " \n\t\tor\n\t\t[NodeID] [resourcetypes] " + "([OvercommitTimeout]). ", "Update resource on specific node.")) + .put("-placementConstraint", + new UsageInfo("[-add -t -c " + + " | -remove | -list]", "Add/remove/list" + + " global placement constraints")) .build(); public RMAdminCLI() { @@ -290,7 +297,10 @@ private static void printHelp(String cmd, boolean isHAEnabled) { + " [-refreshClusterMaxPriority]" + " [-updateNodeResource [NodeID] [MemSize] [vCores]" + " ([OvercommitTimeout]) or -updateNodeResource [NodeID] " - + "[ResourceTypes] ([OvercommitTimeout])]"); + + "[ResourceTypes] ([OvercommitTimeout])]" + + " [-placementConstraint [[-add -t -c ] | " + + "[-remove -t ]" + + " | [-list]]"); if (isHAEnabled) { appendHAUsage(summary); } @@ -841,6 +851,8 @@ public int run(String[] args) throws Exception { exitCode = handleRemoveFromClusterNodeLabels(args, cmd, isHAEnabled); } else if ("-replaceLabelsOnNode".equals(cmd)) { exitCode = handleReplaceLabelsOnNodes(args, cmd, isHAEnabled); + } else if ("-placementConstraint".equals(cmd)) { + exitCode = handlePlacementConstraints(args, cmd, isHAEnabled); } else { exitCode = -1; System.err.println(cmd.substring(1) + ": Unknown command"); @@ -979,6 +991,115 @@ private int handleUpdateNodeResource( return updateNodeResource(nodeID, resource, overCommitTimeout); } + private int handlePlacementConstraints(String[] args, String cmd, + boolean isHAEnabled) throws ParseException, IOException, YarnException { + if (args.length <= 1) { + printUsage(cmd, isHAEnabled); + } + String[] subArgs = Arrays.copyOfRange(args, 1, args.length); + + Options opts = new Options(); + Option addOpt = new Option("add", + false, "Add a placement constraint."); + Option removeOpt = new Option("remove", + false, "Remove a placement constraint."); + Option listOpt = new Option("list", + false, "List all placement constraints."); + opts.addOption(addOpt); + opts.addOption(removeOpt); + opts.addOption(listOpt); + + Option tagsOpt = new Option("t", true, + "Allocation tags mapping to the placement constraint."); + tagsOpt.setType(String.class); + Option pcExprOpt = new Option("c", true, + "Placement constraint expression."); + pcExprOpt.setType(String.class); + opts.addOption(tagsOpt); + opts.addOption(pcExprOpt); + + int exitCode = -1; + CommandLine cliParser; + try { + cliParser = new GnuParser().parse(opts, subArgs); + } catch (MissingArgumentException ex) { + printUsage(cmd, isHAEnabled); + return exitCode; + } + + if (cliParser.hasOption("add")) { + // both tags and pc are required. + if (!cliParser.hasOption("t") || !cliParser.hasOption("c")) { + System.err + .println("Option -t and -c are required to run this command."); + printUsage(cmd, isHAEnabled); + return exitCode; + } + + String tags = cliParser.getOptionValue("t"); + Set allocationTags = getAllocationTags(tags); + String pcStr = cliParser.getOptionValue("c"); + return addGlobalPlacementConstraint(allocationTags, pcStr); + } else if (cliParser.hasOption("remove")) { + if (!cliParser.hasOption("t")) { + System.err + .println("Option -t is required to run this command."); + printUsage(cmd, isHAEnabled); + return exitCode; + } + + String tags = cliParser.getOptionValue("t"); + Set toRemoveTags = getAllocationTags(tags); + return removeGlobalPlacementConstraint(toRemoveTags); + } else if (cliParser.hasOption("list")) { + listGlobalPlacementConstraints(); + return 0; + } else { + System.err + .println("No valid option found in this command."); + printUsage(cmd, isHAEnabled); + return exitCode; + } + } + + private Set getAllocationTags(String tagsStr) { + String[] tagStrs = tagsStr.split(","); + Set allocationTags = + Arrays.stream(tagStrs).map(String::trim).collect(Collectors.toSet()); + return allocationTags; + } + + private int addGlobalPlacementConstraint(Set tags, + String constraintExpr) throws IOException, YarnException { + ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol(); + PlacementConstraintsOperationRequest addReq = + PlacementConstraintsOperationRequest + .newInstance(PlacementConstraintsOperationType.ADD, + tags, constraintExpr); + adminProtocol.operatePlacementConstraints(addReq); + return 0; + } + + private int removeGlobalPlacementConstraint(Set tags) + throws IOException, YarnException { + ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol(); + PlacementConstraintsOperationRequest rmReq = + PlacementConstraintsOperationRequest + .newInstance(PlacementConstraintsOperationType.REMOVE, tags); + adminProtocol.operatePlacementConstraints(rmReq); + return 0; + } + + private int listGlobalPlacementConstraints() throws IOException, + YarnException { + ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol(); + PlacementConstraintsOperationRequest lsReq = + PlacementConstraintsOperationRequest + .newInstance(PlacementConstraintsOperationType.LIST); + adminProtocol.operatePlacementConstraints(lsReq); + return 0; + } + private Resource parseCommandAndCreateResource(String resourceTypes) { Resource resource = Resource.newInstance(0, 0); Map resourceTypesFromRM = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java index 1f4b493f457..39745ee8360 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java @@ -65,6 +65,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; 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; @@ -136,6 +138,17 @@ public AddToClusterNodeLabelsResponse answer( } }); + when(admin.operatePlacementConstraints( + any(PlacementConstraintsOperationRequest.class))) + .thenAnswer(new Answer() { + @Override + public PlacementConstraintsOperationResponse answer( + InvocationOnMock invocationOnMock) throws Throwable { + remoteAdminServiceAccessed = true; + return PlacementConstraintsOperationResponse.newInstance(); + } + }); + haadmin = mock(HAServiceProtocol.class); when(haadmin.getServiceStatus()).thenReturn(new HAServiceStatus( HAServiceProtocol.HAServiceState.INITIALIZING)); @@ -707,6 +720,8 @@ public void testHelp() throws Exception { "[-updateNodeResource [NodeID] [MemSize] [vCores] " + "([OvercommitTimeout]) or -updateNodeResource " + "[NodeID] [ResourceTypes] ([OvercommitTimeout])] " + + "[-placementConstraint [[-add -t -c ] | " + + "[-remove -t ] | [-list]] " + "[-help [cmd]]")); assertTrue(dataOut .toString() @@ -780,7 +795,10 @@ public void testHelp() throws Exception { "[-failover [--forcefence] [--forceactive] " + " ]", dataErr, 0); - + testError(new String[] {"-help", "-placementConstraint"}, + "Usage: yarn rmadmin [-placementConstraint [-add -t -c" + + " | -remove | -list]]", + dataErr, 0); testError(new String[] { "-help", "-badParameter" }, "Usage: yarn rmadmin", dataErr, 0); testError(new String[] { "-badParameter" }, @@ -805,6 +823,8 @@ public void testHelp() throws Exception { + "([OvercommitTimeout]) " + "or -updateNodeResource [NodeID] [ResourceTypes] " + "([OvercommitTimeout])] " + + "[-placementConstraint [[-add -t -c ] | " + + "[-remove -t ] | [-list]] " + "[-transitionToActive [--forceactive] ] " + "[-transitionToStandby ] " + "[-getServiceState ] [-getAllServiceState] " @@ -1072,4 +1092,53 @@ public void testRMHAErrorUsage() throws Exception { } } + @Test + public void testPlacementConstraints() throws Exception { + // Missing args for placement + assertEquals(-1, rmAdminCLI.run(new String[] {"-placement"})); + + // Missing args for add + assertEquals(-1, rmAdminCLI.run(new String[] {"-placement", "-add"})); + + // Valid add + assertEquals(0, rmAdminCLI.run(new String[] { + "-placementConstraint", + "-add", + "-c", "notin,node,foo", + "-t", "foo, bar" + })); + + // Invalid add, missing -c + assertEquals(-1, rmAdminCLI.run(new String[] { + "-placementConstraint", + "-add", + "-t", "foo, bar" + })); + + // Invalid add, missing -t + assertEquals(-1, rmAdminCLI.run(new String[] { + "-placementConstraint", + "-add", + "-c", "notin,node,foo" + })); + + // Valid remove + assertEquals(0, rmAdminCLI.run(new String[] { + "-placementConstraint", + "-remove", + "-t", "foo, bar" + })); + + // Invalid remove, missing -t + assertEquals(-1, rmAdminCLI.run(new String[] { + "-placementConstraint", + "-remove" + })); + + // Valid list + assertEquals(0, rmAdminCLI.run(new String[] { + "-placementConstraint", + "-list" + })); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/impl/pb/client/ResourceManagerAdministrationProtocolPBClientImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/impl/pb/client/ResourceManagerAdministrationProtocolPBClientImpl.java index 077edf34900..2e064e342c1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/impl/pb/client/ResourceManagerAdministrationProtocolPBClientImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/impl/pb/client/ResourceManagerAdministrationProtocolPBClientImpl.java @@ -33,6 +33,7 @@ import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.CheckForDecommissioningNodesRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.GetGroupsForUserRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.GetGroupsForUserResponseProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshAdminAclsRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshClusterMaxPriorityRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshNodesRequestProto; @@ -50,6 +51,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshClusterMaxPriorityRequest; @@ -98,6 +101,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.UpdateNodeResourceResponsePBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.RefreshNodesResourcesRequestPBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.RefreshNodesResourcesResponsePBImpl; +import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.PlacementConstraintsOperationResponsePBImpl; +import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.PlacementConstraintsOperationRequestPBImpl; import com.google.protobuf.ServiceException; @@ -323,4 +328,19 @@ public RefreshClusterMaxPriorityResponse refreshClusterMaxPriority( return null; } } + + @Override + public PlacementConstraintsOperationResponse operatePlacementConstraints( + PlacementConstraintsOperationRequest request) + throws YarnException, IOException { + PlacementConstraintsOperationRequestProto requestProto = + ((PlacementConstraintsOperationRequestPBImpl) request).getProto(); + try { + return new PlacementConstraintsOperationResponsePBImpl( + proxy.operatePlacementConstraints(null, requestProto)); + } catch (ServiceException e) { + RPCUtil.unwrapAndThrowException(e); + return null; + } + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/impl/pb/service/ResourceManagerAdministrationProtocolPBServiceImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/impl/pb/service/ResourceManagerAdministrationProtocolPBServiceImpl.java index aafce0875e7..f2679c518aa 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/impl/pb/service/ResourceManagerAdministrationProtocolPBServiceImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/impl/pb/service/ResourceManagerAdministrationProtocolPBServiceImpl.java @@ -50,6 +50,8 @@ import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.UpdateNodeResourceResponseProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshNodesResourcesRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshNodesResourcesResponseProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationRequestProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationResponseProto; import org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol; import org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocolPB; import org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsResponse; @@ -67,6 +69,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.RemoveFromClusterNodeLabelsResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.AddToClusterNodeLabelsRequestPBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.AddToClusterNodeLabelsResponsePBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.CheckForDecommissioningNodesRequestPBImpl; @@ -93,6 +97,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.UpdateNodeResourceResponsePBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.RefreshNodesResourcesRequestPBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.RefreshNodesResourcesResponsePBImpl; +import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.PlacementConstraintsOperationRequestPBImpl; +import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.PlacementConstraintsOperationResponsePBImpl; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; @@ -336,4 +342,23 @@ public RefreshClusterMaxPriorityResponseProto refreshClusterMaxPriority( throw new ServiceException(e); } } + + @Override + public PlacementConstraintsOperationResponseProto operatePlacementConstraints( + RpcController controller, + PlacementConstraintsOperationRequestProto proto) + throws ServiceException { + PlacementConstraintsOperationRequest request = + new PlacementConstraintsOperationRequestPBImpl(proto); + try { + PlacementConstraintsOperationResponse response = + real.operatePlacementConstraints(request); + return ((PlacementConstraintsOperationResponsePBImpl) response) + .getProto(); + } catch (YarnException e) { + throw new ServiceException(e); + } catch (IOException e) { + throw new ServiceException(e); + } + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/AllocationTagsToPlacementConstraintPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/AllocationTagsToPlacementConstraintPBImpl.java new file mode 100644 index 00000000000..0f905669007 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/AllocationTagsToPlacementConstraintPBImpl.java @@ -0,0 +1,111 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb; + +import com.google.common.collect.Sets; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AllocationTagsToPlacementConstraintExpressionProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AllocationTagsToPlacementConstraintExpressionProto.Builder; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AllocationTagsToPlacementConstraintExpressionProtoOrBuilder; +import org.apache.hadoop.yarn.server.api.protocolrecords.AllocationTagsToPlacementConstraint; + +import java.util.Set; + +/** + * A set of allocation tags to a placement constraint protobuf implementation. + */ +public class AllocationTagsToPlacementConstraintPBImpl extends + AllocationTagsToPlacementConstraint { + + private AllocationTagsToPlacementConstraintExpressionProto proto = + AllocationTagsToPlacementConstraintExpressionProto.getDefaultInstance(); + private Builder builder = null; + private boolean viaProto = false; + + public AllocationTagsToPlacementConstraintPBImpl() { + builder = AllocationTagsToPlacementConstraintExpressionProto.newBuilder(); + } + + public AllocationTagsToPlacementConstraintPBImpl( + AllocationTagsToPlacementConstraintExpressionProto tcProto) { + if (tcProto != null) { + this.proto = tcProto; + } + this.viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = AllocationTagsToPlacementConstraintExpressionProto + .newBuilder(proto); + } + viaProto = false; + } + + @Override + public void setAllocationTags(Set allocationTags) { + maybeInitBuilder(); + if (allocationTags != null) { + builder.addAllAllocationTags(allocationTags); + } + } + + @Override + public Set getAllocationTags() { + AllocationTagsToPlacementConstraintExpressionProtoOrBuilder p = + viaProto ? proto : builder; + return Sets.newHashSet(p.getAllocationTagsList()); + } + + @Override + public void setPlacementConstraintExpr(String constraintExpr) { + maybeInitBuilder(); + if (constraintExpr != null) { + builder.setPlacementConstraintExpression(constraintExpr); + } + } + + @Override + public String getPlacementConstraintExpr() { + AllocationTagsToPlacementConstraintExpressionProtoOrBuilder p = + viaProto ? proto : builder; + return p.getPlacementConstraintExpression(); + } + + public AllocationTagsToPlacementConstraintExpressionProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } +} \ No newline at end of file diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/PlacementConstraintsOperationRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/PlacementConstraintsOperationRequestPBImpl.java new file mode 100644 index 00000000000..c87d9dc7986 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/PlacementConstraintsOperationRequestPBImpl.java @@ -0,0 +1,139 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb; + +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AllocationTagsToPlacementConstraintExpressionProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationRequestProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationRequestProto.OptType; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationRequestProtoOrBuilder; +import org.apache.hadoop.yarn.server.api.protocolrecords.AllocationTagsToPlacementConstraint; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationType; + +/** + * PB implementation for add/remove/list placement constraints request. + */ +public class PlacementConstraintsOperationRequestPBImpl extends + PlacementConstraintsOperationRequest{ + private PlacementConstraintsOperationRequestProto proto = + PlacementConstraintsOperationRequestProto.getDefaultInstance(); + + private PlacementConstraintsOperationRequestProto.Builder builder = null; + private boolean viaProto = false; + + public PlacementConstraintsOperationRequestPBImpl() { + builder = PlacementConstraintsOperationRequestProto.newBuilder(); + } + + public PlacementConstraintsOperationRequestPBImpl( + PlacementConstraintsOperationRequestProto requestProto) { + this.proto = requestProto; + this.viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = PlacementConstraintsOperationRequestProto.newBuilder(proto); + } + viaProto = false; + } + + private OptType toProto(PlacementConstraintsOperationType opt) { + return OptType.valueOf(opt.toString()); + } + + private AllocationTagsToPlacementConstraintExpressionProto toProto( + AllocationTagsToPlacementConstraint tagsToConstraint) { + return proto == null ? + AllocationTagsToPlacementConstraintExpressionProto + .getDefaultInstance() : + ((AllocationTagsToPlacementConstraintPBImpl) tagsToConstraint) + .getProto(); + } + + private PlacementConstraintsOperationType convert(OptType opt) { + return PlacementConstraintsOperationType.valueOf(opt.toString()); + } + + private AllocationTagsToPlacementConstraint convert( + AllocationTagsToPlacementConstraintExpressionProto constraintProto) { + return new AllocationTagsToPlacementConstraintPBImpl(constraintProto); + } + + @Override + public void setOperationType(PlacementConstraintsOperationType opt) { + maybeInitBuilder(); + if (opt != null) { + builder.setOperationType(toProto(opt)); + } + } + + @Override + public void setAllocationTagsToPlacementConstraint( + AllocationTagsToPlacementConstraint constraint) { + maybeInitBuilder(); + if (constraint == null) { + builder.clearConstraint(); + } + builder.setConstraint(toProto(constraint)); + } + + @Override + public PlacementConstraintsOperationType getOperationType() { + PlacementConstraintsOperationRequestProtoOrBuilder p = + viaProto ? proto : builder; + if (!p.hasOperationType()) { + return null; + } + return convert(p.getOperationType()); + } + + @Override + public AllocationTagsToPlacementConstraint + getAllocationTagsToPlacementConstraint() { + PlacementConstraintsOperationRequestProtoOrBuilder p = + viaProto ? proto : builder; + if (!p.hasConstraint()) { + return null; + } + return convert(p.getConstraint()); + } + + public PlacementConstraintsOperationRequestProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/PlacementConstraintsOperationResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/PlacementConstraintsOperationResponsePBImpl.java new file mode 100644 index 00000000000..0e9f0d522f2 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/PlacementConstraintsOperationResponsePBImpl.java @@ -0,0 +1,115 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb; + +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AllocationTagsToPlacementConstraintExpressionProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationResponseProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationResponseProtoOrBuilder; +import org.apache.hadoop.yarn.server.api.protocolrecords.AllocationTagsToPlacementConstraint; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * PB implementation for add/remove/list placement constraints response. + */ +public class PlacementConstraintsOperationResponsePBImpl extends + PlacementConstraintsOperationResponse{ + + private PlacementConstraintsOperationResponseProto proto = + PlacementConstraintsOperationResponseProto.getDefaultInstance(); + private PlacementConstraintsOperationResponseProto.Builder builder = null; + private boolean viaProto = false; + + public PlacementConstraintsOperationResponsePBImpl() { + builder = PlacementConstraintsOperationResponseProto.newBuilder(); + } + + public PlacementConstraintsOperationResponsePBImpl( + PlacementConstraintsOperationResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public PlacementConstraintsOperationResponseProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = PlacementConstraintsOperationResponseProto + .newBuilder(proto); + } + viaProto = false; + } + + private AllocationTagsToPlacementConstraintExpressionProto toProto( + AllocationTagsToPlacementConstraint constraint) { + return constraint == null ? + AllocationTagsToPlacementConstraintExpressionProto + .getDefaultInstance() : + ((AllocationTagsToPlacementConstraintPBImpl) constraint).getProto(); + } + + @Override + public void addAllocationTagsToPlacementConstraint( + AllocationTagsToPlacementConstraint constraint) { + maybeInitBuilder(); + if (constraint != null) { + builder.addConstraints(toProto(constraint)); + } + } + + @Override + public Set + getAllAllocationTagsToPlacementConstraints() { + PlacementConstraintsOperationResponseProtoOrBuilder p = viaProto ? + proto : builder; + List constraintList = + p.getConstraintsList(); + Set constraints = new HashSet<>(); + if (constraintList != null) { + constraints.addAll(constraintList + .stream().map(t -> new AllocationTagsToPlacementConstraintPBImpl(t)) + .collect(Collectors.toSet())); + } + return constraints; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/BasePBImplRecordsTest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/BasePBImplRecordsTest.java index ebd66af2618..741e2b12f40 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/BasePBImplRecordsTest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/BasePBImplRecordsTest.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.yarn.api; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -24,6 +25,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.yarn.api.resource.PlacementConstraint; import org.apache.hadoop.yarn.api.resource.PlacementConstraints; +import org.apache.hadoop.yarn.server.api.protocolrecords.AllocationTagsToPlacementConstraint; import org.junit.Assert; import java.lang.reflect.*; @@ -96,6 +98,11 @@ private static Object genTypeValue(Type type) { PlacementConstraint.AbstractConstraint sConstraintExpr = targetIn(NODE, allocationTag("foo")); ret = PlacementConstraints.build(sConstraintExpr); + } else if (type.equals(AllocationTagsToPlacementConstraint.class)) { + AllocationTagsToPlacementConstraint tags2Constraint = + AllocationTagsToPlacementConstraint + .newInstance(ImmutableSet.of("foo"), "notin, node, foo"); + ret = tags2Constraint; } } else if (type instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)type; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java index dfa0c8826bd..c75ca1bffe1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java @@ -234,10 +234,13 @@ import org.apache.hadoop.yarn.proto.YarnProtos.StrictPreemptionContractProto; import org.apache.hadoop.yarn.proto.YarnProtos.URLProto; import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AllocationTagsToPlacementConstraintExpressionProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AddToClusterNodeLabelsRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AddToClusterNodeLabelsResponseProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.CheckForDecommissioningNodesRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.CheckForDecommissioningNodesResponseProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationResponseProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshAdminAclsRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshAdminAclsResponseProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshNodesRequestProto; @@ -322,8 +325,10 @@ import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetResourceProfileResponseProto; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.AddToClusterNodeLabelsRequestPBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.AddToClusterNodeLabelsResponsePBImpl; +import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.AllocationTagsToPlacementConstraintPBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.CheckForDecommissioningNodesRequestPBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.CheckForDecommissioningNodesResponsePBImpl; +import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.PlacementConstraintsOperationResponsePBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.RefreshAdminAclsRequestPBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.RefreshAdminAclsResponsePBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.RefreshNodesRequestPBImpl; @@ -344,6 +349,7 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.ReplaceLabelsOnNodeResponsePBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.UpdateNodeResourceRequestPBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.UpdateNodeResourceResponsePBImpl; +import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.PlacementConstraintsOperationRequestPBImpl; import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.BeforeClass; @@ -1228,4 +1234,24 @@ public void testGetAllResourceTypesInfoResponsePBImpl() throws Exception { validatePBImplRecord(GetAllResourceTypeInfoResponsePBImpl.class, YarnServiceProtos.GetAllResourceTypeInfoResponseProto.class); } + + @Test + public void testAllocationTagsToPlacementConstraintPBImpl() throws Exception { + validatePBImplRecord(AllocationTagsToPlacementConstraintPBImpl.class, + AllocationTagsToPlacementConstraintExpressionProto.class); + } + + @Test + public void testPlacementConstraintsOperationRequestPBImpl() + throws Exception { + validatePBImplRecord(PlacementConstraintsOperationRequestPBImpl.class, + PlacementConstraintsOperationRequestProto.class); + } + + @Test + public void testPlacementConstraintsOperationResponsePBImpl() + throws Exception { + validatePBImplRecord(PlacementConstraintsOperationResponsePBImpl.class, + PlacementConstraintsOperationResponseProto.class); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPlacementConstraintsOperationPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPlacementConstraintsOperationPBImpl.java new file mode 100644 index 00000000000..e94f5d9ac36 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPlacementConstraintsOperationPBImpl.java @@ -0,0 +1,161 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.api; + +import com.google.common.collect.ImmutableSet; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AllocationTagsToPlacementConstraintExpressionProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationRequestProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationRequestProto.OptType; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.PlacementConstraintsOperationResponseProto; +import org.apache.hadoop.yarn.server.api.protocolrecords.AllocationTagsToPlacementConstraint; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationType; +import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.PlacementConstraintsOperationRequestPBImpl; +import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.PlacementConstraintsOperationResponsePBImpl; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Set; + +import static org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationType.ADD; + +/** + * Tests for PlacementConstraintsOperationRequestPBImpl. + */ +public class TestPlacementConstraintsOperationPBImpl { + + @Test + public void testEmptyRequestPB() { + PlacementConstraintsOperationRequest empty = + new PlacementConstraintsOperationRequestPBImpl(); + AllocationTagsToPlacementConstraint c = empty + .getAllocationTagsToPlacementConstraint(); + Assert.assertNull(c); + } + + @Test + public void testInitRequest() { + PlacementConstraintsOperationRequest request = + PlacementConstraintsOperationRequest.newInstance( + ADD, ImmutableSet.of("foo"), "notin,node,foo"); + + PlacementConstraintsOperationRequestProto proto = + ((PlacementConstraintsOperationRequestPBImpl) request).getProto(); + + Assert.assertEquals(OptType.ADD, proto.getOperationType()); + AllocationTagsToPlacementConstraintExpressionProto c = + proto.getConstraint(); + Assert.assertEquals(1, c.getAllocationTagsCount()); + Assert.assertEquals("foo", c.getAllocationTags(0)); + Assert.assertEquals("notin,node,foo", + c.getPlacementConstraintExpression()); + } + + @Test + public void testInitRequestFromOldPB() { + AllocationTagsToPlacementConstraintExpressionProto cp = + AllocationTagsToPlacementConstraintExpressionProto.newBuilder() + .addAllocationTags("foo") + .addAllocationTags("bar") + .setPlacementConstraintExpression("notin,node,foo") + .build(); + + PlacementConstraintsOperationRequestProto proto = + PlacementConstraintsOperationRequestProto.newBuilder() + .setOperationType(OptType.ADD) + .setConstraint(cp) + .build(); + + PlacementConstraintsOperationRequest request = + new PlacementConstraintsOperationRequestPBImpl(proto); + Assert.assertEquals(PlacementConstraintsOperationType.ADD, + request.getOperationType()); + AllocationTagsToPlacementConstraint rc = + request.getAllocationTagsToPlacementConstraint(); + Assert.assertEquals(2, rc.getAllocationTags().size()); + } + + @Test + public void testEmptyResponsePB() { + PlacementConstraintsOperationResponse response = + PlacementConstraintsOperationResponse.newInstance(); + Assert.assertEquals(0, response + .getAllAllocationTagsToPlacementConstraints().size()); + } + + @Test + public void testInitResponse() { + PlacementConstraintsOperationResponse response = + PlacementConstraintsOperationResponse.newInstance(); + AllocationTagsToPlacementConstraint c1 = + AllocationTagsToPlacementConstraint + .newInstance(ImmutableSet.of("T1", "T2")); + AllocationTagsToPlacementConstraint c2 = + AllocationTagsToPlacementConstraint + .newInstance(ImmutableSet.of("T1")); + response.addAllocationTagsToPlacementConstraint(c1); + response.addAllocationTagsToPlacementConstraint(c2); + + PlacementConstraintsOperationResponseProto proto = + ((PlacementConstraintsOperationResponsePBImpl) response).getProto(); + Assert.assertEquals(2, proto.getConstraintsCount()); + } + + @Test + public void testInitResponseFromOldPB() { + AllocationTagsToPlacementConstraintExpressionProto c1 = + AllocationTagsToPlacementConstraintExpressionProto.newBuilder() + .addAllocationTags("T1") + .addAllocationTags("T2") + .setPlacementConstraintExpression("notin,node,T1") + .build(); + + AllocationTagsToPlacementConstraintExpressionProto c2 = + AllocationTagsToPlacementConstraintExpressionProto.newBuilder() + .addAllocationTags("T3") + .setPlacementConstraintExpression("in,node,T3") + .build(); + + PlacementConstraintsOperationResponseProto proto = + PlacementConstraintsOperationResponseProto.newBuilder() + .addConstraints(c1) + .addConstraints(c2) + .build(); + + PlacementConstraintsOperationResponsePBImpl record = + new PlacementConstraintsOperationResponsePBImpl(proto); + Set constraints = + record.getAllAllocationTagsToPlacementConstraints(); + Assert.assertNotNull(constraints); + Assert.assertEquals(2, constraints.size()); + + for (AllocationTagsToPlacementConstraint atp : constraints) { + if (atp.getAllocationTags().size() == 1) { + String tag3 = atp.getAllocationTags().iterator().next(); + Assert.assertEquals("T3", tag3); + Assert.assertEquals("in,node,T3", atp.getPlacementConstraintExpr()); + } else if (atp.getAllocationTags().size() == 2) { + Assert.assertTrue(atp.getAllocationTags().contains("T1")); + Assert.assertTrue(atp.getAllocationTags().contains("T2")); + Assert.assertEquals("notin,node,T1", atp.getPlacementConstraintExpr()); + } + } + } +} \ No newline at end of file diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/MockResourceManagerFacade.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/MockResourceManagerFacade.java index 15e1ceac653..6fb85c45ffb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/MockResourceManagerFacade.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/MockResourceManagerFacade.java @@ -136,6 +136,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshClusterMaxPriorityRequest; @@ -899,4 +901,10 @@ public GetAllResourceTypeInfoResponse getResourceTypeInfo( GetAllResourceTypeInfoRequest request) throws YarnException, IOException { return null; } + + @Override + public PlacementConstraintsOperationResponse operatePlacementConstraints( + PlacementConstraintsOperationRequest request) throws YarnException { + return null; + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java index 3c117bc4b07..92951c81e00 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java @@ -88,6 +88,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.NodeLabelsUtils; import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSystem; import org.apache.hadoop.yarn.server.resourcemanager.resource.DynamicResourceConfiguration; @@ -961,4 +963,12 @@ private void refreshClusterMaxPriority() throws IOException, YarnException { rm.getRMContext().getScheduler().setClusterMaxPriority(conf); } + + @Override + public PlacementConstraintsOperationResponse operatePlacementConstraints( + PlacementConstraintsOperationRequest request) throws YarnException { + // TODO implement PC management in PlacementConstraintsManager + return recordFactory + .newRecordInstance(PlacementConstraintsOperationResponse.class); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/rmadmin/DefaultRMAdminRequestInterceptor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/rmadmin/DefaultRMAdminRequestInterceptor.java index 7e6a1ff28d3..188a7361b98 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/rmadmin/DefaultRMAdminRequestInterceptor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/rmadmin/DefaultRMAdminRequestInterceptor.java @@ -54,6 +54,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -212,4 +214,11 @@ public RefreshClusterMaxPriorityResponse refreshClusterMaxPriority( public String[] getGroupsForUser(String userName) throws IOException { return rmAdminProxy.getGroupsForUser(userName); } + + @Override + public PlacementConstraintsOperationResponse operatePlacementConstraints( + PlacementConstraintsOperationRequest request) + throws YarnException, IOException { + return rmAdminProxy.operatePlacementConstraints(request); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/rmadmin/RouterRMAdminService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/rmadmin/RouterRMAdminService.java index b8b7ad818f3..044472541c3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/rmadmin/RouterRMAdminService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/rmadmin/RouterRMAdminService.java @@ -65,6 +65,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; import org.apache.hadoop.yarn.util.LRUCacheHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -420,4 +422,12 @@ public RefreshClusterMaxPriorityResponse refreshClusterMaxPriority( RequestInterceptorChainWrapper pipeline = getInterceptorChain(); return pipeline.getRootInterceptor().refreshClusterMaxPriority(request); } + + @Override + public PlacementConstraintsOperationResponse operatePlacementConstraints( + PlacementConstraintsOperationRequest request) + throws YarnException, IOException { + RequestInterceptorChainWrapper pipeline = getInterceptorChain(); + return pipeline.getRootInterceptor().operatePlacementConstraints(request); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/rmadmin/PassThroughRMAdminRequestInterceptor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/rmadmin/PassThroughRMAdminRequestInterceptor.java index 38dcc3d96d3..eb9b33ab045 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/rmadmin/PassThroughRMAdminRequestInterceptor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/rmadmin/PassThroughRMAdminRequestInterceptor.java @@ -48,6 +48,8 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.PlacementConstraintsOperationRequest; /** * Mock intercepter that does not do anything other than forwarding it to the @@ -145,4 +147,10 @@ public RefreshClusterMaxPriorityResponse refreshClusterMaxPriority( return getNextInterceptor().getGroupsForUser(user); } + @Override + public PlacementConstraintsOperationResponse operatePlacementConstraints( + PlacementConstraintsOperationRequest request) + throws YarnException, IOException { + return getNextInterceptor().operatePlacementConstraints(request); + } }