Search in sources :

Example 1 with SCMClientConfig

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

the class TestFailoverWithSCMHA method testFailover.

@Test
public void testFailover() 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);
    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);
    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"));
}
Also used : SCMBlockLocationFailoverProxyProvider(org.apache.hadoop.hdds.scm.proxy.SCMBlockLocationFailoverProxyProvider) ScmBlockLocationProtocolClientSideTranslatorPB(org.apache.hadoop.hdds.scm.protocolPB.ScmBlockLocationProtocolClientSideTranslatorPB) ScmBlockLocationProtocol(org.apache.hadoop.hdds.scm.protocol.ScmBlockLocationProtocol) StorageContainerManager(org.apache.hadoop.hdds.scm.server.StorageContainerManager) SCMClientConfig(org.apache.hadoop.hdds.scm.proxy.SCMClientConfig) StorageContainerLocationProtocol(org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol) GenericTestUtils(org.apache.ozone.test.GenericTestUtils) StorageContainerLocationProtocolClientSideTranslatorPB(org.apache.hadoop.hdds.scm.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB) SCMContainerLocationFailoverProxyProvider(org.apache.hadoop.hdds.scm.proxy.SCMContainerLocationFailoverProxyProvider) Test(org.junit.jupiter.api.Test)

Example 2 with SCMClientConfig

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

the class HddsServerUtil method getScmSecurityClientWithFixedDuration.

public static SCMSecurityProtocolClientSideTranslatorPB getScmSecurityClientWithFixedDuration(OzoneConfiguration conf) throws IOException {
    // As for OM during init, we need to wait for specific duration so that
    // we can give response to user performed operation init in a definite
    // period, instead of stuck for ever.
    OzoneConfiguration configuration = new OzoneConfiguration(conf);
    long duration = conf.getTimeDuration(OZONE_SCM_INFO_WAIT_DURATION, OZONE_SCM_INFO_WAIT_DURATION_DEFAULT, TimeUnit.SECONDS);
    SCMClientConfig scmClientConfig = conf.getObject(SCMClientConfig.class);
    int retryCount = (int) (duration / (scmClientConfig.getRetryInterval() / 1000));
    // retry count.
    if (retryCount > scmClientConfig.getRetryCount()) {
        scmClientConfig.setRetryCount(retryCount);
        configuration.setFromObject(scmClientConfig);
    }
    return new SCMSecurityProtocolClientSideTranslatorPB(new SCMSecurityProtocolFailoverProxyProvider(configuration, UserGroupInformation.getCurrentUser()));
}
Also used : SCMClientConfig(org.apache.hadoop.hdds.scm.proxy.SCMClientConfig) SCMSecurityProtocolClientSideTranslatorPB(org.apache.hadoop.hdds.protocolPB.SCMSecurityProtocolClientSideTranslatorPB) SCMSecurityProtocolFailoverProxyProvider(org.apache.hadoop.hdds.scm.proxy.SCMSecurityProtocolFailoverProxyProvider) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) DBCheckpoint(org.apache.hadoop.hdds.utils.db.DBCheckpoint)

Example 3 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)

Example 4 with SCMClientConfig

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

the class HddsServerUtil method getScmSecurityClientWithMaxRetry.

public static SCMSecurityProtocolClientSideTranslatorPB getScmSecurityClientWithMaxRetry(OzoneConfiguration conf) throws IOException {
    // Certificate from SCM is required for DN startup to succeed, so retry
    // for ever. In this way DN start up is resilient to SCM service running
    // status.
    OzoneConfiguration configuration = new OzoneConfiguration(conf);
    SCMClientConfig scmClientConfig = conf.getObject(SCMClientConfig.class);
    int retryCount = Integer.MAX_VALUE;
    scmClientConfig.setRetryCount(retryCount);
    configuration.setFromObject(scmClientConfig);
    return new SCMSecurityProtocolClientSideTranslatorPB(new SCMSecurityProtocolFailoverProxyProvider(configuration, UserGroupInformation.getCurrentUser()));
}
Also used : SCMClientConfig(org.apache.hadoop.hdds.scm.proxy.SCMClientConfig) SCMSecurityProtocolClientSideTranslatorPB(org.apache.hadoop.hdds.protocolPB.SCMSecurityProtocolClientSideTranslatorPB) SCMSecurityProtocolFailoverProxyProvider(org.apache.hadoop.hdds.scm.proxy.SCMSecurityProtocolFailoverProxyProvider) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) DBCheckpoint(org.apache.hadoop.hdds.utils.db.DBCheckpoint)

Example 5 with SCMClientConfig

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

the class SCMThroughputBenchmark method createDatanodeScmClient.

private StorageContainerDatanodeProtocol createDatanodeScmClient() throws IOException {
    int dnPort = conf.getInt(OZONE_SCM_DATANODE_PORT_KEY, OZONE_SCM_DATANODE_PORT_DEFAULT);
    InetSocketAddress scmAddress = NetUtils.createSocketAddr(scm, dnPort);
    Configuration hadoopConfig = LegacyHadoopConfigurationSource.asHadoopConfiguration(this.conf);
    RPC.setProtocolEngine(hadoopConfig, StorageContainerDatanodeProtocolPB.class, ProtobufRpcEngine.class);
    long version = RPC.getProtocolVersion(StorageContainerDatanodeProtocolPB.class);
    SCMClientConfig scmClientConfig = conf.getObject(SCMClientConfig.class);
    int rpcTimeout = (int) scmClientConfig.getRpcTimeOut();
    RetryPolicy retryPolicy = RetryPolicies.retryUpToMaximumCountWithFixedSleep(getScmRpcRetryCount(conf), getScmRpcRetryInterval(conf), TimeUnit.MILLISECONDS);
    StorageContainerDatanodeProtocolPB rpcProxy = RPC.getProtocolProxy(StorageContainerDatanodeProtocolPB.class, version, scmAddress, UserGroupInformation.getCurrentUser(), hadoopConfig, NetUtils.getDefaultSocketFactory(hadoopConfig), rpcTimeout, retryPolicy).getProxy();
    return new StorageContainerDatanodeProtocolClientSideTranslatorPB(rpcProxy);
}
Also used : StorageContainerDatanodeProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB) SCMClientConfig(org.apache.hadoop.hdds.scm.proxy.SCMClientConfig) Configuration(org.apache.hadoop.conf.Configuration) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) InetSocketAddress(java.net.InetSocketAddress) RetryPolicy(org.apache.hadoop.io.retry.RetryPolicy) StorageContainerDatanodeProtocolPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolPB)

Aggregations

SCMClientConfig (org.apache.hadoop.hdds.scm.proxy.SCMClientConfig)6 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)4 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 StorageContainerManager (org.apache.hadoop.hdds.scm.server.StorageContainerManager)2 DBCheckpoint (org.apache.hadoop.hdds.utils.db.DBCheckpoint)2 GenericTestUtils (org.apache.ozone.test.GenericTestUtils)2 Test (org.junit.jupiter.api.Test)2 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 MockDatanodeDetails.randomDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails)1