Search in sources :

Example 91 with MemberId

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

the class RaftLogShippingManager method resume.

/**
     * Resumed when becoming leader.
     */
public synchronized void resume(LeaderContext initialLeaderContext) {
    if (stopped) {
        return;
    }
    running = true;
    for (MemberId member : membership.replicationMembers()) {
        ensureLogShipperRunning(member, initialLeaderContext);
    }
    lastLeaderContext = initialLeaderContext;
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId)

Example 92 with MemberId

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

the class MemberIdSetSerializer method marshal.

public static void marshal(MemberIdSet memberSet, WritableChannel channel) throws IOException {
    Set<MemberId> members = memberSet.getMembers();
    channel.putInt(members.size());
    MemberId.Marshal memberIdMarshal = new MemberId.Marshal();
    for (MemberId member : members) {
        memberIdMarshal.marshal(member, channel);
    }
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId)

Example 93 with MemberId

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

the class CoreTopologyTest method shouldDetectRemovedMembers.

@Test
public void shouldDetectRemovedMembers() throws Exception {
    // given
    UUID one = UUID.randomUUID();
    UUID two = UUID.randomUUID();
    Map<MemberId, CoreServerInfo> initialMembers = new HashMap<>();
    initialMembers.put(new MemberId(one), mock(CoreServerInfo.class));
    initialMembers.put(new MemberId(two), mock(CoreServerInfo.class));
    Map<MemberId, CoreServerInfo> newMembers = new HashMap<>();
    newMembers.put(new MemberId(two), mock(CoreServerInfo.class));
    CoreTopology topology = new CoreTopology(new ClusterId(UUID.randomUUID()), true, initialMembers);
    // when
    TopologyDifference diff = topology.difference(new CoreTopology(new ClusterId(UUID.randomUUID()), true, newMembers));
    // then
    assertThat(diff.added().size(), Matchers.equalTo(0));
    assertThat(diff.removed().size(), Matchers.equalTo(1));
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) HashMap(java.util.HashMap) ClusterId(org.neo4j.causalclustering.identity.ClusterId) UUID(java.util.UUID) Test(org.junit.Test)

Example 94 with MemberId

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

the class CoreTopologyTest method shouldDetectAddedMembers.

@Test
public void shouldDetectAddedMembers() throws Exception {
    // given
    UUID one = UUID.randomUUID();
    UUID two = UUID.randomUUID();
    Map<MemberId, CoreServerInfo> initialMembers = new HashMap<>();
    initialMembers.put(new MemberId(one), mock(CoreServerInfo.class));
    initialMembers.put(new MemberId(two), mock(CoreServerInfo.class));
    Map<MemberId, CoreServerInfo> newMembers = new HashMap<>();
    newMembers.put(new MemberId(one), mock(CoreServerInfo.class));
    newMembers.put(new MemberId(two), mock(CoreServerInfo.class));
    newMembers.put(new MemberId(UUID.randomUUID()), mock(CoreServerInfo.class));
    CoreTopology topology = new CoreTopology(new ClusterId(UUID.randomUUID()), true, initialMembers);
    // when
    TopologyDifference diff = topology.difference(new CoreTopology(new ClusterId(UUID.randomUUID()), true, newMembers));
    // then
    assertThat(diff.added().size(), Matchers.equalTo(1));
    assertThat(diff.removed().size(), Matchers.equalTo(0));
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) HashMap(java.util.HashMap) ClusterId(org.neo4j.causalclustering.identity.ClusterId) UUID(java.util.UUID) Test(org.junit.Test)

Example 95 with MemberId

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

the class HazelcastClusterTopologyTest method shouldCollectMembersAsAMap.

@Test
public void shouldCollectMembersAsAMap() throws Exception {
    // given
    Set<Member> hazelcastMembers = new HashSet<>();
    List<MemberId> coreMembers = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        MemberId memberId = new MemberId(UUID.randomUUID());
        coreMembers.add(memberId);
        Config config = Config.defaults();
        HashMap<String, String> settings = new HashMap<>();
        settings.put(CausalClusteringSettings.transaction_advertised_address.name(), "tx:" + (i + 1));
        settings.put(CausalClusteringSettings.raft_advertised_address.name(), "raft:" + (i + 1));
        settings.put(new BoltConnector("bolt").type.name(), "BOLT");
        settings.put(new BoltConnector("bolt").enabled.name(), "true");
        settings.put(new BoltConnector("bolt").advertised_address.name(), "bolt:" + (i + 1));
        settings.put(new BoltConnector("http").type.name(), "HTTP");
        settings.put(new BoltConnector("http").enabled.name(), "true");
        settings.put(new BoltConnector("http").advertised_address.name(), "http:" + (i + 1));
        config.augment(settings);
        Map<String, Object> attributes = buildMemberAttributesForCore(memberId, config).getAttributes();
        hazelcastMembers.add(new MemberImpl(new Address("localhost", i), null, attributes, false));
    }
    // when
    Map<MemberId, CoreServerInfo> coreMemberMap = toCoreMemberMap(hazelcastMembers, NullLog.getInstance(), hzInstance);
    // then
    for (int i = 0; i < 5; i++) {
        CoreServerInfo coreServerInfo = coreMemberMap.get(coreMembers.get(i));
        assertEquals(new AdvertisedSocketAddress("tx", i + 1), coreServerInfo.getCatchupServer());
        assertEquals(new AdvertisedSocketAddress("raft", i + 1), coreServerInfo.getRaftServer());
        assertEquals(new AdvertisedSocketAddress("bolt", i + 1), coreServerInfo.connectors().boltAddress());
        assertEquals(coreServerInfo.groups(), GROUPS);
    }
}
Also used : Address(com.hazelcast.nio.Address) AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) HashMap(java.util.HashMap) BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Config(org.neo4j.kernel.configuration.Config) MemberImpl(com.hazelcast.client.impl.MemberImpl) ArrayList(java.util.ArrayList) AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) Matchers.anyString(org.mockito.Matchers.anyString) MemberId(org.neo4j.causalclustering.identity.MemberId) Member(com.hazelcast.core.Member) HashSet(java.util.HashSet) 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