/** {@inheritDoc} */ @Override public void stop(boolean cancel) { busyLock.block(); // Clear interrupted flag temporarily. boolean interrupted = Thread.interrupted(); if (secondaryFs != null) { // Force all workers to finish their batches. for (IgfsFileWorkerBatch batch : workerMap.values()) batch.cancel(); try { if (secondaryFs instanceof LifecycleAware) ((LifecycleAware)secondaryFs).stop(); } catch (Exception e) { log.error("Failed to close secondary file system.", e); } } // Restore interrupted flag. if (interrupted) Thread.currentThread().interrupt(); if (dualPool != null) dualPool.shutdownNow(); }
break; else prevBatch.await();
/** * Add the last task to that batch which will release all the resources. * * @return {@code True} if finish was signalled. */ synchronized boolean finish() { return offer(FINISH_MARKER, false, true); }
break; else prevBatch.await();
/** * Cancel batch processing. * * @return {@code True} if cancel was signalled. */ synchronized boolean cancel() { return offer(CANCEL_MARKER, true, true); }
/** {@inheritDoc} */ @Override public void stop(boolean cancel) { busyLock.block(); // Clear interrupted flag temporarily. boolean interrupted = Thread.interrupted(); if (secondaryFs != null) { // Force all workers to finish their batches. for (IgfsFileWorkerBatch batch : workerMap.values()) batch.cancel(); try { if (secondaryFs instanceof LifecycleAware) ((LifecycleAware)secondaryFs).stop(); } catch (Exception e) { log.error("Failed to close secondary file system.", e); } } // Restore interrupted flag. if (interrupted) Thread.currentThread().interrupt(); if (dualPool != null) dualPool.shutdownNow(); }
/** * Perform write if batch is not finishing yet. * * @param data Data to be written. * @return {@code True} in case write was enqueued. */ synchronized boolean write(final byte[] data) { return offer(data, false, false); }
/** * Cancel batch processing. * * @return {@code True} if cancel was signalled. */ synchronized boolean cancel() { return offer(CANCEL_MARKER, true, true); }