use of com.orientechnologies.orient.core.exception.ODatabaseException in project orientdb by orientechnologies.
the class DistributedDbDropAndReCreateTest method onAfterExecution.
@Override
protected void onAfterExecution() throws Exception {
int s = 0;
do {
ServerRun server = serverInstance.get(0);
ODatabaseDocumentTx db = new ODatabaseDocumentTx(getDatabaseURL(server));
db.open("admin", "admin");
banner("DROPPING DATABASE ON SERVERS");
waitForDatabaseIsOnline(0, "europe-0", getDatabaseName(), 5000);
waitForDatabaseIsOnline(0, "europe-1", getDatabaseName(), 5000);
waitForDatabaseIsOnline(0, "europe-2", getDatabaseName(), 5000);
db.drop();
Thread.sleep(2000);
Assert.assertFalse(server.getServerInstance().getDistributedManager().getConfigurationMap().containsKey(OHazelcastPlugin.CONFIG_DATABASE_PREFIX + getDatabaseName()));
server = serverInstance.get(s);
banner("RE-CREATING DATABASE ON SERVER " + server.getServerId());
db = new ODatabaseDocumentTx(getDatabaseURL(server));
Assert.assertFalse(server.getServerInstance().getDistributedManager().getConfigurationMap().containsKey(OHazelcastPlugin.CONFIG_DATABASE_PREFIX + getDatabaseName()));
for (int retry = 0; retry < 10; retry++) {
try {
db.create();
break;
} catch (ODatabaseException e) {
System.out.println("DB STILL IN THE CLUSTER, WAIT AND RETRY (retry " + retry + ")...");
Thread.sleep(1000);
}
}
db.activateOnCurrentThread();
db.close();
} while (++s < serverInstance.size());
// DROP LAST DATABASE
final ODatabaseDocumentTx db = new ODatabaseDocumentTx(getDatabaseURL(serverInstance.get(serverInstance.size() - 1)));
db.open("admin", "admin");
db.drop();
}
use of com.orientechnologies.orient.core.exception.ODatabaseException in project orientdb by orientechnologies.
the class OServerCommandPostInstallDatabase method execute.
@Override
public boolean execute(final OHttpRequest iRequest, OHttpResponse iResponse) throws Exception {
checkSyntax(iRequest.url, 1, "Syntax error: installDatabase");
iRequest.data.commandInfo = "Import database";
try {
final String url = iRequest.content;
final String name = getDbName(url);
if (name != null) {
final String folder = server.getDatabaseDirectory() + File.separator + name;
final File f = new File(folder);
if (f.exists() && OLocalPaginatedStorage.exists(folder)) {
throw new ODatabaseException("Database named '" + name + "' already exists: ");
} else {
f.mkdirs();
final URL uri = new URL(url);
final URLConnection conn = uri.openConnection();
conn.setRequestProperty("User-Agent", "OrientDB-Studio");
conn.setDefaultUseCaches(false);
OZIPCompressionUtil.uncompressDirectory(conn.getInputStream(), folder, new OCommandOutputListener() {
@Override
public void onMessage(String iText) {
}
});
iResponse.send(OHttpUtils.STATUS_OK_CODE, "OK", OHttpUtils.CONTENT_TEXT_PLAIN, null, null);
}
} else {
throw new IllegalArgumentException("Could not find database name");
}
} catch (Exception e) {
throw e;
} finally {
}
return false;
}
use of com.orientechnologies.orient.core.exception.ODatabaseException in project orientdb by orientechnologies.
the class DatabaseThreadFactoryTest method init.
@BeforeClass
public void init() {
try {
ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get();
db.close();
ODatabaseRecordThreadLocal.INSTANCE.remove();
} catch (ODatabaseException ode) {
}
}
Aggregations