Search in sources :

Example 1 with MockPipelineManager

use of org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager in project ozone by apache.

the class TestIncrementalContainerReportHandler method setup.

@Before
public void setup() throws IOException, InvalidStateTransitionException {
    final OzoneConfiguration conf = new OzoneConfiguration();
    final String path = GenericTestUtils.getTempPath(UUID.randomUUID().toString());
    Path scmPath = Paths.get(path, "scm-meta");
    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
    this.containerManager = Mockito.mock(ContainerManager.class);
    NetworkTopology clusterMap = new NetworkTopologyImpl(conf);
    EventQueue eventQueue = new EventQueue();
    SCMStorageConfig storageConfig = new SCMStorageConfig(conf);
    this.versionManager = Mockito.mock(HDDSLayoutVersionManager.class);
    Mockito.when(versionManager.getMetadataLayoutVersion()).thenReturn(maxLayoutVersion());
    Mockito.when(versionManager.getSoftwareLayoutVersion()).thenReturn(maxLayoutVersion());
    this.nodeManager = new SCMNodeManager(conf, storageConfig, eventQueue, clusterMap, scmContext, versionManager);
    scmhaManager = MockSCMHAManager.getInstance(true);
    testDir = GenericTestUtils.getTestDir(TestContainerManagerImpl.class.getSimpleName() + UUID.randomUUID());
    dbStore = DBStoreBuilder.createDBStore(conf, new SCMDBDefinition());
    pipelineManager = new MockPipelineManager(dbStore, scmhaManager, nodeManager);
    this.containerStateManager = ContainerStateManagerImpl.newBuilder().setConfiguration(conf).setPipelineManager(pipelineManager).setRatisServer(scmhaManager.getRatisServer()).setContainerStore(SCMDBDefinition.CONTAINERS.getTable(dbStore)).setSCMDBTransactionBuffer(scmhaManager.getDBTransactionBuffer()).build();
    this.publisher = Mockito.mock(EventPublisher.class);
    Mockito.when(containerManager.getContainer(Mockito.any(ContainerID.class))).thenAnswer(invocation -> containerStateManager.getContainer(((ContainerID) invocation.getArguments()[0])));
    Mockito.when(containerManager.getContainerReplicas(Mockito.any(ContainerID.class))).thenAnswer(invocation -> containerStateManager.getContainerReplicas(((ContainerID) invocation.getArguments()[0])));
    Mockito.doAnswer(invocation -> {
        containerStateManager.removeContainerReplica(((ContainerID) invocation.getArguments()[0]), (ContainerReplica) invocation.getArguments()[1]);
        return null;
    }).when(containerManager).removeContainerReplica(Mockito.any(ContainerID.class), Mockito.any(ContainerReplica.class));
    Mockito.doAnswer(invocation -> {
        containerStateManager.updateContainerState(((ContainerID) invocation.getArguments()[0]).getProtobuf(), (HddsProtos.LifeCycleEvent) invocation.getArguments()[1]);
        return null;
    }).when(containerManager).updateContainerState(Mockito.any(ContainerID.class), Mockito.any(HddsProtos.LifeCycleEvent.class));
    Mockito.doAnswer(invocation -> {
        containerStateManager.updateContainerReplica(((ContainerID) invocation.getArguments()[0]), (ContainerReplica) invocation.getArguments()[1]);
        return null;
    }).when(containerManager).updateContainerReplica(Mockito.any(ContainerID.class), Mockito.any(ContainerReplica.class));
}
Also used : Path(java.nio.file.Path) EventPublisher(org.apache.hadoop.hdds.server.events.EventPublisher) SCMStorageConfig(org.apache.hadoop.hdds.scm.server.SCMStorageConfig) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) HDDSLayoutVersionManager(org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager) EventQueue(org.apache.hadoop.hdds.server.events.EventQueue) NetworkTopologyImpl(org.apache.hadoop.hdds.scm.net.NetworkTopologyImpl) SCMNodeManager(org.apache.hadoop.hdds.scm.node.SCMNodeManager) MockPipelineManager(org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager) HddsProtos(org.apache.hadoop.hdds.protocol.proto.HddsProtos) NetworkTopology(org.apache.hadoop.hdds.scm.net.NetworkTopology) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) Before(org.junit.Before)

