Search in sources :

Example 6 with TimeGranularity

use of org.smartdata.metastore.utils.TimeGranularity in project SSM by Intel-bigdata.

the class TestAccessCountTableManager method testGetTablesCornerCase2.

@Test
public void testGetTablesCornerCase2() throws MetaStoreException {
    MetaStore adapter = mock(MetaStore.class);
    TableEvictor tableEvictor = new CountEvictor(adapter, 20);
    Map<TimeGranularity, AccessCountTableDeque> map = new HashMap<>();
    AccessCountTableDeque minute = new AccessCountTableDeque(tableEvictor);
    AccessCountTable firstMinute = new AccessCountTable(0L, Constants.ONE_MINUTE_IN_MILLIS);
    minute.addAndNotifyListener(firstMinute);
    map.put(TimeGranularity.MINUTE, minute);
    AccessCountTableDeque secondDeque = new AccessCountTableDeque(tableEvictor);
    AccessCountTable firstFiveSeconds = new AccessCountTable(55 * Constants.ONE_SECOND_IN_MILLIS, 60 * Constants.ONE_SECOND_IN_MILLIS);
    AccessCountTable secondFiveSeconds = new AccessCountTable(60 * Constants.ONE_SECOND_IN_MILLIS, 65 * Constants.ONE_SECOND_IN_MILLIS);
    AccessCountTable thirdFiveSeconds = new AccessCountTable(110 * Constants.ONE_SECOND_IN_MILLIS, 115 * Constants.ONE_SECOND_IN_MILLIS);
    secondDeque.addAndNotifyListener(firstFiveSeconds);
    secondDeque.addAndNotifyListener(secondFiveSeconds);
    secondDeque.addAndNotifyListener(thirdFiveSeconds);
    map.put(TimeGranularity.SECOND, secondDeque);
    List<AccessCountTable> result = AccessCountTableManager.getTables(map, adapter, Constants.ONE_MINUTE_IN_MILLIS);
    Assert.assertTrue(result.size() == 3);
    Assert.assertTrue(result.get(0).equals(firstFiveSeconds));
    Assert.assertFalse(result.get(0).isEphemeral());
    Assert.assertTrue(result.get(1).equals(secondFiveSeconds));
    Assert.assertTrue(result.get(2).equals(thirdFiveSeconds));
}
Also used : MetaStore(org.smartdata.metastore.MetaStore) HashMap(java.util.HashMap) TimeGranularity(org.smartdata.metastore.utils.TimeGranularity) DBTest(org.smartdata.metastore.DBTest) Test(org.junit.Test)

Aggregations

TimeGranularity (org.smartdata.metastore.utils.TimeGranularity)6 Test (org.junit.Test)4 DBTest (org.smartdata.metastore.DBTest)4 MetaStore (org.smartdata.metastore.MetaStore)4 HashMap (java.util.HashMap)3 ArrayList (java.util.ArrayList)1