Search in sources :

Example 21 with XceiverClientManager

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

the class ContainerOperationClient method createContainer.

@Override
public ContainerWithPipeline createContainer(HddsProtos.ReplicationType type, HddsProtos.ReplicationFactor factor, String owner) throws IOException {
    XceiverClientSpi client = null;
    XceiverClientManager clientManager = getXceiverClientManager();
    try {
        // allocate container on SCM.
        ContainerWithPipeline containerWithPipeline = storageContainerLocationClient.allocateContainer(type, factor, owner);
        Pipeline pipeline = containerWithPipeline.getPipeline();
        // connect to pipeline leader and allocate container on leader datanode.
        client = clientManager.acquireClient(pipeline);
        createContainer(client, containerWithPipeline.getContainerInfo().getContainerID());
        return containerWithPipeline;
    } finally {
        if (client != null) {
            clientManager.releaseClient(client, false);
        }
    }
}
Also used : XceiverClientManager(org.apache.hadoop.hdds.scm.XceiverClientManager) XceiverClientSpi(org.apache.hadoop.hdds.scm.XceiverClientSpi) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline)

Example 22 with XceiverClientManager

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

the class ContainerOperationClient method createContainer.

@Override
public ContainerWithPipeline createContainer(String owner) throws IOException {
    XceiverClientSpi client = null;
    XceiverClientManager clientManager = getXceiverClientManager();
    try {
        ContainerWithPipeline containerWithPipeline = storageContainerLocationClient.allocateContainer(replicationType, replicationFactor, owner);
        Pipeline pipeline = containerWithPipeline.getPipeline();
        client = clientManager.acquireClient(pipeline);
        Preconditions.checkState(pipeline.isOpen(), "Unexpected state=%s for pipeline=%s, expected state=%s", pipeline.getPipelineState(), pipeline.getId(), Pipeline.PipelineState.OPEN);
        createContainer(client, containerWithPipeline.getContainerInfo().getContainerID());
        return containerWithPipeline;
    } finally {
        if (client != null) {
            clientManager.releaseClient(client, false);
        }
    }
}
Also used : XceiverClientManager(org.apache.hadoop.hdds.scm.XceiverClientManager) XceiverClientSpi(org.apache.hadoop.hdds.scm.XceiverClientSpi) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline)

Example 23 with XceiverClientManager

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

the class TestAllocateContainer method init.

@BeforeClass
public static void init() throws Exception {
    conf = new OzoneConfiguration();
    cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(3).build();
    cluster.waitForClusterToBeReady();
    storageContainerLocationClient = cluster.getStorageContainerLocationClient();
    xceiverClientManager = new XceiverClientManager(conf);
}
Also used : OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) XceiverClientManager(org.apache.hadoop.hdds.scm.XceiverClientManager) BeforeClass(org.junit.BeforeClass)

Example 24 with XceiverClientManager

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

the class TestGetCommittedBlockLengthAndPutKey method init.

@BeforeClass
public static void init() throws Exception {
    ozoneConfig = new OzoneConfiguration();
    ozoneConfig.setClass(ScmConfigKeys.OZONE_SCM_CONTAINER_PLACEMENT_IMPL_KEY, SCMContainerPlacementCapacity.class, PlacementPolicy.class);
    cluster = MiniOzoneCluster.newBuilder(ozoneConfig).setNumDatanodes(3).build();
    cluster.waitForClusterToBeReady();
    storageContainerLocationClient = cluster.getStorageContainerLocationClient();
    xceiverClientManager = new XceiverClientManager(ozoneConfig);
}
Also used : OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) XceiverClientManager(org.apache.hadoop.hdds.scm.XceiverClientManager) BeforeClass(org.junit.BeforeClass)

Example 25 with XceiverClientManager

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

the class TestBlockOutputStreamCorrectness method createBlockOutputStream.

private BlockOutputStream createBlockOutputStream(BufferPool bufferPool) throws IOException {
    final Pipeline pipeline = MockPipeline.createRatisPipeline();
    final XceiverClientManager xcm = Mockito.mock(XceiverClientManager.class);
    Mockito.when(xcm.acquireClient(Mockito.any())).thenReturn(new MockXceiverClientSpi(pipeline));
    OzoneClientConfig config = new OzoneClientConfig();
    config.setStreamBufferSize(4 * 1024 * 1024);
    config.setStreamBufferMaxSize(32 * 1024 * 1024);
    config.setStreamBufferFlushDelay(true);
    config.setStreamBufferFlushSize(16 * 1024 * 1024);
    config.setChecksumType(ChecksumType.NONE);
    config.setBytesPerChecksum(256 * 1024);
    BlockOutputStream outputStream = new RatisBlockOutputStream(new BlockID(1L, 1L), xcm, pipeline, bufferPool, config, null);
    return outputStream;
}
Also used : OzoneClientConfig(org.apache.hadoop.hdds.scm.OzoneClientConfig) BlockID(org.apache.hadoop.hdds.client.BlockID) XceiverClientManager(org.apache.hadoop.hdds.scm.XceiverClientManager) MockPipeline(org.apache.hadoop.hdds.scm.pipeline.MockPipeline) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline)

Aggregations

XceiverClientManager (org.apache.hadoop.hdds.scm.XceiverClientManager)32 XceiverClientSpi (org.apache.hadoop.hdds.scm.XceiverClientSpi)18 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)17 ContainerWithPipeline (org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline)13 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)13 Test (org.junit.Test)12 BeforeClass (org.junit.BeforeClass)8 IOException (java.io.IOException)7 XceiverClientReply (org.apache.hadoop.hdds.scm.XceiverClientReply)7 ArrayList (java.util.ArrayList)5 OzoneClientConfig (org.apache.hadoop.hdds.scm.OzoneClientConfig)5 XceiverClientRatis (org.apache.hadoop.hdds.scm.XceiverClientRatis)5 BlockID (org.apache.hadoop.hdds.client.BlockID)4 DatanodeRatisServerConfig (org.apache.hadoop.hdds.conf.DatanodeRatisServerConfig)4 ContainerProtos (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos)4 Random (java.util.Random)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)3 ContainerCommandRequestProto (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto)3 RatisClientConfig (org.apache.hadoop.hdds.ratis.conf.RatisClientConfig)3