pinot-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-pinot] jackjlli commented on a change in pull request #5039: Close Kafka consumer before building or downloading immutable segment
Date Sun, 09 Feb 2020 20:41:06 GMT
jackjlli commented on a change in pull request #5039: Close Kafka consumer before building
or downloading immutable segment
URL: https://github.com/apache/incubator-pinot/pull/5039#discussion_r376813446
 
 

 ##########
 File path: pinot-core/src/test/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManagerTest.java
 ##########
 @@ -609,6 +639,43 @@ public void testFileRemovedDuringOnlineTransition()
     segmentDataManager._state.set(segmentDataManager, LLRealtimeSegmentDataManager.State.HOLDING);
     segmentDataManager.goOnlineFromConsuming(metadata);
     Assert.assertFalse(new File(segTarFileName).exists());
+    segmentDataManager.destroy();
+  }
+
+  @Test
+  public void testOnlyOneSegmentHoldingTheSemaphoreForParticularPartition()
+      throws Exception {
+    long timeout = 2_000L;
+    FakeLLRealtimeSegmentDataManager firstSegmentDataManager = createFakeSegmentManager();
+    Assert.assertTrue(firstSegmentDataManager.getAcquireConsumerSemaphore().get());
+    Assert.assertEquals(firstSegmentDataManager.getPartitionConsumerSemaphore().availablePermits(),
0);
+
+    // Release semaphore after timeout.
+    Thread releaseSemaphore = new Thread(() -> {
+      try {
+        Thread.sleep(timeout);
+      } catch (InterruptedException e) {
+        throw new RuntimeException("InterruptedException when sleeping for " + timeout +
"ms");
+      } finally {
+        firstSegmentDataManager.destroy();
+      }
+    });
+    releaseSemaphore.start();
+
+    // The second segment will be hanged until the semaphore gets released.
+    FakeLLRealtimeSegmentDataManager secondSegmentDataManager = createFakeSegmentManager();
+    Assert.assertEquals(firstSegmentDataManager.getPartitionConsumerSemaphore(),
+        secondSegmentDataManager.getPartitionConsumerSemaphore());
+    Assert.assertTrue(secondSegmentDataManager.getAcquireConsumerSemaphore().get());
 
 Review comment:
   The acquire method of semaphore is a blocking method. The second segmentManager will be
blocked on the acquire method until the first segmentManager releases the permit. 
   Thus, after the second segmentManager finishes its construction, it has already taken the
permit. So it should be true here.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Mime
View raw message