You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by GitBox <gi...@apache.org> on 2022/07/26 17:32:40 UTC

[GitHub] [samza] mynameborat commented on a diff in pull request #1616: SAMZA-2751: [Pipeline Drain] RunLoop and High Level API changes for Drain

mynameborat commented on code in PR #1616:
URL: https://github.com/apache/samza/pull/1616#discussion_r927135337


##########
samza-core/src/main/java/org/apache/samza/config/JobConfig.java:
##########
@@ -169,6 +169,9 @@ public class JobConfig extends MapConfig {
   public static final String DRAIN_MONITOR_ENABLED = "samza.drain-monitor.enabled";
   public static final boolean DRAIN_MONITOR_ENABLED_DEFAULT = false;
 
+  public static final String DRAIN_MONITOR_POLL_INTERVAL_MILLIS = "samza.drain-monitor.poll.interval.ms";
+  public static final long DRAIN_MONITOR_POLL_INTERVAL_MILLIS_DEFAULT = 60_000;

Review Comment:
   Can we be consistent and call these as `job.drain-monitor...` instead of `samza.drain-monitor...`? Same for enabled vs disabled config.



##########
samza-core/src/main/scala/org/apache/samza/container/TaskInstance.scala:
##########
@@ -613,14 +638,20 @@ class TaskInstance(
     // if elasticityFactor > 1, find the SSP with keyBucket
     var incomingMessageSsp = envelope.getSystemStreamPartition(elasticityFactor)
 
-    // if envelope is end of stream or watermark, it needs to be routed to all tasks consuming the ssp irresp of keyBucket
+    // if envelope is end of stream or watermark or drain,
+    // it needs to be routed to all tasks consuming the ssp irresp of keyBucket
     val messageType = MessageType.of(envelope.getMessage)
-    if (envelope.isEndOfStream() || MessageType.END_OF_STREAM == messageType || MessageType.WATERMARK == messageType) {
+    if (envelope.isEndOfStream()
+      || envelope.isDrain()
+      || messageType == MessageType.END_OF_STREAM
+      || messageType == MessageType.DRAIN
+      || messageType == MessageType.WATERMARK) {

Review Comment:
   what is the scenario where the message envelope will have `envelope.isDrain()` vs when `messageType == MessageType.DRAIN`?
   
   Wondering why you need both.



##########
samza-core/src/main/java/org/apache/samza/container/RunLoopFactory.java:
##########
@@ -34,14 +34,15 @@
 public class RunLoopFactory {
   private static final Logger log = LoggerFactory.getLogger(RunLoopFactory.class);
 
-  public static Runnable createRunLoop(scala.collection.immutable.Map<TaskName, RunLoopTask> taskInstances,
+  public static RunLoop createRunLoop(scala.collection.immutable.Map<TaskName, RunLoopTask> taskInstances,

Review Comment:
   why is this change in return type needed?



##########
samza-api/src/main/java/org/apache/samza/system/DrainMessage.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.samza.system;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * The DrainMessage is a control message that is sent out to next stage
+ * once the task has consumed to the end of a bounded stream.
+ */
+public class DrainMessage extends ControlMessage {
+  /**
+   * Id used to invalidate DrainMessages between runs. Ties to app.run.id from config.
+   */
+  private final String runId;
+
+  public DrainMessage(String runId) {
+    this(null, runId);
+  }
+
+  public DrainMessage(@JsonProperty("task-name") String taskName, @JsonProperty("run-id") String runId) {

Review Comment:
   can you follow the existing pattern of using Mixin instead of adding annotations to the model classes? E.g., https://github.com/apache/samza/blob/master/samza-core/src/main/java/org/apache/samza/serializers/model/JsonJobCoordinatorMetadataMixIn.java



##########
samza-core/src/main/java/org/apache/samza/coordinator/metadatastore/NamespaceAwareCoordinatorStreamStore.java:
##########
@@ -35,6 +35,10 @@ public class NamespaceAwareCoordinatorStreamStore implements MetadataStore {
   private final MetadataStore metadataStore;
   private final String namespace;
 
+  public MetadataStore getMetadataStore() {
+    return metadataStore;
+  }
+

Review Comment:
   Why is this needed? If its used in tests, can we make it package private and add annotation `VisibleForTesting` instead?



##########
samza-core/src/main/scala/org/apache/samza/storage/ContainerStorageManager.java:
##########
@@ -934,7 +941,9 @@ private void startSideInputs() {
         taskConfig.getMaxIdleMs(),
         sideInputContainerMetrics,
         System::nanoTime,
-        false); // commit must be synchronous to ensure integrity of state flush
+        false,
+        DEFAULT_SIDE_INPUT_ELASTICITY_FACTOR,

Review Comment:
   does this change have any impact? what is the elasticity factor defaults to with the constructor prior to this change? Is this the same as `DEFAULT_SIDE_INPUT_ELASTICITY_FACTOR`



##########
samza-core/src/main/scala/org/apache/samza/container/TaskInstance.scala:
##########
@@ -72,6 +72,8 @@ class TaskInstance(
 
   val taskName: TaskName = taskModel.getTaskName
   val isInitableTask = task.isInstanceOf[InitableTask]
+  //val isDrainTask = classOf[DrainListenerTask].isAssignableFrom(task.getClass)

Review Comment:
   Remove commented code?



-- 
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: commits-unsubscribe@samza.apache.org

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