Search in sources :

Example 1 with ClusterMembershipEvent

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

the class KubeClusterMembershipConnectorTest method doAddOrUpdateSibling.

private ClusterMembershipRevision<ClusterMember> doAddOrUpdateSibling(ClusterMembershipRevision<ClusterMember> revision, ClusterMembershipChangeEvent.ChangeType changeType) throws InterruptedException {
    String siblingId = revision.getCurrent().getMemberId();
    kubeExecutors.addOrUpdateSibling(revision);
    ClusterMembershipEvent event = connectorEvents.takeNext(TIMEOUT);
    assertThat(event).isInstanceOf(ClusterMembershipChangeEvent.class);
    assertThat(((ClusterMembershipChangeEvent) event).getChangeType()).isEqualTo(changeType);
    assertThat(((ClusterMembershipChangeEvent) event).getRevision()).isEqualTo(revision);
    assertThat(connector.getClusterMemberSiblings()).containsKey(siblingId);
    return connector.getClusterMemberSiblings().get(siblingId);
}
Also used : ClusterMembershipChangeEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent) ClusterMembershipEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent)

Example 2 with ClusterMembershipEvent

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

the class KubeClusterMembershipConnectorTest method doRemoveSibling.

private void doRemoveSibling(ClusterMembershipRevision<ClusterMember> revision) throws InterruptedException {
    kubeExecutors.removeSibling(revision.getCurrent().getMemberId());
    ClusterMembershipEvent event = connectorEvents.takeNext(TIMEOUT);
    assertThat(event).isInstanceOf(ClusterMembershipChangeEvent.class);
    assertThat(((ClusterMembershipChangeEvent) event).getChangeType()).isEqualTo(ClusterMembershipChangeEvent.ChangeType.Removed);
}
Also used : ClusterMembershipChangeEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent) ClusterMembershipEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent)

Example 3 with ClusterMembershipEvent

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

the class AbstractKubeMembershipExecutorTest method findNextMemberEvent.

private ClusterMembershipChangeEvent findNextMemberEvent(String memberId) throws InterruptedException {
    while (true) {
        ClusterMembershipEvent event = eventSubscriber.takeNext(KUBE_TIMEOUT);
        assertThat(event).isNotNull();
        if (event instanceof ClusterMembershipChangeEvent) {
            ClusterMembershipChangeEvent memberEvent = (ClusterMembershipChangeEvent) event;
            if (memberEvent.getRevision().getCurrent().getMemberId().equals(memberId)) {
                return memberEvent;
            }
        }
    }
}
Also used : ClusterMembershipChangeEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent) ClusterMembershipEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent)

Example 4 with ClusterMembershipEvent

use of com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent 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 5 with ClusterMembershipEvent

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

the class KubeClusterMembershipConnectorTest method doRegistrationChange.

private ClusterMembershipRevision<ClusterMember> doRegistrationChange(Supplier<ClusterMembershipRevision<ClusterMember>> action) throws InterruptedException {
    long now = titusRuntime.getClock().wallTime();
    ClusterMembershipRevision<ClusterMember> newRevision = action.get();
    assertThat(newRevision.getTimestamp()).isGreaterThanOrEqualTo(now);
    assertThat(connector.getLocalClusterMemberRevision()).isEqualTo(newRevision);
    ClusterMembershipEvent registrationEvent1 = connectorEvents.takeNext(TIMEOUT);
    assertThat(registrationEvent1).isInstanceOf(ClusterMembershipChangeEvent.class);
    assertThat(((ClusterMembershipChangeEvent) registrationEvent1).getChangeType()).isEqualTo(ClusterMembershipChangeEvent.ChangeType.Updated);
    return newRevision;
}
Also used : ClusterMember(com.netflix.titus.api.clustermembership.model.ClusterMember) ClusterMemberGenerator.activeClusterMember(com.netflix.titus.testkit.model.clustermembership.ClusterMemberGenerator.activeClusterMember) ClusterMembershipChangeEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent) ClusterMembershipEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent)

Aggregations

ClusterMembershipEvent (com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent)6 ClusterMembershipChangeEvent (com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent)4 ClusterMember (com.netflix.titus.api.clustermembership.model.ClusterMember)1 LeaderElectionChangeEvent (com.netflix.titus.api.clustermembership.model.event.LeaderElectionChangeEvent)1 ClusterMemberGenerator.activeClusterMember (com.netflix.titus.testkit.model.clustermembership.ClusterMemberGenerator.activeClusterMember)1 Before (org.junit.Before)1