use of org.apache.hadoop.ozone.recon.ReconTestInjector in project ozone by apache.
the class TestOpenContainerCount method initializeInjector.
private void initializeInjector() throws Exception {
reconOMMetadataManager = getTestReconOmMetadataManager(initializeNewOmMetadataManager(temporaryFolder.newFolder()), temporaryFolder.newFolder());
datanodeDetails = randomDatanodeDetails();
datanodeDetails.setHostName(HOST1);
datanodeDetails.setIpAddress(IP1);
pipeline = getRandomPipeline(datanodeDetails);
pipelineId = pipeline.getId().getId().toString();
pipeline2 = getRandomPipeline(datanodeDetails);
pipelineId2 = pipeline2.getId().getId().toString();
StorageContainerLocationProtocol mockScmClient = mock(StorageContainerLocationProtocol.class);
mockScmServiceProvider = mock(StorageContainerServiceProviderImpl.class);
when(mockScmServiceProvider.getPipeline(pipeline.getId().getProtobuf())).thenReturn(pipeline);
when(mockScmServiceProvider.getPipeline(pipeline2.getId().getProtobuf())).thenReturn(pipeline2);
// Open 5 containers on pipeline 1
containerIDs = new LinkedList<>();
cpw = new LinkedList<>();
for (long i = 1L; i <= 5L; ++i) {
ContainerInfo containerInfo = new ContainerInfo.Builder().setContainerID(i).setReplicationConfig(RatisReplicationConfig.getInstance(ReplicationFactor.ONE)).setState(LifeCycleState.OPEN).setOwner("test").setPipelineID(pipeline.getId()).build();
ContainerWithPipeline containerWithPipeline = new ContainerWithPipeline(containerInfo, pipeline);
when(mockScmServiceProvider.getContainerWithPipeline(i)).thenReturn(containerWithPipeline);
containerIDs.add(i);
cpw.add(containerWithPipeline);
}
// Open 5 containers on pipeline 2
for (long i = 6L; i <= 10L; ++i) {
ContainerInfo containerInfo = new ContainerInfo.Builder().setContainerID(i).setReplicationConfig(RatisReplicationConfig.getInstance(ReplicationFactor.ONE)).setState(LifeCycleState.OPEN).setOwner("test").setPipelineID(pipeline2.getId()).build();
ContainerWithPipeline containerWithPipeline = new ContainerWithPipeline(containerInfo, pipeline2);
when(mockScmServiceProvider.getContainerWithPipeline(i)).thenReturn(containerWithPipeline);
containerIDs.add(i);
cpw.add(containerWithPipeline);
}
when(mockScmServiceProvider.getExistContainerWithPipelinesInBatch(containerIDs)).thenReturn(cpw);
reconUtilsMock = mock(ReconUtils.class);
HttpURLConnection urlConnectionMock = mock(HttpURLConnection.class);
when(urlConnectionMock.getResponseCode()).thenReturn(HttpServletResponse.SC_OK);
when(reconUtilsMock.makeHttpCall(any(URLConnectionFactory.class), anyString(), anyBoolean())).thenReturn(urlConnectionMock);
when(reconUtilsMock.getReconDbDir(any(OzoneConfiguration.class), anyString())).thenReturn(GenericTestUtils.getRandomizedTestDir());
ReconTestInjector reconTestInjector = new ReconTestInjector.Builder(temporaryFolder).withReconSqlDb().withReconOm(reconOMMetadataManager).withOmServiceProvider(mock(OzoneManagerServiceProviderImpl.class)).addBinding(StorageContainerServiceProvider.class, mockScmServiceProvider).addBinding(OzoneStorageContainerManager.class, ReconStorageContainerManagerFacade.class).withContainerDB().addBinding(NodeEndpoint.class).addBinding(MetricsServiceProviderFactory.class).addBinding(ContainerHealthSchemaManager.class).addBinding(ReconUtils.class, reconUtilsMock).addBinding(StorageContainerLocationProtocol.class, mockScmClient).build();
nodeEndpoint = reconTestInjector.getInstance(NodeEndpoint.class);
reconScm = (ReconStorageContainerManagerFacade) reconTestInjector.getInstance(OzoneStorageContainerManager.class);
}
use of org.apache.hadoop.ozone.recon.ReconTestInjector in project ozone by apache.
the class TestEndpoints method initializeInjector.
private void initializeInjector() throws Exception {
reconOMMetadataManager = getTestReconOmMetadataManager(initializeNewOmMetadataManager(temporaryFolder.newFolder()), temporaryFolder.newFolder());
datanodeDetails = randomDatanodeDetails();
datanodeDetails2 = randomDatanodeDetails();
datanodeDetails.setHostName(HOST1);
datanodeDetails.setIpAddress(IP1);
datanodeDetails2.setHostName(HOST2);
datanodeDetails2.setIpAddress(IP2);
pipeline = getRandomPipeline(datanodeDetails);
pipelineId = pipeline.getId().getId().toString();
ContainerInfo containerInfo = new ContainerInfo.Builder().setContainerID(containerId).setReplicationConfig(RatisReplicationConfig.getInstance(ReplicationFactor.ONE)).setState(LifeCycleState.OPEN).setOwner("test").setPipelineID(pipeline.getId()).build();
ContainerWithPipeline containerWithPipeline = new ContainerWithPipeline(containerInfo, pipeline);
StorageContainerLocationProtocol mockScmClient = mock(StorageContainerLocationProtocol.class);
StorageContainerServiceProvider mockScmServiceProvider = mock(StorageContainerServiceProviderImpl.class);
when(mockScmServiceProvider.getPipeline(pipeline.getId().getProtobuf())).thenReturn(pipeline);
when(mockScmServiceProvider.getContainerWithPipeline(containerId)).thenReturn(containerWithPipeline);
List<Long> containerIDs = new LinkedList<>();
containerIDs.add(containerId);
List<ContainerWithPipeline> cpw = new LinkedList<>();
cpw.add(containerWithPipeline);
when(mockScmServiceProvider.getExistContainerWithPipelinesInBatch(containerIDs)).thenReturn(cpw);
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(PROMETHEUS_TEST_RESPONSE_FILE);
reconUtilsMock = mock(ReconUtils.class);
HttpURLConnection urlConnectionMock = mock(HttpURLConnection.class);
when(urlConnectionMock.getResponseCode()).thenReturn(HttpServletResponse.SC_OK);
when(urlConnectionMock.getInputStream()).thenReturn(inputStream);
when(reconUtilsMock.makeHttpCall(any(URLConnectionFactory.class), anyString(), anyBoolean())).thenReturn(urlConnectionMock);
when(reconUtilsMock.getReconDbDir(any(OzoneConfiguration.class), anyString())).thenReturn(GenericTestUtils.getRandomizedTestDir());
ReconTestInjector reconTestInjector = new ReconTestInjector.Builder(temporaryFolder).withReconSqlDb().withReconOm(reconOMMetadataManager).withOmServiceProvider(mock(OzoneManagerServiceProviderImpl.class)).addBinding(StorageContainerServiceProvider.class, mockScmServiceProvider).addBinding(OzoneStorageContainerManager.class, ReconStorageContainerManagerFacade.class).withContainerDB().addBinding(ClusterStateEndpoint.class).addBinding(NodeEndpoint.class).addBinding(MetricsServiceProviderFactory.class).addBinding(ContainerHealthSchemaManager.class).addBinding(UtilizationEndpoint.class).addBinding(ReconUtils.class, reconUtilsMock).addBinding(StorageContainerLocationProtocol.class, mockScmClient).build();
nodeEndpoint = reconTestInjector.getInstance(NodeEndpoint.class);
pipelineEndpoint = reconTestInjector.getInstance(PipelineEndpoint.class);
fileCountBySizeDao = getDao(FileCountBySizeDao.class);
GlobalStatsDao globalStatsDao = getDao(GlobalStatsDao.class);
UtilizationSchemaDefinition utilizationSchemaDefinition = getSchemaDefinition(UtilizationSchemaDefinition.class);
Configuration sqlConfiguration = reconTestInjector.getInstance(Configuration.class);
utilizationEndpoint = new UtilizationEndpoint(fileCountBySizeDao, utilizationSchemaDefinition);
fileSizeCountTask = new FileSizeCountTask(fileCountBySizeDao, utilizationSchemaDefinition);
tableCountTask = new TableCountTask(globalStatsDao, sqlConfiguration, reconOMMetadataManager);
reconScm = (ReconStorageContainerManagerFacade) reconTestInjector.getInstance(OzoneStorageContainerManager.class);
clusterStateEndpoint = new ClusterStateEndpoint(reconScm, globalStatsDao);
MetricsServiceProviderFactory metricsServiceProviderFactory = reconTestInjector.getInstance(MetricsServiceProviderFactory.class);
metricsProxyEndpoint = new MetricsProxyEndpoint(metricsServiceProviderFactory);
dslContext = getDslContext();
}
use of org.apache.hadoop.ozone.recon.ReconTestInjector in project ozone by apache.
the class TestReconNamespaceSummaryManagerImpl method setupOnce.
@BeforeClass
public static void setupOnce() throws Exception {
ReconTestInjector reconTestInjector = new ReconTestInjector.Builder(TEMP_FOLDER).withReconSqlDb().withContainerDB().build();
reconNamespaceSummaryManager = reconTestInjector.getInstance(ReconNamespaceSummaryManagerImpl.class);
testBucket = new int[40];
for (int i = 0; i < 40; ++i) {
testBucket[i] = i + 1;
}
}
use of org.apache.hadoop.ozone.recon.ReconTestInjector in project ozone by apache.
the class TestContainerKeyMapperTask method setUp.
@Before
public void setUp() throws Exception {
omMetadataManager = initializeNewOmMetadataManager(temporaryFolder.newFolder());
ozoneManagerServiceProvider = getMockOzoneManagerServiceProvider();
reconOMMetadataManager = getTestReconOmMetadataManager(omMetadataManager, temporaryFolder.newFolder());
ReconTestInjector reconTestInjector = new ReconTestInjector.Builder(temporaryFolder).withReconSqlDb().withReconOm(reconOMMetadataManager).withOmServiceProvider(ozoneManagerServiceProvider).withContainerDB().build();
reconContainerMetadataManager = reconTestInjector.getInstance(ReconContainerMetadataManager.class);
}
use of org.apache.hadoop.ozone.recon.ReconTestInjector in project ozone by apache.
the class TestNSSummaryTask method setUp.
@Before
public void setUp() throws Exception {
omMetadataManager = initializeNewOmMetadataManager(temporaryFolder.newFolder());
ozoneManagerServiceProvider = getMockOzoneManagerServiceProviderWithFSO();
reconOMMetadataManager = getTestReconOmMetadataManager(omMetadataManager, temporaryFolder.newFolder());
ReconTestInjector reconTestInjector = new ReconTestInjector.Builder(temporaryFolder).withReconOm(reconOMMetadataManager).withOmServiceProvider(ozoneManagerServiceProvider).withReconSqlDb().withContainerDB().build();
reconNamespaceSummaryManager = reconTestInjector.getInstance(ReconNamespaceSummaryManager.class);
}
Aggregations