Java Code Examples for org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest#setNodeStatus()
The following examples show how to use
org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest#setNodeStatus() .
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: TestNMExpiry.java From hadoop with Apache License 2.0 | 6 votes |
public void run() { int lastResponseID = 0; while (!stopT) { try { org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = recordFactory .newRecordInstance(org.apache.hadoop.yarn.server.api.records.NodeStatus.class); nodeStatus.setNodeId(request3.getNodeId()); nodeStatus.setResponseId(lastResponseID); nodeStatus.setNodeHealthStatus(recordFactory.newRecordInstance(NodeHealthStatus.class)); nodeStatus.getNodeHealthStatus().setIsNodeHealthy(true); NodeHeartbeatRequest request = recordFactory .newRecordInstance(NodeHeartbeatRequest.class); request.setNodeStatus(nodeStatus); lastResponseID = resourceTrackerService.nodeHeartbeat(request) .getResponseId(); Thread.sleep(1000); } catch(Exception e) { LOG.info("failed to heartbeat ", e); } } }
Example 2
Source File: TestNMExpiry.java From big-c with Apache License 2.0 | 6 votes |
public void run() { int lastResponseID = 0; while (!stopT) { try { org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = recordFactory .newRecordInstance(org.apache.hadoop.yarn.server.api.records.NodeStatus.class); nodeStatus.setNodeId(request3.getNodeId()); nodeStatus.setResponseId(lastResponseID); nodeStatus.setNodeHealthStatus(recordFactory.newRecordInstance(NodeHealthStatus.class)); nodeStatus.getNodeHealthStatus().setIsNodeHealthy(true); NodeHeartbeatRequest request = recordFactory .newRecordInstance(NodeHeartbeatRequest.class); request.setNodeStatus(nodeStatus); lastResponseID = resourceTrackerService.nodeHeartbeat(request) .getResponseId(); Thread.sleep(1000); } catch(Exception e) { LOG.info("failed to heartbeat ", e); } } }
Example 3
Source File: NodeManager.java From hadoop 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 4
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 5
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 6
Source File: MockNM.java From big-c 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 7
Source File: TestRMNMRPCResponseId.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testRPCResponseId() throws IOException, YarnException { String node = "localhost"; Resource capability = BuilderUtils.newResource(1024, 1, 1); RegisterNodeManagerRequest request = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class); nodeId = NodeId.newInstance(node, 1234); request.setNodeId(nodeId); request.setHttpPort(0); request.setResource(capability); RegisterNodeManagerRequest request1 = recordFactory .newRecordInstance(RegisterNodeManagerRequest.class); request1.setNodeId(nodeId); request1.setHttpPort(0); request1.setResource(capability); resourceTrackerService.registerNodeManager(request1); org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = recordFactory. newRecordInstance(org.apache.hadoop.yarn.server.api.records.NodeStatus.class); nodeStatus.setNodeId(nodeId); NodeHealthStatus nodeHealthStatus = recordFactory.newRecordInstance(NodeHealthStatus.class); nodeHealthStatus.setIsNodeHealthy(true); nodeStatus.setNodeHealthStatus(nodeHealthStatus); NodeHeartbeatRequest nodeHeartBeatRequest = recordFactory .newRecordInstance(NodeHeartbeatRequest.class); nodeHeartBeatRequest.setNodeStatus(nodeStatus); nodeStatus.setResponseId(0); NodeHeartbeatResponse response = resourceTrackerService.nodeHeartbeat( nodeHeartBeatRequest); Assert.assertTrue(response.getResponseId() == 1); nodeStatus.setResponseId(response.getResponseId()); response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest); Assert.assertTrue(response.getResponseId() == 2); /* try calling with less response id */ response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest); Assert.assertTrue(response.getResponseId() == 2); nodeStatus.setResponseId(0); response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest); Assert.assertTrue(NodeAction.RESYNC.equals(response.getNodeAction())); Assert.assertEquals("Too far behind rm response id:2 nm response id:0", response.getDiagnosticsMessage()); }
Example 8
Source File: NMSimulator.java From hadoop with Apache License 2.0 | 4 votes |
@Override public void middleStep() throws Exception { // we check the lifetime for each running containers ContainerSimulator cs = null; synchronized(completedContainerList) { while ((cs = containerQueue.poll()) != null) { runningContainers.remove(cs.getId()); completedContainerList.add(cs.getId()); LOG.debug(MessageFormat.format("Container {0} has completed", cs.getId())); } } // send heart beat NodeHeartbeatRequest beatRequest = Records.newRecord(NodeHeartbeatRequest.class); beatRequest.setLastKnownNMTokenMasterKey(masterKey); NodeStatus ns = Records.newRecord(NodeStatus.class); ns.setContainersStatuses(generateContainerStatusList()); ns.setNodeId(node.getNodeID()); ns.setKeepAliveApplications(new ArrayList<ApplicationId>()); ns.setResponseId(RESPONSE_ID ++); ns.setNodeHealthStatus(NodeHealthStatus.newInstance(true, "", 0)); beatRequest.setNodeStatus(ns); NodeHeartbeatResponse beatResponse = rm.getResourceTrackerService().nodeHeartbeat(beatRequest); if (! beatResponse.getContainersToCleanup().isEmpty()) { // remove from queue synchronized(releasedContainerList) { for (ContainerId containerId : beatResponse.getContainersToCleanup()){ if (amContainerList.contains(containerId)) { // AM container (not killed?, only release) synchronized(amContainerList) { amContainerList.remove(containerId); } LOG.debug(MessageFormat.format("NodeManager {0} releases " + "an AM ({1}).", node.getNodeID(), containerId)); } else { cs = runningContainers.remove(containerId); containerQueue.remove(cs); releasedContainerList.add(containerId); LOG.debug(MessageFormat.format("NodeManager {0} releases a " + "container ({1}).", node.getNodeID(), containerId)); } } } } if (beatResponse.getNodeAction() == NodeAction.SHUTDOWN) { lastStep(); } }
Example 9
Source File: TestRMNMRPCResponseId.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testRPCResponseId() throws IOException, YarnException { String node = "localhost"; Resource capability = BuilderUtils.newResource(1024, 1); RegisterNodeManagerRequest request = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class); nodeId = NodeId.newInstance(node, 1234); request.setNodeId(nodeId); request.setHttpPort(0); request.setResource(capability); RegisterNodeManagerRequest request1 = recordFactory .newRecordInstance(RegisterNodeManagerRequest.class); request1.setNodeId(nodeId); request1.setHttpPort(0); request1.setResource(capability); resourceTrackerService.registerNodeManager(request1); org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = recordFactory. newRecordInstance(org.apache.hadoop.yarn.server.api.records.NodeStatus.class); nodeStatus.setNodeId(nodeId); NodeHealthStatus nodeHealthStatus = recordFactory.newRecordInstance(NodeHealthStatus.class); nodeHealthStatus.setIsNodeHealthy(true); nodeStatus.setNodeHealthStatus(nodeHealthStatus); NodeHeartbeatRequest nodeHeartBeatRequest = recordFactory .newRecordInstance(NodeHeartbeatRequest.class); nodeHeartBeatRequest.setNodeStatus(nodeStatus); nodeStatus.setResponseId(0); NodeHeartbeatResponse response = resourceTrackerService.nodeHeartbeat( nodeHeartBeatRequest); Assert.assertTrue(response.getResponseId() == 1); nodeStatus.setResponseId(response.getResponseId()); response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest); Assert.assertTrue(response.getResponseId() == 2); /* try calling with less response id */ response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest); Assert.assertTrue(response.getResponseId() == 2); nodeStatus.setResponseId(0); response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest); Assert.assertTrue(NodeAction.RESYNC.equals(response.getNodeAction())); Assert.assertEquals("Too far behind rm response id:2 nm response id:0", response.getDiagnosticsMessage()); }
Example 10
Source File: NMSimulator.java From big-c with Apache License 2.0 | 4 votes |
@Override public void middleStep() throws Exception { // we check the lifetime for each running containers ContainerSimulator cs = null; synchronized(completedContainerList) { while ((cs = containerQueue.poll()) != null) { runningContainers.remove(cs.getId()); completedContainerList.add(cs.getId()); LOG.debug(MessageFormat.format("Container {0} has completed", cs.getId())); } } // send heart beat NodeHeartbeatRequest beatRequest = Records.newRecord(NodeHeartbeatRequest.class); beatRequest.setLastKnownNMTokenMasterKey(masterKey); NodeStatus ns = Records.newRecord(NodeStatus.class); ns.setContainersStatuses(generateContainerStatusList()); ns.setNodeId(node.getNodeID()); ns.setKeepAliveApplications(new ArrayList<ApplicationId>()); ns.setResponseId(RESPONSE_ID ++); ns.setNodeHealthStatus(NodeHealthStatus.newInstance(true, "", 0)); beatRequest.setNodeStatus(ns); NodeHeartbeatResponse beatResponse = rm.getResourceTrackerService().nodeHeartbeat(beatRequest); if (! beatResponse.getContainersToCleanup().isEmpty()) { // remove from queue synchronized(releasedContainerList) { for (ContainerId containerId : beatResponse.getContainersToCleanup()){ if (amContainerList.contains(containerId)) { // AM container (not killed?, only release) synchronized(amContainerList) { amContainerList.remove(containerId); } LOG.debug(MessageFormat.format("NodeManager {0} releases " + "an AM ({1}).", node.getNodeID(), containerId)); } else { cs = runningContainers.remove(containerId); containerQueue.remove(cs); releasedContainerList.add(containerId); LOG.debug(MessageFormat.format("NodeManager {0} releases a " + "container ({1}).", node.getNodeID(), containerId)); } } } } if (beatResponse.getNodeAction() == NodeAction.SHUTDOWN) { lastStep(); } }