|
@@ -113,27 +113,74 @@ public class ProtoUtils {
|
|
/*
|
|
/*
|
|
* ContainerState
|
|
* ContainerState
|
|
*/
|
|
*/
|
|
- private final static String CONTAINER_STATE_PREFIX = "C_";
|
|
|
|
- public static ContainerStateProto convertToProtoFormat(ContainerState e) {
|
|
|
|
- return ContainerStateProto.valueOf(CONTAINER_STATE_PREFIX + e.name());
|
|
|
|
|
|
+ public static ContainerStateProto convertToProtoFormat(ContainerState state) {
|
|
|
|
+ switch (state) {
|
|
|
|
+ case NEW:
|
|
|
|
+ return ContainerStateProto.C_NEW;
|
|
|
|
+ case RUNNING:
|
|
|
|
+ return ContainerStateProto.C_RUNNING;
|
|
|
|
+ case COMPLETE:
|
|
|
|
+ return ContainerStateProto.C_COMPLETE;
|
|
|
|
+ default:
|
|
|
|
+ throw new IllegalArgumentException(
|
|
|
|
+ "ContainerState conversion unsupported");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- public static ContainerState convertFromProtoFormat(ContainerStateProto e) {
|
|
|
|
- return ContainerState.valueOf(e.name().replace(CONTAINER_STATE_PREFIX, ""));
|
|
|
|
|
|
+
|
|
|
|
+ public static ContainerState convertFromProtoFormat(
|
|
|
|
+ ContainerStateProto proto) {
|
|
|
|
+ switch (proto) {
|
|
|
|
+ case C_NEW:
|
|
|
|
+ return ContainerState.NEW;
|
|
|
|
+ case C_RUNNING:
|
|
|
|
+ return ContainerState.RUNNING;
|
|
|
|
+ case C_COMPLETE:
|
|
|
|
+ return ContainerState.COMPLETE;
|
|
|
|
+ default:
|
|
|
|
+ throw new IllegalArgumentException(
|
|
|
|
+ "ContainerStateProto conversion unsupported");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
* Container SubState
|
|
* Container SubState
|
|
*/
|
|
*/
|
|
- private final static String CONTAINER_SUB_STATE_PREFIX = "CSS_";
|
|
|
|
public static ContainerSubStateProto convertToProtoFormat(
|
|
public static ContainerSubStateProto convertToProtoFormat(
|
|
- ContainerSubState e) {
|
|
|
|
- return ContainerSubStateProto.valueOf(
|
|
|
|
- CONTAINER_SUB_STATE_PREFIX + e.name());
|
|
|
|
|
|
+ ContainerSubState state) {
|
|
|
|
+ switch (state) {
|
|
|
|
+ case SCHEDULED:
|
|
|
|
+ return ContainerSubStateProto.CSS_SCHEDULED;
|
|
|
|
+ case RUNNING:
|
|
|
|
+ return ContainerSubStateProto.CSS_RUNNING;
|
|
|
|
+ case PAUSED:
|
|
|
|
+ return ContainerSubStateProto.CSS_PAUSED;
|
|
|
|
+ case COMPLETING:
|
|
|
|
+ return ContainerSubStateProto.CSS_COMPLETING;
|
|
|
|
+ case DONE:
|
|
|
|
+ return ContainerSubStateProto.CSS_DONE;
|
|
|
|
+ default:
|
|
|
|
+ throw new IllegalArgumentException(
|
|
|
|
+ "ContainerSubState conversion unsupported");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
public static ContainerSubState convertFromProtoFormat(
|
|
public static ContainerSubState convertFromProtoFormat(
|
|
- ContainerSubStateProto e) {
|
|
|
|
- return ContainerSubState.valueOf(
|
|
|
|
- e.name().substring(CONTAINER_SUB_STATE_PREFIX.length()));
|
|
|
|
|
|
+ ContainerSubStateProto proto) {
|
|
|
|
+ switch (proto) {
|
|
|
|
+ case CSS_SCHEDULED:
|
|
|
|
+ return ContainerSubState.SCHEDULED;
|
|
|
|
+ case CSS_RUNNING:
|
|
|
|
+ return ContainerSubState.RUNNING;
|
|
|
|
+ case CSS_PAUSED:
|
|
|
|
+ return ContainerSubState.PAUSED;
|
|
|
|
+ case CSS_COMPLETING:
|
|
|
|
+ return ContainerSubState.COMPLETING;
|
|
|
|
+ case CSS_DONE:
|
|
|
|
+ return ContainerSubState.DONE;
|
|
|
|
+ default:
|
|
|
|
+ throw new IllegalArgumentException(
|
|
|
|
+ "ContainerSubStateProto conversion unsupported");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
* NodeState
|
|
* NodeState
|