Search in sources :

Example 6 with UUID

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);
}
Also used : UUID(java.util.UUID) Ignore(org.junit.Ignore) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with UUID

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());
}
Also used : UUID(java.util.UUID) Ignore(org.junit.Ignore) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with UUID

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);
}
Also used : WaitForAllVerticesToBeRunningOrFinished(org.apache.flink.runtime.testingUtils.TestingJobManagerMessages.WaitForAllVerticesToBeRunningOrFinished) NotifyWhenJobRemoved(org.apache.flink.runtime.testingUtils.TestingJobManagerMessages.NotifyWhenJobRemoved) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) UUID(java.util.UUID) Test(org.junit.Test)

Example 9 with UUID

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);
}
Also used : WaitForAllVerticesToBeRunningOrFinished(org.apache.flink.runtime.testingUtils.TestingJobManagerMessages.WaitForAllVerticesToBeRunningOrFinished) NotifyWhenJobRemoved(org.apache.flink.runtime.testingUtils.TestingJobManagerMessages.NotifyWhenJobRemoved) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) UUID(java.util.UUID) Test(org.junit.Test)

Example 10 with UUID

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));
        }
    }
}
Also used : UUID(java.util.UUID) GuardedBy(javax.annotation.concurrent.GuardedBy)

Aggregations

UUID (java.util.UUID)2250 Test (org.junit.Test)441 Test (org.testng.annotations.Test)307 ArrayList (java.util.ArrayList)250 HashMap (java.util.HashMap)224 ClusterNode (org.apache.ignite.cluster.ClusterNode)154 LocalDate (org.joda.time.LocalDate)143 BigDecimal (java.math.BigDecimal)142 Map (java.util.Map)136 List (java.util.List)105 Invoice (org.killbill.billing.invoice.api.Invoice)105 Ignite (org.apache.ignite.Ignite)103 DateTime (org.joda.time.DateTime)94 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)93 CountDownLatch (java.util.concurrent.CountDownLatch)92 HashSet (java.util.HashSet)90 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)70 IOException (java.io.IOException)66 Event (org.apache.ignite.events.Event)66 LinkedList (java.util.LinkedList)65