Search in sources :

Example 1 with ElectionCandidate

use of com.dangdang.ddframe.job.reg.base.ElectionCandidate in project elastic-job by dangdangdotcom.

the class ZookeeperElectionServiceTest method assertContend.

@Test
public void assertContend() throws Exception {
    ElectionCandidate anotherElectionCandidate = mock(ElectionCandidate.class);
    CuratorFramework anotherClient = CuratorFrameworkFactory.newClient(EmbedTestingServer.getConnectionString(), new RetryOneTime(2000));
    ZookeeperElectionService anotherService = new ZookeeperElectionService("ANOTHER_CLIENT:8899", anotherClient, ELECTION_PATH, anotherElectionCandidate);
    anotherClient.start();
    anotherClient.blockUntilConnected();
    anotherService.start();
    KillSession.kill(client.getZookeeperClient().getZooKeeper(), EmbedTestingServer.getConnectionString());
    service.stop();
    verify(anotherElectionCandidate).startLeadership();
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) RetryOneTime(org.apache.curator.retry.RetryOneTime) ElectionCandidate(com.dangdang.ddframe.job.reg.base.ElectionCandidate) Test(org.junit.Test)

Aggregations

ElectionCandidate (com.dangdang.ddframe.job.reg.base.ElectionCandidate)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 RetryOneTime (org.apache.curator.retry.RetryOneTime)1 Test (org.junit.Test)1