diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueConfigurations.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueConfigurations.java new file mode 100644 index 0000000..297ed54 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueConfigurations.java @@ -0,0 +1,120 @@ +package org.apache.hadoop.yarn.api.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Stable; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +public abstract class QueueConfigurations { + + @Public + @Unstable + public static QueueConfigurations newInstance(float capacity, + float absoluteCapacity, float maxCapacity, float absoluteMaxCapacity, + float maxAMPercentage) { + QueueConfigurations queueConfigurations = + Records.newRecord(QueueConfigurations.class); + queueConfigurations.setCapacity(capacity); + queueConfigurations.setAbsoluteCapacity(absoluteCapacity); + queueConfigurations.setMaxCapacity(maxCapacity); + queueConfigurations.setAbsoluteMaxCapacity(absoluteMaxCapacity); + queueConfigurations.setMaxAMPercentage(maxAMPercentage); + return queueConfigurations; + } + + /** + * Get the queue capacity. + * + * @return the queue capacity + */ + @Public + @Stable + public abstract float getCapacity(); + + /** + * Set the queue capacity. + * + * @param capacity + * the queue capacity. + */ + @Private + @Unstable + public abstract void setCapacity(float capacity); + + /** + * Get the absolute capacity. + * + * @return the absolute capacity + */ + @Public + @Stable + public abstract float getAbsoluteCapacity(); + + /** + * Set the absolute capacity. + * + * @param absoluteCapacity + * the absolute capacity + */ + @Private + @Unstable + public abstract void setAbsoluteCapacity(float absoluteCapacity); + + /** + * Get the maximum capacity. + * + * @return the maximum capacity + */ + @Public + @Stable + public abstract float getMaxCapacity(); + + /** + * Set the maximum capacity. + * + * @param maxCapacity + * the maximum capacity + */ + @Private + @Unstable + public abstract void setMaxCapacity(float maxCapacity); + + /** + * Get the absolute maximum capacity. + * + * @return the absolute maximum capacity + */ + @Public + @Stable + public abstract float getAbsoluteMaxCapacity(); + + /** + * Set the absolute maximum capacity. + * + * @param absoluteMaxCapacity + * the absolute maximum capacity + */ + @Private + @Unstable + public abstract void setAbsoluteMaxCapacity(float absoluteMaxCapacity); + + /** + * Get the maximum AM resource percentage. + * + * @return the maximum AM resource percentage + */ + @Public + @Stable + public abstract float getMaxAMPercentage(); + + /** + * Set the maximum AM resource percentage. + * + * @param maxAMPercentage + * the maximum AM resource percentage + */ + @Private + @Unstable + public abstract void setMaxAMPercentage(float maxAMPercentage); +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java index 7816feb..5fb3e2d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java @@ -19,6 +19,7 @@ package org.apache.hadoop.yarn.api.records; import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.hadoop.classification.InterfaceAudience.Private; @@ -72,6 +73,25 @@ public static QueueInfo newInstance(String queueName, float capacity, return queueInfo; } + @Private + @Unstable + public static QueueInfo newInstance(String queueName, float capacity, + float maximumCapacity, float currentCapacity, + List childQueues, List applications, + QueueState queueState, Set accessibleNodeLabels, + String defaultNodeLabelExpression, QueueStatistics queueStatistics, + boolean preemptionDisabled, + Map queueConfigurations) { + QueueInfo queueInfo = QueueInfo.newInstance(queueName, capacity, + maximumCapacity, currentCapacity, + childQueues, applications, + queueState, accessibleNodeLabels, + defaultNodeLabelExpression, queueStatistics, + preemptionDisabled); + queueInfo.setQueueConfigurations(queueConfigurations); + return queueInfo; + } + /** * Get the name of the queue. * @return name of the queue @@ -219,4 +239,24 @@ public abstract void setDefaultNodeLabelExpression( @Private @Unstable public abstract void setPreemptionDisabled(boolean preemptionDisabled); + + /** + * Get the per-node-label queue configurations of the queue. + * + * @return the per-node-label queue configurations of the queue. + */ + @Public + @Stable + public abstract Map getQueueConfigurations(); + + /** + * Set the per-node-label queue configurations for the queue. + * + * @param queueConfigurations + * the queue configurations + */ + @Private + @Unstable + public abstract void setQueueConfigurations( + Map queueConfigurations); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto index a6dbf3c..c06ebd0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto @@ -463,6 +463,20 @@ message QueueInfoProto { optional string defaultNodeLabelExpression = 9; optional QueueStatisticsProto queueStatistics = 10; optional bool preemptionDisabled = 11; + repeated QueueConfigurationsMapProto queueConfigurationsMap = 12; +} + +message QueueConfigurationsProto { + required float capacity = 1; + required float absoluteCapacity = 2; + required float maxCapacity = 3; + required float absoluteMaxCapacity = 4; + required float maxAMPercentage = 5; +} + +message QueueConfigurationsMapProto { + required string nodeLabel = 1; + required QueueConfigurationsProto queueConfigurations = 2; } enum QueueACLProto { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/QueueCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/QueueCLI.java index 330b081..c45fc4b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/QueueCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/QueueCLI.java @@ -22,6 +22,7 @@ import java.io.PrintWriter; import java.nio.charset.Charset; import java.text.DecimalFormat; +import java.util.List; import java.util.Set; import org.apache.commons.cli.CommandLine; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java index 7cf9788..3c35b9c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java @@ -1699,7 +1699,7 @@ public void testGetQueueInfo() throws Exception { nodeLabels.add("GPU"); nodeLabels.add("JDK_7"); QueueInfo queueInfo = QueueInfo.newInstance("queueA", 0.4f, 0.8f, 0.5f, - null, null, QueueState.RUNNING, nodeLabels, "GPU", null, false); + null, null, QueueState.RUNNING, nodeLabels, "GPU", null, false, null); when(client.getQueueInfo(any(String.class))).thenReturn(queueInfo); int result = cli.run(new String[] { "-status", "queueA" }); assertEquals(0, result); @@ -1800,7 +1800,7 @@ public void testGetQueueInfoPreemptionDisabled() throws Exception { public void testGetQueueInfoWithEmptyNodeLabel() throws Exception { QueueCLI cli = createAndGetQueueCLI(); QueueInfo queueInfo = QueueInfo.newInstance("queueA", 0.4f, 0.8f, 0.5f, - null, null, QueueState.RUNNING, null, null, null, true); + null, null, QueueState.RUNNING, null, null, null, true, null); when(client.getQueueInfo(any(String.class))).thenReturn(queueInfo); int result = cli.run(new String[] { "-status", "queueA" }); assertEquals(0, result); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueConfigurationsPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueConfigurationsPBImpl.java new file mode 100644 index 0000000..9cd3e13 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueConfigurationsPBImpl.java @@ -0,0 +1,117 @@ +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.yarn.api.records.QueueConfigurations; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueConfigurationsProto; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueConfigurationsProtoOrBuilder; + +import com.google.protobuf.TextFormat; + +public class QueueConfigurationsPBImpl extends QueueConfigurations { + + QueueConfigurationsProto proto = QueueConfigurationsProto.getDefaultInstance(); + QueueConfigurationsProto.Builder builder = null; + boolean viaProto = false; + + public QueueConfigurationsPBImpl() { + builder = QueueConfigurationsProto.newBuilder(); + } + + public QueueConfigurationsPBImpl(QueueConfigurationsProto proto) { + this.proto = proto; + viaProto = true; + } + + public QueueConfigurationsProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public float getCapacity() { + QueueConfigurationsProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasCapacity()) ? p.getCapacity() : 0f; + } + + @Override + public void setCapacity(float capacity) { + maybeInitBuilder(); + builder.setCapacity(capacity); + } + + @Override + public float getAbsoluteCapacity() { + QueueConfigurationsProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasAbsoluteCapacity()) ? p.getAbsoluteCapacity() : 0f; + } + + @Override + public void setAbsoluteCapacity(float absoluteCapacity) { + maybeInitBuilder(); + builder.setAbsoluteCapacity(absoluteCapacity); + } + + @Override + public float getMaxCapacity() { + QueueConfigurationsProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasMaxCapacity()) ? p.getMaxCapacity() : 0f; + } + + @Override + public void setMaxCapacity(float maxCapacity) { + maybeInitBuilder(); + builder.setMaxCapacity(maxCapacity); + } + + @Override + public float getAbsoluteMaxCapacity() { + QueueConfigurationsProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasAbsoluteMaxCapacity()) ? p.getAbsoluteMaxCapacity() : 0f; + } + + @Override + public void setAbsoluteMaxCapacity(float absoluteMaxCapacity) { + maybeInitBuilder(); + builder.setAbsoluteMaxCapacity(absoluteMaxCapacity); + } + + @Override + public float getMaxAMPercentage() { + QueueConfigurationsProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasMaxAMPercentage()) ? p.getMaxAMPercentage() : 0f; + } + + @Override + public void setMaxAMPercentage(float maxAMPercentage) { + maybeInitBuilder(); + builder.setMaxAMPercentage(maxAMPercentage); + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = QueueConfigurationsProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + + @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/api/records/impl/pb/QueueInfoPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java index 605cab1..c4a43bf 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java @@ -19,18 +19,23 @@ package org.apache.hadoop.yarn.api.records.impl.pb; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.QueueConfigurations; import org.apache.hadoop.yarn.api.records.QueueInfo; import org.apache.hadoop.yarn.api.records.QueueState; import org.apache.hadoop.yarn.api.records.QueueStatistics; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueConfigurationsMapProto; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueConfigurationsProto; import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProto; import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.QueueStateProto; @@ -49,7 +54,8 @@ List applicationsList; List childQueuesList; Set accessibleNodeLabels; - + Map queueConfigurations; + public QueueInfoPBImpl() { builder = QueueInfoProto.newBuilder(); } @@ -279,6 +285,46 @@ public void remove() { builder.addAllChildQueues(iterable); } + private void addQueueConfigurations() { + maybeInitBuilder(); + builder.clearQueueConfigurationsMap(); + if (queueConfigurations == null) { + return; + } + Iterable values = + new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + private Iterator iterator = + queueConfigurations.keySet().iterator(); + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public QueueConfigurationsMapProto next() { + String key = iterator.next(); + return QueueConfigurationsMapProto.newBuilder() + .setNodeLabel(key) + .setQueueConfigurations( + convertToProtoFormat(queueConfigurations.get(key))) + .build(); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + }; + this.builder.addAllQueueConfigurationsMap(values); + } + private void mergeLocalToBuilder() { if (this.childQueuesList != null) { addChildQueuesInfoToProto(); @@ -290,6 +336,9 @@ private void mergeLocalToBuilder() { builder.clearAccessibleNodeLabels(); builder.addAllAccessibleNodeLabels(this.accessibleNodeLabels); } + if (this.queueConfigurations != null) { + addQueueConfigurations(); + } } private void mergeLocalToProto() { @@ -327,11 +376,19 @@ private QueueInfoProto convertToProtoFormat(QueueInfo q) { private QueueState convertFromProtoFormat(QueueStateProto q) { return ProtoUtils.convertFromProtoFormat(q); } - + private QueueStateProto convertToProtoFormat(QueueState queueState) { return ProtoUtils.convertToProtoFormat(queueState); } - + + private QueueConfigurationsPBImpl convertFromProtoFormat(QueueConfigurationsProto q) { + return new QueueConfigurationsPBImpl(q); + } + + private QueueConfigurationsProto convertToProtoFormat(QueueConfigurations q) { + return ((QueueConfigurationsPBImpl)q).getProto(); + } + @Override public void setAccessibleNodeLabels(Set nodeLabels) { maybeInitBuilder(); @@ -408,4 +465,38 @@ public void setPreemptionDisabled(boolean preemptionDisabled) { maybeInitBuilder(); builder.setPreemptionDisabled(preemptionDisabled); } + + private void initQueueConfigurations() { + if (queueConfigurations != null) { + return; + } + QueueInfoProtoOrBuilder p = viaProto ? proto : builder; + List lists = p.getQueueConfigurationsMapList(); + queueConfigurations = + new HashMap(lists.size()); + for (QueueConfigurationsMapProto queueConfigurationsProto : lists) { + queueConfigurations.put( + queueConfigurationsProto.getNodeLabel(), + convertFromProtoFormat( + queueConfigurationsProto.getQueueConfigurations())); + } + } + + @Override + public Map getQueueConfigurations() { + initQueueConfigurations(); + return queueConfigurations; + } + + @Override + public void setQueueConfigurations( + Map queueConfigurations) { + if (queueConfigurations == null) { + return; + } + initQueueConfigurations(); + this.queueConfigurations.clear(); + this.queueConfigurations.putAll(queueConfigurations); + } + } 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 10323d5..b62b4ee 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 @@ -16,7 +16,8 @@ * limitations under the License. */ package org.apache.hadoop.yarn.api; -import com.google.common.collect.ImmutableSet; +import java.io.IOException; + import org.apache.commons.lang.math.LongRange; import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenResponseProto; @@ -26,13 +27,13 @@ import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenResponseProto; import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse; +import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest; +import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse; import org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.RestartContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; -import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest; -import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.CancelDelegationTokenRequestPBImpl; @@ -71,6 +72,8 @@ import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetQueueInfoResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetQueueUserAclsInfoRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetQueueUserAclsInfoResponsePBImpl; +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.IncreaseContainersResourceRequestPBImpl; +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.IncreaseContainersResourceResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.KillApplicationRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.KillApplicationResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.MoveApplicationAcrossQueuesRequestPBImpl; @@ -94,8 +97,6 @@ import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StartContainersResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StopContainersRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StopContainersResponsePBImpl; -import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.IncreaseContainersResourceRequestPBImpl; -import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.IncreaseContainersResourceResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationResponsePBImpl; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; @@ -123,6 +124,7 @@ import org.apache.hadoop.yarn.api.records.PreemptionMessage; import org.apache.hadoop.yarn.api.records.PreemptionResourceRequest; import org.apache.hadoop.yarn.api.records.Priority; +import org.apache.hadoop.yarn.api.records.QueueConfigurations; import org.apache.hadoop.yarn.api.records.QueueInfo; import org.apache.hadoop.yarn.api.records.QueueState; import org.apache.hadoop.yarn.api.records.QueueStatistics; @@ -132,8 +134,8 @@ import org.apache.hadoop.yarn.api.records.ReservationId; import org.apache.hadoop.yarn.api.records.ReservationRequest; import org.apache.hadoop.yarn.api.records.ReservationRequests; -import org.apache.hadoop.yarn.api.records.ResourceAllocationRequest; import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.api.records.ResourceAllocationRequest; import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest; import org.apache.hadoop.yarn.api.records.ResourceOption; import org.apache.hadoop.yarn.api.records.ResourceRequest; @@ -272,6 +274,8 @@ import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueUserAclsInfoRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueUserAclsInfoResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.IncreaseContainersResourceRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.IncreaseContainersResourceResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.MoveApplicationAcrossQueuesRequestProto; @@ -287,8 +291,6 @@ import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationSubmissionResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationUpdateRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationUpdateResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.IncreaseContainersResourceRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.IncreaseContainersResourceResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersResponseProto; @@ -326,7 +328,7 @@ import org.junit.Ignore; import org.junit.Test; -import java.io.IOException; +import com.google.common.collect.ImmutableSet; /** * Test class for YARN API protocol records. @@ -399,6 +401,7 @@ public static void setup() throws Exception { generateByNewInstance(RollbackResponse.class); generateByNewInstance(CommitResponse.class); generateByNewInstance(ApplicationTimeout.class); + generateByNewInstance(QueueConfigurations.class); } @Test diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java index e9ef319..3f5cea1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java @@ -19,9 +19,11 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -38,6 +40,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.Priority; import org.apache.hadoop.yarn.api.records.QueueACL; +import org.apache.hadoop.yarn.api.records.QueueConfigurations; import org.apache.hadoop.yarn.api.records.QueueInfo; import org.apache.hadoop.yarn.api.records.QueueState; import org.apache.hadoop.yarn.api.records.QueueStatistics; @@ -411,6 +414,7 @@ protected QueueInfo getQueueInfo() { queueInfo.setCurrentCapacity(getUsedCapacity()); queueInfo.setQueueStatistics(getQueueStatistics()); queueInfo.setPreemptionDisabled(preemptionDisabled); + queueInfo.setQueueConfigurations(getQueueConfigurations()); return queueInfo; } @@ -442,6 +446,29 @@ public QueueStatistics getQueueStatistics() { return stats; } + public Map getQueueConfigurations() { + Map queueConfigurations = new HashMap<>(); + Set nodeLabels = getNodeLabelsForQueue(); + for (String nodeLabel : nodeLabels) { + QueueConfigurations queueConfiguration = + recordFactory.newRecordInstance(QueueConfigurations.class); + float capacity = queueCapacities.getCapacity(nodeLabel); + float absoluteCapacity = queueCapacities.getAbsoluteCapacity(nodeLabel); + float maxCapacity = queueCapacities.getMaximumCapacity(nodeLabel); + float absMaxCapacity = + queueCapacities.getAbsoluteMaximumCapacity(nodeLabel); + float maxAMPercentage = + queueCapacities.getMaxAMResourcePercentage(nodeLabel); + queueConfiguration.setCapacity(capacity); + queueConfiguration.setAbsoluteCapacity(absoluteCapacity); + queueConfiguration.setMaxCapacity(maxCapacity); + queueConfiguration.setAbsoluteMaxCapacity(absMaxCapacity); + queueConfiguration.setMaxAMPercentage(maxAMPercentage); + queueConfigurations.put(nodeLabel, queueConfiguration); + } + return queueConfigurations; + } + @Private public Resource getMaximumAllocation() { return maximumAllocation;