Search in sources :

Example 26 with NodeManager

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

the class TestReconPipelineManager method testAddPipeline.

@Test
public void testAddPipeline() throws IOException {
    Pipeline pipeline = getRandomPipeline();
    NetworkTopology clusterMap = new NetworkTopologyImpl(conf);
    EventQueue eventQueue = new EventQueue();
    this.versionManager = Mockito.mock(HDDSLayoutVersionManager.class);
    Mockito.when(versionManager.getMetadataLayoutVersion()).thenReturn(maxLayoutVersion());
    Mockito.when(versionManager.getSoftwareLayoutVersion()).thenReturn(maxLayoutVersion());
    NodeManager nodeManager = new SCMNodeManager(conf, scmStorageConfig, eventQueue, clusterMap, SCMContext.emptyContext(), versionManager);
    ReconPipelineManager reconPipelineManager = ReconPipelineManager.newReconPipelineManager(conf, nodeManager, ReconSCMDBDefinition.PIPELINES.getTable(store), eventQueue, scmhaManager, scmContext);
    assertFalse(reconPipelineManager.containsPipeline(pipeline.getId()));
    reconPipelineManager.addPipeline(pipeline);
    assertTrue(reconPipelineManager.containsPipeline(pipeline.getId()));
}
Also used : NetworkTopologyImpl(org.apache.hadoop.hdds.scm.net.NetworkTopologyImpl) NodeManager(org.apache.hadoop.hdds.scm.node.NodeManager) SCMNodeManager(org.apache.hadoop.hdds.scm.node.SCMNodeManager) SCMNodeManager(org.apache.hadoop.hdds.scm.node.SCMNodeManager) NetworkTopology(org.apache.hadoop.hdds.scm.net.NetworkTopology) HDDSLayoutVersionManager(org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager) EventQueue(org.apache.hadoop.hdds.server.events.EventQueue) OMMetadataManagerTestUtils.getRandomPipeline(org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.getRandomPipeline) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) Test(org.junit.Test)

Example 27 with NodeManager

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

the class TestStorageContainerManager method testBlockDeletingThrottling.

@Test
public void testBlockDeletingThrottling() throws Exception {
    int numKeys = 15;
    OzoneConfiguration conf = new OzoneConfiguration();
    conf.setTimeDuration(HDDS_CONTAINER_REPORT_INTERVAL, 1, TimeUnit.SECONDS);
    conf.setInt(ScmConfigKeys.OZONE_SCM_BLOCK_DELETION_MAX_RETRY, 5);
    conf.setTimeDuration(OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_INTERVAL, 100, TimeUnit.MILLISECONDS);
    ScmConfig scmConfig = conf.getObject(ScmConfig.class);
    scmConfig.setBlockDeletionInterval(Duration.ofMillis(100));
    conf.setFromObject(scmConfig);
    conf.setInt(ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT, numKeys);
    conf.setBoolean(HDDS_SCM_SAFEMODE_PIPELINE_CREATION, false);
    MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf).setHbInterval(1000).setHbProcessorInterval(3000).setNumDatanodes(1).build();
    cluster.waitForClusterToBeReady();
    cluster.waitForPipelineTobeReady(HddsProtos.ReplicationFactor.ONE, 30000);
    try {
        DeletedBlockLog delLog = cluster.getStorageContainerManager().getScmBlockManager().getDeletedBlockLog();
        Assert.assertEquals(0, delLog.getNumOfValidTransactions());
        int limitSize = 1;
        // Reset limit value to 1, so that we only allow one TX is dealt per
        // datanode.
        SCMBlockDeletingService delService = cluster.getStorageContainerManager().getScmBlockManager().getSCMBlockDeletingService();
        delService.setBlockDeleteTXNum(limitSize);
        // Create {numKeys} random names keys.
        TestStorageContainerManagerHelper helper = new TestStorageContainerManagerHelper(cluster, conf);
        Map<String, OmKeyInfo> keyLocations = helper.createKeys(numKeys, 4096);
        // Wait for container report
        Thread.sleep(5000);
        for (OmKeyInfo keyInfo : keyLocations.values()) {
            OzoneTestUtils.closeContainers(keyInfo.getKeyLocationVersions(), cluster.getStorageContainerManager());
        }
        createDeleteTXLog(cluster.getStorageContainerManager(), delLog, keyLocations, helper);
        // Verify a few TX gets created in the TX log.
        Assert.assertTrue(delLog.getNumOfValidTransactions() > 0);
        // Verify the size in delete commands is expected.
        GenericTestUtils.waitFor(() -> {
            NodeManager nodeManager = cluster.getStorageContainerManager().getScmNodeManager();
            LayoutVersionManager versionManager = nodeManager.getLayoutVersionManager();
            StorageContainerDatanodeProtocolProtos.LayoutVersionProto layoutInfo = StorageContainerDatanodeProtocolProtos.LayoutVersionProto.newBuilder().setSoftwareLayoutVersion(versionManager.getSoftwareLayoutVersion()).setMetadataLayoutVersion(versionManager.getMetadataLayoutVersion()).build();
            List<SCMCommand> commands = nodeManager.processHeartbeat(nodeManager.getNodes(NodeStatus.inServiceHealthy()).get(0), layoutInfo);
            if (commands != null) {
                for (SCMCommand cmd : commands) {
                    if (cmd.getType() == SCMCommandProto.Type.deleteBlocksCommand) {
                        List<DeletedBlocksTransaction> deletedTXs = ((DeleteBlocksCommand) cmd).blocksTobeDeleted();
                        return deletedTXs != null && deletedTXs.size() == limitSize;
                    }
                }
            }
            return false;
        }, 500, 10000);
    } finally {
        cluster.shutdown();
    }
}
Also used : SCMBlockDeletingService(org.apache.hadoop.hdds.scm.block.SCMBlockDeletingService) DeleteBlocksCommand(org.apache.hadoop.ozone.protocol.commands.DeleteBlocksCommand) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) DeletedBlockLog(org.apache.hadoop.hdds.scm.block.DeletedBlockLog) ScmConfig(org.apache.hadoop.hdds.scm.ScmConfig) NodeManager(org.apache.hadoop.hdds.scm.node.NodeManager) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) LayoutVersionManager(org.apache.hadoop.ozone.upgrade.LayoutVersionManager) StorageContainerDatanodeProtocolProtos(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos) DeletedBlocksTransaction(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction) SCMCommand(org.apache.hadoop.ozone.protocol.commands.SCMCommand) Test(org.junit.Test)

