Package org.apache.ambari.server.state

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


  @Test
  public void testRegistrationWithBadVersion() throws AmbariException,
      InvalidStateTransitionException {

    ActionManager am = getMockActionManager();
    Clusters fsm = clusters;
    HeartBeatHandler handler = new HeartBeatHandler(fsm, new ActionQueue(), am,
        injector);
    clusters.addHost(DummyHostname1);
    Host hostObject = clusters.getHost(DummyHostname1);
    hostObject.setIPv4("ipv4");
View Full Code Here


  }

  @Test
  public void testRegistrationPublicHostname() throws AmbariException, InvalidStateTransitionException {
    ActionManager am = getMockActionManager();
    Clusters fsm = clusters;
    HeartBeatHandler handler = new HeartBeatHandler(fsm, new ActionQueue(), am,
        injector);
    clusters.addHost(DummyHostname1);
    Host hostObject = clusters.getHost(DummyHostname1);
    hostObject.setIPv4("ipv4");
View Full Code Here

  @Test
  public void testInvalidOSRegistration() throws AmbariException,
      InvalidStateTransitionException {
    ActionManager am = getMockActionManager();
    Clusters fsm = clusters;
    HeartBeatHandler handler = new HeartBeatHandler(fsm, new ActionQueue(), am,
        injector);
    clusters.addHost(DummyHostname1);
    Host hostObject = clusters.getHost(DummyHostname1);
    hostObject.setIPv4("ipv4");
View Full Code Here

  @Test
  public void testIncompatibleAgentRegistration() throws AmbariException,
          InvalidStateTransitionException {

    ActionManager am = getMockActionManager();
    Clusters fsm = clusters;
    HeartBeatHandler handler = new HeartBeatHandler(fsm, new ActionQueue(), am,
            injector);
    clusters.addHost(DummyHostname1);
    Host hostObject = clusters.getHost(DummyHostname1);
    hostObject.setIPv4("ipv4");
View Full Code Here

  @Test
  public void testRegisterNewNode()
      throws AmbariException, InvalidStateTransitionException {
    ActionManager am = getMockActionManager();
    Clusters fsm = clusters;
    fsm.addHost(DummyHostname1);
    Host hostObject = clusters.getHost(DummyHostname1);
    hostObject.setIPv4("ipv4");
    hostObject.setIPv6("ipv6");

    HeartBeatHandler handler = new HeartBeatHandler(fsm, new ActionQueue(), am,
View Full Code Here

    dummyCmds.add(statusCmd1);
    HeartbeatMonitor hm = mock(HeartbeatMonitor.class);
    when(hm.generateStatusCommands(anyString())).thenReturn(dummyCmds);

    ActionManager am = getMockActionManager();
    Clusters fsm = clusters;
    ActionQueue actionQueue = new ActionQueue();
    HeartBeatHandler handler = new HeartBeatHandler(fsm, actionQueue, am,
        injector);
    handler.setHeartbeatMonitor(hm);
    clusters.addHost(DummyHostname1);
View Full Code Here

  }
 
  @Test
  public void testProcessStatusReports() throws Exception {
    ActionManager am = getMockActionManager();
    Clusters fsm = clusters;

    Cluster cluster = getDummyCluster();
    Host hostObject = clusters.getHost(DummyHostname1);
    clusters.mapHostToCluster(hostObject.getHostName(), cluster.getClusterName());
    Service hdfs = cluster.addService(HDFS);
View Full Code Here

    assertEquals(cmd, cmdDes);
  }

  @Test
  public void testGetClusterHostInfo() throws AmbariException, UnknownHostException {
    Clusters fsm = injector.getInstance(Clusters.class);
   
    List<String> hostList = new ArrayList<String>();
    hostList.add("h1");
    hostList.add("h2");
    hostList.add("h3");
    hostList.add("h4");
    hostList.add("h5");
    hostList.add("h6");
    hostList.add("h7");
    hostList.add("h8");
    hostList.add("h9");
    hostList.add("h10");
   
    List<Integer> pingPorts = Arrays.asList(StageUtils.DEFAULT_PING_PORT,
        StageUtils.DEFAULT_PING_PORT,
        StageUtils.DEFAULT_PING_PORT,
        8671,
        8671,
        null,
        8672,
        8672,
        null,
        8673);
   
    fsm.addCluster("c1");
    fsm.getCluster("c1").setDesiredStackVersion(new StackId(STACK_ID));
   
    int index = 0;
   
    for (String host: hostList) {
      fsm.addHost(host);
      fsm.getHost(host).setOsType("centos5");
      fsm.getHost(host).setCurrentPingPort(pingPorts.get(index));
      fsm.getHost(host).persist();
      fsm.mapHostToCluster(host, "c1");
      index++;
    }

    //Add HDFS service
    Map<String, List<Integer>> hdfsTopology = new HashMap<String, List<Integer>>();
    hdfsTopology.put("NAMENODE", Collections.singletonList(0));
    hdfsTopology.put("SECONDARY_NAMENODE", Collections.singletonList(1));
    List<Integer> datanodeIndexes = Arrays.asList(0,1,2,3,5,7,8,9);
    hdfsTopology.put("DATANODE", new ArrayList<Integer>(datanodeIndexes));
    addService(fsm.getCluster("c1"), hostList, hdfsTopology , "HDFS", injector);
   
    //Add HBASE service
    Map<String, List<Integer>> hbaseTopology = new HashMap<String, List<Integer>>();
    hbaseTopology.put("HBASE_MASTER", Collections.singletonList(5));
    List<Integer> regionServiceIndexes = Arrays.asList(1,3,5,8,9);;
    hbaseTopology.put("HBASE_REGIONSERVER", regionServiceIndexes);
    addService(fsm.getCluster("c1"), hostList, hbaseTopology , "HBASE", injector);
   
    //Add MAPREDUCE service
    Map<String, List<Integer>> mrTopology = new HashMap<String, List<Integer>>();
    mrTopology.put("JOBTRACKER", Collections.singletonList(5));
    List<Integer> taskTrackerIndexes = Arrays.asList(1,2,3,4,5,7,9);;
    mrTopology.put("TASKTRACKER", taskTrackerIndexes);
    addService(fsm.getCluster("c1"), hostList, mrTopology , "MAPREDUCE", injector);
   
   
    //Add NONAME service
    Map<String, List<Integer>> nonameTopology = new HashMap<String, List<Integer>>();
    nonameTopology.put("NONAME_SERVER", Collections.singletonList(7));
    addService(fsm.getCluster("c1"), hostList, nonameTopology , "NONAME", injector);

    fsm.getCluster("c1").getService("MAPREDUCE").getServiceComponent("TASKTRACKER").getServiceComponentHost("h2")
        .setComponentAdminState(HostComponentAdminState.DECOMMISSIONED);
    fsm.getCluster("c1").getService("MAPREDUCE").getServiceComponent("TASKTRACKER").getServiceComponentHost("h3")
        .setComponentAdminState(HostComponentAdminState.DECOMMISSIONED);

    //Get cluster host info
    Map<String, Set<String>> info =
        StageUtils.getClusterHostInfo(fsm.getHostsForCluster("c1"), fsm.getCluster("c1"));

    //All hosts present in cluster host info
    assertEquals(fsm.getHosts().size(), info.get(HOSTS_LIST).size());
    for (Host host: fsm.getHosts()) {
      assertTrue(info.get(HOSTS_LIST).contains(host.getHostName()));
    }
   
   
    //Check HDFS topology compression
View Full Code Here

  @Test
  public void testGetActions() throws Exception {
    int requestId = 500;
    ActionQueue queue = createNiceMock(ActionQueue.class);
    ActionDBAccessor db = createStrictMock(ActionDBAccessor.class);
    Clusters clusters = createNiceMock(Clusters.class);
    Stage stage1 = createNiceMock(Stage.class);
    Stage stage2 = createNiceMock(Stage.class);
    List<Stage> listStages = new ArrayList<Stage>();
    listStages.add(stage1);
    listStages.add(stage2);
View Full Code Here

  protected static class HBaseServiceState implements ServiceState {

    @Override
    public State getState(AmbariManagementController controller,String clusterName, String serviceName) {
      AmbariMetaInfo ambariMetaInfo = controller.getAmbariMetaInfo();
      Clusters       clusters       = controller.getClusters();

      if (clusterName != null && clusterName.length() > 0) {
        try {
          Cluster cluster = clusters.getCluster(clusterName);
          if (cluster != null) {
            StackId stackId = cluster.getDesiredStackVersion();

            ServiceComponentHostRequest request = new ServiceComponentHostRequest(clusterName,
                serviceName, null, null, null);
View Full Code Here

TOP

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

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.