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));
}
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));
}
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));
}
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));
}
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());
}
Aggregations