Package com.orientechnologies.orient.core.storage

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


  @ConsoleCommand(aliases = { "status" }, description = "Display information about the database")
  public void info() {
    if (currentDatabaseName != null) {
      out.println("Current database: " + currentDatabaseName + " (url=" + currentDatabase.getURL() + ")");

      OStorage stg = currentDatabase.getStorage();
      if (stg instanceof OStorageRemoteThread) {
        final ODocument clusterConfig = ((OStorageRemoteThread) stg).getClusterConfiguration();
        if (clusterConfig != null)
          out.println("\nCluster configuration: " + clusterConfig.toJSON("indent:2"));
        else
View Full Code Here


          parameters.put(kv[0], kv[1]);
        }
      } else
        dbName = iURL;

      OStorage storage;
      if (engine.isShared()) {
        // SEARCH IF ALREADY USED
        storage = storages.get(dbName);
        if (storage == null) {
          // NOT FOUND: CREATE IT
View Full Code Here

  }

  public String getStoragePath(final String iName) {
    final String name = iName.indexOf(':') > -1 ? iName.substring(iName.indexOf(':') + 1) : iName;

    final OStorage stg = Orient.instance().getStorage(name);
    if (stg != null)
      // ALREADY OPEN
      return stg.getURL();

    // SEARCH IN CONFIGURED PATHS
    String dbPath = configuration.getStoragePath(name);

    if (dbPath == null) {
View Full Code Here

  }

  protected ODatabaseDocumentTx getDatabaseInstance(final String iDbName, final String iStorageMode) {
    final String path;

    final OStorage stg = Orient.instance().getStorage(iDbName);
    if (stg != null)
      path = stg.getURL();
    else if (iStorageMode.equals(OEngineLocal.NAME)) {
      path = iStorageMode + ":${ORIENTDB_HOME}/databases/" + iDbName;
    } else if (iStorageMode.equals(OEngineMemory.NAME)) {
      path = iStorageMode + ":" + iDbName;
    } else
View Full Code Here

    ODatabaseDocumentTx test_db = new ODatabaseDocumentTx("plocal:" + buildDir + "/testLocalPaginatedStorageLinkBagCrashRestore");
    test_db.open("admin", "admin");

    long minTs = Long.MAX_VALUE;

    OStorage baseStorage = base_db.getStorage();

    OPhysicalPosition[] physicalPositions = baseStorage.ceilingPhysicalPositions(defaultClusterId, new OPhysicalPosition(
        OClusterPositionFactory.INSTANCE.valueOf(0)));

    int recordsRestored = 0;
    int recordsTested = 0;
    while (physicalPositions.length > 0) {
      final ORecordId rid = new ORecordId(defaultClusterId);

      for (OPhysicalPosition physicalPosition : physicalPositions) {
        rid.clusterPosition = physicalPosition.clusterPosition;

        ODatabaseRecordThreadLocal.INSTANCE.set(base_db);
        ODocument baseDocument = base_db.load(rid);
        baseDocument.setLazyLoad(false);

        ODatabaseRecordThreadLocal.INSTANCE.set(test_db);
        ODocument testDocument = test_db.load(rid);
        testDocument.setLazyLoad(false);

        if (testDocument == null) {
          ODatabaseRecordThreadLocal.INSTANCE.set(base_db);
          if (((Long) baseDocument.field("ts")) < minTs)
            minTs = baseDocument.field("ts");
        } else {
          long baseTs;
          long testTs;

          ODatabaseRecordThreadLocal.INSTANCE.set(base_db);
          baseTs = baseDocument.field("ts");

          ODatabaseRecordThreadLocal.INSTANCE.set(test_db);
          testTs = testDocument.field("ts");

          boolean equals = baseTs == testTs;

          if (equals) {
            Set<ORID> baseRids = new HashSet<ORID>();
            ODatabaseRecordThreadLocal.INSTANCE.set(base_db);
            ORidBag baseRidBag = baseDocument.field("ridBag");

            for (OIdentifiable baseIdentifiable : baseRidBag)
              baseRids.add(baseIdentifiable.getIdentity());

            Set<ORID> testRids = new HashSet<ORID>();
            ODatabaseRecordThreadLocal.INSTANCE.set(test_db);
            ORidBag testRidBag = testDocument.field("ridBag");

            for (OIdentifiable testIdentifiable : testRidBag)
              testRids.add(testIdentifiable.getIdentity());

            equals = baseRids.equals(testRids);
          }

          if (!equals)
            if (((Long) baseDocument.field("ts")) < minTs)
              minTs = baseDocument.field("ts");
            else
              recordsRestored++;
        }

        recordsTested++;

        if (recordsTested % 10000 == 0)
          System.out.println(recordsTested + " were tested, " + recordsRestored + " were restored ...");
      }

      physicalPositions = baseStorage.higherPhysicalPositions(defaultClusterId, physicalPositions[physicalPositions.length - 1]);
    }

    System.out.println(recordsRestored + " records were restored. Total records " + recordsTested
        + ". Max interval for lost records " + (lastTs - minTs));
View Full Code Here

  private void compareDocuments(long lastTs) {
    long minTs = Long.MAX_VALUE;
    int clusterId = baseDocumentTx.getClusterIdByName("TestClass");

    OStorage baseStorage = baseDocumentTx.getStorage();

    OPhysicalPosition[] physicalPositions = baseStorage.ceilingPhysicalPositions(clusterId, new OPhysicalPosition(
        OClusterPositionFactory.INSTANCE.valueOf(0)));

    int recordsRestored = 0;
    int recordsTested = 0;
    while (physicalPositions.length > 0) {
      final ORecordId rid = new ORecordId(clusterId);

      for (OPhysicalPosition physicalPosition : physicalPositions) {
        rid.clusterPosition = physicalPosition.clusterPosition;

        ODatabaseRecordThreadLocal.INSTANCE.set(baseDocumentTx);
        ODocument baseDocument = baseDocumentTx.load(rid);

        ODatabaseRecordThreadLocal.INSTANCE.set(testDocumentTx);
        List<ODocument> testDocuments = testDocumentTx.query(new OSQLSynchQuery<ODocument>("select from TestClass where id  = "
            + baseDocument.field("id")));
        if (testDocuments.size() == 0) {
          if (((Long) baseDocument.field("timestamp")) < minTs)
            minTs = baseDocument.field("timestamp");
        } else {
          ODocument testDocument = testDocuments.get(0);
          Assert.assertEquals(testDocument.field("id"), baseDocument.field("id"));
          Assert.assertEquals(testDocument.field("timestamp"), baseDocument.field("timestamp"));
          Assert.assertEquals(testDocument.field("stringValue"), baseDocument.field("stringValue"));
          recordsRestored++;
        }

        recordsTested++;

        if (recordsTested % 10000 == 0)
          System.out.println(recordsTested + " were tested, " + recordsRestored + " were restored ...");
      }

      physicalPositions = baseStorage.higherPhysicalPositions(clusterId, physicalPositions[physicalPositions.length - 1]);
    }

    System.out.println(recordsRestored + " records were restored. Total records " + recordsTested
        + ". Max interval for lost records " + (lastTs - minTs));
  }
View Full Code Here

      } else
        dbPath = iURL;

      final String dbName = registerDatabaseByPath ? dbPath : OIOUtils.getRelativePathIfAny(dbPath, null);

      OStorage storage;
      if (engine.isShared()) {
        // SEARCH IF ALREADY USED
        storage = storages.get(dbName);
        if (storage == null) {
          // NOT FOUND: CREATE IT
          storage = engine.createStorage(dbPath, parameters);

          final OStorage oldStorage = storages.putIfAbsent(dbName, storage);
          if (oldStorage != null)
            storage = oldStorage;
        }
      } else {
        // REGISTER IT WITH A SERIAL NAME TO AVOID BEING REUSED
View Full Code Here

    engineLock.readLock().lock();
    try {
      for (OOrientListener l : browseListeners())
        l.onStorageRegistered(storage);

      OStorage oldStorage = storages.putIfAbsent(storage.getName(), storage);
      if (oldStorage != null)
        storage = oldStorage;

      return storage;
    } finally {
View Full Code Here

    }
  }

  public void unregisterStorageByName(final String name) {
    final String dbName = registerDatabaseByPath ? name : OIOUtils.getRelativePathIfAny(name, null);
    final OStorage stg = storages.get(dbName);
    unregisterStorage(stg);
  }
View Full Code Here

  private void compareDocuments(long lastTs) {
    long minTs = Long.MAX_VALUE;
    int clusterId = baseDocumentTx.getClusterIdByName("TestClass");

    OStorage baseStorage = baseDocumentTx.getStorage();

    OPhysicalPosition[] physicalPositions = baseStorage.ceilingPhysicalPositions(clusterId, new OPhysicalPosition(
        OClusterPositionFactory.INSTANCE.valueOf(0)));

    int recordsRestored = 0;
    int recordsTested = 0;
    while (physicalPositions.length > 0) {
      final ORecordId rid = new ORecordId(clusterId);

      for (OPhysicalPosition physicalPosition : physicalPositions) {
        rid.clusterPosition = physicalPosition.clusterPosition;

        ODatabaseRecordThreadLocal.INSTANCE.set(baseDocumentTx);
        ODocument baseDocument = baseDocumentTx.load(rid);

        ODatabaseRecordThreadLocal.INSTANCE.set(testDocumentTx);
        List<ODocument> testDocuments = testDocumentTx.query(new OSQLSynchQuery<ODocument>("select from TestClass where id  = "
            + baseDocument.field("id")));
        if (testDocuments.size() == 0) {
          if (((Long) baseDocument.field("timestamp")) < minTs)
            minTs = baseDocument.field("timestamp");
        } else {
          ODocument testDocument = testDocuments.get(0);
          Assert.assertEquals(testDocument.field("id"), baseDocument.field("id"));
          Assert.assertEquals(testDocument.field("timestamp"), baseDocument.field("timestamp"));
          Assert.assertEquals(testDocument.field("stringValue"), baseDocument.field("stringValue"));
          Assert.assertEquals(testDocument.field("binaryValue"), baseDocument.field("binaryValue"));
          recordsRestored++;
        }

        recordsTested++;

        if (recordsTested % 10000 == 0)
          System.out.println(recordsTested + " were tested, " + recordsRestored + " were restored ...");
      }

      physicalPositions = baseStorage.higherPhysicalPositions(clusterId, physicalPositions[physicalPositions.length - 1]);
    }

    System.out.println(recordsRestored + " records were restored. Total records " + recordsTested
        + ". Max interval for lost records " + (lastTs - minTs));
  }
View Full Code Here

TOP

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

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.