Examples of BlueprintEntity


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

   *
   * @return blueprint entity for the given name
   * @throws IllegalArgumentException no blueprint with the given name found
   */
  private BlueprintEntity getBlueprint(String blueprintName) {
    BlueprintEntity blueprint = blueprintDAO.findByName(blueprintName);
    if (blueprint == null) {
      throw new IllegalArgumentException("Specified blueprint doesn't exist: " + blueprintName);
    }
    return blueprint;
  }
View Full Code Here

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

      if (requestProps.size() == 1 ) {
        String name = (String) requestProps.iterator().next().get(
            BLUEPRINT_NAME_PROPERTY_ID);

        if (name != null) {
          BlueprintEntity entity = dao.findByName(name);
          results = entity == null ? Collections.<BlueprintEntity>emptyList() :
              Collections.singletonList(entity);
        }
      }
    }
View Full Code Here

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

   * @param resource the resource to convert
   * @return  a new blueprint entity
   */
  @SuppressWarnings("unchecked")
  protected BlueprintEntity toEntity(Resource resource) {
    BlueprintEntity entity = new BlueprintEntity();
    entity.setBlueprintName((String) resource.getPropertyValue(BLUEPRINT_NAME_PROPERTY_ID));
    entity.setStackName((String) resource.getPropertyValue(STACK_NAME_PROPERTY_ID));
    entity.setStackVersion((String) resource.getPropertyValue(STACK_VERSION_PROPERTY_ID));

    Collection<HostGroupEntity> blueprintHostGroups = new ArrayList<HostGroupEntity>();
    entity.setHostGroups(blueprintHostGroups);

    Collection<Map<String, Object>> hostGroupProps = (Collection<Map<String, Object>>)
        resource.getPropertyValue(HOST_GROUP_PROPERTY_ID);

    for (Map<String, Object> properties : hostGroupProps) {
      HostGroupEntity group = new HostGroupEntity();
      group.setName((String) properties.get(BlueprintResourceProvider.HOST_GROUP_NAME_PROPERTY_ID));
      group.setBlueprintEntity(entity);
      group.setBlueprintName(entity.getBlueprintName());
      group.setCardinality((String) properties.get(HOST_GROUP_CARDINALITY_PROPERTY_ID));

      Collection<HostGroupComponentEntity> hostGroupComponents = new ArrayList<HostGroupComponentEntity>();
      group.setComponents(hostGroupComponents);

      List<Map<String, String>> listComponents = (List<Map<String, String>>)
          properties.get(BlueprintResourceProvider.COMPONENT_PROPERTY_ID);

      for (Map<String, String> componentProperties : listComponents) {
        HostGroupComponentEntity component = new HostGroupComponentEntity();
        component.setName(componentProperties.get(COMPONENT_NAME_PROPERTY_ID));
        component.setBlueprintName(entity.getBlueprintName());
        component.setHostGroupEntity(group);
        component.setHostGroupName((String) properties.get(HOST_GROUP_NAME_PROPERTY_ID));

        hostGroupComponents.add(component);
      }
      blueprintHostGroups.add(group);
    }

    entity.setConfigurations(createConfigEntities(
        (Collection<Map<String, String>>) resource.getPropertyValue(CONFIGURATION_PROPERTY_ID), entity));

    return entity;
  }
