/** * Shutdown valueQueue executor threads */ @Override public void close() throws IOException { try { encKeyVersionQueue.shutdown(); } catch (Exception e) { throw new IOException(e); } finally { if (sslFactory != null) { sslFactory.destroy(); sslFactory = null; } } }
/** * Shutdown valueQueue executor threads */ @Override public void close() throws IOException { try { encKeyVersionQueue.shutdown(); } catch (Exception e) { throw new IOException(e); } finally { if (sslFactory != null) { sslFactory.destroy(); } } }
/** * Shutdown valueQueue executor threads */ @Override public void close() throws IOException { try { encKeyVersionQueue.shutdown(); } catch (Exception e) { throw new IOException(e); } finally { if (sslFactory != null) { sslFactory.destroy(); } } }
/** * Shutdown valueQueue executor threads */ @Override public void close() throws IOException { try { encKeyVersionQueue.shutdown(); } catch (Exception e) { throw new IOException(e); } finally { if (sslFactory != null) { sslFactory.destroy(); sslFactory = null; } } }
/** * Shutdown valueQueue executor threads */ @Override public void close() throws IOException { try { encKeyVersionQueue.shutdown(); } catch (Exception e) { throw new IOException(e); } finally { if (sslFactory != null) { sslFactory.destroy(); } } }
/** * Verifies that Queue is initially filled to "numInitValues" */ @Test(timeout=30000) public void testInitFill() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.1f, 300, 1, SyncGenerationPolicy.ALL, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(1, filler.getTop().num); vq.shutdown(); }
/** * Verifies that Queue is initially filled to "numInitValues" */ @Test(timeout=30000) public void testInitFill() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.1f, 300, 1, SyncGenerationPolicy.ALL, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(1, filler.getTop().num); vq.shutdown(); }
/** * Verifies that Queue is initialized (Warmed-up) for provided keys */ @Test(timeout=30000) public void testWarmUp() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.5f, 300, 1, SyncGenerationPolicy.ALL, filler); vq.initializeQueuesForKeys("k1", "k2", "k3"); FillInfo[] fillInfos = {filler.getTop(), filler.getTop(), filler.getTop()}; Assert.assertEquals(5, fillInfos[0].num); Assert.assertEquals(5, fillInfos[1].num); Assert.assertEquals(5, fillInfos[2].num); Assert.assertEquals(Sets.newHashSet("k1", "k2", "k3"), Sets.newHashSet(fillInfos[0].key, fillInfos[1].key, fillInfos[2].key)); vq.shutdown(); }
/** * Verifies that Queue is initialized (Warmed-up) for provided keys */ @Test(timeout=30000) public void testWarmUp() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.5f, 300, 1, SyncGenerationPolicy.ALL, filler); vq.initializeQueuesForKeys("k1", "k2", "k3"); FillInfo[] fillInfos = {filler.getTop(), filler.getTop(), filler.getTop()}; Assert.assertEquals(5, fillInfos[0].num); Assert.assertEquals(5, fillInfos[1].num); Assert.assertEquals(5, fillInfos[2].num); Assert.assertEquals(Sets.newHashSet("k1", "k2", "k3"), Sets.newHashSet(fillInfos[0].key, fillInfos[1].key, fillInfos[2].key)); vq.shutdown(); }
/** * Verify getAtMost when SyncGeneration Policy = ALL */ @Test(timeout=30000) public void testgetAtMostPolicyATLEAST_ONE() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.3f, 300, 1, SyncGenerationPolicy.ATLEAST_ONE, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(3, filler.getTop().num); // Drain completely Assert.assertEquals(2, vq.getAtMost("k1", 10).size()); // Asynch Refill call Assert.assertEquals(10, filler.getTop().num); vq.shutdown(); }
/** * Verify getAtMost when SyncGeneration Policy = ALL */ @Test(timeout=30000) public void testgetAtMostPolicyATLEAST_ONE() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.3f, 300, 1, SyncGenerationPolicy.ATLEAST_ONE, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(3, filler.getTop().num); // Drain completely Assert.assertEquals(2, vq.getAtMost("k1", 10).size()); // Asynch Refill call Assert.assertEquals(10, filler.getTop().num); vq.shutdown(); }
@Test(timeout=30000) public void testDrain() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.1f, 300, 1, SyncGenerationPolicy.ALL, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(1, filler.getTop().num); vq.drain("k1"); Assert.assertNull(filler.getTop()); vq.shutdown(); }
@Test(timeout=30000) public void testDrain() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.1f, 300, 1, SyncGenerationPolicy.ALL, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(1, filler.getTop().num); vq.drain("k1"); Assert.assertNull(filler.getTop()); vq.shutdown(); }
/** * Verifies that the No refill Happens after "checkInterval" if * num values above "lowWatermark" */ @Test(timeout=30000) public void testNoRefill() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.5f, 300, 1, SyncGenerationPolicy.ALL, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(5, filler.getTop().num); Assert.assertEquals(null, filler.getTop()); vq.shutdown(); }
/** * Verifies that the No refill Happens after "checkInterval" if * num values above "lowWatermark" */ @Test(timeout=30000) public void testNoRefill() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.5f, 300, 1, SyncGenerationPolicy.ALL, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(5, filler.getTop().num); Assert.assertEquals(null, filler.getTop()); vq.shutdown(); }
/** * Verify getAtMost when SyncGeneration Policy = LOW_WATERMARK */ @Test(timeout=30000) public void testgetAtMostPolicyLOW_WATERMARK() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.3f, 300, 1, SyncGenerationPolicy.LOW_WATERMARK, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(3, filler.getTop().num); // Drain completely Assert.assertEquals(3, vq.getAtMost("k1", 10).size()); // Synchronous call Assert.assertEquals(1, filler.getTop().num); // Asynch Refill call Assert.assertEquals(10, filler.getTop().num); vq.shutdown(); }
/** * Verify getAtMost when SyncGeneration Policy = LOW_WATERMARK */ @Test(timeout=30000) public void testgetAtMostPolicyLOW_WATERMARK() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.3f, 300, 1, SyncGenerationPolicy.LOW_WATERMARK, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(3, filler.getTop().num); // Drain completely Assert.assertEquals(3, vq.getAtMost("k1", 10).size()); // Synchronous call Assert.assertEquals(1, filler.getTop().num); // Asynch Refill call Assert.assertEquals(10, filler.getTop().num); vq.shutdown(); }
vq.getAtMost("k1", 19).size()); Assert.assertEquals("Failed in sync call.", 19, filler.getTop().num); vq.shutdown();
/** * Verifies that the refill task is executed after "checkInterval" if * num values below "lowWatermark" */ @Test(timeout=30000) public void testRefill() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.1f, 300, 1, SyncGenerationPolicy.ALL, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(1, filler.getTop().num); // Trigger refill vq.getNext("k1"); Assert.assertEquals(1, filler.getTop().num); Assert.assertEquals(10, filler.getTop().num); vq.shutdown(); }
/** * Verifies that the refill task is executed after "checkInterval" if * num values below "lowWatermark" */ @Test(timeout=30000) public void testRefill() throws Exception { MockFiller filler = new MockFiller(); ValueQueue<String> vq = new ValueQueue<String>(10, 0.1f, 300, 1, SyncGenerationPolicy.ALL, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(1, filler.getTop().num); // Trigger refill vq.getNext("k1"); Assert.assertEquals(1, filler.getTop().num); Assert.assertEquals(10, filler.getTop().num); vq.shutdown(); }