Search in sources :

Example 1 with CatalogDto

use of com.netflix.metacat.common.dto.CatalogDto 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;
}
Also used : UserMetadataService(com.netflix.metacat.common.server.usermetadata.UserMetadataService) CatalogService(com.netflix.metacat.main.services.CatalogService) CreateCatalogDto(com.netflix.metacat.common.dto.CreateCatalogDto) MetacatEventBus(com.netflix.metacat.common.server.events.MetacatEventBus) ConverterUtil(com.netflix.metacat.common.server.converter.ConverterUtil) MetacatContextManager(com.netflix.metacat.common.server.util.MetacatContextManager) MetacatUpdateDatabasePreEvent(com.netflix.metacat.common.server.events.MetacatUpdateDatabasePreEvent) CatalogMappingDto(com.netflix.metacat.common.dto.CatalogMappingDto) QualifiedName(com.netflix.metacat.common.QualifiedName) MetacatUpdateDatabasePostEvent(com.netflix.metacat.common.server.events.MetacatUpdateDatabasePostEvent) Collectors(java.util.stream.Collectors) MetacatNotFoundException(com.netflix.metacat.common.exception.MetacatNotFoundException) CatalogDto(com.netflix.metacat.common.dto.CatalogDto) MetacatCatalogConfig(com.netflix.metacat.main.spi.MetacatCatalogConfig) List(java.util.List) Map(java.util.Map) MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) ConnectorContext(com.netflix.metacat.common.server.connectors.ConnectorContext) ConnectorManager(com.netflix.metacat.main.manager.ConnectorManager) Nonnull(javax.annotation.Nonnull) CreateCatalogDto(com.netflix.metacat.common.dto.CreateCatalogDto) CatalogDto(com.netflix.metacat.common.dto.CatalogDto) MetacatCatalogConfig(com.netflix.metacat.main.spi.MetacatCatalogConfig) ConnectorContext(com.netflix.metacat.common.server.connectors.ConnectorContext) Nonnull(javax.annotation.Nonnull)

Example 2 with CatalogDto

use of com.netflix.metacat.common.dto.CatalogDto in project metacat by Netflix.

the class ElasticSearchMetacatRefresh method _processCatalogs.

@SuppressWarnings("checkstyle:methodname")
private ListenableFuture<Void> _processCatalogs(final List<String> catalogNames) {
    log.info("Start: Full refresh of catalogs: {}", catalogNames);
    final List<ListenableFuture<CatalogDto>> getCatalogFutures = catalogNames.stream().map(catalogName -> service.submit(() -> {
        CatalogDto result = null;
        try {
            result = getCatalog(catalogName);
        } catch (Exception e) {
            log.error("Failed to retrieve catalog: {}", catalogName);
            elasticSearchUtil.log("ElasticSearchMetacatRefresh.getCatalog", ElasticSearchDoc.Type.catalog.name(), catalogName, null, e.getMessage(), e, true);
        }
        return result;
    })).collect(Collectors.toList());
    return Futures.transformAsync(Futures.successfulAsList(getCatalogFutures), input -> {
        final List<ListenableFuture<Void>> processCatalogFutures = input.stream().filter(NOT_NULL).map(catalogDto -> {
            final List<QualifiedName> databaseNames = getDatabaseNamesToRefresh(catalogDto);
            return _processDatabases(catalogDto.getName(), databaseNames);
        }).filter(NOT_NULL).collect(Collectors.toList());
        return Futures.transform(Futures.successfulAsList(processCatalogFutures), Functions.constant(null));
    });
}
Also used : UserMetadataService(com.netflix.metacat.common.server.usermetadata.UserMetadataService) CatalogService(com.netflix.metacat.main.services.CatalogService) MetacatEventBus(com.netflix.metacat.common.server.events.MetacatEventBus) SortOrder(com.netflix.metacat.common.dto.SortOrder) MetacatContextManager(com.netflix.metacat.common.server.util.MetacatContextManager) PartitionService(com.netflix.metacat.main.services.PartitionService) DatabaseDto(com.netflix.metacat.common.dto.DatabaseDto) TagService(com.netflix.metacat.common.server.usermetadata.TagService) DatabaseService(com.netflix.metacat.main.services.DatabaseService) Splitter(com.google.common.base.Splitter) NonNull(lombok.NonNull) Predicate(java.util.function.Predicate) Pageable(com.netflix.metacat.common.dto.Pageable) Set(java.util.Set) CatalogMappingDto(com.netflix.metacat.common.dto.CatalogMappingDto) QualifiedName(com.netflix.metacat.common.QualifiedName) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) CatalogDto(com.netflix.metacat.common.dto.CatalogDto) HasMetadata(com.netflix.metacat.common.dto.HasMetadata) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) PartitionDto(com.netflix.metacat.common.dto.PartitionDto) Optional(java.util.Optional) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) Sort(com.netflix.metacat.common.dto.Sort) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) MetacatDeleteTablePostEvent(com.netflix.metacat.common.server.events.MetacatDeleteTablePostEvent) TableDto(com.netflix.metacat.common.dto.TableDto) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Supplier(java.util.function.Supplier) DatabaseNotFoundException(com.netflix.metacat.common.server.connectors.exception.DatabaseNotFoundException) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) TableService(com.netflix.metacat.main.services.TableService) MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) Config(com.netflix.metacat.common.server.properties.Config) Nonnull(javax.annotation.Nonnull) ExecutorService(java.util.concurrent.ExecutorService) Metrics(com.netflix.metacat.common.server.monitoring.Metrics) Functions(com.google.common.base.Functions) Throwables(com.google.common.base.Throwables) TimeUnit(java.util.concurrent.TimeUnit) Futures(com.google.common.util.concurrent.Futures) Registry(com.netflix.spectator.api.Registry) Instant(org.joda.time.Instant) CatalogDto(com.netflix.metacat.common.dto.CatalogDto) QualifiedName(com.netflix.metacat.common.QualifiedName) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DatabaseNotFoundException(com.netflix.metacat.common.server.connectors.exception.DatabaseNotFoundException)

Aggregations

MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)2 QualifiedName (com.netflix.metacat.common.QualifiedName)2 CatalogDto (com.netflix.metacat.common.dto.CatalogDto)2 CatalogMappingDto (com.netflix.metacat.common.dto.CatalogMappingDto)2 MetacatEventBus (com.netflix.metacat.common.server.events.MetacatEventBus)2 UserMetadataService (com.netflix.metacat.common.server.usermetadata.UserMetadataService)2 MetacatContextManager (com.netflix.metacat.common.server.util.MetacatContextManager)2 CatalogService (com.netflix.metacat.main.services.CatalogService)2 List (java.util.List)2 Functions (com.google.common.base.Functions)1 Splitter (com.google.common.base.Splitter)1 Strings (com.google.common.base.Strings)1 Throwables (com.google.common.base.Throwables)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1