rmatharu commented on a change in pull request #952: Improved standby-aware 
container allocation for active-containers on job redeploys
URL: https://github.com/apache/samza/pull/952#discussion_r268030497
 
 

 ##########
 File path: 
samza-core/src/main/java/org/apache/samza/clustermanager/StandbyContainerManager.java
 ##########
 @@ -226,15 +244,35 @@ private void initiateActiveContainerFailover(String 
containerID, String resource
         // use this standby if there was no previous failover for which this 
standbyResource was used
         if (!(failoverMetadata.isPresent() && 
failoverMetadata.get().isStandbyResourceUsed(standbyContainerResource.getResourceID())))
 {
 
-          log.info("Returning standby container {} in running state for active 
container {}", standbyContainerID,
-              activeContainerID);
-          return Optional.of(new Entry<>(standbyContainerID, 
standbyContainerResource));
+          log.info("Returning standby container {} in running state on host {} 
for active container {}", standbyContainerID, 
standbyContainerResource.getHost(), activeContainerID);
+          return standbyContainerResource.getHost();
         }
       }
     }
-
     log.info("Did not find any running standby container for active container 
{}", activeContainerID);
-    return Optional.empty();
+
+    // Now, we iterate over the list of last-known standbyHosts to check if 
anyone of them has not already been tried
+    Map<String, String> containerToHostMapping = 
this.samzaApplicationState.jobModelManager.jobModel().getAllContainerLocality();
+
+    for (String standbyContainerID : 
this.standbyContainerConstraints.get(activeContainerID)) {
+      String standbyHost = containerToHostMapping.get(standbyContainerID);
+
+      // if there is no last-known host for the standby, continue
+      if (standbyHost == null) {
+        continue;
 
 Review comment:
   i agree, simplified it a bit. 
   but we cant return any-host only once we're done iterating over all 
standbyContainerIDs.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to