Search in sources :

Example 61 with BackendException

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

the class ConsistentKeyLockerTest method testWriteLockDiesOnPermanentStorageException.

/**
 * Test that the first {@link org.janusgraph.diskstorage.PermanentBackendException} thrown by the
 * locker's store causes it to attempt to delete outstanding lock writes and
 * then emit the exception without retrying.
 *
 * @throws org.janusgraph.diskstorage.BackendException shouldn't happen
 */
@Test
public void testWriteLockDiesOnPermanentStorageException() throws BackendException {
    PermanentBackendException errOnFire = new PermanentBackendException("Storage cluster is on fire");
    expect(lockState.has(defaultTx, defaultLockID)).andReturn(false);
    recordSuccessfulLocalLock();
    StaticBuffer lockCol = recordExceptionLockWrite(errOnFire);
    recordSuccessfulLockDelete(lockCol);
    recordSuccessfulLocalUnlock();
    ctrl.replay();
    BackendException expected = null;
    try {
        // SUT
        locker.writeLock(defaultLockID, defaultTx);
    } catch (PermanentLockingException e) {
        expected = e;
    }
    assertNotNull(expected);
    assertEquals(errOnFire, expected.getCause());
}
Also used : PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) StaticBuffer(org.janusgraph.diskstorage.StaticBuffer) TemporaryBackendException(org.janusgraph.diskstorage.TemporaryBackendException) BackendException(org.janusgraph.diskstorage.BackendException) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) Test(org.junit.jupiter.api.Test)

Example 62 with BackendException

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

the class KCVSCacheTest method loadStore.

public void loadStore(int numKeys, int numCols) {
    StoreTransaction tx = getStoreTx();
    try {
        for (int i = 1; i <= numKeys; i++) {
            final List<Entry> adds = new ArrayList<>(numCols);
            for (int j = 1; j <= numCols; j++) adds.add(getEntry(j, j));
            store.mutate(BufferUtil.getIntBuffer(i), adds, KeyColumnValueStore.NO_DELETIONS, tx);
        }
        tx.commit();
    } catch (BackendException e) {
        throw new RuntimeException(e);
    }
}
Also used : StaticArrayEntry(org.janusgraph.diskstorage.util.StaticArrayEntry) Entry(org.janusgraph.diskstorage.Entry) StoreTransaction(org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction) ArrayList(java.util.ArrayList) BackendException(org.janusgraph.diskstorage.BackendException)

Aggregations

BackendException (org.janusgraph.diskstorage.BackendException)62 PermanentBackendException (org.janusgraph.diskstorage.PermanentBackendException)26 TemporaryBackendException (org.janusgraph.diskstorage.TemporaryBackendException)18 JanusGraphException (org.janusgraph.core.JanusGraphException)17 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)16 StoreTransaction (org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction)16 ArrayList (java.util.ArrayList)14 List (java.util.List)13 Map (java.util.Map)12 Duration (java.time.Duration)11 HashMap (java.util.HashMap)11 Configuration (org.janusgraph.diskstorage.configuration.Configuration)11 Entry (org.janusgraph.diskstorage.Entry)10 Test (org.junit.jupiter.api.Test)10 BaseTransactionConfig (org.janusgraph.diskstorage.BaseTransactionConfig)9 BackendOperation (org.janusgraph.diskstorage.util.BackendOperation)9 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)9 IOException (java.io.IOException)8 StaticArrayEntry (org.janusgraph.diskstorage.util.StaticArrayEntry)8 Preconditions (com.google.common.base.Preconditions)6