use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class PrestoSparkModule method setup.
@Override
protected void setup(Binder binder) {
// configs
// TODO: decouple configuration properties that don't make sense on Spark
configBinder(binder).bindConfig(NodeSchedulerConfig.class);
configBinder(binder).bindConfig(SimpleTtlNodeSelectorConfig.class);
configBinder(binder).bindConfig(QueryManagerConfig.class);
configBinder(binder).bindConfigGlobalDefaults(QueryManagerConfig.class, PrestoSparkSettingsRequirements::setDefaults);
configBinder(binder).bindConfig(FeaturesConfig.class);
configBinder(binder).bindConfigGlobalDefaults(FeaturesConfig.class, PrestoSparkSettingsRequirements::setDefaults);
configBinder(binder).bindConfig(MemoryManagerConfig.class);
configBinder(binder).bindConfig(TaskManagerConfig.class);
configBinder(binder).bindConfig(TransactionManagerConfig.class);
configBinder(binder).bindConfig(NodeMemoryConfig.class);
configBinder(binder).bindConfig(WarningCollectorConfig.class);
configBinder(binder).bindConfig(NodeSpillConfig.class);
configBinder(binder).bindConfig(CompilerConfig.class);
configBinder(binder).bindConfig(SqlEnvironmentConfig.class);
configBinder(binder).bindConfig(StaticFunctionNamespaceStoreConfig.class);
configBinder(binder).bindConfig(PrestoSparkConfig.class);
configBinder(binder).bindConfig(TracingConfig.class);
// json codecs
jsonCodecBinder(binder).bindJsonCodec(ViewDefinition.class);
jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class);
jsonCodecBinder(binder).bindJsonCodec(PrestoSparkTaskDescriptor.class);
jsonCodecBinder(binder).bindJsonCodec(PlanFragment.class);
jsonCodecBinder(binder).bindJsonCodec(TaskSource.class);
jsonCodecBinder(binder).bindJsonCodec(TableCommitContext.class);
jsonCodecBinder(binder).bindJsonCodec(ExplainAnalyzeContext.class);
jsonCodecBinder(binder).bindJsonCodec(ExecutionFailureInfo.class);
jsonCodecBinder(binder).bindJsonCodec(StageInfo.class);
jsonCodecBinder(binder).bindJsonCodec(OperatorStats.class);
jsonCodecBinder(binder).bindJsonCodec(QueryInfo.class);
jsonCodecBinder(binder).bindJsonCodec(PrestoSparkQueryStatusInfo.class);
jsonCodecBinder(binder).bindJsonCodec(PrestoSparkQueryData.class);
jsonCodecBinder(binder).bindListJsonCodec(TaskMemoryReservationSummary.class);
// smile codecs
smileCodecBinder(binder).bindSmileCodec(TaskSource.class);
smileCodecBinder(binder).bindSmileCodec(TaskInfo.class);
PrestoSparkConfig prestoSparkConfig = buildConfigObject(PrestoSparkConfig.class);
if (prestoSparkConfig.isSmileSerializationEnabled()) {
binder.bind(new TypeLiteral<Codec<TaskSource>>() {
}).to(new TypeLiteral<SmileCodec<TaskSource>>() {
}).in(Scopes.SINGLETON);
binder.bind(new TypeLiteral<Codec<TaskInfo>>() {
}).to(new TypeLiteral<SmileCodec<TaskInfo>>() {
}).in(Scopes.SINGLETON);
} else {
binder.bind(new TypeLiteral<Codec<TaskSource>>() {
}).to(new TypeLiteral<JsonCodec<TaskSource>>() {
}).in(Scopes.SINGLETON);
binder.bind(new TypeLiteral<Codec<TaskInfo>>() {
}).to(new TypeLiteral<JsonCodec<TaskInfo>>() {
}).in(Scopes.SINGLETON);
}
// index manager
binder.bind(IndexManager.class).in(Scopes.SINGLETON);
// handle resolver
binder.install(new HandleJsonModule());
// plugin manager
configBinder(binder).bindConfig(PluginManagerConfig.class);
binder.bind(PluginManager.class).in(Scopes.SINGLETON);
// catalog manager
binder.bind(StaticCatalogStore.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(StaticCatalogStoreConfig.class);
// catalog
binder.bind(ConnectorManager.class).in(Scopes.SINGLETON);
binder.bind(CatalogManager.class).in(Scopes.SINGLETON);
// property managers
binder.bind(SessionPropertyManager.class).toProvider(PrestoSparkSessionPropertyManagerProvider.class).in(Scopes.SINGLETON);
binder.bind(SystemSessionProperties.class).in(Scopes.SINGLETON);
binder.bind(PrestoSparkSessionProperties.class).in(Scopes.SINGLETON);
binder.bind(SessionPropertyDefaults.class).in(Scopes.SINGLETON);
binder.bind(SchemaPropertyManager.class).in(Scopes.SINGLETON);
binder.bind(TablePropertyManager.class).in(Scopes.SINGLETON);
binder.bind(ColumnPropertyManager.class).in(Scopes.SINGLETON);
binder.bind(AnalyzePropertyManager.class).in(Scopes.SINGLETON);
binder.bind(QuerySessionSupplier.class).in(Scopes.SINGLETON);
// block encodings
binder.bind(BlockEncodingManager.class).in(Scopes.SINGLETON);
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);
// metadata
binder.bind(FunctionAndTypeManager.class).in(Scopes.SINGLETON);
binder.bind(MetadataManager.class).in(Scopes.SINGLETON);
binder.bind(Metadata.class).to(MetadataManager.class).in(Scopes.SINGLETON);
binder.bind(StaticFunctionNamespaceStore.class).in(Scopes.SINGLETON);
// type
newSetBinder(binder, Type.class);
binder.bind(TypeManager.class).to(FunctionAndTypeManager.class).in(Scopes.SINGLETON);
jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
// PageSorter
binder.bind(PageSorter.class).to(PagesIndexPageSorter.class).in(Scopes.SINGLETON);
// PageIndexer
binder.bind(PagesIndex.Factory.class).to(PagesIndex.DefaultFactory.class);
binder.bind(PageIndexerFactory.class).to(GroupByHashPageIndexerFactory.class).in(Scopes.SINGLETON);
// compilers
binder.bind(JoinFilterFunctionCompiler.class).in(Scopes.SINGLETON);
newExporter(binder).export(JoinFilterFunctionCompiler.class).withGeneratedName();
binder.bind(JoinCompiler.class).in(Scopes.SINGLETON);
newExporter(binder).export(JoinCompiler.class).withGeneratedName();
binder.bind(OrderingCompiler.class).in(Scopes.SINGLETON);
newExporter(binder).export(OrderingCompiler.class).withGeneratedName();
binder.bind(LookupJoinOperators.class).in(Scopes.SINGLETON);
binder.bind(DomainTranslator.class).to(RowExpressionDomainTranslator.class).in(Scopes.SINGLETON);
binder.bind(PredicateCompiler.class).to(RowExpressionPredicateCompiler.class).in(Scopes.SINGLETON);
binder.bind(DeterminismEvaluator.class).to(RowExpressionDeterminismEvaluator.class).in(Scopes.SINGLETON);
binder.bind(ExpressionCompiler.class).in(Scopes.SINGLETON);
binder.bind(PageFunctionCompiler.class).in(Scopes.SINGLETON);
// split manager
binder.bind(SplitManager.class).in(Scopes.SINGLETON);
// partitioning provider manager
binder.bind(PartitioningProviderManager.class).in(Scopes.SINGLETON);
// executors
ExecutorService executor = newCachedThreadPool(daemonThreadsNamed("presto-spark-executor-%s"));
binder.bind(Executor.class).toInstance(executor);
binder.bind(ExecutorService.class).toInstance(executor);
binder.bind(ScheduledExecutorService.class).toInstance(newScheduledThreadPool(0, daemonThreadsNamed("presto-spark-scheduled-executor-%s")));
// task executor
binder.bind(EmbedVersion.class).in(Scopes.SINGLETON);
binder.bind(MultilevelSplitQueue.class).in(Scopes.SINGLETON);
binder.bind(TaskExecutor.class).in(Scopes.SINGLETON);
// data stream provider
binder.bind(PageSourceManager.class).in(Scopes.SINGLETON);
binder.bind(PageSourceProvider.class).to(PageSourceManager.class).in(Scopes.SINGLETON);
// connector distributed metadata manager
binder.bind(ConnectorMetadataUpdaterManager.class).in(Scopes.SINGLETON);
// page sink provider
binder.bind(PageSinkManager.class).in(Scopes.SINGLETON);
binder.bind(PageSinkProvider.class).to(PageSinkManager.class).in(Scopes.SINGLETON);
// query explainer
binder.bind(QueryExplainer.class).in(Scopes.SINGLETON);
// parser
binder.bind(PlanChecker.class).in(Scopes.SINGLETON);
binder.bind(SqlParser.class).in(Scopes.SINGLETON);
binder.bind(SqlParserOptions.class).toInstance(sqlParserOptions);
// planner
binder.bind(PlanFragmenter.class).in(Scopes.SINGLETON);
binder.bind(PlanOptimizers.class).in(Scopes.SINGLETON);
binder.bind(ConnectorPlanOptimizerManager.class).in(Scopes.SINGLETON);
binder.bind(LocalExecutionPlanner.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(FileFragmentResultCacheConfig.class);
binder.bind(FragmentCacheStats.class).in(Scopes.SINGLETON);
binder.bind(IndexJoinLookupStats.class).in(Scopes.SINGLETON);
binder.bind(QueryIdGenerator.class).in(Scopes.SINGLETON);
binder.bind(QueryPreparer.class).in(Scopes.SINGLETON);
jsonBinder(binder).addKeySerializerBinding(VariableReferenceExpression.class).to(VariableReferenceExpressionSerializer.class);
jsonBinder(binder).addKeyDeserializerBinding(VariableReferenceExpression.class).to(VariableReferenceExpressionDeserializer.class);
// statistics calculator / cost calculator
binder.install(new StatsCalculatorModule());
binder.bind(CostCalculator.class).to(CostCalculatorUsingExchanges.class).in(Scopes.SINGLETON);
binder.bind(CostCalculator.class).annotatedWith(CostCalculator.EstimatedExchanges.class).to(CostCalculatorWithEstimatedExchanges.class).in(Scopes.SINGLETON);
binder.bind(CostComparator.class).in(Scopes.SINGLETON);
// JMX (Do not export to the real MXBean server, as the Presto context may be created multiple times per JVM)
binder.bind(MBeanServer.class).toInstance(new TestingMBeanServer());
binder.bind(MBeanExporter.class).in(Scopes.SINGLETON);
// spill
binder.bind(SpillerFactory.class).to(GenericSpillerFactory.class).in(Scopes.SINGLETON);
binder.bind(SingleStreamSpillerFactory.class).to(TempStorageSingleStreamSpillerFactory.class).in(Scopes.SINGLETON);
binder.bind(PartitioningSpillerFactory.class).to(GenericPartitioningSpillerFactory.class).in(Scopes.SINGLETON);
binder.bind(SpillerStats.class).in(Scopes.SINGLETON);
binder.bind(StandaloneSpillerFactory.class).to(TempStorageStandaloneSpillerFactory.class).in(Scopes.SINGLETON);
// monitoring
jsonCodecBinder(binder).bindJsonCodec(OperatorInfo.class);
binder.bind(QueryMonitor.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(QueryMonitorConfig.class);
binder.bind(SplitMonitor.class).in(Scopes.SINGLETON);
// Determine the NodeVersion
ServerConfig serverConfig = buildConfigObject(ServerConfig.class);
NodeVersion nodeVersion = new NodeVersion(serverConfig.getPrestoVersion());
binder.bind(NodeVersion.class).toInstance(nodeVersion);
// Support DDL statements. Helper class binds DDL statements to DataDefinitionTasks
PrestoDataDefBindingHelper.bindDDLDefinitionTasks(binder);
// TODO: Decouple node specific system tables
binder.bind(QueryManager.class).to(PrestoSparkQueryManager.class).in(Scopes.SINGLETON);
binder.bind(TaskManager.class).to(PrestoSparkTaskManager.class).in(Scopes.SINGLETON);
binder.install(new SystemConnectorModule());
// TODO: support explain analyze for Spark
binder.bind(new TypeLiteral<Optional<ExplainAnalyzeContext>>() {
}).toInstance(Optional.of(new ExplainAnalyzeContext((queryId) -> {
throw new UnsupportedOperationException("explain analyze is not supported");
})));
// TODO: support CBO, supply real nodes count
binder.bind(TaskCountEstimator.class).toInstance(new TaskCountEstimator(() -> 1000));
// TODO: Decouple and remove: required by ConnectorManager
binder.bind(InternalNodeManager.class).toInstance(new PrestoSparkInternalNodeManager());
// TODO: Decouple and remove: required by PluginManager
binder.bind(InternalResourceGroupManager.class).in(Scopes.SINGLETON);
binder.bind(ResourceGroupManager.class).to(InternalResourceGroupManager.class);
binder.bind(new TypeLiteral<ResourceGroupManager<?>>() {
}).to(new TypeLiteral<InternalResourceGroupManager<?>>() {
});
binder.bind(LegacyResourceGroupConfigurationManager.class).in(Scopes.SINGLETON);
binder.bind(ClusterMemoryPoolManager.class).toInstance(((poolId, listener) -> {
}));
binder.bind(QueryPrerequisitesManager.class).in(Scopes.SINGLETON);
binder.bind(ResourceGroupService.class).to(NoopResourceGroupService.class).in(Scopes.SINGLETON);
binder.bind(NodeTtlFetcherManager.class).to(ThrowingNodeTtlFetcherManager.class).in(Scopes.SINGLETON);
binder.bind(ClusterTtlProviderManager.class).to(ThrowingClusterTtlProviderManager.class).in(Scopes.SINGLETON);
// TODO: Decouple and remove: required by SessionPropertyDefaults, PluginManager, InternalResourceGroupManager, ConnectorManager
configBinder(binder).bindConfig(NodeConfig.class);
binder.bind(NodeInfo.class).in(Scopes.SINGLETON);
// TODO: Decouple and remove: required by LocalExecutionPlanner, PlanFragmenter
binder.bind(NodePartitioningManager.class).to(PrestoSparkNodePartitioningManager.class).in(Scopes.SINGLETON);
// TODO: Decouple and remove: required by PluginManager
install(new ServerSecurityModule());
// spark specific
binder.bind(SparkProcessType.class).toInstance(sparkProcessType);
binder.bind(PrestoSparkExecutionExceptionFactory.class).in(Scopes.SINGLETON);
binder.bind(PrestoSparkSettingsRequirements.class).in(Scopes.SINGLETON);
binder.bind(PrestoSparkQueryPlanner.class).in(Scopes.SINGLETON);
binder.bind(PrestoSparkPlanFragmenter.class).in(Scopes.SINGLETON);
binder.bind(PrestoSparkRddFactory.class).in(Scopes.SINGLETON);
binder.bind(PrestoSparkTaskExecutorFactory.class).in(Scopes.SINGLETON);
binder.bind(PrestoSparkQueryExecutionFactory.class).in(Scopes.SINGLETON);
binder.bind(PrestoSparkService.class).in(Scopes.SINGLETON);
binder.bind(PrestoSparkBroadcastTableCacheManager.class).in(Scopes.SINGLETON);
newSetBinder(binder, PrestoSparkServiceWaitTimeMetrics.class);
// extra credentials and authenticator for Presto-on-Spark
newSetBinder(binder, PrestoSparkCredentialsProvider.class);
newSetBinder(binder, PrestoSparkAuthenticatorProvider.class);
}
use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class VerifierModule method setup.
protected final void setup(Binder binder) {
configBinder(binder).bindConfig(VerifierConfig.class);
configBinder(binder).bindConfig(DeterminismAnalyzerConfig.class);
configBinder(binder).bindConfig(QueryConfigurationOverridesConfig.class, ForControl.class, "control");
configBinder(binder).bindConfig(QueryConfigurationOverridesConfig.class, ForTest.class, "test");
binder.bind(QueryConfigurationOverrides.class).annotatedWith(ForControl.class).to(Key.get(QueryConfigurationOverridesConfig.class, ForControl.class)).in(SINGLETON);
binder.bind(QueryConfigurationOverrides.class).annotatedWith(ForTest.class).to(Key.get(QueryConfigurationOverridesConfig.class, ForTest.class)).in(SINGLETON);
for (Class<? extends Predicate<SourceQuery>> customQueryFilterClass : customQueryFilterClasses) {
binder.bind(customQueryFilterClass).in(SINGLETON);
}
// block encoding
binder.bind(BlockEncodingSerde.class).to(BlockEncodingManager.class).in(Scopes.SINGLETON);
newSetBinder(binder, BlockEncoding.class);
// catalog
binder.bind(CatalogManager.class).in(Scopes.SINGLETON);
// function
binder.bind(FunctionAndTypeManager.class).in(SINGLETON);
// handle resolver
binder.install(new HandleJsonModule());
// parser
binder.bind(SqlParserOptions.class).toInstance(sqlParserOptions);
binder.bind(SqlParser.class).in(SINGLETON);
// transaction
configBinder(binder).bindConfig(TransactionManagerConfig.class);
// type
configBinder(binder).bindConfig(FeaturesConfig.class);
binder.bind(TypeManager.class).to(FunctionAndTypeManager.class).in(SINGLETON);
newSetBinder(binder, Type.class);
// verifier
install(new VerificationQueryRewriterModule());
install(FailureResolverModule.BUILT_IN);
binder.bind(VerificationManager.class).in(SINGLETON);
binder.bind(VerificationFactory.class).in(SINGLETON);
binder.bind(ChecksumValidator.class).in(SINGLETON);
MapBinder<Category, ColumnValidator> columnValidatorBinder = MapBinder.newMapBinder(binder, Category.class, ColumnValidator.class);
columnValidatorBinder.addBinding(SIMPLE).to(SimpleColumnValidator.class).in(SINGLETON);
columnValidatorBinder.addBinding(FLOATING_POINT).to(FloatingPointColumnValidator.class).in(SINGLETON);
columnValidatorBinder.addBinding(ARRAY).to(ArrayColumnValidator.class).in(SINGLETON);
columnValidatorBinder.addBinding(ROW).to(RowColumnValidator.class).in(SINGLETON);
columnValidatorBinder.addBinding(MAP).to(MapColumnValidator.class).in(SINGLETON);
binder.bind(new TypeLiteral<List<Predicate<SourceQuery>>>() {
}).toProvider(new CustomQueryFilterProvider(customQueryFilterClasses));
}
use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class ServerMainModule method setup.
@Override
protected void setup(Binder binder) {
ServerConfig serverConfig = buildConfigObject(ServerConfig.class);
if (serverConfig.isResourceManager()) {
install(new ResourceManagerModule());
} else if (serverConfig.isCoordinator()) {
install(new CoordinatorModule());
} else {
install(new WorkerModule());
}
install(new InternalCommunicationModule());
configBinder(binder).bindConfig(FeaturesConfig.class);
binder.bind(PlanChecker.class).in(Scopes.SINGLETON);
binder.bind(SqlParser.class).in(Scopes.SINGLETON);
binder.bind(SqlParserOptions.class).toInstance(sqlParserOptions);
sqlParserOptions.useEnhancedErrorHandler(serverConfig.isEnhancedErrorReporting());
jaxrsBinder(binder).bind(ThrowableMapper.class);
configBinder(binder).bindConfig(QueryManagerConfig.class);
configBinder(binder).bindConfig(SqlEnvironmentConfig.class);
jsonCodecBinder(binder).bindJsonCodec(ViewDefinition.class);
newOptionalBinder(binder, ExplainAnalyzeContext.class);
// GC Monitor
binder.bind(GcMonitor.class).to(JmxGcMonitor.class).in(Scopes.SINGLETON);
// session properties
binder.bind(SessionPropertyManager.class).in(Scopes.SINGLETON);
binder.bind(SystemSessionProperties.class).in(Scopes.SINGLETON);
binder.bind(SessionPropertyDefaults.class).in(Scopes.SINGLETON);
// schema properties
binder.bind(SchemaPropertyManager.class).in(Scopes.SINGLETON);
// table properties
binder.bind(TablePropertyManager.class).in(Scopes.SINGLETON);
// column properties
binder.bind(ColumnPropertyManager.class).in(Scopes.SINGLETON);
// analyze properties
binder.bind(AnalyzePropertyManager.class).in(Scopes.SINGLETON);
// node manager
discoveryBinder(binder).bindSelector("presto");
binder.bind(DiscoveryNodeManager.class).in(Scopes.SINGLETON);
binder.bind(InternalNodeManager.class).to(DiscoveryNodeManager.class).in(Scopes.SINGLETON);
newExporter(binder).export(DiscoveryNodeManager.class).withGeneratedName();
httpClientBinder(binder).bindHttpClient("node-manager", ForNodeManager.class).withTracing().withConfigDefaults(config -> {
config.setRequestTimeout(new Duration(10, SECONDS));
});
driftClientBinder(binder).bindDriftClient(ThriftServerInfoClient.class, ForNodeManager.class).withAddressSelector(((addressSelectorBinder, annotation, prefix) -> addressSelectorBinder.bind(AddressSelector.class).annotatedWith(annotation).to(FixedAddressSelector.class)));
// node scheduler
// TODO: remove from NodePartitioningManager and move to CoordinatorModule
configBinder(binder).bindConfig(NodeSchedulerConfig.class);
configBinder(binder).bindConfig(SimpleTtlNodeSelectorConfig.class);
binder.bind(NodeScheduler.class).in(Scopes.SINGLETON);
binder.bind(NodeSelectionStats.class).in(Scopes.SINGLETON);
newExporter(binder).export(NodeSelectionStats.class).withGeneratedName();
binder.bind(NodeSchedulerExporter.class).in(Scopes.SINGLETON);
binder.bind(NodeTaskMap.class).in(Scopes.SINGLETON);
newExporter(binder).export(NodeScheduler.class).withGeneratedName();
// network topology
// TODO: move to CoordinatorModule when NodeScheduler is moved
install(installModuleIf(NodeSchedulerConfig.class, config -> LEGACY.equalsIgnoreCase(config.getNetworkTopology()), moduleBinder -> moduleBinder.bind(NetworkTopology.class).to(LegacyNetworkTopology.class).in(Scopes.SINGLETON)));
install(installModuleIf(NodeSchedulerConfig.class, config -> FLAT.equalsIgnoreCase(config.getNetworkTopology()), moduleBinder -> moduleBinder.bind(NetworkTopology.class).to(FlatNetworkTopology.class).in(Scopes.SINGLETON)));
// task execution
jaxrsBinder(binder).bind(TaskResource.class);
newExporter(binder).export(TaskResource.class).withGeneratedName();
jaxrsBinder(binder).bind(TaskExecutorResource.class);
newExporter(binder).export(TaskExecutorResource.class).withGeneratedName();
binder.bind(TaskManagementExecutor.class).in(Scopes.SINGLETON);
install(new DefaultThriftCodecsModule());
thriftCodecBinder(binder).bindCustomThriftCodec(SqlInvokedFunctionCodec.class);
thriftCodecBinder(binder).bindCustomThriftCodec(SqlFunctionIdCodec.class);
jsonCodecBinder(binder).bindListJsonCodec(TaskMemoryReservationSummary.class);
binder.bind(SqlTaskManager.class).in(Scopes.SINGLETON);
binder.bind(TaskManager.class).to(Key.get(SqlTaskManager.class));
binder.bind(SpoolingOutputBufferFactory.class).in(Scopes.SINGLETON);
binder.bind(RandomResourceManagerAddressSelector.class).in(Scopes.SINGLETON);
driftClientBinder(binder).bindDriftClient(ResourceManagerClient.class, ForResourceManager.class).withAddressSelector((addressSelectorBinder, annotation, prefix) -> addressSelectorBinder.bind(AddressSelector.class).annotatedWith(annotation).to(RandomResourceManagerAddressSelector.class)).withExceptionClassifier(throwable -> {
if (throwable instanceof ResourceManagerInconsistentException) {
return new ExceptionClassification(Optional.of(true), DOWN);
}
return new ExceptionClassification(Optional.of(true), NORMAL);
});
newOptionalBinder(binder, ClusterMemoryManagerService.class);
install(installModuleIf(ServerConfig.class, ServerConfig::isResourceManagerEnabled, new Module() {
@Override
public void configure(Binder moduleBinder) {
configBinder(moduleBinder).bindConfig(ResourceManagerConfig.class);
moduleBinder.bind(ClusterStatusSender.class).to(ResourceManagerClusterStatusSender.class).in(Scopes.SINGLETON);
if (serverConfig.isCoordinator()) {
moduleBinder.bind(ClusterMemoryManagerService.class).in(Scopes.SINGLETON);
moduleBinder.bind(ResourceGroupService.class).to(ResourceManagerResourceGroupService.class).in(Scopes.SINGLETON);
}
}
@Provides
@Singleton
@ForResourceManager
public ScheduledExecutorService createResourceManagerScheduledExecutor(ResourceManagerConfig config) {
return createConcurrentScheduledExecutor("resource-manager-heartbeats", config.getHeartbeatConcurrency(), config.getHeartbeatThreads());
}
@Provides
@Singleton
@ForResourceManager
public ListeningExecutorService createResourceManagerExecutor(ResourceManagerConfig config) {
ExecutorService executor = new ThreadPoolExecutor(0, config.getResourceManagerExecutorThreads(), 60, SECONDS, new LinkedBlockingQueue<>(), daemonThreadsNamed("resource-manager-executor-%s"));
return listeningDecorator(executor);
}
}, moduleBinder -> {
moduleBinder.bind(ClusterStatusSender.class).toInstance(execution -> {
});
moduleBinder.bind(ResourceGroupService.class).to(NoopResourceGroupService.class).in(Scopes.SINGLETON);
}));
FeaturesConfig featuresConfig = buildConfigObject(FeaturesConfig.class);
FeaturesConfig.TaskSpillingStrategy taskSpillingStrategy = featuresConfig.getTaskSpillingStrategy();
switch(taskSpillingStrategy) {
case PER_TASK_MEMORY_THRESHOLD:
binder.bind(TaskThresholdMemoryRevokingScheduler.class).in(Scopes.SINGLETON);
break;
default:
binder.bind(MemoryRevokingScheduler.class).in(Scopes.SINGLETON);
}
// Add monitoring for JVM pauses
binder.bind(PauseMeter.class).in(Scopes.SINGLETON);
newExporter(binder).export(PauseMeter.class).withGeneratedName();
binder.bind(GcStatusMonitor.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(MemoryManagerConfig.class);
configBinder(binder).bindConfig(NodeMemoryConfig.class);
configBinder(binder).bindConfig(ReservedSystemMemoryConfig.class);
binder.bind(LocalMemoryManager.class).in(Scopes.SINGLETON);
binder.bind(LocalMemoryManagerExporter.class).in(Scopes.SINGLETON);
binder.bind(EmbedVersion.class).in(Scopes.SINGLETON);
newExporter(binder).export(TaskManager.class).withGeneratedName();
binder.bind(TaskExecutor.class).in(Scopes.SINGLETON);
newExporter(binder).export(TaskExecutor.class).withGeneratedName();
binder.bind(MultilevelSplitQueue.class).in(Scopes.SINGLETON);
newExporter(binder).export(MultilevelSplitQueue.class).withGeneratedName();
binder.bind(LocalExecutionPlanner.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(FileFragmentResultCacheConfig.class);
binder.bind(FragmentCacheStats.class).in(Scopes.SINGLETON);
newExporter(binder).export(FragmentCacheStats.class).withGeneratedName();
configBinder(binder).bindConfig(CompilerConfig.class);
binder.bind(ExpressionCompiler.class).in(Scopes.SINGLETON);
newExporter(binder).export(ExpressionCompiler.class).withGeneratedName();
binder.bind(PageFunctionCompiler.class).in(Scopes.SINGLETON);
newExporter(binder).export(PageFunctionCompiler.class).withGeneratedName();
configBinder(binder).bindConfig(TaskManagerConfig.class);
binder.bind(IndexJoinLookupStats.class).in(Scopes.SINGLETON);
newExporter(binder).export(IndexJoinLookupStats.class).withGeneratedName();
binder.bind(AsyncHttpExecutionMBean.class).in(Scopes.SINGLETON);
newExporter(binder).export(AsyncHttpExecutionMBean.class).withGeneratedName();
binder.bind(JoinFilterFunctionCompiler.class).in(Scopes.SINGLETON);
newExporter(binder).export(JoinFilterFunctionCompiler.class).withGeneratedName();
binder.bind(JoinCompiler.class).in(Scopes.SINGLETON);
newExporter(binder).export(JoinCompiler.class).withGeneratedName();
binder.bind(OrderingCompiler.class).in(Scopes.SINGLETON);
newExporter(binder).export(OrderingCompiler.class).withGeneratedName();
binder.bind(PagesIndex.Factory.class).to(PagesIndex.DefaultFactory.class);
binder.bind(LookupJoinOperators.class).in(Scopes.SINGLETON);
jsonCodecBinder(binder).bindJsonCodec(TaskStatus.class);
jsonCodecBinder(binder).bindJsonCodec(StageInfo.class);
jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class);
jsonCodecBinder(binder).bindJsonCodec(OperatorStats.class);
jsonCodecBinder(binder).bindJsonCodec(ExecutionFailureInfo.class);
jsonCodecBinder(binder).bindJsonCodec(TableCommitContext.class);
jsonCodecBinder(binder).bindJsonCodec(SqlInvokedFunction.class);
smileCodecBinder(binder).bindSmileCodec(TaskStatus.class);
smileCodecBinder(binder).bindSmileCodec(TaskInfo.class);
thriftCodecBinder(binder).bindThriftCodec(TaskStatus.class);
jaxrsBinder(binder).bind(PagesResponseWriter.class);
// exchange client
binder.bind(ExchangeClientSupplier.class).to(ExchangeClientFactory.class).in(Scopes.SINGLETON);
httpClientBinder(binder).bindHttpClient("exchange", ForExchange.class).withTracing().withFilter(GenerateTraceTokenRequestFilter.class).withConfigDefaults(config -> {
config.setRequestTimeout(new Duration(10, SECONDS));
config.setMaxConnectionsPerServer(250);
config.setMaxContentLength(new DataSize(32, MEGABYTE));
});
binder.install(new DriftNettyClientModule());
driftClientBinder(binder).bindDriftClient(ThriftTaskClient.class, ForExchange.class).withAddressSelector(((addressSelectorBinder, annotation, prefix) -> addressSelectorBinder.bind(AddressSelector.class).annotatedWith(annotation).to(FixedAddressSelector.class)));
configBinder(binder).bindConfig(ExchangeClientConfig.class);
binder.bind(ExchangeExecutionMBean.class).in(Scopes.SINGLETON);
newExporter(binder).export(ExchangeExecutionMBean.class).withGeneratedName();
// execution
binder.bind(LocationFactory.class).to(HttpLocationFactory.class).in(Scopes.SINGLETON);
// memory manager
jaxrsBinder(binder).bind(MemoryResource.class);
jsonCodecBinder(binder).bindJsonCodec(MemoryInfo.class);
jsonCodecBinder(binder).bindJsonCodec(MemoryPoolAssignmentsRequest.class);
smileCodecBinder(binder).bindSmileCodec(MemoryInfo.class);
smileCodecBinder(binder).bindSmileCodec(MemoryPoolAssignmentsRequest.class);
// transaction manager
configBinder(binder).bindConfig(TransactionManagerConfig.class);
// data stream provider
binder.bind(PageSourceManager.class).in(Scopes.SINGLETON);
binder.bind(PageSourceProvider.class).to(PageSourceManager.class).in(Scopes.SINGLETON);
// connector distributed metadata manager
binder.bind(ConnectorMetadataUpdaterManager.class).in(Scopes.SINGLETON);
// page sink provider
binder.bind(PageSinkManager.class).in(Scopes.SINGLETON);
binder.bind(PageSinkProvider.class).to(PageSinkManager.class).in(Scopes.SINGLETON);
// metadata
binder.bind(StaticCatalogStore.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(StaticCatalogStoreConfig.class);
binder.bind(StaticFunctionNamespaceStore.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(StaticFunctionNamespaceStoreConfig.class);
binder.bind(FunctionAndTypeManager.class).in(Scopes.SINGLETON);
binder.bind(MetadataManager.class).in(Scopes.SINGLETON);
binder.bind(Metadata.class).to(MetadataManager.class).in(Scopes.SINGLETON);
// row expression utils
binder.bind(DomainTranslator.class).to(RowExpressionDomainTranslator.class).in(Scopes.SINGLETON);
binder.bind(PredicateCompiler.class).to(RowExpressionPredicateCompiler.class).in(Scopes.SINGLETON);
binder.bind(DeterminismEvaluator.class).to(RowExpressionDeterminismEvaluator.class).in(Scopes.SINGLETON);
// type
binder.bind(TypeManager.class).to(FunctionAndTypeManager.class).in(Scopes.SINGLETON);
jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
newSetBinder(binder, Type.class);
// plan
jsonBinder(binder).addKeySerializerBinding(VariableReferenceExpression.class).to(VariableReferenceExpressionSerializer.class);
jsonBinder(binder).addKeyDeserializerBinding(VariableReferenceExpression.class).to(VariableReferenceExpressionDeserializer.class);
// split manager
binder.bind(SplitManager.class).in(Scopes.SINGLETON);
// partitioning provider manager
binder.bind(PartitioningProviderManager.class).in(Scopes.SINGLETON);
// node partitioning manager
binder.bind(NodePartitioningManager.class).in(Scopes.SINGLETON);
// connector plan optimizer manager
binder.bind(ConnectorPlanOptimizerManager.class).in(Scopes.SINGLETON);
// index manager
binder.bind(IndexManager.class).in(Scopes.SINGLETON);
// handle resolver
binder.install(new HandleJsonModule());
binder.bind(ObjectMapper.class).toProvider(JsonObjectMapperProvider.class);
// connector
binder.bind(ScalarStatsCalculator.class).in(Scopes.SINGLETON);
binder.bind(StatsNormalizer.class).in(Scopes.SINGLETON);
binder.bind(FilterStatsCalculator.class).in(Scopes.SINGLETON);
binder.bind(ConnectorManager.class).in(Scopes.SINGLETON);
// system connector
binder.install(new SystemConnectorModule());
// splits
jsonCodecBinder(binder).bindJsonCodec(TaskUpdateRequest.class);
jsonCodecBinder(binder).bindJsonCodec(ConnectorSplit.class);
jsonCodecBinder(binder).bindJsonCodec(PlanFragment.class);
smileCodecBinder(binder).bindSmileCodec(TaskUpdateRequest.class);
smileCodecBinder(binder).bindSmileCodec(ConnectorSplit.class);
smileCodecBinder(binder).bindSmileCodec(PlanFragment.class);
jsonBinder(binder).addSerializerBinding(Slice.class).to(SliceSerializer.class);
jsonBinder(binder).addDeserializerBinding(Slice.class).to(SliceDeserializer.class);
jsonBinder(binder).addSerializerBinding(Expression.class).to(ExpressionSerializer.class);
jsonBinder(binder).addDeserializerBinding(Expression.class).to(ExpressionDeserializer.class);
jsonBinder(binder).addDeserializerBinding(FunctionCall.class).to(FunctionCallDeserializer.class);
// metadata updates
jsonCodecBinder(binder).bindJsonCodec(MetadataUpdates.class);
smileCodecBinder(binder).bindSmileCodec(MetadataUpdates.class);
// split monitor
binder.bind(SplitMonitor.class).in(Scopes.SINGLETON);
// Determine the NodeVersion
NodeVersion nodeVersion = new NodeVersion(serverConfig.getPrestoVersion());
binder.bind(NodeVersion.class).toInstance(nodeVersion);
// presto announcement
checkArgument(!(serverConfig.isResourceManager() && serverConfig.isCoordinator()), "Server cannot be configured as both resource manager and coordinator");
discoveryBinder(binder).bindHttpAnnouncement("presto").addProperty("node_version", nodeVersion.toString()).addProperty("coordinator", String.valueOf(serverConfig.isCoordinator())).addProperty("resource_manager", String.valueOf(serverConfig.isResourceManager())).addProperty("connectorIds", nullToEmpty(serverConfig.getDataSources()));
// server info resource
jaxrsBinder(binder).bind(ServerInfoResource.class);
jsonCodecBinder(binder).bindJsonCodec(ServerInfo.class);
// node status resource
jaxrsBinder(binder).bind(StatusResource.class);
jsonCodecBinder(binder).bindJsonCodec(NodeStatus.class);
// plugin manager
binder.bind(PluginManager.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(PluginManagerConfig.class);
binder.bind(CatalogManager.class).in(Scopes.SINGLETON);
// block encodings
binder.bind(BlockEncodingManager.class).in(Scopes.SINGLETON);
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);
// thread visualizer
jaxrsBinder(binder).bind(ThreadResource.class);
// PageSorter
binder.bind(PageSorter.class).to(PagesIndexPageSorter.class).in(Scopes.SINGLETON);
// PageIndexer
binder.bind(PageIndexerFactory.class).to(GroupByHashPageIndexerFactory.class).in(Scopes.SINGLETON);
// Finalizer
binder.bind(FinalizerService.class).in(Scopes.SINGLETON);
// Spiller
binder.bind(SpillerFactory.class).to(GenericSpillerFactory.class).in(Scopes.SINGLETON);
binder.bind(StandaloneSpillerFactory.class).to(TempStorageStandaloneSpillerFactory.class).in(Scopes.SINGLETON);
binder.bind(PartitioningSpillerFactory.class).to(GenericPartitioningSpillerFactory.class).in(Scopes.SINGLETON);
binder.bind(SpillerStats.class).in(Scopes.SINGLETON);
newExporter(binder).export(SpillerFactory.class).withGeneratedName();
binder.bind(LocalSpillManager.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(NodeSpillConfig.class);
install(installModuleIf(FeaturesConfig.class, config -> config.getSingleStreamSpillerChoice() == SingleStreamSpillerChoice.LOCAL_FILE, moduleBinder -> moduleBinder.bind(SingleStreamSpillerFactory.class).to(FileSingleStreamSpillerFactory.class).in(Scopes.SINGLETON)));
install(installModuleIf(FeaturesConfig.class, config -> config.getSingleStreamSpillerChoice() == SingleStreamSpillerChoice.TEMP_STORAGE, moduleBinder -> moduleBinder.bind(SingleStreamSpillerFactory.class).to(TempStorageSingleStreamSpillerFactory.class).in(Scopes.SINGLETON)));
// Thrift RPC
binder.install(new DriftNettyServerModule());
driftServerBinder(binder).bindService(ThriftTaskService.class);
driftServerBinder(binder).bindService(ThriftServerInfoService.class);
// Async page transport
newMapBinder(binder, String.class, Servlet.class, TheServlet.class).addBinding("/v1/task/async/*").to(AsyncPageTransportServlet.class).in(Scopes.SINGLETON);
// cleanup
binder.bind(ExecutorCleanup.class).in(Scopes.SINGLETON);
// Distributed tracing
configBinder(binder).bindConfig(TracingConfig.class);
install(installModuleIf(TracingConfig.class, config -> !config.getEnableDistributedTracing() || NOOP.equalsIgnoreCase(config.getTracerType()), moduleBinder -> moduleBinder.bind(TracerProvider.class).to(NoopTracerProvider.class).in(Scopes.SINGLETON)));
install(installModuleIf(TracingConfig.class, config -> config.getEnableDistributedTracing() && SIMPLE.equalsIgnoreCase(config.getTracerType()), moduleBinder -> moduleBinder.bind(TracerProvider.class).to(SimpleTracerProvider.class).in(Scopes.SINGLETON)));
// Optional Status Detector
newOptionalBinder(binder, NodeStatusService.class);
}
use of com.facebook.presto.sql.parser.SqlParserOptions 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);
}
}
use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class TestConcurrentExecutor method createExecutor.
private ConcurrentPhaseExecutor createExecutor(BenchmarkRunnerConfig config) {
SqlParser sqlParser = new SqlParser(new SqlParserOptions().allowIdentifierSymbol(COLON, AT_SIGN));
ParsingOptions parsingOptions = ParsingOptions.builder().setDecimalLiteralTreatment(AS_DOUBLE).build();
PrestoActionFactory prestoActionFactory = new BenchmarkPrestoActionFactory(new PrestoExceptionClassifier(ImmutableSet.of()), new PrestoClusterConfig().setJdbcUrl(format("jdbc:presto://%s:%s", queryRunner.getServer().getAddress().getHost(), queryRunner.getServer().getAddress().getPort())), new RetryConfig());
return new ConcurrentPhaseExecutor(sqlParser, parsingOptions, prestoActionFactory, ImmutableSet.of(getEventClient()), config.setTestId(TEST_ID));
}
Aggregations