use of org.springframework.context.event.EventListener in project metacat by Netflix.
the class SNSNotificationServiceImpl method notifyOfTableUpdate.
/**
* {@inheritDoc}
*/
@Override
@EventListener
public void notifyOfTableUpdate(final MetacatUpdateTablePostEvent event) {
log.debug("Received UpdateTableEvent {}", event);
UpdateTableMessage message = null;
try {
message = this.createUpdateTableMessage(UUID.randomUUID().toString(), event.getRequestContext().getTimestamp(), event.getRequestContext().getId(), event.getName().toString(), event.getOldTable(), event.getCurrentTable());
this.publishNotification(this.tableTopicArn, message, event.getName(), "Unable to publish update table notification", Metrics.CounterSNSNotificationTableUpdate.getMetricName(), true);
} catch (final Exception e) {
this.notificationMetric.handleException(event.getName(), "Unable to create json patch for update table notification", Metrics.CounterSNSNotificationTableUpdate.getMetricName(), message, e);
}
}
use of org.springframework.context.event.EventListener in project metacat by Netflix.
the class ElasticSearchEventHandlers method metacatCreateTablePostEventHandler.
/**
* Subscriber.
*
* @param event event
*/
@EventListener
public void metacatCreateTablePostEventHandler(final MetacatCreateTablePostEvent event) {
log.debug("Received CreateTableEvent {}", event);
this.tableCreateEventsDelayTimer.record(System.currentTimeMillis() - event.getRequestContext().getTimestamp(), TimeUnit.MILLISECONDS);
this.tableCreateTimer.record(() -> {
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);
});
}
use of org.springframework.context.event.EventListener in project metacat by Netflix.
the class ElasticSearchEventHandlers method metacatUpdateTablePostEventHandler.
/**
* Subscriber.
*
* @param event event
*/
@EventListener
public void metacatUpdateTablePostEventHandler(final MetacatUpdateTablePostEvent event) {
log.debug("Received UpdateTableEvent {}", event);
this.tableUpdateEventsDelayTimer.record(System.currentTimeMillis() - event.getRequestContext().getTimestamp(), TimeUnit.MILLISECONDS);
this.tableUpdateTimer.record(() -> {
final TableDto dto = event.getCurrentTable();
final ElasticSearchDoc doc = new ElasticSearchDoc(dto.getName().toString(), dto, event.getRequestContext().getUserName(), false);
final ElasticSearchDoc oldDoc = es.get(ElasticSearchDoc.Type.table.name(), doc.getId());
es.save(ElasticSearchDoc.Type.table.name(), doc.getId(), doc);
if (oldDoc == null || oldDoc.getDto() == null || !Objects.equals(((TableDto) oldDoc.getDto()).getDataMetadata(), dto.getDataMetadata())) {
updateEntitiesWithSameUri(ElasticSearchDoc.Type.table.name(), dto, event.getRequestContext().getUserName());
}
});
}
use of org.springframework.context.event.EventListener in project ArachneCentralAPI by OHDSI.
the class AntivirusServiceImpl method processRequest.
@EventListener
@Async(value = "antivirusScanExecutor")
public void processRequest(AntivirusJobEvent event) {
final AntivirusJob antivirusJob = event.getAntivirusJob();
final AntivirusJobFileType fileType = antivirusJob.getAntivirusJobFileType();
final Long fileId = antivirusJob.getFileId();
logger.debug(PROCESSING_SCAN_REQUEST, fileId, fileType);
String description = null;
AntivirusStatus status;
try {
final ScanResult scan = retryTemplate.execute((RetryCallback<ScanResult, Exception>) retryContext -> {
logger.debug(PROCESSING_SCAN_ATTEMPT, fileId, fileType);
return scan(antivirusJob.getContent());
});
if (scan instanceof ScanResult.OK) {
status = AntivirusStatus.OK;
} else {
status = AntivirusStatus.INFECTED;
description = scan.toString();
}
} catch (Exception e) {
logger.error("Error scanning file: {}", e.getMessage());
if (e instanceof ClamavException) {
final Throwable cause = e.getCause();
description = cause.getMessage();
} else {
description = e.getMessage();
}
status = AntivirusStatus.NOT_SCANNED;
}
logger.debug(PROCESSING_SCAN_RESULT, fileId, fileType, status);
publishResponse(fileType, fileId, status, description);
}
Aggregations