/** * Cancels the recovery and interrupts all eligible threads. */ public void cancel(String reason) { cancellableThreads.cancel(reason); }
@Override public void close() throws IOException { try { if (closed.compareAndSet(false, true)) { cancellableThreads.cancel("connect handler is closed"); running.acquire(); // acquire the semaphore to ensure all connections are closed and all thread joined running.release(); maybeConnect(); // now go and notify pending listeners } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
/** * cancel the recovery. calling this method will clean temporary files and release the store * unless this object is in use (in which case it will be cleaned once all ongoing users call * {@link #decRef()} * <p> * if {@link #cancellableThreads()} was used, the threads will be interrupted. */ public void cancel(String reason) { if (finished.compareAndSet(false, true)) { try { logger.debug("recovery canceled (reason: [{}])", reason); cancellableThreads.cancel(reason); } finally { // release the initial reference. recovery files will be cleaned as soon as ref count goes to zero, potentially now decRef(); } } }
/** * fail the recovery and call listener * * @param e exception that encapsulating the failure * @param sendShardFailure indicates whether to notify the master of the shard failure */ public void fail(RecoveryFailedException e, boolean sendShardFailure) { if (finished.compareAndSet(false, true)) { try { notifyListener(e, sendShardFailure); } finally { try { cancellableThreads.cancel("failed recovery [" + ExceptionsHelper.stackTrace(e) + "]"); } finally { // release the initial reference. recovery files will be cleaned as soon as ref count goes to zero, potentially now decRef(); } } } }
/** * Cancels the recovery and interrupts all eligible threads. */ public void cancel(String reason) { cancellableThreads.cancel(reason); }
/** * Cancels the recovery and interrupts all eligible threads. */ public void cancel(String reason) { cancellableThreads.cancel(reason); }
/** * Cancels the recovery and interrupts all eligible threads. */ public void cancel(String reason) { cancellableThreads.cancel(reason); }
/** * Cancels the recovery and interrupts all eligible threads. */ public void cancel(String reason) { cancellableThreads.cancel(reason); }
@Override public void close() { cancellableThreads.cancel("closed"); } }
@Override public void close() throws IOException { try { if (closed.compareAndSet(false, true)) { cancellableThreads.cancel("connect handler is closed"); running.acquire(); // acquire the semaphore to ensure all connections are closed and all thread joined running.release(); maybeConnect(); // now go and notify pending listeners } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
@Override public void close() throws IOException { try { if (closed.compareAndSet(false, true)) { cancellableThreads.cancel("connect handler is closed"); running.acquire(); // acquire the semaphore to ensure all connections are closed and all thread joined running.release(); maybeConnect(); // now go and notify pending listeners } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
@Override public void close() throws IOException { try { if (closed.compareAndSet(false, true)) { cancellableThreads.cancel("connect handler is closed"); running.acquire(); // acquire the semaphore to ensure all connections are closed and all thread joined running.release(); maybeConnect(); // now go and notify pending listeners } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
/** * cancel the recovery. calling this method will clean temporary files and release the store * unless this object is in use (in which case it will be cleaned once all ongoing users call * {@link #decRef()} * <p> * if {@link #CancellableThreads()} was used, the threads will be interrupted. */ public void cancel(String reason) { if (finished.compareAndSet(false, true)) { try { logger.debug("recovery canceled (reason: [{}])", reason); cancellableThreads.cancel(reason); } finally { // release the initial reference. recovery files will be cleaned as soon as ref count goes to zero, potentially now decRef(); } } }
/** * cancel the recovery. calling this method will clean temporary files and release the store * unless this object is in use (in which case it will be cleaned once all ongoing users call * {@link #decRef()} * <p> * if {@link #cancellableThreads()} was used, the threads will be interrupted. */ public void cancel(String reason) { if (finished.compareAndSet(false, true)) { try { logger.debug("recovery canceled (reason: [{}])", reason); cancellableThreads.cancel(reason); } finally { // release the initial reference. recovery files will be cleaned as soon as ref count goes to zero, potentially now decRef(); } } }
/** * cancel the recovery. calling this method will clean temporary files and release the store * unless this object is in use (in which case it will be cleaned once all ongoing users call * {@link #decRef()} * <p> * if {@link #cancellableThreads()} was used, the threads will be interrupted. */ public void cancel(String reason) { if (finished.compareAndSet(false, true)) { try { logger.debug("recovery canceled (reason: [{}])", reason); cancellableThreads.cancel(reason); } finally { // release the initial reference. recovery files will be cleaned as soon as ref count goes to zero, potentially now decRef(); } } }
public synchronized void close0() throws IOException { // establish a happens-before edge between closing and accepting a new connection // we have to sync this entire block to ensure that our openChannels checks work correctly. // The close block below will close all worker channels but if one of the worker channels runs into an exception // for instance due to a disconnect the handling of this exception might be executed concurrently. // now if we are in-turn concurrently call close we might not wait for the actual close to happen and that will, down the road // make the assertion trip that not all channels are closed. if (isOpen.compareAndSet(true, false)) { final boolean removedChannel; synchronized (openChannels) { removedChannel = openChannels.remove(this); } IOUtils.close(serverSocket, activeChannel, () -> IOUtils.close(workerChannels), () -> cancellableThreads.cancel("channel closed"), onClose); assert removedChannel: "Channel was not removed or removed twice?"; } }
/** * cancel the recovery. calling this method will clean temporary files and release the store * unless this object is in use (in which case it will be cleaned once all ongoing users call * {@link #decRef()} * <p> * if {@link #CancellableThreads()} was used, the threads will be interrupted. */ public void cancel(String reason) { if (finished.compareAndSet(false, true)) { try { logger.debug("recovery canceled (reason: [{}])", reason); cancellableThreads.cancel(reason); } finally { // release the initial reference. recovery files will be cleaned as soon as ref count goes to zero, potentially now decRef(); } } }
/** * fail the recovery and call listener * * @param e exception that encapsulating the failure * @param sendShardFailure indicates whether to notify the master of the shard failure */ public void fail(RecoveryFailedException e, boolean sendShardFailure) { if (finished.compareAndSet(false, true)) { try { notifyListener(e, sendShardFailure); } finally { try { cancellableThreads.cancel("failed recovery [" + ExceptionsHelper.stackTrace(e) + "]"); } finally { // release the initial reference. recovery files will be cleaned as soon as ref count goes to zero, potentially now decRef(); } } } }
/** * fail the recovery and call listener * * @param e exception that encapsulating the failure * @param sendShardFailure indicates whether to notify the master of the shard failure */ public void fail(RecoveryFailedException e, boolean sendShardFailure) { if (finished.compareAndSet(false, true)) { try { notifyListener(e, sendShardFailure); } finally { try { cancellableThreads.cancel("failed recovery [" + ExceptionsHelper.stackTrace(e) + "]"); } finally { // release the initial reference. recovery files will be cleaned as soon as ref count goes to zero, potentially now decRef(); } } } }
/** * fail the recovery and call listener * * @param e exception that encapsulating the failure * @param sendShardFailure indicates whether to notify the master of the shard failure */ public void fail(RecoveryFailedException e, boolean sendShardFailure) { if (finished.compareAndSet(false, true)) { try { listener.onRecoveryFailure(state(), e, sendShardFailure); } finally { try { cancellableThreads.cancel("failed recovery [" + e.getMessage() + "]"); } finally { // release the initial reference. recovery files will be cleaned as soon as ref count goes to zero, potentially now decRef(); } } } }