rayman7718 commented on a change in pull request #1580:
URL: https://github.com/apache/samza/pull/1580#discussion_r797234179



##########
File path: samza-core/src/main/java/org/apache/samza/container/RunLoop.java
##########
@@ -239,8 +258,29 @@ private void runTasks(IncomingMessageEnvelope envelope) {
     if (!shutdownNow) {
       if (envelope != null) {
         PendingEnvelope pendingEnvelope = new PendingEnvelope(envelope);
-        for (AsyncTaskWorker worker : 
sspToTaskWorkerMapping.get(envelope.getSystemStreamPartition())) {
-          worker.state.insertEnvelope(pendingEnvelope);
+        SystemStreamPartition sspOfEnvelope = null;
+        // when elasticity is enabled
+        // the tasks actually consume a keyBucket of the ssp.
+        // hence use the SSP with keybucket to find the worker(s) for the 
envelope
+        if (elasticityFactor <= 1) {
+          sspOfEnvelope = envelope.getSystemStreamPartition();
+        } else {
+          sspOfEnvelope = envelope.getSystemStreamPartition(elasticityFactor);
+          log.trace("elasticity enabled. using the ssp of the envelope as {}", 
sspOfEnvelope);
+        }
+        List<AsyncTaskWorker> listOfWorkersForEnvelope = 
sspToTaskWorkerMapping.get(sspOfEnvelope);
+        if (listOfWorkersForEnvelope != null) {
+          for (AsyncTaskWorker worker : listOfWorkersForEnvelope) {
+            worker.state.insertEnvelope(pendingEnvelope);
+          }
+        } else if (elasticityFactor > 1) {
+          // when elasticity is enabled

Review comment:
       Add comment 
   // is listOfWorkersForEnvelope is null and elascity factor > 1, then 




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