Search in sources :

Example 11 with MemberId

use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.

the class RaftMessageProcessingTest method shouldEncodeAndDecodeVoteResponse.

@Test
public void shouldEncodeAndDecodeVoteResponse() {
    // given
    MemberId member = new MemberId(UUID.randomUUID());
    RaftMessages.Vote.Response response = new RaftMessages.Vote.Response(member, 1, true);
    // when
    channel.writeOutbound(response);
    channel.writeInbound(new Object[] { channel.readOutbound() });
    // then
    assertEquals(response, channel.readInbound());
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) RaftMessages(org.neo4j.causalclustering.core.consensus.RaftMessages) Test(org.junit.Test)

Example 12 with MemberId

use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.

the class RaftMessageProcessingTest method shouldEncodeAndDecodeNewEntryRequest.

@Test
public void shouldEncodeAndDecodeNewEntryRequest() {
    // given
    MemberId member = new MemberId(UUID.randomUUID());
    RaftMessages.NewEntry.Request request = new RaftMessages.NewEntry.Request(member, ReplicatedInteger.valueOf(12));
    // when
    channel.writeOutbound(request);
    channel.writeInbound(new Object[] { channel.readOutbound() });
    // then
    assertEquals(request, channel.readInbound());
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) RaftMessages(org.neo4j.causalclustering.core.consensus.RaftMessages) Test(org.junit.Test)

Example 13 with MemberId

use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.

the class UnknownAddressMonitorTest method shouldResumeLoggingAfterQuietPeriod.

@Test
public void shouldResumeLoggingAfterQuietPeriod() throws Exception {
    // given
    Log log = mock(Log.class);
    FakeClock clock = testClock();
    UnknownAddressMonitor logger = new UnknownAddressMonitor(log, clock, 1000);
    MemberId to = member(0);
    // when
    logger.logAttemptToSendToMemberWithNoKnownAddress(to);
    clock.forward(20001, MILLISECONDS);
    logger.logAttemptToSendToMemberWithNoKnownAddress(to);
    clock.forward(80001, MILLISECONDS);
    logger.logAttemptToSendToMemberWithNoKnownAddress(to);
    // then
    verify(log, times(3)).info(format("No address found for %s, probably because the member has been shut " + "down.", to));
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) Log(org.neo4j.logging.Log) FakeClock(org.neo4j.time.FakeClock) Test(org.junit.Test)

Example 14 with MemberId

use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.

the class UnknownAddressMonitorTest method shouldThrottleLogging.

@Test
public void shouldThrottleLogging() throws Exception {
    // given
    Log log = mock(Log.class);
    FakeClock clock = testClock();
    UnknownAddressMonitor logger = new UnknownAddressMonitor(log, clock, 1000);
    MemberId to = member(0);
    // when
    logger.logAttemptToSendToMemberWithNoKnownAddress(to);
    clock.forward(1, MILLISECONDS);
    logger.logAttemptToSendToMemberWithNoKnownAddress(to);
    // then
    verify(log, times(1)).info(format("No address found for %s, probably because the member has been shut " + "down.", to));
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) Log(org.neo4j.logging.Log) FakeClock(org.neo4j.time.FakeClock) Test(org.junit.Test)

Example 15 with MemberId

use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.

the class RaftMessageEncodingDecodingTest method shouldSerializeVoteRequest.

@Test
public void shouldSerializeVoteRequest() throws Exception {
    MemberId sender = new MemberId(UUID.randomUUID());
    RaftMessages.Vote.Request request = new VoteRequestBuilder().candidate(sender).from(sender).lastLogIndex(2).lastLogTerm(1).term(3).build();
    serializeReadBackAndVerifyMessage(request);
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) VoteRequestBuilder(org.neo4j.causalclustering.core.consensus.vote.VoteRequestBuilder) Test(org.junit.Test)

Aggregations

MemberId (org.neo4j.causalclustering.identity.MemberId)114 Test (org.junit.Test)83 HashMap (java.util.HashMap)26 CoreTopology (org.neo4j.causalclustering.discovery.CoreTopology)16 CoreServerInfo (org.neo4j.causalclustering.discovery.CoreServerInfo)15 LeaderLocator (org.neo4j.causalclustering.core.consensus.LeaderLocator)13 ReadReplicaTopology (org.neo4j.causalclustering.discovery.ReadReplicaTopology)12 DirectNetworking (org.neo4j.causalclustering.core.consensus.DirectNetworking)10 RaftTestFixture (org.neo4j.causalclustering.core.consensus.RaftTestFixture)10 CoreTopologyService (org.neo4j.causalclustering.discovery.CoreTopologyService)10 Log (org.neo4j.logging.Log)10 ClusterId (org.neo4j.causalclustering.identity.ClusterId)9 ArrayList (java.util.ArrayList)8 UUID (java.util.UUID)8 RaftMessages (org.neo4j.causalclustering.core.consensus.RaftMessages)8 TopologyService (org.neo4j.causalclustering.discovery.TopologyService)7 ByteBuf (io.netty.buffer.ByteBuf)6 File (java.io.File)6 RaftLogEntry (org.neo4j.causalclustering.core.consensus.log.RaftLogEntry)6 HashSet (java.util.HashSet)5