Search in sources :

Example 1 with HistoricJobLogEventEntity

use of org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity in project camunda-bpm-platform by camunda.

the class GetHistoricJobLogExceptionStacktraceCmd method execute.

public String execute(CommandContext commandContext) {
    ensureNotNull("historicJobLogId", historicJobLogId);
    HistoricJobLogEventEntity job = commandContext.getHistoricJobLogManager().findHistoricJobLogById(historicJobLogId);
    ensureNotNull("No historic job log found with id " + historicJobLogId, "historicJobLog", job);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadHistoricJobLog(job);
    }
    return job.getExceptionStacktrace();
}
Also used : CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) HistoricJobLogEventEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)

Example 2 with HistoricJobLogEventEntity

use of org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity in project camunda-bpm-platform by camunda.

the class HistoryCleanupHistoricBatchTest method findExceptionByteArrayIds.

private List<String> findExceptionByteArrayIds() {
    List<String> exceptionByteArrayIds = new ArrayList<String>();
    List<HistoricJobLog> historicJobLogs = historyService.createHistoricJobLogQuery().list();
    for (HistoricJobLog historicJobLog : historicJobLogs) {
        HistoricJobLogEventEntity historicJobLogEventEntity = (HistoricJobLogEventEntity) historicJobLog;
        if (historicJobLogEventEntity.getExceptionByteArrayId() != null) {
            exceptionByteArrayIds.add(historicJobLogEventEntity.getExceptionByteArrayId());
        }
    }
    return exceptionByteArrayIds;
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) ArrayList(java.util.ArrayList) HistoricJobLogEventEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)

Example 3 with HistoricJobLogEventEntity

use of org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity in project camunda-bpm-platform by camunda.

the class HistoricJobLogTest method testDeleteByteArray.

public void testDeleteByteArray() {
    final String processDefinitionId = "myProcessDefition";
    processEngineConfiguration.getCommandExecutorTxRequiresNew().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            for (int i = 0; i < 1234; i++) {
                HistoricJobLogEventEntity log = new HistoricJobLogEventEntity();
                log.setJobId(String.valueOf(i));
                log.setTimestamp(new Date());
                log.setJobDefinitionType(MessageEntity.TYPE);
                log.setProcessDefinitionId(processDefinitionId);
                byte[] aByteValue = StringUtil.toByteArray("abc");
                ByteArrayEntity byteArray = ExceptionUtil.createJobExceptionByteArray(aByteValue);
                log.setExceptionByteArrayId(byteArray.getId());
                commandContext.getHistoricJobLogManager().insert(log);
            }
            return null;
        }
    });
    assertEquals(1234, historyService.createHistoricJobLogQuery().count());
    processEngineConfiguration.getCommandExecutorTxRequiresNew().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByProcessDefinitionId(processDefinitionId);
            return null;
        }
    });
    assertEquals(0, historyService.createHistoricJobLogQuery().count());
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity) Date(java.util.Date) HistoricJobLogEventEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)

Example 4 with HistoricJobLogEventEntity

use of org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity in project camunda-bpm-platform by camunda.

the class DefaultHistoryEventProducer method createHistoricJobLogEvt.

protected HistoryEvent createHistoricJobLogEvt(Job job, HistoryEventType eventType) {
    HistoricJobLogEventEntity event = newHistoricJobLogEntity(job);
    initHistoricJobLogEvent(event, job, eventType);
    return event;
}
Also used : HistoricJobLogEventEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)

Example 5 with HistoricJobLogEventEntity

use of org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity in project camunda-bpm-platform by camunda.

the class DefaultHistoryEventProducer method createHistoricJobLogFailedEvt.

public HistoryEvent createHistoricJobLogFailedEvt(Job job, Throwable exception) {
    HistoricJobLogEventEntity event = (HistoricJobLogEventEntity) createHistoricJobLogEvt(job, HistoryEventTypes.JOB_FAIL);
    if (exception != null) {
        // exception message
        event.setJobExceptionMessage(exception.getMessage());
        // stacktrace
        String exceptionStacktrace = getExceptionStacktrace(exception);
        byte[] exceptionBytes = toByteArray(exceptionStacktrace);
        ByteArrayEntity byteArray = createJobExceptionByteArray(exceptionBytes);
        event.setExceptionByteArrayId(byteArray.getId());
    }
    return event;
}
Also used : ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity) HistoricJobLogEventEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)

Aggregations

HistoricJobLogEventEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)6 ArrayList (java.util.ArrayList)2 HistoricJobLog (org.camunda.bpm.engine.history.HistoricJobLog)2 ByteArrayEntity (org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity)2 Date (java.util.Date)1 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1