Search in sources :

Example 36 with JsonModule

use of com.facebook.airlift.json.JsonModule in project presto by prestodb.

the class SheetsConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    requireNonNull(config, "config is null");
    Bootstrap app = new Bootstrap(new JsonModule(), new SheetsModule(context.getTypeManager()));
    Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
    return injector.getInstance(SheetsConnector.class);
}
Also used : Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) JsonModule(com.facebook.airlift.json.JsonModule)

Example 37 with JsonModule

use of com.facebook.airlift.json.JsonModule in project presto by prestodb.

the class PinotConnectorFactory method create.

@Override
public Connector create(final String connectorId, Map<String, String> config, ConnectorContext context) {
    requireNonNull(connectorId, "connectorId is null");
    requireNonNull(config, "config is null");
    try {
        Bootstrap app = new Bootstrap(new JsonModule(), new MBeanModule(), new PinotModule(connectorId), binder -> {
            binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(getPlatformMBeanServer()));
            binder.bind(ConnectorId.class).toInstance(new ConnectorId(connectorId));
            binder.bind(TypeManager.class).toInstance(context.getTypeManager());
            binder.bind(FunctionMetadataManager.class).toInstance(context.getFunctionMetadataManager());
            binder.bind(NodeManager.class).toInstance(context.getNodeManager());
            binder.bind(RowExpressionService.class).toInstance(context.getRowExpressionService());
            binder.bind(LogicalRowExpressions.class).toInstance(new LogicalRowExpressions(context.getRowExpressionService().getDeterminismEvaluator(), context.getStandardFunctionResolution(), context.getFunctionMetadataManager()));
            binder.bind(StandardFunctionResolution.class).toInstance(context.getStandardFunctionResolution());
            binder.bind(PinotMetrics.class).in(Scopes.SINGLETON);
            newExporter(binder).export(PinotMetrics.class).as(generatedNameOf(PinotMetrics.class, connectorId));
            binder.bind(ConnectorNodePartitioningProvider.class).to(PinotNodePartitioningProvider.class).in(Scopes.SINGLETON);
        });
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(PinotConnector.class);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : MBeanModule(org.weakref.jmx.guice.MBeanModule) LogicalRowExpressions(com.facebook.presto.expressions.LogicalRowExpressions) JsonModule(com.facebook.airlift.json.JsonModule) FunctionMetadataManager(com.facebook.presto.spi.function.FunctionMetadataManager) NodeManager(com.facebook.presto.spi.NodeManager) RowExpressionService(com.facebook.presto.spi.relation.RowExpressionService) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) TypeManager(com.facebook.presto.common.type.TypeManager) StandardFunctionResolution(com.facebook.presto.spi.function.StandardFunctionResolution) ManagementFactory.getPlatformMBeanServer(java.lang.management.ManagementFactory.getPlatformMBeanServer) MBeanServer(javax.management.MBeanServer) ConnectorId(com.facebook.presto.spi.ConnectorId)

Example 38 with JsonModule

use of com.facebook.airlift.json.JsonModule in project presto by prestodb.

the class TestHttpBackupStore method setup.

@BeforeMethod
public void setup() throws Exception {
    temporary = createTempDir();
    Map<String, String> properties = ImmutableMap.<String, String>builder().put("backup.http.uri", "http://localhost:8080").build();
    Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(true), binder -> jaxrsBinder(binder).bind(TestingHttpBackupResource.class), override(new HttpBackupModule()).with(new TestingModule()));
    Injector injector = app.setRequiredConfigurationProperties(properties).doNotInitializeLogging().quiet().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    store = injector.getInstance(BackupStore.class);
}
Also used : TestingHttpServerModule(com.facebook.airlift.http.server.testing.TestingHttpServerModule) TestingNodeModule(com.facebook.airlift.node.testing.TestingNodeModule) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) JsonModule(com.facebook.airlift.json.JsonModule) LifeCycleManager(com.facebook.airlift.bootstrap.LifeCycleManager) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

JsonModule (com.facebook.airlift.json.JsonModule)38 Injector (com.google.inject.Injector)37 Bootstrap (com.facebook.airlift.bootstrap.Bootstrap)36 TypeManager (com.facebook.presto.common.type.TypeManager)15 Module (com.google.inject.Module)10 NodeManager (com.facebook.presto.spi.NodeManager)8 JsonBinder.jsonBinder (com.facebook.airlift.json.JsonBinder.jsonBinder)7 FeaturesConfig (com.facebook.presto.sql.analyzer.FeaturesConfig)7 ImmutableList (com.google.common.collect.ImmutableList)7 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)6 JsonCodecBinder.jsonCodecBinder (com.facebook.airlift.json.JsonCodecBinder.jsonCodecBinder)6 Type (com.facebook.presto.common.type.Type)6 FunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager)6 FunctionAndTypeManager.createTestFunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager)6 HandleJsonModule (com.facebook.presto.metadata.HandleJsonModule)6 TypeDeserializer (com.facebook.presto.type.TypeDeserializer)6 Multibinder.newSetBinder (com.google.inject.multibindings.Multibinder.newSetBinder)6 Map (java.util.Map)6 Test (org.testng.annotations.Test)6 MBeanModule (org.weakref.jmx.guice.MBeanModule)6