Examples of HostGroupConfigEntity


Examples of org.apache.ambari.server.orm.entities.HostGroupConfigEntity

                                             HostGroupEntity hostGroup) {

    Collection<HostGroupConfigEntity> configurations = new ArrayList<HostGroupConfigEntity>();
    if (propertyMaps != null) {
      for (Map<String, String> configuration : propertyMaps) {
        HostGroupConfigEntity configEntity = new HostGroupConfigEntity();
        configEntity.setHostGroupEntity(hostGroup);
        configEntity.setHostGroupName(hostGroup.getName());
        populateConfigurationEntity(hostGroup.getBlueprintName(), configuration, configEntity);
        configurations.add(configEntity);
      }
    }
    hostGroup.setConfigurations(configurations);
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.HostGroupConfigEntity

    HostGroupComponentEntity hostGroupComponent1 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent2 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent3 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent4 = createNiceMock(HostGroupComponentEntity.class);

    HostGroupConfigEntity hostGroupConfig = createNiceMock(HostGroupConfigEntity.class);

    ServiceResourceProvider serviceResourceProvider = createStrictMock(ServiceResourceProvider.class);
    ResourceProvider componentResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostComponentResourceProvider = createStrictMock(ResourceProvider.class);
    ConfigGroupResourceProvider configGroupResourceProvider = createStrictMock(ConfigGroupResourceProvider.class);
    PersistKeyValueImpl persistKeyValue = createNiceMock(PersistKeyValueImpl.class);

    Capture<ClusterRequest> createClusterRequestCapture = new Capture<ClusterRequest>();
    Capture<Set<ClusterRequest>> updateClusterRequestCapture = new Capture<Set<ClusterRequest>>();
    Capture<Map<String, String>> updateClusterPropertyMapCapture = new Capture<Map<String, String>>();
    Capture<Set<ClusterRequest>> updateClusterRequestCapture2 = new Capture<Set<ClusterRequest>>();
    Capture<Map<String, String>> updateClusterPropertyMapCapture2 = new Capture<Map<String, String>>();
    Capture<Set<ClusterRequest>> updateClusterRequestCapture3 = new Capture<Set<ClusterRequest>>();
    Capture<Map<String, String>> updateClusterPropertyMapCapture3 = new Capture<Map<String, String>>();
    Capture<Set<ClusterRequest>> updateClusterRequestCapture4 = new Capture<Set<ClusterRequest>>();
    Capture<Map<String, String>> updateClusterPropertyMapCapture4 = new Capture<Map<String, String>>();

    Capture<Request> serviceRequestCapture = new Capture<Request>();
    Capture<Request> componentRequestCapture = new Capture<Request>();
    Capture<Request> componentRequestCapture2 = new Capture<Request>();
    Capture<Request> hostRequestCapture = new Capture<Request>();
    Capture<Request> hostComponentRequestCapture = new Capture<Request>();
    Capture<Set<ConfigGroupRequest>> configGroupRequestCapture = new Capture<Set<ConfigGroupRequest>>();

    Set<StackServiceResponse> stackServiceResponses = new LinkedHashSet<StackServiceResponse>();
    stackServiceResponses.add(stackServiceResponse1);
    stackServiceResponses.add(stackServiceResponse2);

    // service1 has 3 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses1 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses1.add(stackServiceComponentResponse1);
    stackServiceComponentResponses1.add(stackServiceComponentResponse2);
    stackServiceComponentResponses1.add(stackServiceComponentResponse4);

    // service2 has 1 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses2 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses2.add(stackServiceComponentResponse3);

    // service1 has 2 config
    Set<StackConfigurationResponse> stackConfigurationResponses1 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses1.add(stackConfigurationResponse1);
    stackConfigurationResponses1.add(stackConfigurationResponse5);

    // service2 has 3 config
    Set<StackConfigurationResponse> stackConfigurationResponses2 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses2.add(stackConfigurationResponse2);
    stackConfigurationResponses2.add(stackConfigurationResponse3);
    stackConfigurationResponses2.add(stackConfigurationResponse4);

    Collection<HostGroupComponentEntity> hostGroupComponents = new LinkedHashSet<HostGroupComponentEntity>();
    hostGroupComponents.add(hostGroupComponent1);
    hostGroupComponents.add(hostGroupComponent2);
    hostGroupComponents.add(hostGroupComponent3);
    hostGroupComponents.add(hostGroupComponent4);

    // request properties
    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
    Map<String, Object> properties = new LinkedHashMap<String, Object>();

    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName);
    properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
    propertySet.add(properties);

    Collection<Map<String, Object>> hostGroups = new ArrayList<Map<String, Object>>();
    Map<String, Object> hostGroupProperties = new HashMap<String, Object>();
    hostGroups.add(hostGroupProperties);
    hostGroupProperties.put("name", "group1");
    Collection<Map<String, String>> hostGroupHosts = new ArrayList<Map<String, String>>();
    hostGroupProperties.put("hosts", hostGroupHosts);
    Map<String, String> hostGroupHostProperties = new HashMap<String, String>();
    hostGroupHostProperties.put("fqdn", "host.domain");
    hostGroupHosts.add(hostGroupHostProperties);
    properties.put("host_groups", hostGroups);

    Map<String, String> mapGroupConfigProperties = new HashMap<String, String>();
    mapGroupConfigProperties.put("myGroupProp", "awesomeValue");

    // blueprint core-site cluster configuration properties
    Map<String, String> blueprintCoreConfigProperties = new HashMap<String, String>();
    blueprintCoreConfigProperties.put("property1", "value2");
    blueprintCoreConfigProperties.put("new.property", "new.property.value");

    Map<String, String> blueprintGlobalConfigProperties = new HashMap<String, String>();
    blueprintGlobalConfigProperties.put("hive_database", "New MySQL Database");

    Collection<BlueprintConfigEntity> configurations = new HashSet<BlueprintConfigEntity>();
    configurations.add(blueprintConfig);
    configurations.add(blueprintConfig2);

    // expectations
    expect(request.getProperties()).andReturn(propertySet).anyTimes();
    expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint);
    expect(blueprint.getStackName()).andReturn(stackName);
    expect(blueprint.getStackVersion()).andReturn(stackVersion);
    expect(blueprint.getConfigurations()).andReturn(configurations);
    expect(blueprint.validateConfigurations(metaInfo, PropertyInfo.PropertyType.PASSWORD)).andReturn(
        Collections.<String, Map<String, Collection<String>>>emptyMap());

    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component1")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component2")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "MYSQL_SERVER")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service2", "component3")).
        andReturn(Collections.<DependencyInfo>emptyList());

    expect(managementController.getStackServices(capture(stackServiceRequestCapture))).andReturn(stackServiceResponses);
    expect(stackServiceResponse1.getServiceName()).andReturn("service1");
    expect(stackServiceResponse2.getServiceName()).andReturn("service2");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture1))).
        andReturn(stackServiceComponentResponses1);
    expect(stackServiceComponentResponse1.getComponentName()).andReturn("component1");
    expect(stackServiceComponentResponse2.getComponentName()).andReturn("component2");
    expect(stackServiceComponentResponse4.getComponentName()).andReturn("MYSQL_SERVER");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture1))).
        andReturn(stackConfigurationResponses1);
    expect(stackConfigurationResponse1.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse1.getPropertyName()).andReturn("property1");
    expect(stackConfigurationResponse1.getPropertyValue()).andReturn("value1");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture2))).
        andReturn(stackServiceComponentResponses2);
    expect(stackServiceComponentResponse3.getComponentName()).andReturn("component3");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture2))).
        andReturn(stackConfigurationResponses2);
    expect(stackConfigurationResponse2.getType()).andReturn("hdfs-site.xml");
    expect(stackConfigurationResponse2.getPropertyName()).andReturn("property2");
    expect(stackConfigurationResponse2.getPropertyValue()).andReturn("value2");

    expect(stackConfigurationResponse3.getType()).andReturn("global.xml");
    expect(stackConfigurationResponse3.getPropertyName()).andReturn("oozie_user");
    expect(stackConfigurationResponse3.getPropertyValue()).andReturn("oozie");

    expect(stackConfigurationResponse4.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse4.getPropertyName()).andReturn("property3");
    expect(stackConfigurationResponse4.getPropertyValue()).andReturn("value3");

    expect(stackConfigurationResponse5.getType()).andReturn("hive-site.xml");
    expect(stackConfigurationResponse5.getPropertyName()).andReturn("javax.jdo.option.ConnectionURL");
    expect(stackConfigurationResponse5.getPropertyValue()).andReturn("localhost:12345");

    expect(blueprintConfig.getBlueprintName()).andReturn("test-blueprint").anyTimes();
    expect(blueprintConfig.getType()).andReturn("core-site").anyTimes();
    expect(blueprintConfig.getConfigData()).andReturn(new Gson().toJson(blueprintCoreConfigProperties)).anyTimes();
    expect(blueprintConfig2.getBlueprintName()).andReturn("test-blueprint").anyTimes();
    expect(blueprintConfig2.getType()).andReturn("global").anyTimes();
    expect(blueprintConfig2.getConfigData()).andReturn(new Gson().toJson(blueprintGlobalConfigProperties)).anyTimes();

    expect(blueprint.getHostGroups()).andReturn(Collections.singleton(hostGroup)).anyTimes();
    expect(hostGroup.getName()).andReturn("group1").anyTimes();
    expect(hostGroup.getComponents()).andReturn(hostGroupComponents).anyTimes();
    expect(hostGroupComponent1.getName()).andReturn("component1").anyTimes();
    expect(hostGroupComponent2.getName()).andReturn("component2").anyTimes();
    expect(hostGroupComponent3.getName()).andReturn("component3").anyTimes();
    expect(hostGroupComponent4.getName()).andReturn("MYSQL_SERVER").anyTimes();
    expect(hostGroup.getConfigurations()).andReturn(
        Collections.<HostGroupConfigEntity>singleton(hostGroupConfig)).anyTimes();

    expect(hostGroupConfig.getType()).andReturn("core-site").anyTimes();
    expect(hostGroupConfig.getConfigData()).andReturn(new Gson().toJson(mapGroupConfigProperties)).anyTimes();

    managementController.createCluster(capture(createClusterRequestCapture));
    expect(managementController.updateClusters(capture(updateClusterRequestCapture),
        capture(updateClusterPropertyMapCapture))).andReturn(null);
    expect(managementController.updateClusters(capture(updateClusterRequestCapture2),
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.HostGroupConfigEntity

    HostGroupEntity hostGroup = createNiceMock(HostGroupEntity.class);
    HostGroupComponentEntity hostGroupComponent1 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent2 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent3 = createNiceMock(HostGroupComponentEntity.class);

    HostGroupConfigEntity hostGroupConfig = createNiceMock(HostGroupConfigEntity.class);

    ServiceResourceProvider serviceResourceProvider = createStrictMock(ServiceResourceProvider.class);
    ResourceProvider componentResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostComponentResourceProvider = createStrictMock(ResourceProvider.class);
    ConfigGroupResourceProvider configGroupResourceProvider = createStrictMock(ConfigGroupResourceProvider.class);
    PersistKeyValueImpl persistKeyValue = createNiceMock(PersistKeyValueImpl.class);

    Set<StackServiceResponse> stackServiceResponses = new LinkedHashSet<StackServiceResponse>();
    stackServiceResponses.add(stackServiceResponse1);
    stackServiceResponses.add(stackServiceResponse2);

    // service1 has 2 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses1 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses1.add(stackServiceComponentResponse1);
    stackServiceComponentResponses1.add(stackServiceComponentResponse2);

    // service2 has 1 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses2 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses2.add(stackServiceComponentResponse3);

    // service1 has 1 config
    Set<StackConfigurationResponse> stackConfigurationResponses1 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses1.add(stackConfigurationResponse1);

    // service2 has 3 config
    Set<StackConfigurationResponse> stackConfigurationResponses2 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses2.add(stackConfigurationResponse2);
    stackConfigurationResponses2.add(stackConfigurationResponse3);
    stackConfigurationResponses2.add(stackConfigurationResponse4);

    Collection<HostGroupComponentEntity> hostGroupComponents = new LinkedHashSet<HostGroupComponentEntity>();
    hostGroupComponents.add(hostGroupComponent1);
    hostGroupComponents.add(hostGroupComponent2);
    hostGroupComponents.add(hostGroupComponent3);

    // request properties
    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
    Map<String, Object> properties = new LinkedHashMap<String, Object>();

    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName);
    properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
    propertySet.add(properties);

    Collection<Map<String, Object>> hostGroups = new ArrayList<Map<String, Object>>();
    Map<String, Object> hostGroupProperties = new HashMap<String, Object>();
    hostGroups.add(hostGroupProperties);
    hostGroupProperties.put("name", "group1");
    Collection<Map<String, String>> hostGroupHosts = new ArrayList<Map<String, String>>();
    hostGroupProperties.put("hosts", hostGroupHosts);
    Map<String, String> hostGroupHostProperties = new HashMap<String, String>();
    hostGroupHostProperties.put("fqdn", "host.domain");
    hostGroupHosts.add(hostGroupHostProperties);
    properties.put("host_groups", hostGroups);

    Map<String, String> mapGroupConfigProperties = new HashMap<String, String>();
    mapGroupConfigProperties.put("myGroupProp", "awesomeValue");

    // blueprint cluster configuration properties
    Map<String, String> blueprintConfigProperties = new HashMap<String, String>();
    blueprintConfigProperties.put("property1", "value2");
    blueprintConfigProperties.put("new.property", "new.property.value");

    Map<String, Map<String, Collection<String>>> allMissingPasswords = new HashMap<String, Map<String, Collection<String>>>();
    Map<String, Collection<String>> missingHGPasswords = new HashMap<String, Collection<String>>();
    Collection<String> missingPasswords = new ArrayList<String>();
    missingPasswords.add("my.missing.password");
    missingHGPasswords.put("core-site", missingPasswords);
    allMissingPasswords.put("group1", missingHGPasswords);

    // expectations
    expect(request.getProperties()).andReturn(propertySet).anyTimes();
    expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint);
    expect(blueprint.getStackName()).andReturn(stackName);
    expect(blueprint.getStackVersion()).andReturn(stackVersion);
    expect(blueprint.getConfigurations()).andReturn(Collections.<BlueprintConfigEntity>singletonList(blueprintConfig));
    expect(blueprint.validateConfigurations(metaInfo, PropertyInfo.PropertyType.PASSWORD)).andReturn(allMissingPasswords);

    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component1")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component2")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service2", "component3")).
        andReturn(Collections.<DependencyInfo>emptyList());

    expect(managementController.getStackServices(capture(stackServiceRequestCapture))).andReturn(stackServiceResponses);
    expect(stackServiceResponse1.getServiceName()).andReturn("service1");
    expect(stackServiceResponse2.getServiceName()).andReturn("service2");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture1))).
        andReturn(stackServiceComponentResponses1);
    expect(stackServiceComponentResponse1.getComponentName()).andReturn("component1");
    expect(stackServiceComponentResponse2.getComponentName()).andReturn("component2");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture1))).
        andReturn(stackConfigurationResponses1);
    expect(stackConfigurationResponse1.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse1.getPropertyName()).andReturn("property1");
    expect(stackConfigurationResponse1.getPropertyValue()).andReturn("value1");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture2))).
        andReturn(stackServiceComponentResponses2);
    expect(stackServiceComponentResponse3.getComponentName()).andReturn("component3");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture2))).
        andReturn(stackConfigurationResponses2);
    expect(stackConfigurationResponse2.getType()).andReturn("hdfs-site.xml");
    expect(stackConfigurationResponse2.getPropertyName()).andReturn("property2");
    expect(stackConfigurationResponse2.getPropertyValue()).andReturn("value2");

    expect(stackConfigurationResponse3.getType()).andReturn("global.xml");
    expect(stackConfigurationResponse3.getPropertyName()).andReturn("oozie_user");
    expect(stackConfigurationResponse3.getPropertyValue()).andReturn("oozie");

    expect(stackConfigurationResponse4.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse4.getPropertyName()).andReturn("property3");
    expect(stackConfigurationResponse4.getPropertyValue()).andReturn("value3");

    expect(blueprintConfig.getBlueprintName()).andReturn("test-blueprint").anyTimes();
    expect(blueprintConfig.getType()).andReturn("core-site").anyTimes();
    expect(blueprintConfig.getConfigData()).andReturn(new Gson().toJson(blueprintConfigProperties));

    expect(blueprint.getHostGroups()).andReturn(Collections.singleton(hostGroup)).anyTimes();
    expect(hostGroup.getName()).andReturn("group1").anyTimes();
    expect(hostGroup.getComponents()).andReturn(hostGroupComponents).anyTimes();
    expect(hostGroupComponent1.getName()).andReturn("component1").anyTimes();
    expect(hostGroupComponent2.getName()).andReturn("component2").anyTimes();
    expect(hostGroupComponent3.getName()).andReturn("component3").anyTimes();
    expect(hostGroup.getConfigurations()).andReturn(
        Collections.<HostGroupConfigEntity>singleton(hostGroupConfig)).anyTimes();

    expect(hostGroupConfig.getType()).andReturn("core-site").anyTimes();
    expect(hostGroupConfig.getConfigData()).andReturn(new Gson().toJson(mapGroupConfigProperties)).anyTimes();

    replay(blueprintDAO, managementController, request, response, blueprint, stackServiceResponse1, stackServiceResponse2,
        stackServiceComponentResponse1, stackServiceComponentResponse2, stackServiceComponentResponse3,
        stackConfigurationResponse1, stackConfigurationResponse2, stackConfigurationResponse3, stackConfigurationResponse4,
        blueprintConfig, hostGroup, hostGroupComponent1, hostGroupComponent2, hostGroupComponent3, hostGroupConfig,
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.HostGroupConfigEntity

    HostGroupEntity hostGroup = createNiceMock(HostGroupEntity.class);
    HostGroupComponentEntity hostGroupComponent1 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent2 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent3 = createNiceMock(HostGroupComponentEntity.class);

    HostGroupConfigEntity hostGroupConfig = createNiceMock(HostGroupConfigEntity.class);

    ServiceResourceProvider serviceResourceProvider = createStrictMock(ServiceResourceProvider.class);
    ResourceProvider componentResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostComponentResourceProvider = createStrictMock(ResourceProvider.class);
    ConfigGroupResourceProvider configGroupResourceProvider = createStrictMock(ConfigGroupResourceProvider.class);
    PersistKeyValueImpl persistKeyValue = createNiceMock(PersistKeyValueImpl.class);

    Set<StackServiceResponse> stackServiceResponses = new LinkedHashSet<StackServiceResponse>();
    stackServiceResponses.add(stackServiceResponse1);
    stackServiceResponses.add(stackServiceResponse2);

    // service1 has 2 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses1 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses1.add(stackServiceComponentResponse1);
    stackServiceComponentResponses1.add(stackServiceComponentResponse2);

    // service2 has 1 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses2 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses2.add(stackServiceComponentResponse3);

    // service1 has 1 config
    Set<StackConfigurationResponse> stackConfigurationResponses1 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses1.add(stackConfigurationResponse1);

    // service2 has 3 config
    Set<StackConfigurationResponse> stackConfigurationResponses2 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses2.add(stackConfigurationResponse2);
    stackConfigurationResponses2.add(stackConfigurationResponse3);
    stackConfigurationResponses2.add(stackConfigurationResponse4);

    Collection<HostGroupComponentEntity> hostGroupComponents = new LinkedHashSet<HostGroupComponentEntity>();
    hostGroupComponents.add(hostGroupComponent1);
    hostGroupComponents.add(hostGroupComponent2);
    hostGroupComponents.add(hostGroupComponent3);

    // request properties
    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
    Map<String, Object> properties = new LinkedHashMap<String, Object>();

    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName);
    properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
    propertySet.add(properties);

    Map<String, String> mapGroupConfigProperties = new HashMap<String, String>();
    mapGroupConfigProperties.put("myGroupProp", "awesomeValue");

    // blueprint cluster configuration properties
    Map<String, String> blueprintConfigProperties = new HashMap<String, String>();
    blueprintConfigProperties.put("property1", "value2");
    blueprintConfigProperties.put("new.property", "new.property.value");

    // expectations
    expect(request.getProperties()).andReturn(propertySet).anyTimes();
    expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint);
    expect(blueprint.getStackName()).andReturn(stackName);
    expect(blueprint.getStackVersion()).andReturn(stackVersion);

    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component1")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component2")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service2", "component3")).
        andReturn(Collections.<DependencyInfo>emptyList());

    expect(managementController.getStackServices(capture(stackServiceRequestCapture))).andReturn(stackServiceResponses);
    expect(stackServiceResponse1.getServiceName()).andReturn("service1");
    expect(stackServiceResponse2.getServiceName()).andReturn("service2");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture1))).
        andReturn(stackServiceComponentResponses1);
    expect(stackServiceComponentResponse1.getComponentName()).andReturn("component1");
    expect(stackServiceComponentResponse2.getComponentName()).andReturn("component2");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture1))).
        andReturn(stackConfigurationResponses1);
    expect(stackConfigurationResponse1.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse1.getPropertyName()).andReturn("property1");
    expect(stackConfigurationResponse1.getPropertyValue()).andReturn("value1");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture2))).
        andReturn(stackServiceComponentResponses2);
    expect(stackServiceComponentResponse3.getComponentName()).andReturn("component3");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture2))).
        andReturn(stackConfigurationResponses2);
    expect(stackConfigurationResponse2.getType()).andReturn("hdfs-site.xml");
    expect(stackConfigurationResponse2.getPropertyName()).andReturn("property2");
    expect(stackConfigurationResponse2.getPropertyValue()).andReturn("value2");

    expect(stackConfigurationResponse3.getType()).andReturn("global.xml");
    expect(stackConfigurationResponse3.getPropertyName()).andReturn("oozie_user");
    expect(stackConfigurationResponse3.getPropertyValue()).andReturn("oozie");

    expect(stackConfigurationResponse4.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse4.getPropertyName()).andReturn("property3");
    expect(stackConfigurationResponse4.getPropertyValue()).andReturn("value3");

    expect(blueprintConfig.getBlueprintName()).andReturn("test-blueprint").anyTimes();
    expect(blueprintConfig.getType()).andReturn("core-site").anyTimes();

    expect(blueprint.getHostGroups()).andReturn(Collections.singleton(hostGroup)).anyTimes();
    expect(hostGroup.getName()).andReturn("group1").anyTimes();
    expect(hostGroup.getComponents()).andReturn(hostGroupComponents).anyTimes();
    expect(hostGroupComponent1.getName()).andReturn("component1").anyTimes();
    expect(hostGroupComponent2.getName()).andReturn("component2").anyTimes();
    expect(hostGroupComponent3.getName()).andReturn("component3").anyTimes();
    expect(hostGroup.getConfigurations()).andReturn(
        Collections.<HostGroupConfigEntity>singleton(hostGroupConfig)).anyTimes();

    expect(hostGroupConfig.getType()).andReturn("core-site").anyTimes();
    expect(hostGroupConfig.getConfigData()).andReturn(new Gson().toJson(mapGroupConfigProperties)).anyTimes();

    replay(blueprintDAO, managementController, request, response, blueprint, stackServiceResponse1, stackServiceResponse2,
        stackServiceComponentResponse1, stackServiceComponentResponse2, stackServiceComponentResponse3,
        stackConfigurationResponse1, stackConfigurationResponse2, stackConfigurationResponse3, stackConfigurationResponse4,
        blueprintConfig, hostGroup, hostGroupComponent1, hostGroupComponent2, hostGroupComponent3, hostGroupConfig,
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.HostGroupConfigEntity

    HostGroupEntity hostGroup = createNiceMock(HostGroupEntity.class);
    HostGroupComponentEntity hostGroupComponent1 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent2 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent3 = createNiceMock(HostGroupComponentEntity.class);

    HostGroupConfigEntity hostGroupConfig = createNiceMock(HostGroupConfigEntity.class);

    ServiceResourceProvider serviceResourceProvider = createStrictMock(ServiceResourceProvider.class);
    ResourceProvider componentResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostComponentResourceProvider = createStrictMock(ResourceProvider.class);
    ConfigGroupResourceProvider configGroupResourceProvider = createStrictMock(ConfigGroupResourceProvider.class);
    PersistKeyValueImpl persistKeyValue = createNiceMock(PersistKeyValueImpl.class);

    Set<StackServiceResponse> stackServiceResponses = new LinkedHashSet<StackServiceResponse>();
    stackServiceResponses.add(stackServiceResponse1);
    stackServiceResponses.add(stackServiceResponse2);

    // service1 has 2 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses1 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses1.add(stackServiceComponentResponse1);
    stackServiceComponentResponses1.add(stackServiceComponentResponse2);

    // service2 has 1 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses2 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses2.add(stackServiceComponentResponse3);

    // service1 has 1 config
    Set<StackConfigurationResponse> stackConfigurationResponses1 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses1.add(stackConfigurationResponse1);

    // service2 has 3 config
    Set<StackConfigurationResponse> stackConfigurationResponses2 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses2.add(stackConfigurationResponse2);
    stackConfigurationResponses2.add(stackConfigurationResponse3);
    stackConfigurationResponses2.add(stackConfigurationResponse4);

    Collection<HostGroupComponentEntity> hostGroupComponents = new LinkedHashSet<HostGroupComponentEntity>();
    hostGroupComponents.add(hostGroupComponent1);
    hostGroupComponents.add(hostGroupComponent2);
    hostGroupComponents.add(hostGroupComponent3);

    // request properties
    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
    Map<String, Object> properties = new LinkedHashMap<String, Object>();

    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName);
    properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
    propertySet.add(properties);

    Collection<Map<String, Object>> hostGroups = new ArrayList<Map<String, Object>>();
    Map<String, Object> hostGroupProperties = new HashMap<String, Object>();
    hostGroups.add(hostGroupProperties);
    Collection<Map<String, String>> hostGroupHosts = new ArrayList<Map<String, String>>();
    hostGroupProperties.put("hosts", hostGroupHosts);
    Map<String, String> hostGroupHostProperties = new HashMap<String, String>();
    hostGroupHostProperties.put("fqdn", "host.domain");
    hostGroupHosts.add(hostGroupHostProperties);
    properties.put("host_groups", hostGroups);

    Map<String, String> mapGroupConfigProperties = new HashMap<String, String>();
    mapGroupConfigProperties.put("myGroupProp", "awesomeValue");

    // blueprint cluster configuration properties
    Map<String, String> blueprintConfigProperties = new HashMap<String, String>();
    blueprintConfigProperties.put("property1", "value2");
    blueprintConfigProperties.put("new.property", "new.property.value");

    // expectations
    expect(request.getProperties()).andReturn(propertySet).anyTimes();
    expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint);
    expect(blueprint.getStackName()).andReturn(stackName);
    expect(blueprint.getStackVersion()).andReturn(stackVersion);

    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component1")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component2")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service2", "component3")).
        andReturn(Collections.<DependencyInfo>emptyList());

    expect(managementController.getStackServices(capture(stackServiceRequestCapture))).andReturn(stackServiceResponses);
    expect(stackServiceResponse1.getServiceName()).andReturn("service1");
    expect(stackServiceResponse2.getServiceName()).andReturn("service2");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture1))).
        andReturn(stackServiceComponentResponses1);
    expect(stackServiceComponentResponse1.getComponentName()).andReturn("component1");
    expect(stackServiceComponentResponse2.getComponentName()).andReturn("component2");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture1))).
        andReturn(stackConfigurationResponses1);
    expect(stackConfigurationResponse1.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse1.getPropertyName()).andReturn("property1");
    expect(stackConfigurationResponse1.getPropertyValue()).andReturn("value1");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture2))).
        andReturn(stackServiceComponentResponses2);
    expect(stackServiceComponentResponse3.getComponentName()).andReturn("component3");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture2))).
        andReturn(stackConfigurationResponses2);
    expect(stackConfigurationResponse2.getType()).andReturn("hdfs-site.xml");
    expect(stackConfigurationResponse2.getPropertyName()).andReturn("property2");
    expect(stackConfigurationResponse2.getPropertyValue()).andReturn("value2");

    expect(stackConfigurationResponse3.getType()).andReturn("global.xml");
    expect(stackConfigurationResponse3.getPropertyName()).andReturn("oozie_user");
    expect(stackConfigurationResponse3.getPropertyValue()).andReturn("oozie");

    expect(stackConfigurationResponse4.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse4.getPropertyName()).andReturn("property3");
    expect(stackConfigurationResponse4.getPropertyValue()).andReturn("value3");

    expect(blueprintConfig.getBlueprintName()).andReturn("test-blueprint").anyTimes();
    expect(blueprintConfig.getType()).andReturn("core-site").anyTimes();

    expect(blueprint.getHostGroups()).andReturn(Collections.singleton(hostGroup)).anyTimes();
    expect(hostGroup.getName()).andReturn("group1").anyTimes();
    expect(hostGroup.getComponents()).andReturn(hostGroupComponents).anyTimes();
    expect(hostGroupComponent1.getName()).andReturn("component1").anyTimes();
    expect(hostGroupComponent2.getName()).andReturn("component2").anyTimes();
    expect(hostGroupComponent3.getName()).andReturn("component3").anyTimes();
    expect(hostGroup.getConfigurations()).andReturn(
        Collections.<HostGroupConfigEntity>singleton(hostGroupConfig)).anyTimes();

    expect(hostGroupConfig.getType()).andReturn("core-site").anyTimes();
    expect(hostGroupConfig.getConfigData()).andReturn(new Gson().toJson(mapGroupConfigProperties)).anyTimes();

    replay(blueprintDAO, managementController, request, response, blueprint, stackServiceResponse1, stackServiceResponse2,
        stackServiceComponentResponse1, stackServiceComponentResponse2, stackServiceComponentResponse3,
        stackConfigurationResponse1, stackConfigurationResponse2, stackConfigurationResponse3, stackConfigurationResponse4,
        blueprintConfig, hostGroup, hostGroupComponent1, hostGroupComponent2, hostGroupComponent3, hostGroupConfig,
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.HostGroupConfigEntity

    HostGroupEntity hostGroup = createNiceMock(HostGroupEntity.class);
    HostGroupComponentEntity hostGroupComponent1 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent2 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent3 = createNiceMock(HostGroupComponentEntity.class);

    HostGroupConfigEntity hostGroupConfig = createNiceMock(HostGroupConfigEntity.class);

    ServiceResourceProvider serviceResourceProvider = createStrictMock(ServiceResourceProvider.class);
    ResourceProvider componentResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostComponentResourceProvider = createStrictMock(ResourceProvider.class);
    ConfigGroupResourceProvider configGroupResourceProvider = createStrictMock(ConfigGroupResourceProvider.class);
    PersistKeyValueImpl persistKeyValue = createNiceMock(PersistKeyValueImpl.class);

    Set<StackServiceResponse> stackServiceResponses = new LinkedHashSet<StackServiceResponse>();
    stackServiceResponses.add(stackServiceResponse1);
    stackServiceResponses.add(stackServiceResponse2);

    // service1 has 2 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses1 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses1.add(stackServiceComponentResponse1);
    stackServiceComponentResponses1.add(stackServiceComponentResponse2);

    // service2 has 1 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses2 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses2.add(stackServiceComponentResponse3);

    // service1 has 1 config
    Set<StackConfigurationResponse> stackConfigurationResponses1 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses1.add(stackConfigurationResponse1);

    // service2 has 3 config
    Set<StackConfigurationResponse> stackConfigurationResponses2 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses2.add(stackConfigurationResponse2);
    stackConfigurationResponses2.add(stackConfigurationResponse3);
    stackConfigurationResponses2.add(stackConfigurationResponse4);

    Collection<HostGroupComponentEntity> hostGroupComponents = new LinkedHashSet<HostGroupComponentEntity>();
    hostGroupComponents.add(hostGroupComponent1);
    hostGroupComponents.add(hostGroupComponent2);
    hostGroupComponents.add(hostGroupComponent3);

    // request properties
    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
    Map<String, Object> properties = new LinkedHashMap<String, Object>();

    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName);
    properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
    propertySet.add(properties);

    Collection<Map<String, Object>> hostGroups = new ArrayList<Map<String, Object>>();
    Map<String, Object> hostGroupProperties = new HashMap<String, Object>();
    hostGroups.add(hostGroupProperties);
    hostGroupProperties.put("name", "group1");
    Collection<Map<String, String>> hostGroupHosts = new ArrayList<Map<String, String>>();
    hostGroupProperties.put("hosts", hostGroupHosts);
    Map<String, String> hostGroupHostProperties = new HashMap<String, String>();
        hostGroupHosts.add(hostGroupHostProperties);
    properties.put("host_groups", hostGroups);

    Map<String, String> mapGroupConfigProperties = new HashMap<String, String>();
    mapGroupConfigProperties.put("myGroupProp", "awesomeValue");

    // blueprint cluster configuration properties
    Map<String, String> blueprintConfigProperties = new HashMap<String, String>();
    blueprintConfigProperties.put("property1", "value2");
    blueprintConfigProperties.put("new.property", "new.property.value");

    // expectations
    expect(request.getProperties()).andReturn(propertySet).anyTimes();
    expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint);
    expect(blueprint.getStackName()).andReturn(stackName);
    expect(blueprint.getStackVersion()).andReturn(stackVersion);

    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component1")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component2")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service2", "component3")).
        andReturn(Collections.<DependencyInfo>emptyList());

    expect(managementController.getStackServices(capture(stackServiceRequestCapture))).andReturn(stackServiceResponses);
    expect(stackServiceResponse1.getServiceName()).andReturn("service1");
    expect(stackServiceResponse2.getServiceName()).andReturn("service2");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture1))).
        andReturn(stackServiceComponentResponses1);
    expect(stackServiceComponentResponse1.getComponentName()).andReturn("component1");
    expect(stackServiceComponentResponse2.getComponentName()).andReturn("component2");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture1))).
        andReturn(stackConfigurationResponses1);
    expect(stackConfigurationResponse1.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse1.getPropertyName()).andReturn("property1");
    expect(stackConfigurationResponse1.getPropertyValue()).andReturn("value1");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture2))).
        andReturn(stackServiceComponentResponses2);
    expect(stackServiceComponentResponse3.getComponentName()).andReturn("component3");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture2))).
        andReturn(stackConfigurationResponses2);
    expect(stackConfigurationResponse2.getType()).andReturn("hdfs-site.xml");
    expect(stackConfigurationResponse2.getPropertyName()).andReturn("property2");
    expect(stackConfigurationResponse2.getPropertyValue()).andReturn("value2");

    expect(stackConfigurationResponse3.getType()).andReturn("global.xml");
    expect(stackConfigurationResponse3.getPropertyName()).andReturn("oozie_user");
    expect(stackConfigurationResponse3.getPropertyValue()).andReturn("oozie");

    expect(stackConfigurationResponse4.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse4.getPropertyName()).andReturn("property3");
    expect(stackConfigurationResponse4.getPropertyValue()).andReturn("value3");

    expect(blueprintConfig.getBlueprintName()).andReturn("test-blueprint").anyTimes();
    expect(blueprintConfig.getType()).andReturn("core-site").anyTimes();

    expect(blueprint.getHostGroups()).andReturn(Collections.singleton(hostGroup)).anyTimes();
    expect(hostGroup.getName()).andReturn("group1").anyTimes();
    expect(hostGroup.getComponents()).andReturn(hostGroupComponents).anyTimes();
    expect(hostGroupComponent1.getName()).andReturn("component1").anyTimes();
    expect(hostGroupComponent2.getName()).andReturn("component2").anyTimes();
    expect(hostGroupComponent3.getName()).andReturn("component3").anyTimes();
    expect(hostGroup.getConfigurations()).andReturn(
        Collections.<HostGroupConfigEntity>singleton(hostGroupConfig)).anyTimes();

    expect(hostGroupConfig.getType()).andReturn("core-site").anyTimes();
    expect(hostGroupConfig.getConfigData()).andReturn(new Gson().toJson(mapGroupConfigProperties)).anyTimes();

    replay(blueprintDAO, managementController, request, response, blueprint, stackServiceResponse1, stackServiceResponse2,
        stackServiceComponentResponse1, stackServiceComponentResponse2, stackServiceComponentResponse3,
        stackConfigurationResponse1, stackConfigurationResponse2, stackConfigurationResponse3, stackConfigurationResponse4,
        blueprintConfig, hostGroup, hostGroupComponent1, hostGroupComponent2, hostGroupComponent3, hostGroupConfig,
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.HostGroupConfigEntity

    HostGroupEntity hostGroup = createNiceMock(HostGroupEntity.class);
    HostGroupComponentEntity hostGroupComponent1 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent2 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent3 = createNiceMock(HostGroupComponentEntity.class);

    HostGroupConfigEntity hostGroupConfig = createNiceMock(HostGroupConfigEntity.class);

    ServiceResourceProvider serviceResourceProvider = createStrictMock(ServiceResourceProvider.class);
    ResourceProvider componentResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostComponentResourceProvider = createStrictMock(ResourceProvider.class);
    ConfigGroupResourceProvider configGroupResourceProvider = createStrictMock(ConfigGroupResourceProvider.class);
    PersistKeyValueImpl persistKeyValue = createNiceMock(PersistKeyValueImpl.class);

    Capture<ClusterRequest> createClusterRequestCapture = new Capture<ClusterRequest>();
    Capture<Set<ClusterRequest>> updateClusterRequestCapture = new Capture<Set<ClusterRequest>>();
    Capture<Map<String, String>> updateClusterPropertyMapCapture = new Capture<Map<String, String>>();
    Capture<Set<ClusterRequest>> updateClusterRequestCapture2 = new Capture<Set<ClusterRequest>>();
    Capture<Map<String, String>> updateClusterPropertyMapCapture2 = new Capture<Map<String, String>>();
    Capture<Set<ClusterRequest>> updateClusterRequestCapture3 = new Capture<Set<ClusterRequest>>();
    Capture<Map<String, String>> updateClusterPropertyMapCapture3 = new Capture<Map<String, String>>();

    Capture<Request> serviceRequestCapture = new Capture<Request>();
    Capture<Request> componentRequestCapture = new Capture<Request>();
    Capture<Request> componentRequestCapture2 = new Capture<Request>();
    Capture<Request> hostRequestCapture = new Capture<Request>();
    Capture<Request> hostComponentRequestCapture = new Capture<Request>();
    Capture<Set<ConfigGroupRequest>> configGroupRequestCapture = new Capture<Set<ConfigGroupRequest>>();

    Set<StackServiceResponse> stackServiceResponses = new LinkedHashSet<StackServiceResponse>();
    stackServiceResponses.add(stackServiceResponse1);
    stackServiceResponses.add(stackServiceResponse2);

    // service1 has 2 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses1 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses1.add(stackServiceComponentResponse1);
    stackServiceComponentResponses1.add(stackServiceComponentResponse2);

    // service2 has 1 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses2 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses2.add(stackServiceComponentResponse3);

    // service1 has 1 config
    Set<StackConfigurationResponse> stackConfigurationResponses1 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses1.add(stackConfigurationResponse1);

    // service2 has 3 config
    Set<StackConfigurationResponse> stackConfigurationResponses2 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses2.add(stackConfigurationResponse2);
    stackConfigurationResponses2.add(stackConfigurationResponse3);
    stackConfigurationResponses2.add(stackConfigurationResponse4);

    Collection<HostGroupComponentEntity> hostGroupComponents = new LinkedHashSet<HostGroupComponentEntity>();
    hostGroupComponents.add(hostGroupComponent1);
    hostGroupComponents.add(hostGroupComponent2);
    hostGroupComponents.add(hostGroupComponent3);

    // request properties
    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
    Map<String, Object> properties = new LinkedHashMap<String, Object>();

    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName);
    properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
    properties.put("default_password", "foo");
    propertySet.add(properties);

    Collection<Map<String, Object>> hostGroups = new ArrayList<Map<String, Object>>();
    Map<String, Object> hostGroupProperties = new HashMap<String, Object>();
    hostGroups.add(hostGroupProperties);
    hostGroupProperties.put("name", "group1");
    Collection<Map<String, String>> hostGroupHosts = new ArrayList<Map<String, String>>();
    hostGroupProperties.put("hosts", hostGroupHosts);
    Map<String, String> hostGroupHostProperties = new HashMap<String, String>();
    hostGroupHostProperties.put("fqdn", "host.domain");
    hostGroupHosts.add(hostGroupHostProperties);
    properties.put("host_groups", hostGroups);

    Map<String, String> mapGroupConfigProperties = new HashMap<String, String>();
    mapGroupConfigProperties.put("myGroupProp", "awesomeValue");

    // blueprint cluster configuration properties
    Map<String, String> blueprintConfigProperties = new HashMap<String, String>();
    blueprintConfigProperties.put("property1", "value2");
    blueprintConfigProperties.put("new.property", "new.property.value");

    Map<String, Map<String, Collection<String>>> allMissingPasswords = new HashMap<String, Map<String, Collection<String>>>();
    Map<String, Collection<String>> missingHGPasswords = new HashMap<String, Collection<String>>();
    Collection<String> missingPasswords = new ArrayList<String>();
    missingPasswords.add("my.missing.password");
    missingPasswords.add("my.missing.password2");
    missingHGPasswords.put("core-site", missingPasswords);
    allMissingPasswords.put("group1", missingHGPasswords);

    // expectations
    expect(request.getProperties()).andReturn(propertySet).anyTimes();
    expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint);
    expect(blueprint.getStackName()).andReturn(stackName);
    expect(blueprint.getStackVersion()).andReturn(stackVersion);
    expect(blueprint.getConfigurations()).andReturn(Collections.<BlueprintConfigEntity>singletonList(blueprintConfig));
    expect(blueprint.validateConfigurations(metaInfo, PropertyInfo.PropertyType.PASSWORD)).andReturn(allMissingPasswords);

    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component1")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component2")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service2", "component3")).
        andReturn(Collections.<DependencyInfo>emptyList());

    expect(managementController.getStackServices(capture(stackServiceRequestCapture))).andReturn(stackServiceResponses);
    expect(stackServiceResponse1.getServiceName()).andReturn("service1");
    expect(stackServiceResponse2.getServiceName()).andReturn("service2");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture1))).
        andReturn(stackServiceComponentResponses1);
    expect(stackServiceComponentResponse1.getComponentName()).andReturn("component1");
    expect(stackServiceComponentResponse2.getComponentName()).andReturn("component2");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture1))).
        andReturn(stackConfigurationResponses1);
    expect(stackConfigurationResponse1.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse1.getPropertyName()).andReturn("property1");
    expect(stackConfigurationResponse1.getPropertyValue()).andReturn("value1");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture2))).
        andReturn(stackServiceComponentResponses2);
    expect(stackServiceComponentResponse3.getComponentName()).andReturn("component3");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture2))).
        andReturn(stackConfigurationResponses2);
    expect(stackConfigurationResponse2.getType()).andReturn("hdfs-site.xml");
    expect(stackConfigurationResponse2.getPropertyName()).andReturn("property2");
    expect(stackConfigurationResponse2.getPropertyValue()).andReturn("value2");

    expect(stackConfigurationResponse3.getType()).andReturn("global.xml");
    expect(stackConfigurationResponse3.getPropertyName()).andReturn("oozie_user");
    expect(stackConfigurationResponse3.getPropertyValue()).andReturn("oozie");

    expect(stackConfigurationResponse4.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse4.getPropertyName()).andReturn("property3");
    expect(stackConfigurationResponse4.getPropertyValue()).andReturn("value3");

    expect(blueprintConfig.getBlueprintName()).andReturn("test-blueprint").anyTimes();
    expect(blueprintConfig.getType()).andReturn("core-site").anyTimes();
    expect(blueprintConfig.getConfigData()).andReturn(new Gson().toJson(blueprintConfigProperties));

    expect(blueprint.getHostGroups()).andReturn(Collections.singleton(hostGroup)).anyTimes();
    expect(hostGroup.getName()).andReturn("group1").anyTimes();
    expect(hostGroup.getComponents()).andReturn(hostGroupComponents).anyTimes();
    expect(hostGroupComponent1.getName()).andReturn("component1").anyTimes();
    expect(hostGroupComponent2.getName()).andReturn("component2").anyTimes();
    expect(hostGroupComponent3.getName()).andReturn("component3").anyTimes();
    expect(hostGroup.getConfigurations()).andReturn(
        Collections.<HostGroupConfigEntity>singleton(hostGroupConfig)).anyTimes();

    expect(hostGroupConfig.getType()).andReturn("core-site").anyTimes();
    expect(hostGroupConfig.getConfigData()).andReturn(new Gson().toJson(mapGroupConfigProperties)).anyTimes();

    managementController.createCluster(capture(createClusterRequestCapture));
    expect(managementController.updateClusters(capture(updateClusterRequestCapture),
        capture(updateClusterPropertyMapCapture))).andReturn(null);
    expect(managementController.updateClusters(capture(updateClusterRequestCapture2),
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.HostGroupConfigEntity

    HostGroupEntity hostGroup = createNiceMock(HostGroupEntity.class);
    HostGroupComponentEntity hostGroupComponent1 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent2 = createNiceMock(HostGroupComponentEntity.class);
    HostGroupComponentEntity hostGroupComponent3 = createNiceMock(HostGroupComponentEntity.class);

    HostGroupConfigEntity hostGroupConfig = createNiceMock(HostGroupConfigEntity.class);

    ServiceResourceProvider serviceResourceProvider = createStrictMock(ServiceResourceProvider.class);
    ResourceProvider componentResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostComponentResourceProvider = createStrictMock(ResourceProvider.class);
    ConfigGroupResourceProvider configGroupResourceProvider = createStrictMock(ConfigGroupResourceProvider.class);

    Capture<ClusterRequest> createClusterRequestCapture = new Capture<ClusterRequest>();
    Capture<Set<ClusterRequest>> updateClusterRequestCapture = new Capture<Set<ClusterRequest>>();
    Capture<Map<String, String>> updateClusterPropertyMapCapture = new Capture<Map<String, String>>();
    Capture<Set<ClusterRequest>> updateClusterRequestCapture2 = new Capture<Set<ClusterRequest>>();
    Capture<Map<String, String>> updateClusterPropertyMapCapture2 = new Capture<Map<String, String>>();
    Capture<Set<ClusterRequest>> updateClusterRequestCapture3 = new Capture<Set<ClusterRequest>>();
    Capture<Map<String, String>> updateClusterPropertyMapCapture3 = new Capture<Map<String, String>>();

    Capture<Request> serviceRequestCapture = new Capture<Request>();
    Capture<Request> componentRequestCapture = new Capture<Request>();
    Capture<Request> componentRequestCapture2 = new Capture<Request>();
    Capture<Request> hostRequestCapture = new Capture<Request>();
    Capture<Request> hostComponentRequestCapture = new Capture<Request>();
    Capture<Set<ConfigGroupRequest>> configGroupRequestCapture = new Capture<Set<ConfigGroupRequest>>();

    Set<StackServiceResponse> stackServiceResponses = new LinkedHashSet<StackServiceResponse>();
    stackServiceResponses.add(stackServiceResponse1);
    stackServiceResponses.add(stackServiceResponse2);

    // service1 has 2 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses1 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses1.add(stackServiceComponentResponse1);
    stackServiceComponentResponses1.add(stackServiceComponentResponse2);

    // service2 has 1 components
    Set<StackServiceComponentResponse> stackServiceComponentResponses2 = new LinkedHashSet<StackServiceComponentResponse>();
    stackServiceComponentResponses2.add(stackServiceComponentResponse3);

    // service1 has 1 config
    Set<StackConfigurationResponse> stackConfigurationResponses1 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses1.add(stackConfigurationResponse1);

    // service2 has 3 config
    Set<StackConfigurationResponse> stackConfigurationResponses2 = new LinkedHashSet<StackConfigurationResponse>();
    stackConfigurationResponses2.add(stackConfigurationResponse2);
    stackConfigurationResponses2.add(stackConfigurationResponse3);
    stackConfigurationResponses2.add(stackConfigurationResponse4);

    Collection<HostGroupComponentEntity> hostGroupComponents = new LinkedHashSet<HostGroupComponentEntity>();
    hostGroupComponents.add(hostGroupComponent1);
    hostGroupComponents.add(hostGroupComponent2);
    hostGroupComponents.add(hostGroupComponent3);

    // request properties
    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
    Map<String, Object> properties = new LinkedHashMap<String, Object>();

    properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName);
    properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
    propertySet.add(properties);

    Collection<Map<String, Object>> hostGroups = new ArrayList<Map<String, Object>>();
    Map<String, Object> hostGroupProperties1 = new HashMap<String, Object>();
    Map<String, Object> hostGroupProperties2 = new HashMap<String, Object>();
    hostGroups.add(hostGroupProperties1);
    hostGroups.add(hostGroupProperties2);
    hostGroupProperties1.put("name", "group1");
    hostGroupProperties2.put("name", "group2");
    Collection<Map<String, String>> hostGroupHosts = new ArrayList<Map<String, String>>();
    hostGroupProperties1.put("hosts", hostGroupHosts);
    hostGroupProperties2.put("hosts", hostGroupHosts);
    Map<String, String> hostGroupHostProperties = new HashMap<String, String>();
    hostGroupHostProperties.put("fqdn", "host.domain");
    hostGroupHosts.add(hostGroupHostProperties);
    properties.put("host_groups", hostGroups);

    Map<String, String> mapGroupConfigProperties = new HashMap<String, String>();
    mapGroupConfigProperties.put("myGroupProp", "awesomeValue");

    // blueprint cluster configuration properties
    Map<String, String> blueprintConfigProperties = new HashMap<String, String>();
    blueprintConfigProperties.put("property1", "value2");
    blueprintConfigProperties.put("new.property", "new.property.value");

    // expectations
    expect(request.getProperties()).andReturn(propertySet).anyTimes();
    expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint);
    expect(blueprint.getStackName()).andReturn(stackName);
    expect(blueprint.getStackVersion()).andReturn(stackVersion);
    expect(blueprint.getConfigurations()).andReturn(Collections.<BlueprintConfigEntity>singletonList(blueprintConfig));
    expect(blueprint.validateConfigurations(metaInfo, PropertyInfo.PropertyType.PASSWORD)).andReturn(
        Collections.<String, Map<String, Collection<String>>>emptyMap());

    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component1")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component2")).
        andReturn(Collections.<DependencyInfo>emptyList());
    expect(metaInfo.getComponentDependencies("test", "1.23", "service2", "component3")).
        andReturn(Collections.<DependencyInfo>emptyList());

    expect(managementController.getStackServices(capture(stackServiceRequestCapture))).andReturn(stackServiceResponses);
    expect(stackServiceResponse1.getServiceName()).andReturn("service1");
    expect(stackServiceResponse2.getServiceName()).andReturn("service2");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture1))).
        andReturn(stackServiceComponentResponses1);
    expect(stackServiceComponentResponse1.getComponentName()).andReturn("component1");
    expect(stackServiceComponentResponse2.getComponentName()).andReturn("component2");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture1))).
        andReturn(stackConfigurationResponses1);
    expect(stackConfigurationResponse1.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse1.getPropertyName()).andReturn("property1");
    expect(stackConfigurationResponse1.getPropertyValue()).andReturn("value1");

    expect(managementController.getStackComponents(capture(serviceComponentRequestCapture2))).
        andReturn(stackServiceComponentResponses2);
    expect(stackServiceComponentResponse3.getComponentName()).andReturn("component3");

    expect(managementController.getStackConfigurations(capture(serviceConfigurationRequestCapture2))).
        andReturn(stackConfigurationResponses2);
    expect(stackConfigurationResponse2.getType()).andReturn("hdfs-site.xml");
    expect(stackConfigurationResponse2.getPropertyName()).andReturn("property2");
    expect(stackConfigurationResponse2.getPropertyValue()).andReturn("value2");

    expect(stackConfigurationResponse3.getType()).andReturn("global.xml");
    expect(stackConfigurationResponse3.getPropertyName()).andReturn("oozie_user");
    expect(stackConfigurationResponse3.getPropertyValue()).andReturn("oozie");

    expect(stackConfigurationResponse4.getType()).andReturn("core-site.xml");
    expect(stackConfigurationResponse4.getPropertyName()).andReturn("property3");
    expect(stackConfigurationResponse4.getPropertyValue()).andReturn("value3");

    expect(blueprintConfig.getBlueprintName()).andReturn("test-blueprint").anyTimes();
    expect(blueprintConfig.getType()).andReturn("core-site").anyTimes();
    expect(blueprintConfig.getConfigData()).andReturn(new Gson().toJson(blueprintConfigProperties));

    expect(blueprint.getHostGroups()).andReturn(Collections.singleton(hostGroup)).anyTimes();
    expect(hostGroup.getName()).andReturn("group1").anyTimes();
    expect(hostGroup.getComponents()).andReturn(hostGroupComponents).anyTimes();
    expect(hostGroupComponent1.getName()).andReturn("component1").anyTimes();
    expect(hostGroupComponent2.getName()).andReturn("component2").anyTimes();
    expect(hostGroupComponent3.getName()).andReturn("component3").anyTimes();
    expect(hostGroup.getConfigurations()).andReturn(
        Collections.<HostGroupConfigEntity>singleton(hostGroupConfig)).anyTimes();

    expect(hostGroupConfig.getType()).andReturn("core-site").anyTimes();
    expect(hostGroupConfig.getConfigData()).andReturn(new Gson().toJson(mapGroupConfigProperties)).anyTimes();

    managementController.createCluster(capture(createClusterRequestCapture));
    expect(managementController.updateClusters(capture(updateClusterRequestCapture),
        capture(updateClusterPropertyMapCapture))).andReturn(null);
    expect(managementController.updateClusters(capture(updateClusterRequestCapture2),
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.HostGroupConfigEntity

        assertEquals("component1", componentEntity.getName());

        if (containsConfig) {
          Collection<HostGroupConfigEntity> configurations = hostGroup.getConfigurations();
          assertEquals(1, configurations.size());
          HostGroupConfigEntity hostGroupConfigEntity = configurations.iterator().next();
          assertEquals(BLUEPRINT_NAME, hostGroupConfigEntity.getBlueprintName());
          assertSame(hostGroup, hostGroupConfigEntity.getHostGroupEntity());
          assertEquals("core-site", hostGroupConfigEntity.getType());
          Map<String, String> properties = gson.<Map<String, String>>fromJson(
              hostGroupConfigEntity.getConfigData(), Map.class);
          assertEquals(1, properties.size());
          assertEquals("anything", properties.get("my.custom.hg.property"));
        }
      } else {
        fail("Unexpected host group name");
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.HostGroupConfigEntity

                                             HostGroupEntity hostGroup) {

    Collection<HostGroupConfigEntity> configurations = new ArrayList<HostGroupConfigEntity>();
    if (propertyMaps != null) {
      for (Map<String, String> configuration : propertyMaps) {
        HostGroupConfigEntity configEntity = new HostGroupConfigEntity();
        configEntity.setHostGroupEntity(hostGroup);
        configEntity.setHostGroupName(hostGroup.getName());
        populateConfigurationEntity(hostGroup.getBlueprintName(), configuration, configEntity);
        configurations.add(configEntity);
      }
    }
    hostGroup.setConfigurations(configurations);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.