return createNewResource();
/** * Acquires an object of type {@code T} from the pool. This operation is blocking if no resource * is available. Each call of {@link #acquire()} should be paired with another call of * {@link #release(Object)}} after the use of this resource completes to return this resource to * the pool. * * @return a resource taken from the pool */ @Override public T acquire() { return acquire(WAIT_INDEFINITELY, null); }
/** * Checks whether anyone is using the block lock for the given block id, returning the lock to * the lock pool if it is unused. * * @param blockId the block id for which to potentially release the block lock */ private void releaseBlockLockIfUnused(long blockId) { synchronized (mSharedMapsLock) { ClientRWLock lock = mLocks.get(blockId); if (lock == null) { // Someone else probably released the block lock already. return; } // If we were the last worker with a reference to the lock, clean it up. if (lock.dropReference() == 0) { mLocks.remove(blockId); mLockPool.release(lock); } } }
/** * Acquires an object of type {@code T} from the pool. This operation is blocking if no resource * is available. Each call of {@link #acquire()} should be paired with another call of * {@link #release(Object)}} after the use of this resource completes to return this resource to * the pool. * * @return a resource taken from the pool */ @Override public T acquire() { return acquire(WAIT_INDEFINITELY, null); }
@Override public void release(BlockWorkerClient blockWorkerClient) { try { // Heartbeat to send the client metrics. blockWorkerClient.sessionHeartbeat(); } catch (Exception e) { LOG.warn("Failed sending client metrics before releasing the worker client", e); } blockWorkerClient.createNewSession(ClientUtils.getRandomNonNegativeLong()); super.release(blockWorkerClient); }