org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest Java Examples
The following examples show how to use
org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest.
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: 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 #2
Source File: TestResourceTrackerOnHA.java From hadoop with Apache License 2.0 | 6 votes |
@Test(timeout = 15000) public void testResourceTrackerOnHA() throws Exception { NodeId nodeId = NodeId.newInstance("localhost", 0); Resource resource = Resource.newInstance(2048, 4, 4); // make sure registerNodeManager works when failover happens RegisterNodeManagerRequest request = RegisterNodeManagerRequest.newInstance(nodeId, 0, resource, YarnVersionInfo.getVersion(), null, null); resourceTracker.registerNodeManager(request); Assert.assertTrue(waitForNodeManagerToConnect(10000, nodeId)); // restart the failover thread, and make sure nodeHeartbeat works failoverThread = createAndStartFailoverThread(); NodeStatus status = NodeStatus.newInstance(NodeId.newInstance("localhost", 0), 0, null, null, null); NodeHeartbeatRequest request2 = NodeHeartbeatRequest.newInstance(status, null, null); resourceTracker.nodeHeartbeat(request2); }
Example #3
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 #4
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 #5
Source File: TestResourceTrackerOnHA.java From big-c with Apache License 2.0 | 6 votes |
@Test(timeout = 15000) public void testResourceTrackerOnHA() throws Exception { NodeId nodeId = NodeId.newInstance("localhost", 0); Resource resource = Resource.newInstance(2048, 4); // make sure registerNodeManager works when failover happens RegisterNodeManagerRequest request = RegisterNodeManagerRequest.newInstance(nodeId, 0, resource, YarnVersionInfo.getVersion(), null, null); resourceTracker.registerNodeManager(request); Assert.assertTrue(waitForNodeManagerToConnect(10000, nodeId)); // restart the failover thread, and make sure nodeHeartbeat works failoverThread = createAndStartFailoverThread(); NodeStatus status = NodeStatus.newInstance(NodeId.newInstance("localhost", 0), 0, null, null, null); NodeHeartbeatRequest request2 = NodeHeartbeatRequest.newInstance(status, null, null); resourceTracker.nodeHeartbeat(request2); }
Example #6
Source File: TestResourceTrackerPBClientImpl.java From big-c with Apache License 2.0 | 6 votes |
/** * Test the method nodeHeartbeat. Method should return a not null result. * */ @Test public void testNodeHeartbeat() throws Exception { NodeHeartbeatRequest request = recordFactory .newRecordInstance(NodeHeartbeatRequest.class); assertNotNull(client.nodeHeartbeat(request)); ResourceTrackerTestImpl.exception = true; try { client.nodeHeartbeat(request); fail("there should be YarnException"); } catch (YarnException e) { assertTrue(e.getMessage().startsWith("testMessage")); }finally{ ResourceTrackerTestImpl.exception = false; } }
Example #7
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 #8
Source File: TestResourceTrackerPBClientImpl.java From hadoop with Apache License 2.0 | 6 votes |
/** * Test the method nodeHeartbeat. Method should return a not null result. * */ @Test public void testNodeHeartbeat() throws Exception { NodeHeartbeatRequest request = recordFactory .newRecordInstance(NodeHeartbeatRequest.class); assertNotNull(client.nodeHeartbeat(request)); ResourceTrackerTestImpl.exception = true; try { client.nodeHeartbeat(request); fail("there should be YarnException"); } catch (YarnException e) { assertTrue(e.getMessage().startsWith("testMessage")); }finally{ ResourceTrackerTestImpl.exception = false; } }
Example #9
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, heartBeatNodeAction, null, null, null, null, null, 1000L); nhResponse.setDiagnosticsMessage(shutDownMessage); return nhResponse; }
Example #10
Source File: TestNodeStatusUpdater.java From big-c 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, 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 #11
Source File: TestResourceTrackerPBClientImpl.java From big-c 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 #12
Source File: TestNodeStatusUpdater.java From big-c with Apache License 2.0 | 5 votes |
@Override public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) throws YarnException, IOException { heartBeatID++; if(heartBeatID == 1) { // EOFException should be retried as well. throw new EOFException("NodeHeartbeat exception"); } else { throw new java.net.ConnectException( "NodeHeartbeat exception"); } }
Example #13
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; }
Example #14
Source File: TestYSCRecordFactory.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testPbRecordFactory() { RecordFactory pbRecordFactory = RecordFactoryPBImpl.get(); try { NodeHeartbeatRequest request = pbRecordFactory.newRecordInstance(NodeHeartbeatRequest.class); Assert.assertEquals(NodeHeartbeatRequestPBImpl.class, request.getClass()); } catch (YarnRuntimeException e) { e.printStackTrace(); Assert.fail("Failed to crete record"); } }
Example #15
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 #16
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 #17
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 #18
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 #19
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 #20
Source File: ProtocolHATestBase.java From hadoop with Apache License 2.0 | 5 votes |
@Override public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) throws YarnException, IOException { resetStartFailoverFlag(true); // make sure failover has been triggered Assert.assertTrue(waittingForFailOver()); return super.nodeHeartbeat(request); }
Example #21
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 #22
Source File: ProtocolHATestBase.java From big-c with Apache License 2.0 | 5 votes |
@Override public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) throws YarnException, IOException { resetStartFailoverFlag(true); // make sure failover has been triggered Assert.assertTrue(waittingForFailOver()); return super.nodeHeartbeat(request); }
Example #23
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 #24
Source File: TestNodeStatusUpdater.java From hadoop 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, 1000L); return nhResponse; }
Example #25
Source File: TestNodeStatusUpdater.java From hadoop with Apache License 2.0 | 5 votes |
@Override public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) throws YarnException, IOException { heartBeatID++; if(heartBeatID == 1) { // EOFException should be retried as well. throw new EOFException("NodeHeartbeat exception"); } else { throw new java.net.ConnectException( "NodeHeartbeat exception"); } }
Example #26
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 #27
Source File: TestNodeStatusUpdater.java From hadoop 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, heartBeatNodeAction, null, null, null, null, 1000L); nhResponse.setDiagnosticsMessage(shutDownMessage); return nhResponse; }
Example #28
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 #29
Source File: TestYSCRecordFactory.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testPbRecordFactory() { RecordFactory pbRecordFactory = RecordFactoryPBImpl.get(); try { NodeHeartbeatRequest request = pbRecordFactory.newRecordInstance(NodeHeartbeatRequest.class); Assert.assertEquals(NodeHeartbeatRequestPBImpl.class, request.getClass()); } catch (YarnRuntimeException e) { e.printStackTrace(); Assert.fail("Failed to crete record"); } }
Example #30
Source File: ResourceTrackerPBClientImpl.java From hadoop 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; } }