Search in sources :

Example 1 with ContainerID

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

the class StorageContainerLocationProtocolClientSideTranslatorPB method getExistContainerWithPipelinesInBatch.

/**
 * {@inheritDoc}
 */
@Override
public List<ContainerWithPipeline> getExistContainerWithPipelinesInBatch(List<Long> containerIDs) {
    for (Long containerID : containerIDs) {
        Preconditions.checkState(containerID >= 0, "Container ID cannot be negative");
    }
    GetExistContainerWithPipelinesInBatchRequestProto request = GetExistContainerWithPipelinesInBatchRequestProto.newBuilder().setTraceID(TracingUtil.exportCurrentSpan()).addAllContainerIDs(containerIDs).build();
    ScmContainerLocationResponse response = null;
    List<ContainerWithPipeline> cps = new ArrayList<>();
    try {
        response = submitRequest(Type.GetExistContainerWithPipelinesInBatch, (builder) -> builder.setGetExistContainerWithPipelinesInBatchRequest(request));
    } catch (IOException ex) {
        return cps;
    }
    List<HddsProtos.ContainerWithPipeline> protoCps = response.getGetExistContainerWithPipelinesInBatchResponse().getContainerWithPipelinesList();
    for (HddsProtos.ContainerWithPipeline cp : protoCps) {
        try {
            cps.add(ContainerWithPipeline.fromProtobuf(cp));
        } catch (IOException uex) {
        // "fromProtobuf" may throw an exception
        // do nothing , just go ahead
        }
    }
    return cps;
}
Also used : GetExistContainerWithPipelinesInBatchRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetExistContainerWithPipelinesInBatchRequestProto) DatanodeAdminErrorResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.DatanodeAdminErrorResponseProto) GetContainerWithPipelineRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetContainerWithPipelineRequestProto) HddsProtos(org.apache.hadoop.hdds.protocol.proto.HddsProtos) RecommissionNodesRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.RecommissionNodesRequestProto) StartReplicationManagerRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StartReplicationManagerRequestProto) UpgradeFinalizer(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer) SCMContainerLocationFailoverProxyProvider(org.apache.hadoop.hdds.scm.proxy.SCMContainerLocationFailoverProxyProvider) ServiceException(com.google.protobuf.ServiceException) SCMListContainerRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SCMListContainerRequestProto) StopContainerBalancerRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StopContainerBalancerRequestProto) GetContainerWithPipelineBatchRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetContainerWithPipelineBatchRequestProto) ScmContainerLocationResponse(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationResponse) Pair(org.apache.commons.lang3.tuple.Pair) ProtocolTranslator(org.apache.hadoop.ipc.ProtocolTranslator) ProtobufHelper(org.apache.hadoop.ipc.ProtobufHelper) StartMaintenanceNodesRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StartMaintenanceNodesRequestProto) Map(java.util.Map) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages) ScmInfo(org.apache.hadoop.hdds.scm.ScmInfo) RecommissionNodesResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.RecommissionNodesResponseProto) SCMListContainerResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SCMListContainerResponseProto) NodeQueryRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.NodeQueryRequestProto) ForceExitSafeModeRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ForceExitSafeModeRequestProto) PipelineRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.PipelineRequestProto) Builder(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationRequest.Builder) StartContainerBalancerRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StartContainerBalancerRequestProto) ActivatePipelineRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ActivatePipelineRequestProto) RpcController(com.google.protobuf.RpcController) FinalizeScmUpgradeResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.FinalizeScmUpgradeResponseProto) SCMCloseContainerRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SCMCloseContainerRequestProto) SCMDeleteContainerRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SCMDeleteContainerRequestProto) Type(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.Type) ClosePipelineRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ClosePipelineRequestProto) ContainerResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ContainerResponseProto) DeactivatePipelineRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.DeactivatePipelineRequestProto) List(java.util.List) GetContainerReplicasRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetContainerReplicasRequestProto) ListPipelineRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ListPipelineRequestProto) QueryUpgradeFinalizationProgressRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.QueryUpgradeFinalizationProgressRequestProto) QueryUpgradeFinalizationProgressResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.QueryUpgradeFinalizationProgressResponseProto) ContainerRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ContainerRequestProto) ReplicationManagerReportResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ReplicationManagerReportResponseProto) GetContainerCountResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetContainerCountResponseProto) StopReplicationManagerRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StopReplicationManagerRequestProto) RPC(org.apache.hadoop.ipc.RPC) Optional(java.util.Optional) ReplicationManagerReport(org.apache.hadoop.hdds.scm.container.ReplicationManagerReport) GetContainerCountRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetContainerCountRequestProto) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) GetScmInfoResponseProto(org.apache.hadoop.hdds.protocol.proto.HddsProtos.GetScmInfoResponseProto) CURRENT_VERSION(org.apache.hadoop.ozone.ClientVersions.CURRENT_VERSION) StorageContainerLocationProtocolProtos(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos) InSafeModeRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.InSafeModeRequestProto) HashMap(java.util.HashMap) GetSafeModeRuleStatusesRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetSafeModeRuleStatusesRequestProto) UpgradeFinalizationStatus(org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus) GetContainerTokenResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetContainerTokenResponseProto) ArrayList(java.util.ArrayList) FinalizeScmUpgradeRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.FinalizeScmUpgradeRequestProto) DatanodeUsageInfoRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.DatanodeUsageInfoRequestProto) GetContainerRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetContainerRequestProto) ReplicationManagerStatusRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ReplicationManagerStatusRequestProto) NodeQueryResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.NodeQueryResponseProto) ScmContainerLocationRequest(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationRequest) GetPipelineResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetPipelineResponseProto) DecommissionNodesRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.DecommissionNodesRequestProto) ContainerBalancerStatusRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ContainerBalancerStatusRequestProto) ReplicationManagerStatusResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ReplicationManagerStatusResponseProto) GetExistContainerWithPipelinesInBatchRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetExistContainerWithPipelinesInBatchRequestProto) GetPipelineRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetPipelineRequestProto) DatanodeUsageInfoResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.DatanodeUsageInfoResponseProto) StartMaintenanceNodesResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StartMaintenanceNodesResponseProto) DatanodeAdminError(org.apache.hadoop.hdds.scm.DatanodeAdminError) ForceExitSafeModeResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ForceExitSafeModeResponseProto) ContainerBalancerStatusResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ContainerBalancerStatusResponseProto) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) ContainerID(org.apache.hadoop.hdds.scm.container.ContainerID) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) IOException(java.io.IOException) Token(org.apache.hadoop.security.token.Token) PipelineResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.PipelineResponseProto) Consumer(java.util.function.Consumer) GetSafeModeRuleStatusesResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetSafeModeRuleStatusesResponseProto) DecommissionNodesResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.DecommissionNodesResponseProto) ListPipelineResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ListPipelineResponseProto) InterfaceAudience(org.apache.hadoop.hdds.annotation.InterfaceAudience) SafeModeRuleStatusProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SafeModeRuleStatusProto) TracingUtil(org.apache.hadoop.hdds.tracing.TracingUtil) StorageContainerLocationProtocol(org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol) Closeable(java.io.Closeable) GetContainerTokenRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetContainerTokenRequestProto) Preconditions(com.google.common.base.Preconditions) ReplicationManagerReportRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ReplicationManagerReportRequestProto) RetryProxy(org.apache.hadoop.io.retry.RetryProxy) StartContainerBalancerResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StartContainerBalancerResponseProto) ScmContainerLocationResponse(org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationResponse) HddsProtos(org.apache.hadoop.hdds.protocol.proto.HddsProtos) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline)

