Search in sources :

Example 1 with MetadataManager

use of io.prestosql.metadata.MetadataManager in project hetu-core by openlookeng.

the class DataCenterUtility method loadDCCatalogsForShowQueries.

/**
 * Utility method to load all DC catalog from ShowQueriesRewrite.
 *
 * @param session session
 * @param metadata metadata
 */
public static void loadDCCatalogsForShowQueries(Metadata metadata, Session session) {
    MetadataManager metadataManager = (MetadataManager) metadata;
    DataCenterConnectorManager dataCenterConnectorManager = metadataManager.getDataCenterConnectorManager();
    if (dataCenterConnectorManager != null) {
        dataCenterConnectorManager.loadAllDCCatalogs();
    }
}
Also used : MetadataManager(io.prestosql.metadata.MetadataManager)

Example 2 with MetadataManager

use of io.prestosql.metadata.MetadataManager in project hetu-core by openlookeng.

the class TestConnectorFilterStatsCalculatorService method setUp.

@BeforeClass
public void setUp() {
    session = testSessionBuilder().build();
    MetadataManager metadata = MetadataManager.createTestMetadataManager();
    FilterStatsCalculator statsCalculator = new FilterStatsCalculator(metadata, new ScalarStatsCalculator(metadata), new StatsNormalizer());
    statsCalculatorService = new ConnectorFilterStatsCalculatorService(statsCalculator);
    xStats = ColumnStatistics.builder().setDistinctValuesCount(Estimate.of(40)).setRange(new DoubleRange(-10, 10)).setNullsFraction(Estimate.of(0.25)).build();
    zeroTableStatistics = TableStatistics.builder().setRowCount(Estimate.zero()).build();
    unknownTableStatistics = TableStatistics.builder().setRowCount(Estimate.unknown()).build();
    originalTableStatistics = TableStatistics.builder().setRowCount(Estimate.of(100)).setColumnStatistics(xColumn, xStats).build();
    originalTableStatisticsWithoutTotalSize = TableStatistics.builder().setRowCount(Estimate.of(100)).setColumnStatistics(xColumn, xStats).build();
    standardTypes = TypeProvider.viewOf(ImmutableMap.<Symbol, Type>builder().put(new Symbol("x"), DOUBLE).build());
    translator = new TestingRowExpressionTranslator(MetadataManager.createTestMetadataManager());
}
Also used : DoubleRange(io.prestosql.spi.statistics.DoubleRange) Type(io.prestosql.spi.type.Type) MetadataManager(io.prestosql.metadata.MetadataManager) TestingRowExpressionTranslator(io.prestosql.sql.TestingRowExpressionTranslator) Symbol(io.prestosql.spi.plan.Symbol) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with MetadataManager

use of io.prestosql.metadata.MetadataManager in project hetu-core by openlookeng.

the class ConnectorManager method addCatalogConnector.

