use of io.cdap.cdap.common.guice.ZKClientModule in project cdap by caskdata.
the class LeaderElectionMessagingServiceTest method createInjector.
private Injector createInjector(int instanceId) {
CConfiguration cConf = CConfiguration.copy(LeaderElectionMessagingServiceTest.cConf);
cConf.setInt(Constants.MessagingSystem.CONTAINER_INSTANCE_ID, instanceId);
return Guice.createInjector(new ConfigModule(cConf), new ZKClientModule(), new ZKDiscoveryModule(), new AuthorizationEnforcementModule().getNoOpModules(), new DFSLocationModule(), new AbstractModule() {
@Override
protected void configure() {
// Bindings to services for testing only
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
// Use the same in memory client across all injectors.
bind(NamespaceQueryAdmin.class).toInstance(namespaceQueryAdmin);
}
}, new PrivateModule() {
@Override
protected void configure() {
// This is very similar to bindings in distributed mode, except we bind to level db instead of HBase
// Also the level DB has to be one instance since unit-test runs in the same process.
bind(TableFactory.class).annotatedWith(Names.named(CachingTableFactory.DELEGATE_TABLE_FACTORY)).toInstance(levelDBTableFactory);
// The cache must be in singleton scope
bind(MessageTableCacheProvider.class).to(DefaultMessageTableCacheProvider.class).in(Scopes.SINGLETON);
bind(TableFactory.class).to(CachingTableFactory.class);
// Bind http handlers
MessagingServerRuntimeModule.bindHandlers(binder(), Constants.MessagingSystem.HANDLER_BINDING_NAME);
bind(MessagingService.class).to(LeaderElectionMessagingService.class).in(Scopes.SINGLETON);
expose(MessagingService.class);
}
});
}
use of io.cdap.cdap.common.guice.ZKClientModule in project cdap by caskdata.
the class DistributedLogFrameworkTest method createInjector.
private Injector createInjector() throws IOException {
CConfiguration cConf = CConfiguration.copy(KAFKA_TESTER.getCConf());
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
// The event delay cannot be too small, otherwise the events will be out of order, especially on slow machine
cConf.setLong(Constants.Logging.PIPELINE_EVENT_DELAY_MS, 2000);
cConf.setLong("log.process.pipeline.checkpoint.interval.ms", 2000);
MockTwillContext mockTwillContext = new MockTwillContext();
return Guice.createInjector(new ConfigModule(cConf), new ZKClientModule(), new InMemoryDiscoveryModule(), new KafkaClientModule(), new LocalLocationModule(), new DistributedLogFrameworkModule(mockTwillContext.getInstanceId(), mockTwillContext.getInstanceCount()), new DataSetsModules().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new TransactionExecutorModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new NamespaceAdminTestModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), new StorageModule(), new AbstractModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
bind(UGIProvider.class).to(CurrentUGIProvider.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
}
});
}
use of io.cdap.cdap.common.guice.ZKClientModule in project cdap by cdapio.
the class UpgradeTool method createInjector.
@VisibleForTesting
Injector createInjector() {
return Guice.createInjector(new ConfigModule(cConf, hConf), RemoteAuthenticatorModules.getDefaultModule(), new DFSLocationModule(), new ZKClientModule(), new ZKDiscoveryModule(), new MessagingClientModule(), Modules.override(new DataSetsModules().getDistributedModules()).with(new AbstractModule() {
@Override
protected void configure() {
bind(DatasetFramework.class).to(InMemoryDatasetFramework.class).in(Scopes.SINGLETON);
// the DataSetsModules().getDistributedModules() binds to RemoteDatasetFramework so override that to
// the same InMemoryDatasetFramework
bind(DatasetFramework.class).annotatedWith(Names.named(DataSetsModules.BASE_DATASET_FRAMEWORK)).to(DatasetFramework.class);
bind(DatasetDefinitionRegistryFactory.class).to(DefaultDatasetDefinitionRegistryFactory.class).in(Scopes.SINGLETON);
// CDAP-5954 Upgrade tool does not need to record lineage and metadata changes for now.
bind(LineageWriter.class).to(NoOpLineageWriter.class);
bind(FieldLineageWriter.class).to(NoOpLineageWriter.class);
}
}), new TwillModule(), new ExploreClientModule(), new ProgramRunnerRuntimeModule().getDistributedModules(), new SystemDatasetRuntimeModule().getDistributedModules(), new KafkaClientModule(), new IOModule(), CoreSecurityRuntimeModule.getDistributedModule(cConf), new AuthenticationContextModules().getMasterModule(), new AuthorizationModule(), new AuthorizationEnforcementModule().getMasterModule(), new SecureStoreServerModule(), new DataFabricModules(UpgradeTool.class.getName()).getDistributedModules(), new AppFabricServiceRuntimeModule(cConf).getDistributedModules(), new KafkaLogAppenderModule(), // the DataFabricDistributedModule needs MetricsCollectionService binding
new AbstractModule() {
@Override
protected void configure() {
// Since Upgrade tool does not do anything with Metrics we just bind it to no-op implementations
bind(MetricsCollectionService.class).toInstance(new NoOpMetricsCollectionService());
bind(MetricsSystemClient.class).toInstance(new NoOpMetricsSystemClient());
}
@Provides
@Singleton
@Named("datasetInstanceManager")
@SuppressWarnings("unused")
public DatasetInstanceManager getDatasetInstanceManager(TransactionRunner transactionRunner) {
return new DatasetInstanceManager(transactionRunner);
}
// This is needed because the LocalApplicationManager
// expects a dsframework injection named datasetMDS
@Provides
@Singleton
@Named("datasetMDS")
@SuppressWarnings("unused")
public DatasetFramework getInDsFramework(DatasetFramework dsFramework) {
return dsFramework;
}
}, new AbstractModule() {
@Override
protected void configure() {
// TODO (CDAP-14677): find a better way to inject metadata publisher
bind(MetadataServiceClient.class).to(NoOpMetadataServiceClient.class);
}
});
}
use of io.cdap.cdap.common.guice.ZKClientModule 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.ZKClientModule in project cdap by cdapio.
the class DistributedKeyManagerTest method setup.
@BeforeClass
public static void setup() throws Exception {
HBaseTestingUtility testUtil = new HBaseTestingUtility();
zkCluster = testUtil.startMiniZKCluster();
String zkConnectString = testUtil.getConfiguration().get(HConstants.ZOOKEEPER_QUORUM) + ":" + zkCluster.getClientPort();
LOG.info("Running ZK cluster at " + zkConnectString);
CConfiguration cConf1 = CConfiguration.create();
cConf1.setBoolean(Constants.Security.ENABLED, true);
cConf1.set(Constants.Zookeeper.QUORUM, zkConnectString);
CConfiguration cConf2 = CConfiguration.create();
cConf2.setBoolean(Constants.Security.ENABLED, true);
cConf2.set(Constants.Zookeeper.QUORUM, zkConnectString);
List<Module> modules = new ArrayList<>();
modules.add(new ConfigModule(cConf1, testUtil.getConfiguration()));
modules.add(new IOModule());
CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf1);
modules.add(coreSecurityModule);
if (coreSecurityModule.requiresZKClient()) {
modules.add(new ZKClientModule());
modules.add(new ZKDiscoveryModule());
}
injector1 = Guice.createInjector(modules);
modules.clear();
modules.add(new ConfigModule(cConf2, testUtil.getConfiguration()));
modules.add(new IOModule());
coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf2);
modules.add(coreSecurityModule);
if (coreSecurityModule.requiresZKClient()) {
modules.add(new ZKClientModule());
modules.add(new ZKDiscoveryModule());
}
injector2 = Guice.createInjector(modules);
}
Aggregations