DataBuffer implements DataArchive, DataProvider { @Override public boolean isFullyWithinTimeSpan(String feedID, long startTime, TimeUnit timeUnit) { int startPartition = this.currentParition.getBufferEnv().getCurrentBufferPartition(); int i = startPartition; do { if (metaDataBuffer.isFullyWithinTimeSpan(i, feedID, timeUnit, startTime)) { return true; } i = this.currentParition.getBufferEnv().previousBufferPartition(i); } while (i != startPartition); return false; } @SuppressWarnings("unchecked")  DataBuffer(DataBufferEnv env, DataBufferHelper partitionBufferFactory); @Override boolean isFullyWithinTimeSpan(String feedID, long startTime, TimeUnit timeUnit); @Override Map<String, SortedMap<Long, Map<String, String>>> getData(Set<String> feedIDs, long startTime, long endTime,
            TimeUnit timeUnit); @Override Map<String, List<Map<String, String>>> getData(Set<String> feedIDs, TimeUnit timeUnit, long startTime,
            long endTime); @Override void putData(String feedID, TimeUnit timeUnit, Map<Long, Map<String, String>> entries); @Override void putData(Map<String, Map<Long, Map<String, String>>> value, TimeUnit timeUnit,
                    Runnable callback); @Override void putData(String feedID, TimeUnit timeUnit, long time, Map<String, String> value); int getConcurrencyDegree(); int getBufferWriteThreadPoolSize(); @Override void reset(); void closeBuffer(); boolean isDataBufferClose(); boolean isAllDataBuffersClose(); void prepareForNextPartition(); void moveToNextPartition(); @Override LOS getLOS();  }
@Test public void isFullyWithinTimeSpanTest() throws BufferFullException { Map<String, String> value1 = new HashMap<String, String>(); value1.put("value", "1.3"); value1.put("status", "ok"); long time1 = System.currentTimeMillis(); dataBuffer.putData(testFeedID1, TimeUnit.MILLISECONDS, time1, value1); Map<String, String> value2 = new HashMap<String, String>(); value2.put("value", "2.3"); value2.put("status", "ok2"); long time2 = time1 + 100; dataBuffer.putData(testFeedID2, TimeUnit.MILLISECONDS, time2, value2); Map<String, String> value3 = new HashMap<String, String>(); value3.put("value", "2.3"); value3.put("status", "ok2"); long time3 = time1 + 200; dataBuffer.putData(testFeedID1, TimeUnit.MILLISECONDS, time3, value3); Map<String, String> value4 = new HashMap<String, String>(); value4.put("value", "2.3"); value4.put("status", "ok2"); long time4 = time1 + 300; dataBuffer.putData(testFeedID2, TimeUnit.MILLISECONDS, time4, value4); Assert.assertTrue(dataBuffer.isFullyWithinTimeSpan(testFeedID1, time1, TimeUnit.MILLISECONDS)); Assert.assertFalse(dataBuffer.isFullyWithinTimeSpan(testFeedID1, time1 - 1, TimeUnit.MILLISECONDS)); Assert.assertTrue(dataBuffer.isFullyWithinTimeSpan(testFeedID2, time2, TimeUnit.MILLISECONDS)); Assert.assertFalse(dataBuffer.isFullyWithinTimeSpan(testFeedID2, time2 - 1, TimeUnit.MILLISECONDS)); }