Search in sources :

Example 11 with PermanentStorageException

use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.

the class LuceneIndex method getWriter.

private IndexWriter getWriter(String store) throws StorageException {
    Preconditions.checkArgument(writerLock.isHeldByCurrentThread());
    IndexWriter writer = writers.get(store);
    if (writer == null) {
        IndexWriterConfig iwc = new IndexWriterConfig(LUCENE_VERSION, analyzer);
        iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
        try {
            writer = new IndexWriter(getStoreDirectory(store), iwc);
            writers.put(store, writer);
        } catch (IOException e) {
            throw new PermanentStorageException("Could not create writer", e);
        }
    }
    return writer;
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) IOException(java.io.IOException)

Example 12 with PermanentStorageException

use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.

the class LuceneIndex method getStoreDirectory.

private Directory getStoreDirectory(String store) throws StorageException {
    Preconditions.checkArgument(StringUtils.isAlphanumeric(store), "Invalid store name: %s", store);
    String dir = basePath + File.separator + store;
    try {
        File path = new File(dir);
        if (!path.exists())
            path.mkdirs();
        if (!path.exists() || !path.isDirectory() || !path.canWrite())
            throw new PermanentStorageException("Cannot access or write to directory: " + dir);
        log.debug("Opening store directory [{}]", path);
        return FSDirectory.open(path);
    } catch (IOException e) {
        throw new PermanentStorageException("Could not open directory: " + dir, e);
    }
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) IOException(java.io.IOException) File(java.io.File)

Example 13 with PermanentStorageException

use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.

the class PersistitKeyValueStore method clear.

/**
 * Clears the contents of this kv store
 */
public void clear() throws StorageException {
    try {
        Exchange exchange = persistit.getExchange(VOLUME_NAME, name, true);
        exchange.removeTree();
    } catch (PersistitException ex) {
        throw new PermanentStorageException(ex);
    }
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) PersistitException(com.persistit.exception.PersistitException)

Example 14 with PermanentStorageException

use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.

the class PersistitKeyValueStore method get.

@Override
public StaticBuffer get(final StaticBuffer key, StoreTransaction txh) throws StorageException {
    final PersistitTransaction tx = (PersistitTransaction) txh;
    synchronized (tx) {
        tx.assign();
        final Exchange exchange = tx.getExchange(name);
        try {
            toKey(exchange, key);
            exchange.fetch();
            if (exchange.getValue().isDefined()) {
                return getValue(exchange);
            } else {
                return null;
            }
        } catch (PersistitException ex) {
            throw new PermanentStorageException(ex);
        } finally {
            tx.releaseExchange(exchange);
        }
    }
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) PersistitException(com.persistit.exception.PersistitException)

Example 15 with PermanentStorageException

use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.

the class PersistitKeyValueStore method containsKey.

@Override
public boolean containsKey(final StaticBuffer key, StoreTransaction txh) throws StorageException {
    final PersistitTransaction tx = (PersistitTransaction) txh;
    synchronized (tx) {
        tx.assign();
        final Exchange exchange = tx.getExchange(name);
        try {
            toKey(exchange, key);
            return exchange.isValueDefined();
        } catch (PersistitException ex) {
            throw new PermanentStorageException(ex);
        } finally {
            tx.releaseExchange(exchange);
        }
    }
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) PersistitException(com.persistit.exception.PersistitException)

Aggregations

PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)43 TemporaryStorageException (com.thinkaurelius.titan.diskstorage.TemporaryStorageException)14 StorageException (com.thinkaurelius.titan.diskstorage.StorageException)12 PersistitException (com.persistit.exception.PersistitException)9 IOException (java.io.IOException)8 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)6 StaticBuffer (com.thinkaurelius.titan.diskstorage.StaticBuffer)5 ByteBuffer (java.nio.ByteBuffer)5 StaticByteBuffer (com.thinkaurelius.titan.diskstorage.util.StaticByteBuffer)4 ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)4 StoreTransaction (com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction)3 InvalidRequestException (org.apache.cassandra.thrift.InvalidRequestException)3 ColumnFamilyDefinition (com.netflix.astyanax.ddl.ColumnFamilyDefinition)2 Exchange (com.persistit.Exchange)2 DatabaseException (com.sleepycat.je.DatabaseException)2 TitanException (com.thinkaurelius.titan.core.TitanException)2 CTConnection (com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection)2 Entry (com.thinkaurelius.titan.diskstorage.keycolumnvalue.Entry)2 KeyValueEntry (com.thinkaurelius.titan.diskstorage.keycolumnvalue.keyvalue.KeyValueEntry)2 ConsistentKeyLockStatus (com.thinkaurelius.titan.diskstorage.locking.consistentkey.ConsistentKeyLockStatus)2