Search in sources :

Example 1 with ReplicationConfig

use of org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig in project ozone by apache.

the class TestReplicationConfig method isCreatedWitDefaultValues.

@Test
public void isCreatedWitDefaultValues() {
    // GIVEN
    OzoneConfiguration conf = new OzoneConfiguration();
    // WHEN
    ReplicationConfig subject = conf.getObject(ReplicationConfig.class);
    // THEN
    assertEquals(REPLICATION_MAX_STREAMS_DEFAULT, subject.getReplicationMaxStreams());
}
Also used : ReplicationConfig(org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Test(org.junit.Test)

Example 2 with ReplicationConfig

use of org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig in project ozone by apache.

the class TestReplicationConfig method acceptsValidValues.

@Test
public void acceptsValidValues() {
    // GIVEN
    int validReplicationLimit = 123;
    OzoneConfiguration conf = new OzoneConfiguration();
    conf.setInt(REPLICATION_STREAMS_LIMIT_KEY, validReplicationLimit);
    // WHEN
    ReplicationConfig subject = conf.getObject(ReplicationConfig.class);
    // THEN
    assertEquals(validReplicationLimit, subject.getReplicationMaxStreams());
}
Also used : ReplicationConfig(org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Test(org.junit.Test)

Example 3 with ReplicationConfig

use of org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig in project ozone by apache.

the class TestEndPoint method testCheckVersionResponse.

@Test
public void testCheckVersionResponse() throws Exception {
    OzoneConfiguration conf = SCMTestUtils.getConf();
    conf.setBoolean(OzoneConfigKeys.DFS_CONTAINER_IPC_RANDOM_PORT, true);
    conf.setBoolean(OzoneConfigKeys.DFS_CONTAINER_RATIS_IPC_RANDOM_PORT, true);
    conf.setFromObject(new ReplicationConfig().setPort(0));
    try (EndpointStateMachine rpcEndPoint = createEndpoint(conf, serverAddress, 1000)) {
        GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.captureLogs(VersionEndpointTask.LOG);
        DatanodeDetails datanodeDetails = randomDatanodeDetails();
        OzoneContainer ozoneContainer = new OzoneContainer(datanodeDetails, conf, getContext(datanodeDetails), null);
        rpcEndPoint.setState(EndpointStateMachine.EndPointStates.GETVERSION);
        VersionEndpointTask versionTask = new VersionEndpointTask(rpcEndPoint, conf, ozoneContainer);
        EndpointStateMachine.EndPointStates newState = versionTask.call();
        // if version call worked the endpoint should automatically move to the
        // next state.
        Assert.assertEquals(EndpointStateMachine.EndPointStates.REGISTER, newState);
        // Now rpcEndpoint should remember the version it got from SCM
        Assert.assertNotNull(rpcEndPoint.getVersion());
        // Now change server cluster ID, so datanode cluster ID will be
        // different from SCM server response cluster ID.
        String newClusterId = UUID.randomUUID().toString();
        scmServerImpl.setClusterId(newClusterId);
        rpcEndPoint.setState(EndpointStateMachine.EndPointStates.GETVERSION);
        newState = versionTask.call();
        Assert.assertEquals(EndpointStateMachine.EndPointStates.SHUTDOWN, newState);
        List<HddsVolume> volumesList = StorageVolumeUtil.getHddsVolumesList(ozoneContainer.getVolumeSet().getFailedVolumesList());
        Assert.assertTrue(volumesList.size() == 1);
        Assert.assertTrue(logCapturer.getOutput().contains("org.apache.hadoop.ozone.common" + ".InconsistentStorageStateException: Mismatched ClusterIDs"));
        Assert.assertTrue(ozoneContainer.getVolumeSet().getVolumesList().size() == 0);
        Assert.assertTrue(ozoneContainer.getVolumeSet().getFailedVolumesList().size() == 1);
    }
}
Also used : EndpointStateMachine(org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine) HddsVolume(org.apache.hadoop.ozone.container.common.volume.HddsVolume) VersionEndpointTask(org.apache.hadoop.ozone.container.common.states.endpoint.VersionEndpointTask) ReplicationConfig(org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig) MockDatanodeDetails.randomDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) GenericTestUtils(org.apache.ozone.test.GenericTestUtils) OzoneContainer(org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer) Test(org.junit.Test)

Example 4 with ReplicationConfig

use of org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig in project ozone by apache.

the class TestEndPoint method testGetVersionTask.

@Test
public /**
 * We make getVersion RPC call, but via the VersionEndpointTask which is
 * how the state machine would make the call.
 */
void testGetVersionTask() throws Exception {
    OzoneConfiguration conf = SCMTestUtils.getConf();
    conf.setFromObject(new ReplicationConfig().setPort(0));
    try (EndpointStateMachine rpcEndPoint = createEndpoint(conf, serverAddress, 1000)) {
        DatanodeDetails datanodeDetails = randomDatanodeDetails();
        OzoneContainer ozoneContainer = new OzoneContainer(datanodeDetails, conf, getContext(datanodeDetails), null);
        rpcEndPoint.setState(EndpointStateMachine.EndPointStates.GETVERSION);
        VersionEndpointTask versionTask = new VersionEndpointTask(rpcEndPoint, conf, ozoneContainer);
        EndpointStateMachine.EndPointStates newState = versionTask.call();
        // if version call worked the endpoint should automatically move to the
        // next state.
        Assert.assertEquals(EndpointStateMachine.EndPointStates.REGISTER, newState);
        // Now rpcEndpoint should remember the version it got from SCM
        Assert.assertNotNull(rpcEndPoint.getVersion());
    }
}
Also used : EndpointStateMachine(org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine) VersionEndpointTask(org.apache.hadoop.ozone.container.common.states.endpoint.VersionEndpointTask) ReplicationConfig(org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig) MockDatanodeDetails.randomDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) OzoneContainer(org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer) Test(org.junit.Test)

Example 5 with ReplicationConfig

use of org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig in project ozone by apache.

the class TestReplicationConfig method overridesInvalidValues.

@Test
public void overridesInvalidValues() {
    // GIVEN
    int invalidReplicationLimit = -5;
    OzoneConfiguration conf = new OzoneConfiguration();
    conf.setInt(REPLICATION_STREAMS_LIMIT_KEY, invalidReplicationLimit);
    // WHEN
    ReplicationConfig subject = conf.getObject(ReplicationConfig.class);
    // THEN
    assertEquals(REPLICATION_MAX_STREAMS_DEFAULT, subject.getReplicationMaxStreams());
}
Also used : ReplicationConfig(org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Test(org.junit.Test)

Aggregations

OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)5 ReplicationConfig (org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig)5 Test (org.junit.Test)5 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)2 MockDatanodeDetails.randomDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails)2 EndpointStateMachine (org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine)2 VersionEndpointTask (org.apache.hadoop.ozone.container.common.states.endpoint.VersionEndpointTask)2 OzoneContainer (org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer)2 HddsVolume (org.apache.hadoop.ozone.container.common.volume.HddsVolume)1 GenericTestUtils (org.apache.ozone.test.GenericTestUtils)1