zentol commented on code in PR #19747:
URL: https://github.com/apache/flink/pull/19747#discussion_r874580409


##########
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphTestUtils.java:
##########
@@ -428,6 +428,18 @@ public static Execution getExecution(
         return 
ejv.getTaskVertices()[subtaskIndex].getCurrentExecutionAttempt();
     }
 
+    public static ExecutionAttemptID createExecutionAttemptId() {
+        return createExecutionAttemptId(new JobVertexID(0, 0), 0, 0);
+    }
+
+    public static ExecutionAttemptID createExecutionAttemptId(
+            JobVertexID jobVertexId, int subtaskIndex, int attemptNumber) {
+        return new ExecutionAttemptID(
+                new ExecutionGraphID(),
+                new ExecutionVertexID(jobVertexId, subtaskIndex),
+                attemptNumber);
+    }

Review Comment:
   I'd rather have these factory methods in the ExecutionAttemptID class so 
that they are available everywhere.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionAttemptID.java:
##########
@@ -68,19 +117,32 @@ public boolean equals(Object obj) {
             return true;
         } else if (obj != null && obj.getClass() == getClass()) {
             ExecutionAttemptID that = (ExecutionAttemptID) obj;
-            return that.executionAttemptId.equals(this.executionAttemptId);
+            return that.executionGraphId.equals(this.executionGraphId)
+                    && that.executionVertexId.equals(this.executionVertexId)
+                    && that.attemptNumber == this.attemptNumber;
         } else {
             return false;
         }
     }
 
     @Override
     public int hashCode() {
-        return executionAttemptId.hashCode();
+        return Objects.hash(executionGraphId, executionVertexId, 
attemptNumber);
     }
 
     @Override
     public String toString() {
-        return executionAttemptId.toString();
+        return String.format(
+                "%s_%s_%d", executionGraphId.toString(), executionVertexId, 
attemptNumber);
+    }
+
+    public String getLogString() {
+        if (DefaultExecutionGraph.LOG.isDebugEnabled()) {
+            return toString();
+        } else {
+            return String.format(
+                    "%s_%s_%d",
+                    executionGraphId.toString().substring(0, 4), 
executionVertexId, attemptNumber);

Review Comment:
   logging the EG ID is fine, but this can't be done in isolation. There must 
be a way to correlate this id with a specific job submission; for example we 
could log the EG ID when the EG for a given job was created.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ResultPartitionID.java:
##########
@@ -44,7 +47,12 @@ public final class ResultPartitionID implements Serializable 
{
 
     @VisibleForTesting
     public ResultPartitionID() {
-        this(new IntermediateResultPartitionID(), new ExecutionAttemptID());
+        this(
+                new IntermediateResultPartitionID(),
+                new ExecutionAttemptID(
+                        new ExecutionGraphID(),
+                        new ExecutionVertexID(new JobVertexID(0, 0), 0),
+                        0));

Review Comment:
   We could add a convenience constructor to avoid these changes.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionAttemptID.java:
##########
@@ -48,11 +47,6 @@ public class ExecutionAttemptID implements 
java.io.Serializable {
 
     private final int attemptNumber;
 
-    @VisibleForTesting
-    public ExecutionAttemptID() {

Review Comment:
   I'd prefer to keep this.



##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java:
##########
@@ -1420,6 +1422,13 @@ public void testRequestPartitionState() throws Exception 
{
         }
     }
 
+    private static ExecutionAttemptID 
deepCopyExecutionAttemptId(ExecutionAttemptID toCopy)
+            throws IOException, ClassNotFoundException {
+        return InstantiationUtil.deserializeObject(
+                InstantiationUtil.serializeObject(toCopy),
+                ExecutionGraphTestUtils.class.getClassLoader());
+    }
+

Review Comment:
   Why aren't you directly using `InstantiationUtils#clone`?



##########
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionAttemptID.java:
##########
@@ -68,19 +117,32 @@ public boolean equals(Object obj) {
             return true;
         } else if (obj != null && obj.getClass() == getClass()) {
             ExecutionAttemptID that = (ExecutionAttemptID) obj;
-            return that.executionAttemptId.equals(this.executionAttemptId);
+            return that.executionGraphId.equals(this.executionGraphId)
+                    && that.executionVertexId.equals(this.executionVertexId)
+                    && that.attemptNumber == this.attemptNumber;
         } else {
             return false;
         }
     }
 
     @Override
     public int hashCode() {
-        return executionAttemptId.hashCode();
+        return Objects.hash(executionGraphId, executionVertexId, 
attemptNumber);
     }
 
     @Override
     public String toString() {
-        return executionAttemptId.toString();
+        return String.format(
+                "%s_%s_%d", executionGraphId.toString(), executionVertexId, 
attemptNumber);
+    }
+
+    public String getLogString() {
+        if (DefaultExecutionGraph.LOG.isDebugEnabled()) {
+            return toString();
+        } else {
+            return String.format(
+                    "%s_%s_%d",
+                    executionGraphId.toString().substring(0, 4), 
executionVertexId, attemptNumber);

Review Comment:
   It might also make sense to return a more structured representation that 
actually tells the reader what they are looking at.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to