use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ReplicatedLockTokenStateMachineTest method shouldSetInitialPendingRequestToInitialState.
@Test
public void shouldSetInitialPendingRequestToInitialState() throws Exception {
// Given
@SuppressWarnings("unchecked") StateStorage<ReplicatedLockTokenState> storage = mock(StateStorage.class);
MemberId initialHoldingCoreMember = member(0);
ReplicatedLockTokenState initialState = new ReplicatedLockTokenState(123, new ReplicatedLockTokenRequest(initialHoldingCoreMember, 3));
when(storage.getInitialState()).thenReturn(initialState);
// When
ReplicatedLockTokenStateMachine stateMachine = new ReplicatedLockTokenStateMachine(storage);
// Then
LockToken initialToken = stateMachine.currentToken();
assertEquals(initialState.get().owner(), initialToken.owner());
assertEquals(initialState.get().id(), initialToken.id());
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ReplicatedLockTokenStateMachineTest method shouldBeIdempotent.
@Test
public void shouldBeIdempotent() throws Exception {
// given
EphemeralFileSystemAbstraction fsa = fileSystemRule.get();
fsa.mkdir(testDir.directory());
StateMarshal<ReplicatedLockTokenState> marshal = new ReplicatedLockTokenState.Marshal(new MemberId.Marshal());
DurableStateStorage<ReplicatedLockTokenState> storage = new DurableStateStorage<>(fsa, testDir.directory(), "state", marshal, 100, NullLogProvider.getInstance());
try (Lifespan lifespan = new Lifespan(storage)) {
ReplicatedLockTokenStateMachine stateMachine = new ReplicatedLockTokenStateMachine(storage);
MemberId memberA = member(0);
MemberId memberB = member(1);
stateMachine.applyCommand(new ReplicatedLockTokenRequest(memberA, 0), 3, r -> {
});
// when
stateMachine.applyCommand(new ReplicatedLockTokenRequest(memberB, 1), 2, r -> {
});
// then
assertEquals(memberA, stateMachine.currentToken().owner());
}
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class CoreReplicatedContentMarshalTest method shouldMarshalMemberSet.
@Test
public void shouldMarshalMemberSet() throws Exception {
ByteBuf buffer = Unpooled.buffer();
ReplicatedContent message = new MemberIdSet(asSet(new MemberId(UUID.randomUUID()), new MemberId(UUID.randomUUID())));
assertMarshalingEquality(buffer, message);
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class VoteStateTest method shouldUpdateVote.
@Test
public void shouldUpdateVote() throws Exception {
// given
VoteState voteState = new VoteState();
MemberId member1 = new MemberId(UUID.randomUUID());
MemberId member2 = new MemberId(UUID.randomUUID());
// when
voteState.update(member1, 0);
voteState.update(member2, 1);
// then
assertEquals(member2, voteState.votedFor());
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class VoteStateTest method shouldStoreVote.
@Test
public void shouldStoreVote() throws Exception {
// given
VoteState voteState = new VoteState();
MemberId member = new MemberId(UUID.randomUUID());
// when
voteState.update(member, 0);
// then
assertEquals(member, voteState.votedFor());
}
Aggregations