Example 2 with ContainerID

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

the class TestReconAsPassiveScm method testReconRestart.

@Test
public void testReconRestart() throws Exception {
    final OzoneStorageContainerManager reconScm = cluster.getReconServer().getReconStorageContainerManager();
    StorageContainerManager scm = cluster.getStorageContainerManager();
    // Stop Recon
    ContainerManager scmContainerManager = scm.getContainerManager();
    assertTrue(scmContainerManager.getContainers().isEmpty());
    ContainerManager reconContainerManager = reconScm.getContainerManager();
    assertTrue(reconContainerManager.getContainers().isEmpty());
    LambdaTestUtils.await(60000, 5000, () -> (reconScm.getScmNodeManager().getAllNodes().size() == 3));
    cluster.stopRecon();
    // Create container in SCM.
    ContainerInfo containerInfo = scmContainerManager.allocateContainer(RatisReplicationConfig.getInstance(ONE), "test");
    long containerID = containerInfo.getContainerID();
    PipelineManager scmPipelineManager = scm.getPipelineManager();
    Pipeline pipeline = scmPipelineManager.getPipeline(containerInfo.getPipelineID());
    XceiverClientGrpc client = new XceiverClientGrpc(pipeline, conf);
    runTestOzoneContainerViaDataNode(containerID, client);
    assertFalse(scmContainerManager.getContainers().isEmpty());
    // Close a pipeline
    Optional<Pipeline> pipelineToClose = scmPipelineManager.getPipelines(RatisReplicationConfig.getInstance(ONE)).stream().filter(p -> !p.getId().equals(containerInfo.getPipelineID())).findFirst();
    assertTrue(pipelineToClose.isPresent());
    scmPipelineManager.closePipeline(pipelineToClose.get(), false);
    // Start Recon
    cluster.startRecon();
    // Verify if Recon has all the nodes on restart (even if heartbeats are
    // not yet received).
    NodeManager reconNodeManager = reconScm.getScmNodeManager();
    NodeManager scmNodeManager = scm.getScmNodeManager();
    assertEquals(scmNodeManager.getAllNodes().size(), reconNodeManager.getAllNodes().size());
    // Verify Recon picks up new container, close pipeline SCM actions.
    OzoneStorageContainerManager newReconScm = cluster.getReconServer().getReconStorageContainerManager();
    PipelineManager reconPipelineManager = newReconScm.getPipelineManager();
    assertFalse(reconPipelineManager.containsPipeline(pipelineToClose.get().getId()));
    LambdaTestUtils.await(90000, 5000, () -> (newReconScm.getContainerManager().containerExist(ContainerID.valueOf(containerID))));
}
Also used : OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) ReconNodeManager(org.apache.hadoop.ozone.recon.scm.ReconNodeManager) NodeManager(org.apache.hadoop.hdds.scm.node.NodeManager) MiniOzoneCluster(org.apache.hadoop.ozone.MiniOzoneCluster) OzoneStorageContainerManager(org.apache.hadoop.hdds.scm.server.OzoneStorageContainerManager) ONE(org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.ONE) PipelineNotFoundException(org.apache.hadoop.hdds.scm.pipeline.PipelineNotFoundException) After(org.junit.After) Level(org.slf4j.event.Level) Timeout(org.junit.rules.Timeout) ContainerManager(org.apache.hadoop.hdds.scm.container.ContainerManager) StorageContainerManager(org.apache.hadoop.hdds.scm.server.StorageContainerManager) LambdaTestUtils(org.apache.ozone.test.LambdaTestUtils) TestOzoneContainer.runTestOzoneContainerViaDataNode(org.apache.hadoop.ozone.container.ozoneimpl.TestOzoneContainer.runTestOzoneContainerViaDataNode) Before(org.junit.Before) HDDS_CONTAINER_REPORT_INTERVAL(org.apache.hadoop.hdds.HddsConfigKeys.HDDS_CONTAINER_REPORT_INTERVAL) RatisReplicationConfig(org.apache.hadoop.hdds.client.RatisReplicationConfig) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) ContainerID(org.apache.hadoop.hdds.scm.container.ContainerID) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) Test(org.junit.Test) PipelineManager(org.apache.hadoop.hdds.scm.pipeline.PipelineManager) XceiverClientGrpc(org.apache.hadoop.hdds.scm.XceiverClientGrpc) CLOSE_CONTAINER(org.apache.hadoop.hdds.scm.events.SCMEvents.CLOSE_CONTAINER) Rule(org.junit.Rule) HDDS_PIPELINE_REPORT_INTERVAL(org.apache.hadoop.hdds.HddsConfigKeys.HDDS_PIPELINE_REPORT_INTERVAL) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) ReconStorageContainerManagerFacade(org.apache.hadoop.ozone.recon.scm.ReconStorageContainerManagerFacade) Assert(org.junit.Assert) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) GenericTestUtils(org.apache.ozone.test.GenericTestUtils) TemporaryFolder(org.junit.rules.TemporaryFolder) Assert.assertEquals(org.junit.Assert.assertEquals) ReconNodeManager(org.apache.hadoop.ozone.recon.scm.ReconNodeManager) NodeManager(org.apache.hadoop.hdds.scm.node.NodeManager) OzoneStorageContainerManager(org.apache.hadoop.hdds.scm.server.OzoneStorageContainerManager) StorageContainerManager(org.apache.hadoop.hdds.scm.server.StorageContainerManager) OzoneStorageContainerManager(org.apache.hadoop.hdds.scm.server.OzoneStorageContainerManager) ContainerManager(org.apache.hadoop.hdds.scm.container.ContainerManager) StorageContainerManager(org.apache.hadoop.hdds.scm.server.StorageContainerManager) PipelineManager(org.apache.hadoop.hdds.scm.pipeline.PipelineManager) XceiverClientGrpc(org.apache.hadoop.hdds.scm.XceiverClientGrpc) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) OzoneStorageContainerManager(org.apache.hadoop.hdds.scm.server.OzoneStorageContainerManager) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) Test(org.junit.Test)

