Package org.apache.ambari.server.actionmanager

Examples of org.apache.ambari.server.actionmanager.Stage


    clusters.mapHostsToCluster(new HashSet<String>(){
      {add(hostName1);}}, clusterName);


    List<Stage> stages = new ArrayList<Stage>();
    stages.add(new Stage(requestId1, "/a1", clusterName, context, CLUSTER_HOST_INFO));
    stages.get(0).setStageId(1);
    stages.get(0).addHostRoleExecutionCommand(hostName1, Role.HBASE_MASTER,
            RoleCommand.START,
            new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
                    hostName1, System.currentTimeMillis()),
            clusterName, "HBASE");

    stages.add(new Stage(requestId1, "/a2", clusterName, context, CLUSTER_HOST_INFO));
    stages.get(1).setStageId(2);
    stages.get(1).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
            RoleCommand.START,
            new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
                    hostName1, System.currentTimeMillis()), clusterName, "HBASE");

    stages.add(new Stage(requestId1, "/a3", clusterName, context, CLUSTER_HOST_INFO));
    stages.get(2).setStageId(3);
    stages.get(2).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
            RoleCommand.START,
            new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
                    hostName1, System.currentTimeMillis()), clusterName, "HBASE");


    stages.add(new Stage(requestId2, "/a4", clusterName, context, CLUSTER_HOST_INFO));
    stages.get(3).setStageId(4);
    stages.get(3).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
            RoleCommand.START,
            new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
                    hostName1, System.currentTimeMillis()), clusterName, "HBASE");

    stages.add(new Stage(requestId2, "/a5", clusterName, context, CLUSTER_HOST_INFO));
    stages.get(4).setStageId(5);
    stages.get(4).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
            RoleCommand.START,
            new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
                    hostName1, System.currentTimeMillis()), clusterName, "HBASE");
View Full Code Here


  }

  //For testing only
  public static Stage getATestStage(long requestId, long stageId, String hostname, String clusterHostInfo) {
   
    Stage s = new Stage(requestId, "/tmp", "cluster1", "context", clusterHostInfo);
    s.setStageId(stageId);
    long now = System.currentTimeMillis();
    s.addHostRoleExecutionCommand(hostname, Role.NAMENODE, RoleCommand.INSTALL,
        new ServiceComponentHostInstallEvent("NAMENODE", hostname, now, "HDP-1.2.0"),
        "cluster1", "HDFS");
    ExecutionCommand execCmd = s.getExecutionCommandWrapper(hostname, "NAMENODE").getExecutionCommand();
    execCmd.setCommandId(s.getActionId());
    List<String> slaveHostList = new ArrayList<String>();
    slaveHostList.add(hostname);
    slaveHostList.add("host2");
    Map<String, String> hdfsSite = new TreeMap<String, String>();
    hdfsSite.put("dfs.block.size", "2560000000");
View Full Code Here

    Map<String, List<String>> clusterHostInfo = StageUtils.getClusterHostInfo(
        clusters.getHostsForCluster(cluster.getClusterName()), cluster, hostsMap,
        injector.getInstance(Configuration.class));

    String clusterHostInfoJson = StageUtils.getGson().toJson(clusterHostInfo);
    Stage stage = createNewStage(cluster, actionManager.getNextRequestId(), requestContext, clusterHostInfoJson);

    stage.setStageId(0);

    Map<String, String> params = new TreeMap<String, String>();
    params.put("jdk_location", this.jdkResourceUrl);
    params.put("stack_version", cluster.getDesiredStackVersion().getStackVersion());

    if (actionRequest.isCommand()) {
      customCommandExecutionHelper.addAction(actionRequest, stage, configuration, hostsMap, params);
    } else {
      actionExecutionHelper.addAction(actionExecContext, stage, configuration, hostsMap, params);
    }

    RoleCommandOrder rco = this.getRoleCommandOrder(cluster);
    RoleGraph rg = new RoleGraph(rco);
    rg.build(stage);
    List<Stage> stages = rg.getStages();
    if (stages != null && !stages.isEmpty()) {
      actionManager.sendActions(stages, actionRequest);
      return getRequestStatusResponse(stage.getRequestId());
    } else {
      throw new AmbariException("Stage was not created");
    }
  }
