Examples of HostRoleCommand


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

  public void testGetResourcesOrPredicate() throws Exception {
    Resource.Type type = Resource.Type.Request;

    AmbariManagementController managementController = createMock(AmbariManagementController.class);
    ActionManager actionManager = createNiceMock(ActionManager.class);
    HostRoleCommand hostRoleCommand = createNiceMock(HostRoleCommand.class);

    List<HostRoleCommand> hostRoleCommands = new LinkedList<HostRoleCommand>();
    hostRoleCommands.add(hostRoleCommand);

    org.apache.ambari.server.actionmanager.Request requestMock =
        createNiceMock(org.apache.ambari.server.actionmanager.Request.class);
    expect(requestMock.getCommands()).andReturn(hostRoleCommands).anyTimes();
    expect(requestMock.getRequestContext()).andReturn("this is a context").anyTimes();
    expect(requestMock.getRequestId()).andReturn(100L).anyTimes();

    org.apache.ambari.server.actionmanager.Request requestMock1 =
        createNiceMock(org.apache.ambari.server.actionmanager.Request.class);
    expect(requestMock1.getCommands()).andReturn(hostRoleCommands).anyTimes();
    expect(requestMock1.getRequestContext()).andReturn("this is a context").anyTimes();
    expect(requestMock1.getRequestId()).andReturn(101L).anyTimes();

    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();

    // set expectations
    expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
    expect(actionManager.getRequests(capture(requestIdsCapture))).
        andReturn(Arrays.asList(requestMock, requestMock1)).anyTimes();
    expect(hostRoleCommand.getStatus()).andReturn(HostRoleStatus.IN_PROGRESS).anyTimes();

    // replay
    replay(managementController, actionManager, hostRoleCommand, requestMock, requestMock1);

    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
View Full Code Here

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

  public void testGetResourcesCompleted() throws Exception {
    Resource.Type type = Resource.Type.Request;

    AmbariManagementController managementController = createMock(AmbariManagementController.class);
    ActionManager actionManager = createNiceMock(ActionManager.class);
    HostRoleCommand hostRoleCommand0 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand hostRoleCommand1 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand hostRoleCommand2 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand hostRoleCommand3 = createNiceMock(HostRoleCommand.class);

    List<HostRoleCommand> hostRoleCommands0 = new LinkedList<HostRoleCommand>();
    hostRoleCommands0.add(hostRoleCommand0);
    hostRoleCommands0.add(hostRoleCommand1);

    List<HostRoleCommand> hostRoleCommands1 = new LinkedList<HostRoleCommand>();
    hostRoleCommands1.add(hostRoleCommand2);
    hostRoleCommands1.add(hostRoleCommand3);

    org.apache.ambari.server.actionmanager.Request requestMock0 =
        createNiceMock(org.apache.ambari.server.actionmanager.Request.class);
    expect(requestMock0.getCommands()).andReturn(hostRoleCommands0).anyTimes();
    expect(requestMock0.getRequestContext()).andReturn("this is a context").anyTimes();
    expect(requestMock0.getRequestId()).andReturn(100L).anyTimes();

    org.apache.ambari.server.actionmanager.Request requestMock1 =
        createNiceMock(org.apache.ambari.server.actionmanager.Request.class);
    expect(requestMock1.getCommands()).andReturn(hostRoleCommands1).anyTimes();
    expect(requestMock1.getRequestContext()).andReturn("this is a context").anyTimes();
    expect(requestMock1.getRequestId()).andReturn(101L).anyTimes();

    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();

    // set expectations
    expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
    expect(actionManager.getRequests(capture(requestIdsCapture))).andReturn(Arrays.asList(requestMock0));
    expect(actionManager.getRequests(capture(requestIdsCapture))).andReturn(Arrays.asList(requestMock1));
    expect(hostRoleCommand0.getRequestId()).andReturn(100L).anyTimes();
    expect(hostRoleCommand1.getRequestId()).andReturn(100L).anyTimes();
    expect(hostRoleCommand2.getRequestId()).andReturn(101L).anyTimes();
    expect(hostRoleCommand3.getRequestId()).andReturn(101L).anyTimes();
    expect(hostRoleCommand0.getStatus()).andReturn(HostRoleStatus.COMPLETED).anyTimes();
    expect(hostRoleCommand1.getStatus()).andReturn(HostRoleStatus.COMPLETED).anyTimes();
    expect(hostRoleCommand2.getStatus()).andReturn(HostRoleStatus.COMPLETED).anyTimes();
    expect(hostRoleCommand3.getStatus()).andReturn(HostRoleStatus.COMPLETED).anyTimes();

    // replay
    replay(managementController, actionManager, hostRoleCommand0, hostRoleCommand1, hostRoleCommand2, hostRoleCommand3,
        requestMock0, requestMock1);
View Full Code Here

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

  public void testGetResourcesInProgress() throws Exception {
    Resource.Type type = Resource.Type.Request;

    AmbariManagementController managementController = createMock(AmbariManagementController.class);
    ActionManager actionManager = createNiceMock(ActionManager.class);
    HostRoleCommand hostRoleCommand0 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand hostRoleCommand1 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand hostRoleCommand2 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand hostRoleCommand3 = createNiceMock(HostRoleCommand.class);

    List<HostRoleCommand> hostRoleCommands0 = new LinkedList<HostRoleCommand>();
    hostRoleCommands0.add(hostRoleCommand0);
    hostRoleCommands0.add(hostRoleCommand1);

    List<HostRoleCommand> hostRoleCommands1 = new LinkedList<HostRoleCommand>();
    hostRoleCommands1.add(hostRoleCommand2);
    hostRoleCommands1.add(hostRoleCommand3);

    org.apache.ambari.server.actionmanager.Request requestMock0 =
        createNiceMock(org.apache.ambari.server.actionmanager.Request.class);
    expect(requestMock0.getCommands()).andReturn(hostRoleCommands0).anyTimes();
    expect(requestMock0.getRequestContext()).andReturn("this is a context").anyTimes();
    expect(requestMock0.getRequestId()).andReturn(100L).anyTimes();

    org.apache.ambari.server.actionmanager.Request requestMock1 =
        createNiceMock(org.apache.ambari.server.actionmanager.Request.class);
    expect(requestMock1.getCommands()).andReturn(hostRoleCommands1).anyTimes();
    expect(requestMock1.getRequestContext()).andReturn("this is a context").anyTimes();
    expect(requestMock1.getRequestId()).andReturn(101L).anyTimes();

    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();

    // set expectations
    expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
    expect(actionManager.getRequests(capture(requestIdsCapture))).andReturn(Arrays.asList(requestMock0));
    expect(actionManager.getRequests(capture(requestIdsCapture))).andReturn(Arrays.asList(requestMock1));
    expect(hostRoleCommand0.getRequestId()).andReturn(100L).anyTimes();
    expect(hostRoleCommand1.getRequestId()).andReturn(100L).anyTimes();
    expect(hostRoleCommand2.getRequestId()).andReturn(101L).anyTimes();
    expect(hostRoleCommand3.getRequestId()).andReturn(101L).anyTimes();
    expect(hostRoleCommand0.getStatus()).andReturn(HostRoleStatus.IN_PROGRESS).anyTimes();
    expect(hostRoleCommand1.getStatus()).andReturn(HostRoleStatus.PENDING).anyTimes();
    expect(hostRoleCommand2.getStatus()).andReturn(HostRoleStatus.IN_PROGRESS).anyTimes();
    expect(hostRoleCommand3.getStatus()).andReturn(HostRoleStatus.QUEUED).anyTimes();

    // replay
    replay(managementController, actionManager, hostRoleCommand0, hostRoleCommand1, hostRoleCommand2, hostRoleCommand3,
        requestMock0, requestMock1);
View Full Code Here

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

  public void testGetResourcesFailed() throws Exception {
    Resource.Type type = Resource.Type.Request;

    AmbariManagementController managementController = createMock(AmbariManagementController.class);
    ActionManager actionManager = createNiceMock(ActionManager.class);
    HostRoleCommand hostRoleCommand0 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand hostRoleCommand1 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand hostRoleCommand2 = createNiceMock(HostRoleCommand.class);
    HostRoleCommand hostRoleCommand3 = createNiceMock(HostRoleCommand.class);

    List<HostRoleCommand> hostRoleCommands0 = new LinkedList<HostRoleCommand>();
    hostRoleCommands0.add(hostRoleCommand0);
    hostRoleCommands0.add(hostRoleCommand1);

    List<HostRoleCommand> hostRoleCommands1 = new LinkedList<HostRoleCommand>();
    hostRoleCommands1.add(hostRoleCommand2);
    hostRoleCommands1.add(hostRoleCommand3);

    org.apache.ambari.server.actionmanager.Request requestMock0 =
        createNiceMock(org.apache.ambari.server.actionmanager.Request.class);
    expect(requestMock0.getCommands()).andReturn(hostRoleCommands0).anyTimes();
    expect(requestMock0.getRequestContext()).andReturn("this is a context").anyTimes();
    expect(requestMock0.getRequestId()).andReturn(100L).anyTimes();

    org.apache.ambari.server.actionmanager.Request requestMock1 =
        createNiceMock(org.apache.ambari.server.actionmanager.Request.class);
    expect(requestMock1.getCommands()).andReturn(hostRoleCommands1).anyTimes();
    expect(requestMock1.getRequestContext()).andReturn("this is a context").anyTimes();
    expect(requestMock1.getRequestId()).andReturn(101L).anyTimes();

    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();

    // set expectations
    expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
    expect(actionManager.getRequests(capture(requestIdsCapture))).andReturn(Arrays.asList(requestMock0));
    expect(actionManager.getRequests(capture(requestIdsCapture))).andReturn(Arrays.asList(requestMock1));
    expect(hostRoleCommand0.getRequestId()).andReturn(100L).anyTimes();
    expect(hostRoleCommand1.getRequestId()).andReturn(100L).anyTimes();
    expect(hostRoleCommand2.getRequestId()).andReturn(101L).anyTimes();
    expect(hostRoleCommand3.getRequestId()).andReturn(101L).anyTimes();
    expect(hostRoleCommand0.getStatus()).andReturn(HostRoleStatus.FAILED).anyTimes();
    expect(hostRoleCommand1.getStatus()).andReturn(HostRoleStatus.COMPLETED).anyTimes();
    expect(hostRoleCommand2.getStatus()).andReturn(HostRoleStatus.ABORTED).anyTimes();
    expect(hostRoleCommand3.getStatus()).andReturn(HostRoleStatus.TIMEDOUT).anyTimes();

    // replay
    replay(managementController, actionManager, hostRoleCommand0, hostRoleCommand1, hostRoleCommand2, hostRoleCommand3,
        requestMock0, requestMock1);
View Full Code Here

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

      Map<String, Map<String, String>> configurations =
          new TreeMap<String, Map<String, String>>();
      Map<String, Map<String, String>> configTags =
          managementController.findConfigurationTagsWithOverrides(cluster, hostName);

      HostRoleCommand cmd = stage.getHostRoleCommand(hostName, componentName);
      if (cmd != null) {
        cmd.setCommandDetail(commandDetail);
        cmd.setCustomCommandName(commandName);
      }

      ExecutionCommand execCmd = stage.getExecutionCommandWrapper(hostName,
          componentName).getExecutionCommand();
View Full Code Here

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

        Role.valueOf(smokeTestRole),
        RoleCommand.SERVICE_CHECK,
        new ServiceComponentHostOpInProgressEvent(componentName, hostname,
            nowTimestamp), cluster.getClusterName(), serviceName);

    HostRoleCommand hrc = stage.getHostRoleCommand(hostname, smokeTestRole);
    if (hrc != null) {
      hrc.setCommandDetail(String.format("%s %s", RoleCommand.SERVICE_CHECK.toString(), serviceName));
    }
    // [ type -> [ key, value ] ]
    Map<String, Map<String, String>> configurations =
        new TreeMap<String, Map<String, String>>();
    Map<String, Map<String, String>> configTags =
View Full Code Here

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

    initialStage = stage;

    Map<String, Map<String, HostRoleCommand>> hostRoleCommands = stage.getHostRoleCommands();
    for (String host : hostRoleCommands.keySet()) {
      for (String role : hostRoleCommands.get(host).keySet()) {
        HostRoleCommand hostRoleCommand = hostRoleCommands.get(host).get(role);
        RoleGraphNode rgn;
        if (graph.get(role) == null) {
          rgn = new RoleGraphNode(hostRoleCommand.getRole(),
              hostRoleCommand.getRoleCommand());
          graph.put(role, rgn);
        }
        rgn = graph.get(role);
        rgn.addHost(host);
      }
View Full Code Here

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

    List<HostRoleCommand> storedTasks = actionDB.getRequestTasks(response.getRequestId());
    Stage stage = actionDB.getAllStages(response.getRequestId()).get(0);

    assertEquals(1, storedTasks.size());
    HostRoleCommand hostRoleCommand = storedTasks.get(0);

    assertEquals(task.getTaskId(), hostRoleCommand.getTaskId());
    assertEquals(actionRequest.getServiceName(), hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getServiceName());
    assertEquals(actionRequest.getClusterName(), hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getClusterName());
    assertEquals(actionRequest.getActionName(), hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getRole().name());
    assertEquals(Role.HDFS_CLIENT.name(), hostRoleCommand.getEvent().getEvent().getServiceComponentName());
    assertEquals(actionRequest.getParameters(), hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getRoleParams());
    assertNotNull(hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getConfigurations());
    assertEquals(2, hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getConfigurations().size());
    assertEquals(requestProperties.get(REQUEST_CONTEXT_PROPERTY), stage.getRequestContext());
    actionRequests.add(new ActionRequest("c1", "MAPREDUCE", Role.MAPREDUCE_SERVICE_CHECK.name(), null));

    response = controller.createActions(actionRequests, requestProperties);
View Full Code Here

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

    long requestId2 = startService(clusterName, serviceName1, true, true);
    long requestId3 = startService(clusterName, serviceName2, true, true);

    stages = actionDB.getAllStages(requestId2);
    stages.addAll(actionDB.getAllStages(requestId3));
    HostRoleCommand hdfsCmdHost3 = null;
    HostRoleCommand hdfsCmdHost2 = null;
    HostRoleCommand mapRedCmdHost2 = null;
    HostRoleCommand mapRedCmdHost3 = null;
    for (Stage stage : stages) {
      List<HostRoleCommand> hrcs = stage.getOrderedHostRoleCommands();

      for (HostRoleCommand hrc : hrcs) {
        LOG.debug("role: " + hrc.getRole());
        if (hrc.getRole().toString().equals("HDFS_CLIENT")) {
          if (hrc.getHostName().equals(host3))
            hdfsCmdHost3 = hrc;
          else if (hrc.getHostName().equals(host2))
            hdfsCmdHost2 = hrc;
        }
        if (hrc.getRole().toString().equals("MAPREDUCE_CLIENT")) {
          if (hrc.getHostName().equals(host2))
            mapRedCmdHost2 = hrc;
          else if (hrc.getHostName().equals(host3))
            mapRedCmdHost3 = hrc;
        }
      }
    }
    Assert.assertNotNull(hdfsCmdHost3);
    Assert.assertNotNull(hdfsCmdHost2);
    ExecutionCommand execCmd = hdfsCmdHost3.getExecutionCommandWrapper()
      .getExecutionCommand();
    Assert.assertEquals(2, execCmd.getConfigurationTags().size());
    Assert.assertEquals("version122", execCmd.getConfigurationTags().get
      ("core-site").get("tag"));
    Assert.assertEquals("d", execCmd.getConfigurations().get("core-site")
      .get("c"));
    // Check if MapReduce client is reinstalled
    Assert.assertNotNull(mapRedCmdHost2);
    Assert.assertNotNull(mapRedCmdHost3);

    /**
     * Test for lost host
     */
    // Stop HDFS & MAPREDUCE
    stopService(clusterName, serviceName1, false, false);
    stopService(clusterName, serviceName2, false, false);

    clusters.getHost(host2).setState(HostState.HEARTBEAT_LOST);

    // Start
    requestId2 = startService(clusterName, serviceName1, true, true);
    requestId3 = startService(clusterName, serviceName2, true, true);
    stages = actionDB.getAllStages(requestId2);
    stages.addAll(actionDB.getAllStages(requestId3));
    HostRoleCommand clientWithHostDown = null;
    for (Stage stage : stages) {
      for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
        if (hrc.getRole().toString().equals("MAPREDUCE_CLIENT") && hrc
          .getHostName().equals(host2))
          clientWithHostDown = hrc;
View Full Code Here

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

    crReq.setDesiredConfig(cr3);
    controller.updateCluster(crReq, null);

    id = startService(clusterName, serviceName, false, true);
    List<Stage> stages = actionDB.getAllStages(id);
    HostRoleCommand clientHrc = null;
    for (Stage stage : stages) {
      for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
        if (hrc.getHostName().equals(host2) && hrc.getRole().toString()
          .equals("HDFS_CLIENT")) {
          clientHrc = hrc;
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.