Search in sources :

Example 6 with SCMClientConfig

use of org.apache.hadoop.hdds.scm.proxy.SCMClientConfig in project ozone by apache.

the class TestFailoverWithSCMHA method testMoveFailover.

@Test
public void testMoveFailover() throws Exception {
    SCMClientConfig scmClientConfig = conf.getObject(SCMClientConfig.class);
    scmClientConfig.setRetryCount(1);
    scmClientConfig.setRetryInterval(100);
    scmClientConfig.setMaxRetryTimeout(1500);
    Assert.assertEquals(scmClientConfig.getRetryCount(), 15);
    conf.setFromObject(scmClientConfig);
    StorageContainerManager scm = getLeader(cluster);
    Assert.assertNotNull(scm);
    final ContainerID id = getContainer(HddsProtos.LifeCycleState.CLOSED).containerID();
    DatanodeDetails dn1 = randomDatanodeDetails();
    DatanodeDetails dn2 = randomDatanodeDetails();
    // here we just want to test whether the new leader will get the same
    // inflight move after failover, so no need to create container and datanode,
    // just mock them bypassing all the pre checks.
    scm.getReplicationManager().getMoveScheduler().startMove(id.getProtobuf(), (new MoveDataNodePair(dn1, dn2)).getProtobufMessage(ClientVersion.CURRENT_VERSION));
    SCMBlockLocationFailoverProxyProvider failoverProxyProvider = new SCMBlockLocationFailoverProxyProvider(conf);
    failoverProxyProvider.changeCurrentProxy(scm.getSCMNodeId());
    ScmBlockLocationProtocolClientSideTranslatorPB scmBlockLocationClient = new ScmBlockLocationProtocolClientSideTranslatorPB(failoverProxyProvider);
    GenericTestUtils.setLogLevel(SCMBlockLocationFailoverProxyProvider.LOG, Level.DEBUG);
    GenericTestUtils.LogCapturer logCapture = GenericTestUtils.LogCapturer.captureLogs(SCMBlockLocationFailoverProxyProvider.LOG);
    ScmBlockLocationProtocol scmBlockLocationProtocol = TracingUtil.createProxy(scmBlockLocationClient, ScmBlockLocationProtocol.class, conf);
    scmBlockLocationProtocol.getScmInfo();
    Assert.assertTrue(logCapture.getOutput().contains("Performing failover to suggested leader"));
    scm = getLeader(cluster);
    Assert.assertNotNull(scm);
    // switch to the new leader successfully, new leader should
    // get the same inflightMove
    Map<ContainerID, MoveDataNodePair> inflightMove = scm.getReplicationManager().getMoveScheduler().getInflightMove();
    Assert.assertTrue(inflightMove.containsKey(id));
    MoveDataNodePair mp = inflightMove.get(id);
    Assert.assertTrue(dn2.equals(mp.getTgt()));
    Assert.assertTrue(dn1.equals(mp.getSrc()));
    // complete move in the new leader
    scm.getReplicationManager().getMoveScheduler().completeMove(id.getProtobuf());
    SCMContainerLocationFailoverProxyProvider proxyProvider = new SCMContainerLocationFailoverProxyProvider(conf, null);
    GenericTestUtils.setLogLevel(SCMContainerLocationFailoverProxyProvider.LOG, Level.DEBUG);
    logCapture = GenericTestUtils.LogCapturer.captureLogs(SCMContainerLocationFailoverProxyProvider.LOG);
    proxyProvider.changeCurrentProxy(scm.getSCMNodeId());
    StorageContainerLocationProtocol scmContainerClient = TracingUtil.createProxy(new StorageContainerLocationProtocolClientSideTranslatorPB(proxyProvider), StorageContainerLocationProtocol.class, conf);
    scmContainerClient.allocateContainer(HddsProtos.ReplicationType.RATIS, HddsProtos.ReplicationFactor.ONE, "ozone");
    Assert.assertTrue(logCapture.getOutput().contains("Performing failover to suggested leader"));
    // switch to the new leader successfully, new leader should
    // get the same inflightMove , which should not contains
    // that container.
    scm = getLeader(cluster);
    Assert.assertNotNull(scm);
    inflightMove = scm.getReplicationManager().getMoveScheduler().getInflightMove();
    Assert.assertFalse(inflightMove.containsKey(id));
}
Also used : SCMBlockLocationFailoverProxyProvider(org.apache.hadoop.hdds.scm.proxy.SCMBlockLocationFailoverProxyProvider) StorageContainerManager(org.apache.hadoop.hdds.scm.server.StorageContainerManager) SCMClientConfig(org.apache.hadoop.hdds.scm.proxy.SCMClientConfig) GenericTestUtils(org.apache.ozone.test.GenericTestUtils) SCMContainerLocationFailoverProxyProvider(org.apache.hadoop.hdds.scm.proxy.SCMContainerLocationFailoverProxyProvider) ScmBlockLocationProtocolClientSideTranslatorPB(org.apache.hadoop.hdds.scm.protocolPB.ScmBlockLocationProtocolClientSideTranslatorPB) ScmBlockLocationProtocol(org.apache.hadoop.hdds.scm.protocol.ScmBlockLocationProtocol) MoveDataNodePair(org.apache.hadoop.hdds.scm.container.common.helpers.MoveDataNodePair) ContainerID(org.apache.hadoop.hdds.scm.container.ContainerID) MockDatanodeDetails.randomDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) StorageContainerLocationProtocol(org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol) StorageContainerLocationProtocolClientSideTranslatorPB(org.apache.hadoop.hdds.scm.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB) Test(org.junit.jupiter.api.Test)

