public class MockLeaderElector extends Object implements ILeaderElector
| Constructor and Description |
|---|
MockLeaderElector() |
MockLeaderElector(boolean isLeader) |
MockLeaderElector(boolean isLeader,
String host,
int port) |
| Modifier and Type | Method and Description |
|---|---|
void |
addToLeaderLockQueue()
queue up for leadership lock.
|
boolean |
awaitLeadership(long timeout,
TimeUnit timeUnit)
Wait for the caller to gain leadership.
|
void |
close()
Method called to allow for cleanup.
|
List<NimbusInfo> |
getAllNimbuses()
Get list of current nimbus addresses.
|
NimbusInfo |
getLeader()
Get the current leader's address.
|
boolean |
isLeader()
Decide if the caller currently has the leader lock.
|
void |
prepare(Map<String,Object> conf)
Method guaranteed to be called as part of initialization of leader elector instance.
|
void |
quitElectionFor(int delayMs)
Removes the caller from leadership election, relinquishing leadership if acquired, then requeues for leadership after the specified
delay.
|
public MockLeaderElector()
public MockLeaderElector(boolean isLeader)
public MockLeaderElector(boolean isLeader,
String host,
int port)
public void prepare(Map<String,Object> conf)
ILeaderElectorprepare in interface ILeaderElectorconf - configurationpublic void addToLeaderLockQueue()
throws Exception
ILeaderElectoraddToLeaderLockQueue in interface ILeaderElectorExceptionpublic void quitElectionFor(int delayMs)
throws Exception
ILeaderElectorquitElectionFor in interface ILeaderElectordelayMs - The delay to wait before re-entering the electionExceptionpublic boolean isLeader()
throws Exception
ILeaderElectorisLeader in interface ILeaderElectorExceptionpublic boolean awaitLeadership(long timeout,
TimeUnit timeUnit)
throws InterruptedException
ILeaderElectorawaitLeadership in interface ILeaderElectorInterruptedExceptionpublic NimbusInfo getLeader()
ILeaderElectorgetLeader in interface ILeaderElectorpublic List<NimbusInfo> getAllNimbuses() throws Exception
ILeaderElectorgetAllNimbuses in interface ILeaderElectorExceptionpublic void close()
ILeaderElectorclose in interface AutoCloseableclose in interface ILeaderElectorCopyright © 2023 The Apache Software Foundation. All rights reserved.