// SYNCHRONOUS: LOAD PREVIOUS CONTENT TO BE USED IN CASE OF UNDO
final OStorageOperationResult<ORawBuffer> previousContent = readRecord(iRecordId, null, false, null, false,
LOCKING_STRATEGY.DEFAULT);
// REPLICATE IT
final Object result = dManager.sendRequest(getName(), Collections.singleton(clusterName), nodes, new OUpdateRecordTask(
iRecordId, previousContent.getResult().getBuffer(), previousContent.getResult().version, iContent, iVersion),
EXECUTION_MODE.RESPONSE);
if (result instanceof ONeedRetryException)
throw (ONeedRetryException) result;
else if (result instanceof Throwable)
throw new ODistributedException("Error on execution distributed UPDATE_RECORD", (Throwable) result);
// UPDATE LOCALLY
return new OStorageOperationResult<ORecordVersion>((ORecordVersion) result);
}
final OStorageOperationResult<ORecordVersion> localResult = wrapped.updateRecord(iRecordId, updateContent, iContent,
iVersion, iRecordType, iMode, iCallback);
nodes.remove(0);
if (!nodes.isEmpty()) {
// LOAD PREVIOUS CONTENT TO BE USED IN CASE OF UNDO
final OStorageOperationResult<ORawBuffer> previousContent = readRecord(iRecordId, null, false, null, false,
LOCKING_STRATEGY.DEFAULT);
asynchronousExecution(new OAsynchDistributedOperation(getName(), Collections.singleton(clusterName), nodes,
new OUpdateRecordTask(iRecordId, previousContent.getResult().getBuffer(), previousContent.getResult().version,
iContent, iVersion)));
}
return localResult;