Examples of OCluster


Examples of com.orientechnologies.orient.core.storage.OCluster

    lock.acquireSharedLock();
    try {

      final long offset = data.createRecord(iContent);
      final OCluster cluster = getClusterById(iRid.clusterId);

      iRid.clusterPosition = cluster.addPhysicalPosition(0, offset, iRecordType);
      return iRid.clusterPosition;
    } catch (IOException e) {
      throw new OStorageException("Error on create record in cluster: " + iRid.clusterId, e);

    } finally {
View Full Code Here

Examples of com.orientechnologies.orient.core.storage.OCluster

  }

  public int updateRecord(final ORecordId iRid, final byte[] iContent, final int iVersion, final byte iRecordType) {
    final long timer = OProfiler.getInstance().startChrono();

    final OCluster cluster = getClusterById(iRid.clusterId);

    lock.acquireSharedLock();
    try {

      lockManager.acquireLock(Thread.currentThread(), iRid, LOCK.EXCLUSIVE);
      try {

        final OPhysicalPosition ppos = cluster.getPhysicalPosition(iRid.clusterPosition, new OPhysicalPosition());
        if (ppos == null)
          return -1;

        // MVCC TRANSACTION: CHECK IF VERSION IS THE SAME
        if (iVersion > -1 && ppos.version != iVersion)
View Full Code Here

Examples of com.orientechnologies.orient.core.storage.OCluster

  }

  public boolean deleteRecord(final ORecordId iRid, final int iVersion) {
    final long timer = OProfiler.getInstance().startChrono();

    final OCluster cluster = getClusterById(iRid.clusterId);

    lock.acquireSharedLock();
    try {

      lockManager.acquireLock(Thread.currentThread(), iRid, LOCK.EXCLUSIVE);
      try {

        final OPhysicalPosition ppos = cluster.getPhysicalPosition(iRid.clusterPosition, new OPhysicalPosition());

        if (ppos == null)
          return false;

        // MVCC TRANSACTION: CHECK IF VERSION IS THE SAME
        if (iVersion > -1 && ppos.version != iVersion)
          throw new OConcurrentModificationException(
              "Can't delete record "
                  + iRid
                  + " because the version is not the latest one. Probably you are deleting an old record or it has been modified by another user (db=v"
                  + ppos.version + " your=v" + iVersion + ")");

        cluster.removePhysicalPosition(iRid.clusterPosition, null);
        data.deleteRecord(ppos.dataPosition);

        return true;

      } finally {
View Full Code Here

Examples of com.orientechnologies.orient.core.storage.OCluster

      OProfiler.getInstance().stopChrono("OStorageMemory.deleteRecord", timer);
    }
  }

  public long count(final int iClusterId) {
    final OCluster cluster = getClusterById(iClusterId);

    lock.acquireSharedLock();
    try {

      return cluster.getEntries();

    } finally {
      lock.releaseSharedLock();
    }
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.storage.OCluster

      lock.releaseSharedLock();
    }
  }

  public long[] getClusterDataRange(final int iClusterId) {
    final OCluster cluster = getClusterById(iClusterId);
    lock.acquireSharedLock();
    try {

      return new long[] { cluster.getFirstEntryPosition(), cluster.getLastEntryPosition() };

    } catch (IOException e) {
      throw new OStorageException("Error on getting last entry position in cluster: " + iClusterId, e);
    } finally {
      lock.releaseSharedLock();
View Full Code Here

Examples of com.orientechnologies.orient.core.storage.OCluster

    lock.acquireSharedLock();
    try {

      long tot = 0;
      for (int i = 0; i < iClusterIds.length; ++i) {
        final OCluster cluster = clusters.get(iClusterIds[i]);

        if (cluster != null)
          tot += cluster.getEntries();
      }
      return tot;

    } finally {
      lock.releaseSharedLock();
View Full Code Here

Examples of com.orientechnologies.orient.core.storage.OCluster

  public OCluster getClusterByName(final String iClusterName) {
    lock.acquireSharedLock();
    try {

      for (int i = 0; i < clusters.size(); ++i) {
        final OCluster cluster = clusters.get(i);

        if (cluster != null && cluster.getName().equalsIgnoreCase(iClusterName))
          return cluster;
      }
      return null;

    } finally {
View Full Code Here

Examples of com.orientechnologies.orient.core.storage.OCluster

    lock.acquireSharedLock();
    try {

      for (int i = 0; i < clusters.size(); ++i) {
        final OCluster cluster = clusters.get(i);

        if (cluster != null && cluster.getName().equalsIgnoreCase(iClusterName))
          return cluster.getId();
      }
      return -1;

    } finally {
      lock.releaseSharedLock();
View Full Code Here

Examples of com.orientechnologies.orient.core.storage.OCluster

  public String getPhysicalClusterNameById(final int iClusterId) {
    lock.acquireSharedLock();
    try {

      for (int i = 0; i < clusters.size(); ++i) {
        final OCluster cluster = clusters.get(i);

        if (cluster != null && cluster.getId() == iClusterId)
          return cluster.getName();
      }
      return null;

    } finally {
      lock.releaseSharedLock();
View Full Code Here

Examples of com.orientechnologies.orient.core.storage.OCluster

    lock.acquireSharedLock();
    try {

      Set<String> result = new HashSet<String>();
      for (int i = 0; i < clusters.size(); ++i) {
        final OCluster cluster = clusters.get(i);

        if (cluster != null)
          result.add(cluster.getName());
      }
      return result;

    } finally {
      lock.releaseSharedLock();
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.