public synchronized void addCatalogConnector(CatalogName catalogName, Connector catalogConnector) {
    MaterializedConnector connector = new MaterializedConnector(catalogName, catalogConnector);
    MaterializedConnector informationSchemaConnector = new MaterializedConnector(createInformationSchemaCatalogName(catalogName), new InformationSchemaConnector(catalogName.getCatalogName(), nodeManager, metadataManager, accessControlManager));
    CatalogName systemId = createSystemTablesCatalogName(catalogName);
    SystemTablesProvider systemTablesProvider;
    if (nodeManager.getCurrentNode().isCoordinator()) {
        systemTablesProvider = new DelegatingSystemTablesProvider(new StaticSystemTablesProvider(connector.getSystemTables()), new MetadataBasedSystemTablesProvider(metadataManager, catalogName.getCatalogName()));
    } else {
        systemTablesProvider = new StaticSystemTablesProvider(connector.getSystemTables());
    }
    MaterializedConnector systemConnector = new MaterializedConnector(systemId, new SystemConnector(nodeManager, systemTablesProvider, transactionId -> transactionManager.getConnectorTransaction(transactionId, catalogName)));
    Catalog catalog = new Catalog(catalogName.getCatalogName(), connector.getCatalogName(), connector.getConnector(), informationSchemaConnector.getCatalogName(), informationSchemaConnector.getConnector(), systemConnector.getCatalogName(), systemConnector.getConnector());
    try {
        addConnectorInternal(connector);
        addConnectorInternal(informationSchemaConnector);
        addConnectorInternal(systemConnector);
        catalogManager.registerCatalog(catalog);
    } catch (Throwable e) {
        catalogManager.removeCatalog(catalog.getCatalogName());
        removeConnectorInternal(systemConnector.getCatalogName());
        removeConnectorInternal(informationSchemaConnector.getCatalogName());
        removeConnectorInternal(connector.getCatalogName());
        throw e;
    }
}
Also used : SystemConnector(io.prestosql.connector.system.SystemConnector) ConnectorPlanOptimizerProvider(io.prestosql.spi.connector.ConnectorPlanOptimizerProvider) CONNECTION_USER(io.prestosql.spi.HetuConstant.CONNECTION_USER) VersionEmbedder(io.prestosql.spi.VersionEmbedder) ConnectorAccessControl(io.prestosql.spi.connector.ConnectorAccessControl) ConnectorSplitManager(io.prestosql.spi.connector.ConnectorSplitManager) NodeInfo(io.airlift.node.NodeInfo) FilterStatsCalculator(io.prestosql.cost.FilterStatsCalculator) ConnectorFilterStatsCalculatorService(io.prestosql.cost.ConnectorFilterStatsCalculatorService) DeterminismEvaluator(io.prestosql.spi.relation.DeterminismEvaluator) ServerConfig(io.prestosql.server.ServerConfig) RecordPageSourceProvider(io.prestosql.split.RecordPageSourceProvider) PreDestroy(javax.annotation.PreDestroy) ConnectorPlanOptimizerManager(io.prestosql.sql.planner.ConnectorPlanOptimizerManager) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) PrestoTransportException(io.prestosql.spi.PrestoTransportException) Procedure(io.prestosql.spi.procedure.Procedure) ConnectorNodePartitioningProvider(io.prestosql.spi.connector.ConnectorNodePartitioningProvider) Map(java.util.Map) PropertyMetadata(io.prestosql.spi.session.PropertyMetadata) ConnectorPageSinkProvider(io.prestosql.spi.connector.ConnectorPageSinkProvider) Announcer(io.airlift.discovery.client.Announcer) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) PageIndexerFactory(io.prestosql.spi.PageIndexerFactory) PrestoException(io.prestosql.spi.PrestoException) ImmutableSet(com.google.common.collect.ImmutableSet) SystemTable(io.prestosql.spi.connector.SystemTable) DomainTranslator(io.prestosql.spi.relation.DomainTranslator) DATA_CENTER_CONNECTOR_NAME(io.prestosql.spi.HetuConstant.DATA_CENTER_CONNECTOR_NAME) CatalogName(io.prestosql.spi.connector.CatalogName) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ThreadSafe(javax.annotation.concurrent.ThreadSafe) NodeSchedulerConfig(io.prestosql.execution.scheduler.NodeSchedulerConfig) GuardedBy(javax.annotation.concurrent.GuardedBy) ExternalFunctionHub(io.prestosql.spi.function.ExternalFunctionHub) MetadataManager(io.prestosql.metadata.MetadataManager) String.format(java.lang.String.format) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) FunctionResolution(io.prestosql.sql.relational.FunctionResolution) ConnectorRecordSetProvider(io.prestosql.spi.connector.ConnectorRecordSetProvider) PageSinkManager(io.prestosql.split.PageSinkManager) Optional(java.util.Optional) FunctionAndTypeManager(io.prestosql.metadata.FunctionAndTypeManager) Joiner(com.google.common.base.Joiner) Connector(io.prestosql.spi.connector.Connector) NodePartitioningManager(io.prestosql.sql.planner.NodePartitioningManager) REMOTE_TASK_ERROR(io.prestosql.spi.StandardErrorCode.REMOTE_TASK_ERROR) Logger(io.airlift.log.Logger) EmbedVersion(io.prestosql.version.EmbedVersion) TransactionManager(io.prestosql.transaction.TransactionManager) ConnectorContext(io.prestosql.spi.connector.ConnectorContext) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) AccessControlManager(io.prestosql.security.AccessControlManager) SqlInvokedFunction(io.prestosql.spi.function.SqlInvokedFunction) FunctionExtractor.extractExternalFunctions(io.prestosql.metadata.FunctionExtractor.extractExternalFunctions) StaticSystemTablesProvider(io.prestosql.connector.system.StaticSystemTablesProvider) ConcurrentMap(java.util.concurrent.ConcurrentMap) InformationSchemaConnector(io.prestosql.connector.informationschema.InformationSchemaConnector) Inject(javax.inject.Inject) ConnectorIndexProvider(io.prestosql.spi.connector.ConnectorIndexProvider) MetadataBasedSystemTablesProvider(io.prestosql.connector.system.MetadataBasedSystemTablesProvider) ImmutableList(com.google.common.collect.ImmutableList) SystemTablesProvider(io.prestosql.connector.system.SystemTablesProvider) Verify.verify(com.google.common.base.Verify.verify) CatalogName.createSystemTablesCatalogName(io.prestosql.spi.connector.CatalogName.createSystemTablesCatalogName) Objects.requireNonNull(java.util.Objects.requireNonNull) PageSourceManager(io.prestosql.split.PageSourceManager) SystemConnector(io.prestosql.connector.system.SystemConnector) LinkedHashSet(java.util.LinkedHashSet) InternalNodeManager(io.prestosql.metadata.InternalNodeManager) InternalTypeManager(io.prestosql.type.InternalTypeManager) IndexManager(io.prestosql.index.IndexManager) CatalogName.createInformationSchemaCatalogName(io.prestosql.spi.connector.CatalogName.createInformationSchemaCatalogName) ThreadContextClassLoader(io.prestosql.spi.classloader.ThreadContextClassLoader) PageSorter(io.prestosql.spi.PageSorter) Field(java.lang.reflect.Field) ServiceAnnouncement(io.airlift.discovery.client.ServiceAnnouncement) DelegatingSystemTablesProvider(io.prestosql.connector.system.DelegatingSystemTablesProvider) Catalog(io.prestosql.metadata.Catalog) HandleResolver(io.prestosql.metadata.HandleResolver) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) ConnectorFactory(io.prestosql.spi.connector.ConnectorFactory) SplitManager(io.prestosql.split.SplitManager) CatalogManager(io.prestosql.metadata.CatalogManager) ConnectorRowExpressionService(io.prestosql.sql.relational.ConnectorRowExpressionService) ConnectorPageSourceProvider(io.prestosql.spi.connector.ConnectorPageSourceProvider) StaticSystemTablesProvider(io.prestosql.connector.system.StaticSystemTablesProvider) InformationSchemaConnector(io.prestosql.connector.informationschema.InformationSchemaConnector) DelegatingSystemTablesProvider(io.prestosql.connector.system.DelegatingSystemTablesProvider) MetadataBasedSystemTablesProvider(io.prestosql.connector.system.MetadataBasedSystemTablesProvider) CatalogName(io.prestosql.spi.connector.CatalogName) CatalogName.createSystemTablesCatalogName(io.prestosql.spi.connector.CatalogName.createSystemTablesCatalogName) CatalogName.createInformationSchemaCatalogName(io.prestosql.spi.connector.CatalogName.createInformationSchemaCatalogName) StaticSystemTablesProvider(io.prestosql.connector.system.StaticSystemTablesProvider) MetadataBasedSystemTablesProvider(io.prestosql.connector.system.MetadataBasedSystemTablesProvider) SystemTablesProvider(io.prestosql.connector.system.SystemTablesProvider) DelegatingSystemTablesProvider(io.prestosql.connector.system.DelegatingSystemTablesProvider) Catalog(io.prestosql.metadata.Catalog)

