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 2021/04/02 22:09:55 UTC

[GitHub] [samza] mynameborat commented on a change in pull request #1478: SAMZA-2638: Skip container stop/restart for processors that have same work assignment across rebalances

mynameborat commented on a change in pull request #1478:
URL: https://github.com/apache/samza/pull/1478#discussion_r606449171



##########
File path: samza-core/src/main/java/org/apache/samza/job/model/JobModelUtil.java
##########
@@ -119,6 +120,47 @@ public static JobModel readJobModel(String jobModelVersion, MetadataStore metada
     }
   }
 
+  /**
+   * Compares the {@link ContainerModel} for a given <i>processorId</i> across two {@link JobModel}.
+   * @param processorId processor id for which work assignments are compared
+   * @param first first job model
+   * @param second second job model
+   * @return true - if {@link ContainerModel} for the processor is same across the {@link JobModel}
+   *         false - otherwise
+   */
+  public static boolean compareContainerModelForProcessor(String processorId, JobModel first, JobModel second) {
+    Preconditions.checkArgument(StringUtils.isNotBlank(processorId), "Processor id cannot be blank");
+    if (first == second) {
+      return true;
+    }
+
+    if (first == null || second == null) {
+      return false;
+    }
+
+    return compareContainerModel(first.getContainers().get(processorId), second.getContainers().get(processorId));

Review comment:
       JobModel guarantees `getContainers()` always returns non-null map instance.




-- 
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.

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