Examples of OCluster


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

  }

  private void recoverTransactionEntry(final byte status, final byte operation, final int txId, final ORecordId iRid,
      final long oldDataOffset, final int recordVersion, final 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>. Operation <%d> was in status <%d> on record %s in data space %d...",
        txId, 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

   */
  public Object execute(final Map<Object, Object> iArgs) {
    if (clusterName == null)
      throw new OCommandExecutionException("Can't execute the command because it hasn't been parsed yet");

    OCluster cluster = ((OStorageEmbedded) database.getStorage()).getClusterByName(clusterName);

    final long recs = cluster.getEntries();

    try {
      cluster.truncate();
    } catch (IOException e) {
      throw new OCommandExecutionException("Error on executing command", e);
    }

    return recs;
View Full Code Here

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

   */
  public Object execute(final Map<Object, Object> iArgs) {
    if (attribute == null)
      throw new OCommandExecutionException("Can't execute the command because it hasn't been parsed yet");

    final OCluster cls = getCluster();

    if (cls == null)
      throw new OCommandExecutionException("Cluster '" + clusterName + "' not found");

    if (clusterId > -1 && clusterName.equals(String.valueOf(clusterId))) {
      clusterName = cls.getName();
    } else {
      clusterId = cls.getId();
    }

    try {
      cls.set(attribute, value);
    } catch (IOException ioe) {
      throw new OCommandExecutionException("Error altering cluster '" + clusterName + "'", ioe);
    }

    return null;
View Full Code Here

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

    return null;
  }

  protected void deleteDefaultCluster(int clusterId) {
    OCluster cluster = database.getStorage().getClusterById(clusterId);
    if (cluster.getName().equalsIgnoreCase(className)) {
      if (isClusterDeletable(clusterId)) {
        database.getStorage().dropCluster(clusterId);
      }
    }
  }
View Full Code Here

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

        json.endCollection(1, true);
      }

      if (db.getClusterNames() != null) {
        json.beginCollection(1, false, "clusters");
        OCluster cluster;
        for (String clusterName : db.getClusterNames()) {
          cluster = ((OStorageEmbedded) db.getStorage()).getClusterById(db.getClusterIdByName(clusterName));

          try {
            json.beginObject(2, true, null);
            json.writeAttribute(3, false, "id", cluster.getId());
            json.writeAttribute(3, false, "name", clusterName);
            json.writeAttribute(3, false, "type", cluster.getType());
            json.writeAttribute(3, false, "records", cluster.getEntries());
            if (cluster instanceof OClusterLocal) {
              json.writeAttribute(3, false, "size", ((OClusterLocal) cluster).getSize());
              json.writeAttribute(3, false, "filled", ((OClusterLocal) cluster).getFilledUpTo());
              json.writeAttribute(3, false, "maxSize", ((OClusterLocal) cluster).getConfig().maxSize);
              json.writeAttribute(3, false, "files", Arrays.toString(((OClusterLocal) cluster).getConfig().infoFiles));
View Full Code Here

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

        json.endCollection(1, true);
      }

      if (db.getClusterNames() != null) {
        json.beginCollection(1, false, "clusters");
        OCluster cluster;
        for (String clusterName : db.getClusterNames()) {
          cluster = ((OStorageEmbedded) db.getStorage()).getClusterById(db.getClusterIdByName(clusterName));

          try {
            json.beginObject(2, true, null);
            json.writeAttribute(3, false, "id", cluster.getId());
            json.writeAttribute(3, false, "name", clusterName);
            json.writeAttribute(3, false, "type", cluster.getType());
            json.writeAttribute(3, false, "records", cluster.getEntries());
            if (cluster instanceof OClusterLocal) {
              json.writeAttribute(3, false, "size", ((OClusterLocal) cluster).getSize());
              json.writeAttribute(3, false, "filled", ((OClusterLocal) cluster).getFilledUpTo());
              json.writeAttribute(3, false, "maxSize", ((OClusterLocal) cluster).getConfig().maxSize);
              json.writeAttribute(3, false, "files", Arrays.toString(((OClusterLocal) cluster).getConfig().infoFiles));
View Full Code Here

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

    try {
      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;

      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

    final boolean locked = 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;

    final boolean locked = lock.acquireSharedLock();

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

    } finally {
      lock.releaseSharedLock(locked);
    }

    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;

    final boolean locked = lock.acquireSharedLock();

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

    } finally {
      lock.releaseSharedLock(locked);
    }

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

    return null;
  }
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.