use of org.apache.hadoop.hdds.conf.OzoneConfiguration in project ozone by apache.
the class TestContainerCache method testUnderlyingDBzIsClosed.
@Test
public void testUnderlyingDBzIsClosed() throws Exception {
File root = new File(testRoot);
root.mkdirs();
OzoneConfiguration conf = new OzoneConfiguration();
conf.setInt(OzoneConfigKeys.OZONE_CONTAINER_CACHE_SIZE, 2);
ContainerCache cache = ContainerCache.getInstance(conf);
cache.clear();
assertEquals(0, cache.size());
File containerDir1 = new File(root, "cont100");
createContainerDB(conf, containerDir1);
ReferenceCountedDB db1 = cache.getDB(100, "RocksDB", containerDir1.getPath(), VersionedDatanodeFeatures.SchemaV2.chooseSchemaVersion(), conf);
ReferenceCountedDB db2 = cache.getDB(100, "RocksDB", containerDir1.getPath(), VersionedDatanodeFeatures.SchemaV2.chooseSchemaVersion(), conf);
assertEquals(db1, db2);
db1.getStore().getStore().close();
ReferenceCountedDB db3 = cache.getDB(100, "RocksDB", containerDir1.getPath(), VersionedDatanodeFeatures.SchemaV2.chooseSchemaVersion(), conf);
ReferenceCountedDB db4 = cache.getDB(100, "RocksDB", containerDir1.getPath(), VersionedDatanodeFeatures.SchemaV2.chooseSchemaVersion(), conf);
Assert.assertNotEquals(db3, db2);
assertEquals(db4, db3);
db1.close();
db2.close();
db3.close();
db4.close();
cache.clear();
}
use of org.apache.hadoop.hdds.conf.OzoneConfiguration in project ozone by apache.
the class TestDatanodeStateMachine method testDatanodeStateMachineWithInvalidConfiguration.
/**
* Test state transition with a list of invalid scm configurations,
* and verify the state transits to SHUTDOWN each time.
*/
@Test
public void testDatanodeStateMachineWithInvalidConfiguration() throws Exception {
List<Map.Entry<String, String>> confList = new ArrayList<>();
// Invalid ozone.scm.names
/**
* Empty *
*/
confList.add(Maps.immutableEntry(ScmConfigKeys.OZONE_SCM_NAMES, ""));
/**
* Invalid schema *
*/
confList.add(Maps.immutableEntry(ScmConfigKeys.OZONE_SCM_NAMES, "x..y"));
/**
* Invalid port *
*/
confList.add(Maps.immutableEntry(ScmConfigKeys.OZONE_SCM_NAMES, "scm:xyz"));
/**
* Port out of range *
*/
confList.add(Maps.immutableEntry(ScmConfigKeys.OZONE_SCM_NAMES, "scm:123456"));
confList.forEach((entry) -> {
OzoneConfiguration perTestConf = new OzoneConfiguration(conf);
perTestConf.setStrings(entry.getKey(), entry.getValue());
LOG.info("Test with {} = {}", entry.getKey(), entry.getValue());
try (DatanodeStateMachine stateMachine = new DatanodeStateMachine(getNewDatanodeDetails(), perTestConf, null, null, null)) {
DatanodeStateMachine.DatanodeStates currentState = stateMachine.getContext().getState();
Assert.assertEquals(DatanodeStateMachine.DatanodeStates.INIT, currentState);
DatanodeState<DatanodeStateMachine.DatanodeStates> task = stateMachine.getContext().getTask();
task.execute(executorService);
DatanodeStateMachine.DatanodeStates newState = task.await(2, TimeUnit.SECONDS);
Assert.assertEquals(DatanodeStateMachine.DatanodeStates.SHUTDOWN, newState);
} catch (Exception e) {
Assert.fail("Unexpected exception found");
}
});
}
use of org.apache.hadoop.hdds.conf.OzoneConfiguration in project ozone by apache.
the class TestSchemaTwoBackwardsCompatibility method setup.
@Before
public void setup() throws Exception {
testRoot = tempFolder.newFolder();
conf = new OzoneConfiguration();
clusterID = UUID.randomUUID().toString();
datanodeUuid = UUID.randomUUID().toString();
// turn off schemaV3 first
ContainerTestUtils.disableSchemaV3(conf);
conf.set(ScmConfigKeys.HDDS_DATANODE_DIR_KEY, testRoot.getAbsolutePath());
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testRoot.getAbsolutePath());
volumeSet = new MutableVolumeSet(datanodeUuid, clusterID, conf, null, StorageVolume.VolumeType.DATA_VOLUME, null);
blockManager = new BlockManagerImpl(conf);
chunkManager = new FilePerBlockStrategy(true, blockManager, volumeSet);
containerSet = new ContainerSet();
keyValueHandler = new KeyValueHandler(conf, datanodeUuid, containerSet, volumeSet, ContainerMetrics.create(conf), c -> {
});
ozoneContainer = mock(OzoneContainer.class);
when(ozoneContainer.getContainerSet()).thenReturn(containerSet);
when(ozoneContainer.getWriteChannel()).thenReturn(null);
ContainerDispatcher dispatcher = mock(ContainerDispatcher.class);
when(ozoneContainer.getDispatcher()).thenReturn(dispatcher);
when(dispatcher.getHandler(any())).thenReturn(keyValueHandler);
}
use of org.apache.hadoop.hdds.conf.OzoneConfiguration in project ozone by apache.
the class TestReportManager method testReportManagerInit.
@Test
public void testReportManagerInit() {
OzoneConfiguration conf = new OzoneConfiguration();
StateContext dummyContext = Mockito.mock(StateContext.class);
ReportPublisher dummyPublisher = Mockito.mock(ReportPublisher.class);
ReportManager.Builder builder = ReportManager.newBuilder(conf);
builder.setStateContext(dummyContext);
builder.addPublisher(dummyPublisher);
ReportManager reportManager = builder.build();
reportManager.init();
verify(dummyPublisher, times(1)).init(eq(dummyContext), any(ScheduledExecutorService.class));
}
use of org.apache.hadoop.hdds.conf.OzoneConfiguration in project ozone by apache.
the class TestReportPublisherFactory method testGetContainerReportPublisher.
@Test
public void testGetContainerReportPublisher() {
OzoneConfiguration conf = new OzoneConfiguration();
ReportPublisherFactory factory = new ReportPublisherFactory(conf);
ReportPublisher publisher = factory.getPublisherFor(ContainerReportsProto.class);
Assert.assertEquals(ContainerReportPublisher.class, publisher.getClass());
Assert.assertEquals(conf, publisher.getConf());
}
Aggregations