@Test public void testAdviseConfigurationWithOnlyStackDefaultsApplyWhenNoUserInputForDefault() throws StackAdvisorException, ConfigurationTopologyException { Map<String, Map<String, String>> props = createProps(); props.get("core-site").put("dummyKey3", "stackDefaultValue"); Map<String, AdvisedConfiguration> advisedConfigurations = new HashMap<String, AdvisedConfiguration>(); expect(clusterTopology.getBlueprint()).andReturn(blueprint).anyTimes(); expect(clusterTopology.getHostGroupInfo()).andReturn(createHostGroupInfo()).anyTimes(); expect(clusterTopology.getAdvisedConfigurations()).andReturn(advisedConfigurations).anyTimes(); expect(clusterTopology.getConfiguration()).andReturn(configuration).anyTimes(); expect(clusterTopology.isClusterKerberosEnabled()).andReturn(false).anyTimes(); expect(clusterTopology.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.ONLY_STACK_DEFAULTS_APPLY); expect(blueprint.getStack()).andReturn(stack).anyTimes(); expect(stack.getVersion()).andReturn("2.3").anyTimes(); expect(stack.getName()).andReturn("HDP").anyTimes(); expect(stack.getConfiguration(Arrays.asList("HDFS", "YARN", "HIVE"))).andReturn(createStackDefaults()).anyTimes(); expect(blueprint.getServices()).andReturn(Arrays.asList("HDFS", "YARN", "HIVE")).anyTimes(); expect(blueprint.getHostGroups()).andReturn(createHostGroupMap()).anyTimes(); expect(hostGroup.getComponentNames()).andReturn(Arrays.asList("comp1", "comp2")).anyTimes(); expect(stackAdvisorHelper.recommend(anyObject(StackAdvisorRequest.class))).andReturn(createRecommendationResponse()); expect(configuration.getFullProperties()).andReturn(props).anyTimes(); replay(clusterTopology, blueprint, stack, hostGroup, configuration, stackAdvisorHelper); underTest.adviseConfiguration(clusterTopology, props); assertTrue(advisedConfigurations.get("core-site").getProperties().containsKey("dummyKey1")); assertTrue(advisedConfigurations.get("core-site").getProperties().containsKey("dummyKey3")); assertTrue(advisedConfigurations.get("core-site").getPropertyValueAttributes().containsKey("dummyKey2")); assertTrue(advisedConfigurations.get("core-site").getPropertyValueAttributes().containsKey("dummyKey3")); assertEquals("dummyValue", advisedConfigurations.get("core-site").getProperties().get("dummyKey1")); assertEquals(Boolean.toString(true), advisedConfigurations.get("core-site") .getPropertyValueAttributes().get("dummyKey2").getDelete()); }
public void adviseConfiguration(ClusterTopology clusterTopology, Map<String, Map<String, String>> existingConfigurations) throws ConfigurationTopologyException { StackAdvisorRequest request = createStackAdvisorRequest(clusterTopology, StackAdvisorRequestType.CONFIGURATIONS); try { RecommendationResponse response = stackAdvisorHelper.recommend(request); addAdvisedConfigurationsToTopology(response, clusterTopology, existingConfigurations); } catch (StackAdvisorException e) { throw new ConfigurationTopologyException(RECOMMENDATION_FAILED, e); } catch (IllegalArgumentException e) { throw new ConfigurationTopologyException(INVALID_RESPONSE, e); } }
StackAdvisorBlueprintProcessor { public void adviseConfiguration(ClusterTopology clusterTopology, Map<String, Map<String, String>> existingConfigurations) throws ConfigurationTopologyException { StackAdvisorRequest request = createStackAdvisorRequest(clusterTopology, StackAdvisorRequestType.CONFIGURATIONS); try { RecommendationResponse response = stackAdvisorHelper.recommend(request); addAdvisedConfigurationsToTopology(response, clusterTopology, existingConfigurations); } catch (StackAdvisorException e) { throw new ConfigurationTopologyException(RECOMMENDATION_FAILED, e); } catch (IllegalArgumentException e) { throw new ConfigurationTopologyException(INVALID_RESPONSE, e); } } }
StackAdvisorBlueprintProcessor { public void adviseConfiguration(ClusterTopology clusterTopology, Map<String, Map<String, String>> existingConfigurations) throws ConfigurationTopologyException { StackAdvisorRequest request = createStackAdvisorRequest(clusterTopology, StackAdvisorRequestType.CONFIGURATIONS); try { RecommendationResponse response = stackAdvisorHelper.recommend(request); addAdvisedConfigurationsToTopology(response, clusterTopology, existingConfigurations); } catch (StackAdvisorException e) { throw new ConfigurationTopologyException(RECOMMENDATION_FAILED, e); } catch (IllegalArgumentException e) { throw new ConfigurationTopologyException(INVALID_RESPONSE, e); } }  }
StackAdvisorBlueprintProcessor { public void adviseConfiguration(ClusterTopology clusterTopology, Map<String, Map<String, String>> existingConfigurations) throws ConfigurationTopologyException { StackAdvisorRequest request = createStackAdvisorRequest(clusterTopology, StackAdvisorRequestType.CONFIGURATIONS); try { RecommendationResponse response = stackAdvisorHelper.recommend(request); addAdvisedConfigurationsToTopology(response, clusterTopology, existingConfigurations); } catch (StackAdvisorException e) { throw new ConfigurationTopologyException(RECOMMENDATION_FAILED, e); } catch (IllegalArgumentException e) { throw new ConfigurationTopologyException(INVALID_RESPONSE, e); } }  static void init(StackAdvisorHelper instance); void adviseConfiguration(ClusterTopology clusterTopology, Map<String, Map<String, String>> existingConfigurations); }
StackAdvisorBlueprintProcessor { public void adviseConfiguration(ClusterTopology clusterTopology, Map<String, Map<String, String>> existingConfigurations) throws ConfigurationTopologyException { StackAdvisorRequest request = createStackAdvisorRequest(clusterTopology, StackAdvisorRequestType.CONFIGURATIONS); try { RecommendationResponse response = stackAdvisorHelper.recommend(request); addAdvisedConfigurationsToTopology(response, clusterTopology, existingConfigurations); } catch (StackAdvisorException e) { throw new ConfigurationTopologyException(RECOMMENDATION_FAILED, e); } catch (IllegalArgumentException e) { throw new ConfigurationTopologyException(INVALID_RESPONSE, e); } }  static void init(StackAdvisorHelper instance); void adviseConfiguration(ClusterTopology clusterTopology, Map<String, Map<String, String>> existingConfigurations);  }