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;
}
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);
}
}
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));
}
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));
}
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);
}
}
Aggregations