View Full Code Here

        RoleGraphNode rgn = graph.get(role);
        if (rgn.getInDegree() == 0) {
          firstStageNodes.add(rgn);
        }
      }
      Stage aStage = getStageFromGraphNodes(initialStage, firstStageNodes);
      aStage.setStageId(++initialStageId);
      stageList.add(aStage);
      //Remove first stage nodes from the graph, we know that none of
      //these nodes have an incoming edges.
      for (RoleGraphNode rgn : firstStageNodes) {
        if (this.sameHostOptimization) {
View Full Code Here

  }

  private Stage getStageFromGraphNodes(Stage origStage,
      List<RoleGraphNode> stageGraphNodes) {

    Stage newStage = new Stage(origStage.getRequestId(),
        origStage.getLogDir(), origStage.getClusterName(),
        origStage.getRequestContext(), origStage.getClusterHostInfo());
    newStage.setSuccessFactors(origStage.getSuccessFactors());
    for (RoleGraphNode rgn : stageGraphNodes) {
      for (String host : rgn.getHosts()) {
        newStage.addExecutionCommandWrapper(origStage, host, rgn.getRole());
      }
    }
    return newStage;
  }
View Full Code Here

  @Test
  public void testGetAddStages() {
    RequestStageContainer requestStages = new RequestStageContainer(500L, null, null, null);
    assertTrue(requestStages.getStages().isEmpty());

    Stage stage = createNiceMock(Stage.class);
    requestStages.addStages(Collections.singletonList(stage));
    assertEquals(1, requestStages.getStages().size());
    assertTrue(requestStages.getStages().contains(stage));

    Stage stage2 = createNiceMock(Stage.class);
    Stage stage3 = createNiceMock(Stage.class);
    List<Stage> listStages = new ArrayList<Stage>();
    listStages.add(stage2);
    listStages.add(stage3);
    requestStages.addStages(listStages);
    assertEquals(3, requestStages.getStages().size());
View Full Code Here

  @Test
  public void testGetLastStageId() {
    RequestStageContainer requestStages = new RequestStageContainer(1L, null, null, null);
    assertEquals(-1, requestStages.getLastStageId());

    Stage stage1 = createNiceMock(Stage.class);
    Stage stage2 = createNiceMock(Stage.class);
    List<Stage> listStages = new ArrayList<Stage>();
    listStages.add(stage1);
    listStages.add(stage2);

    expect(stage2.getStageId()).andReturn(22L);
    replay(stage1, stage2);

    requestStages = new RequestStageContainer(1L, listStages, null, null);
    assertEquals(22, requestStages.getLastStageId());
  }
View Full Code Here

  @Test
  public void testGetProjectedState() {
    String hostname = "host";
    String componentName = "component";

    Stage stage1 = createNiceMock(Stage.class);
    Stage stage2 = createNiceMock(Stage.class);
    Stage stage3 = createNiceMock(Stage.class);
    Stage stage4 = createNiceMock(Stage.class);
    HostRoleCommand command1 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand command2 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand command3 = createNiceMock(HostRoleCommand.class);

    List<Stage> stages = new ArrayList<Stage>();
    stages.add(stage1);
    stages.add(stage2);
    stages.add(stage3);
    stages.add(stage4);

    //expectations
    expect(stage1.getHostRoleCommands()).andReturn(Collections.singletonMap(hostname, Collections.singletonMap(componentName, command1))).anyTimes();
    expect(stage2.getHostRoleCommands()).andReturn(Collections.singletonMap(hostname, Collections.singletonMap(componentName, command2))).anyTimes();
    expect(stage3.getHostRoleCommands()).andReturn(Collections.singletonMap(hostname, Collections.singletonMap(componentName, command3))).anyTimes();
    expect(stage4.getHostRoleCommands()).andReturn(Collections.<String, Map<String, HostRoleCommand>>emptyMap()).anyTimes();

    expect(command3.getRoleCommand()).andReturn(RoleCommand.SERVICE_CHECK).anyTimes();
    expect(command2.getRoleCommand()).andReturn(RoleCommand.INSTALL).anyTimes();
    replay(stage1, stage2, stage3, stage4, command1, command2, command3);
View Full Code Here

  @Test
  public void testPersist() {
    ActionManager actionManager = createStrictMock(ActionManager.class);
    RequestFactory requestFactory = createStrictMock(RequestFactory.class);
    Request request = createStrictMock(Request.class);
    Stage stage1 = createNiceMock(Stage.class);
    Stage stage2 = createNiceMock(Stage.class);
    List<Stage> stages = new ArrayList<Stage>();
    stages.add(stage1);
    stages.add(stage2);

    //expectations
View Full Code Here

  }

  @Test
  public void testGetRequestStatusResponse() {
    ActionManager actionManager = createStrictMock(ActionManager.class);
    Stage stage1 = createNiceMock(Stage.class);
    Stage stage2 = createNiceMock(Stage.class);
    HostRoleCommand command1 = createNiceMock(HostRoleCommand.class);
    Role role = createNiceMock(Role.class);
    List<Stage> stages = new ArrayList<Stage>();
    RoleCommand roleCommand = RoleCommand.INSTALL;
    HostRoleStatus status = HostRoleStatus.IN_PROGRESS;
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.actionmanager.Stage

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.