Search in sources :

Example 11 with OStorage

use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.

the class LocalPaginatedStorageRestoreFromWAL method testSimpleRestore.

public void testSimpleRestore() throws Exception {
    List<Future<Void>> futures = new ArrayList<Future<Void>>();
    baseDocumentTx.declareIntent(new OIntentMassiveInsert());
    for (int i = 0; i < 8; i++) futures.add(executorService.submit(new DataPropagationTask()));
    for (Future<Void> future : futures) future.get();
    Thread.sleep(1500);
    copyDataFromTestWithoutClose();
    OStorage baseStorage = baseDocumentTx.getStorage();
    baseDocumentTx.close();
    baseStorage.close();
    testDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDir.getAbsolutePath() + "/testLocalPaginatedStorageRestoreFromWAL");
    testDocumentTx.open("admin", "admin");
    testDocumentTx.close();
    ODatabaseCompare databaseCompare = new ODatabaseCompare(testDocumentTx.getURL(), baseDocumentTx.getURL(), "admin", "admin", new OCommandOutputListener() {

        @Override
        public void onMessage(String text) {
            System.out.println(text);
        }
    });
    databaseCompare.setCompareIndexMetadata(true);
    Assert.assertTrue(databaseCompare.compare());
}
Also used : ODatabaseCompare(com.orientechnologies.orient.core.db.tool.ODatabaseCompare) ArrayList(java.util.ArrayList) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OIntentMassiveInsert(com.orientechnologies.orient.core.intent.OIntentMassiveInsert) Future(java.util.concurrent.Future) OCommandOutputListener(com.orientechnologies.orient.core.command.OCommandOutputListener)

Example 12 with OStorage

use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.

the class OStorageLocalTest method withLegacyPath.

