Package com.orientechnologies.orient.core.storage

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


   * @return The id (physical position into the array) of the new cluster just created. First is 0.
   * @throws IOException
   * @throws IOException
   */
  private int createClusterFromConfig(final OStorageClusterConfiguration iConfig) throws IOException {
    OCluster cluster = clusterMap.get(iConfig.getName());

    if (cluster != null) {
      if (cluster instanceof OClusterLocal)
        // ALREADY CONFIGURED, JUST OVERWRITE CONFIG
        ((OClusterLocal) cluster).config = (OStorageSegmentConfiguration) iConfig;
View Full Code Here


        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

      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

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

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

      return tot;

    } finally {
View Full Code Here

    // SEARCH IT BETWEEN PHYSICAL CLUSTERS
    lock.acquireSharedLock();
    try {

      final OCluster segment = clusterMap.get(iClusterName.toLowerCase());
      if (segment != null)
        return segment.getId();

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

    // SEARCH IT BETWEEN PHYSICAL CLUSTERS
    lock.acquireSharedLock();
    try {

      final OCluster segment = clusterMap.get(iClusterName.toLowerCase());
      if (segment != null)
        return segment.getType();

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

  @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

   * @return The id (physical position into the array) of the new cluster just created. First is 0.
   * @throws IOException
   * @throws IOException
   */
  private int createClusterFromConfig(final OStorageClusterConfiguration iConfig) throws IOException {
    OCluster cluster = clusterMap.get(iConfig.getName());

    if (cluster != null) {
      if (cluster instanceof OClusterLocal)
        // ALREADY CONFIGURED, JUST OVERWRITE CONFIG
        ((OClusterLocal) cluster).config = (OStorageSegmentConfiguration) iConfig;
View Full Code Here

  }

  private void recoverTransactionEntry(byte status, byte operation, 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>. 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

    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

TOP

Related Classes of com.orientechnologies.orient.core.storage.OCluster

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.