Example 3 with ContainerID

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

the class PipelineManagerImpl method closeContainersForPipeline.

/**
 * Fire events to close all containers related to the input pipeline.
 * @param pipelineId - ID of the pipeline.
 * @throws IOException
 */
protected void closeContainersForPipeline(final PipelineID pipelineId) throws IOException {
    Set<ContainerID> containerIDs = stateManager.getContainers(pipelineId);
    ContainerManager containerManager = scmContext.getScm().getContainerManager();
    for (ContainerID containerID : containerIDs) {
        if (containerManager.getContainer(containerID).getState() == HddsProtos.LifeCycleState.OPEN) {
            try {
                containerManager.updateContainerState(containerID, HddsProtos.LifeCycleEvent.FINALIZE);
            } catch (InvalidStateTransitionException ex) {
                throw new IOException(ex);
            }
        }
        eventPublisher.fireEvent(SCMEvents.CLOSE_CONTAINER, containerID);
        LOG.info("Container {} closed for pipeline={}", containerID, pipelineId);
    }
}
Also used : ContainerManager(org.apache.hadoop.hdds.scm.container.ContainerManager) InvalidStateTransitionException(org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException) ContainerID(org.apache.hadoop.hdds.scm.container.ContainerID) IOException(java.io.IOException)

