public static Object executeWithRetries(final OCallable<Object, Integer> callback, final int maxRetry, final int waitBetweenRetry, final ORecord[] recordToReloadOnRetry) { ONeedRetryException lastException = null; for (int retry = 0; retry < maxRetry; ++retry) { try { return callback.call(retry); } catch (ONeedRetryException e) { // SAVE LAST EXCEPTION AND RETRY lastException = e; if (recordToReloadOnRetry != null) { // RELOAD THE RECORDS for (ORecord r : recordToReloadOnRetry) r.reload(); } if (waitBetweenRetry > 0) try { Thread.sleep(waitBetweenRetry); } catch (InterruptedException ignore) { Thread.currentThread().interrupt(); break; } } } throw lastException; }
if (value != null && value instanceof ORecord && ((ORecord) value).getInternalStatus() == STATUS.NOT_LOADED) ((ORecord) value).reload(); } else if (value instanceof Map<?, ?>) value = getMapEntry((Map<String, ?>) value, fieldName);
private boolean isEventAlreadyExecuted() { final ORecord rec = document.getIdentity().getRecord(); if (rec == null) // SKIP EXECUTION BECAUSE THE EVENT WAS DELETED return true; final ODocument updated = rec.reload(); final Long currentExecutionId = updated.field(PROP_EXEC_ID); if (currentExecutionId == null) return false; if (currentExecutionId >= nextExecutionId) { OLogManager.instance() .info(this, "Scheduled event '%s' with id %d is already running (current id=%d)", getName(), nextExecutionId, currentExecutionId); // ALREADY RUNNING return true; } return false; }
try { if (rec.getIdentity().isValid()) rec.reload();