use of org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity in project incubator-inlong by apache.
the class LogableEventListener method executeListenerWithLog.
private ListenerResult executeListenerWithLog(WorkflowContext context) {
WorkflowEventLogEntity logEntity = buildEventLog(context);
ListenerResult result;
try {
result = eventListener.listen(context);
logEntity.setStatus(result.isSuccess() ? EventStatus.SUCCESS.getStatus() : EventStatus.FAILED.getStatus());
logEntity.setRemark(result.getRemark());
logEntity.setException(Optional.ofNullable(result.getException()).map(Exception::getMessage).orElse(null));
} catch (Exception e) {
logEntity.setStatus(EventStatus.FAILED.getStatus());
logEntity.setException(e.getMessage());
log.error("listener exception:{}", JsonUtils.toJson(logEntity), e);
if (!async()) {
throw new WorkflowListenerException(e.getMessage());
}
result = ListenerResult.fail(e);
} finally {
logEntity.setEndTime(new Date());
eventLogMapper.insert(logEntity);
}
return result;
}
use of org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity in project incubator-inlong by apache.
the class EventListenerServiceImpl method executeEventListener.
@Override
public void executeEventListener(Integer eventLogId) {
WorkflowEventLogEntity eventLogEntity = eventLogMapper.selectById(eventLogId);
Preconditions.checkNotNull(eventLogEntity, "event log not exist with id: " + eventLogId);
if (ProcessEvent.class.getSimpleName().equals(eventLogEntity.getEventType())) {
this.executeProcessEventListener(eventLogEntity.getProcessId(), eventLogEntity.getListener());
return;
}
if (TaskEvent.class.getSimpleName().equals(eventLogEntity.getEventType())) {
this.executeTaskEventListener(eventLogEntity.getTaskId(), eventLogEntity.getListener());
return;
}
throw new WorkflowException("unknown event type: " + eventLogEntity.getEventType());
}
use of org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity in project incubator-inlong by apache.
the class LogableEventListener method executeListenerWithoutLog.
private ListenerResult executeListenerWithoutLog(WorkflowContext context) {
WorkflowEventLogEntity workflowEventLogEntity = buildEventLog(context);
try {
ListenerResult result = eventListener.listen(context);
log.debug("listener execute result:{} - {}", workflowEventLogEntity, result);
return result;
} catch (Exception e) {
log.error("listener exception:{}", workflowEventLogEntity, e);
if (!async()) {
throw new WorkflowListenerException(e);
}
return ListenerResult.fail(e);
}
}
use of org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity in project incubator-inlong by apache.
the class LogableEventListener method buildEventLog.
protected WorkflowEventLogEntity buildEventLog(WorkflowContext context) {
WorkflowProcessEntity workflowProcessEntity = context.getProcessEntity();
Element currentElement = context.getCurrentElement();
WorkflowEventLogEntity logEntity = new WorkflowEventLogEntity();
logEntity.setProcessId(workflowProcessEntity.getId());
logEntity.setProcessName(workflowProcessEntity.getName());
logEntity.setProcessDisplayName(workflowProcessEntity.getDisplayName());
logEntity.setInlongGroupId(context.getProcessForm().getInlongGroupId());
logEntity.setElementName(currentElement.getName());
logEntity.setElementDisplayName(currentElement.getDisplayName());
logEntity.setEventType(event().getClass().getSimpleName());
logEntity.setEvent(event().name());
logEntity.setListener(eventListener.name());
logEntity.setStatus(EventStatus.EXECUTING.getStatus());
logEntity.setAsync(async() ? 1 : 0);
logEntity.setIp(NetworkUtils.getLocalIp());
logEntity.setStartTime(new Date());
return logEntity;
}
use of org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity in project incubator-inlong by apache.
the class LogableTaskEventListener method buildEventLog.
@Override
protected WorkflowEventLogEntity buildEventLog(WorkflowContext context) {
WorkflowEventLogEntity workflowEventLogEntity = super.buildEventLog(context);
workflowEventLogEntity.setTaskId(getTaskId(context));
return workflowEventLogEntity;
}
Aggregations