use of org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl in project ozone by apache.
the class TestSCMCertStore method initDbStore.
@Before
public void initDbStore() throws IOException {
scmMetadataStore = new SCMMetadataStoreImpl(config);
scmCertStore = new SCMCertStore.Builder().setRatisServer(null).setCRLSequenceId(INITIAL_SEQUENCE_ID).setMetadaStore(scmMetadataStore).build();
}
use of org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl in project ozone by apache.
the class TestCRLStatusReportHandler method init.
@Before
public void init() throws IOException {
OzoneConfiguration config = new OzoneConfiguration();
config.set(HddsConfigKeys.OZONE_METADATA_DIRS, tempDir.newFolder().getAbsolutePath());
config.setBoolean(OZONE_SECURITY_ENABLED_KEY, true);
SCMStorageConfig storageConfig = Mockito.mock(SCMStorageConfig.class);
Mockito.when(storageConfig.getClusterID()).thenReturn("cluster1");
scmMetadataStore = new SCMMetadataStoreImpl(config);
certificateStore = new SCMCertStore.Builder().setRatisServer(null).setMetadaStore(scmMetadataStore).build();
crlStatusReportHandler = new CRLStatusReportHandler(certificateStore, config);
}
use of org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl in project ozone by apache.
the class TestHealthyPipelineSafeModeRule method testHealthyPipelineSafeModeRuleWithMixedPipelines.
@Test
public void testHealthyPipelineSafeModeRuleWithMixedPipelines() throws Exception {
String storageDir = GenericTestUtils.getTempPath(TestHealthyPipelineSafeModeRule.class.getName() + UUID.randomUUID());
EventQueue eventQueue = new EventQueue();
SCMServiceManager serviceManager = new SCMServiceManager();
SCMContext scmContext = SCMContext.emptyContext();
List<ContainerInfo> containers = new ArrayList<>(HddsTestUtils.getContainerInfo(1));
OzoneConfiguration config = new OzoneConfiguration();
// In Mock Node Manager, first 8 nodes are healthy, next 2 nodes are
// stale and last one is dead, and this repeats. So for a 12 node, 9
// healthy, 2 stale and one dead.
MockNodeManager nodeManager = new MockNodeManager(true, 12);
config.set(HddsConfigKeys.OZONE_METADATA_DIRS, storageDir);
// enable pipeline check
config.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_AVAILABILITY_CHECK, true);
config.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_CREATION, false);
SCMMetadataStore scmMetadataStore = new SCMMetadataStoreImpl(config);
try {
PipelineManagerImpl pipelineManager = PipelineManagerImpl.newPipelineManager(config, MockSCMHAManager.getInstance(true), nodeManager, scmMetadataStore.getPipelineTable(), eventQueue, scmContext, serviceManager);
PipelineProvider mockRatisProvider = new MockRatisPipelineProvider(nodeManager, pipelineManager.getStateManager(), config);
pipelineManager.setPipelineProvider(HddsProtos.ReplicationType.RATIS, mockRatisProvider);
// Create 3 pipelines
Pipeline pipeline1 = pipelineManager.createPipeline(RatisReplicationConfig.getInstance(ReplicationFactor.ONE));
pipelineManager.openPipeline(pipeline1.getId());
Pipeline pipeline2 = pipelineManager.createPipeline(RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
pipelineManager.openPipeline(pipeline2.getId());
Pipeline pipeline3 = pipelineManager.createPipeline(RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
pipelineManager.openPipeline(pipeline3.getId());
// Mark pipeline healthy
pipeline1 = pipelineManager.getPipeline(pipeline1.getId());
MockRatisPipelineProvider.markPipelineHealthy(pipeline1);
pipeline2 = pipelineManager.getPipeline(pipeline2.getId());
MockRatisPipelineProvider.markPipelineHealthy(pipeline2);
pipeline3 = pipelineManager.getPipeline(pipeline3.getId());
MockRatisPipelineProvider.markPipelineHealthy(pipeline3);
SCMSafeModeManager scmSafeModeManager = new SCMSafeModeManager(config, containers, null, pipelineManager, eventQueue, serviceManager, scmContext);
HealthyPipelineSafeModeRule healthyPipelineSafeModeRule = scmSafeModeManager.getHealthyPipelineSafeModeRule();
// No pipeline event have sent to SCMSafemodeManager
Assert.assertFalse(healthyPipelineSafeModeRule.validate());
GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.captureLogs(LoggerFactory.getLogger(SCMSafeModeManager.class));
// fire event with pipeline create status with ratis type and factor 1
// pipeline, validate() should return false
firePipelineEvent(pipeline1, eventQueue);
GenericTestUtils.waitFor(() -> logCapturer.getOutput().contains("reported count is 1"), 1000, 5000);
Assert.assertFalse(healthyPipelineSafeModeRule.validate());
firePipelineEvent(pipeline2, eventQueue);
firePipelineEvent(pipeline3, eventQueue);
GenericTestUtils.waitFor(() -> healthyPipelineSafeModeRule.validate(), 1000, 5000);
} finally {
scmMetadataStore.getStore().close();
FileUtil.fullyDelete(new File(storageDir));
}
}
use of org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl in project ozone by apache.
the class TestOneReplicaPipelineSafeModeRule method setup.
private void setup(int nodes, int pipelineFactorThreeCount, int pipelineFactorOneCount) throws Exception {
OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
ozoneConfiguration.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_AVAILABILITY_CHECK, true);
ozoneConfiguration.set(HddsConfigKeys.OZONE_METADATA_DIRS, folder.newFolder().toString());
ozoneConfiguration.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_CREATION, false);
List<ContainerInfo> containers = new ArrayList<>();
containers.addAll(HddsTestUtils.getContainerInfo(1));
mockNodeManager = new MockNodeManager(true, nodes);
eventQueue = new EventQueue();
serviceManager = new SCMServiceManager();
scmContext = SCMContext.emptyContext();
SCMMetadataStore scmMetadataStore = new SCMMetadataStoreImpl(ozoneConfiguration);
pipelineManager = PipelineManagerImpl.newPipelineManager(ozoneConfiguration, MockSCMHAManager.getInstance(true), mockNodeManager, scmMetadataStore.getPipelineTable(), eventQueue, scmContext, serviceManager);
PipelineProvider mockRatisProvider = new MockRatisPipelineProvider(mockNodeManager, pipelineManager.getStateManager(), ozoneConfiguration);
pipelineManager.setPipelineProvider(HddsProtos.ReplicationType.RATIS, mockRatisProvider);
createPipelines(pipelineFactorThreeCount, HddsProtos.ReplicationFactor.THREE);
createPipelines(pipelineFactorOneCount, HddsProtos.ReplicationFactor.ONE);
SCMSafeModeManager scmSafeModeManager = new SCMSafeModeManager(ozoneConfiguration, containers, null, pipelineManager, eventQueue, serviceManager, scmContext);
rule = scmSafeModeManager.getOneReplicaPipelineSafeModeRule();
}
use of org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl in project ozone by apache.
the class TestBlockManager method setUp.
@Before
public void setUp() throws Exception {
conf = SCMTestUtils.getConf();
numContainerPerOwnerInPipeline = conf.getInt(ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT, ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT_DEFAULT);
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, folder.newFolder().toString());
conf.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_CREATION, false);
conf.setTimeDuration(HddsConfigKeys.HDDS_PIPELINE_REPORT_INTERVAL, 5, TimeUnit.SECONDS);
// Override the default Node Manager and SCMHAManager
// in SCM with the Mock one.
nodeManager = new MockNodeManager(true, 10);
scmHAManager = MockSCMHAManager.getInstance(true);
eventQueue = new EventQueue();
scmContext = SCMContext.emptyContext();
serviceManager = new SCMServiceManager();
scmMetadataStore = new SCMMetadataStoreImpl(conf);
scmMetadataStore.start(conf);
sequenceIdGen = new SequenceIdGenerator(conf, scmHAManager, scmMetadataStore.getSequenceIdTable());
pipelineManager = PipelineManagerImpl.newPipelineManager(conf, scmHAManager, nodeManager, scmMetadataStore.getPipelineTable(), eventQueue, scmContext, serviceManager);
PipelineProvider mockRatisProvider = new MockRatisPipelineProvider(nodeManager, pipelineManager.getStateManager(), conf, eventQueue);
pipelineManager.setPipelineProvider(HddsProtos.ReplicationType.RATIS, mockRatisProvider);
ContainerManager containerManager = new ContainerManagerImpl(conf, scmHAManager, sequenceIdGen, pipelineManager, scmMetadataStore.getContainerTable());
SCMSafeModeManager safeModeManager = new SCMSafeModeManager(conf, containerManager.getContainers(), containerManager, pipelineManager, eventQueue, serviceManager, scmContext) {
@Override
public void emitSafeModeStatus() {
// skip
}
};
SCMConfigurator configurator = new SCMConfigurator();
configurator.setScmNodeManager(nodeManager);
configurator.setPipelineManager(pipelineManager);
configurator.setContainerManager(containerManager);
configurator.setScmSafeModeManager(safeModeManager);
configurator.setMetadataStore(scmMetadataStore);
configurator.setSCMHAManager(scmHAManager);
configurator.setScmContext(scmContext);
scm = HddsTestUtils.getScm(conf, configurator);
// Initialize these fields so that the tests can pass.
mapping = scm.getContainerManager();
blockManager = (BlockManagerImpl) scm.getScmBlockManager();
DatanodeCommandHandler handler = new DatanodeCommandHandler();
eventQueue.addHandler(SCMEvents.DATANODE_COMMAND, handler);
CloseContainerEventHandler closeContainerHandler = new CloseContainerEventHandler(pipelineManager, mapping, scmContext);
eventQueue.addHandler(SCMEvents.CLOSE_CONTAINER, closeContainerHandler);
replicationConfig = RatisReplicationConfig.getInstance(ReplicationFactor.THREE);
scm.getScmContext().updateSafeModeStatus(new SafeModeStatus(false, true));
}
Aggregations