You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/02/06 10:45:08 UTC

[GitHub] zentol commented on a change in pull request #7654: [FLINK-11524] Solve race condition in EmbeddedLeaderService

zentol commented on a change in pull request #7654: [FLINK-11524] Solve race condition in EmbeddedLeaderService
URL: https://github.com/apache/flink/pull/7654#discussion_r254216932
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/nonha/embedded/EmbeddedHaServicesTest.java
 ##########
 @@ -164,4 +171,70 @@ public void testResourceManagerLeaderRetrieval() throws Exception {
 
 		verify(leaderRetrievalListener).notifyLeaderAddress(eq(address), eq(leaderId));
 	}
+
+	/**
+	 * Tests that concurrent leadership operations (granting and revoking) leadership leave the
+	 * system in a sane state.
+	 */
+	@Test
+	public void testConcurrentLeadershipOperations() throws Exception {
+		final LeaderElectionService dispatcherLeaderElectionService = embeddedHaServices.getDispatcherLeaderElectionService();
+		final ArrayBlockingQueue<UUID> offeredSessionIds = new ArrayBlockingQueue<>(2);
+		final TestingLeaderContender leaderContender = new TestingLeaderContender(offeredSessionIds);
+
+		dispatcherLeaderElectionService.start(leaderContender);
+
+		final UUID oldLeaderSessionId = offeredSessionIds.take();
+
+		assertThat(dispatcherLeaderElectionService.hasLeadership(oldLeaderSessionId), is(true));
+
+		embeddedHaServices.getDispatcherLeaderService().revokeLeadership().get();
 
 Review comment:
   is there a reason you don't access `dispatcherLeaderElectionService` directly?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services