Search in sources :

Example 1 with AbstractReconSqlDBTest

use of org.apache.hadoop.ozone.recon.persistence.AbstractReconSqlDBTest in project ozone by apache.

the class ReconTestInjector method setupInjector.

void setupInjector() throws IOException {
    List<Module> modules = new ArrayList<>();
    modules.add(new AbstractModule() {

        @Override
        protected void configure() {
            try {
                bind(OzoneConfiguration.class).toInstance(getTestOzoneConfiguration(temporaryFolder.newFolder()));
                if (reconOMMetadataManager != null) {
                    bind(ReconOMMetadataManager.class).toInstance(reconOMMetadataManager);
                }
                if (ozoneManagerServiceProvider != null) {
                    bind(OzoneManagerServiceProvider.class).toInstance(ozoneManagerServiceProvider);
                }
                if (reconScm != null) {
                    bind(OzoneStorageContainerManager.class).toInstance(reconScm);
                }
                if (withContainerDB) {
                    bind(ReconContainerMetadataManager.class).to(ReconContainerMetadataManagerImpl.class).in(Singleton.class);
                    bind(ReconNamespaceSummaryManager.class).to(ReconNamespaceSummaryManagerImpl.class).in(Singleton.class);
                    bind(ReconDBProvider.class).in(Singleton.class);
                }
                for (Map.Entry<Class, Object> entry : extraInstanceBindings.entrySet()) {
                    bind(entry.getKey()).toInstance(entry.getValue());
                }
                for (Map.Entry<Class, Class> entry : extraInheritedBindings.entrySet()) {
                    bind(entry.getKey()).to(entry.getValue()).in(Singleton.class);
                }
                for (Class type : extraClassBindings) {
                    bind(type).in(Singleton.class);
                }
            } catch (IOException e) {
                Assert.fail();
            }
        }
    });
    if (CollectionUtils.isNotEmpty(additionalModules)) {
        modules.addAll(additionalModules);
    }
    if (withReconSqlDb) {
        reconSqlDB = new AbstractReconSqlDBTest();
        modules.addAll(reconSqlDB.getReconSqlDBModules());
    }
    injector = Guice.createInjector(modules);
    if (reconSqlDB != null) {
        reconSqlDB.createSchema(injector);
    }
}
Also used : ReconContainerMetadataManager(org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager) AbstractReconSqlDBTest(org.apache.hadoop.ozone.recon.persistence.AbstractReconSqlDBTest) Singleton(com.google.inject.Singleton) ArrayList(java.util.ArrayList) ReconNamespaceSummaryManager(org.apache.hadoop.ozone.recon.spi.ReconNamespaceSummaryManager) IOException(java.io.IOException) Module(com.google.inject.Module) AbstractModule(com.google.inject.AbstractModule) AbstractModule(com.google.inject.AbstractModule)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 Singleton (com.google.inject.Singleton)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 AbstractReconSqlDBTest (org.apache.hadoop.ozone.recon.persistence.AbstractReconSqlDBTest)1 ReconContainerMetadataManager (org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager)1 ReconNamespaceSummaryManager (org.apache.hadoop.ozone.recon.spi.ReconNamespaceSummaryManager)1