View Full Code Here

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

    String name = (String) properties.get(BLUEPRINT_NAME_PROPERTY_ID);
    if (name == null || name.isEmpty()) {
      throw new IllegalArgumentException("Blueprint name must be provided");
    }

    BlueprintEntity blueprint = new BlueprintEntity();
    blueprint.setBlueprintName(name);
    blueprint.setStackName((String) properties.get(STACK_NAME_PROPERTY_ID));
    blueprint.setStackVersion((String) properties.get(STACK_VERSION_PROPERTY_ID));

    Collection<HostGroupEntity> blueprintHostGroups = new ArrayList<HostGroupEntity>();
    blueprint.setHostGroups(blueprintHostGroups);

    HashSet<HashMap<String, Object>> setHostGroups =
        (HashSet<HashMap<String, Object>>) properties.get(HOST_GROUP_PROPERTY_ID);

    for (HashMap<String, Object> hostGroupProperties : setHostGroups) {
      HostGroupEntity group = new HostGroupEntity();
      group.setName((String) hostGroupProperties.get(HOST_GROUP_NAME_PROPERTY_ID));
      group.setBlueprintEntity(blueprint);
      group.setBlueprintName(name);
      group.setCardinality((String) hostGroupProperties.get(HOST_GROUP_CARDINALITY_PROPERTY_ID));

      Collection<HostGroupComponentEntity> components = new ArrayList<HostGroupComponentEntity>();
      group.setComponents(components);

      HashSet<HashMap<String, String>> setComponents =
          (HashSet<HashMap<String, String>>) hostGroupProperties.get(COMPONENT_PROPERTY_ID);
      for (HashMap<String, String> componentProperties : setComponents) {
        HostGroupComponentEntity component = new HostGroupComponentEntity();
        component.setName(componentProperties.get(COMPONENT_NAME_PROPERTY_ID));
        component.setBlueprintName(name);
        component.setHostGroupEntity(group);
        component.setHostGroupName((String) hostGroupProperties.get(HOST_GROUP_NAME_PROPERTY_ID));

        components.add(component);
      }
      blueprintHostGroups.add(group);
    }

    blueprint.setConfigurations(createConfigEntities(
        (Collection<Map<String, String>>) properties.get(CONFIGURATION_PROPERTY_ID), blueprint));

    return blueprint;
  }
View Full Code Here

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

   */
  private Command<Void> getCreateCommand(final Map<String, Object> properties) {
    return new Command<Void>() {
      @Override
      public Void invoke() throws AmbariException {
        BlueprintEntity blueprint = toEntity(properties);

        if (LOG.isDebugEnabled()) {
          LOG.debug("Creating Blueprint, name=" + blueprint.getBlueprintName());
        }

        if (dao.findByName(blueprint.getBlueprintName()) != null) {
          throw new DuplicateResourceException(
              "Attempted to create a Blueprint which already exists, blueprint_name=" +
              blueprint.getBlueprintName());
        }
        dao.create(blueprint);
        return null;
      }
    };
View Full Code Here

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

    BlueprintDAO blueprintDAO = createStrictMock(BlueprintDAO.class);
    AmbariManagementController managementController = createStrictMock(AmbariManagementController.class);
    Request request = createNiceMock(Request.class);
    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
    BlueprintEntity blueprint = createNiceMock(BlueprintEntity.class);
    StackServiceResponse stackServiceResponse1 = createNiceMock(StackServiceResponse.class);
    StackServiceResponse stackServiceResponse2 = createNiceMock(StackServiceResponse.class);
    Capture<Set<StackServiceRequest>> stackServiceRequestCapture = new Capture<Set<StackServiceRequest>>();

    StackServiceComponentResponse stackServiceComponentResponse1 = createNiceMock(StackServiceComponentResponse.class);
    StackServiceComponentResponse stackServiceComponentResponse2 = createNiceMock(StackServiceComponentResponse.class);
    StackServiceComponentResponse stackServiceComponentResponse3 = createNiceMock(StackServiceComponentResponse.class);
    Capture<Set<StackServiceComponentRequest>> serviceComponentRequestCapture1 = new Capture<Set<StackServiceComponentRequest>>();
    Capture<Set<StackServiceComponentRequest>> serviceComponentRequestCapture2 = new Capture<Set<StackServiceComponentRequest>>();

    StackConfigurationResponse stackConfigurationResponse1 = createNiceMock(StackConfigurationResponse.class);
    StackConfigurationResponse stackConfigurationResponse2 = createNiceMock(StackConfigurationResponse.class);
    StackConfigurationResponse stackConfigurationResponse3 = createNiceMock(StackConfigurationResponse.class);
    StackConfigurationResponse stackConfigurationResponse4 = createNiceMock(StackConfigurationResponse.class);
    Capture<Set<StackConfigurationRequest>> serviceConfigurationRequestCapture1 = new Capture<Set<StackConfigurationRequest>>();
    Capture<Set<StackConfigurationRequest>> serviceConfigurationRequestCapture2 = new Capture<Set<StackConfigurationRequest>>();

    BlueprintConfigEntity blueprintConfig = createNiceMock(BlueprintConfigEntity.class);

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

    ServiceResourceProvider serviceResourceProvider = createStrictMock(ServiceResourceProvider.class);
    ResourceProvider componentResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider hostComponentResourceProvider = createStrictMock(ResourceProvider.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>();

    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, "c1");
    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);

    // 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(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));
    expect(hostGroup.getName()).andReturn("group1");
    expect(hostGroup.getComponents()).andReturn(hostGroupComponents);
    expect(hostGroupComponent1.getName()).andReturn("component1");
    expect(hostGroupComponent2.getName()).andReturn("component2");
    expect(hostGroupComponent3.getName()).andReturn("component3");
