Search in sources :

Example 36 with MetacatRequestContext

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

the class MetacatElasticSearchEventHandlers method metacatSaveTablePartitionPostEventHandler.

/**
     * Subscriber.
     *
     * @param event event
     */
@EventListener
public void metacatSaveTablePartitionPostEventHandler(final MetacatSaveTablePartitionPostEvent event) {
    log.debug("Received SaveTablePartitionEvent {}", event);
    registry.counter(Metrics.CounterElasticSearchPartitionSave.name()).increment();
    final List<PartitionDto> partitionDtos = event.getPartitions();
    final MetacatRequestContext context = event.getRequestContext();
    final List<ElasticSearchDoc> docs = partitionDtos.stream().map(dto -> new ElasticSearchDoc(dto.getName().toString(), dto, context.getUserName(), false)).collect(Collectors.toList());
    es.save(ElasticSearchDoc.Type.partition.name(), docs);
}
Also used : MetacatDeleteTablePartitionPostEvent(com.netflix.metacat.common.server.events.MetacatDeleteTablePartitionPostEvent) MetacatDeleteTablePostEvent(com.netflix.metacat.common.server.events.MetacatDeleteTablePostEvent) MetacatUpdateTablePostEvent(com.netflix.metacat.common.server.events.MetacatUpdateTablePostEvent) TableDto(com.netflix.metacat.common.dto.TableDto) MetacatRenameTablePostEvent(com.netflix.metacat.common.server.events.MetacatRenameTablePostEvent) EventListener(org.springframework.context.event.EventListener) DatabaseDto(com.netflix.metacat.common.dto.DatabaseDto) MetacatDeleteDatabasePostEvent(com.netflix.metacat.common.server.events.MetacatDeleteDatabasePostEvent) Collectors(java.util.stream.Collectors) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MetacatJsonLocator(com.netflix.metacat.common.json.MetacatJsonLocator) MetacatCreateDatabasePostEvent(com.netflix.metacat.common.server.events.MetacatCreateDatabasePostEvent) Objects(java.util.Objects) MetacatCreateTablePostEvent(com.netflix.metacat.common.server.events.MetacatCreateTablePostEvent) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) PartitionDto(com.netflix.metacat.common.dto.PartitionDto) Registry(com.netflix.spectator.api.Registry) MetacatSaveTablePartitionPostEvent(com.netflix.metacat.common.server.events.MetacatSaveTablePartitionPostEvent) MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) Metrics(com.netflix.metacat.common.server.monitoring.Metrics) MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) PartitionDto(com.netflix.metacat.common.dto.PartitionDto) EventListener(org.springframework.context.event.EventListener)

Aggregations

MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)36 ConnectorContext (com.netflix.metacat.common.server.connectors.ConnectorContext)21 QualifiedName (com.netflix.metacat.common.QualifiedName)15 TableDto (com.netflix.metacat.common.dto.TableDto)15 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)12 ConnectorTableService (com.netflix.metacat.common.server.connectors.ConnectorTableService)11 List (java.util.List)8 PartitionDto (com.netflix.metacat.common.dto.PartitionDto)7 ConnectorPartitionService (com.netflix.metacat.common.server.connectors.ConnectorPartitionService)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 GetPartitionsRequestDto (com.netflix.metacat.common.dto.GetPartitionsRequestDto)6 Lists (com.google.common.collect.Lists)5 DatabaseDto (com.netflix.metacat.common.dto.DatabaseDto)5 PartitionsSaveRequestDto (com.netflix.metacat.common.dto.PartitionsSaveRequestDto)5 NotFoundException (com.netflix.metacat.common.server.connectors.exception.NotFoundException)5 Collectors (java.util.stream.Collectors)5 Slf4j (lombok.extern.slf4j.Slf4j)5 HasMetadata (com.netflix.metacat.common.dto.HasMetadata)4 Pageable (com.netflix.metacat.common.dto.Pageable)4 PartitionsSaveResponseDto (com.netflix.metacat.common.dto.PartitionsSaveResponseDto)4