Search in sources :

Example 56 with OStorage

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

the class ServerRun method deleteStorages.

public void deleteStorages() {
    for (OStorage s : Orient.instance().getStorages()) {
        if (s instanceof OLocalPaginatedStorage && new File(((OLocalPaginatedStorage) s).getStoragePath()).getAbsolutePath().startsWith(getDatabasePath(""))) {
            s.close(true, true);
            Orient.instance().unregisterStorage(s);
        }
    }
}
Also used : OLocalPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage) OStorage(com.orientechnologies.orient.core.storage.OStorage) File(java.io.File)

Example 57 with OStorage

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

the class ORidBagTest method testAddSBTreeAddInMemoryIterateAndRemove.

public void testAddSBTreeAddInMemoryIterateAndRemove() {
    List<OIdentifiable> rids = new ArrayList<OIdentifiable>();
    ORidBag bag = new ORidBag();
    bag.setAutoConvertToRecord(false);
    assertEmbedded(bag.isEmbedded());
    bag.add(new ORecordId("#77:2"));
    rids.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:2"));
    rids.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:3"));
    rids.add(new ORecordId("#77:3"));
    bag.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:7"));
    rids.add(new ORecordId("#77:7"));
    bag.add(new ORecordId("#77:8"));
    rids.add(new ORecordId("#77:8"));
    assertEmbedded(bag.isEmbedded());
    ODocument doc = new ODocument();
    doc.field("ridbag", bag);
    doc.save();
    ORID rid = doc.getIdentity();
    OStorage storage = database.getStorage();
    database.close();
    storage.close(true, false);
    database = new ODatabaseDocumentTx(database.getURL());
    database.open("admin", "admin");
    doc = database.load(rid);
    doc.setLazyLoad(false);
    bag = doc.field("ridbag");
    assertEmbedded(bag.isEmbedded());
    bag.add(new ORecordId("#77:0"));
    rids.add(new ORecordId("#77:0"));
    bag.add(new ORecordId("#77:1"));
    rids.add(new ORecordId("#77:1"));
    bag.add(new ORecordId("#77:2"));
    rids.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:3"));
    rids.add(new ORecordId("#77:3"));
    bag.add(new ORecordId("#77:3"));
    rids.add(new ORecordId("#77:3"));
    bag.add(new ORecordId("#77:5"));
    rids.add(new ORecordId("#77:5"));
    bag.add(new ORecordId("#77:6"));
    rids.add(new ORecordId("#77:6"));
    assertEmbedded(bag.isEmbedded());
    Iterator<OIdentifiable> iterator = bag.iterator();
    int r2c = 0;
    int r3c = 0;
    int r6c = 0;
    int r4c = 0;
    int r7c = 0;
    while (iterator.hasNext()) {
        OIdentifiable identifiable = iterator.next();
        if (identifiable.equals(new ORecordId("#77:2"))) {
            if (r2c < 2) {
                r2c++;
                iterator.remove();
                rids.remove(identifiable);
            }
        }
        if (identifiable.equals(new ORecordId("#77:3"))) {
            if (r3c < 1) {
                r3c++;
                iterator.remove();
                rids.remove(identifiable);
            }
        }
        if (identifiable.equals(new ORecordId("#77:6"))) {
            if (r6c < 1) {
                r6c++;
                iterator.remove();
                rids.remove(identifiable);
            }
        }
        if (identifiable.equals(new ORecordId("#77:4"))) {
            if (r4c < 1) {
                r4c++;
                iterator.remove();
                rids.remove(identifiable);
            }
        }
        if (identifiable.equals(new ORecordId("#77:7"))) {
            if (r7c < 1) {
                r7c++;
                iterator.remove();
                rids.remove(identifiable);
            }
        }
    }
    assertEquals(r2c, 2);
    assertEquals(r3c, 1);
    assertEquals(r6c, 1);
    assertEquals(r4c, 1);
    assertEquals(r7c, 1);
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
    for (OIdentifiable identifiable : bag) rids.add(identifiable);
    doc = new ODocument();
    final ORidBag otherBag = new ORidBag();
    for (OIdentifiable id : bag) otherBag.add(id);
    assertEmbedded(otherBag.isEmbedded());
    doc.field("ridbag", otherBag);
    doc.save();
    rid = doc.getIdentity();
    doc = database.load(rid);
    doc.setLazyLoad(false);
    bag = doc.field("ridbag");
    assertEmbedded(bag.isEmbedded());
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
}
Also used : ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ORID(com.orientechnologies.orient.core.id.ORID) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 58 with OStorage

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

the class ORidBagTest method testAddRemoveDuringIterationSBTreeContainsValues.

