Search in sources :

Example 1 with StorageContainerDatanodeProtocolClientSideTranslatorPB

use of org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB in project ozone by apache.

the class SCMConnectionManager method addReconServer.

/**
 * Adds a new Recon server to the set of endpoints.
 * @param address Recon address.
 * @throws IOException
 */
public void addReconServer(InetSocketAddress address) throws IOException {
    LOG.info("Adding Recon Server : {}", address.toString());
    writeLock();
    try {
        if (scmMachines.containsKey(address)) {
            LOG.warn("Trying to add an existing SCM Machine to Machines group. " + "Ignoring the request.");
            return;
        }
        Configuration hadoopConfig = LegacyHadoopConfigurationSource.asHadoopConfiguration(this.conf);
        RPC.setProtocolEngine(hadoopConfig, ReconDatanodeProtocolPB.class, ProtobufRpcEngine.class);
        long version = RPC.getProtocolVersion(ReconDatanodeProtocolPB.class);
        RetryPolicy retryPolicy = RetryPolicies.retryUpToMaximumCountWithFixedSleep(getScmRpcRetryCount(conf), getScmRpcRetryInterval(conf), TimeUnit.MILLISECONDS);
        ReconDatanodeProtocolPB rpcProxy = RPC.getProtocolProxy(ReconDatanodeProtocolPB.class, version, address, UserGroupInformation.getCurrentUser(), hadoopConfig, NetUtils.getDefaultSocketFactory(hadoopConfig), getRpcTimeout(), retryPolicy).getProxy();
        StorageContainerDatanodeProtocolClientSideTranslatorPB rpcClient = new StorageContainerDatanodeProtocolClientSideTranslatorPB(rpcProxy);
        EndpointStateMachine endPoint = new EndpointStateMachine(address, rpcClient, conf);
        endPoint.setPassive(true);
        scmMachines.put(address, endPoint);
    } finally {
        writeUnlock();
    }
}
Also used : StorageContainerDatanodeProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB) ReconDatanodeProtocolPB(org.apache.hadoop.ozone.protocolPB.ReconDatanodeProtocolPB) Configuration(org.apache.hadoop.conf.Configuration) RetryPolicy(org.apache.hadoop.io.retry.RetryPolicy)

Example 2 with StorageContainerDatanodeProtocolClientSideTranslatorPB

use of org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB in project ozone by apache.

the class TestHeartbeatEndpointTask method testheartbeatWithoutReports.

@Test
public void testheartbeatWithoutReports() throws Exception {
    StorageContainerDatanodeProtocolClientSideTranslatorPB scm = Mockito.mock(StorageContainerDatanodeProtocolClientSideTranslatorPB.class);
    ArgumentCaptor<SCMHeartbeatRequestProto> argument = ArgumentCaptor.forClass(SCMHeartbeatRequestProto.class);
    Mockito.when(scm.sendHeartbeat(argument.capture())).thenAnswer(invocation -> SCMHeartbeatResponseProto.newBuilder().setDatanodeUUID(((SCMHeartbeatRequestProto) invocation.getArgument(0)).getDatanodeDetails().getUuid()).build());
    HeartbeatEndpointTask endpointTask = getHeartbeatEndpointTask(scm);
    endpointTask.call();
    SCMHeartbeatRequestProto heartbeat = argument.getValue();
    Assert.assertTrue(heartbeat.hasDatanodeDetails());
    Assert.assertFalse(heartbeat.hasNodeReport());
    Assert.assertFalse(heartbeat.hasContainerReport());
    Assert.assertTrue(heartbeat.getCommandStatusReportsCount() == 0);
    Assert.assertFalse(heartbeat.hasContainerActions());
}
Also used : SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) StorageContainerDatanodeProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB) Test(org.junit.Test)

Example 3 with StorageContainerDatanodeProtocolClientSideTranslatorPB

use of org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB in project ozone by apache.

the class TestHeartbeatEndpointTask method testheartbeatWithContainerActions.

@Test
public void testheartbeatWithContainerActions() throws Exception {
    OzoneConfiguration conf = new OzoneConfiguration();
    StateContext context = new StateContext(conf, DatanodeStates.RUNNING, Mockito.mock(DatanodeStateMachine.class));
    StorageContainerDatanodeProtocolClientSideTranslatorPB scm = Mockito.mock(StorageContainerDatanodeProtocolClientSideTranslatorPB.class);
    ArgumentCaptor<SCMHeartbeatRequestProto> argument = ArgumentCaptor.forClass(SCMHeartbeatRequestProto.class);
    Mockito.when(scm.sendHeartbeat(argument.capture())).thenAnswer(invocation -> SCMHeartbeatResponseProto.newBuilder().setDatanodeUUID(((SCMHeartbeatRequestProto) invocation.getArgument(0)).getDatanodeDetails().getUuid()).build());
    HeartbeatEndpointTask endpointTask = getHeartbeatEndpointTask(conf, context, scm);
    context.addEndpoint(TEST_SCM_ENDPOINT);
    context.addContainerAction(getContainerAction());
    endpointTask.call();
    SCMHeartbeatRequestProto heartbeat = argument.getValue();
    Assert.assertTrue(heartbeat.hasDatanodeDetails());
    Assert.assertFalse(heartbeat.hasNodeReport());
    Assert.assertFalse(heartbeat.hasContainerReport());
    Assert.assertTrue(heartbeat.getCommandStatusReportsCount() == 0);
    Assert.assertTrue(heartbeat.hasContainerActions());
}
Also used : SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) StorageContainerDatanodeProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB) StateContext(org.apache.hadoop.ozone.container.common.statemachine.StateContext) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine) Test(org.junit.Test)

