Search in sources :

Example 31 with Reference

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);
}
Also used : Reference(java.lang.ref.Reference) WeakReference(java.lang.ref.WeakReference) HiveConf(org.apache.hadoop.hive.conf.HiveConf) Supplier(com.google.common.base.Supplier) IMetaStoreClient(org.apache.hadoop.hive.metastore.IMetaStoreClient)

Aggregations

Reference (java.lang.ref.Reference)31 WeakReference (java.lang.ref.WeakReference)17 PhantomReference (java.lang.ref.PhantomReference)10 ReferenceQueue (java.lang.ref.ReferenceQueue)10 SoftReference (java.lang.ref.SoftReference)10 Field (java.lang.reflect.Field)5 Map (java.util.Map)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 IOException (java.io.IOException)2 AccessControlContext (java.security.AccessControlContext)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Supplier (com.google.common.base.Supplier)1 SoftReference (com.intellij.reference.SoftReference)1 SideEffect (dalvik.annotation.SideEffect)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1