use of org.neo4j.com.TransactionObligationResponse in project neo4j by neo4j.
the class SlaveLocksClientTest method shouldIncludeReasonForNotLocked.
@Test
public void shouldIncludeReasonForNotLocked() throws Exception {
// GIVEN
SlaveLocksClient client = newSlaveLocksClient(lockManager);
LockResult lockResult = new LockResult(LockStatus.NOT_LOCKED, "Simply not locked");
Response<LockResult> response = new TransactionObligationResponse<>(lockResult, DEFAULT, 2, NO_OP);
long nodeId = 0;
ResourceTypes resourceType = NODE;
when(master.acquireExclusiveLock(any(RequestContext.class), eq(resourceType), anyLong())).thenReturn(response);
// WHEN
try {
client.acquireExclusive(LockTracer.NONE, resourceType, nodeId);
fail("Should have failed");
} catch (UnsupportedOperationException e) {
// THEN
assertThat(e.getMessage(), containsString(lockResult.getMessage()));
assertThat(e.getMessage(), containsString(lockResult.getStatus().name()));
}
}
use of org.neo4j.com.TransactionObligationResponse in project neo4j by neo4j.
the class ResponsePackerIT method shouldPackTheHighestTxCommittedAsObligation.
@Test
public void shouldPackTheHighestTxCommittedAsObligation() throws Exception {
// GIVEN
LogicalTransactionStore transactionStore = mock(LogicalTransactionStore.class);
FileSystemAbstraction fs = fsRule.get();
PageCache pageCache = pageCacheRule.getPageCache(fs);
try (NeoStores neoStore = createNeoStore(fs, pageCache)) {
MetaDataStore store = neoStore.getMetaDataStore();
store.transactionCommitted(2, 111, BASE_TX_COMMIT_TIMESTAMP);
store.transactionCommitted(3, 222, BASE_TX_COMMIT_TIMESTAMP);
store.transactionCommitted(4, 333, BASE_TX_COMMIT_TIMESTAMP);
store.transactionCommitted(5, 444, BASE_TX_COMMIT_TIMESTAMP);
store.transactionCommitted(6, 555, BASE_TX_COMMIT_TIMESTAMP);
// skip 7 to emulate the fact we have an hole in the committed tx ids list
final long expectedTxId = 8L;
store.transactionCommitted(expectedTxId, 777, BASE_TX_COMMIT_TIMESTAMP);
ResponsePacker packer = new ResponsePacker(transactionStore, store, Suppliers.singleton(newStoreIdForCurrentVersion()));
// WHEN
Response<Object> response = packer.packTransactionObligationResponse(new RequestContext(0, 0, 0, 0, 0), new Object());
// THEN
assertTrue(response instanceof TransactionObligationResponse);
((TransactionObligationResponse) response).accept(new Response.Handler() {
@Override
public void obligation(long txId) throws IOException {
assertEquals(expectedTxId, txId);
}
@Override
public Visitor<CommittedTransactionRepresentation, Exception> transactions() {
throw new UnsupportedOperationException("not expected");
}
});
}
}
Aggregations