use of java.util.UUID in project flink by apache.
the class JobManagerRunnerMockTest method testRegainLeadership.
@Ignore
@Test
public void testRegainLeadership() throws Exception {
runner.start();
UUID leaderSessionID = UUID.randomUUID();
runner.grantLeadership(leaderSessionID);
verify(jobManager).start(leaderSessionID);
assertTrue(!jobCompletion.isJobFinished());
runner.revokeLeadership();
verify(jobManager).suspendExecution(any(Throwable.class));
assertFalse(runner.isShutdown());
UUID leaderSessionID2 = UUID.randomUUID();
runner.grantLeadership(leaderSessionID2);
verify(jobManager).start(leaderSessionID2);
}
use of java.util.UUID in project flink by apache.
the class JobManagerRunnerMockTest method testLeadershipRevoked.
@Ignore
@Test
public void testLeadershipRevoked() throws Exception {
runner.start();
UUID leaderSessionID = UUID.randomUUID();
runner.grantLeadership(leaderSessionID);
verify(jobManager).start(leaderSessionID);
assertTrue(!jobCompletion.isJobFinished());
runner.revokeLeadership();
verify(jobManager).suspendExecution(any(Throwable.class));
assertFalse(runner.isShutdown());
}
use of java.util.UUID in project flink by apache.
the class LeaderChangeStateCleanupTest method testStateCleanupAfterNewLeaderElection.
/**
* Tests that a job is properly canceled in the case of a leader change. However, this time only the
* JMs are notified about the leader change and the TMs still believe the old leader to have
* leadership.
*/
@Test
public void testStateCleanupAfterNewLeaderElection() throws Exception {
UUID leaderSessionID = UUID.randomUUID();
UUID newLeaderSessionID = UUID.randomUUID();
cluster.grantLeadership(0, leaderSessionID);
cluster.notifyRetrievalListeners(0, leaderSessionID);
cluster.waitForTaskManagersToBeRegistered(timeout);
// submit blocking job so that we can test job clean up
cluster.submitJobDetached(job);
ActorGateway jm = cluster.getLeaderGateway(timeout);
Future<Object> wait = jm.ask(new WaitForAllVerticesToBeRunningOrFinished(job.getJobID()), timeout);
Await.ready(wait, timeout);
Future<Object> jobRemoval = jm.ask(new NotifyWhenJobRemoved(job.getJobID()), timeout);
// only notify the JMs about the new leader JM(1)
cluster.grantLeadership(1, newLeaderSessionID);
// job should be removed anyway
Await.ready(jobRemoval, timeout);
}
use of java.util.UUID in project flink by apache.
the class LeaderChangeStateCleanupTest method testStateCleanupAfterListenerNotification.
/**
* Tests that a job is properly canceled in the event of a leader change. However, this time
* only the TMs are notified about the changing leader. This should be enough to cancel the
* currently running job, though.
*/
@Test
public void testStateCleanupAfterListenerNotification() throws Exception {
UUID leaderSessionID = UUID.randomUUID();
UUID newLeaderSessionID = UUID.randomUUID();
cluster.grantLeadership(0, leaderSessionID);
cluster.notifyRetrievalListeners(0, leaderSessionID);
cluster.waitForTaskManagersToBeRegistered(timeout);
// submit blocking job
cluster.submitJobDetached(job);
ActorGateway jm = cluster.getLeaderGateway(timeout);
Future<Object> wait = jm.ask(new WaitForAllVerticesToBeRunningOrFinished(job.getJobID()), timeout);
Await.ready(wait, timeout);
Future<Object> jobRemoval = jm.ask(new NotifyWhenJobRemoved(job.getJobID()), timeout);
// notify listeners (TMs) about the leader change
cluster.notifyRetrievalListeners(1, newLeaderSessionID);
Await.ready(jobRemoval, timeout);
}
use of java.util.UUID in project flink by apache.
the class EmbeddedLeaderService method updateLeader.
@GuardedBy("lock")
private void updateLeader() {
// this must be called under the lock
assert Thread.holdsLock(lock);
if (currentLeaderConfirmed == null && currentLeaderProposed == null) {
// we need a new leader
if (allLeaderContenders.isEmpty()) {
// no new leader available, tell everyone that there is no leader currently
for (EmbeddedLeaderRetrievalService listener : listeners) {
notificationExecutor.execute(new NotifyOfLeaderCall(null, null, listener.listener, LOG));
}
} else {
// propose a leader and ask it
final UUID leaderSessionId = UUID.randomUUID();
EmbeddedLeaderElectionService leaderService = allLeaderContenders.iterator().next();
currentLeaderSessionId = leaderSessionId;
currentLeaderProposed = leaderService;
LOG.info("Proposing leadership to contender {} @ {}", leaderService.contender, leaderService.contender.getAddress());
notificationExecutor.execute(new GrantLeadershipCall(leaderService.contender, leaderSessionId, LOG));
}
}
}
Aggregations