Search in sources :

Example 1 with LeadershipService

use of org.onosproject.cluster.LeadershipService in project onos by opennetworkinglab.

the class ElectionTestRunCommand method doExecute.

@Override
protected void doExecute() {
    LeadershipService service = get(LeadershipService.class);
    service.runForLeadership(ELECTION_APP);
    // print the current leader
    print("Entering leadership elections for the Election app.");
}
Also used : LeadershipService(org.onosproject.cluster.LeadershipService)

Example 2 with LeadershipService

use of org.onosproject.cluster.LeadershipService in project onos by opennetworkinglab.

the class ElectionTestWithdrawCommand method doExecute.

@Override
protected void doExecute() {
    LeadershipService service = get(LeadershipService.class);
    service.withdraw(ELECTION_APP);
    // print the current leader
    print("Withdrawing from leadership elections for the Election app.");
}
Also used : LeadershipService(org.onosproject.cluster.LeadershipService)

Example 3 with LeadershipService

use of org.onosproject.cluster.LeadershipService in project onos by opennetworkinglab.

the class WorkPartitionManagerTest method setUp.

@Before
public void setUp() {
    leadershipService = createMock(LeadershipService.class);
    leadershipService.addListener(anyObject(LeadershipEventListener.class));
    expectLastCall().andDelegateTo(new TestLeadershipService());
    for (int i = 0; i < WorkPartitionManager.NUM_PARTITIONS; i++) {
        expect(leadershipService.runForLeadership(ELECTION_PREFIX + i)).andReturn(null).times(1);
    }
    partitionManager = new WorkPartitionManager().withScheduledExecutor(new NullScheduledExecutor());
    partitionManager.clusterService = new TestClusterService();
    partitionManager.localNodeId = MY_NODE_ID;
    partitionManager.leadershipService = leadershipService;
    partitionManager.eventDispatcher = new TestEventDispatcher();
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) LeadershipService(org.onosproject.cluster.LeadershipService) NullScheduledExecutor(org.onlab.junit.NullScheduledExecutor) LeadershipEventListener(org.onosproject.cluster.LeadershipEventListener) Before(org.junit.Before)

Example 4 with LeadershipService

use of org.onosproject.cluster.LeadershipService in project onos by opennetworkinglab.

the class ElectionTestLeaderCommand method doExecute.

@Override
protected void doExecute() {
    LeadershipService service = get(LeadershipService.class);
    // print the current leader
    leader = service.getLeader(ELECTION_APP);
    printLeader(leader);
}
Also used : LeadershipService(org.onosproject.cluster.LeadershipService)

Aggregations

LeadershipService (org.onosproject.cluster.LeadershipService)4 Before (org.junit.Before)1 NullScheduledExecutor (org.onlab.junit.NullScheduledExecutor)1 LeadershipEventListener (org.onosproject.cluster.LeadershipEventListener)1 TestEventDispatcher (org.onosproject.common.event.impl.TestEventDispatcher)1