use of org.neo4j.com.TransactionNotPresentOnMasterException in project neo4j by neo4j.
the class MasterImplTest method shouldNotAllowCommitIfThereIsNoMatchingLockSession.
@Test
public void shouldNotAllowCommitIfThereIsNoMatchingLockSession() throws Throwable {
// Given
MasterImpl.SPI spi = mock(MasterImpl.SPI.class);
DefaultConversationSPI conversationSpi = mockedConversationSpi();
Config config = config();
ConversationManager conversationManager = new ConversationManager(conversationSpi, config);
when(spi.isAccessible()).thenReturn(true);
when(spi.getTransactionChecksum(anyLong())).thenReturn(1L);
mockEmptyResponse(spi);
MasterImpl master = new MasterImpl(spi, conversationManager, mock(MasterImpl.Monitor.class), config);
master.start();
HandshakeResult handshake = master.handshake(1, newStoreIdForCurrentVersion()).response();
RequestContext ctx = new RequestContext(handshake.epoch(), 1, 2, 0, 0);
// When
try {
master.commit(ctx, mock(TransactionRepresentation.class));
fail("Should have failed.");
} catch (TransactionNotPresentOnMasterException e) {
// Then
assertThat(e.getMessage(), equalTo(new TransactionNotPresentOnMasterException(ctx).getMessage()));
}
}
use of org.neo4j.com.TransactionNotPresentOnMasterException in project neo4j by neo4j.
the class MasterImpl method commit.
@Override
public Response<Long> commit(RequestContext context, TransactionRepresentation preparedTransaction) throws IOException, org.neo4j.kernel.api.exceptions.TransactionFailureException {
assertCorrectEpoch(context);
if (context.getEventIdentifier() == Locks.Client.NO_LOCK_SESSION_ID) {
// Client is not holding locks, use a temporary lock client
try (Conversation conversation = conversationManager.acquire()) {
return commit0(context, preparedTransaction, conversation.getLocks());
}
} else {
// Client is holding locks, use the clients lock session
try {
Conversation conversation = conversationManager.acquire(context);
Locks.Client locks = conversation.getLocks();
try {
return commit0(context, preparedTransaction, locks);
} finally {
conversationManager.release(context);
}
} catch (NoSuchEntryException | ConcurrentAccessException e) {
throw new TransactionNotPresentOnMasterException(context);
}
}
}
Aggregations