View Full Code Here

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

      if (requestProps.size() == 1 ) {
        String name = (String) requestProps.iterator().next().get(
            BLUEPRINT_NAME_PROPERTY_ID);

        if (name != null) {
          BlueprintEntity entity = blueprintDAO.findByName(name);
          results = entity == null ? Collections.<BlueprintEntity>emptyList() :
              Collections.singletonList(entity);
        }
      }
    }
View Full Code Here

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

    String name = (String) properties.get(BLUEPRINT_NAME_PROPERTY_ID);
    if (name == null || name.isEmpty()) {
      throw new IllegalArgumentException("Blueprint name must be provided");
    }

    BlueprintEntity blueprint = new BlueprintEntity();
    blueprint.setBlueprintName(name);
    blueprint.setStackName((String) properties.get(STACK_NAME_PROPERTY_ID));
    blueprint.setStackVersion((String) properties.get(STACK_VERSION_PROPERTY_ID));

    createHostGroupEntities(blueprint,
        (HashSet<HashMap<String, Object>>) properties.get(HOST_GROUP_PROPERTY_ID));

    createBlueprintConfigEntities((Collection<Map<String, String>>)
View Full Code Here

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

   */
  private Command<Void> getCreateCommand(final Map<String, Object> properties, final Map<String, String> requestInfoProps) {
    return new Command<Void>() {
      @Override
      public Void invoke() throws AmbariException {
        BlueprintEntity blueprint = toBlueprintEntity(properties);

        if (blueprintDAO.findByName(blueprint.getBlueprintName()) != null) {
          throw new DuplicateResourceException(
              "Attempted to create a Blueprint which already exists, blueprint_name=" +
              blueprint.getBlueprintName());
        }
        Map<String, Map<String, Collection<String>>> missingProperties = blueprint.validateConfigurations(
            stackInfo, PropertyInfo.PropertyType.DEFAULT);

        if (! missingProperties.isEmpty()) {
          throw new IllegalArgumentException("Required configurations are missing from the specified host groups: " +
                                             missingProperties);
        }

        String validateTopology =  requestInfoProps.get("validate_topology");
        if (validateTopology == null || ! validateTopology.equalsIgnoreCase("false")) {
          validateTopology(blueprint);
        }

        if (LOG.isDebugEnabled()) {
          LOG.debug("Creating Blueprint, name=" + blueprint.getBlueprintName());
        }
        try {
          blueprintDAO.create(blueprint);
        } catch (Exception e) {
          throw new RuntimeException(e);
View Full Code Here

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

    LOG.info("Creating Cluster '" + properties.get(CLUSTER_NAME_PROPERTY_ID) +
        "' based on blueprint '" + blueprintName + "'.");

    //todo: build up a proper topology object
    BlueprintEntity blueprint = getExistingBlueprint(blueprintName);
    Stack stack = parseStack(blueprint);

    Map<String, HostGroup> blueprintHostGroups = parseBlueprintHostGroups(blueprint, stack);
    applyRequestInfoToHostGroups(properties, blueprintHostGroups);
    processConfigurations(processBlueprintConfigurations(blueprint, (Collection<Map<String, String>>)
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.