Java Code Examples for org.jboss.msc.service.StopContext#complete()
The following examples show how to use
org.jboss.msc.service.StopContext#complete() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockerExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void stop(final StopContext context) { if (!blockStart) { try { synchronized (waitObject) { log.info("BlockService blocking in stop"); waitObject.wait(blockTime); } context.complete(); } catch (InterruptedException e) { log.info("BlockService interrupted"); Thread.currentThread().interrupt(); throw new RuntimeException(e); } } else { synchronized (waitObject) { log.info("BlockService Stopping"); waitObject.notifyAll(); } } }
Example 2
Source File: HostControllerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public synchronized void stop(final StopContext context) { Runnable r = new Runnable() { @Override public void run() { try { scheduledExecutorService.shutdown(); } finally { scheduledExecutorService = null; context.complete(); } } }; try { executorInjector.getValue().execute(r); } catch (RejectedExecutionException e) { r.run(); } finally { context.asynchronous(); } }
Example 3
Source File: RemoteDomainConnectionService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** {@inheritDoc} */ @Override public synchronized void stop(final StopContext context) { Runnable r = new Runnable() { @Override public void run() { try { StreamUtils.safeClose(connection); responseAttachmentSupport.shutdown(); } finally { context.complete(); } } }; try { executor.execute(r); } catch (RejectedExecutionException e) { r.run(); } finally { context.asynchronous(); } }
Example 4
Source File: DiscoveryService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** {@inheritDoc} */ @Override public synchronized void stop(final StopContext context) { final Runnable task = new Runnable() { @Override public void run() { try { if (isMasterDomainController && (discoveryOptions != null)) { for (DiscoveryOption discoveryOption : discoveryOptions) { discoveryOption.cleanUp(); } } } finally { context.complete(); } } }; try { executorService.getValue().execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } }
Example 5
Source File: HostControllerConnectionService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public synchronized void stop(final StopContext stopContext) { final ExecutorService executorService = executorSupplier.get(); final Runnable task = new Runnable() { @Override public void run() { try { responseAttachmentSupport.shutdown(); } finally { StreamUtils.safeClose(client); client = null; stopContext.complete(); } } }; try { executorService.execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { stopContext.asynchronous(); } }
Example 6
Source File: ServerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public synchronized void stop(final StopContext context) { Runnable r = new Runnable() { @Override public void run() { try { scheduledExecutorService.shutdown(); } finally { scheduledExecutorService = null; context.complete(); } } }; try { executorInjector.getValue().execute(r); } catch (RejectedExecutionException e) { r.run(); } finally { context.asynchronous(); } }
Example 7
Source File: HostControllerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public synchronized void stop(final StopContext context) { Thread executorShutdown = new Thread(new Runnable() { @Override public void run() { boolean interrupted = false; try { executorService.shutdown(); executorService.awaitTermination(100, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { interrupted = true; } finally { try { List<Runnable> tasks = executorService.shutdownNow(); executorService = null; if (!interrupted) { for (Runnable task : tasks) { HostControllerLogger.ROOT_LOGGER.debugf("%s -- Discarding unexecuted task %s", getClass().getSimpleName(), task); } } } finally { context.complete(); } } } }, "HostController ExecutorService Shutdown Thread"); executorShutdown.start(); context.asynchronous(); }
Example 8
Source File: ServerInventoryService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Stops all servers. * * {@inheritDoc} */ @Override public synchronized void stop(final StopContext context) { final boolean shutdownServers = runningModeControl.getRestartMode() == RestartMode.SERVERS; if (shutdownServers) { Runnable task = new Runnable() { @Override public void run() { try { serverInventory.shutdown(true, -1, true); // TODO graceful shutdown serverInventory = null; // client.getValue().setServerInventory(null); } finally { serverCallback.getValue().setCallbackHandler(null); context.complete(); } } }; try { executorService.getValue().execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } } else { // We have to set the shutdown flag in any case serverInventory.shutdown(false, -1, true); serverInventory = null; } }
Example 9
Source File: AbstractControllerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void stop(final StopContext context) { capabilityRegistry.clear(); capabilityRegistry.publish(); ServiceNameFactory.clearCache(); controller = null; stabilityMonitor = null; processState.setStopping(); Runnable r = new Runnable() { @Override public void run() { try { stopAsynchronous(context); } finally { try { authorizer.shutdown(); } finally { context.complete(); } } } }; final ExecutorService executorService = this.executorService != null ? this.executorService.get() : null; try { if (executorService != null) { try { executorService.execute(r); } catch (RejectedExecutionException e) { r.run(); } } else { Thread executorShutdown = new Thread(r, getClass().getSimpleName() + " Shutdown Thread"); executorShutdown.start(); } } finally { processState.setStopped(); context.asynchronous(); } }
Example 10
Source File: AbstractModelControllerOperationHandlerFactoryService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** {@inheritDoc} */ @Override public synchronized void stop(final StopContext stopContext) { serviceConsumer.accept(null); final ExecutorService executorService = executorSupplier.get(); final Runnable task = new Runnable() { @Override public void run() { try { responseAttachmentSupport.shutdown(); // Shut down new requests to the client request executor, // but don't mess with currently running tasks clientRequestExecutor.shutdown(); } finally { stopContext.complete(); } } }; try { executorService.execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { stopContext.asynchronous(); } }
Example 11
Source File: DeploymentMountProvider.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void stop(final StopContext context) { Runnable r = new Runnable() { @Override public void run() { try { deploymentMountProviderConsumer.accept(null); VFSUtils.safeClose(tempFileProvider); } finally { try { ScheduledExecutorService ses = scheduledExecutorService; scheduledExecutorService = null; if (ses != null) { ses.shutdown(); } ServerLogger.ROOT_LOGGER.debugf("%s stopped", DeploymentMountProvider.class.getSimpleName()); } finally { context.complete(); } } } }; final ExecutorService executorService = executorSupplier.get(); try { try { executorService.execute(r); } catch (RejectedExecutionException e) { r.run(); } } finally { context.asynchronous(); } }
Example 12
Source File: ServerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public synchronized void stop(final StopContext context) { if (executorService != null) { context.asynchronous(); Thread executorShutdown = new Thread(new Runnable() { @Override public void run() { boolean interrupted = false; try { executorService.shutdown(); // Hack. Give in progress tasks a brief period to complete before we // interrupt threads via shutdownNow executorService.awaitTermination(100, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { interrupted = true; } finally { try { List<Runnable> tasks = executorService.shutdownNow(); executorService = null; if (!interrupted) { for (Runnable task : tasks) { ServerLogger.AS_ROOT_LOGGER.debugf("%s -- Discarding unexecuted task %s", getClass().getSimpleName(), task); } } } finally { context.complete(); } } } }, "ServerExecutorService Shutdown Thread"); executorShutdown.start(); } }
Example 13
Source File: ScheduledThreadPoolService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected void terminated() { super.terminated(); StopContext context; synchronized (ScheduledThreadPoolService.this) { context = ScheduledThreadPoolService.this.context; ScheduledThreadPoolService.this.context = null; } context.complete(); }
Example 14
Source File: ProcessStateListenerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * The stop is asynchronous and will wait until the current transition / suspendTransition ends before effectively stopping. * This will force the executorService to be Value * @param context the stop context. */ @Override public void stop(StopContext context) { Runnable asyncStop = () -> { synchronized (stopLock) { processStateNotifierSupplier.get().removePropertyChangeListener(propertyChangeListener); SuspendController controller = suspendControllerSupplier != null ? suspendControllerSupplier.get() : null; if (controller != null) { controller.removeListener(operationListener); } runningState = null; try { listener.cleanup(); } catch (RuntimeException t) { CoreManagementLogger.ROOT_LOGGER.processStateCleanupError(t, name); } finally { context.complete(); } } }; final ExecutorService executorService = executorServiceSupplier.get(); try { try { executorService.execute(asyncStop); } catch (RejectedExecutionException e) { asyncStop.run(); } } finally { context.asynchronous(); } }
Example 15
Source File: WorkerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void stopDone() { synchronized (stopLock) { final StopContext stopContext = this.stopContext; this.stopContext = null; if (stopContext != null) { stopContext.complete(); } stopLock.notifyAll(); } }
Example 16
Source File: StopContextEventListener.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public void handleEvent(final StopContext stopContext) { stopContext.complete(); }