Search in sources :

Example 16 with EventListener

use of org.springframework.context.event.EventListener 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)

Example 17 with EventListener

use of org.springframework.context.event.EventListener in project metacat by Netflix.

the class MetacatElasticSearchEventHandlers method metacatRenameTablePostEventHandler.

/**
     * Subscriber.
     *
     * @param event event
     */
@EventListener
public void metacatRenameTablePostEventHandler(final MetacatRenameTablePostEvent event) {
    log.debug("Received RenameTableEvent {}", event);
    registry.counter(Metrics.CounterElasticSearchTableRename.name()).increment();
    es.delete(ElasticSearchDoc.Type.table.name(), event.getName().toString());
    final TableDto dto = event.getCurrentTable();
    final ElasticSearchDoc doc = new ElasticSearchDoc(dto.getName().toString(), dto, event.getRequestContext().getUserName(), false);
    es.save(ElasticSearchDoc.Type.table.name(), doc.getId(), doc.toJsonString());
}
Also used : TableDto(com.netflix.metacat.common.dto.TableDto) EventListener(org.springframework.context.event.EventListener)

Example 18 with EventListener

use of org.springframework.context.event.EventListener in project metacat by Netflix.

the class MetacatElasticSearchEventHandlers method metacatCreateTablePostEventHandler.

/**
     * Subscriber.
     *
     * @param event event
     */
@EventListener
public void metacatCreateTablePostEventHandler(final MetacatCreateTablePostEvent event) {
    log.debug("Received CreateTableEvent {}", event);
    registry.counter(Metrics.CounterElasticSearchTableCreate.name()).increment();
    final TableDto dto = event.getTable();
    final ElasticSearchDoc doc = new ElasticSearchDoc(dto.getName().toString(), dto, event.getRequestContext().getUserName(), false);
    es.save(ElasticSearchDoc.Type.table.name(), doc.getId(), doc.toJsonString());
}
Also used : TableDto(com.netflix.metacat.common.dto.TableDto) EventListener(org.springframework.context.event.EventListener)

Example 19 with EventListener

use of org.springframework.context.event.EventListener in project metacat by Netflix.

the class MetacatElasticSearchEventHandlers method metacatCreateDatabasePostEventHandler.

/**
     * Subscriber.
     *
     * @param event event
     */
@EventListener
public void metacatCreateDatabasePostEventHandler(final MetacatCreateDatabasePostEvent event) {
    log.debug("Received CreateDatabaseEvent {}", event);
    registry.counter(Metrics.CounterElasticSearchDatabaseCreate.name()).increment();
    final DatabaseDto dto = event.getDatabase();
    final ElasticSearchDoc doc = new ElasticSearchDoc(dto.getName().toString(), dto, event.getRequestContext().getUserName(), false);
    es.save(ElasticSearchDoc.Type.database.name(), doc.getId(), doc.toJsonString());
}
Also used : DatabaseDto(com.netflix.metacat.common.dto.DatabaseDto) EventListener(org.springframework.context.event.EventListener)

Aggregations

EventListener (org.springframework.context.event.EventListener)19 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)6 IOException (java.io.IOException)6 TableDto (com.netflix.metacat.common.dto.TableDto)5 AbstractCasEvent (org.apereo.cas.support.events.AbstractCasEvent)4 CasEvent (org.apereo.cas.support.events.dao.CasEvent)4 DatabaseDto (com.netflix.metacat.common.dto.DatabaseDto)3 PartitionDto (com.netflix.metacat.common.dto.PartitionDto)2 UpdateTableMessage (com.netflix.metacat.common.dto.notifications.sns.messages.UpdateTableMessage)2 UpdateTablePartitionsMessage (com.netflix.metacat.common.dto.notifications.sns.messages.UpdateTablePartitionsMessage)2 TablePartitionsUpdatePayload (com.netflix.metacat.common.dto.notifications.sns.payloads.TablePartitionsUpdatePayload)2 CasAuthenticationPolicyFailureEvent (org.apereo.cas.support.events.authentication.CasAuthenticationPolicyFailureEvent)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 User (com.naturalprogrammer.spring.tutorial.domain.User)1 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)1 AddPartitionMessage (com.netflix.metacat.common.dto.notifications.sns.messages.AddPartitionMessage)1 CreateTableMessage (com.netflix.metacat.common.dto.notifications.sns.messages.CreateTableMessage)1 DeletePartitionMessage (com.netflix.metacat.common.dto.notifications.sns.messages.DeletePartitionMessage)1 DeleteTableMessage (com.netflix.metacat.common.dto.notifications.sns.messages.DeleteTableMessage)1 MetacatJsonLocator (com.netflix.metacat.common.json.MetacatJsonLocator)1