Example 4 with ContainerID

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

the class SequenceIdGenerator method upgradeToSequenceId.

/**
 * TODO
 *  Relocate the code after upgrade framework is ready.
 *
 * Upgrade localID, delTxnId, containerId from legacy solution
 * to SequenceIdGenerator.
 */
public static void upgradeToSequenceId(SCMMetadataStore scmMetadataStore) throws IOException {
    Table<String, Long> sequenceIdTable = scmMetadataStore.getSequenceIdTable();
    // operations can take effect exactly once in a SCM HA cluster.
    if (sequenceIdTable.get(LOCAL_ID) == null) {
        long millisSinceEpoch = TimeUnit.DAYS.toMillis(LocalDate.of(LocalDate.now().getYear() + 1, 1, 1).toEpochDay());
        long localId = millisSinceEpoch << Short.SIZE;
        Preconditions.checkArgument(localId > UniqueId.next());
        sequenceIdTable.put(LOCAL_ID, localId);
        LOG.info("upgrade {} to {}", LOCAL_ID, sequenceIdTable.get(LOCAL_ID));
    }
    // upgrade delTxnId
    if (sequenceIdTable.get(DEL_TXN_ID) == null) {
        // fetch delTxnId from DeletedBlocksTXTable
        // check HDDS-4477 for details.
        DeletedBlocksTransaction txn = scmMetadataStore.getDeletedBlocksTXTable().get(0L);
        sequenceIdTable.put(DEL_TXN_ID, txn != null ? txn.getTxID() : 0L);
        LOG.info("upgrade {} to {}", DEL_TXN_ID, sequenceIdTable.get(DEL_TXN_ID));
    }
    // upgrade containerId
    if (sequenceIdTable.get(CONTAINER_ID) == null) {
        long largestContainerId = 0;
        TableIterator<ContainerID, ? extends KeyValue<ContainerID, ContainerInfo>> iterator = scmMetadataStore.getContainerTable().iterator();
        while (iterator.hasNext()) {
            ContainerInfo containerInfo = iterator.next().getValue();
            largestContainerId = Long.max(containerInfo.getContainerID(), largestContainerId);
        }
        sequenceIdTable.put(CONTAINER_ID, largestContainerId);
        LOG.info("upgrade {} to {}", CONTAINER_ID, sequenceIdTable.get(CONTAINER_ID));
    }
}
Also used : ContainerID(org.apache.hadoop.hdds.scm.container.ContainerID) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) DeletedBlocksTransaction(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction)

