Search in sources :

Example 1 with StorageContainerLocationProtocol

use of org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol 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 StorageContainerLocationProtocol

use of org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol in project ozone by apache.

the class BaseFreonGenerator method findPipelineForTest.

public static Pipeline findPipelineForTest(String pipelineId, StorageContainerLocationProtocol client, Logger log) throws IOException {
    List<Pipeline> pipelines = client.listPipelines();
    Pipeline pipeline;
    if (pipelineId != null && pipelineId.length() > 0) {
        pipeline = pipelines.stream().filter(p -> p.getId().toString().equals(pipelineId)).findFirst().orElseThrow(() -> new IllegalArgumentException("Pipeline ID is defined, but there is no such pipeline: " + pipelineId));
    } else {
        pipeline = pipelines.stream().filter(p -> p.getReplicationConfig().getRequiredNodes() == 3).findFirst().orElseThrow(() -> new IllegalArgumentException("Pipeline ID is NOT defined, and no pipeline " + "has been found with factor=THREE"));
        log.info("Using pipeline {}", pipeline.getId());
    }
    return pipeline;
}
Also used : OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) ProtobufRpcEngine(org.apache.hadoop.ipc.ProtobufRpcEngine) OZONE_OM_SERVICE_IDS_KEY(org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY) LoggerFactory(org.slf4j.LoggerFactory) HAUtils(org.apache.hadoop.hdds.utils.HAUtils) ParentCommand(picocli.CommandLine.ParentCommand) ResultCodes(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes) Matcher(java.util.regex.Matcher) OzoneManagerProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) OmTransportFactory(org.apache.hadoop.ozone.om.protocolPB.OmTransportFactory) LinkedList(java.util.LinkedList) ExecutorService(java.util.concurrent.ExecutorService) OzoneManagerProtocolPB(org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolPB) MetricRegistry(com.codahale.metrics.MetricRegistry) Logger(org.slf4j.Logger) ScheduledReporter(com.codahale.metrics.ScheduledReporter) IOException(java.io.IOException) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) GlobalTracer(io.opentracing.util.GlobalTracer) OzoneClientFactory(org.apache.hadoop.ozone.client.OzoneClientFactory) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) Option(picocli.CommandLine.Option) OMException(org.apache.hadoop.ozone.om.exceptions.OMException) ClientId(org.apache.ratis.protocol.ClientId) StorageContainerLocationProtocol(org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol) ShutdownHookManager(org.apache.hadoop.ozone.util.ShutdownHookManager) ConsoleReporter(com.codahale.metrics.ConsoleReporter) Slf4jReporter(com.codahale.metrics.Slf4jReporter) RPC(org.apache.hadoop.ipc.RPC) Span(io.opentracing.Span) RandomStringUtils(org.apache.commons.lang3.RandomStringUtils) Pattern(java.util.regex.Pattern) Scope(io.opentracing.Scope) DigestUtils(org.apache.commons.codec.digest.DigestUtils) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) InputStream(java.io.InputStream) OmTransport(org.apache.hadoop.ozone.om.protocolPB.OmTransport) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline)

Example 3 with StorageContainerLocationProtocol

use of org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol in project ozone by apache.

the class DatanodeBlockPutter method call.

@Override
public Void call() throws Exception {
    init();
    OzoneConfiguration ozoneConf = createOzoneConfiguration();
    if (OzoneSecurityUtil.isSecurityEnabled(ozoneConf)) {
        throw new IllegalArgumentException("datanode-block-putter is not supported in secure environment");
    }
    try (StorageContainerLocationProtocol scmLocationClient = createStorageContainerLocationClient(ozoneConf)) {
        Pipeline pipeline = findPipelineForTest(pipelineId, scmLocationClient, LOG);
        try (XceiverClientManager xceiverClientManager = new XceiverClientManager(ozoneConf)) {
            client = xceiverClientManager.acquireClient(pipeline);
            timer = getMetrics().timer("put-block");
            byte[] data = RandomStringUtils.randomAscii(chunkSize).getBytes(StandardCharsets.UTF_8);
            Checksum checksum = new Checksum(ChecksumType.CRC32, 1024 * 1024);
            checksumProtobuf = checksum.computeChecksum(data).getProtoBufMessage();
            runTests(this::putBlock);
        }
    } finally {
        if (client != null) {
            client.close();
        }
    }
    return null;
}
Also used : StorageContainerLocationProtocol(org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol) Checksum(org.apache.hadoop.ozone.common.Checksum) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) XceiverClientManager(org.apache.hadoop.hdds.scm.XceiverClientManager) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline)

Example 4 with StorageContainerLocationProtocol

use of org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol in project ozone by apache.

the class TestKeyManagerImpl method testRefreshPipeline.

