@Test(timeout = 30_000) public void testLeaderElection() { Iterator<ClusterMembershipSnapshot> eventIterator = resolver.resolve().toIterable().iterator(); eventIterator.next(); memberResolver1.setAsLeader(MEMBER_1); Optional<ClusterMembershipRevision<ClusterMemberLeadership>> firstLeader = eventIterator.next().getLeaderRevision(); assertThat(firstLeader).isPresent(); assertThat(firstLeader.get().getCurrent().getMemberId()).isEqualTo(MEMBER_1.getCurrent().getMemberId()); memberResolver1.setAsLeader(MEMBER_2); Optional<ClusterMembershipRevision<ClusterMemberLeadership>> secondLeader = eventIterator.next().getLeaderRevision(); assertThat(secondLeader).isPresent(); assertThat(secondLeader.get().getCurrent().getMemberId()).isEqualTo(MEMBER_2.getCurrent().getMemberId()); }
@Override public Flux<ClusterMembershipSnapshot> resolve() { return snapshotEventObservable; }
MultiNodeClusterMemberResolver implements ClusterMemberResolver { @Override public Flux<ClusterMembershipSnapshot> resolve() { return snapshotEventObservable; } }
MultiNodeClusterMemberResolver implements ClusterMemberResolver { @Override public Flux<ClusterMembershipSnapshot> resolve() { return snapshotEventObservable; } MultiNodeClusterMemberResolver(String serviceName,
                                          ClusterMembershipResolverConfiguration configuration,
                                          Supplier<Set<ClusterMemberAddress>> seedAddressesProvider,
                                          Function<ClusterMemberAddress, DirectClusterMemberResolver> directResolverFactory,
                                          Function<ClusterMember, ClusterMemberAddress> addressSelector,
                                          TitusRuntime titusRuntime); }
MultiNodeClusterMemberResolver implements ClusterMemberResolver { @Override public Flux<ClusterMembershipSnapshot> resolve() { return snapshotEventObservable; } MultiNodeClusterMemberResolver(String serviceName,
                                          ClusterMembershipResolverConfiguration configuration,
                                          Supplier<Set<ClusterMemberAddress>> seedAddressesProvider,
                                          Function<ClusterMemberAddress, DirectClusterMemberResolver> directResolverFactory,
                                          Function<ClusterMember, ClusterMemberAddress> addressSelector,
                                          TitusRuntime titusRuntime); @Override void close(); @Override ClusterMembershipSnapshot getSnapshot(); @Override Flux<ClusterMembershipSnapshot> resolve(); }
MultiNodeClusterMemberResolver implements ClusterMemberResolver { @Override public Flux<ClusterMembershipSnapshot> resolve() { return snapshotEventObservable; } MultiNodeClusterMemberResolver(String serviceName,
                                          ClusterMembershipResolverConfiguration configuration,
                                          Supplier<Set<ClusterMemberAddress>> seedAddressesProvider,
                                          Function<ClusterMemberAddress, DirectClusterMemberResolver> directResolverFactory,
                                          Function<ClusterMember, ClusterMemberAddress> addressSelector,
                                          TitusRuntime titusRuntime); @Override void close(); @Override ClusterMembershipSnapshot getSnapshot(); @Override Flux<ClusterMembershipSnapshot> resolve();  }