Package org.apache.ambari.server.controller.spi

Examples of org.apache.ambari.server.controller.spi.ClusterController


  private static final Logger logger = Logger
      .getLogger(AmbariInternalClient.class);

  @Override
  public AmbariCluster getCluster(AmbariClusterInfo clusterInfo) {
    ClusterController clusterController = ClusterControllerHelper
        .getClusterController();
    try {
      EqualsPredicate<String> clusterPredicate = new EqualsPredicate<String>(
          "Clusters/cluster_name", clusterInfo.getName());
      Set<Resource> clusterResources = clusterController.getResources(
          Resource.Type.Cluster, PropertyHelper.getReadRequest(),
          clusterPredicate);
      if (!clusterResources.isEmpty()) {
        Resource clusterResource = clusterResources.iterator().next();
        AmbariCluster cluster = new AmbariCluster();
        cluster.setName(clusterResource.getPropertyValue(
            "Clusters/cluster_name").toString());
        cluster.setVersion(clusterResource.getPropertyValue("Clusters/version")
            .toString());
        Map<String, String> desiredConfigsMap = new HashMap<String, String>();
        Map<String, Object> desiredConfigsMapResource = clusterResource
            .getPropertiesMap().get("Clusters/desired_configs");
        for (Map.Entry<String, Object> siteEntry : desiredConfigsMapResource
            .entrySet()) {
          desiredConfigsMap.put(siteEntry.getKey(),
              ((DesiredConfig) siteEntry.getValue()).getVersion());
        }
        cluster.setDesiredConfigs(desiredConfigsMap);

        EqualsPredicate<String> serviceClusterPredicate = new EqualsPredicate<String>(
            "ServiceInfo/cluster_name", cluster.getName());
        EqualsPredicate<String> hostClusterPredicate = new EqualsPredicate<String>(
            "Hosts/cluster_name", cluster.getName());
        Set<Resource> serviceResources = clusterController.getResources(
            Resource.Type.Service, PropertyHelper.getReadRequest(),
            serviceClusterPredicate);
        Set<Resource> hostResources = clusterController.getResources(
            Resource.Type.Host, PropertyHelper.getReadRequest(),
            hostClusterPredicate);
        List<AmbariServiceInfo> servicesList = new ArrayList<AmbariServiceInfo>();
        List<AmbariHostInfo> hostsList = new ArrayList<AmbariHostInfo>();
        for (Resource serviceResource : serviceResources) {
View Full Code Here


    return null;
  }

  @Override
  public AmbariClusterInfo getClusterInfo() {
    ClusterController clusterController = ClusterControllerHelper
        .getClusterController();
    try {
      Set<Resource> resources = clusterController.getResources(
          Resource.Type.Cluster, PropertyHelper.getReadRequest(), null);
      if (resources.size() > 0) {
        Resource clusterResource = resources.iterator().next();
        AmbariClusterInfo clusterInfo = new AmbariClusterInfo();
        clusterInfo.setName(clusterResource.getPropertyValue(
View Full Code Here

  }

  @Override
  public Map<String, String> getConfiguration(AmbariClusterInfo cluster,
      String configType, String configTag) {
    ClusterController clusterController = ClusterControllerHelper
        .getClusterController();
    try {
      EqualsPredicate<String> clusterPredicate = new EqualsPredicate<String>(
          "Config/cluster_name", cluster.getName());
      EqualsPredicate<String> typePredicate = new EqualsPredicate<String>(
          "type", configType);
      EqualsPredicate<String> tagPredicate = new EqualsPredicate<String>("tag",
          configTag);
      AndPredicate typeTagPredicate = new AndPredicate(typePredicate,
          tagPredicate);
      AndPredicate configsPredicate = new AndPredicate(clusterPredicate,
          typeTagPredicate);

      Set<Resource> configResources = clusterController.getResources(
          Resource.Type.Configuration, PropertyHelper.getReadRequest(),
          configsPredicate);
      if (!configResources.isEmpty()) {
        Resource configResource = configResources.iterator().next();
        Map<String, String> configs = new HashMap<String, String>();
View Full Code Here

  }

  @Override
  public AmbariService getService(AmbariClusterInfo clusterInfo,
      String serviceId) {
    ClusterController clusterController = ClusterControllerHelper
        .getClusterController();
    try {
      EqualsPredicate<String> clusterPredicate = new EqualsPredicate<String>(
          "ServiceInfo/cluster_name", clusterInfo.getName());
      EqualsPredicate<String> servicePredicate = new EqualsPredicate<String>(
          "ServiceInfo/service_name", serviceId);
      AndPredicate andPredicate = new AndPredicate(clusterPredicate,
          servicePredicate);
      Set<Resource> serviceResources = clusterController.getResources(
          Resource.Type.Service, PropertyHelper.getReadRequest(), andPredicate);
      if (!serviceResources.isEmpty()) {
        Resource serviceResource = serviceResources.iterator().next();
        AmbariService service = new AmbariService();
        service.setId(serviceResource.getPropertyValue(
            "ServiceInfo/service_name").toString());
        service.setStarted(State.STARTED.toString().equals(
            serviceResource.getPropertyValue("ServiceInfo/state")));
        service.setMaintenanceMode("ON".equals(serviceResource
            .getPropertyValue("ServiceInfo/maintenance_state")));
        // Components
        Map<String, List<AmbariHostComponent>> componentsMap = new HashMap<String, List<AmbariHostComponent>>();
        service.setComponentsToHostComponentsMap(componentsMap);
        clusterPredicate = new EqualsPredicate<String>(
            "ServiceComponentInfo/cluster_name", clusterInfo.getName());
        servicePredicate = new EqualsPredicate<String>(
            "ServiceComponentInfo/service_name", serviceId);
        andPredicate = new AndPredicate(clusterPredicate, servicePredicate);
        Set<Resource> componentResources = clusterController.getResources(
            Resource.Type.Component, PropertyHelper.getReadRequest(),
            andPredicate);
        if (!componentResources.isEmpty()) {
          for (Resource componentResouce : componentResources) {
            List<AmbariHostComponent> hostComponents = new ArrayList<AmbariHostComponent>();
            String componentName = componentResouce.getPropertyValue(
                "ServiceComponentInfo/component_name").toString();
            componentsMap.put(componentName, hostComponents);
            clusterPredicate = new EqualsPredicate<String>(
                "HostRoles/cluster_name", clusterInfo.getName());
            EqualsPredicate<String> componentPredicate = new EqualsPredicate<String>(
                "HostRoles/component_name", componentName);
            andPredicate = new AndPredicate(clusterPredicate,
                componentPredicate);
            Set<Resource> hostComponentResources = clusterController
                .getResources(Resource.Type.HostComponent,
                    PropertyHelper.getReadRequest(), andPredicate);
            if (!hostComponentResources.isEmpty()) {
              for (Resource hostComponentResource : hostComponentResources) {
                AmbariHostComponent hc = new AmbariHostComponent();
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.controller.spi.ClusterController

Copyright © 2018 www.massapicom. 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.