/** * This removes the value currently at the head of the Queue for the * provided key. Will immediately fire the Queue filler function if key * does not exist. * If Queue exists but all values are drained, It will ask the generator * function to add 1 value to Queue and then drain it. * @param keyName String key name * @return E the next value in the Queue * @throws IOException * @throws ExecutionException */ public E getNext(String keyName) throws IOException, ExecutionException { return getAtMost(keyName, 1).get(0); }
/** * This removes the value currently at the head of the Queue for the * provided key. Will immediately fire the Queue filler function if key * does not exist. * If Queue exists but all values are drained, It will ask the generator * function to add 1 value to Queue and then drain it. * @param keyName String key name * @return E the next value in the Queue * @throws IOException * @throws ExecutionException */ public E getNext(String keyName) throws IOException, ExecutionException { return getAtMost(keyName, 1).get(0); }
/** * This removes the value currently at the head of the Queue for the * provided key. Will immediately fire the Queue filler function if key * does not exist. * If Queue exists but all values are drained, It will ask the generator * function to add 1 value to Queue and then drain it. * @param keyName String key name * @return E the next value in the Queue * @throws IOException * @throws ExecutionException */ public E getNext(String keyName) throws IOException, ExecutionException { return getAtMost(keyName, 1).get(0); }
/** * This removes the value currently at the head of the Queue for the * provided key. Will immediately fire the Queue filler function if key * does not exist. * If Queue exists but all values are drained, It will ask the generator * function to add 1 value to Queue and then drain it. * @param keyName String key name * @return E the next value in the Queue * @throws IOException * @throws ExecutionException */ public E getNext(String keyName) throws IOException, ExecutionException { return getAtMost(keyName, 1).get(0); }
/** * This removes the value currently at the head of the Queue for the * provided key. Will immediately fire the Queue filler function if key * does not exist. * If Queue exists but all values are drained, It will ask the generator * function to add 1 value to Queue and then drain it. * @param keyName String key name * @return E the next value in the Queue * @throws IOException * @throws ExecutionException */ public E getNext(String keyName) throws IOException, ExecutionException { return getAtMost(keyName, 1).get(0); }
/** * 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(); }
/** * 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(); }