Example 2 with MockPipelineManager

use of org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager in project ozone by apache.

the class TestContainerReportHandler method setup.

@Before
public void setup() throws IOException, InvalidStateTransitionException {
    final OzoneConfiguration conf = SCMTestUtils.getConf();
    nodeManager = new MockNodeManager(true, 10);
    containerManager = Mockito.mock(ContainerManager.class);
    testDir = GenericTestUtils.getTestDir(TestContainerManagerImpl.class.getSimpleName() + UUID.randomUUID());
    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getAbsolutePath());
    dbStore = DBStoreBuilder.createDBStore(conf, new SCMDBDefinition());
    scmhaManager = MockSCMHAManager.getInstance(true);
    nodeManager = new MockNodeManager(true, 10);
    pipelineManager = new MockPipelineManager(dbStore, scmhaManager, nodeManager);
    containerStateManager = ContainerStateManagerImpl.newBuilder().setConfiguration(conf).setPipelineManager(pipelineManager).setRatisServer(scmhaManager.getRatisServer()).setContainerStore(SCMDBDefinition.CONTAINERS.getTable(dbStore)).setSCMDBTransactionBuffer(scmhaManager.getDBTransactionBuffer()).build();
    publisher = Mockito.mock(EventPublisher.class);
    Mockito.when(containerManager.getContainer(Mockito.any(ContainerID.class))).thenAnswer(invocation -> containerStateManager.getContainer(((ContainerID) invocation.getArguments()[0])));
    Mockito.when(containerManager.getContainerReplicas(Mockito.any(ContainerID.class))).thenAnswer(invocation -> containerStateManager.getContainerReplicas(((ContainerID) invocation.getArguments()[0])));
    Mockito.doAnswer(invocation -> {
        containerStateManager.updateContainerState(((ContainerID) invocation.getArguments()[0]).getProtobuf(), (HddsProtos.LifeCycleEvent) invocation.getArguments()[1]);
        return null;
    }).when(containerManager).updateContainerState(Mockito.any(ContainerID.class), Mockito.any(HddsProtos.LifeCycleEvent.class));
    Mockito.doAnswer(invocation -> {
        containerStateManager.updateContainerReplica(((ContainerID) invocation.getArguments()[0]), (ContainerReplica) invocation.getArguments()[1]);
        return null;
    }).when(containerManager).updateContainerReplica(Mockito.any(ContainerID.class), Mockito.any(ContainerReplica.class));
    Mockito.doAnswer(invocation -> {
        containerStateManager.removeContainerReplica(((ContainerID) invocation.getArguments()[0]), (ContainerReplica) invocation.getArguments()[1]);
        return null;
    }).when(containerManager).removeContainerReplica(Mockito.any(ContainerID.class), Mockito.any(ContainerReplica.class));
}
Also used : MockPipelineManager(org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager) EventPublisher(org.apache.hadoop.hdds.server.events.EventPublisher) HddsProtos(org.apache.hadoop.hdds.protocol.proto.HddsProtos) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Before(org.junit.Before)

Example 3 with MockPipelineManager

use of org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager in project ozone by apache.

the class TestContainerManagerImpl method setUp.

@Before
public void setUp() throws Exception {
    final OzoneConfiguration conf = SCMTestUtils.getConf();
    testDir = GenericTestUtils.getTestDir(TestContainerManagerImpl.class.getSimpleName() + UUID.randomUUID());
    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getAbsolutePath());
    dbStore = DBStoreBuilder.createDBStore(conf, new SCMDBDefinition());
    scmhaManager = MockSCMHAManager.getInstance(true);
    nodeManager = new MockNodeManager(true, 10);
    sequenceIdGen = new SequenceIdGenerator(conf, scmhaManager, SCMDBDefinition.SEQUENCE_ID.getTable(dbStore));
    final PipelineManager pipelineManager = new MockPipelineManager(dbStore, scmhaManager, nodeManager);
    pipelineManager.createPipeline(RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
    containerManager = new ContainerManagerImpl(conf, scmhaManager, sequenceIdGen, pipelineManager, SCMDBDefinition.CONTAINERS.getTable(dbStore));
}
Also used : SequenceIdGenerator(org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator) MockPipelineManager(org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) MockPipelineManager(org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager) PipelineManager(org.apache.hadoop.hdds.scm.pipeline.PipelineManager) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Before(org.junit.Before)

