use of org.neo4j.com.storecopy.TransactionCommittingResponseUnpacker.Dependencies in project neo4j by neo4j.
the class TransactionCommittingResponseUnpackerTest method shouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge.
/*
* Tests that we unfreeze active transactions after commit and after apply of batch if batch length (in time)
* is larger than safeZone time.
*/
@Test
public void shouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge() throws Throwable {
// GIVEN
int maxBatchSize = 10;
long idReuseSafeZoneTime = 100;
Dependencies dependencies = mock(Dependencies.class);
TransactionObligationFulfiller fulfiller = mock(TransactionObligationFulfiller.class);
when(dependencies.obligationFulfiller()).thenReturn(fulfiller);
when(dependencies.logService()).thenReturn(NullLogService.getInstance());
KernelTransactions kernelTransactions = mock(KernelTransactions.class);
when(dependencies.kernelTransactions()).thenReturn(kernelTransactions);
TransactionCommitProcess commitProcess = mock(TransactionCommitProcess.class);
when(dependencies.commitProcess()).thenReturn(commitProcess);
TransactionCommittingResponseUnpacker unpacker = life.add(new TransactionCommittingResponseUnpacker(dependencies, maxBatchSize, idReuseSafeZoneTime));
// WHEN
int txCount = maxBatchSize;
int doesNotMatter = 1;
unpacker.unpackResponse(new DummyTransactionResponse(doesNotMatter, txCount, idReuseSafeZoneTime + 1), NO_OP_TX_HANDLER);
// THEN
InOrder inOrder = inOrder(commitProcess, kernelTransactions);
inOrder.verify(commitProcess, times(1)).commit(any(), any(), any());
inOrder.verify(kernelTransactions, times(1)).unblockNewTransactions();
}
use of org.neo4j.com.storecopy.TransactionCommittingResponseUnpacker.Dependencies in project neo4j by neo4j.
the class TransactionCommittingResponseUnpackerTest method shouldAwaitTransactionObligationsToBeFulfilled.
@Test
public void shouldAwaitTransactionObligationsToBeFulfilled() throws Throwable {
// GIVEN
Dependencies dependencies = mock(Dependencies.class);
TransactionObligationFulfiller fulfiller = mock(TransactionObligationFulfiller.class);
when(dependencies.obligationFulfiller()).thenReturn(fulfiller);
when(dependencies.logService()).thenReturn(NullLogService.getInstance());
TransactionCommittingResponseUnpacker unpacker = life.add(new TransactionCommittingResponseUnpacker(dependencies, 10, 0));
// WHEN
unpacker.unpackResponse(new DummyObligationResponse(4), NO_OP_TX_HANDLER);
// THEN
verify(fulfiller, times(1)).fulfill(4L);
}
use of org.neo4j.com.storecopy.TransactionCommittingResponseUnpacker.Dependencies in project neo4j by neo4j.
the class MasterClientTest method clientShouldReadAndApplyTransactionLogsOnNewLockSessionRequest.
@Test
public void clientShouldReadAndApplyTransactionLogsOnNewLockSessionRequest() throws Throwable {
// Given
MasterImpl master = spy(newMasterImpl(mockMasterImplSpiWith(StoreId.DEFAULT)));
doReturn(voidResponseWithTransactionLogs()).when(master).newLockSession(any(RequestContext.class));
newMasterServer(master);
Dependencies deps = mock(Dependencies.class);
TransactionCommitProcess commitProcess = mock(TransactionCommitProcess.class);
when(deps.commitProcess()).thenReturn(commitProcess);
when(deps.logService()).thenReturn(NullLogService.getInstance());
when(deps.kernelTransactions()).thenReturn(mock(KernelTransactions.class));
ResponseUnpacker unpacker = life.add(new TransactionCommittingResponseUnpacker(deps, DEFAULT_BATCH_SIZE, 0));
MasterClient masterClient = newMasterClient320(StoreId.DEFAULT, unpacker);
// When
masterClient.newLockSession(new RequestContext(1, 2, 3, 4, 5));
// Then
verify(commitProcess).commit(any(TransactionToApply.class), any(CommitEvent.class), any(TransactionApplicationMode.class));
}
use of org.neo4j.com.storecopy.TransactionCommittingResponseUnpacker.Dependencies in project neo4j by neo4j.
the class TransactionCommittingResponseUnpackerTest method shouldCommitTransactionsInBatches.
@Test
public void shouldCommitTransactionsInBatches() throws Exception {
// GIVEN
Dependencies dependencies = mock(Dependencies.class);
TransactionCountingTransactionCommitProcess commitProcess = new TransactionCountingTransactionCommitProcess();
when(dependencies.commitProcess()).thenReturn(commitProcess);
when(dependencies.logService()).thenReturn(NullLogService.getInstance());
KernelTransactions kernelTransactions = mock(KernelTransactions.class);
when(dependencies.kernelTransactions()).thenReturn(kernelTransactions);
TransactionCommittingResponseUnpacker unpacker = life.add(new TransactionCommittingResponseUnpacker(dependencies, 5, 0));
// WHEN
unpacker.unpackResponse(new DummyTransactionResponse(BASE_TX_ID + 1, 7), NO_OP_TX_HANDLER);
// THEN
commitProcess.assertBatchSize(5);
commitProcess.assertBatchSize(2);
commitProcess.assertNoMoreBatches();
}
Aggregations