@Test public void testEvictHiveCache() throws Exception { String useDbName = "default"; String tableName = "tableName"; List<String> databases = Arrays.asList(useDbName); given(client.getAllDatabases()).willReturn(databases); given(client.getAllTables(databases.get(0))).willReturn(Arrays .asList(tableName)); given(client.getTable(useDbName, tableName)).willReturn(new Table()); assertEquals(service.getAllTable().size(), 1); verify(client).getAllDatabases(); verify(client).getAllTables(useDbName); verify(client).getTable(useDbName, tableName); service.getAllTable(); verifyNoMoreInteractions(client); service.evictHiveCache(); service.getAllTable().size(); service.getAllTable().size(); verify(client, times(2)).getAllDatabases(); verify(client, times(2)).getAllTables(useDbName); verify(client, times(2)).getTable(useDbName, tableName); }
@Scheduled(fixedRateString = "${cache.evict.hive.fixedRate.in.milliseconds}") @CacheEvict( cacheNames = "hive", allEntries = true, beforeInvocation = true) public void evictHiveCache() { LOGGER.info("Evict hive cache"); }
HiveMetaStoreServiceImpl implements HiveMetaStoreService { @Scheduled(fixedRateString = "${cache.evict.hive.fixedRate.in.milliseconds}") @CacheEvict( cacheNames = "hive", allEntries = true, beforeInvocation = true) public void evictHiveCache() { LOGGER.info("Evict hive cache"); } }
HiveMetaStoreServiceImpl implements HiveMetaStoreService { @Scheduled(fixedRateString = "${cache.evict.hive.fixedRate.in.milliseconds}") @CacheEvict( cacheNames = "hive", allEntries = true, beforeInvocation = true) public void evictHiveCache() { LOGGER.info("Evict hive cache"); } HiveMetaStoreServiceImpl(); }
HiveMetaStoreServiceImpl implements HiveMetaStoreService { @Scheduled(fixedRateString = "${cache.evict.hive.fixedRate.in.milliseconds}") @CacheEvict( cacheNames = "hive", allEntries = true, beforeInvocation = true) public void evictHiveCache() { LOGGER.info("Evict hive cache"); } HiveMetaStoreServiceImpl(); void setClient(IMetaStoreClient client); @Override @Cacheable(unless = "#result==null") Iterable<String> getAllDatabases(); @Override @Cacheable(unless = "#result==null") Iterable<String> getAllTableNames(String dbName); @Override @Cacheable(unless = "#result==null || #result.isEmpty()") List<Table> getAllTable(String db); @Override @Cacheable(unless = "#result==null || #result.isEmpty()") Map<String, List<String>> getAllTableNames(); @Override @Cacheable(unless = "#result==null") Map<String, List<Table>> getAllTable(); @Override @Cacheable(unless = "#result==null") Table getTable(String dbName, String tableName); @Scheduled(fixedRateString = "${cache.evict.hive.fixedRate.in.milliseconds}") @CacheEvict( cacheNames = "hive", allEntries = true, beforeInvocation = true) void evictHiveCache(); }
HiveMetaStoreServiceImpl implements HiveMetaStoreService { @Scheduled(fixedRateString = "${cache.evict.hive.fixedRate.in.milliseconds}") @CacheEvict( cacheNames = "hive", allEntries = true, beforeInvocation = true) public void evictHiveCache() { LOGGER.info("Evict hive cache"); } HiveMetaStoreServiceImpl(); void setClient(IMetaStoreClient client); @Override @Cacheable(unless = "#result==null") Iterable<String> getAllDatabases(); @Override @Cacheable(unless = "#result==null") Iterable<String> getAllTableNames(String dbName); @Override @Cacheable(unless = "#result==null || #result.isEmpty()") List<Table> getAllTable(String db); @Override @Cacheable(unless = "#result==null || #result.isEmpty()") Map<String, List<String>> getAllTableNames(); @Override @Cacheable(unless = "#result==null") Map<String, List<Table>> getAllTable(); @Override @Cacheable(unless = "#result==null") Table getTable(String dbName, String tableName); @Scheduled(fixedRateString = "${cache.evict.hive.fixedRate.in.milliseconds}") @CacheEvict( cacheNames = "hive", allEntries = true, beforeInvocation = true) void evictHiveCache();  }