use of com.netflix.metacat.main.spi.MetacatCatalogConfig in project metacat by Netflix.
the class ConnectorManager method createConnection.
/**
* Creates a connection for the given catalog.
*
* @param catalogName catalog name
* @param connectorType connector type
* @param properties properties
*/
synchronized void createConnection(final String catalogName, final String connectorType, final Map<String, String> properties, final Registry registry) {
Preconditions.checkState(!stopped.get(), "ConnectorManager is stopped");
Preconditions.checkNotNull(catalogName, "catalogName is null");
Preconditions.checkNotNull(connectorType, "connectorName is null");
Preconditions.checkNotNull(properties, "properties is null");
final ConnectorPlugin connectorPlugin = plugins.get(connectorType);
if (connectorPlugin != null) {
Preconditions.checkState(!connectorFactories.containsKey(catalogName), "A connector %s already exists", catalogName);
final ConnectorFactory connectorFactory = connectorPlugin.create(this.config, catalogName, properties, registry);
connectorFactories.put(catalogName, connectorFactory);
final MetacatCatalogConfig catalogConfig = MetacatCatalogConfig.createFromMapAndRemoveProperties(connectorType, properties);
catalogs.put(catalogName, catalogConfig);
} else {
log.warn("No plugin for connector with type %s", connectorType);
}
}
use of com.netflix.metacat.main.spi.MetacatCatalogConfig in project metacat by Netflix.
the class CatalogServiceImpl method get.
/**
* {@inheritDoc}
*/
@Nonnull
@Override
public CatalogDto get(@Nonnull final QualifiedName name) {
final MetacatCatalogConfig config = connectorManager.getCatalogConfig(name);
final CatalogDto result = new CatalogDto();
result.setName(name);
result.setType(config.getType());
final ConnectorContext context = converterUtil.toConnectorContext(MetacatContextManager.getContext());
result.setDatabases(connectorManager.getDatabaseService(name.getCatalogName()).listNames(context, name, null, null, null).stream().map(QualifiedName::getDatabaseName).filter(s -> config.getSchemaBlacklist().isEmpty() || !config.getSchemaBlacklist().contains(s)).filter(s -> config.getSchemaWhitelist().isEmpty() || config.getSchemaWhitelist().contains(s)).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList()));
userMetadataService.populateMetadata(result);
return result;
}
use of com.netflix.metacat.main.spi.MetacatCatalogConfig in project metacat by Netflix.
the class DatabaseServiceImpl method get.
@Override
public DatabaseDto get(@Nonnull final QualifiedName name, final boolean includeUserMetadata) {
validate(name);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final MetacatCatalogConfig config = connectorManager.getCatalogConfig(name.getCatalogName());
final ConnectorDatabaseService service = connectorManager.getDatabaseService(name.getCatalogName());
final ConnectorTableService tableService = connectorManager.getTableService(name.getCatalogName());
final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
final List<QualifiedName> tableNames = tableService.listNames(connectorContext, name, null, null, null);
List<QualifiedName> viewNames = Collections.emptyList();
if (config.isIncludeViewsWithTables()) {
// TODO JdbcMetadata returns ImmutableList.of() for views. We should change it to fetch views.
try {
viewNames = service.listViewNames(connectorContext, name);
} catch (UnsupportedOperationException ignored) {
}
}
// Check to see if schema exists
if (tableNames.isEmpty() && viewNames.isEmpty() && !exists(name)) {
throw new DatabaseNotFoundException(name);
}
final DatabaseDto dto = converterUtil.toDatabaseDto(service.get(connectorContext, name));
dto.setType(connectorManager.getCatalogConfig(name).getType());
dto.setTables(Stream.concat(tableNames.stream(), viewNames.stream()).map(QualifiedName::getTableName).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList()));
if (includeUserMetadata) {
log.info("Populate user metadata for schema {}", name);
userMetadataService.populateMetadata(dto);
}
return dto;
}
Aggregations