use of org.neo4j.causalclustering.core.state.machines.locks.ReplicatedLockTokenRequest in project neo4j by neo4j.
the class CommitProcessStateMachineCollaborationTest method lockState.
private ReplicatedLockTokenStateMachine lockState(int lockSessionId) {
ReplicatedLockTokenStateMachine lockState = mock(ReplicatedLockTokenStateMachine.class);
when(lockState.currentToken()).thenReturn(new ReplicatedLockTokenRequest(null, lockSessionId));
return lockState;
}
use of org.neo4j.causalclustering.core.state.machines.locks.ReplicatedLockTokenRequest in project neo4j by neo4j.
the class SegmentedRaftLogPartialEntryRecoveryTest method incompleteEntriesAtTheEndShouldNotCauseFailures.
@Test
public void incompleteEntriesAtTheEndShouldNotCauseFailures() throws Throwable {
// Given
// we use a RaftLog to create a raft log file and then we will start chopping bits off from the end
SegmentedRaftLog raftLog = createRaftLog(100_000);
raftLog.start();
// Add a bunch of entries, preferably one of each available kind.
raftLog.append(new RaftLogEntry(4, new NewLeaderBarrier()));
raftLog.append(new RaftLogEntry(4, new ReplicatedIdAllocationRequest(new MemberId(UUID.randomUUID()), IdType.RELATIONSHIP, 1, 1024)));
raftLog.append(new RaftLogEntry(4, new ReplicatedIdAllocationRequest(new MemberId(UUID.randomUUID()), IdType.RELATIONSHIP, 1025, 1024)));
raftLog.append(new RaftLogEntry(4, new ReplicatedLockTokenRequest(new MemberId(UUID.randomUUID()), 1)));
raftLog.append(new RaftLogEntry(4, new NewLeaderBarrier()));
raftLog.append(new RaftLogEntry(5, new ReplicatedTokenRequest(TokenType.LABEL, "labelToken", new byte[] { 1, 2, 3 })));
raftLog.append(new RaftLogEntry(5, new ReplicatedTransaction(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 })));
raftLog.stop();
// We use a temporary RecoveryProtocol to get the file to chop
RecoveryProtocol recovery = createRecoveryProtocol();
State recoveryState = recovery.run();
String logFilename = recoveryState.segments.last().getFilename();
File logFile = new File(logDirectory, logFilename);
// When
// We remove any number of bytes from the end (up to but not including the header) and try to recover
// Then
// No exceptions should be thrown
truncateAndRecover(logFile, SegmentHeader.SIZE);
}
use of org.neo4j.causalclustering.core.state.machines.locks.ReplicatedLockTokenRequest in project neo4j by neo4j.
the class ReplicatedTransactionStateMachineTest method lockState.
private ReplicatedLockTokenStateMachine lockState(int lockSessionId) {
@SuppressWarnings("unchecked") ReplicatedLockTokenStateMachine lockState = mock(ReplicatedLockTokenStateMachine.class);
when(lockState.currentToken()).thenReturn(new ReplicatedLockTokenRequest(null, lockSessionId));
return lockState;
}
Aggregations