sv2000 commented on a change in pull request #2876: GOBBLIN-1034: Ensure
underlying writers are expired from the Partitio…
URL: https://github.com/apache/incubator-gobblin/pull/2876#discussion_r372719715
##########
File path:
gobblin-core/src/test/java/org/apache/gobblin/writer/PartitionedWriterTest.java
##########
@@ -176,4 +165,31 @@ public void testControlMessageHandler() throws
IOException {
writer.close();
}
+
+ @Test
+ public void testPartitionWriterCacheRemovalListener()
+ throws IOException, InterruptedException {
+ State state = new State();
+ state.setProp(ConfigurationKeys.WRITER_PARTITIONER_CLASS,
TestPartitioner.class.getCanonicalName());
+ state.setProp(PartitionedDataWriter.PARTITIONED_WRITER_CACHE_TTL_SECONDS,
1);
+ TestPartitionAwareWriterBuilder builder = new
TestPartitionAwareWriterBuilder();
+
+ PartitionedDataWriter writer = new PartitionedDataWriter<String,
String>(builder, state);
+
+ String record1 = "abc";
+ writer.writeEnvelope(new RecordEnvelope(record1));
+
+ String record2 = "123";
+ writer.writeEnvelope(new RecordEnvelope(record2));
+
+ //Sleep for more than cache expiration interval
+ Thread.sleep(1500);
Review comment:
Guava does provide Ticker interface for testing cache evictions without
having to put sleeps. Unfortunately, the cache has to be built with the ticker,
which is not what we want for our test. In our test, since we explicitly call
cache cleanup(), we should not encounter the issue you are describing.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services