Search in sources :

Example 6 with LeaderElectionChangeEvent

use of com.netflix.titus.api.clustermembership.model.event.LeaderElectionChangeEvent in project titus-control-plane by Netflix.

the class KubeClusterMembershipConnectorTest method takeLeaderElectionEvent.

private LeaderElectionChangeEvent takeLeaderElectionEvent(LeaderElectionChangeEvent.ChangeType changeType) throws InterruptedException {
    ClusterMembershipEvent event = connectorEvents.takeNext(TIMEOUT);
    assertThat(event).isInstanceOf(LeaderElectionChangeEvent.class);
    LeaderElectionChangeEvent electionEvent = (LeaderElectionChangeEvent) event;
    assertThat(electionEvent.getChangeType()).isEqualTo(changeType);
    return electionEvent;
}
Also used : ClusterMembershipEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent) LeaderElectionChangeEvent(com.netflix.titus.api.clustermembership.model.event.LeaderElectionChangeEvent)

Example 7 with LeaderElectionChangeEvent

use of com.netflix.titus.api.clustermembership.model.event.LeaderElectionChangeEvent in project titus-control-plane by Netflix.

the class KubeClusterMembershipConnectorTest method joinLeaderElectionProcess.

private void joinLeaderElectionProcess() throws InterruptedException {
    connector.joinLeadershipGroup().block();
    LeaderElectionChangeEvent electionEvent = takeLeaderElectionEvent(LeaderElectionChangeEvent.ChangeType.LocalJoined);
    assertThat(electionEvent.getLeadershipRevision().getCurrent().getLeadershipState()).isEqualTo(ClusterMemberLeadershipState.NonLeader);
    assertThat(connector.getLocalLeadershipRevision().getCurrent().getLeadershipState()).isEqualTo(ClusterMemberLeadershipState.NonLeader);
}
Also used : LeaderElectionChangeEvent(com.netflix.titus.api.clustermembership.model.event.LeaderElectionChangeEvent)

Example 8 with LeaderElectionChangeEvent

use of com.netflix.titus.api.clustermembership.model.event.LeaderElectionChangeEvent in project titus-control-plane by Netflix.

the class KubeClusterMembershipConnectorTest method electLocalAsLeader.

private void electLocalAsLeader() throws InterruptedException {
    kubeExecutors.emitLeadershipEvent(ClusterMembershipEvent.leaderElected(ClusterMembershipRevision.<ClusterMemberLeadership>newBuilder().withCurrent(ClusterMemberLeadership.newBuilder().withMemberId(LOCAL_MEMBER_UNREGISTERED.getMemberId()).withLeadershipState(ClusterMemberLeadershipState.Leader).build()).build()));
    LeaderElectionChangeEvent electionEvent = takeLeaderElectionEvent(LeaderElectionChangeEvent.ChangeType.LeaderElected);
    assertThat(electionEvent.getLeadershipRevision().getCurrent().getLeadershipState()).isEqualTo(ClusterMemberLeadershipState.Leader);
}
Also used : ClusterMemberLeadership(com.netflix.titus.api.clustermembership.model.ClusterMemberLeadership) LeaderElectionChangeEvent(com.netflix.titus.api.clustermembership.model.event.LeaderElectionChangeEvent)

Example 9 with LeaderElectionChangeEvent

use of com.netflix.titus.api.clustermembership.model.event.LeaderElectionChangeEvent in project titus-control-plane by Netflix.

the class KubeClusterMembershipConnectorTest method leaveLeaderElectionProcess.

private void leaveLeaderElectionProcess() throws InterruptedException {
    connector.leaveLeadershipGroup(true).block();
    LeaderElectionChangeEvent electionEvent = takeLeaderElectionEvent(LeaderElectionChangeEvent.ChangeType.LocalLeft);
    assertThat(electionEvent.getLeadershipRevision().getCurrent().getLeadershipState()).isEqualTo(ClusterMemberLeadershipState.Disabled);
    assertThat(connector.getLocalLeadershipRevision().getCurrent().getLeadershipState()).isEqualTo(ClusterMemberLeadershipState.Disabled);
}
Also used : LeaderElectionChangeEvent(com.netflix.titus.api.clustermembership.model.event.LeaderElectionChangeEvent)

Aggregations

LeaderElectionChangeEvent (com.netflix.titus.api.clustermembership.model.event.LeaderElectionChangeEvent)9 ClusterMemberLeadership (com.netflix.titus.api.clustermembership.model.ClusterMemberLeadership)3 ClusterMembershipEvent (com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent)1 Test (org.junit.Test)1