use of akka.cluster.ClusterEvent.CurrentClusterState in project controller by opendaylight.
the class IntegrationTestKit method waitForMembersUp.
public void waitForMembersUp(final String... otherMembers) {
Set<String> otherMembersSet = Sets.newHashSet(otherMembers);
Stopwatch sw = Stopwatch.createStarted();
while (sw.elapsed(TimeUnit.SECONDS) <= 10) {
CurrentClusterState state = Cluster.get(getSystem()).state();
for (Member m : state.getMembers()) {
if (m.status() == MemberStatus.up() && otherMembersSet.remove(m.getRoles().iterator().next()) && otherMembersSet.isEmpty()) {
return;
}
}
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
fail("Member(s) " + otherMembersSet + " are not Up");
}
use of akka.cluster.ClusterEvent.CurrentClusterState in project controller by opendaylight.
the class Follower method isLeaderAvailabilityKnown.
private boolean isLeaderAvailabilityKnown() {
if (leaderId == null) {
return false;
}
Optional<Cluster> cluster = context.getCluster();
if (!cluster.isPresent()) {
return false;
}
ActorSelection leaderActor = context.getPeerActorSelection(leaderId);
if (leaderActor == null) {
return false;
}
Address leaderAddress = leaderActor.anchorPath().address();
CurrentClusterState state = cluster.get().state();
Set<Member> unreachable = state.getUnreachable();
log.debug("{}: Checking for leader {} in the cluster unreachable set {}", logName(), leaderAddress, unreachable);
for (Member m : unreachable) {
if (leaderAddress.equals(m.address())) {
log.info("{}: Leader {} is unreachable", logName(), leaderAddress);
return false;
}
}
for (Member m : state.getMembers()) {
if (leaderAddress.equals(m.address())) {
if (m.status() == MemberStatus.up() || m.status() == MemberStatus.weaklyUp()) {
log.debug("{}: Leader {} cluster status is {} - leader is available", logName(), leaderAddress, m.status());
return true;
} else {
log.debug("{}: Leader {} cluster status is {} - leader is unavailable", logName(), leaderAddress, m.status());
return false;
}
}
}
log.debug("{}: Leader {} not found in the cluster member set", logName(), leaderAddress);
return false;
}
use of akka.cluster.ClusterEvent.CurrentClusterState in project controller by opendaylight.
the class EntityOwnershipShard method initializeDownPeerMemberNamesFromClusterState.
private void initializeDownPeerMemberNamesFromClusterState() {
java.util.Optional<Cluster> cluster = getRaftActorContext().getCluster();
if (!cluster.isPresent()) {
return;
}
CurrentClusterState state = cluster.get().state();
Set<Member> unreachable = state.getUnreachable();
LOG.debug("{}: initializeDownPeerMemberNamesFromClusterState - current downPeerMemberNames: {}, unreachable: {}", persistenceId(), downPeerMemberNames, unreachable);
downPeerMemberNames.clear();
for (Member m : unreachable) {
downPeerMemberNames.add(MemberName.forName(m.getRoles().iterator().next()));
}
for (Member m : state.getMembers()) {
if (m.status() != MemberStatus.up() && m.status() != MemberStatus.weaklyUp()) {
LOG.debug("{}: Adding down member with status {}", persistenceId(), m.status());
downPeerMemberNames.add(MemberName.forName(m.getRoles().iterator().next()));
}
}
LOG.debug("{}: new downPeerMemberNames: {}", persistenceId(), downPeerMemberNames);
}
use of akka.cluster.ClusterEvent.CurrentClusterState in project controller by opendaylight.
the class MemberNode method waitForMemberDown.
public void waitForMemberDown(final String member) {
Stopwatch sw = Stopwatch.createStarted();
while (sw.elapsed(TimeUnit.SECONDS) <= 10) {
CurrentClusterState state = Cluster.get(kit.getSystem()).state();
for (Member m : state.getUnreachable()) {
if (member.equals(m.getRoles().iterator().next())) {
return;
}
}
for (Member m : state.getMembers()) {
if (m.status() != MemberStatus.up() && member.equals(m.getRoles().iterator().next())) {
return;
}
}
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
fail("Member " + member + " is now down");
}
use of akka.cluster.ClusterEvent.CurrentClusterState in project controller by opendaylight.
the class RpcRegistryTest method waitForMembersUp.
static void waitForMembersUp(final ActorSystem node, final UniqueAddress... addresses) {
Set<UniqueAddress> otherMembersSet = Sets.newHashSet(addresses);
Stopwatch sw = Stopwatch.createStarted();
while (sw.elapsed(TimeUnit.SECONDS) <= 10) {
CurrentClusterState state = Cluster.get(node).state();
for (Member m : state.getMembers()) {
if (m.status() == MemberStatus.up() && otherMembersSet.remove(m.uniqueAddress()) && otherMembersSet.isEmpty()) {
return;
}
}
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
fail("Member(s) " + otherMembersSet + " are not Up");
}
Aggregations