HTableDescriptor[] tableList(HbaseSource hbaseSourceInstance) throws MasterNotRunningException {
if (tableDescriptors == null || tableDescriptorsExpired()) {
tableDescriptors = getHBaseClient(hbaseSourceInstance).listTables()
lastRefreshTs = System.currentTimeMillis()
}
return tableDescriptors
}
boolean tableDescriptorsExpired() {
if ((System.currentTimeMillis() - lastRefreshTs) > TWO_MINUTES) {
return true;
}
return false;
}
extract method #forceRefresh and call when tables are changed
I've moved descriptors cache to ConfigHolder object as they should be cached on per HbaseSource basis. Combined with a simple time based invalidation in cache getter.