Package com.orientechnologies.orient.core.version

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


    final OPhysicalPosition physicalPosition = new OPhysicalPosition();
    int position = startPosition;
    physicalPosition.clusterPosition = OClusterPositionSerializer.INSTANCE.deserializeNativeObject(stream, position);
    position += OClusterPositionSerializer.INSTANCE.getFixedLength();

    final ORecordVersion version = OVersionFactory.instance().createVersion();
    version.getSerializer().fastReadFrom(stream, position, version);
    position += OVersionFactory.instance().getVersionSize();

    physicalPosition.recordSize = OIntegerSerializer.INSTANCE.deserializeNative(stream, position);
    position += OIntegerSerializer.INT_SIZE;
View Full Code Here


    long currentPointer = offset;
    physicalPosition.clusterPosition = OClusterPositionSerializer.INSTANCE.deserializeFromDirectMemoryObject(pointer,
        currentPointer);
    currentPointer += OClusterPositionSerializer.INSTANCE.getFixedLength();

    final ORecordVersion version = OVersionFactory.instance().createVersion();
    byte[] serializedVersion = pointer.get(currentPointer, OVersionFactory.instance().getVersionSize());
    version.getSerializer().fastReadFrom(serializedVersion, 0, version);
    physicalPosition.recordVersion = version;
    currentPointer += OVersionFactory.instance().getVersionSize();

    OIntegerSerializer.INSTANCE.deserializeFromDirectMemory(pointer, currentPointer);
    currentPointer += OIntegerSerializer.INT_SIZE;
View Full Code Here

    deleteAllRidBags(document);
    return RESULT.RECORD_CHANGED;
  }

  private void deleteAllRidBags(ODocument document) {
    final ORecordVersion version = document.getRecordVersion();
    if (document.fields() == 0) {
      // FORCE LOADING OF CLASS+FIELDS TO USE IT AFTER ON onRecordAfterDelete METHOD
      document.reload();
      if (version.getCounter() > -1 && document.getRecordVersion().compareTo(version) != 0) // check for record version errors
        if (OFastConcurrentModificationException.enabled())
          throw OFastConcurrentModificationException.instance();
        else
          throw new OConcurrentModificationException(document.getIdentity(), document.getRecordVersion(), version,
              ORecordOperation.DELETED);
View Full Code Here

    if (vField != null) {
      versionConfigured = true;
      Object ver = getFieldValue(vField, iPojo);
      if (ver != null) {
        // FOUND
        final ORecordVersion version = iRecord.getRecordVersion();
        if (ver instanceof ORecordVersion) {
          version.copyFrom((ORecordVersion) ver);
        } else if (ver instanceof Number) {
          if (version instanceof OSimpleVersion)
            // TREATS AS CLUSTER POSITION
            version.setCounter(((Number) ver).intValue());
          else
            OLogManager
                .instance()
                .warn(OObjectEntitySerializer.class,
                    "@Version field can't be declared as Number in distributed mode. Should be one of following: String, Object, ORecordVersion");
        } else if (ver instanceof String) {
          version.getSerializer().fromString((String) ver, version);
        } else if (ver.getClass().equals(Object.class))
          version.copyFrom((ORecordVersion) ver);
        else
          OLogManager.instance().warn(OObjectSerializerHelper.class,
              "@Version field has been declared as %s while the supported are: Number, String, Object", ver.getClass());
      }
    }
View Full Code Here

    List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>("select from Account"));
    ODocument doc = result.get(0);
    doc.field("name", "modified");
    int oldVersion = doc.getVersion();

    ORecordVersion recordVersion = OVersionFactory.instance().createVersion();
    recordVersion.setCounter(-2);
    doc.getRecordVersion().copyFrom(recordVersion);

    doc.save();

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

  public void onRecordUpdateReplicated(ODocument iDocument) {
  }

  @Override
  public RESULT onRecordBeforeDelete(final ODocument iDocument) {
    final ORecordVersion version = iDocument.getRecordVersion(); // Cache the transaction-provided value
    if (iDocument.fields() == 0) {
      // FORCE LOADING OF CLASS+FIELDS TO USE IT AFTER ON onRecordAfterDelete METHOD
      iDocument.reload();
      if (version.getCounter() > -1 && iDocument.getRecordVersion().compareTo(version) != 0) // check for record version errors
        if (OFastConcurrentModificationException.enabled())
          throw OFastConcurrentModificationException.instance();
        else
          throw new OConcurrentModificationException(iDocument.getIdentity(), iDocument.getRecordVersion(), version,
              ORecordOperation.DELETED);
View Full Code Here

           final Map.Entry<ORecordId, OPair<Long, ORecordVersion>> entry = it.next();

           try {
             final ORecordId rid = entry.getKey();
             final long time = entry.getValue().getKey();
             final ORecordVersion version = entry.getValue().getValue();

             if (now - time > (OGlobalConfiguration.DISTRIBUTED_ASYNCH_RESPONSES_TIMEOUT.getValueAsLong() * 2)) {
               // DELETE RECORD
               final OStorageOperationResult<Boolean> result = wrapped.deleteRecord(rid, version, 0, null);
               if (result == null || !result.getResult())
View Full Code Here

     return QUORUM_TYPE.WRITE;
   }

   @Override
   public OUpdateRecordTask getFixTask(final ODistributedRequest iRequest, final Object iBadResponse, final Object iGoodResponse) {
     final ORecordVersion versionCopy = version.copy();
     versionCopy.setRollbackMode();

     return new OUpdateRecordTask(rid, null, null, ((OUpdateRecordTask) iRequest.getTask()).content, versionCopy);
   }
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.