Examples of OCluster


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

  private void commitEntry(final int iTxId, final OTransactionEntry txEntry) throws IOException {

    final ORecordId rid = (ORecordId) txEntry.getRecord().getIdentity();

    final OCluster cluster = txEntry.clusterName != null ? getClusterByName(txEntry.clusterName) : getClusterById(rid.clusterId);
    rid.clusterId = cluster.getId();

    switch (txEntry.status) {
    case OTransactionEntry.LOADED:
      break;
View Full Code Here

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

  }

  private void recoverTransactionEntry(byte status, byte operation, int reqId, int txId, final ORecordId iRid, long oldDataOffset,
      OPhysicalPosition ppos) throws IOException {

    final OCluster cluster = storage.getClusterById(iRid.clusterId);

    if (!(cluster instanceof OClusterLocal))
      return;

    final OClusterLocal logCluster = (OClusterLocal) cluster;

    OLogManager.instance().info(this,
        "Recovering tx <%d> by req <%d>. Operation <%d> was in status <%d> on record %s in data space %d...", txId, reqId,
        operation, status, iRid, oldDataOffset);

    switch (operation) {
    case OPERATION_CREATE:
      // JUST DELETE THE RECORD
      storage.deleteRecord(iRid, -1);
      break;

    case OPERATION_UPDATE:
      // RETRIEVE THE OLD RECORD
      // final int recSize = storage.getDataSegment(ppos.dataSegment).getRecordSize(oldDataOffset);

      // RETRIEVE THE CURRENT PPOS
      cluster.getPhysicalPosition(iRid.clusterPosition, ppos);

      long newPosition = ppos.dataPosition;
      int newSize = ppos.recordSize;

      // REPLACE THE POSITION OF THE OLD RECORD
      ppos.dataPosition = oldDataOffset;

      // UPDATE THE PPOS WITH THE COORDS OF THE OLD RECORD
      storage.getClusterById(iRid.clusterId).setPhysicalPosition(iRid.clusterPosition, ppos.dataSegment, oldDataOffset, ppos.type);

      // CREATE A HOLE
      storage.getDataSegment(ppos.dataSegment).createHole(newPosition, newSize);
      break;

    case OPERATION_DELETE:
      // GET THE PPOS
      cluster.getPhysicalPosition(iRid.clusterPosition, ppos);

      // SAVE THE PPOS WITH THE VERSION TO 0 (VALID IF >-1)
      cluster.updateVersion(iRid.clusterPosition, 0);

      // REMOVE THE HOLE
      logCluster.removeHole(iRid.clusterPosition);
      break;
    }
View Full Code Here

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

    final byte[] content = new byte[recordSize];
    file.read(pos[1] + RECORD_FIX_SIZE, content, recordSize);

    if (clusterId > -1) {
      // CHANGE THE POINTMENT OF CLUSTER TO THE NEW POSITION
      final OCluster cluster = storage.getClusterById(clusterId);
      final OPhysicalPosition ppos = cluster.getPhysicalPosition(clusterPosition, new OPhysicalPosition());

      if (ppos.dataPosition != iSourcePosition)
        throw new OStorageException("Found corrupted record hole for rid " + clusterId + ":" + clusterPosition
            + ": data position is wrong: " + ppos.dataPosition + "<->" + iSourcePosition);

      cluster.setPhysicalPosition(clusterPosition, iDestinationPosition);
    }

    writeRecord(getRelativePosition(iDestinationPosition), clusterId, clusterPosition, content);

    OProfiler.getInstance().stopChrono(PROFILER_MOVE_RECORD, timer);
View Full Code Here

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

  }

  private void recoverTransactionEntry(byte status, byte operation, int reqId, int txId, final ORecordId iRid, long oldDataOffset,
      OPhysicalPosition ppos) throws IOException {

    final OCluster cluster = storage.getClusterById(iRid.clusterId);

    if (!(cluster instanceof OClusterLocal))
      return;

    final OClusterLocal logCluster = (OClusterLocal) cluster;

    OLogManager.instance().info(this,
        "Recovering tx <%d> by req <%d>. Operation <%d> was in status <%d> on record %s in data space %d...", txId, reqId,
        operation, status, iRid, oldDataOffset);

    switch (operation) {
    case OPERATION_CREATE:
      // JUST DELETE THE RECORD
      storage.deleteRecord(iRid, -1);
      break;

    case OPERATION_UPDATE:
      // RETRIEVE THE OLD RECORD
      // final int recSize = storage.getDataSegment(ppos.dataSegment).getRecordSize(oldDataOffset);

      // RETRIEVE THE CURRENT PPOS
      cluster.getPhysicalPosition(iRid.clusterPosition, ppos);

      long newPosition = ppos.dataPosition;
      int newSize = ppos.recordSize;

      // REPLACE THE POSITION OF THE OLD RECORD
      ppos.dataPosition = oldDataOffset;

      // UPDATE THE PPOS WITH THE COORDS OF THE OLD RECORD
      storage.getClusterById(iRid.clusterId).setPhysicalPosition(iRid.clusterPosition, ppos.dataSegment, oldDataOffset, ppos.type);

      // CREATE A HOLE
      storage.getDataSegment(ppos.dataSegment).handleHole(newPosition, newSize);
      break;

    case OPERATION_DELETE:
      // GET THE PPOS
      cluster.getPhysicalPosition(iRid.clusterPosition, ppos);

      // SAVE THE PPOS WITH THE VERSION TO 0 (VALID IF >-1)
      cluster.updateVersion(iRid.clusterPosition, 0);

      // REMOVE THE HOLE
      logCluster.removeHole(iRid.clusterPosition);
      break;
    }
View Full Code Here

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

    final byte[] content = new byte[recordSize];
    file.read(pos[1] + RECORD_FIX_SIZE, content, recordSize);

    if (clusterId > -1) {
      // CHANGE THE POINTMENT OF CLUSTER TO THE NEW POSITION
      final OCluster cluster = storage.getClusterById(clusterId);
      final OPhysicalPosition ppos = cluster.getPhysicalPosition(clusterPosition, new OPhysicalPosition());

      if (ppos.dataPosition != iSourcePosition)
        throw new OStorageException("Found corrupted record hole for rid " + clusterId + ":" + clusterPosition
            + ": data position is wrong: " + ppos.dataPosition + "<->" + iSourcePosition);

      cluster.setPhysicalPosition(clusterPosition, iDestinationPosition);
    }

    writeRecord(getRelativePosition(iDestinationPosition), clusterId, clusterPosition, content);

    OProfiler.getInstance().stopChrono(PROFILER_MOVE_RECORD, timer);
View Full Code Here

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

      if (iClusterId < 0 || iClusterId >= clusters.length)
        throw new IllegalArgumentException("Cluster id '" + iClusterId + "' is out of range of configured clusters (0-"
            + (clusters.length - 1) + ")");

      final OCluster cluster = clusters[iClusterId];
      if (cluster == null)
        return false;

      getLevel2Cache().freeCluster(iClusterId);

      cluster.delete();

      clusterMap.remove(cluster.getName());
      clusters[iClusterId] = null;

      // UPDATE CONFIGURATION
      configuration.clusters.set(iClusterId, null);
      configuration.update();
View Full Code Here

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

    lock.acquireSharedLock();
    try {

      long tot = 0;

      OCluster c;
      for (int i = 0; i < iClusterIds.length; ++i) {
        if (iClusterIds[i] >= clusters.length)
          throw new OConfigurationException("Cluster id " + iClusterIds[i] + "was not found");

        c = clusters[iClusterIds[i]];
        if (c != null)
          tot += c.getEntries();
      }

      return tot;

    } finally {
View Full Code Here

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

    if (Character.isDigit(iClusterName.charAt(0)))
      return Integer.parseInt(iClusterName);

    // SEARCH IT BETWEEN PHYSICAL CLUSTERS
    OCluster segment;

    lock.acquireSharedLock();
    try {

      segment = clusterMap.get(iClusterName.toLowerCase());

    } finally {
      lock.releaseSharedLock();
    }

    if (segment != null)
      return segment.getId();

    return -1;
  }
View Full Code Here

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

    if (iClusterName == null)
      throw new IllegalArgumentException("Cluster name is null");

    // SEARCH IT BETWEEN PHYSICAL CLUSTERS
    OCluster segment;

    lock.acquireSharedLock();
    try {

      segment = clusterMap.get(iClusterName.toLowerCase());

    } finally {
      lock.releaseSharedLock();
    }

    if (segment != null)
      return segment.getType();

    return null;
  }
View Full Code Here

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

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

      final OCluster cluster = clusterMap.get(iClusterName.toLowerCase());

      if (cluster == null)
        throw new IllegalArgumentException("Cluster " + iClusterName + " not exists");
      return cluster;
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.