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();
}
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();
}
}
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);
}
}
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;
}
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);
}
}
Aggregations