@Override public Thread newThread(Runnable runnable) { Thread newThread = new ThreadWithGarbageCleanup(runnable); newThread.setName(namePrefix + ": Thread-" + newThread.getId()); return newThread; }
private synchronized void releaseBeforeOpLock(boolean userAccess) { if (sessionState != null) { // can be null in-case of junit tests. skip reset. // reset thread name at release time. sessionState.resetThreadName(); } SessionState.detachSession(); if (ThreadWithGarbageCleanup.currentThread() instanceof ThreadWithGarbageCleanup) { ThreadWithGarbageCleanup currentThread = (ThreadWithGarbageCleanup) ThreadWithGarbageCleanup.currentThread(); currentThread.cacheThreadLocalRawStore(); } if (userAccess) { lastAccessTime = System.currentTimeMillis(); lockedByUser = false; } }
/** * Add any Thread specific garbage cleanup code here. * Currently, it shuts down the RawStore object for this thread if it is not null. */ @Override public void finalize() throws Throwable { cleanRawStore(); super.finalize(); }
private void cleanRawStore() { Long threadId = this.getId(); RawStore threadLocalRawStore = threadRawStoreMap.get(threadId); if (threadLocalRawStore != null) { LOG.debug("RawStore: " + threadLocalRawStore + ", for the thread: " + this.getName() + " will be closed now."); threadLocalRawStore.shutdown(); threadRawStoreMap.remove(threadId); } }
/** * Cache the ThreadLocal RawStore object. Called from the corresponding thread. */ public void cacheThreadLocalRawStore() { Long threadId = this.getId(); RawStore threadLocalRawStore = HiveMetaStore.HMSHandler.getRawStore(); if (threadLocalRawStore == null) { LOG.debug("Thread Local RawStore is null, for the thread: " + this.getName() + " and so removing entry from threadRawStoreMap."); threadRawStoreMap.remove(threadId); } else { LOG.debug("Adding RawStore: " + threadLocalRawStore + ", for the thread: " + this.getName() + " to threadRawStoreMap for future cleanup."); threadRawStoreMap.put(threadId, threadLocalRawStore); } } }
private void cleanRawStore() { Long threadId = this.getId(); RawStore threadLocalRawStore = threadRawStoreMap.get(threadId); if (threadLocalRawStore != null) { LOG.debug("RawStore: " + threadLocalRawStore + ", for the thread: " + this.getName() + " will be closed now."); threadLocalRawStore.shutdown(); threadRawStoreMap.remove(threadId); } }
if (ThreadWithGarbageCleanup.currentThread() instanceof ThreadWithGarbageCleanup) { ThreadWithGarbageCleanup currentThread = (ThreadWithGarbageCleanup) ThreadWithGarbageCleanup.currentThread(); currentThread.cacheThreadLocalRawStore();
@Override public Thread newThread(Runnable runnable) { Thread newThread = new ThreadWithGarbageCleanup(runnable); newThread.setName(namePrefix + ": Thread-" + newThread.getId()); return newThread; }
/** * Add any Thread specific garbage cleanup code here. * Currently, it shuts down the RawStore object for this thread if it is not null. */ @Override public void finalize() throws Throwable { cleanRawStore(); super.finalize(); }
private void cleanRawStore() { Long threadId = this.getId(); RawStore threadLocalRawStore = threadRawStoreMap.get(threadId); if (threadLocalRawStore != null) { LOG.debug("RawStore: " + threadLocalRawStore + ", for the thread: " + this.getName() + " will be closed now."); threadLocalRawStore.shutdown(); threadRawStoreMap.remove(threadId); } }
/** * 1. We'll remove the ThreadLocal SessionState as this thread might now serve * other requests. * 2. We'll cache the ThreadLocal RawStore object for this background thread for an orderly cleanup * when this thread is garbage collected later. * @see org.apache.hive.service.server.ThreadWithGarbageCleanup#finalize() */ protected synchronized void release(boolean userAccess) { SessionState.detachSession(); if (ThreadWithGarbageCleanup.currentThread() instanceof ThreadWithGarbageCleanup) { ThreadWithGarbageCleanup currentThread = (ThreadWithGarbageCleanup) ThreadWithGarbageCleanup.currentThread(); currentThread.cacheThreadLocalRawStore(); } if (userAccess) { lastAccessTime = System.currentTimeMillis(); } if (opHandleSet.isEmpty()) { lastIdleTime = System.currentTimeMillis(); } else { lastIdleTime = 0; } }
@Override public Thread newThread(Runnable runnable) { Thread newThread = new ThreadWithGarbageCleanup(runnable); newThread.setName(namePrefix + ": Thread-" + newThread.getId()); return newThread; }
/** * Add any Thread specific garbage cleanup code here. * Currently, it shuts down the RawStore object for this thread if it is not null. */ @Override public void finalize() throws Throwable { cleanRawStore(); super.finalize(); }
private void cleanRawStore() { Long threadId = this.getId(); RawStore threadLocalRawStore = threadRawStoreMap.get(threadId); if (threadLocalRawStore != null) { LOG.debug("RawStore: " + threadLocalRawStore + ", for the thread: " + this.getName() + " will be closed now."); threadLocalRawStore.shutdown(); threadRawStoreMap.remove(threadId); } }
private synchronized void releaseBeforeOpLock(boolean userAccess) { if (sessionState != null) { // can be null in-case of junit tests. skip reset. // reset thread name at release time. sessionState.resetThreadName(); } SessionState.detachSession(); if (ThreadWithGarbageCleanup.currentThread() instanceof ThreadWithGarbageCleanup) { ThreadWithGarbageCleanup currentThread = (ThreadWithGarbageCleanup) ThreadWithGarbageCleanup.currentThread(); currentThread.cacheThreadLocalRawStore(); } if (userAccess) { lastAccessTime = System.currentTimeMillis(); lockedByUser = false; } }
@Override public Thread newThread(Runnable runnable) { Thread newThread = new ThreadWithGarbageCleanup(runnable); newThread.setName(namePrefix + ": Thread-" + newThread.getId()); return newThread; }
/** * Add any Thread specific garbage cleanup code here. * Currently, it shuts down the RawStore object for this thread if it is not null. */ @Override public void finalize() throws Throwable { cleanRawStore(); super.finalize(); }
private void cleanRawStore() { Long threadId = this.getId(); RawStore threadLocalRawStore = threadRawStoreMap.get(threadId); if (threadLocalRawStore != null) { LOG.debug("RawStore: " + threadLocalRawStore + ", for the thread: " + this.getName() + " will be closed now."); threadLocalRawStore.shutdown(); threadRawStoreMap.remove(threadId); } }
/** * 1. We'll remove the ThreadLocal SessionState as this thread might now serve * other requests. * 2. We'll cache the ThreadLocal RawStore object for this background thread for an orderly cleanup * when this thread is garbage collected later. * @see org.apache.hive.service.server.ThreadWithGarbageCleanup#finalize() */ protected synchronized void release(boolean userAccess) { SessionState.detachSession(); if (ThreadWithGarbageCleanup.currentThread() instanceof ThreadWithGarbageCleanup) { ThreadWithGarbageCleanup currentThread = (ThreadWithGarbageCleanup) ThreadWithGarbageCleanup.currentThread(); currentThread.cacheThreadLocalRawStore(); } if (userAccess) { lastAccessTime = System.currentTimeMillis(); } if (opHandleSet.isEmpty()) { lastIdleTime = System.currentTimeMillis(); } else { lastIdleTime = 0; } }
@Override public Thread newThread(Runnable runnable) { Thread newThread = new ThreadWithGarbageCleanup(runnable); newThread.setName(namePrefix + ": Thread-" + newThread.getId()); return newThread; }