Search in sources :

Example 16 with PipelineID

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

the class TestSCMRatisRequest method testEncodeAndDecodeSuccess.

@Test
public void testEncodeAndDecodeSuccess() throws Exception {
    PipelineID pipelineID = PipelineID.randomId();
    Object[] args = new Object[] { pipelineID.getProtobuf() };
    String operation = "test";
    SCMRatisRequest request = SCMRatisRequest.of(PIPELINE, operation, new Class[] { pipelineID.getProtobuf().getClass() }, args);
    Assert.assertEquals(operation, SCMRatisRequest.decode(request.encode()).getOperation());
    Assert.assertEquals(args[0], SCMRatisRequest.decode(request.encode()).getArguments()[0]);
}
Also used : PipelineID(org.apache.hadoop.hdds.scm.pipeline.PipelineID) Test(org.junit.Test)

Example 17 with PipelineID

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

the class TestPipelineIDCodec method testConvertAndReadBackFFAsUUID.

@Test
public void testConvertAndReadBackFFAsUUID() throws Exception {
    long mostSigBits = 0xFFFF_FFFF_FFFF_FFFFL;
    long leastSigBits = 0xFFFF_FFFF_FFFF_FFFFL;
    UUID uuid = new UUID(mostSigBits, leastSigBits);
    PipelineID pid = PipelineID.valueOf(uuid);
    byte[] encoded = new PipelineIDCodec().toPersistedFormat(pid);
    PipelineID decoded = new PipelineIDCodec().fromPersistedFormat(encoded);
    assertEquals(pid, decoded);
}
Also used : PipelineID(org.apache.hadoop.hdds.scm.pipeline.PipelineID) UUID(java.util.UUID) Test(org.junit.Test)

Example 18 with PipelineID

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

the class TestPipelineIDCodec method testConvertAndReadBackZeroAsUUID.

@Test
public void testConvertAndReadBackZeroAsUUID() throws Exception {
    long mostSigBits = 0x0000_0000_0000_0000L;
    long leastSigBits = 0x0000_0000_0000_0000L;
    UUID uuid = new UUID(mostSigBits, leastSigBits);
    PipelineID pid = PipelineID.valueOf(uuid);
    byte[] encoded = new PipelineIDCodec().toPersistedFormat(pid);
    PipelineID decoded = new PipelineIDCodec().fromPersistedFormat(encoded);
    assertEquals(pid, decoded);
}
Also used : PipelineID(org.apache.hadoop.hdds.scm.pipeline.PipelineID) UUID(java.util.UUID) Test(org.junit.Test)

Example 19 with PipelineID

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

the class TestPipelineIDCodec method testConvertAndReadBackRandomUUID.

@Test
public void testConvertAndReadBackRandomUUID() throws Exception {
    UUID uuid = UUID.randomUUID();
    PipelineID pid = PipelineID.valueOf(uuid);
    byte[] encoded = new PipelineIDCodec().toPersistedFormat(pid);
    PipelineID decoded = new PipelineIDCodec().fromPersistedFormat(encoded);
    assertEquals(pid, decoded);
}
Also used : PipelineID(org.apache.hadoop.hdds.scm.pipeline.PipelineID) UUID(java.util.UUID) Test(org.junit.Test)

Example 20 with PipelineID

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

the class ReconPipelineManager method removeInvalidPipelines.

public void removeInvalidPipelines(List<Pipeline> pipelinesFromScm) {
    acquireWriteLock();
    try {
        List<Pipeline> pipelinesInHouse = getPipelines();
        // Removing pipelines in Recon that are no longer in SCM.
        // TODO Recon may need to track inactive pipelines as well. So this can be
        // removed in a followup JIRA.
        List<Pipeline> invalidPipelines = pipelinesInHouse.stream().filter(p -> !pipelinesFromScm.contains(p)).collect(Collectors.toList());
        invalidPipelines.forEach(p -> {
            PipelineID pipelineID = p.getId();
            if (!p.getPipelineState().equals(CLOSED)) {
                try {
                    getStateManager().updatePipelineState(pipelineID.getProtobuf(), HddsProtos.PipelineState.PIPELINE_CLOSED);
                } catch (IOException e) {
                    LOG.warn("Pipeline {} not found while updating state. ", p.getId(), e);
                }
            }
            try {
                LOG.info("Removing invalid pipeline {} from Recon.", pipelineID);
                closePipeline(p, false);
            } catch (IOException e) {
                LOG.warn("Unable to remove pipeline {}", pipelineID, e);
            }
        });
    } finally {
        releaseWriteLock();
    }
}
Also used : HddsProtos(org.apache.hadoop.hdds.protocol.proto.HddsProtos) NodeManager(org.apache.hadoop.hdds.scm.node.NodeManager) ClientVersions(org.apache.hadoop.ozone.ClientVersions) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) SCMContext(org.apache.hadoop.hdds.scm.ha.SCMContext) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) Collectors(java.util.stream.Collectors) List(java.util.List) PipelineFactory(org.apache.hadoop.hdds.scm.pipeline.PipelineFactory) CLOSED(org.apache.hadoop.hdds.scm.pipeline.Pipeline.PipelineState.CLOSED) ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) PipelineStateManager(org.apache.hadoop.hdds.scm.pipeline.PipelineStateManager) PipelineStateManagerImpl(org.apache.hadoop.hdds.scm.pipeline.PipelineStateManagerImpl) EventPublisher(org.apache.hadoop.hdds.server.events.EventPublisher) Table(org.apache.hadoop.hdds.utils.db.Table) PipelineID(org.apache.hadoop.hdds.scm.pipeline.PipelineID) SCMHAManager(org.apache.hadoop.hdds.scm.ha.SCMHAManager) VisibleForTesting(com.google.common.annotations.VisibleForTesting) PipelineManagerImpl(org.apache.hadoop.hdds.scm.pipeline.PipelineManagerImpl) PipelineID(org.apache.hadoop.hdds.scm.pipeline.PipelineID) IOException(java.io.IOException) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline)

Aggregations

PipelineID (org.apache.hadoop.hdds.scm.pipeline.PipelineID)35 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)15 Test (org.junit.Test)13 IOException (java.io.IOException)12 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)11 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)6 PipelineNotFoundException (org.apache.hadoop.hdds.scm.pipeline.PipelineNotFoundException)6 XceiverServerSpi (org.apache.hadoop.ozone.container.common.transport.server.XceiverServerSpi)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 UUID (java.util.UUID)4 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)4 List (java.util.List)3 ContainerID (org.apache.hadoop.hdds.scm.container.ContainerID)3 RaftGroup (org.apache.ratis.protocol.RaftGroup)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ConfigurationSource (org.apache.hadoop.hdds.conf.ConfigurationSource)2 MockDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails)2 ClosePipelineInfo (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo)2 CreatePipelineCommandProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.CreatePipelineCommandProto)2