Search in sources :

Example 26 with UUID

use of java.util.UUID in project flink by apache.

the class SingleLeaderElectionServiceTest method testStartStopAssignLeadership.

// ------------------------------------------------------------------------
@Test
public void testStartStopAssignLeadership() throws Exception {
    final UUID uuid = UUID.randomUUID();
    final SingleLeaderElectionService service = new SingleLeaderElectionService(executor, uuid);
    final LeaderContender contender = mockContender(service);
    final LeaderContender otherContender = mockContender(service);
    service.start(contender);
    verify(contender, times(1)).grantLeadership(uuid);
    service.stop();
    verify(contender, times(1)).revokeLeadership();
    // start with a new contender - the old contender must not gain another leadership
    service.start(otherContender);
    verify(otherContender, times(1)).grantLeadership(uuid);
    verify(contender, times(1)).grantLeadership(uuid);
    verify(contender, times(1)).revokeLeadership();
}
Also used : LeaderContender(org.apache.flink.runtime.leaderelection.LeaderContender) UUID(java.util.UUID) Test(org.junit.Test)

Example 27 with UUID

use of java.util.UUID in project flink by apache.

the class SingleLeaderElectionServiceTest method testStopBeforeConfirmingLeadership.

@Test
public void testStopBeforeConfirmingLeadership() throws Exception {
    final UUID uuid = UUID.randomUUID();
    final SingleLeaderElectionService service = new SingleLeaderElectionService(executor, uuid);
    final LeaderContender contender = mock(LeaderContender.class);
    service.start(contender);
    verify(contender, times(1)).grantLeadership(uuid);
    service.stop();
    // because the leadership was never confirmed, there is no "revoke" call
    verifyNoMoreInteractions(contender);
}
Also used : LeaderContender(org.apache.flink.runtime.leaderelection.LeaderContender) UUID(java.util.UUID) Test(org.junit.Test)

Example 28 with UUID

use of java.util.UUID in project flink by apache.

the class JobClientActorTest method testConnectionTimeoutAfterJobSubmission.

/** Tests that a {@link org.apache.flink.runtime.client.JobClientActorConnectionTimeoutException}
	 * is thrown after a successful job submission if the JobManager dies.
	 *
	 * @throws Exception
	 */
@Test(expected = JobClientActorConnectionTimeoutException.class)
public void testConnectionTimeoutAfterJobSubmission() throws Exception {
    FiniteDuration jobClientActorTimeout = new FiniteDuration(5, TimeUnit.SECONDS);
    FiniteDuration timeout = jobClientActorTimeout.$times(2);
    UUID leaderSessionID = UUID.randomUUID();
    ActorRef jobManager = system.actorOf(Props.create(JobAcceptingActor.class, leaderSessionID));
    TestingLeaderRetrievalService testingLeaderRetrievalService = new TestingLeaderRetrievalService(jobManager.path().toString(), leaderSessionID);
    Props jobClientActorProps = JobSubmissionClientActor.createActorProps(testingLeaderRetrievalService, jobClientActorTimeout, false, clientConfig);
    ActorRef jobClientActor = system.actorOf(jobClientActorProps);
    Future<Object> jobExecutionResult = Patterns.ask(jobClientActor, new JobClientMessages.SubmitJobAndWait(testJobGraph), new Timeout(timeout));
    Future<Object> waitFuture = Patterns.ask(jobManager, new RegisterTest(), new Timeout(timeout));
    Await.result(waitFuture, timeout);
    jobManager.tell(PoisonPill.getInstance(), ActorRef.noSender());
    Await.result(jobExecutionResult, timeout);
}
Also used : TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService) ActorRef(akka.actor.ActorRef) JobClientMessages(org.apache.flink.runtime.messages.JobClientMessages) Timeout(akka.util.Timeout) FiniteDuration(scala.concurrent.duration.FiniteDuration) UUID(java.util.UUID) Props(akka.actor.Props) Test(org.junit.Test)

Example 29 with UUID

use of java.util.UUID in project flink by apache.

the class JobClientActorTest method testSubmissionTimeout.

/** Tests that a {@link JobClientActorSubmissionTimeoutException} is thrown when the job cannot
	 * be submitted by the JobSubmissionClientActor. This is here the case, because the started JobManager
	 * never replies to a {@link SubmitJob} message.
	 *
	 * @throws Exception
	 */