Example 4 with MockPipelineManager

use of org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager in project ozone by apache.

the class TestContainerPlacement method setUp.

@Before
public void setUp() throws Exception {
    conf = getConf();
    testDir = GenericTestUtils.getTestDir(TestContainerManagerImpl.class.getSimpleName() + UUID.randomUUID());
    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getAbsolutePath());
    dbStore = DBStoreBuilder.createDBStore(conf, new SCMDBDefinition());
    scmhaManager = MockSCMHAManager.getInstance(true);
    sequenceIdGen = new SequenceIdGenerator(conf, scmhaManager, SCMDBDefinition.SEQUENCE_ID.getTable(dbStore));
    nodeManager = new MockNodeManager(true, 10);
    pipelineManager = new MockPipelineManager(dbStore, scmhaManager, nodeManager);
    pipelineManager.createPipeline(RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.THREE));
}
Also used : SequenceIdGenerator(org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator) MockPipelineManager(org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) TestContainerManagerImpl(org.apache.hadoop.hdds.scm.container.TestContainerManagerImpl) MockNodeManager(org.apache.hadoop.hdds.scm.container.MockNodeManager) Before(org.junit.Before)

Example 5 with MockPipelineManager

use of org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager in project ozone by apache.

the class TestUnknownContainerReport method setup.

@Before
public void setup() throws IOException {
    final OzoneConfiguration conf = SCMTestUtils.getConf();
    this.nodeManager = new MockNodeManager(true, 10);
    this.containerManager = Mockito.mock(ContainerManager.class);
    testDir = GenericTestUtils.getTestDir(TestContainerManagerImpl.class.getSimpleName() + UUID.randomUUID());
    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getAbsolutePath());
    dbStore = DBStoreBuilder.createDBStore(conf, new SCMDBDefinition());
    scmhaManager = MockSCMHAManager.getInstance(true);
    pipelineManager = new MockPipelineManager(dbStore, scmhaManager, nodeManager);
    containerStateManager = ContainerStateManagerImpl.newBuilder().setConfiguration(conf).setPipelineManager(pipelineManager).setRatisServer(scmhaManager.getRatisServer()).setContainerStore(SCMDBDefinition.CONTAINERS.getTable(dbStore)).setSCMDBTransactionBuffer(scmhaManager.getDBTransactionBuffer()).build();
    this.publisher = Mockito.mock(EventPublisher.class);
    Mockito.when(containerManager.getContainer(Mockito.any(ContainerID.class))).thenThrow(new ContainerNotFoundException());
}
Also used : MockPipelineManager(org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager) EventPublisher(org.apache.hadoop.hdds.server.events.EventPublisher) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Before(org.junit.Before)

Aggregations

SCMDBDefinition (org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition)5 MockPipelineManager (org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager)5 Before (org.junit.Before)5 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)4 EventPublisher (org.apache.hadoop.hdds.server.events.EventPublisher)3 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)2 SequenceIdGenerator (org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator)2 Path (java.nio.file.Path)1 MockNodeManager (org.apache.hadoop.hdds.scm.container.MockNodeManager)1 TestContainerManagerImpl (org.apache.hadoop.hdds.scm.container.TestContainerManagerImpl)1 NetworkTopology (org.apache.hadoop.hdds.scm.net.NetworkTopology)1 NetworkTopologyImpl (org.apache.hadoop.hdds.scm.net.NetworkTopologyImpl)1 SCMNodeManager (org.apache.hadoop.hdds.scm.node.SCMNodeManager)1 PipelineManager (org.apache.hadoop.hdds.scm.pipeline.PipelineManager)1 SCMStorageConfig (org.apache.hadoop.hdds.scm.server.SCMStorageConfig)1 EventQueue (org.apache.hadoop.hdds.server.events.EventQueue)1 HDDSLayoutVersionManager (org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager)1