You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by hi...@apache.org on 2014/01/13 23:30:32 UTC
git commit: TEZ-720. Inconsistency between VertexState and
VertexStatus.State. (hitesh)
Updated Branches:
refs/heads/master a1164c4db -> 462696e0b
TEZ-720. Inconsistency between VertexState and VertexStatus.State. (hitesh)
Project: http://git-wip-us.apache.org/repos/asf/incubator-tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tez/commit/462696e0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tez/tree/462696e0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tez/diff/462696e0
Branch: refs/heads/master
Commit: 462696e0b6e60eb2e3adc00fb48dff48f75e6c7f
Parents: a1164c4
Author: Hitesh Shah <hi...@apache.org>
Authored: Mon Jan 13 14:30:18 2014 -0800
Committer: Hitesh Shah <hi...@apache.org>
Committed: Mon Jan 13 14:30:18 2014 -0800
----------------------------------------------------------------------
CHANGES.txt | 4 +-
.../apache/tez/dag/api/client/VertexStatus.java | 53 ++++++++++++--------
tez-api/src/main/proto/DAGApiRecords.proto | 16 +++---
.../tez/dag/api/client/VertexStatusBuilder.java | 42 +++++++++-------
.../dag/api/client/TestVertexStatusBuilder.java | 39 ++++++++++++++
5 files changed, 107 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tez/blob/462696e0/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6d5035b..959f8ee 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,7 +4,9 @@ Apache Tez Change Log
Release 0.3.0 - Unreleased
INCOMPATIBLE CHANGES
-
+
+ TEZ-720. Inconsistency between VertexState and VertexStatus.State.
+
TEZ-41. Get VertexCommitter from API and remove MRVertexOutputCommitter.
Release 0.2.0 - 2013-11-30
http://git-wip-us.apache.org/repos/asf/incubator-tez/blob/462696e0/tez-api/src/main/java/org/apache/tez/dag/api/client/VertexStatus.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/dag/api/client/VertexStatus.java b/tez-api/src/main/java/org/apache/tez/dag/api/client/VertexStatus.java
index 5ea190f..2421eec 100644
--- a/tez-api/src/main/java/org/apache/tez/dag/api/client/VertexStatus.java
+++ b/tez-api/src/main/java/org/apache/tez/dag/api/client/VertexStatus.java
@@ -21,21 +21,25 @@ package org.apache.tez.dag.api.client;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
+import com.google.common.annotations.VisibleForTesting;
import org.apache.tez.common.counters.TezCounters;
import org.apache.tez.dag.api.DagTypeConverters;
+import org.apache.tez.dag.api.records.DAGProtos;
import org.apache.tez.dag.api.records.DAGProtos.VertexStatusProtoOrBuilder;
import org.apache.tez.dag.api.TezUncheckedException;
public class VertexStatus {
public enum State {
+ NEW,
+ INITIALIZING,
INITED,
RUNNING,
SUCCEEDED,
- KILLED,
FAILED,
+ KILLED,
ERROR,
- TERMINATING,
+ TERMINATING
}
VertexStatusProtoOrBuilder proxy = null;
@@ -48,24 +52,33 @@ public class VertexStatus {
}
public State getState() {
- switch(proxy.getState()) {
- case VERTEX_INITED:
- return VertexStatus.State.INITED;
- case VERTEX_RUNNING:
- return VertexStatus.State.RUNNING;
- case VERTEX_SUCCEEDED:
- return VertexStatus.State.SUCCEEDED;
- case VERTEX_FAILED:
- return VertexStatus.State.FAILED;
- case VERTEX_KILLED:
- return VertexStatus.State.KILLED;
- case VERTEX_ERROR:
- return VertexStatus.State.ERROR;
- case VERTEX_TERMINATING:
- return VertexStatus.State.TERMINATING;
- default:
- throw new TezUncheckedException(
- "Unsupported value for VertexStatus.State : " + proxy.getState());
+ return getState(proxy.getState());
+ }
+
+ @VisibleForTesting
+ static State getState(DAGProtos.VertexStatusStateProto stateProto) {
+ switch(stateProto) {
+ case VERTEX_NEW:
+ return VertexStatus.State.NEW;
+ case VERTEX_INITIALIZING:
+ return VertexStatus.State.INITIALIZING;
+ case VERTEX_INITED:
+ return VertexStatus.State.INITED;
+ case VERTEX_RUNNING:
+ return VertexStatus.State.RUNNING;
+ case VERTEX_SUCCEEDED:
+ return VertexStatus.State.SUCCEEDED;
+ case VERTEX_FAILED:
+ return VertexStatus.State.FAILED;
+ case VERTEX_KILLED:
+ return VertexStatus.State.KILLED;
+ case VERTEX_ERROR:
+ return VertexStatus.State.ERROR;
+ case VERTEX_TERMINATING:
+ return VertexStatus.State.TERMINATING;
+ default:
+ throw new TezUncheckedException(
+ "Unsupported value for VertexStatus.State : " + stateProto);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tez/blob/462696e0/tez-api/src/main/proto/DAGApiRecords.proto
----------------------------------------------------------------------
diff --git a/tez-api/src/main/proto/DAGApiRecords.proto b/tez-api/src/main/proto/DAGApiRecords.proto
index aae4e63..e133297 100644
--- a/tez-api/src/main/proto/DAGApiRecords.proto
+++ b/tez-api/src/main/proto/DAGApiRecords.proto
@@ -153,13 +153,15 @@ message ProgressProto {
}
enum VertexStatusStateProto {
- VERTEX_INITED = 0;
- VERTEX_RUNNING = 1;
- VERTEX_SUCCEEDED = 2;
- VERTEX_KILLED = 3;
- VERTEX_FAILED = 4;
- VERTEX_ERROR = 5;
- VERTEX_TERMINATING = 6;
+ VERTEX_NEW = 0;
+ VERTEX_INITIALIZING = 1;
+ VERTEX_INITED = 2;
+ VERTEX_RUNNING = 3;
+ VERTEX_SUCCEEDED = 4;
+ VERTEX_FAILED = 5;
+ VERTEX_KILLED = 6;
+ VERTEX_ERROR = 7;
+ VERTEX_TERMINATING = 8;
}
message VertexStatusProto {
http://git-wip-us.apache.org/repos/asf/incubator-tez/blob/462696e0/tez-dag/src/main/java/org/apache/tez/dag/api/client/VertexStatusBuilder.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/api/client/VertexStatusBuilder.java b/tez-dag/src/main/java/org/apache/tez/dag/api/client/VertexStatusBuilder.java
index 47bbb2c..0e693b8 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/api/client/VertexStatusBuilder.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/api/client/VertexStatusBuilder.java
@@ -20,6 +20,7 @@ package org.apache.tez.dag.api.client;
import java.util.List;
+import com.google.common.annotations.VisibleForTesting;
import org.apache.tez.common.counters.TezCounters;
import org.apache.tez.dag.api.DagTypeConverters;
import org.apache.tez.dag.api.records.DAGProtos.VertexStatusProto;
@@ -58,26 +59,29 @@ public class VertexStatusBuilder extends VertexStatus {
return getBuilder().build();
}
- private VertexStatusStateProto getProtoState(VertexState state) {
+ @VisibleForTesting
+ static VertexStatusStateProto getProtoState(VertexState state) {
switch(state) {
- case NEW:
- case INITIALIZING:
- case INITED:
- return VertexStatusStateProto.VERTEX_INITED;
- case RUNNING:
- return VertexStatusStateProto.VERTEX_RUNNING;
- case SUCCEEDED:
- return VertexStatusStateProto.VERTEX_SUCCEEDED;
- case FAILED:
- return VertexStatusStateProto.VERTEX_FAILED;
- case KILLED:
- return VertexStatusStateProto.VERTEX_KILLED;
- case TERMINATING:
- return VertexStatusStateProto.VERTEX_TERMINATING;
- case ERROR:
- return VertexStatusStateProto.VERTEX_ERROR;
- default:
- throw new TezUncheckedException("Unsupported value for VertexState : " + state);
+ case NEW:
+ return VertexStatusStateProto.VERTEX_NEW;
+ case INITIALIZING:
+ return VertexStatusStateProto.VERTEX_INITIALIZING;
+ case INITED:
+ return VertexStatusStateProto.VERTEX_INITED;
+ case RUNNING:
+ return VertexStatusStateProto.VERTEX_RUNNING;
+ case SUCCEEDED:
+ return VertexStatusStateProto.VERTEX_SUCCEEDED;
+ case FAILED:
+ return VertexStatusStateProto.VERTEX_FAILED;
+ case KILLED:
+ return VertexStatusStateProto.VERTEX_KILLED;
+ case TERMINATING:
+ return VertexStatusStateProto.VERTEX_TERMINATING;
+ case ERROR:
+ return VertexStatusStateProto.VERTEX_ERROR;
+ default:
+ throw new TezUncheckedException("Unsupported value for VertexState : " + state);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tez/blob/462696e0/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestVertexStatusBuilder.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestVertexStatusBuilder.java b/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestVertexStatusBuilder.java
new file mode 100644
index 0000000..e965bca
--- /dev/null
+++ b/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestVertexStatusBuilder.java
@@ -0,0 +1,39 @@
+/**
+ * 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.tez.dag.api.client;
+
+import org.apache.tez.dag.api.records.DAGProtos;
+import org.apache.tez.dag.app.dag.VertexState;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestVertexStatusBuilder {
+
+ @Test
+ public void testVertexStateConversion() {
+ for (VertexState state : VertexState.values()) {
+ DAGProtos.VertexStatusStateProto stateProto =
+ VertexStatusBuilder.getProtoState(state);
+ VertexStatus.State clientState =
+ VertexStatus.getState(stateProto);
+ Assert.assertEquals(state.name(), clientState.name());
+ }
+ }
+
+}