@Test(expected = JobClientActorSubmissionTimeoutException.class)
public void testSubmissionTimeout() throws Exception {
    FiniteDuration jobClientActorTimeout = new FiniteDuration(5, TimeUnit.SECONDS);
    FiniteDuration timeout = jobClientActorTimeout.$times(2);
    UUID leaderSessionID = UUID.randomUUID();
    ActorRef jobManager = system.actorOf(Props.create(PlainActor.class, leaderSessionID));
    TestingLeaderRetrievalService testingLeaderRetrievalService = new TestingLeaderRetrievalService(jobManager.path().toString(), leaderSessionID);
    Props jobClientActorProps = JobSubmissionClientActor.createActorProps(testingLeaderRetrievalService, jobClientActorTimeout, false, clientConfig);
    ActorRef jobClientActor = system.actorOf(jobClientActorProps);
    Future<Object> jobExecutionResult = Patterns.ask(jobClientActor, new JobClientMessages.SubmitJobAndWait(testJobGraph), new Timeout(timeout));
    Await.result(jobExecutionResult, timeout);
}
Also used : TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService) ActorRef(akka.actor.ActorRef) JobClientMessages(org.apache.flink.runtime.messages.JobClientMessages) Timeout(akka.util.Timeout) FiniteDuration(scala.concurrent.duration.FiniteDuration) UUID(java.util.UUID) Props(akka.actor.Props) Test(org.junit.Test)

Example 30 with UUID

use of java.util.UUID in project flink by apache.

the class AkkaKvStateLocationLookupServiceTest method testLeaderSessionIdChange.

/**
	 * Tests that messages are properly decorated with the leader session ID.
	 */
@Test
public void testLeaderSessionIdChange() throws Exception {
    TestingLeaderRetrievalService leaderRetrievalService = new TestingLeaderRetrievalService();
    Queue<LookupKvStateLocation> received = new LinkedBlockingQueue<>();
    AkkaKvStateLocationLookupService lookupService = new AkkaKvStateLocationLookupService(leaderRetrievalService, testActorSystem, TIMEOUT, new AkkaKvStateLocationLookupService.DisabledLookupRetryStrategyFactory());
    lookupService.start();
    // Create test actors with random leader session IDs
    KvStateLocation expected1 = new KvStateLocation(new JobID(), new JobVertexID(), 8282, "salt");
    UUID leaderSessionId1 = UUID.randomUUID();
    ActorRef testActor1 = LookupResponseActor.create(received, leaderSessionId1, expected1);
    String testActorAddress1 = AkkaUtils.getAkkaURL(testActorSystem, testActor1);
    KvStateLocation expected2 = new KvStateLocation(new JobID(), new JobVertexID(), 22321, "pepper");
    UUID leaderSessionId2 = UUID.randomUUID();
    ActorRef testActor2 = LookupResponseActor.create(received, leaderSessionId1, expected2);
    String testActorAddress2 = AkkaUtils.getAkkaURL(testActorSystem, testActor2);
    JobID jobId = new JobID();
    //
    // Notify about first leader
    //
    leaderRetrievalService.notifyListener(testActorAddress1, leaderSessionId1);
    KvStateLocation location = Await.result(lookupService.getKvStateLookupInfo(jobId, "rock"), TIMEOUT);
    assertEquals(expected1, location);
    assertEquals(1, received.size());
    verifyLookupMsg(received.poll(), jobId, "rock");
    //
    // Notify about second leader
    //
    leaderRetrievalService.notifyListener(testActorAddress2, leaderSessionId2);
    location = Await.result(lookupService.getKvStateLookupInfo(jobId, "roll"), TIMEOUT);
    assertEquals(expected2, location);
    assertEquals(1, received.size());
    verifyLookupMsg(received.poll(), jobId, "roll");
}
Also used : TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService) ActorRef(akka.actor.ActorRef) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) LookupKvStateLocation(org.apache.flink.runtime.query.KvStateMessage.LookupKvStateLocation) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) UUID(java.util.UUID) LookupKvStateLocation(org.apache.flink.runtime.query.KvStateMessage.LookupKvStateLocation) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

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