SLIDER-967 First AA placement tests all working
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/47540882 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/47540882 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/47540882 Branch: refs/heads/feature/SLIDER-82-pass-3.1 Commit: 47540882e15af473281eee477ea3253d5bef5e58 Parents: a7ba72e Author: Steve Loughran <ste...@apache.org> Authored: Thu Nov 12 13:43:21 2015 +0000 Committer: Steve Loughran <ste...@apache.org> Committed: Thu Nov 12 13:43:21 2015 +0000 ---------------------------------------------------------------------- .../slider/server/appmaster/state/AppState.java | 22 ++++++++++---------- .../server/appmaster/state/RoleHistory.java | 2 -- .../appstate/TestMockAppStateAAPlacement.groovy | 11 ++++++---- 3 files changed, 18 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/47540882/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java index c960510..0c66e25 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java @@ -2187,17 +2187,6 @@ public class AppState { // add all requests to the operations list operations.addAll(allocation.operations); - // now for AA requests, add some more - if (role.isAntiAffinePlacement()) { - role.completeOutstandingAARequest(); - if (role.getPendingAntiAffineRequests() > 0) { - // still an outstanding AA request: need to issue a new one. - log.info("Asking for next container for AA role {}", roleName); - role.decPendingAntiAffineRequests(); - addContainerRequest(operations, createContainerRequest(role)); - } - } - //look for condition where we get more back than we asked if (allocated > desired) { log.info("Discarding surplus {} container {} on {}", roleName, cid, @@ -2228,6 +2217,17 @@ public class AppState { if (request != null) { operations.add(request); } + // now for AA requests, add some more + if (role.isAntiAffinePlacement()) { + role.completeOutstandingAARequest(); + if (role.getPendingAntiAffineRequests() > 0) { + // still an outstanding AA request: need to issue a new one. + log.info("Asking for next container for AA role {}", roleName); + role.decPendingAntiAffineRequests(); + addContainerRequest(operations, createContainerRequest(role)); + } + } + } } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/47540882/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleHistory.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleHistory.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleHistory.java index 8a840fc..d7e6050 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleHistory.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleHistory.java @@ -749,8 +749,6 @@ public class RoleHistory { sortRecentNodeList(role); } } - // TODO: AA placement: now request a new node - return outcome; } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/47540882/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateAAPlacement.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateAAPlacement.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateAAPlacement.groovy index 64c0362..c98f3bf 100644 --- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateAAPlacement.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateAAPlacement.groovy @@ -30,7 +30,7 @@ import org.apache.slider.server.appmaster.model.mock.MockRoles import org.apache.slider.server.appmaster.operations.AbstractRMOperation import org.apache.slider.server.appmaster.state.AppStateBindingInfo import org.apache.slider.server.appmaster.state.ContainerAssignment -import org.apache.slider.server.appmaster.state.NodeInstance +import org.apache.slider.server.appmaster.state.NodeMap import org.apache.slider.server.appmaster.state.RoleInstance import org.apache.slider.server.appmaster.state.RoleStatus import org.junit.Test @@ -85,8 +85,7 @@ class TestMockAppStateAAPlacement extends BaseMockAppStateTest @Test public void testAllocateAANoLabel() throws Throwable { - def nodemap = appState.roleHistory.cloneNodemap() - assert nodemap.size() > 0 + assert cloneNodemap().size() > 0 // want multiple instances, so there will be iterations @@ -107,7 +106,7 @@ class TestMockAppStateAAPlacement extends BaseMockAppStateTest appState.onContainersAllocated([allocated], assignments, operations) def host = allocated.nodeId.host - def hostInstance = nodemap.get(host) + def hostInstance = cloneNodemap().get(host) assert hostInstance.get(aaRole.key).starting == 1 assert !hostInstance.canHost(aaRole.key, "") assert !hostInstance.canHost(aaRole.key, null) @@ -146,6 +145,10 @@ class TestMockAppStateAAPlacement extends BaseMockAppStateTest assertAllContainersAA(); } + protected NodeMap cloneNodemap() { + appState.roleHistory.cloneNodemap() + } + @Test public void testAllocateFlexUp() throws Throwable { // want multiple instances, so there will be iterations