Example 5 with ContainerID

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

the class DatanodeAdminMonitorImpl method checkContainersReplicatedOnNode.

private boolean checkContainersReplicatedOnNode(DatanodeDetails dn) throws NodeNotFoundException {
    int sufficientlyReplicated = 0;
    int underReplicated = 0;
    int unhealthy = 0;
    List<ContainerID> underReplicatedIDs = new ArrayList<>();
    List<ContainerID> unhealthyIDs = new ArrayList<>();
    Set<ContainerID> containers = nodeManager.getContainers(dn);
    for (ContainerID cid : containers) {
        try {
            ContainerReplicaCount replicaSet = replicationManager.getContainerReplicaCount(cid);
            if (replicaSet.isSufficientlyReplicated()) {
                sufficientlyReplicated++;
            } else {
                if (LOG.isDebugEnabled()) {
                    underReplicatedIDs.add(cid);
                }
                if (underReplicated < CONTAINER_DETAILS_LOGGING_LIMIT || LOG.isDebugEnabled()) {
                    LOG.info("Under Replicated Container {} {}; {}", cid, replicaSet, replicaDetails(replicaSet.getReplica()));
                }
                underReplicated++;
            }
            if (!replicaSet.isHealthy()) {
                if (LOG.isDebugEnabled()) {
                    unhealthyIDs.add(cid);
                }
                if (unhealthy < CONTAINER_DETAILS_LOGGING_LIMIT || LOG.isDebugEnabled()) {
                    LOG.info("Unhealthy Container {} {}; {}", cid, replicaSet, replicaDetails(replicaSet.getReplica()));
                }
                unhealthy++;
            }
        } catch (ContainerNotFoundException e) {
            LOG.warn("ContainerID {} present in node list for {} but not found " + "in containerManager", cid, dn);
        }
    }
    LOG.info("{} has {} sufficientlyReplicated, {} underReplicated and {} " + "unhealthy containers", dn, sufficientlyReplicated, underReplicated, unhealthy);
    if (LOG.isDebugEnabled() && underReplicatedIDs.size() < 10000 && unhealthyIDs.size() < 10000) {
        LOG.debug("{} has {} underReplicated [{}] and {} unhealthy [{}] " + "containers", dn, underReplicated, underReplicatedIDs.stream().map(Object::toString).collect(Collectors.joining(", ")), unhealthy, unhealthyIDs.stream().map(Object::toString).collect(Collectors.joining(", ")));
    }
    return underReplicated == 0 && unhealthy == 0;
}
Also used : ContainerID(org.apache.hadoop.hdds.scm.container.ContainerID) ArrayList(java.util.ArrayList) ContainerNotFoundException(org.apache.hadoop.hdds.scm.container.ContainerNotFoundException) ContainerReplicaCount(org.apache.hadoop.hdds.scm.container.ContainerReplicaCount)

Aggregations

ContainerID (org.apache.hadoop.hdds.scm.container.ContainerID)70 Test (org.junit.Test)36 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)28 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)26 IOException (java.io.IOException)17 UUID (java.util.UUID)16 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)16 ContainerWithPipeline (org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline)14 ContainerNotFoundException (org.apache.hadoop.hdds.scm.container.ContainerNotFoundException)12 ArrayList (java.util.ArrayList)11 Map (java.util.Map)11 ContainerReplica (org.apache.hadoop.hdds.scm.container.ContainerReplica)11 HashMap (java.util.HashMap)10 List (java.util.List)9 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)9 ContainerManager (org.apache.hadoop.hdds.scm.container.ContainerManager)8 TreeSet (java.util.TreeSet)7 PipelineID (org.apache.hadoop.hdds.scm.pipeline.PipelineID)7 StorageContainerManager (org.apache.hadoop.hdds.scm.server.StorageContainerManager)7 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)6