use of java.lang.ref.Reference in project cdap by caskdata.
the class BaseHiveExploreService method startUp.
@Override
protected void startUp() throws Exception {
LOG.info("Starting {}...", BaseHiveExploreService.class.getSimpleName());
HiveConf hiveConf = getHiveConf();
setupSparkConf();
cliService.init(hiveConf);
cliService.start();
metastoreClientsExecutorService.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
Reference<? extends Supplier<IMetaStoreClient>> ref = metastoreClientReferenceQueue.poll();
while (ref != null) {
IMetaStoreClient client = metastoreClientReferences.remove(ref);
if (client != null) {
closeMetastoreClient(client);
}
ref = metastoreClientReferenceQueue.poll();
}
}
}, METASTORE_CLIENT_CLEANUP_PERIOD, METASTORE_CLIENT_CLEANUP_PERIOD, TimeUnit.SECONDS);
// Schedule the cache cleanup
scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
runCacheCleanup();
}
}, cleanupJobSchedule, cleanupJobSchedule, TimeUnit.SECONDS);
}
Aggregations