|
@@ -18,10 +18,8 @@
|
|
|
|
|
|
package org.apache.hadoop.yarn.api.protocolrecords.impl.pb;
|
|
|
|
|
|
-
|
|
|
-import java.nio.ByteBuffer;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
+import com.google.protobuf.ByteString;
|
|
|
+import com.google.protobuf.TextFormat;
|
|
|
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
|
|
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
|
|
import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse;
|
|
@@ -29,21 +27,28 @@ import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
|
|
|
import org.apache.hadoop.yarn.api.records.Container;
|
|
|
import org.apache.hadoop.yarn.api.records.NMToken;
|
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
|
+import org.apache.hadoop.yarn.api.records.ResourceTypeInfo;
|
|
|
import org.apache.hadoop.yarn.api.records.impl.pb.ContainerPBImpl;
|
|
|
import org.apache.hadoop.yarn.api.records.impl.pb.NMTokenPBImpl;
|
|
|
import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils;
|
|
|
import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl;
|
|
|
+import org.apache.hadoop.yarn.api.records.impl.pb.ResourceTypeInfoPBImpl;
|
|
|
import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto;
|
|
|
import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto;
|
|
|
import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
|
|
|
+import org.apache.hadoop.yarn.proto.YarnProtos.ResourceTypeInfoProto;
|
|
|
import org.apache.hadoop.yarn.proto.YarnServiceProtos.NMTokenProto;
|
|
|
import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProto;
|
|
|
import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProtoOrBuilder;
|
|
|
import org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes;
|
|
|
|
|
|
-import com.google.protobuf.ByteString;
|
|
|
-import com.google.protobuf.TextFormat;
|
|
|
-
|
|
|
+import java.nio.ByteBuffer;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.EnumSet;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Private
|
|
|
@Unstable
|
|
@@ -59,6 +64,7 @@ public class RegisterApplicationMasterResponsePBImpl extends
|
|
|
private List<Container> containersFromPreviousAttempts = null;
|
|
|
private List<NMToken> nmTokens = null;
|
|
|
private EnumSet<SchedulerResourceTypes> schedulerResourceTypes = null;
|
|
|
+ private List<ResourceTypeInfo> resourceTypeInfo = null;
|
|
|
|
|
|
public RegisterApplicationMasterResponsePBImpl() {
|
|
|
builder = RegisterApplicationMasterResponseProto.newBuilder();
|
|
@@ -123,9 +129,11 @@ public class RegisterApplicationMasterResponsePBImpl extends
|
|
|
if(schedulerResourceTypes != null) {
|
|
|
addSchedulerResourceTypes();
|
|
|
}
|
|
|
+ if (resourceTypeInfo != null) {
|
|
|
+ addResourceTypeInfosToProto();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private void maybeInitBuilder() {
|
|
|
if (viaProto || builder == null) {
|
|
|
builder = RegisterApplicationMasterResponseProto.newBuilder(proto);
|
|
@@ -456,4 +464,75 @@ public class RegisterApplicationMasterResponsePBImpl extends
|
|
|
private NMToken convertFromProtoFormat(NMTokenProto proto) {
|
|
|
return new NMTokenPBImpl(proto);
|
|
|
}
|
|
|
+
|
|
|
+ private ResourceTypeInfoPBImpl convertFromProtoFormat(
|
|
|
+ ResourceTypeInfoProto p) {
|
|
|
+ return new ResourceTypeInfoPBImpl(p);
|
|
|
+ }
|
|
|
+
|
|
|
+ private ResourceTypeInfoProto convertToProtoFormat(ResourceTypeInfo t) {
|
|
|
+ return ((ResourceTypeInfoPBImpl) t).getProto();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ResourceTypeInfo> getResourceTypes() {
|
|
|
+ initResourceTypeInfosList();
|
|
|
+ return this.resourceTypeInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setResourceTypes(List<ResourceTypeInfo> types) {
|
|
|
+ if (resourceTypeInfo == null) {
|
|
|
+ builder.clearResourceTypes();
|
|
|
+ }
|
|
|
+ this.resourceTypeInfo = types;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addResourceTypeInfosToProto() {
|
|
|
+ maybeInitBuilder();
|
|
|
+ builder.clearResourceTypes();
|
|
|
+ if (resourceTypeInfo == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Iterable<ResourceTypeInfoProto> iterable = new Iterable<ResourceTypeInfoProto>() {
|
|
|
+ @Override
|
|
|
+ public Iterator<ResourceTypeInfoProto> iterator() {
|
|
|
+ return new Iterator<ResourceTypeInfoProto>() {
|
|
|
+
|
|
|
+ Iterator<ResourceTypeInfo> iter = resourceTypeInfo.iterator();
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean hasNext() {
|
|
|
+ return iter.hasNext();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResourceTypeInfoProto next() {
|
|
|
+ return convertToProtoFormat(iter.next());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void remove() {
|
|
|
+ throw new UnsupportedOperationException();
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+ builder.addAllResourceTypes(iterable);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initResourceTypeInfosList() {
|
|
|
+ if (this.resourceTypeInfo != null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder;
|
|
|
+ List<ResourceTypeInfoProto> list = p.getResourceTypesList();
|
|
|
+ resourceTypeInfo = new ArrayList<ResourceTypeInfo>();
|
|
|
+
|
|
|
+ for (ResourceTypeInfoProto a : list) {
|
|
|
+ resourceTypeInfo.add(convertFromProtoFormat(a));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|