Refine search
final ServiceBuilder<?> builder = serviceTarget.addService(bindName, binderService) .addDependency(getServiceNameBase(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()); final ServiceController<?> binderServiceController = builder.install(); final StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(binderServiceController); try { monitor.awaitStability(); } finally { monitor.removeController(binderServiceController); final Exception startException = binderServiceController.getStartException(); if (startException != null) { throw startException; final RuntimeBindReleaseService.References duBindingReferences = (RuntimeBindReleaseService.References) binderServiceController.getServiceContainer().getService(JndiNamingDependencyProcessor.serviceName(deploymentUnitServiceName)).getValue(); duBindingReferences.add(binderService);
@Override public void run() { StabilityMonitor monitor = new StabilityMonitor(); for (ServiceController controller : serviceControllers) { monitor.addController(controller); monitor.awaitStability(); } catch (InterruptedException ex) { context.failed(new StartException(ex)); throw new RuntimeException(ex); } finally { monitor.clear();
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); } } }
/** * 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()); } }
@Override public T get() { ServiceTarget target = this.registry.getRequiredService(this.name).getServiceContainer(); ServiceBuilder<?> builder = target.addService(name); Supplier<T> supplier = builder.requires(this.name); ServiceController<?> controller = builder.setInitialMode(this.mode).install(); StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(controller); try { Duration duration = this.duration; if (duration == null) { monitor.awaitStability(); } else if (!monitor.awaitStability(duration.toMillis(), TimeUnit.MILLISECONDS)) { throw new IllegalStateException(new TimeoutException()); switch (controller.getState()) { case START_FAILED: { throw new IllegalStateException(controller.getStartException()); throw new IllegalStateException(e); } finally { monitor.removeController(controller); controller.setMode(ServiceController.Mode.REMOVE);
final ServiceController<?> myController = context.getController(); final ServiceContainer serviceContainer = myController.getServiceContainer(); bootstrapListener.getStabilityMonitor().addController(myController); if (processType == ProcessType.EMBEDDED_HOST_CONTROLLER) { final ProcessControllerConnectionServiceNoop processControllerClient = new ProcessControllerConnectionServiceNoop(environment, authCode); serviceTarget.addService(ProcessControllerConnectionServiceNoop.SERVICE_NAME, processControllerClient).install(); } else { final ProcessControllerConnectionService processControllerClient = new ProcessControllerConnectionService(environment, authCode); serviceTarget.addService(ProcessControllerConnectionService.SERVICE_NAME, processControllerClient).install(); serviceTarget.addService(EXECUTOR_CAPABILITY.getCapabilityServiceName(), executorService)
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 InternalApplicationExtension extend(String extensionId, String resourceId, ObjectNode configuration, boolean boottime) throws Exception { ServiceTarget target = this.target.subTarget(); StabilityMonitor monitor = new StabilityMonitor(); target.addMonitor(monitor); ServiceName resourceServiceName = Services.applicationExtension(this.id, resourceId); ApplicationExtensionService appExt = new ApplicationExtensionService(extensionId, resourceId, configuration, boottime); ServiceController<InternalApplicationExtension> controller = target.addService(resourceServiceName, appExt) .addDependency(Services.extension(extensionId), Extension.class, appExt.extensionInjector()) .addDependency(Services.application(this.id), InternalApplication.class, appExt.applicationInjector()) .addDependency(Services.SERVICE_REGISTRY, ServiceRegistry.class, appExt.serviceRegistryInjector()) .install(); monitor.awaitStability(); InternalApplicationExtension intAppExt = controller.awaitValue(); if (intAppExt.exception() != null) { intAppExt.remove(); log.error(intAppExt.exception()); throw intAppExt.exception(); } target.removeMonitor(monitor); return intAppExt; }
@Override public void start(StartContext context) throws StartException { ServiceTarget target = context.getChildTarget(); InternalApplicationExtension appExtension = this.appExtensionServiceController.getValue(); ApplicationExtensionContextImpl extensionContext = new ApplicationExtensionContextImpl( target, appExtension, null, null, JsonNodeFactory.instance.objectNode(), false); StabilityMonitor monitor = new StabilityMonitor(); target.addMonitor(monitor); try { this.extensionInjector.getValue().unextend(extensionContext); context.complete(); monitor.awaitStability(); } catch (Exception e) { throw new StartException(e); } // remove ourselves context.getController().setMode(ServiceController.Mode.REMOVE); }
@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); }
public void load(String id, Extension extension, ObjectNode config, ExtensionConfigurationManager extensionConfigManager) throws Exception { ServiceName configManagerName = Services.systemConfigurationManager(id); target.addService(configManagerName, new ValueService<>(new ImmediateValue<>(extensionConfigManager))).install(); target.addService(Services.systemEnvironmentProperties(id), new ValueService<>(new ImmediateValue<>(envProperties()))).install(); StabilityMonitor monitor = new StabilityMonitor(); ServiceTarget target = this.target.subTarget(); target.addMonitor(monitor); ExtensionService extensionService = new ExtensionService(id, extension, config, extensionConfigManager); ServiceBuilder builder = target.addService(Services.extension(id), extensionService); JsonNode deps = config.get("dependencies"); if (deps != null) { for (JsonNode node : deps) { builder.addDependency(Services.extension(node.asText())); } } builder.install(); monitor.awaitStability(); }
@Override public void mountPrivate(ServiceName privateName) { StabilityMonitor monitor = new StabilityMonitor(); target.addMonitor(monitor); MountService<RootResource> mount = new MountService(this.id); SystemResourceWrappingResourceService wrapper = new SystemResourceWrappingResourceService(); target.addService(privateName.append("wrapper"), wrapper) .addDependency(privateName, RootResource.class, wrapper.resourceInjector) .addDependency(Services.systemConfigurationManager(moduleId), ExtensionConfigurationManager.class, wrapper.managerInjector) .addDependency(Services.systemEnvironmentProperties(moduleId), Properties.class, wrapper.environmentPropertiesInjector) .addDependency(Services.CLIENT, Client.class, wrapper.clientInjector) .install(); InitializeResourceService configApply = new InitializeResourceService(); target.addService(privateName.append("apply-config"), configApply) .addDependency(privateName.append("wrapper"), RootResource.class, configApply.resourceInjector()) .addInjection(configApply.configurationInjector(), this.configuration) .install(); RootResourceLifecycleService lifecycle = new RootResourceLifecycleService(); target.addService(privateName.append("lifecycle"), lifecycle) .addDependency(privateName.append("apply-config")) .addDependency(privateName, RootResource.class, lifecycle.resourceInjector()) .install(); ServiceController<? extends Resource> controller = this.target.addService(privateName.append("mount"), mount) .addDependency(privateName.append("lifecycle")) .addDependency(this.systemExtensionMount, MountPointResource.class, mount.mountPointInjector()) .addDependency(privateName.append("wrapper"), RootResource.class, mount.resourceInjector()) .install(); }
StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(parentDeploymentService); monitor.addController(phaseService); Set<ServiceController<?>> failed = new HashSet<ServiceController<?>>(); Set<ServiceController<?>> problems = new HashSet<ServiceController<?>>(); try { phaseService.setMode(Mode.ACTIVE); monitor.awaitStability(failed, problems); } catch (final InterruptedException ex) { monitor.clear(); if (aux.getStartException() != null) { startex = aux.getStartException(); break;
monitor.awaitStability(failed, problems); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } finally { monitor.clear(); failedList = failureDescription.get(ControllerLogger.ROOT_LOGGER.failedServices()); ServiceName serviceName = controller.getName(); failedSet.add(serviceName); failedList.get(serviceName.getCanonicalName()).set(getServiceFailureDescription(controller.getStartException())); Collection<ServiceName> immediatelyUnavailable = controller.getUnavailableDependencies(); StringBuilder missing = new StringBuilder(); boolean direct = false;
monitor.awaitStability(failed, problems); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } finally { monitor.clear(); failedList = failureDescription.get(MESSAGES.failedServices()); ServiceName serviceName = controller.getName(); trackedServices.add(serviceName); failedList.get(serviceName.getCanonicalName()).set(getServiceFailureDescription(controller.getStartException())); Set<ServiceName> immediatelyUnavailable = controller.getImmediateUnavailableDependencies(); if (!immediatelyUnavailable.isEmpty()) { if (problemList == null) {
/** * 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 }
/** * Causes the current thread to wait until the monitor is stable. * * @param statistics stability statistics report to fill in * @throws InterruptedException if the current thread is interrupted * while waiting */ public void awaitStability(final StabilityStatistics statistics) throws InterruptedException { awaitStability(null, null, statistics); }
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 printBootStatistics() { final StabilityStatistics statistics = new StabilityStatistics(); try { monitor.awaitStability(statistics); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); return; } finally { serviceTarget.removeMonitor(monitor); final long bootstrapTime = System.currentTimeMillis() - startTime; done(bootstrapTime, statistics); monitor.clear(); } }