ivankelly commented on a change in pull request #832: Issue 620: Close the 
fileChannels for read when they are idle
URL: https://github.com/apache/bookkeeper/pull/832#discussion_r170912467
 
 

 ##########
 File path: 
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EntryLogTest.java
 ##########
 @@ -391,4 +489,57 @@ public void testGetEntryLogsSet() throws Exception {
 
         assertEquals(Sets.newHashSet(0L, 1L, 2L, 3L), 
logger.getEntryLogsSet());
     }
+
+    /**
+     * Fake Ticker to advance ticker as expected.
+     */
+    class FakeTicker extends Ticker {
+
+        private final AtomicLong nanos = new AtomicLong();
+
+        /** Advances the ticker value by {@code time} in {@code timeUnit}. */
+        public FakeTicker advance(long time, TimeUnit timeUnit) {
+            nanos.addAndGet(timeUnit.toNanos(time));
+            return this;
+        }
+
+        @Override
+        public long read() {
+            long value = nanos.getAndAdd(0);
+            return value;
+        }
+    }
+
+    /**
+     * Fake EntryLogger using customized cache to hide superclass'.
+     */
+    class FakeEntryLogger extends EntryLogger {
+        private Ticker ticker;
+        FakeEntryLogger(ServerConfiguration conf, LedgerDirsManager 
ledgerDirsManager,
+                        Ticker ticker) throws IOException{
+            super(conf, ledgerDirsManager);
+            this.ticker = ticker;
+        }
+
+        private final ThreadLocal<Cache<Long, EntryLogBufferedReadChannel>> 
logid2ReadChannel =
 
 Review comment:
   Why are you overridding this? For the ticker? It would be better to always 
pass in a ticker, and have a #getTicker() method that you can override. This 
will cut down the amount of code you need to duplicate.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to