Search in sources :

Example 16 with OStorageException

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;
    }
}
Also used : OStorageException(com.orientechnologies.orient.core.exception.OStorageException)

Example 17 with OStorageException

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();
        }
    }
}
Also used : OStorageException(com.orientechnologies.orient.core.exception.OStorageException) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OSecurityException(com.orientechnologies.orient.core.exception.OSecurityException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) OException(com.orientechnologies.common.exception.OException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) OSecurityException(com.orientechnologies.orient.core.exception.OSecurityException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MalformedObjectNameException(javax.management.MalformedObjectNameException) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ODatabaseException(com.orientechnologies.orient.core.exception.ODatabaseException) IOException(java.io.IOException)

Example 18 with OStorageException

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"));
        }
    }
}
Also used : OStorageException(com.orientechnologies.orient.core.exception.OStorageException) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Example 19 with OStorageException

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:"));
    }
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ODatabaseException(com.orientechnologies.orient.core.exception.ODatabaseException)

Example 20 with OStorageException

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()));
    }
}
Also used : OStorageException(com.orientechnologies.orient.core.exception.OStorageException) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Aggregations

OStorageException (com.orientechnologies.orient.core.exception.OStorageException)46 OException (com.orientechnologies.common.exception.OException)13 IOException (java.io.IOException)13 OIndexException (com.orientechnologies.orient.core.index.OIndexException)10 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)10 OAtomicOperation (com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)10 OLocalHashTableException (com.orientechnologies.orient.core.exception.OLocalHashTableException)5 OTooBigIndexKeyException (com.orientechnologies.orient.core.exception.OTooBigIndexKeyException)5 OIndexEngineException (com.orientechnologies.orient.core.index.OIndexEngineException)5 OFileClassic (com.orientechnologies.orient.core.storage.fs.OFileClassic)5 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)4 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)3 OCachePointer (com.orientechnologies.orient.core.storage.cache.OCachePointer)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 SubScheduledExecutorService (com.orientechnologies.common.concur.executors.SubScheduledExecutorService)2 OType (com.orientechnologies.orient.core.metadata.schema.OType)2 OSessionStoragePerformanceStatistic (com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)2 File (java.io.File)2 RandomAccessFile (java.io.RandomAccessFile)2 OInterruptedException (com.orientechnologies.common.concur.lock.OInterruptedException)1