monitor.addController(controller); try { Duration duration = this.duration;
private void transition(State targetState) { // Short-circuit if the service is already at the target state if (this.controller.getState() == targetState) return; StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(this.controller); try { // Force service to transition to desired state Mode targetMode = modeToggle.get(targetState).get(this.controller.getMode()); if (targetMode != null) { this.controller.setMode(targetMode); } monitor.awaitStability(); if (this.controller.getState() == ServiceController.State.START_FAILED) { throw new IllegalStateException(this.controller.getStartException()); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { monitor.removeController(this.controller); } } }
monitor.addController(controller); try { monitor.awaitStability();
StabilityMonitor monitor = new StabilityMonitor(); for (ServiceController controller : serviceControllers) { monitor.addController(controller);
/** * Wait for the required service to start up and fail otherwise. This method is necessary when a runtime operation * uses a service that might have been created within a composite operation. * * This method will wait at most 100 millis. * * @param controller the service to wait for * @throws OperationFailedException if the service is not available, or the thread was interrupted. */ private static void waitForService(final ServiceController<?> controller) throws OperationFailedException { if (controller.getState() == ServiceController.State.UP) return; final StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(controller); try { monitor.awaitStability(100, MILLISECONDS); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); throw SecurityLogger.ROOT_LOGGER.interruptedWaitingForSecurityDomain(controller.getName().getSimpleName()); } finally { monitor.removeController(controller); } if (controller.getState() != ServiceController.State.UP) { throw SecurityLogger.ROOT_LOGGER.requiredSecurityDomainServiceNotAvailable(controller.getName().getSimpleName()); } }
final ServiceController<?> binderServiceController = builder.install(); final StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(binderServiceController); try { monitor.awaitStability();
public void unbind(final Name name) throws NamingException { requireOwner(); final ServiceName bindName = buildServiceName(name); final ServiceController<?> controller = getServiceRegistry().getService(bindName); if (controller == null) { throw NamingLogger.ROOT_LOGGER.cannotResolveService(bindName); } controller.setMode(ServiceController.Mode.REMOVE); final StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(controller); try { monitor.awaitStability(); } catch (Exception e) { throw namingException("Failed to unbind [" + bindName + "]", e); } finally { monitor.removeController(controller); } }
public synchronized void listenerAdded(final ServiceController<?> controller) { monitor.addController(controller); controller.removeListener(this); }
@Override public void listenerAdded(final ServiceController<?> controller) { monitor.addController(controller); controller.removeListener(this); }
@SuppressWarnings("deprecation") public static void install(ServiceTarget target, ThreadGroup threadGroup, ServiceName cleanupExecutor, StabilityMonitor monitor) { final ExternalManagementRequestExecutor service = new ExternalManagementRequestExecutor(threadGroup); ServiceController<?> controller = target.addService(SERVICE_NAME, service) .addDependency(cleanupExecutor, ExecutorService.class, service.injectedExecutor) .setInitialMode(ServiceController.Mode.ON_DEMAND).install(); monitor.addController(controller); }
@SuppressWarnings("deprecation") public static void install(ServiceTarget target, ThreadGroup threadGroup, ServiceName cleanupExecutor, StabilityMonitor monitor) { final ExternalManagementRequestExecutor service = new ExternalManagementRequestExecutor(threadGroup); ServiceController<?> controller = target.addService(SERVICE_NAME, service) .addDependency(cleanupExecutor, ExecutorService.class, service.injectedExecutor) .setInitialMode(ServiceController.Mode.ON_DEMAND).install(); monitor.addController(controller); }
/** * Tracks a service whose mode is changing for subsequent verification of service stability. * @param service the service */ void serviceModeChanged(ServiceController<?> service) { // This should not be used for removals assert service.getMode() != ServiceController.Mode.REMOVE; if (!executed) { if (addedServices == null || !addedServices.contains(service.getName())) { getServiceVerificationHelper().getMonitor().addController(service); } // else we already handled this when it was added } // else this is rollback stuff we ignore }
/** * Tracks a service whose mode is changing for subsequent verification of service stability. * @param service the service */ void serviceModeChanged(ServiceController<?> service) { // This should not be used for removals assert service.getMode() != ServiceController.Mode.REMOVE; if (!executed) { if (addedServices == null || !addedServices.contains(service.getName())) { getServiceVerificationHelper().getMonitor().addController(service); } // else we already handled this when it was added } // else this is rollback stuff we ignore }
private void transition(State targetState) { // Short-circuit if the service is already at the target state if (this.controller.getState() == targetState) return; StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(this.controller); try { // Force service to transition to desired state Mode targetMode = modeToggle.get(targetState).get(this.controller.getMode()); if (targetMode != null) { this.controller.setMode(targetMode); } monitor.awaitStability(); if (this.controller.getState() == ServiceController.State.START_FAILED) { throw new IllegalStateException(this.controller.getStartException()); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { monitor.removeController(this.controller); } } }
@Override public void close() { if (ROOT_LOGGER.isTraceEnabled()) { ROOT_LOGGER.tracef("stop second level cache by removing dependency on service '%s'", this.controller.getName().getCanonicalName()); } StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(this.controller); this.controller.setMode(ServiceController.Mode.REMOVE); try { monitor.awaitStability(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { monitor.removeController(this.controller); } } }
@Override public void close() { if (ROOT_LOGGER.isTraceEnabled()) { ROOT_LOGGER.tracef("stop second level cache by removing dependency on service '%s'", this.controller.getName().getCanonicalName()); } StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(this.controller); this.controller.setMode(ServiceController.Mode.REMOVE); try { monitor.awaitStability(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { monitor.removeController(this.controller); } } }
/** * Wait for the required service to start up and fail otherwise. This method is necessary when a runtime operation * uses a service that might have been created within a composite operation. * * This method will wait at most 100 millis. * * @param controller the service to wait for * @throws OperationFailedException if the service is not available, or the thread was interrupted. */ private static void waitForService(final ServiceController<?> controller) throws OperationFailedException { if (controller.getState() == ServiceController.State.UP) return; final StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(controller); try { monitor.awaitStability(100, MILLISECONDS); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); throw SecurityLogger.ROOT_LOGGER.interruptedWaitingForSecurityDomain(controller.getName().getSimpleName()); } finally { monitor.removeController(controller); } if (controller.getState() != ServiceController.State.UP) { throw SecurityLogger.ROOT_LOGGER.requiredSecurityDomainServiceNotAvailable(controller.getName().getSimpleName()); } }
public synchronized void start(final StartContext context) throws StartException { ServiceTarget target = context.getChildTarget(); final String deploymentName = context.getController().getName().getSimpleName(); monitor = new StabilityMonitor(); monitor.addController(context.getController()); // Create the first phase deployer deploymentUnit = createAndInitializeDeploymentUnit(context.getController().getServiceContainer()); final String managementName = deploymentUnit.getAttachment(Attachments.MANAGEMENT_NAME); if (deploymentUnit.getParent()==null) { ServerLogger.DEPLOYMENT_LOGGER.startingDeployment(managementName, deploymentName); } else { ServerLogger.DEPLOYMENT_LOGGER.startingSubDeployment(deploymentName); } final ServiceName serviceName = deploymentUnit.getServiceName().append(FIRST_PHASE_NAME); final Phase firstPhase = Phase.values()[0]; final DeploymentUnitPhaseService<?> phaseService = DeploymentUnitPhaseService.create(deploymentUnit, firstPhase); final ServiceBuilder<?> phaseServiceBuilder = target.addService(serviceName, phaseService); phaseServiceBuilder.addDependency(Services.JBOSS_DEPLOYMENT_CHAINS, DeployerChains.class, phaseService.getDeployerChainsInjector()); phaseServiceBuilder.install(); }
public void unbind(final Name name) throws NamingException { requireOwner(); final ServiceName bindName = buildServiceName(name); final ServiceController<?> controller = getServiceRegistry().getService(bindName); if (controller == null) { throw NamingLogger.ROOT_LOGGER.cannotResolveService(bindName); } controller.setMode(ServiceController.Mode.REMOVE); final StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(controller); try { monitor.awaitStability(); } catch (Exception e) { throw namingException("Failed to unbind [" + bindName + "]", e); } finally { monitor.removeController(controller); } }
public void unbind(final Name name) throws NamingException { requireOwner(); final ServiceName bindName = buildServiceName(name); final ServiceController<?> controller = getServiceRegistry().getService(bindName); if (controller == null) { throw NamingLogger.ROOT_LOGGER.cannotResolveService(bindName); } controller.setMode(ServiceController.Mode.REMOVE); final StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(controller); try { monitor.awaitStability(); } catch (Exception e) { throw namingException("Failed to unbind [" + bindName + "]", e); } finally { monitor.removeController(controller); } }