public void withLegacyPath() {
    String dbPath = getDatabasePath();
    System.out.println("Using db = plocal:" + dbPath);
    File dbDir = new File(dbPath);
    System.out.println("Clean db directory for test...");
    delTree(dbDir);
    ODatabaseDocumentTx db = new ODatabaseDocumentTx("plocal:" + dbPath);
    db.create();
    OStorage storage = db.getStorage();
    db.close();
    storage.close(true, false);
    System.out.println("Reopen it...");
    // Something was added to dbPath so the legacy situation was simulated
    dbPath += "/foo";
    db = new ODatabaseDocumentTx("plocal:" + dbPath).open("admin", "admin");
    db.drop();
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OStorage(com.orientechnologies.orient.core.storage.OStorage) File(java.io.File)

Example 13 with OStorage

use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.

the class OStorageLocalTest method withNormalPath.

public void withNormalPath() {
    String dbPath = getDatabasePath();
    System.out.println("Using db = plocal:" + dbPath);
    File dbDir = new File(dbPath);
    System.out.println("Clean db directory for test...");
    delTree(dbDir);
    ODatabaseDocumentTx db = new ODatabaseDocumentTx("plocal:" + dbPath);
    db.create();
    OStorage storage = db.getStorage();
    db.close();
    storage.close(true, false);
    System.out.println("Reopen it...");
    db = new ODatabaseDocumentTx("plocal:" + dbPath).open("admin", "admin");
    db.drop();
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OStorage(com.orientechnologies.orient.core.storage.OStorage) File(java.io.File)

Example 14 with OStorage

use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.

the class ClusterDebugInfoTest method testOnePageRecordDebugInfo.

@Test
public void testOnePageRecordDebugInfo() throws IOException {
    ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:ClusterDebugInfoTest");
    db.create();
    try {
        OStorage storage = db.getStorage();
        int defaultId = storage.getDefaultClusterId();
        OPaginatedCluster cluster = (OPaginatedCluster) storage.getClusterById(defaultId);
        int size = OGlobalConfiguration.DISK_CACHE_PAGE_SIZE.getValueAsInteger();
        int half = size / 2;
        byte[] content = new byte[half * 1024];
        OStorageOperationResult<OPhysicalPosition> result = storage.createRecord(new ORecordId(defaultId), content, 0, (byte) 'b', OPERATION_MODE.SYNCHRONOUS.ordinal(), null);
        OPaginatedClusterDebug debug = cluster.readDebug(result.getResult().clusterPosition);
        Assert.assertEquals(debug.clusterPosition, result.getResult().clusterPosition);
        Assert.assertNotEquals(debug.contentSize, 0);
        Assert.assertFalse(debug.empty);
        Assert.assertEquals(debug.pages.size(), 1);
        Assert.assertNotEquals(debug.pages.get(0).pageIndex, -1);
        Assert.assertNotEquals(debug.pages.get(0).inPagePosition, -1);
        Assert.assertNotEquals(debug.pages.get(0).inPageSize, -1);
        Assert.assertNotNull(debug.pages.get(0).content);
    } finally {
        db.drop();
    }
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OStorage(com.orientechnologies.orient.core.storage.OStorage) ORecordId(com.orientechnologies.orient.core.id.ORecordId) OPhysicalPosition(com.orientechnologies.orient.core.storage.OPhysicalPosition) Test(org.testng.annotations.Test)

Example 15 with OStorage

use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.

the class ClusterDebugInfoTest method testTwoPagesRecordDebugInfo.

@Test
public void testTwoPagesRecordDebugInfo() throws IOException {
    ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:ClusterDebugInfoTest");
    db.create();
    try {
        OStorage storage = db.getStorage();
        int defaultId = storage.getDefaultClusterId();
        OPaginatedCluster cluster = (OPaginatedCluster) storage.getClusterById(defaultId);
        int size = OGlobalConfiguration.DISK_CACHE_PAGE_SIZE.getValueAsInteger();
        int half = size / 2;
        byte[] content = new byte[(size + half) * 1024];
        OStorageOperationResult<OPhysicalPosition> result = storage.createRecord(new ORecordId(defaultId), content, 0, (byte) 'b', OPERATION_MODE.SYNCHRONOUS.ordinal(), null);
        OPaginatedClusterDebug debug = cluster.readDebug(result.getResult().clusterPosition);
        Assert.assertEquals(debug.pages.size(), 2);
        Assert.assertEquals(debug.clusterPosition, result.getResult().clusterPosition);
        Assert.assertNotEquals(debug.contentSize, 0);
        Assert.assertFalse(debug.empty);
        Assert.assertNotEquals(debug.pages.get(0).pageIndex, -1);
        Assert.assertNotEquals(debug.pages.get(0).inPagePosition, -1);
        Assert.assertNotEquals(debug.pages.get(0).inPageSize, -1);
        Assert.assertNotNull(debug.pages.get(0).content);
        Assert.assertNotEquals(debug.pages.get(1).pageIndex, -1);
        Assert.assertNotEquals(debug.pages.get(1).inPagePosition, -1);
        Assert.assertNotEquals(debug.pages.get(1).inPageSize, -1);
        Assert.assertNotNull(debug.pages.get(1).content);
    } finally {
        db.drop();
    }
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OStorage(com.orientechnologies.orient.core.storage.OStorage) ORecordId(com.orientechnologies.orient.core.id.ORecordId) OPhysicalPosition(com.orientechnologies.orient.core.storage.OPhysicalPosition) Test(org.testng.annotations.Test)

Aggregations

OStorage (com.orientechnologies.orient.core.storage.OStorage)90 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)31 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)23 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)22 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)21 ORecordId (com.orientechnologies.orient.core.id.ORecordId)20 OAutoshardedStorage (com.orientechnologies.orient.core.storage.OAutoshardedStorage)18 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)18 OPhysicalPosition (com.orientechnologies.orient.core.storage.OPhysicalPosition)12 OAbstractPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage)11 File (java.io.File)11 ORID (com.orientechnologies.orient.core.id.ORID)10 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)7 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)7 Test (org.testng.annotations.Test)7 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)6 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)6 OCommandOutputListener (com.orientechnologies.orient.core.command.OCommandOutputListener)5 OSchemaException (com.orientechnologies.orient.core.exception.OSchemaException)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)5