Package org.apache.ambari.server.state

Examples of org.apache.ambari.server.state.State


    // replay
    replay(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);

    ServiceResourceProvider.ServiceState serviceState = new ServiceResourceProvider.HDFSServiceState();

    State state = serviceState.getState(managementController, "C1", "MAPREDUCE");
    Assert.assertEquals(State.STARTED, state);

    // verify
    verify(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
  }
View Full Code Here


    // replay
    replay(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);

    ServiceResourceProvider.ServiceState serviceState = new ServiceResourceProvider.HBaseServiceState();

    State state = serviceState.getState(managementController, "C1", "HBASE");
    Assert.assertEquals(State.STARTED, state);

    // verify
    verify(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
  }
View Full Code Here

    // replay
    replay(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);

    ServiceResourceProvider.ServiceState serviceState = new ServiceResourceProvider.HBaseServiceState();

    State state = serviceState.getState(managementController, "C1", "HBASE");
    Assert.assertEquals(State.INSTALLED, state);

    // verify
    verify(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
  }
View Full Code Here

    // replay
    replay(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);

    ServiceResourceProvider.ServiceState serviceState = new ServiceResourceProvider.HBaseServiceState();

    State state = serviceState.getState(managementController, "C1", "HBASE");
    Assert.assertEquals(State.INSTALLED, state);

    // verify
    verify(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
  }
View Full Code Here

    // replay
    replay(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);

    ServiceResourceProvider.ServiceState serviceState = new ServiceResourceProvider.DefaultServiceState();

    State state = serviceState.getState(managementController, "C1", "GANGLIA");
    Assert.assertEquals(State.STARTED, state);

    // verify
    verify(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
  }
View Full Code Here

    // replay
    replay(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);

    ServiceResourceProvider.ServiceState serviceState = new ServiceResourceProvider.DefaultServiceState();

    State state = serviceState.getState(managementController, "C1", "PIG");
    Assert.assertEquals(State.INSTALLED, state);

    // verify
    verify(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
  }
View Full Code Here

    // replay
    replay(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);

    ServiceResourceProvider.ServiceState serviceState = new ServiceResourceProvider.DefaultServiceState();

    State state = serviceState.getState(managementController, "C1", "PIG");
    Assert.assertEquals(State.INSTALL_FAILED, state);

    // verify
    verify(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
  }
View Full Code Here

            int     nameNodeCount       = 0;
            int     nameNodeActiveCount = 0;
            boolean hasSecondary        = false;
            boolean hasJournal          = false;
            State   nonStartedState     = null;

            for (ServiceComponentHostResponse hostComponentResponse : hostComponentResponses ) {
              ComponentInfo componentInfo = ambariMetaInfo.getComponentCategory(stackId.getStackName(),
                  stackId.getStackVersion(), hostComponentResponse.getServiceName(),
                  hostComponentResponse.getComponentName());

              if (componentInfo != null) {
                if (componentInfo.isMaster()) {

                  String componentName = hostComponentResponse.getComponentName();
                  boolean isNameNode = false;

                  if (componentName.equals("NAMENODE")) {
                    ++nameNodeCount;
                    isNameNode = true;
                  } else if (componentName.equals("SECONDARY_NAMENODE")) {
                    hasSecondary = true;
                  } else if (componentName.equals("JOURNALNODE")) {
                    hasJournal = true;
                  }

                  State state = getHostComponentState(hostComponentResponse);

                  switch (state) {
                    case STARTED:
                    case DISABLED:
                      if (isNameNode) {
View Full Code Here

            Set<ServiceComponentHostResponse> hostComponentResponses =
                controller.getHostComponents(Collections.singleton(request));

            int     hBaseMasterActiveCount = 0;
            State   nonStartedState        = null;

            for (ServiceComponentHostResponse hostComponentResponse : hostComponentResponses ) {
              ComponentInfo componentInfo = ambariMetaInfo.getComponentCategory(stackId.getStackName(),
                  stackId.getStackVersion(), hostComponentResponse.getServiceName(),
                  hostComponentResponse.getComponentName());

              if (componentInfo != null) {
                if (componentInfo.isMaster()) {

                  State state = getHostComponentState(hostComponentResponse);

                  switch (state) {
                    case STARTED:
                    case DISABLED:
                      String componentName = hostComponentResponse.getComponentName();
View Full Code Here

      }
      serviceNames.get(request.getClusterName()).add(request.getServiceName());

      if (request.getDesiredState() != null
          && !request.getDesiredState().isEmpty()) {
        State state = State.valueOf(request.getDesiredState());
        if (!state.isValidDesiredState()
            || state != State.INIT) {
          throw new IllegalArgumentException("Invalid desired state"
              + " only INIT state allowed during creation"
              + ", providedDesiredState=" + request.getDesiredState());
        }
      }

      Cluster cluster;
      try {
        cluster = clusters.getCluster(request.getClusterName());
      } catch (ClusterNotFoundException e) {
        throw new ParentObjectNotFoundException("Attempted to add a service to a cluster which doesn't exist", e);
      }
      try {
        Service s = cluster.getService(request.getServiceName());
        if (s != null) {
          // throw error later for dup
          duplicates.add(request.getServiceName());
          continue;
        }
      } catch (ServiceNotFoundException e) {
        // Expected
      }

      StackId stackId = cluster.getDesiredStackVersion();
      if (!ambariMetaInfo.isValidService(stackId.getStackName(),
          stackId.getStackVersion(), request.getServiceName())) {
        throw new IllegalArgumentException("Unsupported or invalid service"
            + " in stack"
            + ", clusterName=" + request.getClusterName()
            + ", serviceName=" + request.getServiceName()
            + ", stackInfo=" + stackId.getStackId());
      }
    }

    // ensure only a single cluster update
    if (serviceNames.size() != 1) {
      throw new IllegalArgumentException("Invalid arguments, updates allowed"
          + "on only one cluster at a time");
    }

    // Validate dups
    if (!duplicates.isEmpty()) {
      StringBuilder svcNames = new StringBuilder();
      boolean first = true;
      for (String svcName : duplicates) {
        if (!first) {
          svcNames.append(",");
        }
        first = false;
        svcNames.append(svcName);
      }
      String clusterName = requests.iterator().next().getClusterName();
      String msg;
      if (duplicates.size() == 1) {
        msg = "Attempted to create a service which already exists: "
            + ", clusterName=" + clusterName  + " serviceName=" + svcNames.toString();
      } else {
        msg = "Attempted to create services which already exist: "
            + ", clusterName=" + clusterName  + " serviceNames=" + svcNames.toString();
      }
      throw new DuplicateResourceException(msg);
    }

    ServiceFactory serviceFactory = getManagementController().getServiceFactory();

    // now to the real work
    for (ServiceRequest request : requests) {
      Cluster cluster = clusters.getCluster(request.getClusterName());

      State state = State.INIT;

      // Already checked that service does not exist
      Service s = serviceFactory.createNew(cluster, request.getServiceName());

      s.setDesiredState(state);
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.state.State

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.