public static MetadataManager createTestMetadataManager(FeaturesConfig featuresConfig) { return createTestMetadataManager(new CatalogManager(), featuresConfig); }
private synchronized Optional<ConnectorId> getConnectorId(String catalogName) { Optional<Catalog> catalog = catalogByName.get(catalogName); if (catalog == null) { catalog = catalogManager.getCatalog(catalogName); catalogByName.put(catalogName, catalog); if (catalog.isPresent()) { registerCatalog(catalog.get()); } } return catalog.map(Catalog::getConnectorId); }
private synchronized Map<String, ConnectorId> getCatalogNames() { // todo if repeatable read, this must be recorded Map<String, ConnectorId> catalogNames = new HashMap<>(); catalogByName.values().stream() .filter(Optional::isPresent) .map(Optional::get) .forEach(catalog -> catalogNames.put(catalog.getCatalogName(), catalog.getConnectorId())); catalogManager.getCatalogs().stream() .forEach(catalog -> catalogNames.putIfAbsent(catalog.getCatalogName(), catalog.getConnectorId())); return ImmutableMap.copyOf(catalogNames); }
@BeforeMethod public void setUp() { catalogManager = new CatalogManager(); typeManager = new TypeRegistry(); transactionManager = createTestTransactionManager(catalogManager); tablePropertyManager = new TablePropertyManager(); columnPropertyManager = new ColumnPropertyManager(); testCatalog = createBogusTestingCatalog(CATALOG_NAME); catalogManager.registerCatalog(testCatalog); tablePropertyManager.addProperties(testCatalog.getConnectorId(), ImmutableList.of(stringProperty("baz", "test property", null, false))); columnPropertyManager.addProperties(testCatalog.getConnectorId(), ImmutableList.of()); testSession = testSessionBuilder() .setTransactionId(transactionManager.beginTransaction(false)) .build(); metadata = new MockMetadata(typeManager, tablePropertyManager, columnPropertyManager, testCatalog.getConnectorId()); }
server.getCatalogManager().registerCatalog(bogusTestingCatalog);
addConnectorInternal(informationSchemaConnector); addConnectorInternal(systemConnector); catalogManager.registerCatalog(catalog); catalogManager.removeCatalog(catalog.getCatalogName()); removeConnectorInternal(systemConnector.getConnectorId()); removeConnectorInternal(informationSchemaConnector.getConnectorId());
public void loadCatalogs() throws Exception { if (!catalogsLoading.compareAndSet(false, true)) { return; } for (File file : listFiles(catalogConfigurationDir)) { if (file.isFile() && file.getName().endsWith(".properties")) { loadCatalog(file); } } catalogsLoaded.set(true); }
public synchronized void dropConnection(String catalogName) { requireNonNull(catalogName, "catalogName is null"); catalogManager.removeCatalog(catalogName).ifPresent(connectorId -> { // todo wait for all running transactions using the connector to complete before removing the services removeConnectorInternal(connectorId); removeConnectorInternal(createInformationSchemaConnectorId(connectorId)); removeConnectorInternal(createSystemTablesConnectorId(connectorId)); }); }
private void loadCatalog(File file) throws Exception { String catalogName = Files.getNameWithoutExtension(file.getName()); if (disabledCatalogs.contains(catalogName)) { log.info("Skipping disabled catalog %s", catalogName); return; } log.info("-- Loading catalog %s --", file); Map<String, String> properties = new HashMap<>(loadProperties(file)); String connectorName = properties.remove("connector.name"); checkState(connectorName != null, "Catalog configuration %s does not contain connector.name", file.getAbsoluteFile()); connectorManager.createConnection(catalogName, connectorName, ImmutableMap.copyOf(properties)); log.info("-- Added catalog %s using connector %s --", catalogName, connectorName); }
injector.getInstance(CatalogManager.class).loadCatalogs();
}).build(); Connector testConnector = mockConnectorFactory.create("test", ImmutableMap.of(), new TestingConnectorContext()); CatalogManager catalogManager = new CatalogManager(); String catalogName = "test_catalog"; ConnectorId connectorId = new ConnectorId(catalogName); catalogManager.registerCatalog(new Catalog( catalogName, connectorId,
private static ConnectorId registerBogusConnector(CatalogManager catalogManager, TransactionManager transactionManager, AccessControl accessControl, String catalogName) { ConnectorId connectorId = new ConnectorId(catalogName); Connector connector = new TpchConnectorFactory().create(catalogName, ImmutableMap.of(), new TestingConnectorContext()); InMemoryNodeManager nodeManager = new InMemoryNodeManager(); MetadataManager metadata = MetadataManager.createTestMetadataManager(catalogManager); ConnectorId systemId = createSystemTablesConnectorId(connectorId); catalogManager.registerCatalog(new Catalog( catalogName, connectorId, connector, createInformationSchemaConnectorId(connectorId), new InformationSchemaConnector(catalogName, nodeManager, metadata, accessControl), systemId, new SystemConnector( systemId, nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, connectorId)))); return connectorId; }
new NodeTaskMap(finalizerService)); this.pageSinkManager = new PageSinkManager(); CatalogManager catalogManager = new CatalogManager(); this.transactionManager = InMemoryTransactionManager.create( new TransactionManagerConfig().setIdleTimeout(new Duration(1, TimeUnit.DAYS)), catalogManager.registerCatalog(createBogusTestingCatalog(TESTING_CATALOG));
private static void registerConnector( CatalogManager catalogManager, TransactionManager transactionManager, String catalogName, ConnectorId connectorId, Connector connector) { ConnectorId systemId = createSystemTablesConnectorId(connectorId); InternalNodeManager nodeManager = new InMemoryNodeManager(); MetadataManager metadata = MetadataManager.createTestMetadataManager(catalogManager); catalogManager.registerCatalog(new Catalog( catalogName, connectorId, connector, createInformationSchemaConnectorId(connectorId), new InformationSchemaConnector(catalogName, nodeManager, metadata, new AllowAllAccessControl()), systemId, new SystemConnector( systemId, nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, connectorId)))); }
public static TransactionManager createTestTransactionManager() { return createTestTransactionManager(new CatalogManager()); }
List<Catalog> catalogs = metadata.getCatalogs();
private synchronized ConnectorId createConnection(String catalogName, ConnectorFactory connectorFactory, Map<String, String> properties) { checkState(!stopped.get(), "ConnectorManager is stopped"); requireNonNull(catalogName, "catalogName is null"); requireNonNull(properties, "properties is null"); requireNonNull(connectorFactory, "connectorFactory is null"); checkArgument(!catalogManager.getCatalog(catalogName).isPresent(), "A catalog already exists for %s", catalogName); ConnectorId connectorId = new ConnectorId(catalogName); checkState(!connectors.containsKey(connectorId), "A connector %s already exists", connectorId); addCatalogConnector(catalogName, connectorId, connectorFactory, properties); return connectorId; }
@BeforeClass public void setUp() { TaskCountEstimator taskCountEstimator = new TaskCountEstimator(() -> NUMBER_OF_NODES); costCalculatorUsingExchanges = new CostCalculatorUsingExchanges(taskCountEstimator); costCalculatorWithEstimatedExchanges = new CostCalculatorWithEstimatedExchanges(costCalculatorUsingExchanges, taskCountEstimator); session = testSessionBuilder().setCatalog("tpch").build(); CatalogManager catalogManager = new CatalogManager(); catalogManager.registerCatalog(createBogusTestingCatalog("tpch")); transactionManager = createTestTransactionManager(catalogManager); metadata = createTestMetadataManager(transactionManager, new FeaturesConfig()); finalizerService = new FinalizerService(); finalizerService.start(); nodeScheduler = new NodeScheduler( new LegacyNetworkTopology(), new InMemoryNodeManager(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService)); nodePartitioningManager = new NodePartitioningManager(nodeScheduler); planFragmenter = new PlanFragmenter(metadata, nodePartitioningManager, new QueryManagerConfig()); }
server.getCatalogManager().registerCatalog(bogusTestingCatalog);
@Test public void testExpiration() throws Exception { try (IdleCheckExecutor executor = new IdleCheckExecutor()) { TransactionManager transactionManager = InMemoryTransactionManager.create( new TransactionManagerConfig() .setIdleTimeout(new Duration(1, TimeUnit.MILLISECONDS)) .setIdleCheckInterval(new Duration(5, TimeUnit.MILLISECONDS)), executor.getExecutor(), new CatalogManager(), finishingExecutor); TransactionId transactionId = transactionManager.beginTransaction(false); assertEquals(transactionManager.getAllTransactionInfos().size(), 1); TransactionInfo transactionInfo = transactionManager.getTransactionInfo(transactionId); assertFalse(transactionInfo.isAutoCommitContext()); assertTrue(transactionInfo.getConnectorIds().isEmpty()); assertFalse(transactionInfo.getWrittenConnectorId().isPresent()); transactionManager.trySetInactive(transactionId); TimeUnit.MILLISECONDS.sleep(100); assertTrue(transactionManager.getAllTransactionInfos().isEmpty()); } }