throw new IllegalStateException(e); } finally { monitor.removeController(controller); controller.setMode(ServiceController.Mode.REMOVE);
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); } } }
throw NamingLogger.ROOT_LOGGER.threadInterrupt(serviceName); } finally { monitor.removeController(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()); } }
monitor.awaitStability(); } finally { monitor.removeController(binderServiceController);
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); } }
/** * 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. * * @deprecated this method is unrelated to this class and will be removed in the next major release */ @Deprecated public void waitFor(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 new OperationFailedException((new ModelNode()).set("Interrupted waiting for service: " + controller.getName())); } finally { monitor.removeController(controller); } if (controller.getState() != ServiceController.State.UP) { throw new OperationFailedException(new ModelNode().set("Required service is not available: " + controller.getName())); } }
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); } } }
private static void transition(final ServiceController<?> targetController, State targetState) throws StartException { // Short-circuit if the service is already at the target state if (targetController.getState() == targetState) return; final StabilityMonitor monitor = new StabilityMonitor(); try { if (targetController.getSubstate().isRestState()) { // Force service to transition to desired state Mode targetMode = modeToggle.get(targetState).get(targetController.getMode()); if (targetMode != null) { targetController.setMode(targetMode); } } monitor.addController(targetController); monitor.awaitStability(); if (targetState == State.UP) { StartException exception = targetController.getStartException(); if (exception != null) { throw exception; } } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { monitor.removeController(targetController); } }
@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); } } }
throw NamingLogger.ROOT_LOGGER.threadInterrupt(serviceName); } finally { monitor.removeController(controller);
/** * Unbind the resource and wait until the corresponding binding service is effectively removed. */ @Override public void unbind(String name) { if (name == null || name.isEmpty()) { throw MessagingLogger.ROOT_LOGGER.cannotUnbindJndiName(); } final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name); ServiceController<?> bindingService = container.getService(bindInfo.getBinderServiceName()); if (bindingService == null) { ROOT_LOGGER.debugf("Cannot unbind %s since no binding exists with that name", name); return; } // remove the binding service bindingService.setMode(ServiceController.Mode.REMOVE); final StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(bindingService); try { monitor.awaitStability(); ROOT_LOGGER.unboundJndiName(bindInfo.getAbsoluteJndiName()); } catch (InterruptedException e) { ROOT_LOGGER.failedToUnbindJndiName(name, 5, SECONDS.toString().toLowerCase(Locale.US)); } finally { monitor.removeController(bindingService); } }
/** * Unbind the resource and wait until the corresponding binding service is effectively removed. */ @Override public void unbind(String name) { if (name == null || name.isEmpty()) { throw MessagingLogger.ROOT_LOGGER.cannotUnbindJndiName(); } final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name); ServiceController<?> bindingService = container.getService(bindInfo.getBinderServiceName()); if (bindingService == null) { ROOT_LOGGER.debugf("Cannot unbind %s since no binding exists with that name", name); return; } // remove the binding service bindingService.setMode(ServiceController.Mode.REMOVE); final StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(bindingService); try { monitor.awaitStability(); ROOT_LOGGER.unboundJndiName(bindInfo.getAbsoluteJndiName()); } catch (InterruptedException e) { ROOT_LOGGER.failedToUnbindJndiName(name, 5, SECONDS.toString().toLowerCase(Locale.US)); } finally { monitor.removeController(bindingService); } }
/** * 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 stop(final StopContext context) { final String deploymentName = context.getController().getName().getSimpleName(); final String managementName = deploymentUnit.getAttachment(Attachments.MANAGEMENT_NAME); if (deploymentUnit.getParent()==null) { ServerLogger.DEPLOYMENT_LOGGER.stoppedDeployment(managementName, deploymentName, (int) (context.getElapsedTime() / 1000000L)); } else { ServerLogger.DEPLOYMENT_LOGGER.stoppedSubDeployment(deploymentName, (int) (context.getElapsedTime() / 1000000L)); } deploymentUnit = null; monitor.removeController(context.getController()); monitor = null; }
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); } }
@Override public synchronized void stop(final StopContext context) { final String deploymentName = context.getController().getName().getSimpleName(); final String managementName = deploymentUnit.getAttachment(Attachments.MANAGEMENT_NAME); if (deploymentUnit.getParent()==null) { ServerLogger.DEPLOYMENT_LOGGER.stoppedDeployment(managementName, deploymentName, (int) (context.getElapsedTime() / 1000000L)); } else { ServerLogger.DEPLOYMENT_LOGGER.stoppedSubDeployment(deploymentName, (int) (context.getElapsedTime() / 1000000L)); } // Retain any attached builder across restarts this.phaseBuilder = this.deploymentUnit.getAttachment(Attachments.DEPLOYMENT_UNIT_PHASE_BUILDER); //clear up all attachments for (AttachmentKey<?> key : this.getDeploymentUnitAttachmentKeys()) { deploymentUnit.removeAttachment(key); } deploymentUnit = null; monitor.removeController(context.getController()); monitor = null; DeploymentResourceSupport.cleanup(resource); }
@Override public synchronized void stop(final StopContext context) { final String deploymentName = context.getController().getName().getSimpleName(); final String managementName = deploymentUnit.getAttachment(Attachments.MANAGEMENT_NAME); if (deploymentUnit.getParent()==null) { ServerLogger.DEPLOYMENT_LOGGER.stoppedDeployment(managementName, deploymentName, (int) (context.getElapsedTime() / 1000000L)); } else { ServerLogger.DEPLOYMENT_LOGGER.stoppedSubDeployment(deploymentName, (int) (context.getElapsedTime() / 1000000L)); } // Retain any attached builder across restarts this.phaseBuilder = this.deploymentUnit.getAttachment(Attachments.DEPLOYMENT_UNIT_PHASE_BUILDER); //clear up all attachments for (AttachmentKey<?> key : this.getDeploymentUnitAttachmentKeys()) { deploymentUnit.removeAttachment(key); } deploymentUnit = null; monitor.removeController(context.getController()); monitor = null; DeploymentResourceSupport.cleanup(resource); }