use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class H2ResourceGroupConfigurationManagerFactory method create.
@Override
public ResourceGroupConfigurationManager<VariableMap> create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(new JsonModule(), new H2ResourceGroupsModule(), new NodeModule(), new ReloadingResourceGroupConfigurationManagerModule(), binder -> binder.bind(ResourceGroupConfigurationManagerContext.class).toInstance(context), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).quiet().initialize();
return injector.getInstance(ReloadingResourceGroupConfigurationManager.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class TestProxyServer method setupServer.
@BeforeClass
public void setupServer() throws Exception {
byte[] sharedSecret = Base64.getMimeEncoder().encode("test secret".getBytes(US_ASCII));
sharedSecretFile = Files.createTempFile("secret", "txt");
Files.write(sharedSecretFile, sharedSecret);
Logging.initialize();
server = new TestingPrestoServer();
server.installPlugin(new TpchPlugin());
server.createCatalog("tpch", "tpch");
server.installPlugin(new BlackHolePlugin());
server.createCatalog("blackhole", "blackhole");
server.refreshNodes();
Bootstrap app = new Bootstrap(new TestingNodeModule("test"), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(true), new TestingJmxModule(), new ProxyModule());
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperty("proxy.uri", server.getBaseUrl().toString()).setRequiredConfigurationProperty("proxy.shared-secret-file", sharedSecretFile.toString()).quiet().initialize();
lifeCycleManager = injector.getInstance(LifeCycleManager.class);
httpServerInfo = injector.getInstance(HttpServerInfo.class);
executorService = newCachedThreadPool(daemonThreadsNamed("test-%s"));
setupTestTable();
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class PrestoProxy method start.
public static void start(Module... extraModules) {
Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new NodeModule()).add(new HttpServerModule()).add(new JsonModule()).add(new JaxrsModule(true)).add(new MBeanModule()).add(new JmxModule()).add(new LogJmxModule()).add(new TraceTokenModule()).add(new EventModule()).add(new ProxyModule()).add(extraModules).build());
Logger log = Logger.get(PrestoProxy.class);
try {
app.initialize();
log.info("======== SERVER STARTED ========");
} catch (Throwable t) {
log.error(t);
System.exit(1);
}
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class RaptorConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
NodeManager nodeManager = context.getNodeManager();
try {
Bootstrap app = new Bootstrap(new JsonModule(), new MBeanModule(), binder -> {
MBeanServer mbeanServer = new RebindSafeMBeanServer(getPlatformMBeanServer());
binder.bind(MBeanServer.class).toInstance(mbeanServer);
binder.bind(NodeManager.class).toInstance(nodeManager);
binder.bind(PageSorter.class).toInstance(context.getPageSorter());
binder.bind(TypeManager.class).toInstance(context.getTypeManager());
}, metadataModule, new FileSystemModule(fileSystemProviders), new BackupModule(backupProviders), new StorageModule(catalogName), new RaptorModule(catalogName), new RaptorSecurityModule(), new RaptorProcedureModule());
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(RaptorConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.json.JsonModule 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;
}
Aggregations