Search in sources :

Example 1 with NodeHeartbeatResponsePBImpl

use of org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatResponsePBImpl in project hadoop by apache.

the class TestProtocolRecords method testNodeHeartBeatResponse.

@Test
public void testNodeHeartBeatResponse() throws IOException {
    NodeHeartbeatResponse record = Records.newRecord(NodeHeartbeatResponse.class);
    Map<ApplicationId, ByteBuffer> appCredentials = new HashMap<ApplicationId, ByteBuffer>();
    Credentials app1Cred = new Credentials();
    Token<DelegationTokenIdentifier> token1 = new Token<DelegationTokenIdentifier>();
    token1.setKind(new Text("kind1"));
    app1Cred.addToken(new Text("token1"), token1);
    Token<DelegationTokenIdentifier> token2 = new Token<DelegationTokenIdentifier>();
    token2.setKind(new Text("kind2"));
    app1Cred.addToken(new Text("token2"), token2);
    DataOutputBuffer dob = new DataOutputBuffer();
    app1Cred.writeTokenStorageToStream(dob);
    ByteBuffer byteBuffer1 = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
    appCredentials.put(ApplicationId.newInstance(1234, 1), byteBuffer1);
    record.setSystemCredentialsForApps(appCredentials);
    NodeHeartbeatResponse proto = new NodeHeartbeatResponsePBImpl(((NodeHeartbeatResponsePBImpl) record).getProto());
    Assert.assertEquals(appCredentials, proto.getSystemCredentialsForApps());
}
Also used : HashMap(java.util.HashMap) DelegationTokenIdentifier(org.apache.hadoop.security.token.delegation.web.DelegationTokenIdentifier) DataOutputBuffer(org.apache.hadoop.io.DataOutputBuffer) NodeHeartbeatResponsePBImpl(org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatResponsePBImpl) Token(org.apache.hadoop.security.token.Token) Text(org.apache.hadoop.io.Text) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) ByteBuffer(java.nio.ByteBuffer) Credentials(org.apache.hadoop.security.Credentials) Test(org.junit.Test)

Example 2 with NodeHeartbeatResponsePBImpl

use of org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatResponsePBImpl in project hadoop by apache.

the class TestYarnServerApiClasses method testNodeHeartbeatResponsePBImplWithDecreasedContainers.

@Test
public void testNodeHeartbeatResponsePBImplWithDecreasedContainers() {
    NodeHeartbeatResponsePBImpl original = new NodeHeartbeatResponsePBImpl();
    original.addAllContainersToDecrease(Arrays.asList(getDecreasedContainer(1, 2, 2048, 2), getDecreasedContainer(2, 3, 1024, 1)));
    NodeHeartbeatResponsePBImpl copy = new NodeHeartbeatResponsePBImpl(original.getProto());
    assertEquals(1, copy.getContainersToDecrease().get(0).getId().getContainerId());
    assertEquals(1024, copy.getContainersToDecrease().get(1).getResource().getMemorySize());
}
Also used : NodeHeartbeatResponsePBImpl(org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatResponsePBImpl) Test(org.junit.Test)

Example 3 with NodeHeartbeatResponsePBImpl

use of org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatResponsePBImpl in project hadoop by apache.

the class TestYarnServerApiClasses method testNodeHeartbeatResponsePBImpl.

/**
   * Test NodeHeartbeatResponsePBImpl.
   */
@Test
public void testNodeHeartbeatResponsePBImpl() {
    NodeHeartbeatResponsePBImpl original = new NodeHeartbeatResponsePBImpl();
    original.setDiagnosticsMessage("testDiagnosticMessage");
    original.setContainerTokenMasterKey(getMasterKey());
    original.setNMTokenMasterKey(getMasterKey());
    original.setNextHeartBeatInterval(1000);
    original.setNodeAction(NodeAction.NORMAL);
    original.setResponseId(100);
    Map<ApplicationId, String> collectors = getCollectors();
    original.setAppCollectorsMap(collectors);
    NodeHeartbeatResponsePBImpl copy = new NodeHeartbeatResponsePBImpl(original.getProto());
    assertEquals(100, copy.getResponseId());
    assertEquals(NodeAction.NORMAL, copy.getNodeAction());
    assertEquals(1000, copy.getNextHeartBeatInterval());
    assertEquals(1, copy.getContainerTokenMasterKey().getKeyId());
    assertEquals(1, copy.getNMTokenMasterKey().getKeyId());
    assertEquals("testDiagnosticMessage", copy.getDiagnosticsMessage());
    assertEquals(collectors, copy.getAppCollectorsMap());
    assertEquals(false, copy.getAreNodeLabelsAcceptedByRM());
}
Also used : NodeHeartbeatResponsePBImpl(org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatResponsePBImpl) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Example 4 with NodeHeartbeatResponsePBImpl

use of org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatResponsePBImpl in project hadoop by apache.

the class TestYarnServerApiClasses method testNodeHeartbeatResponsePBImplWithRMAcceptLbls.

@Test
public void testNodeHeartbeatResponsePBImplWithRMAcceptLbls() {
    NodeHeartbeatResponsePBImpl original = new NodeHeartbeatResponsePBImpl();
    original.setAreNodeLabelsAcceptedByRM(true);
    NodeHeartbeatResponsePBImpl copy = new NodeHeartbeatResponsePBImpl(original.getProto());
    assertTrue(copy.getAreNodeLabelsAcceptedByRM());
}
Also used : NodeHeartbeatResponsePBImpl(org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatResponsePBImpl) Test(org.junit.Test)

Aggregations

NodeHeartbeatResponsePBImpl (org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatResponsePBImpl)4 Test (org.junit.Test)4 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 DataOutputBuffer (org.apache.hadoop.io.DataOutputBuffer)1 Text (org.apache.hadoop.io.Text)1 Credentials (org.apache.hadoop.security.Credentials)1 Token (org.apache.hadoop.security.token.Token)1 DelegationTokenIdentifier (org.apache.hadoop.security.token.delegation.web.DelegationTokenIdentifier)1