Search in sources :

Example 1 with WorkflowEventLogEntity

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;
}
Also used : WorkflowEventLogEntity(org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) Date(java.util.Date)

Example 2 with WorkflowEventLogEntity

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());
}
Also used : ProcessEvent(org.apache.inlong.manager.workflow.event.process.ProcessEvent) WorkflowEventLogEntity(org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity) WorkflowException(org.apache.inlong.manager.common.exceptions.WorkflowException) TaskEvent(org.apache.inlong.manager.workflow.event.task.TaskEvent)

Example 3 with WorkflowEventLogEntity

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);
    }
}
Also used : WorkflowEventLogEntity(org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException)

Example 4 with WorkflowEventLogEntity

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;
}
Also used : Element(org.apache.inlong.manager.workflow.definition.Element) WorkflowEventLogEntity(org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) Date(java.util.Date)

Example 5 with WorkflowEventLogEntity

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;
}
Also used : WorkflowEventLogEntity(org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity)

Aggregations

WorkflowEventLogEntity (org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity)5 Date (java.util.Date)2 WorkflowListenerException (org.apache.inlong.manager.common.exceptions.WorkflowListenerException)2 WorkflowException (org.apache.inlong.manager.common.exceptions.WorkflowException)1 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)1 Element (org.apache.inlong.manager.workflow.definition.Element)1 ProcessEvent (org.apache.inlong.manager.workflow.event.process.ProcessEvent)1 TaskEvent (org.apache.inlong.manager.workflow.event.task.TaskEvent)1