use of io.cdap.cdap.common.guice.LocalLocationModule in project cdap by caskdata.
the class SqlAppMetadataStoreTest method beforeClass.
@BeforeClass
public static void beforeClass() throws IOException, TableAlreadyExistsException {
CConfiguration cConf = CConfiguration.create();
pg = PostgresInstantiator.createAndStart(cConf, TEMP_FOLDER.newFolder());
Injector injector = Guice.createInjector(new ConfigModule(cConf), new LocalLocationModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new StorageModule(), new AbstractModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
}
});
transactionRunner = injector.getInstance(TransactionRunner.class);
StoreDefinition.AppMetadataStore.create(injector.getInstance(StructuredTableAdmin.class));
}
use of io.cdap.cdap.common.guice.LocalLocationModule in project cdap by caskdata.
the class TaskWorkerTwillRunnable method createInjector.
@VisibleForTesting
static Injector createInjector(CConfiguration cConf, Configuration hConf) {
List<Module> modules = new ArrayList<>();
CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf);
modules.add(new ConfigModule(cConf, hConf));
modules.add(RemoteAuthenticatorModules.getDefaultModule());
modules.add(new LocalLocationModule());
modules.add(new IOModule());
modules.add(new AuthenticationContextModules().getMasterWorkerModule());
modules.add(coreSecurityModule);
modules.add(new MessagingClientModule());
modules.add(new SystemAppModule());
modules.add(new MetricsClientRuntimeModule().getDistributedModules());
// 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);
}
use of io.cdap.cdap.common.guice.LocalLocationModule in project cdap by caskdata.
the class ConfiguratorTask method run.
@Override
public void run(RunnableTaskContext context) throws Exception {
AppDeploymentInfo deploymentInfo = GSON.fromJson(context.getParam(), AppDeploymentInfo.class);
Injector injector = Guice.createInjector(new ConfigModule(cConf), RemoteAuthenticatorModules.getDefaultModule(), new LocalLocationModule(), new ConfiguratorTaskModule(), new AuthenticationContextModules().getMasterWorkerModule());
ConfigResponse result = injector.getInstance(ConfiguratorTaskRunner.class).configure(deploymentInfo);
AppSpecInfo appSpecInfo = result.getAppSpecInfo();
// If configuration succeeded and if only system artifacts are involved, no need to restart the task
if (result.getExitCode() == 0 && appSpecInfo != null && NamespaceId.SYSTEM.equals(deploymentInfo.getArtifactId().getNamespaceId())) {
boolean hasUserPlugins = appSpecInfo.getAppSpec().getPlugins().values().stream().map(Plugin::getArtifactId).map(ArtifactId::getScope).anyMatch(ArtifactScope.USER::equals);
context.setTerminateOnComplete(hasUserPlugins);
}
context.writeResult(GSON.toJson(result).getBytes(StandardCharsets.UTF_8));
}
use of io.cdap.cdap.common.guice.LocalLocationModule in project cdap by caskdata.
the class RuntimeClientServiceTest method beforeTest.
@Before
public void beforeTest() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.set(Constants.RuntimeMonitor.TOPICS_CONFIGS, TOPIC_CONFIGS_VALUE);
topicConfigs = RuntimeMonitors.createTopicConfigs(cConf);
InMemoryDiscoveryService discoveryService = new InMemoryDiscoveryService();
// Injector for the server side
Injector injector = Guice.createInjector(new ConfigModule(cConf), new LocalLocationModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), new RuntimeServerModule() {
@Override
protected void bindRequestValidator() {
bind(RuntimeRequestValidator.class).toInstance((programRunId, request) -> new ProgramRunInfo(ProgramRunStatus.COMPLETED, null));
}
@Override
protected void bindLogProcessor() {
bind(RemoteExecutionLogProcessor.class).toInstance(payloads -> {
});
}
}, new AbstractModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
bind(DiscoveryService.class).toInstance(discoveryService);
bind(DiscoveryServiceClient.class).toInstance(discoveryService);
}
});
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
runtimeServer = injector.getInstance(RuntimeServer.class);
runtimeServer.startAndWait();
// Injector for the client side
clientCConf = CConfiguration.create();
clientCConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
clientCConf.set(Constants.RuntimeMonitor.TOPICS_CONFIGS, TOPIC_CONFIGS_VALUE);
// Shorten the poll delay and grace period to speed up testing of program terminate state handling
clientCConf.setLong(Constants.RuntimeMonitor.POLL_TIME_MS, 200);
clientCConf.setLong(Constants.RuntimeMonitor.GRACEFUL_SHUTDOWN_MS, 3000);
// Use smaller batch size so that fetches is broken into multiple fetches
clientCConf.setInt(Constants.RuntimeMonitor.BATCH_SIZE, 1);
injector = Guice.createInjector(new ConfigModule(clientCConf), RemoteAuthenticatorModules.getNoOpModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), new AbstractModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
bind(DiscoveryService.class).toInstance(discoveryService);
bind(DiscoveryServiceClient.class).toInstance(discoveryService);
bind(ProgramRunId.class).toInstance(PROGRAM_RUN_ID);
}
});
clientMessagingService = injector.getInstance(MessagingService.class);
if (clientMessagingService instanceof Service) {
((Service) clientMessagingService).startAndWait();
}
runtimeClientService = injector.getInstance(RuntimeClientService.class);
runtimeClientService.startAndWait();
}
use of io.cdap.cdap.common.guice.LocalLocationModule in project cdap by caskdata.
the class SqlProgramScheduleStoreDatasetTest method setup.
@BeforeClass
public static void setup() throws IOException, TableAlreadyExistsException {
CConfiguration cConf = CConfiguration.create();
// any plugin which requires transaction will be excluded
cConf.set(Constants.REQUIREMENTS_DATASET_TYPE_EXCLUDE, Joiner.on(",").join(Table.TYPE, KeyValueTable.TYPE));
pg = PostgresInstantiator.createAndStart(cConf, TEMP_FOLDER.newFolder());
Injector injector = Guice.createInjector(new ConfigModule(cConf), new LocalLocationModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new StorageModule(), new AbstractModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
}
});
transactionRunner = injector.getInstance(TransactionRunner.class);
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
}
Aggregations