Search in sources :

Example 1 with Member

use of akka.cluster.Member 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");
}
Also used : CurrentClusterState(akka.cluster.ClusterEvent.CurrentClusterState) Stopwatch(com.google.common.base.Stopwatch) Member(akka.cluster.Member)

Example 2 with Member

use of akka.cluster.Member in project controller by opendaylight.

the class MockClusterWrapper method createMemberUp.

public static MemberUp createMemberUp(final String memberName, final String address) {
    UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L);
    Member member = new Member(uniqueAddress, 1, MemberStatus.up(), setOf(memberName));
    return new MemberUp(member);
}
Also used : MemberUp(akka.cluster.ClusterEvent.MemberUp) ReachableMember(akka.cluster.ClusterEvent.ReachableMember) UnreachableMember(akka.cluster.ClusterEvent.UnreachableMember) Member(akka.cluster.Member) UniqueAddress(akka.cluster.UniqueAddress)

Example 3 with Member

use of akka.cluster.Member in project controller by opendaylight.

the class MockClusterWrapper method createReachableMember.

public static ReachableMember createReachableMember(final String memberName, final String address) {
    UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L);
    Member member = new Member(uniqueAddress, 1, MemberStatus.up(), setOf(memberName));
    return new ReachableMember(member);
}
Also used : ReachableMember(akka.cluster.ClusterEvent.ReachableMember) ReachableMember(akka.cluster.ClusterEvent.ReachableMember) UnreachableMember(akka.cluster.ClusterEvent.UnreachableMember) Member(akka.cluster.Member) UniqueAddress(akka.cluster.UniqueAddress)

Example 4 with Member

use of akka.cluster.Member in project controller by opendaylight.

the class MockClusterWrapper method createMemberRemoved.

public static MemberRemoved createMemberRemoved(final String memberName, final String address) {
    UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L);
    Member member = new Member(uniqueAddress, 1, MemberStatus.removed(), setOf(memberName));
    return new MemberRemoved(member, MemberStatus.up());
}
Also used : MemberRemoved(akka.cluster.ClusterEvent.MemberRemoved) ReachableMember(akka.cluster.ClusterEvent.ReachableMember) UnreachableMember(akka.cluster.ClusterEvent.UnreachableMember) Member(akka.cluster.Member) UniqueAddress(akka.cluster.UniqueAddress)

Example 5 with Member

use of akka.cluster.Member 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;
}
Also used : CurrentClusterState(akka.cluster.ClusterEvent.CurrentClusterState) ActorSelection(akka.actor.ActorSelection) Address(akka.actor.Address) Cluster(akka.cluster.Cluster) Member(akka.cluster.Member)

Aggregations

Member (akka.cluster.Member)9 CurrentClusterState (akka.cluster.ClusterEvent.CurrentClusterState)5 UniqueAddress (akka.cluster.UniqueAddress)5 ReachableMember (akka.cluster.ClusterEvent.ReachableMember)4 UnreachableMember (akka.cluster.ClusterEvent.UnreachableMember)4 Stopwatch (com.google.common.base.Stopwatch)3 Cluster (akka.cluster.Cluster)2 ActorSelection (akka.actor.ActorSelection)1 Address (akka.actor.Address)1 MemberRemoved (akka.cluster.ClusterEvent.MemberRemoved)1 MemberUp (akka.cluster.ClusterEvent.MemberUp)1