Examples of OUpdateRecordTask


Examples of com.orientechnologies.orient.server.distributed.task.OUpdateRecordTask

         // 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;
View Full Code Here

Examples of com.orientechnologies.orient.server.distributed.task.OUpdateRecordTask

           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) {

             }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.