/** {@inheritDoc} */ @Override protected void cleanup() { assert cancelled; // Cleanup can only be performed on a cancelled worker. // Clear interrupted flag. boolean interrupted = interrupted(); // Process the last batch if any. if (nextBatch != null) nextBatch.process(); onFinish(); // Reset interrupted flag. if (interrupted) interrupt(); }
/** {@inheritDoc} */ @Override public void stop() { busyLock.block(); // Clear interrupted flag temporarily. boolean interrupted = Thread.interrupted(); // Force all workers to finish their batches. for (GridGgfsFileWorker w : workerMap.values()) w.cancel(); // Wait for all writers to finish their execution. for (GridGgfsFileWorker w : workerMap.values()) { try { w.join(); } catch (InterruptedException e) { U.error(log, e.getMessage(), e); } } workerMap.clear(); if (secondaryFs instanceof AutoCloseable) U.closeQuiet((AutoCloseable)secondaryFs); ggfsCtx.kernalContext().io().removeMessageListener(topic, delMsgLsnr); ggfsCtx.kernalContext().event().removeLocalEventListener(delDiscoLsnr); if (interrupted) Thread.currentThread().interrupt(); }
/** * Await for any pending finished writes on the children paths. * * @param paths Paths to check. */ void await(GridGgfsPath... paths) { assert paths != null; for (Map.Entry<GridGgfsPath, GridGgfsFileWorker> workerEntry : workerMap.entrySet()) { GridGgfsPath workerPath = workerEntry.getKey(); boolean await = false; for (GridGgfsPath path : paths) { if (workerPath.isSubDirectoryOf(path) || workerPath.isSame(path)) { await = true; break; } } if (await) { GridGgfsFileWorkerBatch batch = workerEntry.getValue().currentBatch(); if (batch != null) { try { batch.awaitIfFinished(); } catch (GridException ignore) { // No-op. } } } } }
/** {@inheritDoc} */ @Override public void stop() { busyLock.block(); // Clear interrupted flag temporarily. boolean interrupted = Thread.interrupted(); // Force all workers to finish their batches. for (GridGgfsFileWorker w : workerMap.values()) w.cancel(); // Wait for all writers to finish their execution. for (GridGgfsFileWorker w : workerMap.values()) { try { w.join(); } catch (InterruptedException e) { U.error(log, e.getMessage(), e); } } workerMap.clear(); if (secondaryFs instanceof AutoCloseable) U.closeQuiet((AutoCloseable)secondaryFs); ggfsCtx.kernalContext().io().removeMessageListener(topic, delMsgLsnr); ggfsCtx.kernalContext().event().removeLocalEventListener(delDiscoLsnr); if (interrupted) Thread.currentThread().interrupt(); }
/** * Await for any pending finished writes on the children paths. * * @param paths Paths to check. */ void await(GridGgfsPath... paths) { assert paths != null; for (Map.Entry<GridGgfsPath, GridGgfsFileWorker> workerEntry : workerMap.entrySet()) { GridGgfsPath workerPath = workerEntry.getKey(); boolean await = false; for (GridGgfsPath path : paths) { if (workerPath.isSubDirectoryOf(path) || workerPath.isSame(path)) { await = true; break; } } if (await) { GridGgfsFileWorkerBatch batch = workerEntry.getValue().currentBatch(); if (batch != null) { try { batch.awaitIfFinished(); } catch (GridException ignore) { // No-op. } } } } }
/** {@inheritDoc} */ @Override protected void cleanup() { assert cancelled; // Cleanup can only be performed on a cancelled worker. // Clear interrupted flag. boolean interrupted = interrupted(); // Process the last batch if any. if (nextBatch != null) nextBatch.process(); onFinish(); // Reset interrupted flag. if (interrupted) interrupt(); }