use of io.trino.eventlistener.EventListenerManager in project trino by trinodb.
the class ConnectorManager method createCatalog.
private synchronized void createCatalog(CatalogName catalogName, String connectorName, InternalConnectorFactory factory, Map<String, String> properties) {
// create all connectors before adding, so a broken connector does not leave the system half updated
CatalogClassLoaderSupplier duplicatePluginClassLoaderFactory = new CatalogClassLoaderSupplier(catalogName, factory.getDuplicatePluginClassLoaderFactory(), handleResolver);
MaterializedConnector connector = new MaterializedConnector(catalogName, createConnector(catalogName, factory.getConnectorFactory(), duplicatePluginClassLoaderFactory, properties), duplicatePluginClassLoaderFactory::destroy);
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 CoordinatorSystemTablesProvider(transactionManager, metadataManager, catalogName.getCatalogName(), new StaticSystemTablesProvider(connector.getSystemTables()));
} else {
systemTablesProvider = new StaticSystemTablesProvider(connector.getSystemTables());
}
MaterializedConnector systemConnector = new MaterializedConnector(systemId, new SystemConnector(nodeManager, systemTablesProvider, transactionId -> transactionManager.getConnectorTransaction(transactionId, catalogName)), () -> {
});
SecurityManagement securityManagement = connector.getAccessControl().isPresent() ? CONNECTOR : SYSTEM;
Catalog catalog = new Catalog(catalogName.getCatalogName(), connector.getCatalogName(), connectorName, connector.getConnector(), securityManagement, 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;
}
connector.getEventListeners().forEach(eventListenerManager::addEventListener);
}
use of io.trino.eventlistener.EventListenerManager in project trino by trinodb.
the class TestCreateTableTask method testCreateLikeDenyPermission.
@Test
public void testCreateLikeDenyPermission() {
CreateTable statement = getCreatleLikeStatement(false);
TestingAccessControlManager accessControl = new TestingAccessControlManager(transactionManager, new EventListenerManager(new EventListenerConfig()));
accessControl.deny(privilege("parent_table", SELECT_COLUMN));
CreateTableTask createTableTask = new CreateTableTask(plannerContext, accessControl, columnPropertyManager, tablePropertyManager);
assertThatThrownBy(() -> getFutureValue(createTableTask.internalExecute(statement, testSession, List.of(), output -> {
}))).isInstanceOf(AccessDeniedException.class).hasMessageContaining("Cannot reference columns of table");
}
use of io.trino.eventlistener.EventListenerManager in project trino by trinodb.
the class TestCreateTableTask method testCreateLikeWithPropertiesDenyPermission.
@Test
public void testCreateLikeWithPropertiesDenyPermission() {
CreateTable statement = getCreatleLikeStatement(true);
TestingAccessControlManager accessControl = new TestingAccessControlManager(transactionManager, new EventListenerManager(new EventListenerConfig()));
accessControl.deny(privilege("parent_table", SHOW_CREATE_TABLE));
CreateTableTask createTableTask = new CreateTableTask(plannerContext, accessControl, columnPropertyManager, tablePropertyManager);
assertThatThrownBy(() -> getFutureValue(createTableTask.internalExecute(statement, testSession, List.of(), output -> {
}))).isInstanceOf(AccessDeniedException.class).hasMessageContaining("Cannot reference properties of table");
}
Aggregations