Examples of OTransactionOptimisticProxy


Examples of com.orientechnologies.orient.server.tx.OTransactionOptimisticProxy

    }

    case OChannelBinaryProtocol.REQUEST_TX_COMMIT: {
      data.commandInfo = "Transaction commit";

      final OTransactionOptimisticProxy tx = new OTransactionOptimisticProxy(
          (ODatabaseRecordTx) connection.database.getUnderlying(), channel);

      connection.database.begin(tx);
      try {
        connection.database.commit();
        channel.acquireExclusiveLock();
        try {
          sendOk(lastClientTxId);

          // SEND BACK ALL THE RECORD IDS FOR THE CREATED RECORDS
          channel.writeInt(tx.getCreatedRecords().size());
          for (Entry<ORecordId, ORecord<?>> entry : tx.getCreatedRecords().entrySet()) {
            channel.writeRID(entry.getKey());
            channel.writeRID(entry.getValue().getIdentity());

            // IF THE NEW OBJECT HAS VERSION > 0 MEANS THAT HAS BEEN UPDATED IN THE SAME TX. THIS HAPPENS FOR GRAPHS
            if (entry.getValue().getVersion() > 0)
              tx.getUpdatedRecords().put((ORecordId) entry.getValue().getIdentity(), entry.getValue());
          }
         
          // SEND BACK ALL THE NEW VERSIONS FOR THE UPDATED RECORDS
          channel.writeInt(tx.getUpdatedRecords().size());
          for (Entry<ORecordId, ORecord<?>> entry : tx.getUpdatedRecords().entrySet()) {
            channel.writeRID(entry.getKey());
            channel.writeInt(entry.getValue().getVersion());
          }
        } finally {
          channel.releaseExclusiveLock();
View Full Code Here

Examples of com.orientechnologies.orient.server.tx.OTransactionOptimisticProxy

    }

    case OChannelBinaryProtocol.REQUEST_TX_COMMIT: {
      data.commandInfo = "Transaction commit";

      final OTransactionOptimisticProxy tx = new OTransactionOptimisticProxy(
          (ODatabaseRecordTx) connection.database.getUnderlying(), channel);

      connection.database.begin(tx);
      try {
        connection.database.commit();
        sendOk(lastClientTxId);

        // SEND BACK ALL THE NEW VERSIONS FOR THE UPDATED RECORDS
        channel.writeInt(tx.getUpdatedRecords().size());
        for (Entry<ORecordId, ORecord<?>> entry : tx.getUpdatedRecords().entrySet()) {
          channel.writeRID(entry.getKey());
          channel.writeInt(entry.getValue().getVersion());
        }
      } catch (Exception e) {
        connection.database.rollback();
View Full Code Here

Examples of com.orientechnologies.orient.server.tx.OTransactionOptimisticProxy

    }

    case OChannelBinaryProtocol.REQUEST_TX_COMMIT: {
      data.commandInfo = "Transaction commit";

      final OTransactionOptimisticProxy tx = new OTransactionOptimisticProxy(
          (ODatabaseRecordTx) connection.database.getUnderlying(), channel);

      connection.database.begin(tx);
      try {
        connection.database.commit();
        channel.acquireExclusiveLock();
        try {
          sendOk(lastClientTxId);

          // SEND BACK ALL THE RECORD IDS FOR THE CREATED RECORDS
          channel.writeInt(tx.getCreatedRecords().size());
          for (Entry<ORecordId, ORecord<?>> entry : tx.getCreatedRecords().entrySet()) {
            channel.writeRID(entry.getKey());
            channel.writeRID(entry.getValue().getIdentity());
          }
          // SEND BACK ALL THE NEW VERSIONS FOR THE UPDATED RECORDS
          channel.writeInt(tx.getUpdatedRecords().size());
          for (Entry<ORecordId, ORecord<?>> entry : tx.getUpdatedRecords().entrySet()) {
            channel.writeRID(entry.getKey());
            channel.writeInt(entry.getValue().getVersion());
          }
        } finally {
          channel.releaseExclusiveLock();
View Full Code Here

Examples of com.orientechnologies.orient.server.tx.OTransactionOptimisticProxy

    }

    case OChannelBinaryProtocol.REQUEST_TX_COMMIT: {
      data.commandInfo = "Transaction commit";

      final OTransactionOptimisticProxy tx = new OTransactionOptimisticProxy(
          (ODatabaseRecordTx) connection.database.getUnderlying(), channel);

      connection.database.begin(tx);
      try {
        connection.database.commit();
        channel.acquireExclusiveLock();
        try {
          sendOk(lastClientTxId);

          // SEND BACK ALL THE NEW VERSIONS FOR THE UPDATED RECORDS
          channel.writeInt(tx.getUpdatedRecords().size());
          for (Entry<ORecordId, ORecord<?>> entry : tx.getUpdatedRecords().entrySet()) {
            channel.writeRID(entry.getKey());
            channel.writeInt(entry.getValue().getVersion());
          }
        } finally {
          channel.releaseExclusiveLock();
View Full Code Here

Examples of com.orientechnologies.orient.server.tx.OTransactionOptimisticProxy

     setDataCommandInfo("Transaction commit");

     if (!isConnectionAlive())
       return;

     final OTransactionOptimisticProxy tx = new OTransactionOptimisticProxy((ODatabaseRecordTx) connection.database.getUnderlying(),
         channel, connection.data.protocolVersion, this);

     try {
       connection.database.begin(tx);

       try {
         connection.database.commit();
         beginResponse();
         try {
           sendOk(clientTxId);

           // SEND BACK ALL THE RECORD IDS FOR THE CREATED RECORDS
           channel.writeInt(tx.getCreatedRecords().size());
           for (Entry<ORecordId, ORecord> entry : tx.getCreatedRecords().entrySet()) {
             channel.writeRID(entry.getKey());
             channel.writeRID(entry.getValue().getIdentity());

             // IF THE NEW OBJECT HAS VERSION > 0 MEANS THAT HAS BEEN UPDATED IN THE SAME TX. THIS HAPPENS FOR GRAPHS
             if (entry.getValue().getRecordVersion().getCounter() > 0)
               tx.getUpdatedRecords().put((ORecordId) entry.getValue().getIdentity(), entry.getValue());
           }

           // SEND BACK ALL THE NEW VERSIONS FOR THE UPDATED RECORDS
           channel.writeInt(tx.getUpdatedRecords().size());
           for (Entry<ORecordId, ORecord> entry : tx.getUpdatedRecords().entrySet()) {
             channel.writeRID(entry.getKey());
             channel.writeVersion(entry.getValue().getRecordVersion());
           }

           if (connection.data.protocolVersion >= 20)
             sendCollectionChanges();
         } finally {
           endResponse();
         }
       } catch (Exception e) {
         if (connection != null && connection.database != null) {
           if (connection.database.getTransaction().isActive())
             connection.database.rollback(true);

           final OSBTreeCollectionManager collectionManager = connection.database.getSbTreeCollectionManager();
           if (collectionManager != null)
             collectionManager.clearChangedIds();
         }

         sendErrorOrDropConnection(clientTxId, e);
       }
     } catch (OTransactionAbortedException e) {
       // TX ABORTED BY THE CLIENT
     } catch (Exception e) {
       // Error during TX initialization, possibly index constraints violation.
       if (tx.isActive())
         tx.rollback(true, -1);

       sendErrorOrDropConnection(clientTxId, e);
     }
   }
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.