Search in sources :

Example 31 with PermanentBackendException

use of org.janusgraph.diskstorage.PermanentBackendException in project janusgraph by JanusGraph.

the class AstyanaxStoreManager method getCompressionOptions.

@Override
public Map<String, String> getCompressionOptions(String cf) throws BackendException {
    try {
        Keyspace k = keyspaceContext.getClient();
        KeyspaceDefinition keyspaceDefinition = k.describeKeyspace();
        if (null == keyspaceDefinition) {
            throw new PermanentBackendException("Keyspace " + k.getKeyspaceName() + " is undefined");
        }
        ColumnFamilyDefinition columnFamilyDefinition = keyspaceDefinition.getColumnFamily(cf);
        if (null == columnFamilyDefinition) {
            throw new PermanentBackendException("Column family " + cf + " is undefined");
        }
        return columnFamilyDefinition.getCompressionOptions();
    } catch (ConnectionException e) {
        throw new PermanentBackendException(e);
    }
}
Also used : KeyspaceDefinition(com.netflix.astyanax.ddl.KeyspaceDefinition) ColumnFamilyDefinition(com.netflix.astyanax.ddl.ColumnFamilyDefinition) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) Keyspace(com.netflix.astyanax.Keyspace) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException)

Example 32 with PermanentBackendException

use of org.janusgraph.diskstorage.PermanentBackendException in project janusgraph by JanusGraph.

the class BerkeleyJEKeyValueStore method get.

@Override
public StaticBuffer get(StaticBuffer key, StoreTransaction txh) throws BackendException {
    Transaction tx = getTransaction(txh);
    try {
        DatabaseEntry databaseKey = key.as(ENTRY_FACTORY);
        DatabaseEntry data = new DatabaseEntry();
        log.trace("db={}, op=get, tx={}", name, txh);
        OperationResult result = db.get(tx, databaseKey, data, Get.SEARCH, getReadOptions(txh));
        if (result != null) {
            return getBuffer(data);
        } else {
            return null;
        }
    } catch (DatabaseException e) {
        throw new PermanentBackendException(e);
    }
}
Also used : StoreTransaction(org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction) Transaction(com.sleepycat.je.Transaction) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) OperationResult(com.sleepycat.je.OperationResult) DatabaseEntry(com.sleepycat.je.DatabaseEntry) DatabaseException(com.sleepycat.je.DatabaseException)

Example 33 with PermanentBackendException

use of org.janusgraph.diskstorage.PermanentBackendException in project janusgraph by JanusGraph.

the class BerkeleyJEKeyValueStore method delete.

@Override
public void delete(StaticBuffer key, StoreTransaction txh) throws BackendException {
    log.trace("Deletion");
    Transaction tx = getTransaction(txh);
    try {
        log.trace("db={}, op=delete, tx={}", name, txh);
        OperationStatus status = db.delete(tx, key.as(ENTRY_FACTORY));
        if (status != OperationStatus.SUCCESS && status != OperationStatus.NOTFOUND) {
            throw new PermanentBackendException("Could not remove: " + status);
        }
    } catch (DatabaseException e) {
        throw new PermanentBackendException(e);
    }
}
Also used : StoreTransaction(org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction) Transaction(com.sleepycat.je.Transaction) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseException(com.sleepycat.je.DatabaseException)

Example 34 with PermanentBackendException

use of org.janusgraph.diskstorage.PermanentBackendException in project janusgraph by JanusGraph.

the class BerkeleyJEKeyValueStore method insert.

public void insert(StaticBuffer key, StaticBuffer value, StoreTransaction txh, boolean allowOverwrite, Integer ttl) throws BackendException {
    Transaction tx = getTransaction(txh);
    OperationStatus status;
    log.trace("db={}, op=insert, tx={}", name, txh);
    WriteOptions writeOptions = getWriteOptions(txh);
    if (ttl != null && ttl > 0) {
        int convertedTtl = ttlConverter.apply(ttl);
        writeOptions.setTTL(convertedTtl, TimeUnit.HOURS);
    }
    if (allowOverwrite) {
        OperationResult result = db.put(tx, key.as(ENTRY_FACTORY), value.as(ENTRY_FACTORY), Put.OVERWRITE, writeOptions);
        EnvironmentFailureException.assertState(result != null);
        status = OperationStatus.SUCCESS;
    } else {
        OperationResult result = db.put(tx, key.as(ENTRY_FACTORY), value.as(ENTRY_FACTORY), Put.NO_OVERWRITE, writeOptions);
        status = result == null ? OperationStatus.KEYEXIST : OperationStatus.SUCCESS;
    }
    if (status != OperationStatus.SUCCESS) {
        throw new PermanentBackendException("Key already exists on no-overwrite.");
    }
}
Also used : WriteOptions(com.sleepycat.je.WriteOptions) StoreTransaction(org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction) Transaction(com.sleepycat.je.Transaction) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) OperationStatus(com.sleepycat.je.OperationStatus) OperationResult(com.sleepycat.je.OperationResult)

Example 35 with PermanentBackendException

use of org.janusgraph.diskstorage.PermanentBackendException in project janusgraph by JanusGraph.

the class BerkeleyJETx method commit.

@Override
public synchronized void commit() throws BackendException {
    super.commit();
    if (tx == null)
        return;
    if (log.isTraceEnabled())
        log.trace("{} committed", this, new TransactionClose(this.toString()));
    try {
        isOpen = false;
        closeOpenCursors();
        tx.commit();
        tx = null;
    } catch (DatabaseException e) {
        throw new PermanentBackendException(e);
    }
}
Also used : PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) DatabaseException(com.sleepycat.je.DatabaseException)

Aggregations

PermanentBackendException (org.janusgraph.diskstorage.PermanentBackendException)53 IOException (java.io.IOException)24 TemporaryBackendException (org.janusgraph.diskstorage.TemporaryBackendException)16 UncheckedIOException (java.io.UncheckedIOException)12 BackendException (org.janusgraph.diskstorage.BackendException)12 Configuration (org.janusgraph.diskstorage.configuration.Configuration)8 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)7 DatabaseException (com.sleepycat.je.DatabaseException)7 BaseTransactionConfig (org.janusgraph.diskstorage.BaseTransactionConfig)7 Duration (java.time.Duration)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)6 StoreTransaction (org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction)6 SolrServerException (org.apache.solr.client.solrj.SolrServerException)5 KeeperException (org.apache.zookeeper.KeeperException)5 Transaction (com.sleepycat.je.Transaction)4 HashMap (java.util.HashMap)4 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)4 KeyInformation (org.janusgraph.diskstorage.indexing.KeyInformation)4