Examples of OTxTask


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

       wrapped.commit(iTx, callback);
       return;
     }

     try {
       final OTxTask txTask = new OTxTask();
       final Set<String> involvedClusters = new HashSet<String>();

       for (ORecordOperation op : iTx.getCurrentRecordEntries()) {
         final OAbstractRecordReplicatedTask task;

         final ORecord record = op.getRecord();

         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());
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.