@Override public EncryptedKeyVersion generateEncryptedKey( String encryptionKeyName) throws IOException, GeneralSecurityException { try { return encKeyVersionQueue.getNext(encryptionKeyName); } catch (ExecutionException e) { if (e.getCause() instanceof SocketTimeoutException) { throw (SocketTimeoutException)e.getCause(); } throw new IOException(e); } }
@Override public EncryptedKeyVersion generateEncryptedKey(String encryptionKeyName) throws IOException, GeneralSecurityException { try { return encKeyVersionQueue.getNext(encryptionKeyName); } catch (ExecutionException e) { throw new IOException(e); } }
@Override public EncryptedKeyVersion generateEncryptedKey( String encryptionKeyName) throws IOException, GeneralSecurityException { try { return encKeyVersionQueue.getNext(encryptionKeyName); } catch (ExecutionException e) { if (e.getCause() instanceof SocketTimeoutException) { throw (SocketTimeoutException)e.getCause(); } throw new IOException(e); } }
@Override public EncryptedKeyVersion generateEncryptedKey( String encryptionKeyName) throws IOException, GeneralSecurityException { try { return encKeyVersionQueue.getNext(encryptionKeyName); } catch (ExecutionException e) { if (e.getCause() instanceof SocketTimeoutException) { throw (SocketTimeoutException)e.getCause(); } throw new IOException(e); } }
@Override public EncryptedKeyVersion generateEncryptedKey( String encryptionKeyName) throws IOException, GeneralSecurityException { try { return encKeyVersionQueue.getNext(encryptionKeyName); } catch (ExecutionException e) { if (e.getCause() instanceof SocketTimeoutException) { throw (SocketTimeoutException)e.getCause(); } throw new IOException(e); } }
@Override public EncryptedKeyVersion generateEncryptedKey( String encryptionKeyName) throws IOException, GeneralSecurityException { try { return encKeyVersionQueue.getNext(encryptionKeyName); } catch (ExecutionException e) { if (e.getCause() instanceof SocketTimeoutException) { throw (SocketTimeoutException)e.getCause(); } throw new IOException(e); } }
/** * 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(); }
/** * 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(); }
/** * 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(); }
new ValueQueue<String>(10, 0.1f, 300, 1, SyncGenerationPolicy.ALL, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(1, filler.getTop().num);
new ValueQueue<String>(10, 0.1f, 300, 1, SyncGenerationPolicy.ALL, filler); Assert.assertEquals("test", vq.getNext("k1")); Assert.assertEquals(1, filler.getTop().num);