@Test public void testGetTables() throws MetaStoreException { MetaStore adapter = mock(MetaStore.class); TableEvictor tableEvictor = new CountEvictor(adapter, 20); Map<TimeGranularity, AccessCountTableDeque> map = new HashMap<>(); AccessCountTableDeque dayDeque = new AccessCountTableDeque(tableEvictor); AccessCountTable firstDay = new AccessCountTable(0L, Constants.ONE_DAY_IN_MILLIS); dayDeque.addAndNotifyListener(firstDay); map.put(TimeGranularity.DAY, dayDeque); AccessCountTableDeque hourDeque = new AccessCountTableDeque(tableEvictor); AccessCountTable firstHour = new AccessCountTable(23 * Constants.ONE_HOUR_IN_MILLIS, 24 * Constants.ONE_HOUR_IN_MILLIS); AccessCountTable secondHour = new AccessCountTable(24 * Constants.ONE_HOUR_IN_MILLIS, 25 * Constants.ONE_HOUR_IN_MILLIS); hourDeque.addAndNotifyListener(firstHour); hourDeque.addAndNotifyListener(secondHour); map.put(TimeGranularity.HOUR, hourDeque); AccessCountTableDeque minuteDeque = new AccessCountTableDeque(tableEvictor); Integer numMins = 25 * 60; AccessCountTable firstMin = new AccessCountTable( (numMins - 1) * Constants.ONE_MINUTE_IN_MILLIS, numMins * Constants.ONE_MINUTE_IN_MILLIS); AccessCountTable secondMin = new AccessCountTable( numMins * Constants.ONE_MINUTE_IN_MILLIS, (numMins + 1) * Constants.ONE_MINUTE_IN_MILLIS); minuteDeque.addAndNotifyListener(firstMin); minuteDeque.addAndNotifyListener(secondMin); map.put(TimeGranularity.MINUTE, minuteDeque); AccessCountTableDeque secondDeque = new AccessCountTableDeque(tableEvictor); Integer numSeconds = (25 * 60 + 1) * 60; AccessCountTable firstFiveSeconds = new AccessCountTable( (numSeconds - 5) * Constants.ONE_SECOND_IN_MILLIS, numSeconds * Constants.ONE_SECOND_IN_MILLIS); AccessCountTable secondFiveSeconds = new AccessCountTable( numSeconds * Constants.ONE_SECOND_IN_MILLIS, (numSeconds + 5) * Constants.ONE_SECOND_IN_MILLIS); secondDeque.addAndNotifyListener(firstFiveSeconds); secondDeque.addAndNotifyListener(secondFiveSeconds); map.put(TimeGranularity.SECOND, secondDeque); List<AccessCountTable> firstResult = AccessCountTableManager.getTables( map, adapter, (numSeconds + 5) * Constants.ONE_SECOND_IN_MILLIS); Assert.assertTrue(firstResult.size() == 4); Assert.assertEquals(firstResult.get(0), firstDay); Assert.assertEquals(firstResult.get(1), secondHour); Assert.assertEquals(firstResult.get(2), secondMin); Assert.assertEquals(firstResult.get(3), secondFiveSeconds); List<AccessCountTable> secondResult = AccessCountTableManager.getTables( map, adapter, numSeconds * Constants.ONE_SECOND_IN_MILLIS); Assert.assertTrue(secondResult.size() == 4); AccessCountTable expectDay = new AccessCountTable(5 * Constants.ONE_SECOND_IN_MILLIS, Constants.ONE_DAY_IN_MILLIS); Assert.assertEquals(expectDay, secondResult.get(0)); List<AccessCountTable> thirdResult = AccessCountTableManager.getTables( map, adapter, secondFiveSeconds.getEndTime() - 23 * Constants.ONE_HOUR_IN_MILLIS); Assert.assertTrue(thirdResult.size() == 4); Assert.assertEquals(thirdResult.get(0), firstHour); List<AccessCountTable> fourthResult = AccessCountTableManager.getTables( map, adapter, secondFiveSeconds.getEndTime() - 24 * Constants.ONE_HOUR_IN_MILLIS); Assert.assertTrue(fourthResult.size() == 3); Assert.assertEquals(fourthResult.get(0), secondHour); }
public List<AccessCountTable> getTables(long lengthInMillis) throws MetaStoreException { return AccessCountTableManager.getTables(this.tableDeques, this.metaStore, lengthInMillis); }
AccessCountTableManager { public List<AccessCountTable> getTables(long lengthInMillis) throws MetaStoreException { return AccessCountTableManager.getTables(this.tableDeques, this.metaStore, lengthInMillis); } }
AccessCountTableManager { public List<AccessCountTable> getTables(long lengthInMillis) throws MetaStoreException { return AccessCountTableManager.getTables(this.tableDeques, this.metaStore, lengthInMillis); } AccessCountTableManager(MetaStore adapter);  AccessCountTableManager(MetaStore adapter, ExecutorService service); }
AccessCountTableManager { public List<AccessCountTable> getTables(long lengthInMillis) throws MetaStoreException { return AccessCountTableManager.getTables(this.tableDeques, this.metaStore, lengthInMillis); } AccessCountTableManager(MetaStore adapter);  AccessCountTableManager(MetaStore adapter, ExecutorService service); void addTable(AccessCountTable accessCountTable); void onAccessEventsArrived(List<FileAccessEvent> accessEvents); List<AccessCountTable> getTables(long lengthInMillis); static List<AccessCountTable> getTables(
      Map<TimeGranularity, AccessCountTableDeque> tableDeques,
      MetaStore metaStore,
      long lengthInMillis); }
AccessCountTableManager { public List<AccessCountTable> getTables(long lengthInMillis) throws MetaStoreException { return AccessCountTableManager.getTables(this.tableDeques, this.metaStore, lengthInMillis); } AccessCountTableManager(MetaStore adapter);  AccessCountTableManager(MetaStore adapter, ExecutorService service); void addTable(AccessCountTable accessCountTable); void onAccessEventsArrived(List<FileAccessEvent> accessEvents); List<AccessCountTable> getTables(long lengthInMillis); static List<AccessCountTable> getTables(
      Map<TimeGranularity, AccessCountTableDeque> tableDeques,
      MetaStore metaStore,
      long lengthInMillis); static final Logger LOG; }