use of io.cdap.cdap.common.guice.SupplierProviderBridge in project cdap by caskdata.
the class SparkContainerDriverLauncher method createInjector.
@VisibleForTesting
static Injector createInjector(CConfiguration cConf, Configuration hConf, MasterEnvironment masterEnv) {
List<Module> modules = new ArrayList<>();
CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf);
modules.add(new ConfigModule(cConf, hConf));
modules.add(RemoteAuthenticatorModules.getDefaultModule());
modules.add(new IOModule());
modules.add(new AuthenticationContextModules().getMasterWorkerModule());
modules.add(coreSecurityModule);
modules.add(new MessagingClientModule());
modules.add(new MetricsClientRuntimeModule().getDistributedModules());
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(DiscoveryService.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceSupplier()));
bind(DiscoveryServiceClient.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceClientSupplier()));
}
});
modules.add(new RemoteLogAppenderModule());
return Guice.createInjector(modules);
}
use of io.cdap.cdap.common.guice.SupplierProviderBridge in project cdap by cdapio.
the class PreviewServiceMain method getServiceModules.
@Override
protected List<Module> getServiceModules(MasterEnvironment masterEnv, EnvironmentOptions options, CConfiguration cConf) {
List<Module> modules = new ArrayList<>(Arrays.asList(new DataSetServiceModules().getStandaloneModules(), new DataSetsModules().getStandaloneModules(), new AppFabricServiceRuntimeModule(cConf).getStandaloneModules(), new ProgramRunnerRuntimeModule().getStandaloneModules(), new MetricsStoreModule(), new MessagingClientModule(), new AuditModule(), new SecureStoreClientModule(), new MetadataReaderWriterModules().getStandaloneModules(), getDataFabricModule(), new DFSLocationModule(), new MetadataServiceModule(), new AuthorizationModule(), new AuthorizationEnforcementModule().getDistributedModules(), new AbstractModule() {
@Override
protected void configure() {
bind(TwillRunnerService.class).toProvider(new SupplierProviderBridge<>(masterEnv.getTwillRunnerSupplier())).in(Scopes.SINGLETON);
bind(TwillRunner.class).to(TwillRunnerService.class);
bind(ExploreClient.class).to(UnsupportedExploreClient.class);
}
}));
if (cConf.getInt(Constants.Preview.CONTAINER_COUNT) > 0) {
modules.add(new PreviewManagerModule(true));
} else {
modules.add(new PreviewManagerModule(false));
modules.add(new PreviewRunnerManagerModule().getStandaloneModules());
}
return modules;
}
use of io.cdap.cdap.common.guice.SupplierProviderBridge in project cdap by cdapio.
the class DistributedProgramContainerModule method addOnPremiseModules.
private void addOnPremiseModules(List<Module> modules) {
CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf);
modules.add(new AuthenticationContextModules().getMasterModule());
modules.add(coreSecurityModule);
// If MasterEnvironment is not available, assuming it is the old hadoop stack with ZK, Kafka
MasterEnvironment masterEnv = MasterEnvironments.getMasterEnvironment();
if (masterEnv == null) {
modules.add(new ZKClientModule());
modules.add(new ZKDiscoveryModule());
modules.add(new KafkaClientModule());
modules.add(new KafkaLogAppenderModule());
return;
}
if (coreSecurityModule.requiresZKClient()) {
modules.add(new ZKClientModule());
}
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(DiscoveryService.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceSupplier()));
bind(DiscoveryServiceClient.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceClientSupplier()));
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
}
});
modules.add(new RemoteLogAppenderModule());
}
use of io.cdap.cdap.common.guice.SupplierProviderBridge in project cdap by cdapio.
the class SparkContainerDriverLauncher method createInjector.
@VisibleForTesting
static Injector createInjector(CConfiguration cConf, Configuration hConf, MasterEnvironment masterEnv) {
List<Module> modules = new ArrayList<>();
CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf);
modules.add(new ConfigModule(cConf, hConf));
modules.add(RemoteAuthenticatorModules.getDefaultModule());
modules.add(new IOModule());
modules.add(new AuthenticationContextModules().getMasterWorkerModule());
modules.add(coreSecurityModule);
modules.add(new MessagingClientModule());
modules.add(new MetricsClientRuntimeModule().getDistributedModules());
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(DiscoveryService.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceSupplier()));
bind(DiscoveryServiceClient.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceClientSupplier()));
}
});
modules.add(new RemoteLogAppenderModule());
return Guice.createInjector(modules);
}
use of io.cdap.cdap.common.guice.SupplierProviderBridge in project cdap by cdapio.
the class SystemWorkerTwillRunnable method createInjector.
@VisibleForTesting
static Injector createInjector(CConfiguration cConf, Configuration hConf, SConfiguration sConf) {
List<Module> modules = new ArrayList<>();
ExecutorService cleanupExecutorService = Executors.newFixedThreadPool(cConf.getInt(Constants.SystemWorker.CLEANUP_THREADS));
CoreSecurityModule coreSecurityModule = new FileBasedCoreSecurityModule() {
@Override
protected void bindKeyManager(Binder binder) {
super.bindKeyManager(binder);
expose(KeyManager.class);
}
};
modules.add(new RemoteTwillModule());
modules.add(new ConfigModule(cConf, hConf, sConf));
modules.add(RemoteAuthenticatorModules.getDefaultModule());
modules.add(new IOModule());
modules.add(new AuthenticationContextModules().getMasterModule());
modules.add(coreSecurityModule);
modules.add(new MetricsClientRuntimeModule().getDistributedModules());
modules.addAll(Arrays.asList(// In K8s, there won't be HBase and the cdap-site should be set to use SQL store for StructuredTable.
new DataSetServiceModules().getStandaloneModules(), new AbstractModule() {
@Override
protected void configure() {
bind(ExecutorService.class).annotatedWith(Names.named(Constants.SystemWorker.CLEANUP_EXECUTOR_SERVICE_BINDING)).toInstance(cleanupExecutorService);
}
}, // The Dataset set modules are only needed to satisfy dependency injection
new DataSetsModules().getStandaloneModules(), new MessagingClientModule(), new ExploreClientModule(), new AuthorizationModule(), new AuthorizationEnforcementModule().getDistributedModules(), Modules.override(new AppFabricServiceRuntimeModule(cConf).getDistributedModules()).with(new AbstractModule() {
@Override
protected void configure() {
bind(StorageProviderNamespaceAdmin.class).to(LocalStorageProviderNamespaceAdmin.class);
}
}, new DistributedArtifactManagerModule()), Modules.override(new ProgramRunnerRuntimeModule().getDistributedModules(true)).with(new AbstractModule() {
@Override
protected void configure() {
bind(RemoteExecutionTwillRunnerService.class).to(FireAndForgetTwillRunnerService.class).in(Scopes.SINGLETON);
}
}), new SecureStoreClientModule(), new AbstractModule() {
@Override
protected void configure() {
install(new StorageModule());
install(new TransactionExecutorModule());
bind(TransactionSystemClientService.class).to(DelegatingTransactionSystemClientService.class);
bind(TransactionSystemClient.class).to(ConstantTransactionSystemClient.class);
}
}, new DFSLocationModule(), new AbstractModule() {
@Override
protected void configure() {
bind(MetadataPublisher.class).to(MessagingMetadataPublisher.class);
bind(MetadataServiceClient.class).to(DefaultMetadataServiceClient.class);
}
}));
// If MasterEnvironment is not available, assuming it is the old hadoop stack with ZK, Kafka
MasterEnvironment masterEnv = MasterEnvironments.getMasterEnvironment();
if (masterEnv == null) {
modules.add(new ZKClientModule());
modules.add(new ZKDiscoveryModule());
modules.add(new KafkaClientModule());
modules.add(new KafkaLogAppenderModule());
} else {
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(DiscoveryService.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceSupplier()));
bind(DiscoveryServiceClient.class).toProvider(new SupplierProviderBridge<>(masterEnv.getDiscoveryServiceClientSupplier()));
}
});
modules.add(new RemoteLogAppenderModule());
if (coreSecurityModule.requiresZKClient()) {
modules.add(new ZKClientModule());
}
}
return Guice.createInjector(modules);
}
Aggregations