use of org.neo4j.kernel.ha.com.master.MasterImpl in project neo4j by neo4j.
the class MasterEpochTest method shouldFailSubsequentRequestsAfterAllocateIdsAfterMasterSwitch.
@Test
public void shouldFailSubsequentRequestsAfterAllocateIdsAfterMasterSwitch() throws Throwable {
// GIVEN
SPI spi = MasterImplTest.mockedSpi();
IdAllocation servedIdAllocation = idAllocation(0, 999);
when(spi.allocateIds(any(IdType.class))).thenReturn(servedIdAllocation);
when(spi.getTransactionChecksum(anyLong())).thenReturn(10L);
StoreId storeId = newStoreIdForCurrentVersion();
MasterImpl master = new MasterImpl(spi, mock(ConversationManager.class), mock(MasterImpl.Monitor.class), Config.embeddedDefaults(stringMap(ClusterSettings.server_id.name(), "1")));
HandshakeResult handshake = master.handshake(1, storeId).response();
master.start();
// WHEN/THEN
IdAllocation idAllocation = master.allocateIds(context(handshake.epoch()), IdType.NODE).response();
assertEquals(servedIdAllocation.getHighestIdInUse(), idAllocation.getHighestIdInUse());
try {
master.allocateIds(context(handshake.epoch() + 1), IdType.NODE);
fail("Should fail with invalid epoch");
} catch (InvalidEpochException e) {
// Good
}
}
use of org.neo4j.kernel.ha.com.master.MasterImpl 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));
}
Aggregations