use of com.facebook.presto.security.AccessControlModule in project presto by prestodb.
the class PrestoSparkInjectorFactory method create.
public Injector create() {
// TODO: migrate docker containers to a newer JVM, then re-enable it
// verifyJvmRequirements();
verifySystemTimeIsReasonable();
ImmutableList.Builder<Module> modules = ImmutableList.builder();
modules.add(new JsonModule(), new SmileModule(), new EventListenerModule(), new PrestoSparkModule(sparkProcessType, sqlParserOptions), new WarningCollectorModule());
if (isForTesting) {
modules.add(binder -> {
binder.bind(TestingAccessControlManager.class).in(Scopes.SINGLETON);
binder.bind(AccessControlManager.class).to(TestingAccessControlManager.class).in(Scopes.SINGLETON);
binder.bind(AccessControl.class).to(AccessControlManager.class).in(Scopes.SINGLETON);
binder.bind(TestingTempStorageManager.class).in(Scopes.SINGLETON);
binder.bind(TempStorageManager.class).to(TestingTempStorageManager.class).in(Scopes.SINGLETON);
newSetBinder(binder, PrestoSparkServiceWaitTimeMetrics.class).addBinding().to(PrestoSparkTestingServiceWaitTimeMetrics.class).in(Scopes.SINGLETON);
});
} else {
modules.add(new AccessControlModule());
modules.add(new TempStorageModule());
}
modules.addAll(additionalModules);
Bootstrap app = new Bootstrap(modules.build());
// Stream redirect doesn't work well with spark logging
app.doNotInitializeLogging();
Map<String, String> requiredProperties = new HashMap<>();
requiredProperties.put("node.environment", "spark");
requiredProperties.putAll(configProperties);
app.setRequiredConfigurationProperties(ImmutableMap.copyOf(requiredProperties));
Injector injector = app.initialize();
try {
injector.getInstance(PluginManager.class).loadPlugins();
injector.getInstance(StaticCatalogStore.class).loadCatalogs(catalogProperties);
injector.getInstance(ResourceGroupManager.class).loadConfigurationManager();
injector.getInstance(PasswordAuthenticatorManager.class).loadPasswordAuthenticator();
eventListenerProperties.ifPresent(properties -> injector.getInstance(EventListenerManager.class).loadConfiguredEventListener(properties));
if (!isForTesting) {
if (accessControlProperties.isPresent()) {
injector.getInstance(AccessControlManager.class).loadSystemAccessControl(accessControlProperties.get());
} else {
injector.getInstance(AccessControlManager.class).loadSystemAccessControl();
}
if (tempStorageProperties.isPresent()) {
injector.getInstance(TempStorageManager.class).loadTempStorages(tempStorageProperties.get());
} else {
injector.getInstance(TempStorageManager.class).loadTempStorages();
}
}
if ((sparkProcessType.equals(DRIVER))) {
if (sessionPropertyConfigurationProperties.isPresent()) {
injector.getInstance(SessionPropertyDefaults.class).loadConfigurationManager(sessionPropertyConfigurationProperties.get());
} else {
injector.getInstance(SessionPropertyDefaults.class).loadConfigurationManager();
}
}
if (sparkProcessType.equals(DRIVER) || !injector.getInstance(FeaturesConfig.class).isInlineSqlFunctions()) {
if (functionNamespaceProperties.isPresent()) {
injector.getInstance(StaticFunctionNamespaceStore.class).loadFunctionNamespaceManagers(functionNamespaceProperties.get());
} else {
injector.getInstance(StaticFunctionNamespaceStore.class).loadFunctionNamespaceManagers();
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return injector;
}
use of com.facebook.presto.security.AccessControlModule in project presto by prestodb.
the class PrestoServer method run.
@Override
public void run() {
verifyJvmRequirements();
verifySystemTimeIsReasonable();
Logger log = Logger.get(PrestoServer.class);
ImmutableList.Builder<Module> modules = ImmutableList.builder();
modules.add(new NodeModule(), new DiscoveryModule(), new HttpServerModule(), new JsonModule(), installModuleIf(FeaturesConfig.class, FeaturesConfig::isJsonSerdeCodeGenerationEnabled, binder -> jsonBinder(binder).addModuleBinding().to(AfterburnerModule.class)), new SmileModule(), new JaxrsModule(true), new MBeanModule(), new JmxModule(), new JmxHttpModule(), new LogJmxModule(), new TraceTokenModule(), new JsonEventModule(), new HttpEventModule(), new ServerSecurityModule(), new AccessControlModule(), new EventListenerModule(), new ServerMainModule(sqlParserOptions), new GracefulShutdownModule(), new WarningCollectorModule(), new TempStorageModule(), new QueryPrerequisitesManagerModule(), new NodeTtlFetcherManagerModule(), new ClusterTtlProviderManagerModule());
modules.addAll(getAdditionalModules());
Bootstrap app = new Bootstrap(modules.build());
try {
Injector injector = app.initialize();
injector.getInstance(PluginManager.class).loadPlugins();
ServerConfig serverConfig = injector.getInstance(ServerConfig.class);
if (!serverConfig.isResourceManager()) {
injector.getInstance(StaticCatalogStore.class).loadCatalogs();
}
// TODO: remove this huge hack
updateConnectorIds(injector.getInstance(Announcer.class), injector.getInstance(CatalogManager.class), injector.getInstance(ServerConfig.class), injector.getInstance(NodeSchedulerConfig.class));
// TODO: thrift server port should be announced by discovery server similar to http/https ports
updateThriftServerPort(injector.getInstance(Announcer.class), injector.getInstance(DriftServer.class));
injector.getInstance(StaticFunctionNamespaceStore.class).loadFunctionNamespaceManagers();
injector.getInstance(SessionPropertyDefaults.class).loadConfigurationManager();
injector.getInstance(ResourceGroupManager.class).loadConfigurationManager();
if (!serverConfig.isResourceManager()) {
injector.getInstance(AccessControlManager.class).loadSystemAccessControl();
}
injector.getInstance(PasswordAuthenticatorManager.class).loadPasswordAuthenticator();
injector.getInstance(EventListenerManager.class).loadConfiguredEventListener();
injector.getInstance(TempStorageManager.class).loadTempStorages();
injector.getInstance(QueryPrerequisitesManager.class).loadQueryPrerequisites();
injector.getInstance(NodeTtlFetcherManager.class).loadNodeTtlFetcher();
injector.getInstance(ClusterTtlProviderManager.class).loadClusterTtlProvider();
injector.getInstance(Announcer.class).start();
log.info("======== SERVER STARTED ========");
} catch (Throwable e) {
log.error(e);
System.exit(1);
}
}
Aggregations