Search in sources :

Example 16 with OzoneConfiguration

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();
}
Also used : ContainerCache(org.apache.hadoop.ozone.container.common.utils.ContainerCache) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) File(java.io.File) ReferenceCountedDB(org.apache.hadoop.ozone.container.common.utils.ReferenceCountedDB) Test(org.junit.Test)

Example 17 with OzoneConfiguration

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");
        }
    });
}
Also used : ArrayList(java.util.ArrayList) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 18 with OzoneConfiguration

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);
}
Also used : ScmConfigKeys(org.apache.hadoop.hdds.scm.ScmConfigKeys) Arrays(java.util.Arrays) BlockUtils(org.apache.hadoop.ozone.container.keyvalue.helpers.BlockUtils) BLOCK_COUNT(org.apache.hadoop.ozone.OzoneConsts.BLOCK_COUNT) TimeoutException(java.util.concurrent.TimeoutException) ContainerSet(org.apache.hadoop.ozone.container.common.impl.ContainerSet) MutableVolumeSet(org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet) ByteBuffer(java.nio.ByteBuffer) DispatcherContext(org.apache.hadoop.ozone.container.common.transport.server.ratis.DispatcherContext) BlockIterator(org.apache.hadoop.ozone.container.common.interfaces.BlockIterator) KeyValueContainerData(org.apache.hadoop.ozone.container.keyvalue.KeyValueContainerData) After(org.junit.After) HddsConfigKeys(org.apache.hadoop.hdds.HddsConfigKeys) ContainerLayoutVersion(org.apache.hadoop.ozone.container.common.impl.ContainerLayoutVersion) DatanodeStoreSchemaTwoImpl(org.apache.hadoop.ozone.container.metadata.DatanodeStoreSchemaTwoImpl) BatchOperation(org.apache.hadoop.hdds.utils.db.BatchOperation) KeyValueHandler(org.apache.hadoop.ozone.container.keyvalue.KeyValueHandler) ContainerTestHelper(org.apache.hadoop.ozone.container.ContainerTestHelper) UUID(java.util.UUID) PENDING_DELETE_BLOCK_COUNT(org.apache.hadoop.ozone.OzoneConsts.PENDING_DELETE_BLOCK_COUNT) List(java.util.List) RoundRobinVolumeChoosingPolicy(org.apache.hadoop.ozone.container.common.volume.RoundRobinVolumeChoosingPolicy) StorageContainerException(org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException) RandomStringUtils.randomAlphanumeric(org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric) ChunkInfo(org.apache.hadoop.ozone.container.common.helpers.ChunkInfo) OzoneConfigKeys(org.apache.hadoop.ozone.OzoneConfigKeys) FilePerBlockStrategy(org.apache.hadoop.ozone.container.keyvalue.impl.FilePerBlockStrategy) GenericTestUtils(org.apache.ozone.test.GenericTestUtils) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) BlockID(org.apache.hadoop.hdds.client.BlockID) BlockManager(org.apache.hadoop.ozone.container.keyvalue.interfaces.BlockManager) ContainerProtos(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos) DBHandle(org.apache.hadoop.ozone.container.common.interfaces.DBHandle) CONTAINER_BYTES_USED(org.apache.hadoop.ozone.OzoneConsts.CONTAINER_BYTES_USED) BlockData(org.apache.hadoop.ozone.container.common.helpers.BlockData) BlockDeletingServiceTestImpl(org.apache.hadoop.ozone.container.testutils.BlockDeletingServiceTestImpl) OzoneContainer(org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer) ContainerDispatcher(org.apache.hadoop.ozone.container.common.interfaces.ContainerDispatcher) Before(org.junit.Before) KeyValueContainer(org.apache.hadoop.ozone.container.keyvalue.KeyValueContainer) UTF_8(java.nio.charset.StandardCharsets.UTF_8) OZONE_BLOCK_DELETING_CONTAINER_LIMIT_PER_INTERVAL(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_CONTAINER_LIMIT_PER_INTERVAL) ContainerMetrics(org.apache.hadoop.ozone.container.common.helpers.ContainerMetrics) Test(org.junit.Test) IOException(java.io.IOException) Container(org.apache.hadoop.ozone.container.common.interfaces.Container) Mockito.when(org.mockito.Mockito.when) DeletedBlocksTransaction(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction) OzoneConsts(org.apache.hadoop.ozone.OzoneConsts) File(java.io.File) BlockManagerImpl(org.apache.hadoop.ozone.container.keyvalue.impl.BlockManagerImpl) StorageVolume(org.apache.hadoop.ozone.container.common.volume.StorageVolume) Rule(org.junit.Rule) Table(org.apache.hadoop.hdds.utils.db.Table) ChunkBuffer(org.apache.hadoop.ozone.common.ChunkBuffer) ChunkManager(org.apache.hadoop.ozone.container.keyvalue.interfaces.ChunkManager) TemporaryFolder(org.junit.rules.TemporaryFolder) Assert.assertEquals(org.junit.Assert.assertEquals) KeyValueHandler(org.apache.hadoop.ozone.container.keyvalue.KeyValueHandler) ContainerSet(org.apache.hadoop.ozone.container.common.impl.ContainerSet) FilePerBlockStrategy(org.apache.hadoop.ozone.container.keyvalue.impl.FilePerBlockStrategy) ContainerDispatcher(org.apache.hadoop.ozone.container.common.interfaces.ContainerDispatcher) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) MutableVolumeSet(org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet) OzoneContainer(org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer) BlockManagerImpl(org.apache.hadoop.ozone.container.keyvalue.impl.BlockManagerImpl) Before(org.junit.Before)

Example 19 with OzoneConfiguration

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));
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) StateContext(org.apache.hadoop.ozone.container.common.statemachine.StateContext) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Test(org.junit.Test)

Example 20 with OzoneConfiguration

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());
}
Also used : OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Test(org.junit.Test)

Aggregations

OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)691 Test (org.junit.Test)269 Before (org.junit.Before)116 File (java.io.File)80 BeforeClass (org.junit.BeforeClass)75 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)70 IOException (java.io.IOException)56 Test (org.junit.jupiter.api.Test)50 ArrayList (java.util.ArrayList)49 OmMetadataManagerImpl (org.apache.hadoop.ozone.om.OmMetadataManagerImpl)35 MockDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails)34 BeforeEach (org.junit.jupiter.api.BeforeEach)34 MockDatanodeDetails.randomDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails)32 UUID (java.util.UUID)29 InetSocketAddress (java.net.InetSocketAddress)27 ECReplicationConfig (org.apache.hadoop.hdds.client.ECReplicationConfig)25 ReplicationConfig (org.apache.hadoop.hdds.client.ReplicationConfig)23 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)23 MockDatanodeDetails.createDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.createDatanodeDetails)22 HDDSLayoutVersionManager (org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager)22