taegeonum commented on a change in pull request #317:
URL: https://github.com/apache/incubator-nemo/pull/317#discussion_r690016081



##########
File path: 
compiler/frontend/beam/src/main/java/org/apache/nemo/compiler/frontend/beam/transform/DoFnTransform.java
##########
@@ -93,6 +94,13 @@ public void onWatermark(final Watermark watermark) {
     checkAndFinishBundle();
   }
 
+  @Override
+  public void onLatencymark(final Latencymark latencymark) {
+    checkAndInvokeBundle();

Review comment:
       is it necessary? 

##########
File path: 
compiler/frontend/beam/src/main/java/org/apache/nemo/compiler/frontend/beam/transform/PushBackDoFnTransform.java
##########
@@ -160,6 +161,15 @@ public void onWatermark(final Watermark watermark) {
     checkAndFinishBundle();
   }
 
+
+  @Override
+  public void onLatencymark(final Latencymark latencymark) {
+    checkAndInvokeBundle();

Review comment:
       is it necessary?
   
   

##########
File path: 
runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/TaskMetric.java
##########
@@ -106,6 +110,33 @@ private void setTaskDuration(final long taskDuration) {
     this.taskDuration = taskDuration;
   }
 
+  /**
+   * Method related to stream metric.
+   */
+  public final Map<String, List<StreamMetric>> getStreamMetric() {
+    return this.streamMetrics;
+  }
+
+  private void setStreamMetric(final Map<String, StreamMetric> 
streamMetricMap) {
+    for (String sourceVertexId : streamMetricMap.keySet()) {
+      StreamMetric streamMetric = streamMetricMap.get(sourceVertexId);
+      this.streamMetrics.putIfAbsent(sourceVertexId, new ArrayList<>());
+      this.streamMetrics.get(sourceVertexId).add(streamMetric);
+    }
+  }
+
+  /**
+   * Method related to latency.
+   */
+  public final Map<String, List<LatencyMetric>> getLatencymarks() {
+    return this.latencymarks;
+  }
+
+  private void addLatencymark(final LatencyMetric latencyMetric) {
+    
this.latencymarks.putIfAbsent(latencyMetric.getLatencymark().getLastTaskId(), 
new ArrayList<>());

Review comment:
       Why `ArrayList`? Not `LinkedList`? 

##########
File path: 
compiler/frontend/beam/src/main/java/org/apache/nemo/compiler/frontend/beam/transform/DoFnTransform.java
##########
@@ -93,6 +94,13 @@ public void onWatermark(final Watermark watermark) {
     checkAndFinishBundle();
   }
 
+  @Override
+  public void onLatencymark(final Latencymark latencymark) {
+    checkAndInvokeBundle();
+    getOutputCollector().emitLatencymark(latencymark);
+    checkAndFinishBundle();

Review comment:
       is it necessary? 

##########
File path: 
common/src/main/java/org/apache/nemo/common/punctuation/Latencymark.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.nemo.common.punctuation;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Latency mark is conveyor that has data for debugging.
+ * It is created only from source vertex and record the timestamp when it is 
created and taskId where it is created.
+ */
+public final class Latencymark implements Serializable {
+  private final String createdtaskId;
+  private String lastTaskId;
+  private final long timestamp;
+
+  /**
+   * @param taskId task id where it is created
+   * @param timestamp timestamp when it is created
+   */
+  public Latencymark(final String taskId, final long timestamp) {
+    this.createdtaskId = taskId;
+    this.timestamp = timestamp;
+    this.lastTaskId = "";
+  }
+
+  /**
+   * @return the latencymark timestamp
+   */
+  public long getTimestamp() {
+    return timestamp;
+  }
+
+  /**
+   * @return the task id where it is created
+   */
+  public String getCreatedtaskId() {
+    return createdtaskId;
+  }
+
+
+  /**
+   * @return the task id where it is delivered from. task id of upstream task

Review comment:
       `task id of upstream task`? what does it mean? 

##########
File path: 
common/src/main/java/org/apache/nemo/common/punctuation/Latencymark.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.nemo.common.punctuation;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Latency mark is conveyor that has data for debugging.
+ * It is created only from source vertex and record the timestamp when it is 
created and taskId where it is created.
+ */
+public final class Latencymark implements Serializable {
+  private final String createdtaskId;
+  private String lastTaskId;
+  private final long timestamp;
+
+  /**
+   * @param taskId task id where it is created
+   * @param timestamp timestamp when it is created
+   */
+  public Latencymark(final String taskId, final long timestamp) {
+    this.createdtaskId = taskId;
+    this.timestamp = timestamp;
+    this.lastTaskId = "";
+  }
+
+  /**
+   * @return the latencymark timestamp
+   */
+  public long getTimestamp() {
+    return timestamp;
+  }
+
+  /**
+   * @return the task id where it is created
+   */
+  public String getCreatedtaskId() {
+    return createdtaskId;
+  }
+
+
+  /**
+   * @return the task id where it is delivered from. task id of upstream task
+   */
+  public String getLastTaskId() {
+    return lastTaskId;
+  }
+
+  public void setLastTaskId(final String currTaskId) {
+    lastTaskId = currTaskId;
+  }
+
+  @Override
+  public boolean equals(final Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    final Latencymark latencymark = (Latencymark) o;
+    return (timestamp == latencymark.timestamp)
+      && (createdtaskId.equals(latencymark.createdtaskId)
+      && (lastTaskId.equals(latencymark.lastTaskId)));
+  }
+
+
+  @Override
+  public String toString() {
+    return String.valueOf("Latencymark(" + createdtaskId + ", " + timestamp + 
")");

Review comment:
       `String.valueOf` is unnecessary

##########
File path: 
common/src/main/java/org/apache/nemo/common/punctuation/Latencymark.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.nemo.common.punctuation;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Latency mark is conveyor that has data for debugging.
+ * It is created only from source vertex and record the timestamp when it is 
created and taskId where it is created.

Review comment:
       Why does it contain taskId? 

##########
File path: 
compiler/frontend/beam/src/main/java/org/apache/nemo/compiler/frontend/beam/transform/GBKTransform.java
##########
@@ -166,6 +167,13 @@ public void onWatermark(final Watermark watermark) throws 
RuntimeException {
     checkAndFinishBundle();
   }
 
+  @Override
+  public void onLatencymark(final Latencymark latencymark) {
+    checkAndInvokeBundle();
+    getOutputCollector().emitLatencymark(latencymark);
+    checkAndFinishBundle();

Review comment:
       is it necessary?
   
   

##########
File path: 
compiler/frontend/spark/src/main/java/org/apache/nemo/compiler/frontend/spark/transform/FlatMapTransform.java
##########
@@ -61,6 +62,11 @@ public void onWatermark(final Watermark watermark) {
     outputCollector.emitWatermark(watermark);
   }
 
+  @Override
+  public void onLatencymark(final Latencymark latencymark) {

Review comment:
       Lots of duplicate `onLatencyMark` code blocks. It would be good to 
refactor it. 

##########
File path: 
compiler/frontend/beam/src/main/java/org/apache/nemo/compiler/frontend/beam/transform/GBKTransform.java
##########
@@ -166,6 +167,13 @@ public void onWatermark(final Watermark watermark) throws 
RuntimeException {
     checkAndFinishBundle();
   }
 
+  @Override
+  public void onLatencymark(final Latencymark latencymark) {
+    checkAndInvokeBundle();

Review comment:
       is it necessary?
   
   

##########
File path: conf/src/main/java/org/apache/nemo/conf/JobConf.java
##########
@@ -250,6 +250,25 @@
   public final class ExecutorJSONContents implements Name<String> {
   }
 
+  ///////////////////////// Metric Configurations
+  /**
+   * Period how often stream metrics are recorded. the unit of period is 
millisecond.
+   * -1 indicates that metrics are not recorded periodically.
+   */
+  @NamedParameter(doc = "Period how often stream-related metrics are recorded. 
the unit of period is millisecond.",
+    short_name = "stream_metric_period", default_value = "-1")
+  public final class StreamMetricPeriod implements Name<Integer> {
+  }
+
+  /**
+   * Period how often latencymarks are sent from source vertex. the unit of 
period is millisecond.
+   * -1 indicates that latencymarks are not sent.
+   */
+  @NamedParameter(doc = "Period how often latencymarks are sent from source 
vertex. the unit of period is millisecond.",

Review comment:
       the -> The

##########
File path: 
common/src/main/java/org/apache/nemo/common/ir/vertex/transform/Transform.java
##########
@@ -57,6 +58,8 @@
    */
   void onWatermark(Watermark watermark);
 

Review comment:
       Please add comments. 

##########
File path: 
compiler/frontend/spark/src/main/java/org/apache/nemo/compiler/frontend/spark/transform/MapToPairTransform.java
##########
@@ -64,6 +65,11 @@ public void onWatermark(final Watermark watermark) {
     outputCollector.emitWatermark(watermark);
   }
 
+  @Override
+  public void onLatencymark(final Latencymark latencymark) {

Review comment:
       Lots of duplicate onLatencyMark code blocks. It would be good to 
refactor it.
   
   

##########
File path: 
runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/LatencyMetric.java
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.nemo.runtime.common.metric;
+
+import org.apache.nemo.common.punctuation.Latencymark;
+
+import java.io.Serializable;
+
+/**
+ * Metric class for latency.
+ */
+public class LatencyMetric implements Serializable {

Review comment:
       final

##########
File path: conf/src/main/java/org/apache/nemo/conf/JobConf.java
##########
@@ -250,6 +250,25 @@
   public final class ExecutorJSONContents implements Name<String> {
   }
 
+  ///////////////////////// Metric Configurations
+  /**
+   * Period how often stream metrics are recorded. the unit of period is 
millisecond.
+   * -1 indicates that metrics are not recorded periodically.
+   */
+  @NamedParameter(doc = "Period how often stream-related metrics are recorded. 
the unit of period is millisecond.",

Review comment:
       the -> The

##########
File path: 
compiler/frontend/beam/src/main/java/org/apache/nemo/compiler/frontend/beam/transform/PushBackDoFnTransform.java
##########
@@ -160,6 +161,15 @@ public void onWatermark(final Watermark watermark) {
     checkAndFinishBundle();
   }
 
+
+  @Override
+  public void onLatencymark(final Latencymark latencymark) {
+    checkAndInvokeBundle();
+    getOutputCollector().emitLatencymark(latencymark);
+    checkAndFinishBundle();

Review comment:
       is it necessary?
   
   

##########
File path: 
runtime/executor/src/main/java/org/apache/nemo/runtime/executor/datatransfer/NemoEventDecoderFactory.java
##########
@@ -84,6 +85,9 @@ public Object decode() throws IOException {
         final WatermarkWithIndex watermarkWithIndex =
           (WatermarkWithIndex) SerializationUtils.deserialize(inputStream);
         return watermarkWithIndex;
+      } else if (isWatermark == 0x02) {

Review comment:
       We need to change the variable name `isWatermark`

##########
File path: 
runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/DataUtil.java
##########
@@ -304,6 +305,27 @@ public long getNumEncodedBytes() {
       }
       return numEncodedBytes;
     }
+
+    @Override
+    public long getCurrNumSerializedBytes() {
+      if (serializedCountingStream == null) {
+        return numSerializedBytes;
+      }
+      return numSerializedBytes + serializedCountingStream.getCount();
+    }
+
+    @Override
+    public long getCurrNumEncodedBytes() {

Review comment:
       What is the difference between getNumEncodedBytes and 
getCurrNumEncodedBytes?
   
   

##########
File path: 
runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/StreamMetric.java
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.nemo.runtime.common.metric;
+
+import java.io.Serializable;
+
+/**
+ * Metric associated with stream. it is periodically recorded.
+ */
+public class StreamMetric implements Serializable {

Review comment:
       final

##########
File path: 
runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/LatencyMetric.java
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.nemo.runtime.common.metric;
+
+import org.apache.nemo.common.punctuation.Latencymark;
+
+import java.io.Serializable;
+
+/**
+ * Metric class for latency.

Review comment:
       What is the purpose of this class?

##########
File path: 
runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/DataUtil.java
##########
@@ -304,6 +305,27 @@ public long getNumEncodedBytes() {
       }
       return numEncodedBytes;
     }
+
+    @Override
+    public long getCurrNumSerializedBytes() {

Review comment:
       What is the difference between `getNumSerializedBytes` and 
`getCurrNumSerializedBytes`?  and why do we need this method? 

##########
File path: 
runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/TaskMetric.java
##########
@@ -261,6 +292,12 @@ public final String getId() {
   public final boolean processMetricMessage(final String metricField, final 
byte[] metricValue) {
     LOG.debug("metric {} has just arrived!", metricField);
     switch (metricField) {
+      case "streamMetric":

Review comment:
       Hard-coded strings doesn't look good. Maybe we need to refactor it in 
the future. 

##########
File path: 
runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/StreamMetric.java
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.nemo.runtime.common.metric;
+
+import java.io.Serializable;
+
+/**
+ * Metric associated with stream. it is periodically recorded.

Review comment:
       Metric -> Metrics. it -> It 

##########
File path: 
runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/TaskMetric.java
##########
@@ -34,6 +36,8 @@
   private String containerId = "";
   private int scheduleAttempt = -1;
   private List<StateTransitionEvent<TaskState.State>> stateTransitionEvents = 
new ArrayList<>();
+  private final Map<String, List<StreamMetric>> streamMetrics = new 
HashMap<>();

Review comment:
       What is the key of this map? 

##########
File path: 
compiler/frontend/spark/src/main/java/org/apache/nemo/compiler/frontend/spark/transform/FlatMapTransform.java
##########
@@ -61,6 +62,11 @@ public void onWatermark(final Watermark watermark) {
     outputCollector.emitWatermark(watermark);
   }
 
+  @Override
+  public void onLatencymark(final Latencymark latencymark) {

Review comment:
       Perhaps we can create an abstract class that contains 61-68 code blocks 
and inherit the abstract class here 

##########
File path: 
runtime/executor/src/main/java/org/apache/nemo/runtime/executor/datatransfer/OperatorVertexOutputCollector.java
##########
@@ -131,4 +132,33 @@ public void emitWatermark(final Watermark watermark) {
       }
     }
   }
+
+  @Override
+  public void emitLatencymark(final Latencymark latencymark) {

Review comment:
       Lot's of duplicate codes with emitWatermark. We need refactoring 

##########
File path: 
runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/TaskExecutor.java
##########
@@ -377,6 +450,22 @@ private void doExecute() {
     }
   }
 
+  /**
+   * Send data-processing metrics.
+   */
+  public void sendMetrics() {
+    metricMessageSender.send(TASK_METRIC_ID, taskId, "boundedSourceReadTime",

Review comment:
       Maybe we need to create Metrics class and add static variables, instead 
of using hard-coded strings. 




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to