List of usage examples for com.google.common.util.concurrent Runnables doNothing
public static Runnable doNothing()
From source file:io.pravega.common.concurrent.AbstractThreadPoolService.java
@Override protected void doStop() { Exceptions.checkNotClosed(this.closed.get(), this); log.info("{}: Stopping.", this.traceObjectId); ExecutorServiceHelpers.execute(() -> { Throwable cause = this.stopException.get(); // Cancel the last iteration and wait for it to finish. if (this.runTask != null) { try { // This doesn't actually cancel the task. We need to plumb through the code with 'checkRunning' to // make sure we stop any long-running tasks. this.runTask.get(getShutdownTimeout().toMillis(), TimeUnit.MILLISECONDS); this.runTask = null; } catch (Exception ex) { Throwable realEx = ExceptionHelpers.getRealException(ex); if (cause == null) { // CancellationExceptions are expected if we are shutting down the service; If this was the real // cause why runTask failed, then the service did not actually fail, so do not report a bogus exception. if (!(realEx instanceof CancellationException)) { cause = realEx;/*from ww w. j av a 2s . c o m*/ } } else if (cause != realEx) { cause.addSuppressed(realEx); } } } if (cause == null) { // Normal shutdown. notifyStopped(); } else { // Shutdown caused by some failure. notifyFailed(cause); } log.info("{}: Stopped.", this.traceObjectId); }, this::notifyFailed, Runnables.doNothing(), this.executor); }
From source file:com.dmdirc.addons.ui_swing.dialogs.StandardInputDialog.java
/** * Instantiates a new standard input dialog. * * @param owner Dialog owner/*from w w w. j av a 2 s . c om*/ * @param modal modality type * @param iconManager The icon manager to use for validating text fields. * @param validator Textfield validator * @param title Dialog title * @param message Dialog message */ public StandardInputDialog(final Window owner, final ModalityType modal, final IconManager iconManager, final String title, final String message, final Validator<String> validator, final Consumer<String> save) { this(owner, modal, iconManager, title, message, validator, (final String s) -> { save.accept(s); return true; }, Runnables.doNothing()); }
From source file:com.dmdirc.addons.ui_swing.dialogs.StandardInputDialog.java
/** * Instantiates a new standard input dialog. * * @param owner Dialog owner//w w w .ja v a2s .c o m * @param modal modality type * @param iconManager The icon manager to use for validating text fields. * @param validator Textfield validator * @param title Dialog title * @param message Dialog message */ public StandardInputDialog(final Window owner, final ModalityType modal, final IconManager iconManager, final String title, final String message, final Validator<String> validator, final Function<String, Boolean> save) { this(owner, modal, iconManager, title, message, validator, save, Runnables.doNothing()); }
From source file:io.pravega.service.server.containers.StreamSegmentContainer.java
@Override protected void doStart() { long traceId = LoggerHelpers.traceEnterWithContext(log, traceObjectId, "doStart"); log.info("{}: Starting.", this.traceObjectId); this.durableLog.startAsync(); ExecutorServiceHelpers.execute(() -> { this.durableLog.awaitRunning(); this.storage.initialize(this.metadata.getContainerEpoch()); // DurableLog is running. Now start all other components that depend on it. this.metadataCleaner.startAsync(); this.writer.startAsync(); this.writer.awaitRunning(); this.metadataCleaner.awaitRunning(); log.info("{}: Started.", this.traceObjectId); LoggerHelpers.traceLeave(log, traceObjectId, "doStart", traceId); notifyStarted();/*from w w w . j a va2 s . c om*/ }, this::doStop, Runnables.doNothing(), this.executor); }
From source file:io.pravega.service.server.logs.DurableLog.java
@Override protected void doStop() { long traceId = LoggerHelpers.traceEnterWithContext(log, traceObjectId, "doStop"); log.info("{}: Stopping.", this.traceObjectId); this.operationProcessor.stopAsync(); ExecutorServiceHelpers.execute(() -> { ServiceShutdownListener.awaitShutdown(this.operationProcessor, false); cancelTailReads();/*from www . j av a 2s . c o m*/ this.durableDataLog.close(); Throwable cause = this.stopException.get(); if (cause == null && this.operationProcessor.state() == State.FAILED) { cause = this.operationProcessor.failureCause(); } if (cause == null) { // Normal shutdown. notifyStopped(); } else { // Shutdown caused by some failure. notifyFailed(cause); } log.info("{}: Stopped.", this.traceObjectId); LoggerHelpers.traceLeave(log, traceObjectId, "doStop", traceId); }, this::notifyFailed, Runnables.doNothing(), this.executor); }
From source file:com.google.gerrit.server.account.externalids.ExternalIdsUpdate.java
private ExternalIdsUpdate(GitRepositoryManager repoManager, AllUsersName allUsersName, MetricMaker metricMaker, ExternalIds externalIds, ExternalIdCache externalIdCache, PersonIdent committerIdent, PersonIdent authorIdent) {//from w ww. j av a 2s .c om this(repoManager, allUsersName, metricMaker, externalIds, externalIdCache, committerIdent, authorIdent, Runnables.doNothing(), RETRYER); }
From source file:com.addthis.hydra.task.output.tree.PathPrune.java
/** * It is bad practice use the shutdown hook mechanism as a way * to test whether the JVM is shutting down. However if we use * this method exactly once then it is useful when writing tests * to ensure that zero prune operations occur during shutdown. * * @return true iff the jvm is shutting down *//*from w w w . j a v a2s . co m*/ private static boolean expensiveShutdownTest() { try { Thread shutdownHook = new Thread(Runnables.doNothing(), "Path prune shutdown hook"); Runtime.getRuntime().addShutdownHook(shutdownHook); Runtime.getRuntime().removeShutdownHook(shutdownHook); } catch (IllegalStateException ignored) { return true; } return false; }
From source file:org.apache.brooklyn.core.mgmt.EntityManagementUtils.java
public static CreationResult<List<Entity>, List<String>> addChildrenStarting(final Entity parent, String yaml) { final List<Entity> children = addChildrenUnstarted(parent, yaml); String childrenCountString;/*from w w w.j a v a 2 s . c o m*/ int size = children.size(); childrenCountString = size + " " + (size != 1 ? "children" : "child"); TaskBuilder<List<String>> taskM = Tasks.<List<String>>builder().displayName("add children").dynamic(true) .tag(BrooklynTaskTags.NON_TRANSIENT_TASK_TAG).body(new Callable<List<String>>() { @Override public List<String> call() throws Exception { return ImmutableList.copyOf(Iterables.transform(children, EntityFunctions.id())); } }).description("Add and start " + childrenCountString); TaskBuilder<?> taskS = Tasks.builder().parallel(true).displayName("add (parallel)") .description("Start each new entity"); // autostart if requested for (Entity child : children) { if (child instanceof Startable) { taskS.add(Effectors.invocation(child, Startable.START, ImmutableMap.of("locations", ImmutableList.of()))); } else { // include a task, just to give feedback in the GUI taskS.add(Tasks.builder().displayName("create") .description("Skipping start (not a Startable Entity)").body(Runnables.doNothing()) .tag(BrooklynTaskTags.tagForTargetEntity(child)).build()); } } taskM.add(taskS.build()); Task<List<String>> task = Entities.submit(parent, taskM.build()); return CreationResult.of(children, task); }
From source file:io.pravega.service.server.containers.StreamSegmentContainer.java
/** * Stops the StreamSegmentContainer by stopping all components, waiting for them to stop, and reports a normal * shutdown or failure based on case. It will report a normal shutdown only if all components shut down normally * and cause is null. Otherwise, the container will report either the exception of the failed component, or the * given cause./*from www . ja va 2 s.c o m*/ * * @param cause (Optional) The failure cause. If any of the components failed as well, this will be added as a * suppressed exception to the Service's failure cause. */ private void doStop(Throwable cause) { long traceId = LoggerHelpers.traceEnterWithContext(log, traceObjectId, "doStop"); log.info("{}: Stopping.", this.traceObjectId); this.metadataCleaner.stopAsync(); this.writer.stopAsync(); this.durableLog.stopAsync(); ExecutorServiceHelpers.execute(() -> { ServiceShutdownListener.awaitShutdown(this.metadataCleaner, false); ServiceShutdownListener.awaitShutdown(this.writer, false); ServiceShutdownListener.awaitShutdown(this.durableLog, false); Throwable failureCause = getFailureCause(this.durableLog, this.writer, this.metadataCleaner); if (failureCause == null) { failureCause = cause; } else if (cause != null && failureCause != cause) { failureCause.addSuppressed(cause); } if (failureCause == null) { // Normal shutdown log.info("{}: Stopped.", this.traceObjectId); LoggerHelpers.traceLeave(log, traceObjectId, "doStop", traceId); notifyStopped(); } else { // Shutting down due to failure. log.warn("{}: Failed due to component failure.", this.traceObjectId); LoggerHelpers.traceLeave(log, traceObjectId, "doStop", traceId); notifyFailed(failureCause); } }, this::notifyFailed, Runnables.doNothing(), this.executor); }
From source file:org.apache.cassandra.db.lifecycle.LogTransaction.java
static void waitForDeletions() { FBUtilities.waitOnFuture( ScheduledExecutors.nonPeriodicTasks.schedule(Runnables.doNothing(), 0, TimeUnit.MILLISECONDS)); }