use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ElectionPerformanceIT method electionPerformance_NormalConditions.
@Test
public void electionPerformance_NormalConditions() throws Throwable {
/* This test runs with with few iterations. Hence it does not have the power to catch
* regressions efficiently. Its purpose is mainly to run elections using real-world
* parameters and catch very obvious regressions while not contributing overly much to the
* regression test suites total runtime. */
// given parameters
final long networkLatency = 15L;
final long electionTimeout = 500L;
final long heartbeatInterval = 250L;
final int iterations = 10;
TestNetwork net = new TestNetwork<>((i, o) -> networkLatency);
Set<MemberId> members = asSet(member(0), member(1), member(2));
Fixture fixture = new Fixture(members, net, electionTimeout, heartbeatInterval);
DisconnectLeaderScenario scenario = new DisconnectLeaderScenario(fixture, electionTimeout);
try {
// when running scenario
fixture.boot();
scenario.run(iterations, 10 * electionTimeout);
} finally {
fixture.tearDown();
}
DisconnectLeaderScenario.Result result = scenario.result();
/* These bounds have been experimentally established and should have a very low
* likelihood for false positives without an actual major regression. If this test fails
* then the recommended action is to run the test manually and interpret the results
* to guide further action. Perhaps the power of the test has to be improved, but
* the intention here is not to catch anything but the most major of regressions. */
assertThat(result.nonCollidingAverage, lessThan(2.0 * electionTimeout));
if (result.collisionCount > 3) {
assertThat(result.collidingAverage, lessThan(6.0 * electionTimeout));
}
assertThat(result.timeoutCount, is(0L));
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ElectionUtil method waitForLeaderAgreement.
public static MemberId waitForLeaderAgreement(Iterable<RaftMachine> validRafts, long maxTimeMillis) throws InterruptedException, TimeoutException {
long viewCount = Iterables.count(validRafts);
Map<MemberId, MemberId> leaderViews = new HashMap<>();
CompletableFuture<MemberId> futureAgreedLeader = new CompletableFuture<>();
Collection<Runnable> destructors = new ArrayList<>();
for (RaftMachine raft : validRafts) {
destructors.add(leaderViewUpdatingListener(raft, validRafts, leaderViews, viewCount, futureAgreedLeader));
}
try {
try {
return futureAgreedLeader.get(maxTimeMillis, TimeUnit.MILLISECONDS);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
} finally {
destructors.forEach(Runnable::run);
}
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ClusterState method toString.
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
for (MemberId member : roles.keySet()) {
builder.append(member).append(" : ").append(roles.get(member)).append("\n");
builder.append(" state: ").append(states.get(member)).append("\n");
builder.append(" queue: ").append(queues.get(member)).append("\n");
}
return builder.toString();
}
use of org.neo4j.causalclustering.identity.MemberId 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);
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class HazelcastClusterTopology method readReplicas.
private static Map<MemberId, ReadReplicaInfo> readReplicas(HazelcastInstance hazelcastInstance) {
IMap<String, String> /*boltAddress*/
clientAddressMap = hazelcastInstance.getMap(READ_REPLICA_BOLT_ADDRESS_MAP_NAME);
IMap<String, String> txServerMap = hazelcastInstance.getMap(READ_REPLICA_TRANSACTION_SERVER_ADDRESS_MAP_NAME);
IMap<String, String> memberIdMap = hazelcastInstance.getMap(READ_REPLICA_MEMBER_ID_MAP_NAME);
MultiMap<String, String> serverGroups = hazelcastInstance.getMultiMap(SERVER_GROUPS_MULTIMAP_NAME);
Map<MemberId, ReadReplicaInfo> result = new HashMap<>();
for (String hzUUID : clientAddressMap.keySet()) {
ClientConnectorAddresses clientConnectorAddresses = ClientConnectorAddresses.fromString(clientAddressMap.get(hzUUID));
AdvertisedSocketAddress catchupAddress = socketAddress(txServerMap.get(hzUUID), AdvertisedSocketAddress::new);
result.put(new MemberId(UUID.fromString(memberIdMap.get(hzUUID))), new ReadReplicaInfo(clientConnectorAddresses, catchupAddress, asSet(serverGroups.get(hzUUID))));
}
return result;
}
Aggregations