Search in sources :

Example 1 with MongoLayerModule

use of com.torodb.mongodb.guice.MongoLayerModule in project torodb by torodb.

the class MongoDbReplModule method configure.

@Override
protected void configure() {
    expose(TopologyService.class);
    expose(ReplCoordinator.class);
    expose(OplogManager.class);
    bind(ReplCoordinator.class).in(Singleton.class);
    bind(OplogManager.class).in(Singleton.class);
    bind(ReplCoordinatorStateMachine.class).in(Singleton.class);
    install(new MongoClientWrapperModule());
    expose(CachedMongoClientFactory.class);
    bind(OplogReaderProvider.class).to(MongoOplogReaderProvider.class).asEagerSingleton();
    install(new FactoryModuleBuilder().implement(OplogApplierService.class, DefaultOplogApplierService.class).build(OplogApplierService.OplogApplierServiceFactory.class));
    install(new FactoryModuleBuilder().implement(RecoveryService.class, RecoveryService.class).build(RecoveryService.RecoveryServiceFactory.class));
    install(new FactoryModuleBuilder().implement(ContinuousOplogFetcher.class, ContinuousOplogFetcher.class).build(ContinuousOplogFetcher.ContinuousOplogFetcherFactory.class));
    bind(DbCloner.class).annotatedWith(MongoDbRepl.class).toProvider(AkkaDbClonerProvider.class).in(Singleton.class);
    expose(Key.get(DbCloner.class, MongoDbRepl.class));
    bind(OplogApplier.class).to(DefaultOplogApplier.class).in(Singleton.class);
    bind(DefaultOplogApplier.BatchLimits.class).toInstance(new BatchLimits(1000, Duration.ofSeconds(2)));
    bind(CommitHeuristic.class).to(DefaultCommitHeuristic.class).in(Singleton.class);
    bind(Integer.class).annotatedWith(DocsPerTransaction.class).toInstance(1000);
    bind(ConcurrentOplogBatchExecutor.class).in(Singleton.class);
    bind(AnalyzedOplogBatchExecutor.class).to(ConcurrentOplogBatchExecutor.class);
    expose(AnalyzedOplogBatchExecutor.class);
    bind(ConcurrentOplogBatchExecutor.ConcurrentOplogBatchExecutorMetrics.class).in(Singleton.class);
    bind(AnalyzedOplogBatchExecutor.AnalyzedOplogBatchExecutorMetrics.class).to(ConcurrentOplogBatchExecutorMetrics.class);
    bind(ConcurrentOplogBatchExecutor.SubBatchHeuristic.class).toInstance((ConcurrentOplogBatchExecutorMetrics metrics) -> 100);
    install(new FactoryModuleBuilder().implement(BatchAnalyzer.class, BatchAnalyzer.class).build(BatchAnalyzer.BatchAnalyzerFactory.class));
    bind(AnalyzedOpReducer.class).toInstance(new AnalyzedOpReducer(false));
    install(new TopologyGuiceModule());
    bind(MongodbReplConfig.class).toInstance(config);
    bind(ReplMetrics.class).in(Singleton.class);
    bind(OplogApplierMetrics.class).in(Singleton.class);
    bind(OplogOperationApplier.class).in(Singleton.class);
    bind(NamespaceJobExecutor.class).in(Singleton.class);
    install(new ReplCommandsGuiceModule());
    install(new MongoLayerModule(new ReplCommandImplementionsModule()));
    expose(MongodServer.class);
}
Also used : BatchLimits(com.torodb.mongodb.repl.oplogreplier.DefaultOplogApplier.BatchLimits) AnalyzedOplogBatchExecutor(com.torodb.mongodb.repl.oplogreplier.batch.AnalyzedOplogBatchExecutor) DefaultOplogApplier(com.torodb.mongodb.repl.oplogreplier.DefaultOplogApplier) MongoLayerModule(com.torodb.mongodb.guice.MongoLayerModule) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) ConcurrentOplogBatchExecutor(com.torodb.mongodb.repl.oplogreplier.batch.ConcurrentOplogBatchExecutor) ReplCommandsGuiceModule(com.torodb.mongodb.repl.commands.ReplCommandsGuiceModule) MongoOplogReaderProvider(com.torodb.mongodb.repl.impl.MongoOplogReaderProvider) TopologyGuiceModule(com.torodb.mongodb.repl.topology.TopologyGuiceModule) DbCloner(com.torodb.mongodb.utils.DbCloner) OplogOperationApplier(com.torodb.mongodb.repl.oplogreplier.OplogOperationApplier) NamespaceJobExecutor(com.torodb.mongodb.repl.oplogreplier.batch.NamespaceJobExecutor) AnalyzedOpReducer(com.torodb.mongodb.repl.oplogreplier.analyzed.AnalyzedOpReducer) OplogManager(com.torodb.mongodb.repl.OplogManager) ReplCoordinator(com.torodb.mongodb.repl.ReplCoordinator) ConcurrentOplogBatchExecutorMetrics(com.torodb.mongodb.repl.oplogreplier.batch.ConcurrentOplogBatchExecutor.ConcurrentOplogBatchExecutorMetrics) ReplCommandImplementionsModule(com.torodb.mongodb.repl.commands.ReplCommandImplementionsModule) ReplMetrics(com.torodb.mongodb.repl.ReplMetrics) ReplCoordinatorStateMachine(com.torodb.mongodb.repl.ReplCoordinatorStateMachine) OplogApplierMetrics(com.torodb.mongodb.repl.oplogreplier.OplogApplierMetrics)

