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);
}
}
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);
}
}
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);
}
}
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.");
}
}
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);
}
}
Aggregations