Search in sources :

Example 1 with MemberIdSet

use of org.neo4j.causalclustering.core.consensus.membership.MemberIdSet in project neo4j by neo4j.

the class RaftContentByteBufferMarshalTest method shouldSerializeMemberSet.

@Test
public void shouldSerializeMemberSet() throws Exception {
    // given
    CoreReplicatedContentMarshal serializer = new CoreReplicatedContentMarshal();
    MemberIdSet in = new MemberIdSet(asSet(new MemberId(UUID.randomUUID()), new MemberId(UUID.randomUUID())));
    // when
    ByteBuf buf = Unpooled.buffer();
    assertMarshalingEquality(serializer, buf, in);
}
Also used : CoreReplicatedContentMarshal(org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal) MemberId(org.neo4j.causalclustering.identity.MemberId) MemberIdSet(org.neo4j.causalclustering.core.consensus.membership.MemberIdSet) ByteBuf(io.netty.buffer.ByteBuf) NetworkFlushableByteBuf(org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf) Test(org.junit.Test)

Example 2 with MemberIdSet

use of org.neo4j.causalclustering.core.consensus.membership.MemberIdSet in project neo4j by neo4j.

the class RaftMachineTest method shouldPersistAtSpecifiedLogIndex.

@Test
public void shouldPersistAtSpecifiedLogIndex() throws Exception {
    // given
    FakeClock fakeClock = Clocks.fakeClock();
    ControlledRenewableTimeoutService timeouts = new ControlledRenewableTimeoutService(fakeClock);
    RaftMachine raft = new RaftMachineBuilder(myself, 3, RaftTestMemberSetBuilder.INSTANCE).timeoutService(timeouts).clock(fakeClock).raftLog(raftLog).build();
    raftLog.append(new RaftLogEntry(0, new MemberIdSet(asSet(myself, member1, member2))));
    // when
    raft.handle(appendEntriesRequest().from(member1).prevLogIndex(0).prevLogTerm(0).leaderTerm(0).logEntry(new RaftLogEntry(0, data1)).build());
    // then
    assertEquals(1, raftLog.appendIndex());
    assertEquals(data1, readLogEntry(raftLog, 1).content());
}
Also used : FakeClock(org.neo4j.time.FakeClock) MemberIdSet(org.neo4j.causalclustering.core.consensus.membership.MemberIdSet) ControlledRenewableTimeoutService(org.neo4j.causalclustering.core.consensus.schedule.ControlledRenewableTimeoutService) RaftLogEntry(org.neo4j.causalclustering.core.consensus.log.RaftLogEntry) Test(org.junit.Test)

Example 3 with MemberIdSet

use of org.neo4j.causalclustering.core.consensus.membership.MemberIdSet in project neo4j by neo4j.

the class RaftTestFixture method bootstrap.

public void bootstrap(MemberId[] members) throws RaftMachine.BootstrapException, IOException {
    for (MemberFixture member : members()) {
        member.raftLog().append(new RaftLogEntry(0, new MemberIdSet(asSet(members))));
        member.raftInstance().installCoreState(new RaftCoreState(new MembershipEntry(0, asSet(members))));
        member.raftInstance().startTimers();
    }
}
Also used : MembershipEntry(org.neo4j.causalclustering.core.consensus.membership.MembershipEntry) RaftCoreState(org.neo4j.causalclustering.core.state.snapshot.RaftCoreState) MemberIdSet(org.neo4j.causalclustering.core.consensus.membership.MemberIdSet) RaftLogEntry(org.neo4j.causalclustering.core.consensus.log.RaftLogEntry)

Example 4 with MemberIdSet

use of org.neo4j.causalclustering.core.consensus.membership.MemberIdSet in project neo4j by neo4j.

the class Fixture method boot.

void boot() throws BootstrapException, TimeoutException, InterruptedException, IOException {
    for (RaftFixture raft : rafts) {
        raft.raftLog().append(new RaftLogEntry(0, new MemberIdSet(asSet(members))));
        raft.raftMachine().installCoreState(new RaftCoreState(new MembershipEntry(0, members)));
        raft.raftMachine.startTimers();
    }
    net.start();
    awaitBootstrapped();
}
Also used : MembershipEntry(org.neo4j.causalclustering.core.consensus.membership.MembershipEntry) RaftCoreState(org.neo4j.causalclustering.core.state.snapshot.RaftCoreState) MemberIdSet(org.neo4j.causalclustering.core.consensus.membership.MemberIdSet) RaftLogEntry(org.neo4j.causalclustering.core.consensus.log.RaftLogEntry)

Example 5 with MemberIdSet

use of org.neo4j.causalclustering.core.consensus.membership.MemberIdSet 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);
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) MemberIdSet(org.neo4j.causalclustering.core.consensus.membership.MemberIdSet) ByteBuf(io.netty.buffer.ByteBuf) NetworkFlushableByteBuf(org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf) Test(org.junit.Test)

Aggregations

MemberIdSet (org.neo4j.causalclustering.core.consensus.membership.MemberIdSet)5 Test (org.junit.Test)3 RaftLogEntry (org.neo4j.causalclustering.core.consensus.log.RaftLogEntry)3 ByteBuf (io.netty.buffer.ByteBuf)2 MembershipEntry (org.neo4j.causalclustering.core.consensus.membership.MembershipEntry)2 RaftCoreState (org.neo4j.causalclustering.core.state.snapshot.RaftCoreState)2 MemberId (org.neo4j.causalclustering.identity.MemberId)2 NetworkFlushableByteBuf (org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf)2 ControlledRenewableTimeoutService (org.neo4j.causalclustering.core.consensus.schedule.ControlledRenewableTimeoutService)1 CoreReplicatedContentMarshal (org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal)1 FakeClock (org.neo4j.time.FakeClock)1