|
@@ -21,8 +21,6 @@ package org.apache.hadoop.yarn.api.records.impl.pb;
|
|
|
import org.apache.hadoop.security.proto.SecurityProtos.TokenProto;
|
|
|
import org.apache.hadoop.yarn.api.records.Container;
|
|
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
|
|
-import org.apache.hadoop.yarn.api.records.ContainerState;
|
|
|
-import org.apache.hadoop.yarn.api.records.ContainerStatus;
|
|
|
import org.apache.hadoop.yarn.api.records.ContainerToken;
|
|
|
import org.apache.hadoop.yarn.api.records.NodeId;
|
|
|
import org.apache.hadoop.yarn.api.records.Priority;
|
|
@@ -31,12 +29,9 @@ import org.apache.hadoop.yarn.api.records.Resource;
|
|
|
import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
|
|
|
import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto;
|
|
|
import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProtoOrBuilder;
|
|
|
-import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto;
|
|
|
-import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto;
|
|
|
import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto;
|
|
|
import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto;
|
|
|
import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
|
|
|
-import org.apache.hadoop.yarn.util.ProtoUtils;
|
|
|
|
|
|
public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Container {
|
|
|
|
|
@@ -49,7 +44,6 @@ public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Contai
|
|
|
private Resource resource = null;
|
|
|
private Priority priority = null;
|
|
|
private ContainerToken containerToken = null;
|
|
|
- private ContainerStatus containerStatus = null;
|
|
|
|
|
|
public ContainerPBImpl() {
|
|
|
builder = ContainerProto.newBuilder();
|
|
@@ -94,11 +88,6 @@ public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Contai
|
|
|
builder.getContainerToken())) {
|
|
|
builder.setContainerToken(convertToProtoFormat(this.containerToken));
|
|
|
}
|
|
|
- if (this.containerStatus != null
|
|
|
- && !((ContainerStatusPBImpl) this.containerStatus).getProto().equals(
|
|
|
- builder.getContainerStatus())) {
|
|
|
- builder.setContainerStatus(convertToProtoFormat(this.containerStatus));
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
private void mergeLocalToProto() {
|
|
@@ -115,26 +104,7 @@ public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Contai
|
|
|
}
|
|
|
viaProto = false;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public ContainerState getState() {
|
|
|
- ContainerProtoOrBuilder p = viaProto ? proto : builder;
|
|
|
- if (!p.hasState()) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return convertFromProtoFormat(p.getState());
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public void setState(ContainerState state) {
|
|
|
- maybeInitBuilder();
|
|
|
- if (state == null) {
|
|
|
- builder.clearState();
|
|
|
- return;
|
|
|
- }
|
|
|
- builder.setState(convertToProtoFormat(state));
|
|
|
- }
|
|
|
@Override
|
|
|
public ContainerId getId() {
|
|
|
ContainerProtoOrBuilder p = viaProto ? proto : builder;
|
|
@@ -260,35 +230,6 @@ public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Contai
|
|
|
this.containerToken = containerToken;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ContainerStatus getContainerStatus() {
|
|
|
- ContainerProtoOrBuilder p = viaProto ? proto : builder;
|
|
|
- if (this.containerStatus != null) {
|
|
|
- return this.containerStatus;
|
|
|
- }
|
|
|
- if (!p.hasContainerStatus()) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- this.containerStatus = convertFromProtoFormat(p.getContainerStatus());
|
|
|
- return this.containerStatus;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void setContainerStatus(ContainerStatus containerStatus) {
|
|
|
- maybeInitBuilder();
|
|
|
- if (containerStatus == null)
|
|
|
- builder.clearContainerStatus();
|
|
|
- this.containerStatus = containerStatus;
|
|
|
- }
|
|
|
-
|
|
|
- private ContainerStateProto convertToProtoFormat(ContainerState e) {
|
|
|
- return ProtoUtils.convertToProtoFormat(e);
|
|
|
- }
|
|
|
-
|
|
|
- private ContainerState convertFromProtoFormat(ContainerStateProto e) {
|
|
|
- return ProtoUtils.convertFromProtoFormat(e);
|
|
|
- }
|
|
|
-
|
|
|
private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
|
|
|
return new ContainerIdPBImpl(p);
|
|
|
}
|
|
@@ -329,14 +270,6 @@ public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Contai
|
|
|
return ((ContainerTokenPBImpl)t).getProto();
|
|
|
}
|
|
|
|
|
|
- private ContainerStatusPBImpl convertFromProtoFormat(ContainerStatusProto p) {
|
|
|
- return new ContainerStatusPBImpl(p);
|
|
|
- }
|
|
|
-
|
|
|
- private ContainerStatusProto convertToProtoFormat(ContainerStatus t) {
|
|
|
- return ((ContainerStatusPBImpl)t).getProto();
|
|
|
- }
|
|
|
-
|
|
|
public String toString() {
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
sb.append("Container: [");
|
|
@@ -345,9 +278,7 @@ public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Contai
|
|
|
sb.append("NodeHttpAddress: ").append(getNodeHttpAddress()).append(", ");
|
|
|
sb.append("Resource: ").append(getResource()).append(", ");
|
|
|
sb.append("Priority: ").append(getPriority()).append(", ");
|
|
|
- sb.append("State: ").append(getState()).append(", ");
|
|
|
sb.append("Token: ").append(getContainerToken()).append(", ");
|
|
|
- sb.append("Status: ").append(getContainerStatus());
|
|
|
sb.append("]");
|
|
|
return sb.toString();
|
|
|
}
|
|
@@ -357,16 +288,7 @@ public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Contai
|
|
|
public int compareTo(Container other) {
|
|
|
if (this.getId().compareTo(other.getId()) == 0) {
|
|
|
if (this.getNodeId().compareTo(other.getNodeId()) == 0) {
|
|
|
- if (this.getResource().compareTo(other.getResource()) == 0) {
|
|
|
- if (this.getState().compareTo(other.getState()) == 0) {
|
|
|
- //ContainerToken
|
|
|
- return this.getState().compareTo(other.getState());
|
|
|
- } else {
|
|
|
- return this.getState().compareTo(other.getState());
|
|
|
- }
|
|
|
- } else {
|
|
|
- return this.getResource().compareTo(other.getResource());
|
|
|
- }
|
|
|
+ return this.getResource().compareTo(other.getResource());
|
|
|
} else {
|
|
|
return this.getNodeId().compareTo(other.getNodeId());
|
|
|
}
|