use of com.netflix.metacat.common.server.connectors.ConnectorRequestContext in project metacat by Netflix.
the class DatabaseServiceImpl method get.
/**
* {@inheritDoc}
*/
@Override
public DatabaseDto get(final QualifiedName name, final GetDatabaseServiceParameters getDatabaseServiceParameters) {
validate(name);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final MetacatCatalogConfig config = connectorManager.getCatalogConfig(name);
final ConnectorDatabaseService service = connectorManager.getDatabaseService(name);
final ConnectorTableService tableService = connectorManager.getTableService(name);
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
final DatabaseDto dto = converterUtil.toDatabaseDto(service.get(connectorRequestContext, name));
dto.setType(config.getType());
if (getDatabaseServiceParameters.isIncludeTableNames()) {
final List<QualifiedName> tableNames = tableService.listNames(connectorRequestContext, 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(connectorRequestContext, name);
} catch (UnsupportedOperationException ignored) {
}
}
// Check to see if schema exists
if (tableNames.isEmpty() && viewNames.isEmpty() && !exists(name)) {
throw new DatabaseNotFoundException(name);
}
dto.setTables(Stream.concat(tableNames.stream(), viewNames.stream()).map(QualifiedName::getTableName).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList()));
}
if (getDatabaseServiceParameters.isIncludeUserMetadata()) {
log.info("Populate user metadata for schema {}", name);
userMetadataService.populateMetadata(dto, getDatabaseServiceParameters.isDisableOnReadMetadataIntercetor());
}
return dto;
}
use of com.netflix.metacat.common.server.connectors.ConnectorRequestContext in project metacat by Netflix.
the class PartitionServiceImpl method getPartitionUris.
/**
* {@inheritDoc}
*/
@Override
public List<String> getPartitionUris(final QualifiedName name, @Nullable final Sort sort, @Nullable final Pageable pageable, @Nullable final GetPartitionsRequestDto getPartitionsRequestDto) {
List<String> result = Lists.newArrayList();
if (tableService.exists(name)) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorPartitionService service = connectorManager.getPartitionService(name);
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
try {
result = service.getPartitionUris(connectorRequestContext, name, converterUtil.toPartitionListRequest(getPartitionsRequestDto, pageable, sort));
} catch (final UnsupportedOperationException uoe) {
log.info("Catalog {} doesn't support getPartitionUris. Ignoring.", name.getCatalogName());
}
}
return result;
}
use of com.netflix.metacat.common.server.connectors.ConnectorRequestContext in project metacat by Netflix.
the class PartitionServiceImpl method count.
/**
* {@inheritDoc}
*/
@Override
public Integer count(final QualifiedName name) {
Integer result = 0;
if (tableService.exists(name)) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorPartitionService service = connectorManager.getPartitionService(name);
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
result = service.getPartitionCount(connectorRequestContext, name);
}
return result;
}
use of com.netflix.metacat.common.server.connectors.ConnectorRequestContext in project metacat by Netflix.
the class PartitionServiceImpl method getPartitionKeys.
/**
* {@inheritDoc}
*/
@Override
public List<String> getPartitionKeys(final QualifiedName name, @Nullable final Sort sort, @Nullable final Pageable pageable, @Nullable final GetPartitionsRequestDto getPartitionsRequestDto) {
List<String> result = Lists.newArrayList();
if (tableService.exists(name)) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorPartitionService service = connectorManager.getPartitionService(name);
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
try {
result = service.getPartitionKeys(connectorRequestContext, name, converterUtil.toPartitionListRequest(getPartitionsRequestDto, pageable, sort));
} catch (final UnsupportedOperationException uoe) {
log.debug("Catalog {} doesn't support getPartitionKeys. Ignoring.", name.getCatalogName());
}
}
return result;
}
use of com.netflix.metacat.common.server.connectors.ConnectorRequestContext in project metacat by Netflix.
the class TableServiceImpl method getQualifiedNames.
/**
* {@inheritDoc}
*/
@Override
public Map<String, List<QualifiedName>> getQualifiedNames(final List<String> uris, final boolean prefixSearch) {
final Map<String, List<QualifiedName>> result = Maps.newHashMap();
connectorManager.getTableServices().forEach(service -> {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
try {
final Map<String, List<QualifiedName>> names = service.getTableNames(connectorRequestContext, uris, prefixSearch);
names.forEach((uri, qNames) -> {
final List<QualifiedName> existingNames = result.get(uri);
if (existingNames == null) {
result.put(uri, qNames);
} else {
existingNames.addAll(qNames);
}
});
} catch (final UnsupportedOperationException uoe) {
log.debug("Table service doesn't support getting table names by URI. Skipping");
}
});
return result;
}
Aggregations