Example 28 with NodeManager

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

the class ContainerPlacementPolicyFactory method getPolicy.

public static PlacementPolicy getPolicy(ConfigurationSource conf, final NodeManager nodeManager, NetworkTopology clusterMap, final boolean fallback, SCMContainerPlacementMetrics metrics) throws SCMException {
    final Class<? extends PlacementPolicy> placementClass = conf.getClass(ScmConfigKeys.OZONE_SCM_CONTAINER_PLACEMENT_IMPL_KEY, OZONE_SCM_CONTAINER_PLACEMENT_IMPL_DEFAULT, PlacementPolicy.class);
    Constructor<? extends PlacementPolicy> constructor;
    try {
        constructor = placementClass.getDeclaredConstructor(NodeManager.class, ConfigurationSource.class, NetworkTopology.class, boolean.class, SCMContainerPlacementMetrics.class);
        LOG.info("Create container placement policy of type {}", placementClass.getCanonicalName());
    } catch (NoSuchMethodException e) {
        String msg = "Failed to find constructor(NodeManager, Configuration, " + "NetworkTopology, boolean) for class " + placementClass.getCanonicalName();
        LOG.error(msg);
        throw new SCMException(msg, SCMException.ResultCodes.FAILED_TO_INIT_CONTAINER_PLACEMENT_POLICY);
    }
    try {
        return constructor.newInstance(nodeManager, conf, clusterMap, fallback, metrics);
    } catch (Exception e) {
        throw new RuntimeException("Failed to instantiate class " + placementClass.getCanonicalName() + " for " + e.getMessage());
    }
}
Also used : NodeManager(org.apache.hadoop.hdds.scm.node.NodeManager) ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) NetworkTopology(org.apache.hadoop.hdds.scm.net.NetworkTopology) SCMException(org.apache.hadoop.hdds.scm.exceptions.SCMException) SCMException(org.apache.hadoop.hdds.scm.exceptions.SCMException)

Aggregations

NodeManager (org.apache.hadoop.hdds.scm.node.NodeManager)28 Test (org.junit.Test)21 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)15 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)10 ArrayList (java.util.ArrayList)6 MockDatanodeDetails.randomDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails)6 NetworkTopologyImpl (org.apache.hadoop.hdds.scm.net.NetworkTopologyImpl)6 MockDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails)5 MetadataStorageReportProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.MetadataStorageReportProto)5 StorageReportProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.StorageReportProto)5 ContainerID (org.apache.hadoop.hdds.scm.container.ContainerID)5 NetworkTopology (org.apache.hadoop.hdds.scm.net.NetworkTopology)5 DatanodeInfo (org.apache.hadoop.hdds.scm.node.DatanodeInfo)5 SCMNodeManager (org.apache.hadoop.hdds.scm.node.SCMNodeManager)5 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)5 EventPublisher (org.apache.hadoop.hdds.server.events.EventPublisher)5 EventQueue (org.apache.hadoop.hdds.server.events.EventQueue)5 SCMException (org.apache.hadoop.hdds.scm.exceptions.SCMException)4 HDDSLayoutVersionManager (org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager)4 IOException (java.io.IOException)3