use of com.orientechnologies.orient.core.exception.OStorageException in project orientdb by orientechnologies.
the class OLogSegment method close.
public void close(boolean flush) throws IOException {
if (!closed) {
lastReadRecord.clear();
stopFlush(flush);
if (!closer.isShutdown()) {
closer.shutdown();
try {
if (!closer.awaitTermination(OGlobalConfiguration.WAL_SHUTDOWN_TIMEOUT.getValueAsInteger(), TimeUnit.MILLISECONDS))
throw new OStorageException("WAL file auto close task '" + getPath() + "' cannot be stopped");
} catch (InterruptedException e) {
OLogManager.instance().error(this, "Shutdown of file auto close thread was interrupted");
}
}
fileLock.lock();
try {
if (rndFile != null) {
rndFile.close();
rndFile = null;
}
} finally {
fileLock.unlock();
}
closed = true;
}
}
use of com.orientechnologies.orient.core.exception.OStorageException in project orientdb by orientechnologies.
the class OServer method loadDatabases.
/**
* Opens all the available server's databases.
*/
protected void loadDatabases() {
if (!OGlobalConfiguration.SERVER_OPEN_ALL_DATABASES_AT_STARTUP.getValueAsBoolean())
return;
final String dbPath = getDatabaseDirectory();
for (Map.Entry<String, String> storageEntry : getAvailableStorageNames().entrySet()) {
final String databaseName = storageEntry.getKey();
OLogManager.instance().info(this, "Opening database '%s' at startup...", databaseName);
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("plocal:" + dbPath + databaseName);
try {
try {
openDatabaseBypassingSecurity(db, null, "internal");
} catch (OStorageException e) {
if (e.getCause() instanceof OSecurityException) {
if (askForEncryptionKey(databaseName)) {
// RETRY IT
try {
openDatabaseBypassingSecurity(db, null, "internal");
} catch (Exception e2) {
// LOOK FOR A SECURITY EXCEPTION
Throwable nested = e2;
while (nested != null) {
if (nested instanceof OSecurityException) {
OLogManager.instance().error(this, "Invalid key for database '%s'. Skip database opening", databaseName);
return;
}
nested = nested.getCause();
}
OLogManager.instance().error(this, "Error on opening database '%s': %s", e, e.getMessage());
}
}
}
}
} finally {
db.activateOnCurrentThread();
db.close();
}
}
}
use of com.orientechnologies.orient.core.exception.OStorageException in project orientdb by orientechnologies.
the class DistributedDbDropTest method onAfterExecution.
@Override
protected void onAfterExecution() throws Exception {
ServerRun s = serverInstance.get(0);
final ODatabaseDocumentTx db = new ODatabaseDocumentTx(getDatabaseURL(s));
db.open("admin", "admin");
banner("DROPPING DATABASE ON SERVER " + s.getServerId());
db.drop();
for (int i = 1; i < serverInstance.size(); ++i) {
try {
final ODatabaseDocumentTx database = new ODatabaseDocumentTx(getDatabaseURL(s));
database.open("admin", "admin");
Assert.fail("The database was not deleted on server " + i);
} catch (OStorageException e) {
Assert.assertTrue(e.getCause().getMessage().contains("it does not exist"));
}
}
}
use of com.orientechnologies.orient.core.exception.OStorageException in project orientdb by orientechnologies.
the class DbDeleteTest method testDbDeleteNoCredential.
public void testDbDeleteNoCredential() throws IOException {
ODatabaseDocument db = new ODatabaseDocumentTx(url);
try {
db.drop();
Assert.fail("Should have thrown ODatabaseException because trying to delete a not opened");
} catch (ODatabaseException e) {
Assert.assertTrue(e.getMessage().contains("Database '" + url + "' is closed"));
} catch (OStorageException e) {
Assert.assertTrue(e.getMessage().startsWith("Cannot delete the remote storage:"));
}
}
use of com.orientechnologies.orient.core.exception.OStorageException in project orientdb by orientechnologies.
the class DbCreationTest method testSubFolderMultipleDbCreateSameName.
@Test(dependsOnMethods = { "testChangeLocale" })
public void testSubFolderMultipleDbCreateSameName() throws IOException {
int pos = url.lastIndexOf("/");
String u = url;
if (pos > -1)
u = url.substring(0, pos);
else {
pos = url.lastIndexOf(":");
u = url.substring(0, pos + 1);
}
for (int i = 0; i < 3; ++i) {
String ur = u + "/" + i + "$db";
ODatabaseDocumentTx db = new ODatabaseDocumentTx(ur);
try {
ODatabaseHelper.dropDatabase(db, getStorageType());
} catch (OStorageException e) {
Assert.assertTrue(e.getCause().getMessage().contains("doesn't exits."));
}
ODatabaseHelper.createDatabase(db, ur, getStorageType());
Assert.assertTrue(ODatabaseHelper.existsDatabase(db, getStorageType()));
db.open("admin", "admin");
}
for (int i = 0; i < 3; ++i) {
String ur = u + "/" + i + "$db";
ODatabaseDocumentTx db = new ODatabaseDocumentTx(ur);
Assert.assertTrue(ODatabaseHelper.existsDatabase(db, getStorageType()));
db.activateOnCurrentThread();
ODatabaseHelper.dropDatabase(db, getStorageType());
Assert.assertFalse(ODatabaseHelper.existsDatabase(db, getStorageType()));
}
}
Aggregations