Search in sources :

Example 11 with OServerAdmin

use of com.orientechnologies.orient.client.remote.OServerAdmin in project orientdb by orientechnologies.

the class OEmbeddedRidBagTest method afterMethod.

@AfterMethod
public void afterMethod() throws IOException {
    OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(topThreshold);
    OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD.setValue(bottomThreshold);
    if (database.getStorage() instanceof OStorageProxy) {
        OServerAdmin server = new OServerAdmin(database.getURL()).connect("root", ODatabaseHelper.getServerRootPassword());
        server.setGlobalConfiguration(OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD, topThreshold);
        server.setGlobalConfiguration(OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD, bottomThreshold);
        server.close();
    }
}
Also used : OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin) AfterMethod(org.testng.annotations.AfterMethod)

Example 12 with OServerAdmin

use of com.orientechnologies.orient.client.remote.OServerAdmin in project orientdb by orientechnologies.

the class OEmbeddedRidBagTest method beforeMethod.

@BeforeMethod
public void beforeMethod() throws IOException {
    topThreshold = OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.getValueAsInteger();
    bottomThreshold = OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD.getValueAsInteger();
    OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(Integer.MAX_VALUE);
    OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD.setValue(Integer.MAX_VALUE);
    if (database.getStorage() instanceof OStorageProxy) {
        OServerAdmin server = new OServerAdmin(database.getURL()).connect("root", ODatabaseHelper.getServerRootPassword());
        server.setGlobalConfiguration(OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD, Integer.MAX_VALUE);
        server.setGlobalConfiguration(OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD, Integer.MAX_VALUE);
        server.close();
    }
}
Also used : OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 13 with OServerAdmin

use of com.orientechnologies.orient.client.remote.OServerAdmin in project orientdb by orientechnologies.

the class ORidBagTest method testFromEmbeddedToSBTreeAndBack.

public void testFromEmbeddedToSBTreeAndBack() throws IOException {
    OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(7);
    OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD.setValue(-1);
    if (database.getStorage() instanceof OStorageProxy) {
        OServerAdmin server = new OServerAdmin(database.getURL()).connect("root", ODatabaseHelper.getServerRootPassword());
        server.setGlobalConfiguration(OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD, 7);
        server.setGlobalConfiguration(OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD, -1);
        server.close();
    }
    ORidBag ridBag = new ORidBag();
    ODocument document = new ODocument();
    document.field("ridBag", ridBag);
    Assert.assertTrue(ridBag.isEmbedded());
    document.save();
    document.reload();
    ridBag = document.field("ridBag");
    Assert.assertTrue(ridBag.isEmbedded());
    List<OIdentifiable> addedItems = new ArrayList<OIdentifiable>();
    for (int i = 0; i < 6; i++) {
        ODocument docToAdd = new ODocument();
        docToAdd.save();
        ridBag.add(docToAdd);
        addedItems.add(docToAdd);
    }
    document.save();
    document.reload();
    ridBag = document.field("ridBag");
    Assert.assertTrue(ridBag.isEmbedded());
    ODocument docToAdd = new ODocument();
    ridBag.add(docToAdd);
    addedItems.add(docToAdd);
    document.save();
    Assert.assertTrue(!ridBag.isEmbedded());
    List<OIdentifiable> addedItemsCopy = new ArrayList<OIdentifiable>(addedItems);
    for (OIdentifiable id : ridBag) Assert.assertTrue(addedItems.remove(id));
    Assert.assertTrue(addedItems.isEmpty());
    document.reload();
    ridBag = document.field("ridBag");
    Assert.assertTrue(!ridBag.isEmbedded());
    addedItems.addAll(addedItemsCopy);
    for (OIdentifiable id : ridBag) Assert.assertTrue(addedItems.remove(id));
    Assert.assertTrue(addedItems.isEmpty());
    addedItems.addAll(addedItemsCopy);
    for (int i = 0; i < 3; i++) ridBag.remove(addedItems.remove(i));
    addedItemsCopy.clear();
    addedItemsCopy.addAll(addedItems);
    document.save();
    Assert.assertTrue(!ridBag.isEmbedded());
    for (OIdentifiable id : ridBag) Assert.assertTrue(addedItems.remove(id));
    Assert.assertTrue(addedItems.isEmpty());
    document.reload();
    ridBag = document.field("ridBag");
    Assert.assertTrue(!ridBag.isEmbedded());
    addedItems.addAll(addedItemsCopy);
    for (OIdentifiable id : ridBag) Assert.assertTrue(addedItems.remove(id));
    Assert.assertTrue(addedItems.isEmpty());
}
Also used : ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 14 with OServerAdmin

use of com.orientechnologies.orient.client.remote.OServerAdmin in project orientdb by orientechnologies.

the class ServerTest method testOpenCloseCreateClass.

@Test
public void testOpenCloseCreateClass() throws IOException {
    OServerAdmin admin = new OServerAdmin("remote:localhost/doubleOpenTest");
    admin.connect("root", ODatabaseHelper.getServerRootPassword());
    admin.createDatabase("document", "memory");
    admin.close();
    ODatabaseDocument db = new ODatabaseDocumentTx("remote:localhost/doubleOpenTest");
    try {
        db.open("admin", "admin");
        ODocument d = new ODocument("User");
        d.save();
    } finally {
        db.close();
    }
    try {
        db.open("admin", "admin");
        ODocument d = new ODocument("User");
        d.save();
    } finally {
        db.close();
    }
    admin = new OServerAdmin("remote:localhost/doubleOpenTest");
    admin.connect("root", ODatabaseHelper.getServerRootPassword());
    admin.dropDatabase("memory");
    admin.close();
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 15 with OServerAdmin

use of com.orientechnologies.orient.client.remote.OServerAdmin in project orientdb by orientechnologies.

the class ServerTest method testConnectClose.

@Test
public void testConnectClose() throws IOException {
    ORemoteConnectionManager connManager = (((OEngineRemote) Orient.instance().getRunningEngine("remote"))).getConnectionManager();
    int count = connManager.getAvailableConnections(serverURL);
    OServerAdmin server = new OServerAdmin(serverURL);
    server.connect("root", ODatabaseHelper.getServerRootPassword());
    server.close();
    Assert.assertEquals(connManager.getAvailableConnections(serverURL), count);
}
Also used : ORemoteConnectionManager(com.orientechnologies.orient.client.remote.ORemoteConnectionManager) OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin) Test(org.testng.annotations.Test)

Aggregations

OServerAdmin (com.orientechnologies.orient.client.remote.OServerAdmin)46 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)9 Before (org.junit.Before)9 OServer (com.orientechnologies.orient.server.OServer)8 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)6 IOException (java.io.IOException)5 Test (org.testng.annotations.Test)5 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)4 ONeedRetryException (com.orientechnologies.common.concur.ONeedRetryException)3 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)3 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)3 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)2 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)2 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)2 OConcurrentModificationException (com.orientechnologies.orient.core.exception.OConcurrentModificationException)2 AfterMethod (org.testng.annotations.AfterMethod)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 ORemoteConnectionManager (com.orientechnologies.orient.client.remote.ORemoteConnectionManager)1 OCommandScript (com.orientechnologies.orient.core.command.script.OCommandScript)1 OPartitionedDatabasePool (com.orientechnologies.orient.core.db.OPartitionedDatabasePool)1