Package com.orientechnologies.orient.core.version

Examples of com.orientechnologies.orient.core.version.ORecordVersion


        if (!record.isDirty())
          return (RET) record;

        // CHECK IF ENABLE THE MVCC OR BYPASS IT
        final ORecordVersion realVersion = !mvcc || iVersion.isUntracked() ? OVersionFactory.instance().createUntrackedVersion()
            : record.getRecordVersion();

        try {
          // SAVE IT
          operationResult = underlying.save(rid, ORecordInternal.isContentChanged(record),
              stream == null ? new byte[0] : stream, realVersion, ORecordInternal.getRecordType(record), iMode.ordinal(),
              iForceCreate, iRecordCreatedCallback, iRecordUpdatedCallback);

          final ORecordVersion version = operationResult.getResult();

          if (isNew) {
            // UPDATE INFORMATION: CLUSTER ID+POSITION
            ((ORecordId) record.getIdentity()).copyFrom(rid);
            // NOTIFY IDENTITY HAS CHANGED
View Full Code Here


        ORecord rec = record.getRecord();
        if (iCallTriggers && rec != null)
          callbackHooks(TYPE.BEFORE_DELETE, rec);

        // CHECK IF ENABLE THE MVCC OR BYPASS IT
        final ORecordVersion realVersion = mvcc ? iVersion : OVersionFactory.instance().createUntrackedVersion();

        final OStorageOperationResult<Boolean> operationResult;
        try {
          if (prohibitTombstones)
            operationResult = new OStorageOperationResult<Boolean>(underlying.cleanOutRecord(rid, realVersion, iRequired,
View Full Code Here

          Lock recordLock = lockManager.acquireExclusiveLock(rid);
          try {
            // UPDATE IT
            final OPhysicalPosition ppos = cluster.getPhysicalPosition(new OPhysicalPosition(rid.clusterPosition));
            if (!checkForRecordValidity(ppos)) {
              final ORecordVersion recordVersion = OVersionFactory.instance().createUntrackedVersion();
              if (callback != null)
                callback.call(rid, recordVersion);

              return new OStorageOperationResult<ORecordVersion>(recordVersion);
            }

            boolean contentModified = false;
            if (updateContent) {
              final byte[] newContent = checkAndIncrementVersion(cluster, rid, version, ppos.recordVersion, content, recordType);
              if (newContent != null) {
                contentModified = true;
                content = newContent;
              }
            }

            makeStorageDirty();
            atomicOperationsManager.startAtomicOperation();
            try {
              if (updateContent)
                cluster.updateRecord(rid.clusterPosition, content, ppos.recordVersion, recordType);

              final ORecordSerializationContext context = ORecordSerializationContext.getContext();
              if (context != null)
                context.executeOperations(this);
              atomicOperationsManager.endAtomicOperation(false);
            } catch (Throwable e) {
              atomicOperationsManager.endAtomicOperation(true);

              OLogManager.instance().error(this, "Error on updating record " + rid + " (cluster: " + cluster + ")", e);

              final ORecordVersion recordVersion = OVersionFactory.instance().createUntrackedVersion();
              if (callback != null)
                callback.call(rid, recordVersion);

              return new OStorageOperationResult<ORecordVersion>(recordVersion);
            }

            if (callback != null)
              callback.call(rid, ppos.recordVersion);

            if (contentModified)
              return new OStorageOperationResult<ORecordVersion>(ppos.recordVersion, content, false);
            else
              return new OStorageOperationResult<ORecordVersion>(ppos.recordVersion);

          } finally {
            lockManager.releaseLock(recordLock);
          }
        } catch (IOException e) {
          OLogManager.instance().error(this, "Error on updating record " + rid + " (cluster: " + cluster + ")", e);

          final ORecordVersion recordVersion = OVersionFactory.instance().createUntrackedVersion();
          if (callback != null)
            callback.call(rid, recordVersion);

          return new OStorageOperationResult<ORecordVersion>(recordVersion);
        } finally {
View Full Code Here

          // SAVE THE RECORD TO RETRIEVE THEM FOR THE NEW RID TO SEND BACK TO THE REQUESTER
          createdRecords.put(rid.copy(), entry.getRecord());
          break;

        case ORecordOperation.UPDATED:
          ORecordVersion version = channel.readVersion();
          byte[] bytes = channel.readBytes();
          oNetworkProtocolBinary.fillRecord(rid, bytes, version, entry.getRecord(), database);
          if (protocolVersion >= 23)
            ORecordInternal.setContentChanged(entry.getRecord(), channel.readBoolean());
          break;
View Full Code Here

    country = (Country) database.save(country);
    Assert.assertNotNull(country.getId());
    Assert.assertNotNull(country.getVersion());

    ORecordVersion initVersion = ((ORecordVersion) country.getVersion()).copy();

    database.begin();
    Country loaded = (Country) database.load((ORecordId) country.getId());
    Assert.assertEquals(loaded.getId(), country.getId());
    Assert.assertEquals(loaded.getVersion(), country.getVersion());
    Assert.assertEquals(database.getRecordByUserObject(loaded, false), database.getRecordByUserObject(country, false));
    String newName = "ShouldBeChanged";
    loaded.setName(newName);
    loaded = (Country) database.save(loaded);
    database.commit();

    loaded = (Country) database.load((ORecordId) country.getId());
    Assert.assertEquals(database.getRecordByUserObject(loaded, false), database.getRecordByUserObject(country, false));
    Assert.assertEquals(loaded.getId(), country.getId());
    Assert.assertEquals(((ORecordVersion) loaded.getVersion()).getCounter(), initVersion.getCounter() + 1);
    Assert.assertEquals(loaded.getName(), newName);
  }
View Full Code Here

    country = (Country) database.save(country);
    Assert.assertNotNull(country.getId());
    Assert.assertNotNull(country.getVersion());

    ORecordVersion initVersion = (ORecordVersion) country.getVersion();

    database.begin();
    Country loaded = (Country) database.load((ORecordId) country.getId());
    Assert.assertEquals(loaded.getId(), country.getId());
    Assert.assertEquals(loaded.getVersion(), country.getVersion());
View Full Code Here

    // Keep the IDs.
    ORID vDocA_Rid = vDocA_db1.getIdentity().copy();
    ORID vDocB_Rid = vDocB_db1.getIdentity().copy();

    ORecordVersion vDocA_version = OVersionFactory.instance().createUntrackedVersion();
    ORecordVersion vDocB_version = OVersionFactory.instance().createUntrackedVersion();

    database2.begin(TXTYPE.OPTIMISTIC);
    try {
      // Get docA and update in db2 transaction context
      ODocument vDocA_db2 = database2.load(vDocA_Rid);
View Full Code Here

    database.close();
    database.open("admin", "admin");

    ODocument loadedJack = database.load(jack.getIdentity());

    ORecordVersion jackLastVersion = loadedJack.getRecordVersion().copy();
    database.begin();
    loadedJack.field("occupation", "agent");
    loadedJack.save();
    database.commit();
    Assert.assertTrue(!jackLastVersion.equals(loadedJack.getRecordVersion()));

    loadedJack = database.load(jack.getIdentity());
    Assert.assertTrue(!jackLastVersion.equals(loadedJack.getRecordVersion()));

    database.close();

    database.open("admin", "admin");
    loadedJack = database.load(jack.getIdentity());
    Assert.assertTrue(!jackLastVersion.equals(loadedJack.getRecordVersion()));
    database.close();
  }
View Full Code Here

    OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
    try {
      OClusterPage localPage = new OClusterPage(cacheEntry, true, ODurablePage.TrackMode.FULL);
      Assert.assertEquals(localPage.getRecordsCount(), 0);

      ORecordVersion recordVersion = OVersionFactory.instance().createVersion();
      recordVersion.increment();

      int index = localPage.appendRecord(recordVersion, new byte[] { 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 }, false);
      int freeSpace = localPage.getFreeSpace();

      ORecordVersion newRecordVersion = OVersionFactory.instance().createVersion();
      newRecordVersion.copyFrom(recordVersion);
      newRecordVersion.increment();

      int written = localPage.replaceRecord(index, new byte[] { 5, 2, 3, 4, 5, 11, 5, 4, 3, 2, 1 }, newRecordVersion);
      Assert.assertEquals(localPage.getFreeSpace(), freeSpace);
      Assert.assertEquals(written, 11);
View Full Code Here

    OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
    try {
      OClusterPage localPage = new OClusterPage(cacheEntry, true, ODurablePage.TrackMode.FULL);
      Assert.assertEquals(localPage.getRecordsCount(), 0);

      ORecordVersion recordVersion = OVersionFactory.instance().createVersion();
      recordVersion.increment();

      int index = localPage.appendRecord(recordVersion, new byte[] { 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 }, false);
      int freeSpace = localPage.getFreeSpace();

      ORecordVersion newRecordVersion = OVersionFactory.instance().createVersion();
      newRecordVersion.copyFrom(recordVersion);
      newRecordVersion.increment();

      int written = localPage.replaceRecord(index, new byte[] { 5, 2, 3, 4, 5, 11, }, newRecordVersion);
      Assert.assertEquals(localPage.getFreeSpace(), freeSpace);
      Assert.assertEquals(written, 6);
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.version.ORecordVersion

Copyright © 2018 www.massapicom. 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.