@Test @SuppressWarnings("unchecked") public void testComponentUpgradeCompleteReport() throws Exception { Cluster cluster = heartbeatTestHelper.getDummyCluster(); Service hdfs = cluster.addService(HDFS); hdfs.addServiceComponent(DATANODE); hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1); hdfs.addServiceComponent(NAMENODE); hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1); hdfs.addServiceComponent(HDFS_CLIENT); hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1); ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS). getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1); ServiceComponentHost serviceComponentHost2 = clusters.getCluster(DummyCluster).getService(HDFS). getServiceComponent(NAMENODE).getServiceComponentHost(DummyHostname1); StackId stack130 = new StackId("HDP-1.3.0"); StackId stack120 = new StackId("HDP-1.2.0"); serviceComponentHost1.setState(State.UPGRADING); serviceComponentHost2.setState(State.INSTALLING); serviceComponentHost1.setStackVersion(stack120); serviceComponentHost1.setDesiredStackVersion(stack130); serviceComponentHost2.setStackVersion(stack120); HeartBeat hb = new HeartBeat(); hb.setTimestamp(System.currentTimeMillis()); hb.setResponseId(0); hb.setHostname(DummyHostname1); hb.setNodeStatus(new HostStatus(HostStatus.Status.HEALTHY, DummyHostStatus)); CommandReport cr1 = new CommandReport(); cr1.setActionId(StageUtils.getActionId(requestId, stageId)); cr1.setTaskId(1); cr1.setClusterName(DummyCluster); cr1.setServiceName(HDFS); cr1.setRole(DATANODE); cr1.setStatus(HostRoleStatus.COMPLETED.toString()); cr1.setStdErr("none"); cr1.setStdOut("dummy output"); cr1.setExitCode(0); cr1.setRoleCommand(RoleCommand.UPGRADE.toString()); CommandReport cr2 = new CommandReport(); cr2.setActionId(StageUtils.getActionId(requestId, stageId)); cr2.setTaskId(2); cr2.setClusterName(DummyCluster); cr2.setServiceName(HDFS); cr2.setRole(NAMENODE); cr2.setStatus(HostRoleStatus.COMPLETED.toString()); cr2.setStdErr("none"); cr2.setStdOut("dummy output"); cr2.setExitCode(0); cr2.setRoleCommand(RoleCommand.UPGRADE.toString()); ArrayList<CommandReport> reports = new ArrayList<CommandReport>(); reports.add(cr1); reports.add(cr2); hb.setReports(reports); ActionQueue aq = new ActionQueue(); final HostRoleCommand command = hostRoleCommandFactory.create(DummyHostname1, Role.DATANODE, null, null); ActionManager am = actionManagerTestHelper.getMockActionManager(); expect(am.getTasks(EasyMock.<List<Long>>anyObject())).andReturn( new ArrayList<HostRoleCommand>() {{ add(command); add(command); }}); replay(am); HeartBeatHandler handler = heartbeatTestHelper.getHeartBeatHandler(am, aq); HeartbeatProcessor heartbeatProcessor = handler.getHeartbeatProcessor(); heartbeatProcessor.processHeartbeat(hb); assertEquals("Stack version for SCH should be updated to " + serviceComponentHost1.getDesiredStackVersion(), stack130, serviceComponentHost1.getStackVersion()); assertEquals("Stack version for SCH should not change ", stack120, serviceComponentHost2.getStackVersion()); }
public void processHeartbeat(HeartBeat heartbeat) throws AmbariException { long now = System.currentTimeMillis(); processAlerts(heartbeat); processStatusReports(heartbeat); processCommandReports(heartbeat, now); processHostStatus(heartbeat); }
HeartbeatProcessor extends AbstractService { public void processHeartbeat(HeartBeat heartbeat) throws AmbariException { long now = System.currentTimeMillis(); processAlerts(heartbeat); processStatusReports(heartbeat); processCommandReports(heartbeat, now); processHostStatus(heartbeat); } }
HeartbeatProcessor extends AbstractService { public void processHeartbeat(HeartBeat heartbeat) throws AmbariException { long now = System.currentTimeMillis(); processAlerts(heartbeat); processStatusReports(heartbeat); processCommandReports(heartbeat, now); processHostStatus(heartbeat); } @Inject  HeartbeatProcessor(Clusters clusterFsm, ActionManager am, HeartbeatMonitor heartbeatMonitor,
                            Injector injector); }
HeartbeatProcessor extends AbstractService { public void processHeartbeat(HeartBeat heartbeat) throws AmbariException { long now = System.currentTimeMillis(); processAlerts(heartbeat); processStatusReports(heartbeat); processCommandReports(heartbeat, now); processHostStatus(heartbeat); } @Inject  HeartbeatProcessor(Clusters clusterFsm, ActionManager am, HeartbeatMonitor heartbeatMonitor,
                            Injector injector); void addHeartbeat(HeartBeat heartBeat); void processHeartbeat(HeartBeat heartbeat); }
HeartbeatProcessor extends AbstractService { public void processHeartbeat(HeartBeat heartbeat) throws AmbariException { long now = System.currentTimeMillis(); processAlerts(heartbeat); processStatusReports(heartbeat); processCommandReports(heartbeat, now); processHostStatus(heartbeat); } @Inject  HeartbeatProcessor(Clusters clusterFsm, ActionManager am, HeartbeatMonitor heartbeatMonitor,
                            Injector injector); void addHeartbeat(HeartBeat heartBeat); void processHeartbeat(HeartBeat heartbeat);  }