@Test
public void testRefreshPipeline() throws Exception {
    OzoneManager ozoneManager = om;
    StorageContainerLocationProtocol sclProtocolMock = mock(StorageContainerLocationProtocol.class);
    List<Long> containerIDs = new ArrayList<>();
    containerIDs.add(100L);
    containerIDs.add(200L);
    List<ContainerWithPipeline> cps = new ArrayList<>();
    for (Long containerID : containerIDs) {
        ContainerWithPipeline containerWithPipelineMock = mock(ContainerWithPipeline.class);
        when(containerWithPipelineMock.getPipeline()).thenReturn(getRandomPipeline());
        ContainerInfo ci = mock(ContainerInfo.class);
        when(ci.getContainerID()).thenReturn(containerID);
        when(containerWithPipelineMock.getContainerInfo()).thenReturn(ci);
        cps.add(containerWithPipelineMock);
    }
    when(sclProtocolMock.getContainerWithPipelineBatch(containerIDs)).thenReturn(cps);
    ScmClient scmClientMock = mock(ScmClient.class);
    when(scmClientMock.getContainerClient()).thenReturn(sclProtocolMock);
    OmKeyInfo omKeyInfo = OMRequestTestUtils.createOmKeyInfo("v1", "b1", "k1", ReplicationType.RATIS, ReplicationFactor.THREE);
    // Add block to key.
    List<OmKeyLocationInfo> omKeyLocationInfoList = new ArrayList<>();
    Pipeline pipeline = getRandomPipeline();
    OmKeyLocationInfo omKeyLocationInfo = new OmKeyLocationInfo.Builder().setBlockID(new BlockID(100L, 1000L)).setOffset(0).setLength(100L).setPipeline(pipeline).build();
    omKeyLocationInfoList.add(omKeyLocationInfo);
    OmKeyLocationInfo omKeyLocationInfo2 = new OmKeyLocationInfo.Builder().setBlockID(new BlockID(200L, 1000L)).setOffset(0).setLength(100L).setPipeline(pipeline).build();
    omKeyLocationInfoList.add(omKeyLocationInfo2);
    OmKeyLocationInfo omKeyLocationInfo3 = new OmKeyLocationInfo.Builder().setBlockID(new BlockID(100L, 2000L)).setOffset(0).setLength(100L).setPipeline(pipeline).build();
    omKeyLocationInfoList.add(omKeyLocationInfo3);
    omKeyInfo.appendNewBlocks(omKeyLocationInfoList, false);
    KeyManagerImpl keyManagerImpl = new KeyManagerImpl(ozoneManager, scmClientMock, conf, "om1");
    keyManagerImpl.refresh(omKeyInfo);
    verify(sclProtocolMock, times(1)).getContainerWithPipelineBatch(containerIDs);
}
Also used : ArrayList(java.util.ArrayList) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) OmKeyLocationInfo(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) StorageContainerLocationProtocol(org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) BlockID(org.apache.hadoop.hdds.client.BlockID) Test(org.junit.Test)

Example 5 with StorageContainerLocationProtocol

use of org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol in project ozone by apache.

the class TestStorageContainerServiceProviderImpl method testGetPipelines.

@Test
public void testGetPipelines() throws IOException {
    StorageContainerServiceProvider scmProvider = injector.getInstance(StorageContainerServiceProvider.class);
    StorageContainerLocationProtocol scmClient = injector.getInstance(StorageContainerLocationProtocol.class);
    scmProvider.getPipelines();
    verify(scmClient, times(1)).listPipelines();
}
Also used : StorageContainerServiceProvider(org.apache.hadoop.ozone.recon.spi.StorageContainerServiceProvider) StorageContainerLocationProtocol(org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol) Test(org.junit.Test)

Aggregations

StorageContainerLocationProtocol (org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol)17 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)8 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)7 IOException (java.io.IOException)5 Test (org.junit.Test)5 StorageContainerLocationProtocolClientSideTranslatorPB (org.apache.hadoop.hdds.scm.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB)4 SCMContainerLocationFailoverProxyProvider (org.apache.hadoop.hdds.scm.proxy.SCMContainerLocationFailoverProxyProvider)4 StorageContainerServiceProvider (org.apache.hadoop.ozone.recon.spi.StorageContainerServiceProvider)4 ArrayList (java.util.ArrayList)3 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)3 ContainerWithPipeline (org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline)3 Timer (com.codahale.metrics.Timer)2 InputStream (java.io.InputStream)2 HttpURLConnection (java.net.HttpURLConnection)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Callable (java.util.concurrent.Callable)2 RandomStringUtils (org.apache.commons.lang3.RandomStringUtils)2 HddsVersionProvider (org.apache.hadoop.hdds.cli.HddsVersionProvider)2 BlockID (org.apache.hadoop.hdds.client.BlockID)2