public void performCleanup() { deleteOperations.putAll(performProcessCleanup()); if (isDmnEnabled()) { deleteOperations.putAll(performDmnCleanup()); } DbOperation batchCleanup = performBatchCleanup(); deleteOperations.put(batchCleanup.getEntityType(), batchCleanup); }
protected Map<String, Long> reportMetrics() { Map<String, Long> reports = new HashMap<>(); DbOperation deleteOperationProcessInstance = deleteOperations.get(HistoricProcessInstanceEntity.class); if (deleteOperationProcessInstance != null) { reports.put(Metrics.HISTORY_CLEANUP_REMOVED_PROCESS_INSTANCES, (long) deleteOperationProcessInstance.getRowsAffected()); } DbOperation deleteOperationDecisionInstance = deleteOperations.get(HistoricDecisionInstanceEntity.class); if (deleteOperationDecisionInstance != null) { reports.put(Metrics.HISTORY_CLEANUP_REMOVED_DECISION_INSTANCES, (long) deleteOperationDecisionInstance.getRowsAffected()); } DbOperation deleteOperationBatch = deleteOperations.get(HistoricBatchEntity.class); if (deleteOperationBatch != null) { reports.put(Metrics.HISTORY_CLEANUP_REMOVED_BATCH_OPERATIONS, (long) deleteOperationBatch.getRowsAffected()); } return reports; }
@Override public void recycle() { statement = null; parameter = null; super.recycle(); }
flushResultSize++; DbOperation thisOperation = operationIt.next(); thisOperation.setRowsAffected(statementResult); if (thisOperation instanceof DbEntityOperation && ((DbEntityOperation) thisOperation).getEntity() instanceof HasDbRevision && !thisOperation.getOperationType().equals(DbOperationType.INSERT)) { final DbEntity dbEntity = ((DbEntityOperation) thisOperation).getEntity(); if (statementResult != 1) { } else { if (thisOperation.getOperationType().equals(DbOperationType.UPDATE)) { HasDbRevision versionedObject = (HasDbRevision) dbEntity; versionedObject.setRevision(versionedObject.getRevisionNext());
/** * Checks if the reason for a persistence exception was the foreign-key referencing of a (currently) * non-existing entity. This might happen with concurrent transactions, leading to an * OptimisticLockingException. * * @param failedOperation * @return */ private boolean isOptimisticLockingException(DbOperation failedOperation, Throwable cause) { boolean isConstraintViolation = ExceptionUtil.checkForeignKeyConstraintViolation(cause); boolean isVariableIntegrityViolation = ExceptionUtil.checkVariableIntegrityViolation(cause); if (isVariableIntegrityViolation) { return true; } else if ( isConstraintViolation && failedOperation instanceof DbEntityOperation && ((DbEntityOperation) failedOperation).getEntity() instanceof HasDbReferences && (failedOperation.getOperationType().equals(DbOperationType.INSERT) || failedOperation.getOperationType().equals(DbOperationType.UPDATE)) ) { DbEntity entity = ((DbEntityOperation) failedOperation).getEntity(); for (Map.Entry<String, Class> reference : ((HasDbReferences)entity).getReferencedEntitiesIdAndClass().entrySet()) { DbEntity referencedEntity = this.persistenceSession.selectById(reference.getValue(), reference.getKey()); if (referencedEntity == null) { return true; } } } return false; }
if (dbOperation.isFailed() || doOptimisticLockingException) { handleOptimisticLockingException(dbOperation);
flushResultSize++; DbOperation thisOperation = operationIt.next(); thisOperation.setRowsAffected(statementResult); if (thisOperation instanceof DbEntityOperation && ((DbEntityOperation) thisOperation).getEntity() instanceof HasDbRevision && !thisOperation.getOperationType().equals(DbOperationType.INSERT)) { final DbEntity dbEntity = ((DbEntityOperation) thisOperation).getEntity(); if (statementResult != 1) { } else { if (thisOperation.getOperationType().equals(DbOperationType.UPDATE)) { HasDbRevision versionedObject = (HasDbRevision) dbEntity; versionedObject.setRevision(versionedObject.getRevisionNext());
/** * Checks if the reason for a persistence exception was the foreign-key referencing of a (currently) * non-existing entity. This might happen with concurrent transactions, leading to an * OptimisticLockingException. * * @param failedOperation * @return */ private boolean isOptimisticLockingException(DbOperation failedOperation, Throwable cause) { boolean isConstraintViolation = ExceptionUtil.checkForeignKeyConstraintViolation(cause); boolean isVariableIntegrityViolation = ExceptionUtil.checkVariableIntegrityViolation(cause); if (isVariableIntegrityViolation) { return true; } else if ( isConstraintViolation && failedOperation instanceof DbEntityOperation && ((DbEntityOperation) failedOperation).getEntity() instanceof HasDbReferences && (failedOperation.getOperationType().equals(DbOperationType.INSERT) || failedOperation.getOperationType().equals(DbOperationType.UPDATE)) ) { DbEntity entity = ((DbEntityOperation) failedOperation).getEntity(); for (Map.Entry<String, Class> reference : ((HasDbReferences)entity).getReferencedEntitiesIdAndClass().entrySet()) { DbEntity referencedEntity = this.persistenceSession.selectById(reference.getValue(), reference.getKey()); if (referencedEntity == null) { return true; } } } return false; }
if (dbOperation.isFailed() || doOptimisticLockingException) { handleOptimisticLockingException(dbOperation);
flushResultSize++; DbOperation thisOperation = operationIt.next(); thisOperation.setRowsAffected(statementResult); if (thisOperation instanceof DbEntityOperation && ((DbEntityOperation) thisOperation).getEntity() instanceof HasDbRevision && !thisOperation.getOperationType().equals(DbOperationType.INSERT)) { final DbEntity dbEntity = ((DbEntityOperation) thisOperation).getEntity(); if (statementResult != 1) { } else { if (thisOperation.getOperationType().equals(DbOperationType.UPDATE)) { HasDbRevision versionedObject = (HasDbRevision) dbEntity; versionedObject.setRevision(versionedObject.getRevisionNext());
public void performCleanup() { deleteOperations.putAll(performProcessCleanup()); if (isDmnEnabled()) { deleteOperations.putAll(performDmnCleanup()); } DbOperation batchCleanup = performBatchCleanup(); deleteOperations.put(batchCleanup.getEntityType(), batchCleanup); }
@Override public void recycle() { statement = null; parameter = null; super.recycle(); }
protected Map<String, Long> reportMetrics() { Map<String, Long> reports = new HashMap<>(); DbOperation deleteOperationProcessInstance = deleteOperations.get(HistoricProcessInstanceEntity.class); if (deleteOperationProcessInstance != null) { reports.put(Metrics.HISTORY_CLEANUP_REMOVED_PROCESS_INSTANCES, (long) deleteOperationProcessInstance.getRowsAffected()); } DbOperation deleteOperationDecisionInstance = deleteOperations.get(HistoricDecisionInstanceEntity.class); if (deleteOperationDecisionInstance != null) { reports.put(Metrics.HISTORY_CLEANUP_REMOVED_DECISION_INSTANCES, (long) deleteOperationDecisionInstance.getRowsAffected()); } DbOperation deleteOperationBatch = deleteOperations.get(HistoricBatchEntity.class); if (deleteOperationBatch != null) { reports.put(Metrics.HISTORY_CLEANUP_REMOVED_BATCH_OPERATIONS, (long) deleteOperationBatch.getRowsAffected()); } return reports; }
public void executeDbOperation(DbOperation operation) { switch(operation.getOperationType()) { case INSERT: insertEntity((DbEntityOperation) operation); break; case DELETE: deleteEntity((DbEntityOperation) operation); break; case DELETE_BULK: deleteBulk((DbBulkOperation) operation); break; case UPDATE: updateEntity((DbEntityOperation) operation); break; case UPDATE_BULK: updateBulk((DbBulkOperation) operation); break; } }
if (dbOperation.isFailed() || doOptimisticLockingException) { handleOptimisticLockingException(dbOperation);
.deleteHistoricActivityInstancesByRemovalTime(removalTime, minuteFrom, minuteTo, batchSize); deleteOperations.put(deleteActivityInstances.getEntityType(), deleteActivityInstances); deleteOperations.put(deleteTaskInstances.getEntityType(), deleteTaskInstances); deleteOperations.put(deleteVariableInstances.getEntityType(), deleteVariableInstances); deleteOperations.put(deleteDetails.getEntityType(), deleteDetails); deleteOperations.put(deleteIncidents.getEntityType(), deleteIncidents); deleteOperations.put(deleteTaskLog.getEntityType(), deleteTaskLog); deleteOperations.put(deleteJobLog.getEntityType(), deleteJobLog); deleteOperations.put(deleteOperationLog.getEntityType(), deleteOperationLog); deleteOperations.put(deleteIdentityLinkLog.getEntityType(), deleteIdentityLinkLog); deleteOperations.put(deleteComments.getEntityType(), deleteComments); deleteOperations.put(deleteAttachments.getEntityType(), deleteAttachments); deleteOperations.put(deleteByteArrays.getEntityType(), deleteByteArrays); deleteOperations.put(deleteProcessInstances.getEntityType(), deleteProcessInstances);
public void recycle() { entity = null; super.recycle(); }
protected boolean shouldRescheduleNow() { int batchSize = getBatchSize(); for (DbOperation deleteOperation : deleteOperations.values()) { if (deleteOperation.getRowsAffected() == batchSize) { return true; } } return false; }
public void executeDbOperation(DbOperation operation) { switch(operation.getOperationType()) { case INSERT: insertEntity((DbEntityOperation) operation); break; case DELETE: deleteEntity((DbEntityOperation) operation); break; case DELETE_BULK: deleteBulk((DbBulkOperation) operation); break; case UPDATE: updateEntity((DbEntityOperation) operation); break; case UPDATE_BULK: updateBulk((DbBulkOperation) operation); break; } }
.deleteHistoricActivityInstancesByRemovalTime(removalTime, minuteFrom, minuteTo, batchSize); deleteOperations.put(deleteActivityInstances.getEntityType(), deleteActivityInstances); deleteOperations.put(deleteTaskInstances.getEntityType(), deleteTaskInstances); deleteOperations.put(deleteVariableInstances.getEntityType(), deleteVariableInstances); deleteOperations.put(deleteDetails.getEntityType(), deleteDetails); deleteOperations.put(deleteIncidents.getEntityType(), deleteIncidents); deleteOperations.put(deleteTaskLog.getEntityType(), deleteTaskLog); deleteOperations.put(deleteJobLog.getEntityType(), deleteJobLog); deleteOperations.put(deleteOperationLog.getEntityType(), deleteOperationLog); deleteOperations.put(deleteIdentityLinkLog.getEntityType(), deleteIdentityLinkLog); deleteOperations.put(deleteComments.getEntityType(), deleteComments); deleteOperations.put(deleteAttachments.getEntityType(), deleteAttachments); deleteOperations.put(deleteByteArrays.getEntityType(), deleteByteArrays); deleteOperations.put(deleteProcessInstances.getEntityType(), deleteProcessInstances);