use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class KuduConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
requireNonNull(config, "config is null");
try {
Bootstrap app = new Bootstrap(new JsonModule(), new KuduModule(catalogName, context.getTypeManager()));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(KuduConnector.class);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class AccumuloConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
requireNonNull(catalogName, "catalogName is null");
requireNonNull(config, "requiredConfig is null");
requireNonNull(context, "context is null");
try {
// A plugin is not required to use Guice; it is just very convenient
// Unless you don't really know how to Guice, then it is less convenient
Bootstrap app = new Bootstrap(new JsonModule(), new AccumuloModule(catalogName, context.getTypeManager()));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(AccumuloConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class DruidConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
requireNonNull(config, "config is null");
try {
Bootstrap app = new Bootstrap(new JsonModule(), new DruidModule(), new DruidAuthenticationModule(), binder -> {
binder.bind(TypeManager.class).toInstance(context.getTypeManager());
binder.bind(FunctionMetadataManager.class).toInstance(context.getFunctionMetadataManager());
binder.bind(RowExpressionService.class).toInstance(context.getRowExpressionService());
binder.bind(StandardFunctionResolution.class).toInstance(context.getStandardFunctionResolution());
binder.bind(DeterminismEvaluator.class).toInstance(context.getRowExpressionService().getDeterminismEvaluator());
});
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(DruidConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class TestHttpRemoteTask method createHttpRemoteTaskFactory.
private static HttpRemoteTaskFactory createHttpRemoteTaskFactory(TestingTaskResource testingTaskResource, boolean useThriftEncoding) throws Exception {
Bootstrap app = new Bootstrap(new JsonModule(), new SmileModule(), new ThriftCodecModule(), new HandleJsonModule(), new Module() {
@Override
public void configure(Binder binder) {
binder.bind(JsonMapper.class);
binder.bind(ThriftMapper.class);
configBinder(binder).bindConfig(FeaturesConfig.class);
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
binder.bind(TypeManager.class).toInstance(functionAndTypeManager);
jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
newSetBinder(binder, Type.class);
smileCodecBinder(binder).bindSmileCodec(TaskStatus.class);
smileCodecBinder(binder).bindSmileCodec(TaskInfo.class);
smileCodecBinder(binder).bindSmileCodec(TaskUpdateRequest.class);
smileCodecBinder(binder).bindSmileCodec(PlanFragment.class);
smileCodecBinder(binder).bindSmileCodec(MetadataUpdates.class);
jsonCodecBinder(binder).bindJsonCodec(TaskStatus.class);
jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class);
jsonCodecBinder(binder).bindJsonCodec(TaskUpdateRequest.class);
jsonCodecBinder(binder).bindJsonCodec(PlanFragment.class);
jsonCodecBinder(binder).bindJsonCodec(MetadataUpdates.class);
jsonBinder(binder).addKeySerializerBinding(VariableReferenceExpression.class).to(Serialization.VariableReferenceExpressionSerializer.class);
jsonBinder(binder).addKeyDeserializerBinding(VariableReferenceExpression.class).to(Serialization.VariableReferenceExpressionDeserializer.class);
thriftCodecBinder(binder).bindThriftCodec(TaskStatus.class);
}
@Provides
private HttpRemoteTaskFactory createHttpRemoteTaskFactory(JsonMapper jsonMapper, ThriftMapper thriftMapper, JsonCodec<TaskStatus> taskStatusJsonCodec, SmileCodec<TaskStatus> taskStatusSmileCodec, ThriftCodec<TaskStatus> taskStatusThriftCodec, JsonCodec<TaskInfo> taskInfoJsonCodec, SmileCodec<TaskInfo> taskInfoSmileCodec, JsonCodec<TaskUpdateRequest> taskUpdateRequestJsonCodec, SmileCodec<TaskUpdateRequest> taskUpdateRequestSmileCodec, JsonCodec<PlanFragment> planFragmentJsonCodec, SmileCodec<PlanFragment> planFragmentSmileCodec, JsonCodec<MetadataUpdates> metadataUpdatesJsonCodec, SmileCodec<MetadataUpdates> metadataUpdatesSmileCodec) {
JaxrsTestingHttpProcessor jaxrsTestingHttpProcessor = new JaxrsTestingHttpProcessor(URI.create("http://fake.invalid/"), testingTaskResource, jsonMapper, thriftMapper);
TestingHttpClient testingHttpClient = new TestingHttpClient(jaxrsTestingHttpProcessor.setTrace(TRACE_HTTP));
testingTaskResource.setHttpClient(testingHttpClient);
return new HttpRemoteTaskFactory(new QueryManagerConfig(), TASK_MANAGER_CONFIG, testingHttpClient, new TestSqlTaskManager.MockLocationFactory(), taskStatusJsonCodec, taskStatusSmileCodec, taskStatusThriftCodec, taskInfoJsonCodec, taskInfoSmileCodec, taskUpdateRequestJsonCodec, taskUpdateRequestSmileCodec, planFragmentJsonCodec, planFragmentSmileCodec, metadataUpdatesJsonCodec, metadataUpdatesSmileCodec, new RemoteTaskStats(), new InternalCommunicationConfig().setThriftTransportEnabled(useThriftEncoding), createTestMetadataManager(), new TestQueryManager());
}
});
Injector injector = app.doNotInitializeLogging().quiet().initialize();
HandleResolver handleResolver = injector.getInstance(HandleResolver.class);
handleResolver.addConnectorName("test", new TestingHandleResolver());
return injector.getInstance(HttpRemoteTaskFactory.class);
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class TestRowExpressionSerde method getJsonCodec.
private JsonCodec<RowExpression> getJsonCodec() throws Exception {
Module module = binder -> {
binder.install(new JsonModule());
binder.install(new HandleJsonModule());
configBinder(binder).bindConfig(FeaturesConfig.class);
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
binder.bind(TypeManager.class).toInstance(functionAndTypeManager);
jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
newSetBinder(binder, Type.class);
binder.bind(BlockEncodingSerde.class).to(BlockEncodingManager.class).in(Scopes.SINGLETON);
newSetBinder(binder, BlockEncoding.class);
jsonBinder(binder).addSerializerBinding(Block.class).to(BlockJsonSerde.Serializer.class);
jsonBinder(binder).addDeserializerBinding(Block.class).to(BlockJsonSerde.Deserializer.class);
jsonCodecBinder(binder).bindJsonCodec(RowExpression.class);
};
Bootstrap app = new Bootstrap(ImmutableList.of(module));
Injector injector = app.doNotInitializeLogging().quiet().initialize();
return injector.getInstance(new Key<JsonCodec<RowExpression>>() {
});
}
Aggregations