Repository: samza
Updated Branches:
  refs/heads/master a56a77769 -> 7f15302b0


SAMZA-894 - Refactor container allocator logic


Project: http://git-wip-us.apache.org/repos/asf/samza/repo
Commit: http://git-wip-us.apache.org/repos/asf/samza/commit/7f15302b
Tree: http://git-wip-us.apache.org/repos/asf/samza/tree/7f15302b
Diff: http://git-wip-us.apache.org/repos/asf/samza/diff/7f15302b

Branch: refs/heads/master
Commit: 7f15302b056f19197fb50733135ab80d479fd1e7
Parents: a56a777
Author: Jagadish Venkatraman <jagadish1...@gmail.com>
Authored: Wed Apr 20 12:53:41 2016 -0700
Committer: Navina Ramesh <nram...@linkedin.com>
Committed: Wed Apr 20 12:53:41 2016 -0700

----------------------------------------------------------------------
 .../samza/job/yarn/ContainerRequestState.java   | 21 ++++----------------
 1 file changed, 4 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/samza/blob/7f15302b/samza-yarn/src/main/java/org/apache/samza/job/yarn/ContainerRequestState.java
----------------------------------------------------------------------
diff --git 
a/samza-yarn/src/main/java/org/apache/samza/job/yarn/ContainerRequestState.java 
b/samza-yarn/src/main/java/org/apache/samza/job/yarn/ContainerRequestState.java
index 3e3f48c..57ce350 100644
--- 
a/samza-yarn/src/main/java/org/apache/samza/job/yarn/ContainerRequestState.java
+++ 
b/samza-yarn/src/main/java/org/apache/samza/job/yarn/ContainerRequestState.java
@@ -121,14 +121,11 @@ public class ContainerRequestState {
         int requestCountOnThisHost = requestCount.get();
         List<Container> allocatedContainersOnThisHost = 
allocatedContainers.get(hostName);
         if (requestCountOnThisHost > 0) {
-          if (allocatedContainersOnThisHost == null) {
+          if (allocatedContainersOnThisHost == null || 
allocatedContainersOnThisHost.size() < requestCountOnThisHost) {
             log.debug("Saving the container {} in the buffer for {}", 
container.getId(), hostName);
             addToAllocatedContainerList(hostName, container);
-          } else {
-            if (allocatedContainersOnThisHost.size() < requestCountOnThisHost) 
{
-              log.debug("Saving the container {} in the buffer for {}", 
container.getId(), hostName);
-              addToAllocatedContainerList(hostName, container);
-            } else {
+          }
+          else {
               /**
                * The RM may allocate more containers on a given host than 
requested. In such a case, even though the
                * requestCount != 0, it will be greater than the total request 
count for that host. Hence, it should be
@@ -146,19 +143,9 @@ public class ContainerRequestState {
               addToAllocatedContainerList(ANY_HOST, container);
             }
           }
-        } else {
-          log.debug(
-              "This host was never requested. Hence, saving the container {} 
in the buffer for ANY_HOST",
-              new Object[]{
-                  hostName,
-                  requestCountOnThisHost,
-                  container.getId()
-              }
-          );
-          addToAllocatedContainerList(ANY_HOST, container);
         }
       }
-    } else {
+     else {
       log.debug("Saving the container {} in the buffer for ANY_HOST", 
container.getId());
       addToAllocatedContainerList(ANY_HOST, container);
     }

Reply via email to