Package com.orientechnologies.orient.core.storage

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


   public boolean resurrectDeletedRecord(final ORecordId rid) {
     return deletedRecords.remove(rid) != null;
   }

   public String getClusterNameByRID(final ORecordId iRid) {
     final OCluster cluster = getClusterById(iRid.clusterId);
     return cluster != null ? cluster.getName() : "*";
   }
View Full Code Here


       final ODocument clusters = new ODocument();
       databaseConfiguration.field("clusters", clusters);

       for (String clName : stg.getClusterNames()) {
         final OCluster c = stg.getClusterByName(clName);

         final ODocument cluster = new ODocument();
         clusters.field(clName, cluster);

         try {
           cluster.field("records", c.getEntries());
           cluster.field("first", c.getFirstPosition().longValue());
           cluster.field("last", c.getFirstPosition().longValue());
         } catch (IOException e) {
           OLogManager.instance().error(this, "Error on deploying cluster " + clName, e);
         }
       }
     }
View Full Code Here

      final AtomicLong lastOperationId = new AtomicLong(-1);

      FileOutputStream fileOutputStream = new FileOutputStream(f);
      try {
        final OCluster cluster = database.getStorage().getClusterByName(clusterName);

        // cluster.backup(fileOutputStream, null, null, this,
        // OGlobalConfiguration.DISTRIBUTED_DEPLOYDB_TASK_COMPRESSION.getValueAsInteger(), CHUNK_MAX_SIZE);

        final long fileSize = f.length();
View Full Code Here

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

    final OCluster cluster = getCluster();

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

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

    try {
      cluster.set(attribute, value);
      final OStorage storage = getDatabase().getStorage();
      if (storage instanceof OLocalPaginatedStorage)
        ((OLocalPaginatedStorage) storage).makeFullCheckpoint();
    } catch (IOException ioe) {
      throw new OCommandExecutionException("Error altering cluster '" + clusterName + "'", ioe);
View Full Code Here

      if (clusterId < 0 || clusterId >= clusters.size())
        throw new IllegalArgumentException("Cluster id '" + clusterId + "' is outside the of range of configured clusters (0-"
            + (clusters.size() - 1) + ") in database '" + name + "'");

      final OCluster cluster = clusters.get(clusterId);
      if (cluster == null)
        return false;

      if (iTruncate)
        cluster.truncate();
      cluster.delete();

      makeStorageDirty();
      clusterMap.remove(cluster.getName().toLowerCase());
      clusters.set(clusterId, null);

      // UPDATE CONFIGURATION
      configuration.dropCluster(clusterId);
View Full Code Here

  public ODiskCache getDiskCache() {
    return diskCache;
  }

  public void freeze(boolean throwException, int clusterId) {
    final OCluster cluster = getClusterById(clusterId);

    final String name = cluster.getName();
    if (OMetadataDefault.CLUSTER_INDEX_NAME.equals(name) || OMetadataDefault.CLUSTER_MANUAL_INDEX_NAME.equals(name)) {
      throw new IllegalArgumentException("It is impossible to freeze and release index or manual index cluster!");
    }

    cluster.getExternalModificationLock().prohibitModifications(throwException);

    try {
      cluster.synch();
      cluster.setSoftlyClosed(true);
    } catch (IOException e) {
      throw new OStorageException("Error on synch cluster '" + name + "'", e);
    }
  }
View Full Code Here

      throw new OStorageException("Error on synch cluster '" + name + "'", e);
    }
  }

  public void release(int clusterId) {
    final OCluster cluster = getClusterById(clusterId);

    final String name = cluster.getName();
    if (OMetadataDefault.CLUSTER_INDEX_NAME.equals(name) || OMetadataDefault.CLUSTER_MANUAL_INDEX_NAME.equals(name)) {
      throw new IllegalArgumentException("It is impossible to freeze and release index or manualindex cluster!");
    }

    try {
      cluster.setSoftlyClosed(false);
    } catch (IOException e) {
      throw new OStorageException("Error on unfreeze storage '" + name + "'", e);
    }

    cluster.getExternalModificationLock().allowModifications();
  }
View Full Code Here

      throw new OStorageException("Cluster Id " + clusterId + " is invalid in database '" + name + "'");

    // COUNT PHYSICAL CLUSTER IF ANY
    checkOpeness();

    final OCluster cluster = clusters.get(clusterId);
    if (cluster == null)
      return 0;

    if (countTombstones)
      return cluster.getEntries();

    return cluster.getEntries() - cluster.getTombstonesCount();
  }
View Full Code Here

    for (int iClusterId : iClusterIds) {
      if (iClusterId >= clusters.size())
        throw new OConfigurationException("Cluster id " + iClusterId + " was not found in database '" + name + "'");

      if (iClusterId > -1) {
        final OCluster c = clusters.get(iClusterId);
        if (c != null)
          tot += c.getEntries() - (countTombstones ? 0L : c.getTombstonesCount());
      }
    }

    return tot;
  }
View Full Code Here

      ORecordVersion recordVersion, final byte recordType, final int mode, final ORecordCallback<OClusterPosition> callback) {
    checkOpeness();

    final long timer = Orient.instance().getProfiler().startChrono();

    final OCluster cluster = getClusterById(rid.clusterId);
    cluster.getExternalModificationLock().requestModificationLock();
    try {
      modificationLock.requestModificationLock();
      try {
        checkOpeness();

        if (content == null)
          throw new IllegalArgumentException("Record is null");

        OPhysicalPosition ppos = new OPhysicalPosition(recordType);
        try {
          lock.acquireSharedLock();
          try {
            if (recordVersion.getCounter() > -1)
              recordVersion.increment();
            else
              recordVersion = OVersionFactory.instance().createVersion();

            makeStorageDirty();
            atomicOperationsManager.startAtomicOperation();
            try {
              ppos = cluster.createRecord(content, recordVersion, recordType);
              rid.clusterPosition = ppos.clusterPosition;

              final ORecordSerializationContext context = ORecordSerializationContext.getContext();
              if (context != null)
                context.executeOperations(this);
              atomicOperationsManager.endAtomicOperation(false);
            } catch (Throwable throwable) {
              atomicOperationsManager.endAtomicOperation(true);

              OLogManager.instance().error(this, "Error on creating record in cluster: " + cluster, throwable);

              try {
                if (ppos.clusterPosition != null && ppos.clusterPosition.compareTo(OClusterPosition.INVALID_POSITION) != 0)
                  cluster.deleteRecord(ppos.clusterPosition);
              } catch (IOException e) {
                OLogManager.instance().error(this, "Error on removing record in cluster: " + cluster, e);
              }

              return null;
            }

            if (callback != null)
              callback.call(rid, ppos.clusterPosition);

            return new OStorageOperationResult<OPhysicalPosition>(ppos);
          } finally {
            lock.releaseSharedLock();
          }
        } catch (IOException ioe) {
          try {
            if (ppos.clusterPosition != null && ppos.clusterPosition.compareTo(OClusterPosition.INVALID_POSITION) != 0)
              cluster.deleteRecord(ppos.clusterPosition);
          } catch (IOException e) {
            OLogManager.instance().error(this, "Error on removing record in cluster: " + cluster, e);
          }

          OLogManager.instance().error(this, "Error on creating record in cluster: " + cluster, ioe);
          return null;
        }
      } finally {
        modificationLock.releaseModificationLock();
      }
    } finally {
      cluster.getExternalModificationLock().releaseModificationLock();
      Orient.instance().getProfiler().stopChrono(PROFILER_CREATE_RECORD, "Create a record in database", timer, "db.*.createRecord");
    }
  }
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.