Example 2 with MongoLayerModule

use of com.torodb.mongodb.guice.MongoLayerModule in project torodb by torodb.

the class ToroDbRuntimeModule method configure.

@Override
protected void configure() {
    binder().requireExplicitBindings();
    bind(BackendService.class).toInstance(backend.getBackendService());
    expose(BackendService.class);
    install(new D2RModule());
    install(new SqlTorodModule());
    install(new MongoLayerModule());
    expose(MongodServer.class);
    expose(TorodbCommandsLibrary.class);
    expose(ObjectIdFactory.class);
}
Also used : BackendService(com.torodb.core.backend.BackendService) SqlTorodModule(com.torodb.torod.guice.SqlTorodModule) MongoLayerModule(com.torodb.mongodb.guice.MongoLayerModule) D2RModule(com.torodb.d2r.guice.D2RModule)

Example 3 with MongoLayerModule

use of com.torodb.mongodb.guice.MongoLayerModule in project torodb by torodb.

the class OplogTestContextResourceRule method before.

@Override
protected void before() throws Throwable {
    testInjector = Guice.createInjector(new ReplTestModule(), new TorodServerTestModule(), new CoreModule(), new BackendModule(), new DerbyBackendModule(), new MetainfModule(), new D2RModule(), new MemoryTorodModule(), new MetricsModule(new MetricsConfig() {

        @Override
        public Boolean getMetricsEnabled() {
            return true;
        }
    }), new ConcurrentModule(), new MongoLayerModule(), new MongodServerTestModule(), specificModuleSupplier.get());
    torodServer = testInjector.getInstance(TorodBundle.class).getTorodServer();
    torodServer.startAsync();
    mongodServer = testInjector.getInstance(MongodServer.class);
    mongodServer.startAsync();
    mongodServer.awaitRunning();
    assert mongodServer.getTorodServer().equals(torodServer);
    torodServer.awaitRunning();
    oplogManager = testInjector.getInstance(OplogManager.class);
    oplogManager.startAsync();
    oplogManager.awaitRunning();
    aobe = testInjector.getInstance(AnalyzedOplogBatchExecutor.class);
    aobe.startAsync();
    aobe.awaitRunning();
    oplogApplier = testInjector.getInstance(OplogApplier.class);
    testContext = new DefaultOplogTestContext(mongodServer, oplogApplier);
}
Also used : AnalyzedOplogBatchExecutor(com.torodb.mongodb.repl.oplogreplier.batch.AnalyzedOplogBatchExecutor) MongoLayerModule(com.torodb.mongodb.guice.MongoLayerModule) D2RModule(com.torodb.d2r.guice.D2RModule) OplogManager(com.torodb.mongodb.repl.OplogManager) ConcurrentModule(com.torodb.concurrent.guice.ConcurrentModule) MetricsConfig(com.torodb.core.metrics.MetricsConfig) MetricsModule(com.torodb.core.metrics.guice.MetricsModule) CoreModule(com.torodb.core.guice.CoreModule) BackendModule(com.torodb.backend.guice.BackendModule) DerbyBackendModule(com.torodb.backend.derby.guice.DerbyBackendModule) MetainfModule(com.torodb.metainfo.guice.MetainfModule) MongodServer(com.torodb.mongodb.core.MongodServer) MemoryTorodModule(com.torodb.torod.guice.MemoryTorodModule) DerbyBackendModule(com.torodb.backend.derby.guice.DerbyBackendModule)

Aggregations

MongoLayerModule (com.torodb.mongodb.guice.MongoLayerModule)3 D2RModule (com.torodb.d2r.guice.D2RModule)2 OplogManager (com.torodb.mongodb.repl.OplogManager)2 AnalyzedOplogBatchExecutor (com.torodb.mongodb.repl.oplogreplier.batch.AnalyzedOplogBatchExecutor)2 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 DerbyBackendModule (com.torodb.backend.derby.guice.DerbyBackendModule)1 BackendModule (com.torodb.backend.guice.BackendModule)1 ConcurrentModule (com.torodb.concurrent.guice.ConcurrentModule)1 BackendService (com.torodb.core.backend.BackendService)1 CoreModule (com.torodb.core.guice.CoreModule)1 MetricsConfig (com.torodb.core.metrics.MetricsConfig)1 MetricsModule (com.torodb.core.metrics.guice.MetricsModule)1 MetainfModule (com.torodb.metainfo.guice.MetainfModule)1 MongodServer (com.torodb.mongodb.core.MongodServer)1 ReplCoordinator (com.torodb.mongodb.repl.ReplCoordinator)1 ReplCoordinatorStateMachine (com.torodb.mongodb.repl.ReplCoordinatorStateMachine)1 ReplMetrics (com.torodb.mongodb.repl.ReplMetrics)1 ReplCommandImplementionsModule (com.torodb.mongodb.repl.commands.ReplCommandImplementionsModule)1 ReplCommandsGuiceModule (com.torodb.mongodb.repl.commands.ReplCommandsGuiceModule)1 MongoOplogReaderProvider (com.torodb.mongodb.repl.impl.MongoOplogReaderProvider)1