Search in sources :

Example 1 with TransactionContext

use of io.camunda.zeebe.db.TransactionContext in project zeebe by camunda.

the class ZeebeRocksDbTransactionTest method shouldThrowRecoverableExceptionOnCommit.

@Test(expected = ZeebeDbException.class)
public void shouldThrowRecoverableExceptionOnCommit() throws Exception {
    // given
    final ZeebeTransaction transaction = mock(ZeebeTransaction.class);
    final TransactionContext newContext = new DefaultTransactionContext(transaction);
    final Status status = new Status(Code.IOError, SubCode.None, "");
    doThrow(new RocksDBException("expected", status)).when(transaction).commitInternal();
    // when
    newContext.runInTransaction(() -> {
    });
}
Also used : Status(org.rocksdb.Status) RocksDBException(org.rocksdb.RocksDBException) TransactionContext(io.camunda.zeebe.db.TransactionContext) Test(org.junit.Test)

Example 2 with TransactionContext

use of io.camunda.zeebe.db.TransactionContext in project zeebe by camunda.

the class ZeebeRocksDbTransactionTest method shouldWrapExceptionInRuntimeExceptionOnCommit.

@Test(expected = RuntimeException.class)
public void shouldWrapExceptionInRuntimeExceptionOnCommit() throws Exception {
    // given
    final ZeebeTransaction transaction = mock(ZeebeTransaction.class);
    final TransactionContext newContext = new DefaultTransactionContext(transaction);
    final Status status = new Status(Code.NotSupported, SubCode.None, "");
    doThrow(new RocksDBException("expected", status)).when(transaction).commitInternal();
    // when
    newContext.runInTransaction(() -> {
    });
}
Also used : Status(org.rocksdb.Status) RocksDBException(org.rocksdb.RocksDBException) TransactionContext(io.camunda.zeebe.db.TransactionContext) Test(org.junit.Test)

Example 3 with TransactionContext

use of io.camunda.zeebe.db.TransactionContext in project zeebe by camunda.

the class ZeebeRocksDbTransactionTest method shouldWrapExceptionInRuntimeExceptionOnRollback.

@Test(expected = RuntimeException.class)
public void shouldWrapExceptionInRuntimeExceptionOnRollback() throws Exception {
    // given
    final ZeebeTransaction transaction = mock(ZeebeTransaction.class);
    final TransactionContext newContext = new DefaultTransactionContext(transaction);
    final Status status = new Status(Code.NotSupported, SubCode.None, "");
    doThrow(new RocksDBException("expected", status)).when(transaction).rollbackInternal();
    // when
    newContext.runInTransaction(() -> {
    });
}
Also used : Status(org.rocksdb.Status) RocksDBException(org.rocksdb.RocksDBException) TransactionContext(io.camunda.zeebe.db.TransactionContext) Test(org.junit.Test)

Example 4 with TransactionContext

use of io.camunda.zeebe.db.TransactionContext in project zeebe by zeebe-io.

the class ZeebeRocksDbTransactionTest method shouldThrowRecoverableExceptionOnRollback.

@Test(expected = ZeebeDbException.class)
public void shouldThrowRecoverableExceptionOnRollback() throws Exception {
    // given
    final ZeebeTransaction transaction = mock(ZeebeTransaction.class);
    final TransactionContext newContext = new DefaultTransactionContext(transaction);
    final Status status = new Status(Code.IOError, SubCode.None, "");
    doThrow(new RocksDBException("expected", status)).when(transaction).rollbackInternal();
    // when
    newContext.runInTransaction(() -> {
    });
}
Also used : Status(org.rocksdb.Status) RocksDBException(org.rocksdb.RocksDBException) TransactionContext(io.camunda.zeebe.db.TransactionContext) Test(org.junit.Test)

Example 5 with TransactionContext

use of io.camunda.zeebe.db.TransactionContext in project zeebe by zeebe-io.

the class StreamProcessor method recoverState.

private ZeebeDbState recoverState() {
    final TransactionContext transactionContext = zeebeDb.createContext();
    final ZeebeDbState zeebeState = new ZeebeDbState(partitionId, zeebeDb, transactionContext);
    processingContext.transactionContext(transactionContext);
    processingContext.zeebeState(zeebeState);
    processingContext.eventApplier(eventApplierFactory.apply(zeebeState));
    return zeebeState;
}
Also used : TransactionContext(io.camunda.zeebe.db.TransactionContext) ZeebeDbState(io.camunda.zeebe.engine.state.ZeebeDbState)

Aggregations

TransactionContext (io.camunda.zeebe.db.TransactionContext)15 Test (org.junit.Test)12 RocksDBException (org.rocksdb.RocksDBException)12 Status (org.rocksdb.Status)12 ZeebeDbState (io.camunda.zeebe.engine.state.ZeebeDbState)3