Java Code Examples for org.jboss.msc.service.ServiceController#setMode()
The following examples show how to use
org.jboss.msc.service.ServiceController#setMode() .
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: SubDeploymentProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void undeploy(final DeploymentUnit deploymentUnit) { final ServiceRegistry serviceRegistry = deploymentUnit.getServiceRegistry(); final List<ResourceRoot> childRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS); for (final ResourceRoot childRoot : childRoots) { if (!SubDeploymentMarker.isSubDeployment(childRoot)) { continue; } final ServiceName serviceName = Services.deploymentUnitName(deploymentUnit.getName(), childRoot.getRootName()); final ServiceController<?> serviceController = serviceRegistry.getService(serviceName); if (serviceController != null) { serviceController.setMode(ServiceController.Mode.REMOVE); } } deploymentUnit.removeAttachment(Attachments.SUB_DEPLOYMENTS); }
Example 2
Source File: IOSubsystem20TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testRuntime() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) .setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Assert.fail(String.valueOf(mainServices.getBootError())); } ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default")); workerServiceController.setMode(ServiceController.Mode.ACTIVE); workerServiceController.awaitValue(); XnioWorker worker = workerServiceController.getService().getValue(); Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount()); Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue()); PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default"); ModelNode op = Util.createOperation("read-resource", addr); op.get("include-runtime").set(true); mainServices.executeOperation(op); }
Example 3
Source File: IOSubsystem11TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testRuntime() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) .setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Assert.fail(mainServices.getBootError().toString()); } ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default")); workerServiceController.setMode(ServiceController.Mode.ACTIVE); workerServiceController.awaitValue(); XnioWorker worker = workerServiceController.getService().getValue(); Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount()); Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue()); PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default"); ModelNode op = Util.createOperation("read-resource", addr); op.get("include-runtime").set(true); mainServices.executeOperation(op); }
Example 4
Source File: MscRuntimeContainerDelegate.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void unregisterProcessEngine(ProcessEngine processEngine) { if(processEngine == null) { throw new ProcessEngineException("Cannot unregister process engine with Msc Runtime Container: process engine is 'null'"); } ServiceName serviceName = ServiceNames.forManagedProcessEngine(processEngine.getName()); // remove the service asynchronously ServiceController<ProcessEngine> service = (ServiceController<ProcessEngine>) serviceContainer.getService(serviceName); if(service != null && service.getService() instanceof MscManagedProcessEngine) { service.setMode(Mode.REMOVE); } }
Example 5
Source File: MscRuntimeContainerDelegate.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void unregisterProcessEngine(ProcessEngine processEngine) { if(processEngine == null) { throw new ProcessEngineException("Cannot unregister process engine with Msc Runtime Container: process engine is 'null'"); } ServiceName serviceName = ServiceNames.forManagedProcessEngine(processEngine.getName()); // remove the service asynchronously ServiceController<ProcessEngine> service = (ServiceController<ProcessEngine>) serviceContainer.getService(serviceName); if(service != null && service.getService() instanceof MscManagedProcessEngine) { service.setMode(Mode.REMOVE); } }
Example 6
Source File: DomainDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void startSecurityDomainServiceIfNotUp(ServiceController<SecurityDomain> serviceController) throws OperationFailedException { if (serviceController.getState() != ServiceController.State.UP) { serviceController.setMode(Mode.ACTIVE); try { serviceController.awaitValue(); } catch (InterruptedException e) { throw new OperationFailedException(e); } } }
Example 7
Source File: RequestControllerSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testRuntime() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) .setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Assert.fail(mainServices.getBootError().toString()); } ServiceController<RequestController> workerServiceController = (ServiceController<RequestController>) mainServices.getContainer().getService(RequestController.SERVICE_NAME); workerServiceController.setMode(ServiceController.Mode.ACTIVE); workerServiceController.awaitValue(); RequestController controller = workerServiceController.getService().getValue(); Assert.assertEquals(100, controller.getMaxRequestCount()); }
Example 8
Source File: CapabilityRegistryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testClear() throws OperationFailedException, InterruptedException { add(RELOAD_ELEMENT); try { requireReload(RELOAD_ELEMENT); runtimeCheck(false, RELOAD_ELEMENT); runtimeOnlyCheck(true, RELOAD_ELEMENT); // Do a mock reload ServiceController<?> svc = container.getRequiredService(ServiceName.of("ModelController")); final AtomicInteger downCaps = new AtomicInteger(); final AtomicInteger downPossibleCaps = new AtomicInteger(); StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(svc); svc.setMode(ServiceController.Mode.NEVER); monitor.awaitStability(); downCaps.set(capabilityRegistry.getCapabilities().size()); downPossibleCaps.set(capabilityRegistry.getPossibleCapabilities().size()); svc.setMode(ServiceController.Mode.ACTIVE); Assert.assertTrue("Failed to reload", monitor.awaitStability(30, TimeUnit.SECONDS)); Assert.assertEquals(0, downCaps.get()); Assert.assertEquals(0, downPossibleCaps.get()); Assert.assertEquals(expectedCaps(0), capabilityRegistry.getCapabilities().size()); Assert.assertEquals(expectedCaps(0), capabilityRegistry.getPossibleCapabilities().size()); runtimeCheck(true, RELOAD_ELEMENT); runtimeOnlyCheck(true, RELOAD_ELEMENT); } finally { //noinspection ThrowFromFinallyBlock remove(RELOAD_ELEMENT); } }
Example 9
Source File: IOSubsystem10TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testRuntime() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) .setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Assert.fail(mainServices.getBootError().toString()); } ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default")); workerServiceController.setMode(ServiceController.Mode.ACTIVE); workerServiceController.awaitValue(); XnioWorker worker = workerServiceController.getService().getValue(); Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount()); Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue()); }
Example 10
Source File: NamingContextAssociationHandler.java From wildfly-camel with Apache License 2.0 | 5 votes |
private ServiceController<?> removeBinderService(String name) { final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name); ServiceController<?> controller = serviceRegistry.getService(bindInfo.getBinderServiceName()); if (controller != null) { controller.setMode(Mode.REMOVE); } return controller; }
Example 11
Source File: CamelCoreSubsystemExtension.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Override public void removeCamelContext(CamelContext camelctx) { ServiceController<?> controller; synchronized (contexts) { controller = contexts.get(camelctx); contexts.remove(camelctx); } if (controller != null) { controller.setMode(Mode.REMOVE); } }
Example 12
Source File: AdvertisementHandleImpl.java From thorntail with Apache License 2.0 | 4 votes |
@Override public void unadvertise() { for (ServiceController<?> controller : this.controllers) { controller.setMode(ServiceController.Mode.REMOVE); } }
Example 13
Source File: TestEnvironment.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static void activateService(KernelServices services, RuntimeCapability capability, String... dynamicNameElements) throws InterruptedException { ServiceName serviceName = capability.getCapabilityServiceName(dynamicNameElements); ServiceController<?> serviceController = services.getContainer().getService(serviceName); serviceController.setMode(ServiceController.Mode.ACTIVE); serviceController.awaitValue(); }
Example 14
Source File: IOSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected XnioWorker startXnioWorker(KernelServices kernelServices) throws InterruptedException { ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) kernelServices.getContainer().getService(IOServices.WORKER.append("default")); workerServiceController.setMode(ServiceController.Mode.ACTIVE); workerServiceController.awaitValue(); return workerServiceController.getService().getValue(); }