Example 4 with MetadataManager

use of io.prestosql.metadata.MetadataManager in project hetu-core by openlookeng.

the class DataCenterUtility method loadDCCatalogForUseTask.

/**
 * Utility method to load DC catalog from Usetask.
 *
 * @param statement statement
 * @param metadata metadata
 * @param session session
 */
public static void loadDCCatalogForUseTask(Use statement, Metadata metadata, Session session) {
    Optional<Identifier> catalogIdentifier = statement.getCatalog();
    Optional<String> catalogName = Optional.empty();
    if (!catalogIdentifier.isPresent()) {
        catalogName = session.getCatalog();
    } else {
        catalogName = Optional.ofNullable(catalogIdentifier.get().getValue());
    }
    if (catalogName.isPresent()) {
        if (catalogName.isPresent()) {
            MetadataManager metadataManager = (MetadataManager) metadata;
            DataCenterConnectorManager dataCenterConnectorManager = metadataManager.getDataCenterConnectorManager();
            if (dataCenterConnectorManager != null) {
                dataCenterConnectorManager.loadDCCatalog(catalogName.get());
            }
        }
    }
}
Also used : Identifier(io.prestosql.sql.tree.Identifier) MetadataManager(io.prestosql.metadata.MetadataManager)

Example 5 with MetadataManager

