use of org.neo4j.com.RequestContext in project neo4j by neo4j.
the class MasterClient214 method commit.
@Override
public Response<Long> commit(RequestContext context, TransactionRepresentation tx) {
Serializer serializer = new Protocol.TransactionSerializer(tx);
Deserializer<Long> deserializer = (buffer, temporaryBuffer) -> buffer.readLong();
return sendRequest(requestTypes.type(HaRequestTypes.Type.COMMIT), context, serializer, deserializer);
}
use of org.neo4j.com.RequestContext in project neo4j by neo4j.
the class SlaveTransactionCommitProcess method commit.
@Override
public long commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode) throws TransactionFailureException {
if (batch.next() != null) {
throw new IllegalArgumentException("Only supports single-commit on slave --> master");
}
try {
TransactionRepresentation representation = batch.transactionRepresentation();
RequestContext context = requestContextFactory.newRequestContext(representation.getLockSessionId());
try (Response<Long> response = master.commit(context, representation)) {
return response.response();
}
} catch (IOException e) {
throw new TransactionFailureException(Status.Transaction.TransactionCommitFailed, e, "Could not commit transaction on the master");
} catch (ComException e) {
throw new TransientTransactionFailureException("Cannot commit this transaction on the master. " + "The master is either down, or we have network connectivity problems.", e);
}
}
use of org.neo4j.com.RequestContext in project neo4j by neo4j.
the class SlaveUpdatePullerTest method setUp.
@Before
public void setUp() throws Throwable {
when(requestContextFactory.newRequestContext()).thenReturn(new RequestContext(42, 42, 42, 42, 42));
when(config.get(HaSettings.pull_interval)).thenReturn(1000L);
when(config.get(ClusterSettings.server_id)).thenReturn(instanceId);
when(availabilityGuard.isAvailable(anyLong())).thenReturn(true);
jobScheduler.init();
jobScheduler.start();
updatePuller.start();
}
use of org.neo4j.com.RequestContext in project neo4j by neo4j.
the class ConversationManagerTest method testConversationWorkflow.
@Test
public void testConversationWorkflow() throws Exception {
JobScheduler.JobHandle reaperJobHandle = mock(JobScheduler.JobHandle.class);
when(config.get(HaSettings.lock_read_timeout)).thenReturn(1L);
when(conversationSPI.scheduleRecurringJob(any(JobScheduler.Group.class), any(Long.class), any(Runnable.class))).thenReturn(reaperJobHandle);
RequestContext requestContext = getRequestContext();
conversationManager = getConversationManager();
TimedRepository conversationStorage = mock(TimedRepository.class);
conversationManager.conversations = conversationStorage;
conversationManager.begin(requestContext);
conversationManager.acquire(requestContext);
conversationManager.release(requestContext);
conversationManager.end(requestContext);
InOrder conversationOrder = inOrder(conversationStorage);
conversationOrder.verify(conversationStorage).begin(requestContext);
conversationOrder.verify(conversationStorage).acquire(requestContext);
conversationOrder.verify(conversationStorage).release(requestContext);
conversationOrder.verify(conversationStorage).end(requestContext);
}
use of org.neo4j.com.RequestContext in project neo4j by neo4j.
the class ConversationManagerTest method testConversationStop.
@Test
public void testConversationStop() {
RequestContext requestContext = getRequestContext();
conversationManager = getConversationManager();
Conversation conversation = mock(Conversation.class);
when(conversation.isActive()).thenReturn(true);
TimedRepository conversationStorage = mock(TimedRepository.class);
when(conversationStorage.end(requestContext)).thenReturn(conversation);
conversationManager.conversations = conversationStorage;
conversationManager.stop(requestContext);
verify(conversationStorage).end(requestContext);
verify(conversation).stop();
}
Aggregations