Search in sources :

Example 1 with ConstantTransactionSystemClient

use of io.cdap.cdap.data.runtime.ConstantTransactionSystemClient in project cdap by caskdata.

the class DistributedProgramContainerModule method addDataFabricModules.

/**
 * Adds guice modules that are related to data fabric.
 */
private void addDataFabricModules(List<Module> modules) {
    if (cConf.getBoolean(Constants.Transaction.TX_ENABLED)) {
        String instanceId = programOpts.getArguments().getOption(ProgramOptionConstants.INSTANCE_ID);
        modules.add(new DataFabricModules(generateClientId(programRunId, instanceId)).getDistributedModules());
        modules.add(new SystemDatasetRuntimeModule().getDistributedModules());
    } else {
        modules.add(new DataSetServiceModules().getStandaloneModules());
        modules.add(Modules.override(new DataFabricModules().getInMemoryModules()).with(new AbstractModule() {

            @Override
            protected void configure() {
                // Use the ConstantTransactionSystemClient in isolated mode, basically there is no transaction.
                bind(TransactionSystemClient.class).to(ConstantTransactionSystemClient.class).in(Scopes.SINGLETON);
            }
        }));
    }
    if (cConf.getBoolean(Constants.Explore.EXPLORE_ENABLED)) {
        modules.add(new AbstractModule() {

            @Override
            protected void configure() {
                // bind explore client to ProgramDiscoveryExploreClient which is aware of the programId
                bind(ExploreClient.class).to(ProgramDiscoveryExploreClient.class).in(Scopes.SINGLETON);
            }
        });
    } else {
        modules.add(new AbstractModule() {

            @Override
            protected void configure() {
                // Bind to unsupported/no-op class implementations
                bind(ExploreClient.class).to(UnsupportedExploreClient.class);
            }
        });
    }
}
Also used : ProgramDiscoveryExploreClient(io.cdap.cdap.explore.client.ProgramDiscoveryExploreClient) ExploreClient(io.cdap.cdap.explore.client.ExploreClient) DataSetServiceModules(io.cdap.cdap.data.runtime.DataSetServiceModules) SystemDatasetRuntimeModule(io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule) ConstantTransactionSystemClient(io.cdap.cdap.data.runtime.ConstantTransactionSystemClient) DataFabricModules(io.cdap.cdap.data.runtime.DataFabricModules) AbstractModule(com.google.inject.AbstractModule)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 ConstantTransactionSystemClient (io.cdap.cdap.data.runtime.ConstantTransactionSystemClient)1 DataFabricModules (io.cdap.cdap.data.runtime.DataFabricModules)1 DataSetServiceModules (io.cdap.cdap.data.runtime.DataSetServiceModules)1 SystemDatasetRuntimeModule (io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule)1 ExploreClient (io.cdap.cdap.explore.client.ExploreClient)1 ProgramDiscoveryExploreClient (io.cdap.cdap.explore.client.ProgramDiscoveryExploreClient)1