final ORecordId rid = (ORecordId) op.record.getIdentity();
switch (op.type) {
case ORecordOperation.CREATED:
task = new OCreateRecordTask(rid, record.toStream(), record.getRecordVersion(), ORecordInternal.getRecordType(record));
break;
case ORecordOperation.UPDATED:
// LOAD PREVIOUS CONTENT TO BE USED IN CASE OF UNDO
final OStorageOperationResult<ORawBuffer> previousContent = wrapped.readRecord(rid, null, false, null, false,
LOCKING_STRATEGY.DEFAULT);
if (previousContent.getResult() == null)
// DELETED
throw new OTransactionException("Cannot update record '" + rid + "' because has been deleted");
task = new OUpdateRecordTask(rid, previousContent.getResult().getBuffer(), previousContent.getResult().version,
record.toStream(), record.getRecordVersion());
break;
case ORecordOperation.DELETED:
task = new ODeleteRecordTask(rid, record.getRecordVersion());
break;
default:
continue;
}
involvedClusters.add(getClusterNameByRID(rid));
txTask.add(task);
}
final Set<String> nodes = dbCfg.getServers(involvedClusters);
Boolean executionModeSynch = dbCfg.isExecutionModeSynchronous(null);
if (executionModeSynch == null)
executionModeSynch = Boolean.TRUE;
if (executionModeSynch && !iTx.hasRecordCreation()) {
// SYNCHRONOUS CALL: REPLICATE IT
final Object result = dManager.sendRequest(getName(), involvedClusters, nodes, txTask, EXECUTION_MODE.RESPONSE);
if (result instanceof List<?>) {
final List<Object> list = (List<Object>) result;
for (int i = 0; i < txTask.getTasks().size(); ++i) {
final Object o = list.get(i);
final OAbstractRecordReplicatedTask task = txTask.getTasks().get(i);
if (task instanceof OCreateRecordTask) {
final OCreateRecordTask t = (OCreateRecordTask) task;
t.getRid().copyFrom(((OPlaceholder) o).getIdentity());
t.getVersion().copyFrom(((OPlaceholder) o).getRecordVersion());
} else if (task instanceof OUpdateRecordTask) {
final OUpdateRecordTask t = (OUpdateRecordTask) task;
t.getVersion().copyFrom((ORecordVersion) o);
} else if (task instanceof ODeleteRecordTask) {
}