You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@samza.apache.org by GitBox <gi...@apache.org> on 2019/03/21 07:02:56 UTC

[GitHub] [samza] vjagadish1989 commented on a change in pull request #952: Improved standby-aware container allocation for active-containers on job redeploys

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

 ##########
 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:
   the flow is a bit circuitous. avoid the `continue` and consider returning `any-host` here?

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


With regards,
Apache Git Services