Search in sources :

Example 16 with MetacatRequestContext

use of com.netflix.metacat.common.MetacatRequestContext 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;
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) ConnectorPartitionService(com.netflix.metacat.common.server.connectors.ConnectorPartitionService) ConnectorRequestContext(com.netflix.metacat.common.server.connectors.ConnectorRequestContext)

Example 17 with MetacatRequestContext

use of com.netflix.metacat.common.MetacatRequestContext 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;
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) ConnectorPartitionService(com.netflix.metacat.common.server.connectors.ConnectorPartitionService) ConnectorRequestContext(com.netflix.metacat.common.server.connectors.ConnectorRequestContext)

Example 18 with MetacatRequestContext

use of com.netflix.metacat.common.MetacatRequestContext 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;
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) ConnectorPartitionService(com.netflix.metacat.common.server.connectors.ConnectorPartitionService) ConnectorRequestContext(com.netflix.metacat.common.server.connectors.ConnectorRequestContext)

Example 19 with MetacatRequestContext

use of com.netflix.metacat.common.MetacatRequestContext in project metacat by Netflix.

the class TableServiceImpl method saveMetadata.

/**
 * {@inheritDoc}
 */
@Override
public void saveMetadata(final QualifiedName name, final ObjectNode definitionMetadata, final ObjectNode dataMetadata) {
    validate(name);
    final Optional<TableDto> tableDtoOptional = get(name, GetTableServiceParameters.builder().includeInfo(true).disableOnReadMetadataIntercetor(true).includeDefinitionMetadata(false).includeDataMetadata(false).build());
    if (tableDtoOptional.isPresent()) {
        final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
        final TableDto tableDto = tableDtoOptional.get();
        // override the previous one
        tableDto.setDefinitionMetadata(definitionMetadata);
        tableDto.setDataMetadata(dataMetadata);
        log.info("Saving user metadata for table {}", name);
        userMetadataService.saveMetadata(metacatRequestContext.getUserName(), tableDto, true);
        tag(name, tableDto.getDefinitionMetadata());
    }
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) TableDto(com.netflix.metacat.common.dto.TableDto)

Example 20 with MetacatRequestContext

use of com.netflix.metacat.common.MetacatRequestContext 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;
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) QualifiedName(com.netflix.metacat.common.QualifiedName) List(java.util.List) ConnectorRequestContext(com.netflix.metacat.common.server.connectors.ConnectorRequestContext)

Aggregations

MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)50 QualifiedName (com.netflix.metacat.common.QualifiedName)22 TableDto (com.netflix.metacat.common.dto.TableDto)20 ConnectorRequestContext (com.netflix.metacat.common.server.connectors.ConnectorRequestContext)20 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)16 List (java.util.List)12 PartitionDto (com.netflix.metacat.common.dto.PartitionDto)11 ConnectorTableService (com.netflix.metacat.common.server.connectors.ConnectorTableService)11 ConnectorPartitionService (com.netflix.metacat.common.server.connectors.ConnectorPartitionService)10 Collectors (java.util.stream.Collectors)10 Slf4j (lombok.extern.slf4j.Slf4j)10 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)9 Lists (com.google.common.collect.Lists)8 DatabaseDto (com.netflix.metacat.common.dto.DatabaseDto)8 GetPartitionsRequestDto (com.netflix.metacat.common.dto.GetPartitionsRequestDto)8 NotFoundException (com.netflix.metacat.common.server.connectors.exception.NotFoundException)8 Metrics (com.netflix.metacat.common.server.monitoring.Metrics)8 UserMetadataService (com.netflix.metacat.common.server.usermetadata.UserMetadataService)8 MetacatContextManager (com.netflix.metacat.common.server.util.MetacatContextManager)8 Registry (com.netflix.spectator.api.Registry)8