use of io.prestosql.metadata.MetadataManager in project hetu-core by openlookeng.

the class DataCenterUtility method isDCCatalog.

/**
 * Utility method to check whether a catalog is cross-dc catalog.
 *
 * @param metadata session
 * @param catalogName catalog name
 */
public static boolean isDCCatalog(Metadata metadata, String name) {
    String catalogName = name;
    if (catalogName != null && catalogName.contains(".")) {
        catalogName = catalogName.substring(0, catalogName.indexOf("."));
    }
    MetadataManager metadataManager = (MetadataManager) metadata;
    DataCenterConnectorManager dataCenterConnectorManager = metadataManager.getDataCenterConnectorManager();
    if (dataCenterConnectorManager != null) {
        return dataCenterConnectorManager.isDCCatalog(catalogName);
    }
    return false;
}
Also used : MetadataManager(io.prestosql.metadata.MetadataManager)

Aggregations

MetadataManager (io.prestosql.metadata.MetadataManager)7 ImmutableList (com.google.common.collect.ImmutableList)2 ConnectorFactory (io.prestosql.spi.connector.ConnectorFactory)2 List (java.util.List)2 BeforeClass (org.testng.annotations.BeforeClass)2 Joiner (com.google.common.base.Joiner)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Verify.verify (com.google.common.base.Verify.verify)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Announcer (io.airlift.discovery.client.Announcer)1 ServiceAnnouncement (io.airlift.discovery.client.ServiceAnnouncement)1 Logger (io.airlift.log.Logger)1 NodeInfo (io.airlift.node.NodeInfo)1 TEST_SESSION (io.prestosql.SessionTestUtils.TEST_SESSION)1 MockConnectorFactory (io.prestosql.connector.MockConnectorFactory)1 InformationSchemaConnector (io.prestosql.connector.informationschema.InformationSchemaConnector)1 DelegatingSystemTablesProvider (io.prestosql.connector.system.DelegatingSystemTablesProvider)1 MetadataBasedSystemTablesProvider (io.prestosql.connector.system.MetadataBasedSystemTablesProvider)1