public void testAddRemoveDuringIterationSBTreeContainsValues() {
    ORidBag bag = new ORidBag();
    bag.setAutoConvertToRecord(false);
    assertEmbedded(bag.isEmbedded());
    bag.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:3"));
    bag.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:5"));
    bag.add(new ORecordId("#77:6"));
    assertEmbedded(bag.isEmbedded());
    ODocument doc = new ODocument();
    doc.field("ridbag", bag);
    doc.save();
    ORID rid = doc.getIdentity();
    OStorage storage = database.getStorage();
    database.close();
    storage.close(true, false);
    database.activateOnCurrentThread();
    database.resetInitialization();
    database.open("admin", "admin");
    doc = database.load(rid);
    doc.setLazyLoad(false);
    bag = doc.field("ridbag");
    assertEmbedded(bag.isEmbedded());
    bag.remove(new ORecordId("#77:1"));
    bag.remove(new ORecordId("#77:2"));
    bag.remove(new ORecordId("#77:2"));
    bag.remove(new ORecordId("#77:4"));
    bag.remove(new ORecordId("#77:6"));
    assertEmbedded(bag.isEmbedded());
    final List<OIdentifiable> rids = new ArrayList<OIdentifiable>();
    rids.add(new ORecordId("#77:3"));
    rids.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:5"));
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
    for (OIdentifiable identifiable : bag) rids.add(identifiable);
    Iterator<OIdentifiable> iterator = bag.iterator();
    while (iterator.hasNext()) {
        final OIdentifiable identifiable = iterator.next();
        if (identifiable.equals(new ORecordId("#77:4"))) {
            iterator.remove();
            assertTrue(rids.remove(identifiable));
        }
    }
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    for (OIdentifiable identifiable : bag) rids.add(identifiable);
    assertEmbedded(bag.isEmbedded());
    doc = new ODocument();
    final ORidBag otherBag = new ORidBag();
    for (OIdentifiable id : bag) otherBag.add(id);
    assertEmbedded(otherBag.isEmbedded());
    doc.field("ridbag", otherBag);
    doc.save();
    rid = doc.getIdentity();
    doc = database.load(rid);
    doc.setLazyLoad(false);
    bag = doc.field("ridbag");
    assertEmbedded(bag.isEmbedded());
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
}
Also used : ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) OStorage(com.orientechnologies.orient.core.storage.OStorage) ORID(com.orientechnologies.orient.core.id.ORID) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 59 with OStorage

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

the class ORidBagTest method testAddRemoveSBTreeContainsValues.

public void testAddRemoveSBTreeContainsValues() {
    ORidBag bag = new ORidBag();
    bag.setAutoConvertToRecord(false);
    bag.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:3"));
    bag.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:5"));
    bag.add(new ORecordId("#77:6"));
    assertEmbedded(bag.isEmbedded());
    ODocument doc = new ODocument();
    doc.field("ridbag", bag);
    doc.save();
    ORID rid = doc.getIdentity();
    OStorage storage = database.getStorage();
    database.close();
    storage.close(true, false);
    database = new ODatabaseDocumentTx(database.getURL());
    database.open("admin", "admin");
    doc = database.load(rid);
    doc.setLazyLoad(false);
    bag = doc.field("ridbag");
    assertEmbedded(bag.isEmbedded());
    bag.remove(new ORecordId("#77:1"));
    bag.remove(new ORecordId("#77:2"));
    bag.remove(new ORecordId("#77:2"));
    bag.remove(new ORecordId("#77:4"));
    bag.remove(new ORecordId("#77:6"));
    final List<OIdentifiable> rids = new ArrayList<OIdentifiable>();
    rids.add(new ORecordId("#77:3"));
    rids.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:5"));
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
    for (OIdentifiable identifiable : bag) rids.add(identifiable);
    doc = new ODocument();
    ORidBag otherBag = new ORidBag();
    for (OIdentifiable id : bag) otherBag.add(id);
    assertEmbedded(otherBag.isEmbedded());
    doc.field("ridbag", otherBag);
    doc.save();
    rid = doc.getIdentity();
    doc = database.load(rid);
    doc.setLazyLoad(false);
    bag = doc.field("ridbag");
    assertEmbedded(bag.isEmbedded());
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
}
Also used : ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ORID(com.orientechnologies.orient.core.id.ORID) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 60 with OStorage

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

the class ORidBagTest method testAddSBTreeAddInMemoryIterate.

public void testAddSBTreeAddInMemoryIterate() {
    List<OIdentifiable> rids = new ArrayList<OIdentifiable>();
    ORidBag bag = new ORidBag();
    assertEmbedded(bag.isEmbedded());
    bag.setAutoConvertToRecord(false);
    bag.add(new ORecordId("#77:2"));
    rids.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:2"));
    rids.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:3"));
    rids.add(new ORecordId("#77:3"));
    bag.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:4"));
    assertEmbedded(bag.isEmbedded());
    ODocument doc = new ODocument();
    doc.field("ridbag", bag);
    doc.save();
    ORID rid = doc.getIdentity();
    OStorage storage = database.getStorage();
    database.close();
    storage.close(true, false);
    database = new ODatabaseDocumentTx(database.getURL());
    database.open("admin", "admin");
    doc = database.load(rid);
    doc.setLazyLoad(false);
    bag = doc.field("ridbag");
    assertEmbedded(bag.isEmbedded());
    bag.add(new ORecordId("#77:0"));
    rids.add(new ORecordId("#77:0"));
    bag.add(new ORecordId("#77:1"));
    rids.add(new ORecordId("#77:1"));
    bag.add(new ORecordId("#77:2"));
    rids.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:3"));
    rids.add(new ORecordId("#77:3"));
    bag.add(new ORecordId("#77:5"));
    rids.add(new ORecordId("#77:5"));
    bag.add(new ORecordId("#77:6"));
    rids.add(new ORecordId("#77:6"));
    assertEmbedded(bag.isEmbedded());
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
    for (OIdentifiable identifiable : bag) rids.add(identifiable);
    doc = new ODocument();
    final ORidBag otherBag = new ORidBag();
    for (OIdentifiable id : bag) otherBag.add(id);
    doc.field("ridbag", otherBag);
    doc.save();
    rid = doc.getIdentity();
    doc = database.load(rid);
    doc.setLazyLoad(false);
    bag = doc.field("ridbag");
    assertEmbedded(bag.isEmbedded());
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
}
Also used : ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ORID(com.orientechnologies.orient.core.id.ORID) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

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