Search in sources :

Example 1 with OServerAdmin

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

the class ODatabaseHelper method existsDatabase.

public static boolean existsDatabase(final ODatabase database, String storageType) throws IOException {
    database.activateOnCurrentThread();
    if (database.getURL().startsWith("remote")) {
        OServerAdmin admin = new OServerAdmin(database.getURL()).connect("root", getServerRootPassword());
        boolean exist = admin.existsDatabase(storageType);
        admin.close();
        return exist;
    }
    return database.exists();
}
Also used : OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin)

Example 2 with OServerAdmin

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

the class ODatabaseHelper method freezeDatabase.

public static void freezeDatabase(final ODatabase database) throws IOException {
    database.activateOnCurrentThread();
    if (database.getURL().startsWith("remote")) {
        final OServerAdmin serverAdmin = new OServerAdmin(database.getURL());
        serverAdmin.connect("root", getServerRootPassword()).freezeDatabase("plocal");
        serverAdmin.close();
    } else {
        database.freeze();
    }
}
Also used : OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin)

Example 3 with OServerAdmin

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

the class OrientdbEdgeTest method verifyDatabaseExists.

private static void verifyDatabaseExists(Map<String, Object> conf) {
    final String url = (String) conf.get("storage.url");
    if (!url.startsWith("remote:"))
        return;
    try {
        final OServerAdmin admin = new OServerAdmin(url);
        admin.connect((String) conf.get("storage.user"), (String) conf.get("storage.password"));
        if (!admin.existsDatabase()) {
            System.err.println("creating database " + url);
            admin.createDatabase("graph", "plocal");
        }
        OrientGraph t = new OrientGraph(url, (String) conf.get("storage.user"), (String) conf.get("storage.password"));
        try {
            t.command(new OCommandSQL("alter database custom useLightweightEdges=false")).execute();
            t.commit();
            t.command(new OCommandSQL("ALTER CLASS V CLUSTERSELECTION balanced")).execute();
            t.commit();
            t.command(new OCommandSQL("ALTER CLASS E CLUSTERSELECTION balanced")).execute();
            t.commit();
        } finally {
            t.shutdown();
        }
        admin.close();
    } catch (IOException ex1) {
        throw new RuntimeException(ex1);
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin) IOException(java.io.IOException)

Example 4 with OServerAdmin

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

the class DistributedConfigReloadTest method checkAndCreateDatabase.

/**
   *
   */
public boolean checkAndCreateDatabase(String dbName) {
    boolean isNewDB = false;
    try {
        OServerAdmin serverAdmin = new OServerAdmin(getDBURL()).connect("root", "root");
        if (!serverAdmin.existsDatabase("plocal")) {
            log("Database does not exists. New database is created");
            serverAdmin.createDatabase(dbName, "graph", "plocal");
            OrientBaseGraph orientGraph = new OrientGraphNoTx(getDBURL());
            orientGraph.command(new OCommandSQL("ALTER DATABASE custom strictSQL=false")).execute();
            orientGraph.shutdown();
            isNewDB = true;
        } else {
            log(dbName + " database already exists");
        }
        serverAdmin.close();
    } catch (Exception ex) {
        log("Failed to create database", ex);
    }
    return isNewDB;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin) ONeedRetryException(com.orientechnologies.common.concur.ONeedRetryException) ORecordDuplicatedException(com.orientechnologies.orient.core.storage.ORecordDuplicatedException) ORecordNotFoundException(com.orientechnologies.orient.core.exception.ORecordNotFoundException)

Example 5 with OServerAdmin

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

the class DistributedDatabaseCRUDTest method checkAndCreateDatabase.

/**
   *
   */
public void checkAndCreateDatabase(String dbName) {
    try {
        OServerAdmin serverAdmin = new OServerAdmin(getDBURL()).connect("root", "root");
        if (!serverAdmin.existsDatabase("plocal")) {
            log("Database does not exists. New database is created");
            serverAdmin.createDatabase(dbName, "graph", "plocal");
        } else {
            log(dbName + " database already exists");
        }
        serverAdmin.close();
        OrientBaseGraph orientGraph = new OrientGraphNoTx(getDBURL());
        orientGraph.command(new OCommandSQL("ALTER DATABASE custom strictSQL=false")).execute();
        orientGraph.shutdown();
    } catch (Exception ex) {
        log("Failed to create database", ex);
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin) ONeedRetryException(com.orientechnologies.common.concur.ONeedRetryException) ODatabaseException(com.orientechnologies.orient.core.exception.ODatabaseException)

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