use of io.cdap.cdap.metadata.MetadataReaderWriterModules in project cdap by caskdata.
the class PreviewRunnerTwillRunnable method createInjector.
@VisibleForTesting
static Injector createInjector(CConfiguration cConf, Configuration hConf, PreviewRequestPollerInfo pollerInfo) {
List<Module> modules = new ArrayList<>();
byte[] pollerInfoBytes = Bytes.toBytes(new Gson().toJson(pollerInfo));
SConfiguration sConf = SConfiguration.create();
modules.add(new ConfigModule(cConf, hConf, sConf));
modules.add(RemoteAuthenticatorModules.getDefaultModule());
modules.add(new PreviewConfigModule(cConf, hConf, sConf));
modules.add(new IOModule());
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());
}
modules.add(new PreviewRunnerManagerModule().getDistributedModules());
modules.add(new DataSetServiceModules().getStandaloneModules());
modules.add(new DataSetsModules().getStandaloneModules());
modules.add(new AppFabricServiceRuntimeModule(cConf).getStandaloneModules());
modules.add(new ProgramRunnerRuntimeModule().getStandaloneModules());
modules.add(new MetricsStoreModule());
modules.add(new MessagingClientModule());
modules.add(new AuditModule());
modules.add(new SecureStoreClientModule());
modules.add(new MetadataReaderWriterModules().getStandaloneModules());
modules.add(new DFSLocationModule());
modules.add(new MetadataServiceModule());
modules.add(new CoreSecurityRuntimeModule().getInMemoryModules());
modules.add(new AuthenticationContextModules().getMasterWorkerModule());
modules.add(new AuthorizationModule());
modules.add(new AuthorizationEnforcementModule().getNoOpModules());
modules.add(Modules.override(new DataFabricModules("master").getDistributedModules()).with(new AbstractModule() {
@Override
protected void configure() {
// Bind transaction system to a constant one, basically no transaction, with every write become
// visible immediately.
// TODO: Ideally we shouldn't need this at all. However, it is needed now to satisfy dependencies
bind(TransactionSystemClientService.class).to(DelegatingTransactionSystemClientService.class);
bind(TransactionSystemClient.class).to(ConstantTransactionSystemClient.class);
bind(ExploreClient.class).to(UnsupportedExploreClient.class);
bind(PreviewRequestPollerInfoProvider.class).toInstance(() -> pollerInfoBytes);
}
}));
return Guice.createInjector(modules);
}
use of io.cdap.cdap.metadata.MetadataReaderWriterModules in project cdap by caskdata.
the class DistributedProgramContainerModule method getCoreModules.
private List<Module> getCoreModules() {
Arguments systemArgs = programOpts.getArguments();
ClusterMode clusterMode = systemArgs.hasOption(ProgramOptionConstants.CLUSTER_MODE) ? ClusterMode.valueOf(systemArgs.getOption(ProgramOptionConstants.CLUSTER_MODE)) : ClusterMode.ON_PREMISE;
List<Module> modules = new ArrayList<>();
modules.add(new ConfigModule(cConf, hConf));
modules.add(new IOModule());
modules.add(new DFSLocationModule());
modules.add(new MetricsClientRuntimeModule().getDistributedModules());
modules.add(new MessagingClientModule());
modules.add(new AuditModule());
modules.add(new AuthorizationEnforcementModule().getDistributedModules());
modules.add(new SecureStoreClientModule());
modules.add(new MetadataReaderWriterModules().getDistributedModules());
modules.add(new NamespaceQueryAdminModule());
modules.add(new DataSetsModules().getDistributedModules());
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(ProgramStateWriter.class).to(MessagingProgramStateWriter.class);
bind(WorkflowStateWriter.class).to(MessagingWorkflowStateWriter.class);
// don't need to perform any impersonation from within user programs
bind(UGIProvider.class).to(CurrentUGIProvider.class).in(Scopes.SINGLETON);
// Bind ProgramId to the passed in instance programId so that we can retrieve it back later when needed.
// For example see ProgramDiscoveryExploreClient.
// Also binding to instance is fine here as the programId is guaranteed to not change throughout the
// lifecycle of this program runnable
bind(ProgramId.class).toInstance(programRunId.getParent());
bind(ProgramRunId.class).toInstance(programRunId);
if (serviceAnnouncer != null) {
bind(ServiceAnnouncer.class).toInstance(serviceAnnouncer);
}
bind(PreferencesFetcher.class).to(RemotePreferencesFetcherInternal.class).in(Scopes.SINGLETON);
}
});
addDataFabricModules(modules);
switch(clusterMode) {
case ON_PREMISE:
addOnPremiseModules(modules);
break;
case ISOLATED:
addIsolatedModules(modules);
break;
default:
}
return modules;
}
use of io.cdap.cdap.metadata.MetadataReaderWriterModules in project cdap by caskdata.
the class AppFabricTestModule method configure.
@Override
protected void configure() {
install(new DataFabricModules().getInMemoryModules());
install(new DataSetsModules().getStandaloneModules());
install(new TransactionExecutorModule());
install(new DataSetServiceModules().getInMemoryModules());
install(new ConfigModule(cConf, hConf, sConf));
install(RemoteAuthenticatorModules.getNoOpModule());
install(new IOModule());
install(new InMemoryDiscoveryModule());
install(new AppFabricServiceRuntimeModule(cConf).getInMemoryModules());
install(new MonitorHandlerModule(false));
install(new ProgramRunnerRuntimeModule().getInMemoryModules());
install(new NonCustomLocationUnitTestModule());
install(new LocalLogAppenderModule());
install(new LogReaderRuntimeModules().getInMemoryModules());
install(new LogQueryRuntimeModule().getInMemoryModules());
install(new MetricsHandlerModule());
install(new MetricsClientRuntimeModule().getInMemoryModules());
install(new ExploreClientModule());
install(new ConfigStoreModule());
install(new MetadataServiceModule());
install(new AuthenticationContextModules().getMasterModule());
install(new AuthorizationModule());
install(new AuthorizationEnforcementModule().getStandaloneModules());
install(new SecureStoreServerModule());
install(new MetadataReaderWriterModules().getInMemoryModules());
install(new MessagingServerRuntimeModule().getInMemoryModules());
install(new MockProvisionerModule());
// Needed by MonitorHandlerModuler
bind(TwillRunner.class).to(NoopTwillRunnerService.class);
}
use of io.cdap.cdap.metadata.MetadataReaderWriterModules in project cdap by caskdata.
the class TestBase method initialize.
@BeforeClass
public static void initialize() throws Exception {
if (nestedStartCount++ > 0) {
return;
}
File localDataDir = TMP_FOLDER.newFolder();
cConf = createCConf(localDataDir);
CConfiguration previewCConf = createPreviewConf(cConf);
LevelDBTableService previewLevelDBTableService = new LevelDBTableService();
previewLevelDBTableService.setConfiguration(previewCConf);
// enable default services
File capabilityFolder = new File(localDataDir.toString(), "capability");
capabilityFolder.mkdir();
cConf.set(Constants.Capability.CONFIG_DIR, capabilityFolder.getAbsolutePath());
cConf.setInt(Constants.Capability.AUTO_INSTALL_THREADS, 5);
org.apache.hadoop.conf.Configuration hConf = new org.apache.hadoop.conf.Configuration();
hConf.addResource("mapred-site-local.xml");
hConf.reloadConfiguration();
hConf.set(Constants.CFG_LOCAL_DATA_DIR, localDataDir.getAbsolutePath());
hConf.set(Constants.AppFabric.OUTPUT_DIR, cConf.get(Constants.AppFabric.OUTPUT_DIR));
hConf.set("hadoop.tmp.dir", new File(localDataDir, cConf.get(Constants.AppFabric.TEMP_DIR)).getAbsolutePath());
// Windows specific requirements
if (OSDetector.isWindows()) {
File tmpDir = TMP_FOLDER.newFolder();
File binDir = new File(tmpDir, "bin");
Assert.assertTrue(binDir.mkdirs());
copyTempFile("hadoop.dll", tmpDir);
copyTempFile("winutils.exe", binDir);
System.setProperty("hadoop.home.dir", tmpDir.getAbsolutePath());
System.load(new File(tmpDir, "hadoop.dll").getAbsolutePath());
}
injector = Guice.createInjector(createDataFabricModule(), new TransactionExecutorModule(), new DataSetsModules().getStandaloneModules(), new DataSetServiceModules().getInMemoryModules(), new ConfigModule(cConf, hConf), RemoteAuthenticatorModules.getNoOpModule(), new IOModule(), new LocalLocationModule(), new InMemoryDiscoveryModule(), new AppFabricServiceRuntimeModule(cConf).getInMemoryModules(), new MonitorHandlerModule(false), new AuthenticationContextModules().getMasterModule(), new AuthorizationModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new ProgramRunnerRuntimeModule().getInMemoryModules(), new SecureStoreServerModule(), new MetadataReaderWriterModules().getInMemoryModules(), new MetadataServiceModule(), new AbstractModule() {
@Override
protected void configure() {
bind(MetricsManager.class).toProvider(MetricsManagerProvider.class);
}
}, new MetricsClientRuntimeModule().getInMemoryModules(), new LocalLogAppenderModule(), new LogReaderRuntimeModules().getInMemoryModules(), new ExploreRuntimeModule().getInMemoryModules(), new ExploreClientModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new PreviewConfigModule(cConf, new Configuration(), SConfiguration.create()), new PreviewManagerModule(false), new PreviewRunnerManagerModule().getInMemoryModules(), new SupportBundleServiceModule(), new MockProvisionerModule(), new AbstractModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(ApplicationManager.class, DefaultApplicationManager.class).build(ApplicationManagerFactory.class));
install(new FactoryModuleBuilder().implement(ArtifactManager.class, DefaultArtifactManager.class).build(ArtifactManagerFactory.class));
bind(TemporaryFolder.class).toInstance(TMP_FOLDER);
bind(AuthorizationHandler.class).in(Scopes.SINGLETON);
// Needed by MonitorHandlerModuler
bind(TwillRunner.class).to(NoopTwillRunnerService.class);
bind(MetadataSubscriberService.class).in(Scopes.SINGLETON);
}
});
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
txService = injector.getInstance(TransactionManager.class);
txService.startAndWait();
metadataSubscriberService = injector.getInstance(MetadataSubscriberService.class);
metadataStorage = injector.getInstance(MetadataStorage.class);
metadataAdmin = injector.getInstance(MetadataAdmin.class);
metadataStorage.createIndex();
metadataService = injector.getInstance(MetadataService.class);
metadataService.startAndWait();
// Define all StructuredTable before starting any services that need StructuredTable
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
dsOpService = injector.getInstance(DatasetOpExecutorService.class);
dsOpService.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
metricsCollectionService.startAndWait();
if (cConf.getBoolean(Constants.Explore.EXPLORE_ENABLED)) {
exploreExecutorService = injector.getInstance(ExploreExecutorService.class);
exploreExecutorService.startAndWait();
// wait for explore service to be discoverable
DiscoveryServiceClient discoveryService = injector.getInstance(DiscoveryServiceClient.class);
EndpointStrategy endpointStrategy = new RandomEndpointStrategy(() -> discoveryService.discover(Constants.Service.EXPLORE_HTTP_USER_SERVICE));
Preconditions.checkNotNull(endpointStrategy.pick(5, TimeUnit.SECONDS), "%s service is not up after 5 seconds", Constants.Service.EXPLORE_HTTP_USER_SERVICE);
exploreClient = injector.getInstance(ExploreClient.class);
}
programScheduler = injector.getInstance(Scheduler.class);
if (programScheduler instanceof Service) {
((Service) programScheduler).startAndWait();
}
testManager = injector.getInstance(UnitTestManager.class);
metricsManager = injector.getInstance(MetricsManager.class);
accessControllerInstantiator = injector.getInstance(AccessControllerInstantiator.class);
// This is needed so the logged-in user can successfully create the default namespace
if (cConf.getBoolean(Constants.Security.Authorization.ENABLED)) {
String user = System.getProperty("user.name");
SecurityRequestContext.setUserId(user);
InstanceId instance = new InstanceId(cConf.get(Constants.INSTANCE_NAME));
Principal principal = new Principal(user, Principal.PrincipalType.USER);
accessControllerInstantiator.get().grant(Authorizable.fromEntityId(instance), principal, EnumSet.allOf(StandardPermission.class));
accessControllerInstantiator.get().grant(Authorizable.fromEntityId(NamespaceId.DEFAULT), principal, EnumSet.allOf(StandardPermission.class));
}
namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
if (firstInit) {
// only create the default namespace on first test. if multiple tests are run in the same JVM,
// then any time after the first time, the default namespace already exists. That is because
// the namespaceAdmin.delete(Id.Namespace.DEFAULT) in finish() only clears the default namespace
// but does not remove it entirely
namespaceAdmin.create(NamespaceMeta.DEFAULT);
ProfileService profileService = injector.getInstance(ProfileService.class);
profileService.saveProfile(ProfileId.NATIVE, Profile.NATIVE);
}
secureStore = injector.getInstance(SecureStore.class);
secureStoreManager = injector.getInstance(SecureStoreManager.class);
messagingContext = new MultiThreadMessagingContext(messagingService);
firstInit = false;
previewHttpServer = injector.getInstance(PreviewHttpServer.class);
previewHttpServer.startAndWait();
fieldLineageAdmin = injector.getInstance(FieldLineageAdmin.class);
lineageAdmin = injector.getInstance(LineageAdmin.class);
metadataSubscriberService.startAndWait();
previewRunnerManager = injector.getInstance(PreviewRunnerManager.class);
if (previewRunnerManager instanceof Service) {
((Service) previewRunnerManager).startAndWait();
}
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
preferencesService = injector.getInstance(PreferencesService.class);
scheduler = injector.getInstance(Scheduler.class);
if (scheduler instanceof Service) {
((Service) scheduler).startAndWait();
}
if (scheduler instanceof CoreSchedulerService) {
((CoreSchedulerService) scheduler).waitUntilFunctional(10, TimeUnit.SECONDS);
}
supportBundleInternalService = injector.getInstance(SupportBundleInternalService.class);
supportBundleInternalService.startAndWait();
appFabricHealthCheckService = injector.getInstance(HealthCheckService.class);
appFabricHealthCheckService.helper(Constants.AppFabricHealthCheck.APP_FABRIC_HEALTH_CHECK_SERVICE, cConf, Constants.Service.MASTER_SERVICES_BIND_ADDRESS);
appFabricHealthCheckService.startAndWait();
}
use of io.cdap.cdap.metadata.MetadataReaderWriterModules in project cdap by caskdata.
the class StandaloneMain method createPersistentModules.
private static List<Module> createPersistentModules(CConfiguration cConf, Configuration hConf) {
cConf.setInt(Constants.Master.MAX_INSTANCES, 1);
cConf.setIfUnset(Constants.CFG_DATA_LEVELDB_DIR, Constants.DEFAULT_DATA_LEVELDB_DIR);
cConf.set(Constants.CFG_DATA_INMEMORY_PERSISTENCE, Constants.InMemoryPersistenceType.LEVELDB.name());
// configure all services except for router and auth to bind to 127.0.0.1
String localhost = InetAddress.getLoopbackAddress().getHostAddress();
cConf.set(Constants.Service.MASTER_SERVICES_BIND_ADDRESS, localhost);
cConf.set(Constants.MessagingSystem.HTTP_SERVER_BIND_ADDRESS, localhost);
cConf.set(Constants.Transaction.Container.ADDRESS, localhost);
cConf.set(Constants.Dataset.Executor.ADDRESS, localhost);
cConf.set(Constants.Metrics.ADDRESS, localhost);
cConf.set(Constants.MetricsProcessor.BIND_ADDRESS, localhost);
cConf.set(Constants.LogSaver.ADDRESS, localhost);
cConf.set(Constants.LogQuery.ADDRESS, localhost);
cConf.set(Constants.Explore.SERVER_ADDRESS, localhost);
cConf.set(Constants.Metadata.SERVICE_BIND_ADDRESS, localhost);
cConf.set(Constants.Preview.ADDRESS, localhost);
cConf.set(Constants.SupportBundle.SERVICE_BIND_ADDRESS, localhost);
return ImmutableList.of(new ConfigModule(cConf, hConf), RemoteAuthenticatorModules.getDefaultModule(), new IOModule(), new ZKClientModule(), new KafkaClientModule(), new MetricsHandlerModule(), new LogQueryRuntimeModule().getStandaloneModules(), new InMemoryDiscoveryModule(), new LocalLocationModule(), new ProgramRunnerRuntimeModule().getStandaloneModules(), new DataFabricModules(StandaloneMain.class.getName()).getStandaloneModules(), new DataSetsModules().getStandaloneModules(), new DataSetServiceModules().getStandaloneModules(), new MetricsClientRuntimeModule().getStandaloneModules(), new LocalLogAppenderModule(), new LogReaderRuntimeModules().getStandaloneModules(), new RouterModules().getStandaloneModules(), new CoreSecurityRuntimeModule().getStandaloneModules(), new ExternalAuthenticationModule(), new SecureStoreServerModule(), new ExploreRuntimeModule().getStandaloneModules(), new ExploreClientModule(), new MetadataServiceModule(), new MetadataReaderWriterModules().getStandaloneModules(), new AuditModule(), new AuthenticationContextModules().getMasterModule(), new AuthorizationModule(), new AuthorizationEnforcementModule().getStandaloneModules(), new PreviewConfigModule(cConf, new Configuration(), SConfiguration.create()), new PreviewManagerModule(false), new PreviewRunnerManagerModule().getStandaloneModules(), new MessagingServerRuntimeModule().getStandaloneModules(), new AppFabricServiceRuntimeModule(cConf).getStandaloneModules(), new MonitorHandlerModule(false), new RuntimeServerModule(), new OperationalStatsModule(), new MetricsWriterModule(), new SupportBundleServiceModule(), new AbstractModule() {
@Override
protected void configure() {
// Needed by MonitorHandlerModuler
bind(TwillRunner.class).to(NoopTwillRunnerService.class);
bind(HealthCheckService.class).in(Scopes.SINGLETON);
}
});
}
Aggregations