use of org.apache.hadoop.hdds.scm.safemode.SCMSafeModeManager.SafeModeStatus 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));
}
use of org.apache.hadoop.hdds.scm.safemode.SCMSafeModeManager.SafeModeStatus in project ozone by apache.
the class TestSCMContext method testSafeModeOperations.
@Test
public void testSafeModeOperations() {
// in safe mode
SCMContext scmContext = new SCMContext.Builder().setIsInSafeMode(true).setIsPreCheckComplete(false).buildMaybeInvalid();
assertTrue(scmContext.isInSafeMode());
assertFalse(scmContext.isPreCheckComplete());
// in safe mode, pass preCheck
scmContext.updateSafeModeStatus(new SafeModeStatus(true, true));
assertTrue(scmContext.isInSafeMode());
assertTrue(scmContext.isPreCheckComplete());
// out of safe mode
scmContext.updateSafeModeStatus(new SafeModeStatus(false, true));
assertFalse(scmContext.isInSafeMode());
assertTrue(scmContext.isPreCheckComplete());
}
Aggregations