Examples of OCreateRecordTask


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

         executionModeSynch = iMode == 0;

       if (executionModeSynch) {
         // SYNCHRONOUS CALL: REPLICATE IT
         final Object masterResult = dManager.sendRequest(getName(), Collections.singleton(clusterName), nodes,
             new OCreateRecordTask(iRecordId, iContent, iRecordVersion, iRecordType), EXECUTION_MODE.RESPONSE);

         if (masterResult instanceof ONeedRetryException)
           throw (ONeedRetryException) masterResult;
         else if (masterResult instanceof Throwable)
           throw new ODistributedException("Error on execution distributed CREATE_RECORD", (Throwable) masterResult);

         // COPY THE CLUSTER POS -> RID
         final OPlaceholder masterPlaceholder = (OPlaceholder) masterResult;
         iRecordId.copyFrom(masterPlaceholder.getIdentity());

         return new OStorageOperationResult<OPhysicalPosition>(new OPhysicalPosition(masterPlaceholder.getIdentity()
             .getClusterPosition(), masterPlaceholder.getRecordVersion()));
       }

       final OStorageOperationResult<OPhysicalPosition> localResult = wrapped.createRecord(iRecordId, iContent, iRecordVersion,
           iRecordType, iMode, iCallback);

       // ASYNCHRONOUSLY REPLICATE IT TO ALL THE OTHER NODES
       nodes.remove(getName());
       if (!nodes.isEmpty()) {
         asynchronousExecution(new OAsynchDistributedOperation(getName(), Collections.singleton(clusterName), nodes,
             new OCreateRecordTask(iRecordId, iContent, iRecordVersion, iRecordType)));
       }

       return localResult;

     } catch (ONeedRetryException e) {
View Full Code Here

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

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

             }
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.