org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse Java Examples
The following examples show how to use
org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestApplicationCleanup.java From hadoop with Apache License 2.0 | 6 votes |
protected void waitForContainerCleanup(DrainDispatcher dispatcher, MockNM nm, NodeHeartbeatResponse resp) throws Exception { int waitCount = 0, cleanedConts = 0; List<ContainerId> contsToClean; do { dispatcher.await(); contsToClean = resp.getContainersToCleanup(); cleanedConts += contsToClean.size(); if (cleanedConts >= 1) { break; } Thread.sleep(100); resp = nm.nodeHeartbeat(true); } while(waitCount++ < 200); if (contsToClean.isEmpty()) { LOG.error("Failed to get any containers to cleanup"); } else { LOG.info("Got cleanup for " + contsToClean.get(0)); } Assert.assertEquals(1, cleanedConts); }
Example #2
Source File: YarnServerBuilderUtils.java From hadoop with Apache License 2.0 | 6 votes |
public static NodeHeartbeatResponse newNodeHeartbeatResponse(int responseId, NodeAction action, List<ContainerId> containersToCleanUp, List<ApplicationId> applicationsToCleanUp, MasterKey containerTokenMasterKey, MasterKey nmTokenMasterKey, long nextHeartbeatInterval) { NodeHeartbeatResponse response = recordFactory .newRecordInstance(NodeHeartbeatResponse.class); response.setResponseId(responseId); response.setNodeAction(action); response.setContainerTokenMasterKey(containerTokenMasterKey); response.setNMTokenMasterKey(nmTokenMasterKey); response.setNextHeartBeatInterval(nextHeartbeatInterval); if(containersToCleanUp != null) { response.addAllContainersToCleanup(containersToCleanUp); } if(applicationsToCleanUp != null) { response.addAllApplicationsToCleanup(applicationsToCleanUp); } return response; }
Example #3
Source File: TestApplicationCleanup.java From big-c with Apache License 2.0 | 6 votes |
private void waitForAppCleanupMessageRecved(MockNM nm, ApplicationId appId) throws Exception { while (true) { NodeHeartbeatResponse response = nm.nodeHeartbeat(true); if (response.getApplicationsToCleanup() != null && response.getApplicationsToCleanup().size() == 1 && appId.equals(response.getApplicationsToCleanup().get(0))) { return; } LOG.info("Haven't got application=" + appId.toString() + " in cleanup list from node heartbeat response, " + "sleep for a while before next heartbeat"); Thread.sleep(1000); } }
Example #4
Source File: TestResourceTrackerService.java From hadoop with Apache License 2.0 | 6 votes |
/** * Test RM read NM next heartBeat Interval correctly from Configuration file, * and NM get next heartBeat Interval from RM correctly */ @Test (timeout = 50000) public void testGetNextHeartBeatInterval() throws Exception { Configuration conf = new Configuration(); conf.set(YarnConfiguration.RM_NM_HEARTBEAT_INTERVAL_MS, "4000"); rm = new MockRM(conf); rm.start(); MockNM nm1 = rm.registerNode("host1:1234", 5120); MockNM nm2 = rm.registerNode("host2:5678", 10240); NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals(4000, nodeHeartbeat.getNextHeartBeatInterval()); NodeHeartbeatResponse nodeHeartbeat2 = nm2.nodeHeartbeat(true); Assert.assertEquals(4000, nodeHeartbeat2.getNextHeartBeatInterval()); }
Example #5
Source File: RMNodeImpl.java From hadoop with Apache License 2.0 | 6 votes |
@Override public void updateNodeHeartbeatResponseForCleanup(NodeHeartbeatResponse response) { this.writeLock.lock(); try { response.addAllContainersToCleanup( new ArrayList<ContainerId>(this.containersToClean)); response.addAllApplicationsToCleanup(this.finishedApplications); response.addContainersToBeRemovedFromNM( new ArrayList<ContainerId>(this.containersToBeRemovedFromNM)); this.containersToClean.clear(); this.finishedApplications.clear(); this.containersToBeRemovedFromNM.clear(); } finally { this.writeLock.unlock(); } }
Example #6
Source File: TestApplicationCleanup.java From big-c with Apache License 2.0 | 6 votes |
protected void waitForContainerCleanup(DrainDispatcher dispatcher, MockNM nm, NodeHeartbeatResponse resp) throws Exception { int waitCount = 0, cleanedConts = 0; List<ContainerId> contsToClean; do { dispatcher.await(); contsToClean = resp.getContainersToCleanup(); cleanedConts += contsToClean.size(); if (cleanedConts >= 1) { break; } Thread.sleep(100); resp = nm.nodeHeartbeat(true); } while(waitCount++ < 200); if (contsToClean.isEmpty()) { LOG.error("Failed to get any containers to cleanup"); } else { LOG.info("Got cleanup for " + contsToClean.get(0)); } Assert.assertEquals(1, cleanedConts); }
Example #7
Source File: TestResourceTrackerService.java From hadoop with Apache License 2.0 | 6 votes |
@Test public void testReboot() throws Exception { Configuration conf = new Configuration(); rm = new MockRM(conf); rm.start(); MockNM nm1 = rm.registerNode("host1:1234", 5120); MockNM nm2 = rm.registerNode("host2:1234", 2048); int initialMetricCount = ClusterMetrics.getMetrics().getNumRebootedNMs(); NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertTrue(NodeAction.NORMAL.equals(nodeHeartbeat.getNodeAction())); nodeHeartbeat = nm2.nodeHeartbeat( new HashMap<ApplicationId, List<ContainerStatus>>(), true, -100); Assert.assertTrue(NodeAction.RESYNC.equals(nodeHeartbeat.getNodeAction())); Assert.assertEquals("Too far behind rm response id:0 nm response id:-100", nodeHeartbeat.getDiagnosticsMessage()); checkRebootedNMCount(rm, ++initialMetricCount); }
Example #8
Source File: RMNodeImpl.java From big-c with Apache License 2.0 | 6 votes |
@Override public void updateNodeHeartbeatResponseForCleanup(NodeHeartbeatResponse response) { this.writeLock.lock(); try { response.addAllContainersToCleanup( new ArrayList<ContainerId>(this.containersToClean)); response.addAllApplicationsToCleanup(this.finishedApplications); response.addContainersToBeRemovedFromNM( new ArrayList<ContainerId>(this.containersToBeRemovedFromNM)); this.containersToClean.clear(); this.finishedApplications.clear(); this.containersToBeRemovedFromNM.clear(); } finally { this.writeLock.unlock(); } }
Example #9
Source File: YarnServerBuilderUtils.java From big-c with Apache License 2.0 | 6 votes |
public static NodeHeartbeatResponse newNodeHeartbeatResponse(int responseId, NodeAction action, List<ContainerId> containersToCleanUp, List<ApplicationId> applicationsToCleanUp,List<NodeContainerUpdate> listNodeContainerUpdate, MasterKey containerTokenMasterKey, MasterKey nmTokenMasterKey, long nextHeartbeatInterval) { NodeHeartbeatResponse response = recordFactory .newRecordInstance(NodeHeartbeatResponse.class); response.setResponseId(responseId); response.setNodeAction(action); response.setContainerTokenMasterKey(containerTokenMasterKey); response.setNMTokenMasterKey(nmTokenMasterKey); response.setNextHeartBeatInterval(nextHeartbeatInterval); if(containersToCleanUp != null) { response.addAllContainersToCleanup(containersToCleanUp); } if(applicationsToCleanUp != null) { response.addAllApplicationsToCleanup(applicationsToCleanUp); } if(listNodeContainerUpdate != null){ response.addNodeContainersToUpdate(listNodeContainerUpdate); } return response; }
Example #10
Source File: ResourceTrackerService.java From hadoop with Apache License 2.0 | 6 votes |
private void populateKeys(NodeHeartbeatRequest request, NodeHeartbeatResponse nodeHeartBeatResponse) { // Check if node's masterKey needs to be updated and if the currentKey has // roller over, send it across // ContainerTokenMasterKey MasterKey nextMasterKeyForNode = this.containerTokenSecretManager.getNextKey(); if (nextMasterKeyForNode != null && (request.getLastKnownContainerTokenMasterKey().getKeyId() != nextMasterKeyForNode.getKeyId())) { nodeHeartBeatResponse.setContainerTokenMasterKey(nextMasterKeyForNode); } // NMTokenMasterKey nextMasterKeyForNode = this.nmTokenSecretManager.getNextKey(); if (nextMasterKeyForNode != null && (request.getLastKnownNMTokenMasterKey().getKeyId() != nextMasterKeyForNode.getKeyId())) { nodeHeartBeatResponse.setNMTokenMasterKey(nextMasterKeyForNode); } }
Example #11
Source File: ResourceTrackerService.java From big-c with Apache License 2.0 | 6 votes |
private void populateKeys(NodeHeartbeatRequest request, NodeHeartbeatResponse nodeHeartBeatResponse) { // Check if node's masterKey needs to be updated and if the currentKey has // roller over, send it across // ContainerTokenMasterKey MasterKey nextMasterKeyForNode = this.containerTokenSecretManager.getNextKey(); if (nextMasterKeyForNode != null && (request.getLastKnownContainerTokenMasterKey().getKeyId() != nextMasterKeyForNode.getKeyId())) { nodeHeartBeatResponse.setContainerTokenMasterKey(nextMasterKeyForNode); } // NMTokenMasterKey nextMasterKeyForNode = this.nmTokenSecretManager.getNextKey(); if (nextMasterKeyForNode != null && (request.getLastKnownNMTokenMasterKey().getKeyId() != nextMasterKeyForNode.getKeyId())) { nodeHeartBeatResponse.setNMTokenMasterKey(nextMasterKeyForNode); } }
Example #12
Source File: TestResourceTrackerService.java From big-c with Apache License 2.0 | 5 votes |
/** * Decommissioning using a post-configured exclude hosts file */ @Test public void testAddNewExcludePathToConfiguration() throws Exception { Configuration conf = new Configuration(); rm = new MockRM(conf); rm.start(); MockNM nm1 = rm.registerNode("host1:1234", 5120); MockNM nm2 = rm.registerNode("host2:5678", 10240); ClusterMetrics metrics = ClusterMetrics.getMetrics(); assert(metrics != null); int initialMetricCount = metrics.getNumDecommisionedNMs(); NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals( NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); nodeHeartbeat = nm2.nodeHeartbeat(true); Assert.assertEquals( NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); writeToHostsFile("host2"); conf.set(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH, hostFile .getAbsolutePath()); rm.getNodesListManager().refreshNodes(conf); checkDecommissionedNMCount(rm, ++initialMetricCount); nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals( "Node should not have been decomissioned.", NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); nodeHeartbeat = nm2.nodeHeartbeat(true); Assert.assertEquals("Node should have been decomissioned but is in state" + nodeHeartbeat.getNodeAction(), NodeAction.SHUTDOWN, nodeHeartbeat.getNodeAction()); }
Example #13
Source File: NodeManager.java From big-c with Apache License 2.0 | 5 votes |
public void heartbeat() throws IOException, YarnException { NodeStatus nodeStatus = org.apache.hadoop.yarn.server.resourcemanager.NodeManager.createNodeStatus( nodeId, getContainerStatuses(containers)); nodeStatus.setResponseId(responseID); NodeHeartbeatRequest request = recordFactory .newRecordInstance(NodeHeartbeatRequest.class); request.setNodeStatus(nodeStatus); NodeHeartbeatResponse response = resourceTrackerService .nodeHeartbeat(request); responseID = response.getResponseId(); }
Example #14
Source File: TestNodeStatusUpdater.java From hadoop with Apache License 2.0 | 5 votes |
@Override public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) throws YarnException, IOException { LOG.info("Got heartBeatId: [" + heartBeatID +"]"); NodeStatus nodeStatus = request.getNodeStatus(); nodeStatus.setResponseId(heartBeatID++); NodeHeartbeatResponse nhResponse = YarnServerBuilderUtils. newNodeHeartbeatResponse(heartBeatID, heartBeatNodeAction, null, null, null, null, 1000L); if (nodeStatus.getKeepAliveApplications() != null && nodeStatus.getKeepAliveApplications().size() > 0) { for (ApplicationId appId : nodeStatus.getKeepAliveApplications()) { List<Long> list = keepAliveRequests.get(appId); if (list == null) { list = new LinkedList<Long>(); keepAliveRequests.put(appId, list); } list.add(System.currentTimeMillis()); } } if (heartBeatID == 2) { LOG.info("Sending FINISH_APP for application: [" + appId + "]"); this.context.getApplications().put(appId, mock(Application.class)); nhResponse.addAllApplicationsToCleanup(Collections.singletonList(appId)); } return nhResponse; }
Example #15
Source File: RMNodeStatusEvent.java From big-c with Apache License 2.0 | 5 votes |
public RMNodeStatusEvent(NodeId nodeId, NodeHealthStatus nodeHealthStatus, List<ContainerStatus> collection, List<ApplicationId> keepAliveAppIds, NodeHeartbeatResponse latestResponse) { super(nodeId, RMNodeEventType.STATUS_UPDATE); this.nodeHealthStatus = nodeHealthStatus; this.containersCollection = collection; this.keepAliveAppIds = keepAliveAppIds; this.latestResponse = latestResponse; }
Example #16
Source File: MockNodeStatusUpdater.java From hadoop with Apache License 2.0 | 5 votes |
@Override public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) throws YarnException, IOException { NodeStatus nodeStatus = request.getNodeStatus(); LOG.info("Got heartbeat number " + heartBeatID); nodeStatus.setResponseId(heartBeatID++); NodeHeartbeatResponse nhResponse = YarnServerBuilderUtils .newNodeHeartbeatResponse(heartBeatID, null, null, null, null, null, 1000L); return nhResponse; }
Example #17
Source File: MockNM.java From big-c with Apache License 2.0 | 5 votes |
public NodeHeartbeatResponse nodeHeartbeat(ApplicationAttemptId attemptId, long containerId, ContainerState containerState) throws Exception { HashMap<ApplicationId, List<ContainerStatus>> nodeUpdate = new HashMap<ApplicationId, List<ContainerStatus>>(1); ContainerStatus containerStatus = BuilderUtils.newContainerStatus( BuilderUtils.newContainerId(attemptId, containerId), containerState, "Success", 0); ArrayList<ContainerStatus> containerStatusList = new ArrayList<ContainerStatus>(1); containerStatusList.add(containerStatus); Log.info("ContainerStatus: " + containerStatus); nodeUpdate.put(attemptId.getApplicationId(), containerStatusList); return nodeHeartbeat(nodeUpdate, true); }
Example #18
Source File: TestObjectFactory.java From incubator-myriad with Apache License 2.0 | 5 votes |
public static RMNodeStatusEvent getRMStatusEvent(RMNode node) { NodeId id = node.getNodeID(); NodeHealthStatus hStatus = NodeHealthStatusPBImpl.newInstance(true, "HEALTHY", System.currentTimeMillis()); List<ContainerStatus> cStatus = Lists.newArrayList(getContainerStatus(node)); List<ApplicationId> keepAliveIds = Lists.newArrayList(getApplicationId(node.getHttpPort())); NodeHeartbeatResponse response = new NodeHeartbeatResponsePBImpl(); return new RMNodeStatusEvent(id, hStatus, cStatus, keepAliveIds, response); }
Example #19
Source File: TestResourceTrackerPBClientImpl.java From hadoop with Apache License 2.0 | 5 votes |
@Override public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) throws YarnException, IOException { if (exception) { throw new YarnException("testMessage"); } return recordFactory.newRecordInstance(NodeHeartbeatResponse.class); }
Example #20
Source File: ResourceTrackerPBClientImpl.java From big-c with Apache License 2.0 | 5 votes |
@Override public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) throws YarnException, IOException { NodeHeartbeatRequestProto requestProto = ((NodeHeartbeatRequestPBImpl)request).getProto(); try { return new NodeHeartbeatResponsePBImpl(proxy.nodeHeartbeat(null, requestProto)); } catch (ServiceException e) { RPCUtil.unwrapAndThrowException(e); return null; } }
Example #21
Source File: TestRMNodeTransitions.java From big-c with Apache License 2.0 | 5 votes |
private RMNodeStatusEvent getMockRMNodeStatusEvent() { NodeHeartbeatResponse response = mock(NodeHeartbeatResponse.class); NodeHealthStatus healthStatus = mock(NodeHealthStatus.class); Boolean yes = new Boolean(true); doReturn(yes).when(healthStatus).getIsNodeHealthy(); RMNodeStatusEvent event = mock(RMNodeStatusEvent.class); doReturn(healthStatus).when(event).getNodeHealthStatus(); doReturn(response).when(event).getLatestResponse(); doReturn(RMNodeEventType.STATUS_UPDATE).when(event).getType(); return event; }
Example #22
Source File: NMHeartBeatHandlerTest.java From incubator-myriad with Apache License 2.0 | 5 votes |
private RMNodeStatusEvent getRMStatusEvent(RMNode node) { NodeId id = node.getNodeID(); NodeHealthStatus hStatus = NodeHealthStatusPBImpl.newInstance(true, "HEALTHY", System.currentTimeMillis()); List<ContainerStatus> cStatus = Lists.newArrayList(getContainerStatus(node)); List<ApplicationId> keepAliveIds = Lists.newArrayList(getApplicationId(node.getHttpPort())); NodeHeartbeatResponse response = new NodeHeartbeatResponsePBImpl(); return new RMNodeStatusEvent(id, hStatus, cStatus, keepAliveIds, response); }
Example #23
Source File: TestResourceTrackerService.java From big-c with Apache License 2.0 | 5 votes |
/** * Decommissioning using a post-configured include hosts file */ @Test public void testAddNewIncludePathToConfiguration() throws Exception { Configuration conf = new Configuration(); rm = new MockRM(conf); rm.start(); MockNM nm1 = rm.registerNode("host1:1234", 5120); MockNM nm2 = rm.registerNode("host2:5678", 10240); ClusterMetrics metrics = ClusterMetrics.getMetrics(); assert(metrics != null); int initialMetricCount = metrics.getNumDecommisionedNMs(); NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals( NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); nodeHeartbeat = nm2.nodeHeartbeat(true); Assert.assertEquals( NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); writeToHostsFile("host1"); conf.set(YarnConfiguration.RM_NODES_INCLUDE_FILE_PATH, hostFile .getAbsolutePath()); rm.getNodesListManager().refreshNodes(conf); checkDecommissionedNMCount(rm, ++initialMetricCount); nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals( "Node should not have been decomissioned.", NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); nodeHeartbeat = nm2.nodeHeartbeat(true); Assert.assertEquals("Node should have been decomissioned but is in state" + nodeHeartbeat.getNodeAction(), NodeAction.SHUTDOWN, nodeHeartbeat.getNodeAction()); }
Example #24
Source File: TestRMNodeTransitions.java From hadoop with Apache License 2.0 | 5 votes |
private RMNodeStatusEvent getMockRMNodeStatusEvent() { NodeHeartbeatResponse response = mock(NodeHeartbeatResponse.class); NodeHealthStatus healthStatus = mock(NodeHealthStatus.class); Boolean yes = new Boolean(true); doReturn(yes).when(healthStatus).getIsNodeHealthy(); RMNodeStatusEvent event = mock(RMNodeStatusEvent.class); doReturn(healthStatus).when(event).getNodeHealthStatus(); doReturn(response).when(event).getLatestResponse(); doReturn(RMNodeEventType.STATUS_UPDATE).when(event).getType(); return event; }
Example #25
Source File: TestResourceTrackerService.java From hadoop with Apache License 2.0 | 5 votes |
/** * Decommissioning using a post-configured exclude hosts file */ @Test public void testAddNewExcludePathToConfiguration() throws Exception { Configuration conf = new Configuration(); rm = new MockRM(conf); rm.start(); MockNM nm1 = rm.registerNode("host1:1234", 5120); MockNM nm2 = rm.registerNode("host2:5678", 10240); ClusterMetrics metrics = ClusterMetrics.getMetrics(); assert(metrics != null); int initialMetricCount = metrics.getNumDecommisionedNMs(); NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals( NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); nodeHeartbeat = nm2.nodeHeartbeat(true); Assert.assertEquals( NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); writeToHostsFile("host2"); conf.set(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH, hostFile .getAbsolutePath()); rm.getNodesListManager().refreshNodes(conf); checkDecommissionedNMCount(rm, ++initialMetricCount); nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals( "Node should not have been decomissioned.", NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); nodeHeartbeat = nm2.nodeHeartbeat(true); Assert.assertEquals("Node should have been decomissioned but is in state" + nodeHeartbeat.getNodeAction(), NodeAction.SHUTDOWN, nodeHeartbeat.getNodeAction()); }
Example #26
Source File: MockNM.java From hadoop with Apache License 2.0 | 5 votes |
public NodeHeartbeatResponse nodeHeartbeat(ApplicationAttemptId attemptId, long containerId, ContainerState containerState) throws Exception { HashMap<ApplicationId, List<ContainerStatus>> nodeUpdate = new HashMap<ApplicationId, List<ContainerStatus>>(1); ContainerStatus containerStatus = BuilderUtils.newContainerStatus( BuilderUtils.newContainerId(attemptId, containerId), containerState, "Success", 0); ArrayList<ContainerStatus> containerStatusList = new ArrayList<ContainerStatus>(1); containerStatusList.add(containerStatus); Log.info("ContainerStatus: " + containerStatus); nodeUpdate.put(attemptId.getApplicationId(), containerStatusList); return nodeHeartbeat(nodeUpdate, true); }
Example #27
Source File: MockNodeStatusUpdater.java From big-c with Apache License 2.0 | 5 votes |
@Override public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) throws YarnException, IOException { NodeStatus nodeStatus = request.getNodeStatus(); LOG.info("Got heartbeat number " + heartBeatID); nodeStatus.setResponseId(heartBeatID++); NodeHeartbeatResponse nhResponse = YarnServerBuilderUtils .newNodeHeartbeatResponse(heartBeatID, null, null, null, null, null, null, 1000L); return nhResponse; }
Example #28
Source File: MockNM.java From hadoop with Apache License 2.0 | 5 votes |
public NodeHeartbeatResponse nodeHeartbeat(Map<ApplicationId, List<ContainerStatus>> conts, boolean isHealthy, int resId) throws Exception { NodeHeartbeatRequest req = Records.newRecord(NodeHeartbeatRequest.class); NodeStatus status = Records.newRecord(NodeStatus.class); status.setResponseId(resId); status.setNodeId(nodeId); for (Map.Entry<ApplicationId, List<ContainerStatus>> entry : conts.entrySet()) { Log.info("entry.getValue() " + entry.getValue()); status.setContainersStatuses(entry.getValue()); } NodeHealthStatus healthStatus = Records.newRecord(NodeHealthStatus.class); healthStatus.setHealthReport(""); healthStatus.setIsNodeHealthy(isHealthy); healthStatus.setLastHealthReportTime(1); status.setNodeHealthStatus(healthStatus); req.setNodeStatus(status); req.setLastKnownContainerTokenMasterKey(this.currentContainerTokenMasterKey); req.setLastKnownNMTokenMasterKey(this.currentNMTokenMasterKey); NodeHeartbeatResponse heartbeatResponse = resourceTracker.nodeHeartbeat(req); MasterKey masterKeyFromRM = heartbeatResponse.getContainerTokenMasterKey(); if (masterKeyFromRM != null && masterKeyFromRM.getKeyId() != this.currentContainerTokenMasterKey .getKeyId()) { this.currentContainerTokenMasterKey = masterKeyFromRM; } masterKeyFromRM = heartbeatResponse.getNMTokenMasterKey(); if (masterKeyFromRM != null && masterKeyFromRM.getKeyId() != this.currentNMTokenMasterKey .getKeyId()) { this.currentNMTokenMasterKey = masterKeyFromRM; } return heartbeatResponse; }
Example #29
Source File: TestResourceTrackerService.java From hadoop with Apache License 2.0 | 5 votes |
/** * Decommissioning using a post-configured include hosts file */ @Test public void testAddNewIncludePathToConfiguration() throws Exception { Configuration conf = new Configuration(); rm = new MockRM(conf); rm.start(); MockNM nm1 = rm.registerNode("host1:1234", 5120); MockNM nm2 = rm.registerNode("host2:5678", 10240); ClusterMetrics metrics = ClusterMetrics.getMetrics(); assert(metrics != null); int initialMetricCount = metrics.getNumDecommisionedNMs(); NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals( NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); nodeHeartbeat = nm2.nodeHeartbeat(true); Assert.assertEquals( NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); writeToHostsFile("host1"); conf.set(YarnConfiguration.RM_NODES_INCLUDE_FILE_PATH, hostFile .getAbsolutePath()); rm.getNodesListManager().refreshNodes(conf); checkDecommissionedNMCount(rm, ++initialMetricCount); nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals( "Node should not have been decomissioned.", NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); nodeHeartbeat = nm2.nodeHeartbeat(true); Assert.assertEquals("Node should have been decomissioned but is in state" + nodeHeartbeat.getNodeAction(), NodeAction.SHUTDOWN, nodeHeartbeat.getNodeAction()); }
Example #30
Source File: TestNodeStatusUpdater.java From big-c with Apache License 2.0 | 5 votes |
@Override public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) throws YarnException, IOException { NodeStatus nodeStatus = request.getNodeStatus(); nodeStatus.setResponseId(heartBeatID++); NodeHeartbeatResponse nhResponse = YarnServerBuilderUtils. newNodeHeartbeatResponse(heartBeatID, NodeAction.NORMAL, null, null, null, null, null, 1000L); return nhResponse; }