Package com.orientechnologies.orient.core.exception

Examples of com.orientechnologies.orient.core.exception.OStorageException


  /**
   * Check if the storage is open. If it's closed an exception is raised.
   */
  protected void checkOpeness() {
    if (!open)
      throw new OStorageException("Storage " + name + " is not opened.");
  }
View Full Code Here


      // 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);
    }
View Full Code Here

    }

    // TRY TO CREATE A NEW FILE
    if (maxSize > 0 && getSize() >= maxSize)
      // OUT OF MAX SIZE
      throw new OStorageException("Unable to allocate the requested space of " + iRecordSize
          + " bytes because the segment is full: max-Size=" + maxSize + ", currentSize=" + getFilledUpTo());

    // COPY THE OLD ARRAY TO THE NEW ONE
    OFile[] newFiles = new OFile[files.length + 1];
    for (int i = 0; i < files.length; ++i)
View Full Code Here

   */
  public OStorageConfiguration load() throws OSerializationException {
    final byte[] record = storage.readRecord(null, CONFIG_RID, null).buffer;

    if (record == null)
      throw new OStorageException("Can't load database's configuration. The database seems to be corrupted.");

    fromStream(record);
    return this;
  }
View Full Code Here

    cursor.dataOffset = iHolePosition + iHoleSize;
    ODataHoleInfo higherHole = availableHolesByPosition.higherKey(cursor);

    if (lowerHole != null && higherHole != null && lowerHole.dataOffset >= higherHole.dataOffset)
      // CHECK ERROR
      throw new OStorageException("Found bad order in hole list: " + lowerHole + " is higher than " + higherHole);

    final ODataHoleInfo closestHole;
    if (lowerHole != null && (lowerHole.dataOffset + lowerHole.size < iLowerRange))
      // OUT OF RANGE: INVALID IT
      lowerHole = null;
View Full Code Here

        return;

      addUser();

      if (!exists())
        throw new OStorageException("Can't open the storage '" + name + "' because it not exists in path: " + url);

      open = true;

      // OPEN BASIC SEGMENTS
      int pos;
      pos = registerDataSegment(new OStorageDataConfiguration(configuration, OStorage.DATA_DEFAULT_NAME));
      dataSegments[pos].open();

      pos = createClusterFromConfig(new OStoragePhysicalClusterConfiguration(configuration, OStorage.CLUSTER_INTERNAL_NAME,
          clusters.length));
      clusters[pos].open();

      configuration.load();

      pos = createClusterFromConfig(new OStoragePhysicalClusterConfiguration(configuration, OStorage.CLUSTER_INDEX_NAME,
          clusters.length));
      clusters[pos].open();

      defaultClusterId = createClusterFromConfig(new OStoragePhysicalClusterConfiguration(configuration,
          OStorage.CLUSTER_DEFAULT_NAME, clusters.length));
      clusters[defaultClusterId].open();

      // REGISTER DATA SEGMENT
      OStorageDataConfiguration dataConfig;
      for (int i = 0; i < configuration.dataSegments.size(); ++i) {
        dataConfig = configuration.dataSegments.get(i);

        pos = registerDataSegment(dataConfig);
        if (pos == -1) {
          // CLOSE AND REOPEN TO BE SURE ALL THE FILE SEGMENTS ARE
          // OPENED
          dataSegments[i].close();
          dataSegments[i] = new ODataLocal(this, dataConfig, pos);
          dataSegments[i].open();
        } else
          dataSegments[pos].open();
      }

      // REGISTER CLUSTER
      OStorageClusterConfiguration clusterConfig;
      for (int i = 0; i < configuration.clusters.size(); ++i) {
        clusterConfig = configuration.clusters.get(i);

        if (clusterConfig != null) {
          pos = createClusterFromConfig(clusterConfig);

          if (pos == -1) {
            // CLOSE AND REOPEN TO BE SURE ALL THE FILE SEGMENTS ARE
            // OPENED
            clusters[i].close();
            clusters[i] = new OClusterLocal(this, (OStoragePhysicalClusterConfiguration) clusterConfig);
            clusterMap.put(clusters[i].getName(), clusters[i]);
            clusters[i].open();
          } else {
            if (clusterConfig.getName().equals(OStorage.CLUSTER_DEFAULT_NAME))
              defaultClusterId = pos;

            clusters[pos].open();
          }
        } else {
          clusters = Arrays.copyOf(clusters, clusters.length + 1);
          clusters[i] = null;
        }
      }

      loadVersion();

      txManager.open();

    } catch (Exception e) {
      open = false;
      dataSegments = new ODataLocal[0];
      clusters = new OCluster[0];
      clusterMap.clear();
      throw new OStorageException("Can't open local storage: " + url + ", with mode=" + mode, e);
    } finally {
      lock.releaseExclusiveLock();

      OProfiler.getInstance().stopChrono("storage." + name + ".open", timer);
    }
View Full Code Here

    lock.acquireExclusiveLock();
    try {

      if (open)
        throw new OStorageException("Can't create new storage " + name + " because it isn't closed");

      addUser();

      final File storageFolder = new File(storagePath);
      if (!storageFolder.exists())
        storageFolder.mkdir();

      if (exists())
        throw new OStorageException("Can't create new storage " + name + " because it already exists");

      open = true;

      addDataSegment(OStorage.DATA_DEFAULT_NAME);

      // ADD THE METADATA CLUSTER TO STORE INTERNAL STUFF
      addCluster(OStorage.CLUSTER_INTERNAL_NAME, OStorage.CLUSTER_TYPE.PHYSICAL);

      // ADD THE INDEX CLUSTER TO STORE, BY DEFAULT, ALL THE RECORDS OF
      // INDEXING
      addCluster(OStorage.CLUSTER_INDEX_NAME, OStorage.CLUSTER_TYPE.PHYSICAL);

      // ADD THE DEFAULT CLUSTER
      defaultClusterId = addCluster(OStorage.CLUSTER_DEFAULT_NAME, OStorage.CLUSTER_TYPE.PHYSICAL);

      configuration.create();

      txManager.create();
    } catch (OStorageException e) {
      close();
      throw e;
    } catch (IOException e) {
      close();
      throw new OStorageException("Error on creation of storage: " + name, e);

    } finally {
      lock.releaseExclusiveLock();

      OProfiler.getInstance().stopChrono("storage." + name + ".create", timer);
View Full Code Here

          Thread.sleep(DELETE_WAIT_TIME);
        } catch (InterruptedException e) {
        }
      }

      throw new OStorageException("Can't delete database '" + name + "' located in: " + dbDir + ". Database files seems locked");

    } finally {
      lock.releaseExclusiveLock();

      OProfiler.getInstance().stopChrono("storage." + name + ".delete", timer);
View Full Code Here

    }
  }

  public long[] getClusterDataRange(final int iClusterId) {
    if (iClusterId == -1)
      throw new OStorageException("Cluster Id is invalid: " + iClusterId);

    checkOpeness();

    lock.acquireSharedLock();
    try {
View Full Code Here

    }
  }

  public long count(final int iClusterId) {
    if (iClusterId == -1)
      throw new OStorageException("Cluster Id is invalid: " + iClusterId);

    // COUNT PHYSICAL CLUSTER IF ANY
    checkOpeness();

    lock.acquireSharedLock();
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.exception.OStorageException

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.