Repository: ambari Updated Branches: refs/heads/trunk bbde6b915 -> 261f9e73c
AMBARI-11038. Cluster creation using blueprint is using INITIAL configs Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/261f9e73 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/261f9e73 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/261f9e73 Branch: refs/heads/trunk Commit: 261f9e73c45e01b40f7bb1bd316742e3da2cb07c Parents: bbde6b9 Author: Sumit Mohanty <[email protected]> Authored: Fri May 8 22:12:59 2015 -0700 Committer: Sumit Mohanty <[email protected]> Committed: Fri May 8 22:12:59 2015 -0700 ---------------------------------------------------------------------- .../ambari/server/topology/TopologyManager.java | 17 ++++++++++++++-- .../server/topology/TopologyManagerTest.java | 21 +++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/261f9e73/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java index 5ea175f..864655d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java @@ -99,8 +99,8 @@ public class TopologyManager { String clusterName = topology.getClusterName(); clusterTopologyMap.put(clusterName, topology); - LogicalRequest logicalRequest = processRequest(persistedRequest, topology); addClusterConfigRequest(new ClusterConfigurationRequest(ambariContext, topology, true)); + LogicalRequest logicalRequest = processRequest(persistedRequest, topology); //todo: this should be invoked as part of a generic lifecycle event which could possibly //todo: be tied to cluster state @@ -422,8 +422,21 @@ public class TopologyManager { } } + /** + * Making it a synchronous call as resolution of initial configurations need to happen before + * any tasks are created + * TODO - needs further review + */ private void addClusterConfigRequest(ClusterConfigurationRequest configurationRequest) { - executor.execute(new ConfigureClusterTask(configurationRequest)); + ConfigureClusterTask cct = new ConfigureClusterTask(configurationRequest); + cct.run(); + //executor.execute(new ConfigureClusterTask(configurationRequest)); + //try { + // executor.awaitTermination(10, TimeUnit.SECONDS); + // LOG.info("Resolved cluster topology configuration."); + //}catch(InterruptedException ex) { + // LOG.warn("Failed to resolve topology configuration"); + //} } private class ConfigureClusterTask implements Runnable { http://git-wip-us.apache.org/repos/asf/ambari/blob/261f9e73/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java index 0b6e8ff..53abd1c 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java @@ -72,6 +72,9 @@ public class TopologyManagerTest { private final ConfigurationRequest configurationRequest = createNiceMock(ConfigurationRequest.class); private final ConfigurationRequest configurationRequest2 = createNiceMock(ConfigurationRequest.class); private final ConfigurationRequest configurationRequest3 = createNiceMock(ConfigurationRequest.class); + private final ConfigurationRequest configurationRequest4 = createNiceMock(ConfigurationRequest.class); + private final ConfigurationRequest configurationRequest5 = createNiceMock(ConfigurationRequest.class); + private final ConfigurationRequest configurationRequest6 = createNiceMock(ConfigurationRequest.class); private final RequestStatusResponse requestStatusResponse = createNiceMock(RequestStatusResponse.class); private final ExecutorService executor = createStrictMock(ExecutorService.class); private final PersistedState persistedState = createStrictMock(PersistedState.class); @@ -115,6 +118,9 @@ public class TopologyManagerTest { private Capture<Map<String, Object>> configRequestPropertiesCapture; private Capture<Map<String, Object>> configRequestPropertiesCapture2; private Capture<Map<String, Object>> configRequestPropertiesCapture3; + private Capture<Map<String, Object>> configRequestPropertiesCapture4; + private Capture<Map<String, Object>> configRequestPropertiesCapture5; + private Capture<Map<String, Object>> configRequestPropertiesCapture6; private Capture<ClusterRequest> updateClusterConfigRequestCapture; private Capture<Runnable> updateConfigTaskCapture; @@ -125,6 +131,9 @@ public class TopologyManagerTest { configRequestPropertiesCapture = new Capture<Map<String, Object>>(); configRequestPropertiesCapture2 = new Capture<Map<String, Object>>(); configRequestPropertiesCapture3 = new Capture<Map<String, Object>>(); + configRequestPropertiesCapture4 = new Capture<Map<String, Object>>(); + configRequestPropertiesCapture5 = new Capture<Map<String, Object>>(); + configRequestPropertiesCapture6 = new Capture<Map<String, Object>>(); updateClusterConfigRequestCapture = new Capture<ClusterRequest>(); updateConfigTaskCapture = new Capture<Runnable>(); @@ -245,13 +254,19 @@ public class TopologyManagerTest { andReturn(Collections.singletonList(configurationRequest2)).once(); expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture3))). andReturn(Collections.singletonList(configurationRequest3)).once(); + expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture4))). + andReturn(Collections.singletonList(configurationRequest4)).once(); + expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture5))). + andReturn(Collections.singletonList(configurationRequest5)).once(); + expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture6))). + andReturn(Collections.singletonList(configurationRequest6)).once(); ambariContext.setConfigurationOnCluster(capture(updateClusterConfigRequestCapture)); - expectLastCall().times(3); + expectLastCall().times(6); ambariContext.persistInstallStateForUI(CLUSTER_NAME, STACK_NAME, STACK_VERSION); expectLastCall().once(); - executor.execute(capture(updateConfigTaskCapture)); - expectLastCall().once(); + //executor.execute(capture(updateConfigTaskCapture)); + //expectLastCall().times(0); expect(persistedState.getAllRequests()).andReturn(Collections.<ClusterTopology, List<LogicalRequest>>emptyMap()).once();