Example 7 with SCMClientConfig

use of org.apache.hadoop.hdds.scm.proxy.SCMClientConfig in project ozone by apache.

the class HAUtils method getScmInfo.

public static ScmInfo getScmInfo(OzoneConfiguration conf) throws IOException {
    OzoneConfiguration configuration = new OzoneConfiguration(conf);
    try {
        long duration = conf.getTimeDuration(OZONE_SCM_INFO_WAIT_DURATION, OZONE_SCM_INFO_WAIT_DURATION_DEFAULT, TimeUnit.SECONDS);
        SCMClientConfig scmClientConfig = configuration.getObject(SCMClientConfig.class);
        int retryCount = (int) (duration / (scmClientConfig.getRetryInterval() / 1000));
        // retry count.
        if (retryCount > scmClientConfig.getRetryCount()) {
            scmClientConfig.setRetryCount(retryCount);
            configuration.setFromObject(scmClientConfig);
        }
        return getScmBlockClient(configuration).getScmInfo();
    } catch (IOException e) {
        throw e;
    } catch (Exception e) {
        throw new IOException("Failed to get SCM info", e);
    }
}
Also used : SCMClientConfig(org.apache.hadoop.hdds.scm.proxy.SCMClientConfig) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) IOException(java.io.IOException) SupplierWithIOException(org.apache.hadoop.hdds.function.SupplierWithIOException) SCMSecurityException(org.apache.hadoop.hdds.security.exception.SCMSecurityException) IOException(java.io.IOException) SupplierWithIOException(org.apache.hadoop.hdds.function.SupplierWithIOException)

Aggregations

SCMClientConfig (org.apache.hadoop.hdds.scm.proxy.SCMClientConfig)7 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)4 StorageContainerManager (org.apache.hadoop.hdds.scm.server.StorageContainerManager)3 Test (org.junit.jupiter.api.Test)3 SCMSecurityProtocolClientSideTranslatorPB (org.apache.hadoop.hdds.protocolPB.SCMSecurityProtocolClientSideTranslatorPB)2 ScmBlockLocationProtocol (org.apache.hadoop.hdds.scm.protocol.ScmBlockLocationProtocol)2 StorageContainerLocationProtocol (org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol)2 ScmBlockLocationProtocolClientSideTranslatorPB (org.apache.hadoop.hdds.scm.protocolPB.ScmBlockLocationProtocolClientSideTranslatorPB)2 StorageContainerLocationProtocolClientSideTranslatorPB (org.apache.hadoop.hdds.scm.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB)2 SCMBlockLocationFailoverProxyProvider (org.apache.hadoop.hdds.scm.proxy.SCMBlockLocationFailoverProxyProvider)2 SCMContainerLocationFailoverProxyProvider (org.apache.hadoop.hdds.scm.proxy.SCMContainerLocationFailoverProxyProvider)2 SCMSecurityProtocolFailoverProxyProvider (org.apache.hadoop.hdds.scm.proxy.SCMSecurityProtocolFailoverProxyProvider)2 DBCheckpoint (org.apache.hadoop.hdds.utils.db.DBCheckpoint)2 GenericTestUtils (org.apache.ozone.test.GenericTestUtils)2 ByteString (com.google.protobuf.ByteString)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 Configuration (org.apache.hadoop.conf.Configuration)1 SupplierWithIOException (org.apache.hadoop.hdds.function.SupplierWithIOException)1 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)1