Example 4 with StorageContainerDatanodeProtocolClientSideTranslatorPB

use of org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB in project ozone by apache.

the class TestHeartbeatEndpointTask method testheartbeatWithCommandStatusReports.

@Test
public void testheartbeatWithCommandStatusReports() throws Exception {
    OzoneConfiguration conf = new OzoneConfiguration();
    StateContext context = new StateContext(conf, DatanodeStates.RUNNING, Mockito.mock(DatanodeStateMachine.class));
    StorageContainerDatanodeProtocolClientSideTranslatorPB scm = Mockito.mock(StorageContainerDatanodeProtocolClientSideTranslatorPB.class);
    ArgumentCaptor<SCMHeartbeatRequestProto> argument = ArgumentCaptor.forClass(SCMHeartbeatRequestProto.class);
    Mockito.when(scm.sendHeartbeat(argument.capture())).thenAnswer(invocation -> SCMHeartbeatResponseProto.newBuilder().setDatanodeUUID(((SCMHeartbeatRequestProto) invocation.getArgument(0)).getDatanodeDetails().getUuid()).build());
    HeartbeatEndpointTask endpointTask = getHeartbeatEndpointTask(conf, context, scm);
    context.addEndpoint(TEST_SCM_ENDPOINT);
    context.addIncrementalReport(CommandStatusReportsProto.getDefaultInstance());
    endpointTask.call();
    SCMHeartbeatRequestProto heartbeat = argument.getValue();
    Assert.assertTrue(heartbeat.hasDatanodeDetails());
    Assert.assertFalse(heartbeat.hasNodeReport());
    Assert.assertFalse(heartbeat.hasContainerReport());
    Assert.assertTrue(heartbeat.getCommandStatusReportsCount() != 0);
    Assert.assertFalse(heartbeat.hasContainerActions());
}
Also used : SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) StorageContainerDatanodeProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB) StateContext(org.apache.hadoop.ozone.container.common.statemachine.StateContext) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine) Test(org.junit.Test)

Example 5 with StorageContainerDatanodeProtocolClientSideTranslatorPB

use of org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB in project ozone by apache.

the class TestHeartbeatEndpointTask method testheartbeatWithNodeReports.

@Test
public void testheartbeatWithNodeReports() throws Exception {
    OzoneConfiguration conf = new OzoneConfiguration();
    StateContext context = new StateContext(conf, DatanodeStates.RUNNING, Mockito.mock(DatanodeStateMachine.class));
    StorageContainerDatanodeProtocolClientSideTranslatorPB scm = Mockito.mock(StorageContainerDatanodeProtocolClientSideTranslatorPB.class);
    ArgumentCaptor<SCMHeartbeatRequestProto> argument = ArgumentCaptor.forClass(SCMHeartbeatRequestProto.class);
    Mockito.when(scm.sendHeartbeat(argument.capture())).thenAnswer(invocation -> SCMHeartbeatResponseProto.newBuilder().setDatanodeUUID(((SCMHeartbeatRequestProto) invocation.getArgument(0)).getDatanodeDetails().getUuid()).build());
    HeartbeatEndpointTask endpointTask = getHeartbeatEndpointTask(conf, context, scm);
    context.addEndpoint(TEST_SCM_ENDPOINT);
    context.refreshFullReport(NodeReportProto.getDefaultInstance());
    endpointTask.call();
    SCMHeartbeatRequestProto heartbeat = argument.getValue();
    Assert.assertTrue(heartbeat.hasDatanodeDetails());
    Assert.assertTrue(heartbeat.hasNodeReport());
    Assert.assertFalse(heartbeat.hasContainerReport());
    Assert.assertTrue(heartbeat.getCommandStatusReportsCount() == 0);
    Assert.assertFalse(heartbeat.hasContainerActions());
}
Also used : SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) StorageContainerDatanodeProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB) StateContext(org.apache.hadoop.ozone.container.common.statemachine.StateContext) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine) Test(org.junit.Test)

Aggregations

StorageContainerDatanodeProtocolClientSideTranslatorPB (org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB)10 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)6 SCMHeartbeatRequestProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto)6 Test (org.junit.Test)6 DatanodeStateMachine (org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine)5 StateContext (org.apache.hadoop.ozone.container.common.statemachine.StateContext)5 Configuration (org.apache.hadoop.conf.Configuration)3 RetryPolicy (org.apache.hadoop.io.retry.RetryPolicy)3 StorageContainerDatanodeProtocolPB (org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolPB)3 InetSocketAddress (java.net.InetSocketAddress)1 SCMClientConfig (org.apache.hadoop.hdds.scm.proxy.SCMClientConfig)1 LegacyHadoopConfigurationSource (org.apache.hadoop.hdds.utils.LegacyHadoopConfigurationSource)1 EndpointStateMachine (org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine)1 ReconDatanodeProtocolPB (org.apache.hadoop.ozone.protocolPB.ReconDatanodeProtocolPB)1