org.jboss.as.controller.ModelController Java Examples
The following examples show how to use
org.jboss.as.controller.ModelController.
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: OperationTransactionControlProxy.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void operationPrepared(OperationTransaction transaction, ModelNode result) { Class<?> mainClass = mainTransactionControl.getClass(); ClassLoader mainCl = mainClass.getClassLoader(); try { Method method = mainClass.getMethod("operationPrepared", mainCl.loadClass(ModelController.OperationTransaction.class.getName()), mainCl.loadClass(ModelNode.class.getName())); method.setAccessible(true); Class<?> mainOpTxClass = mainCl.loadClass(OperationTransactionProxy.class.getName()); Constructor<?> ctor = mainOpTxClass.getConstructors()[0]; Object mainOpTxProxy = ctor.newInstance(transaction); method.invoke(mainTransactionControl, mainOpTxProxy, convertModelNodeToMainCl(result)); } catch (Exception e) { unwrapInvocationTargetRuntimeException(e); throw new RuntimeException(e); } }
Example #2
Source File: ModelTestLegacyControllerKernelServicesProxy.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public ModelNode executeOperation(ModelNode operation, OperationTransactionControl txControl) { try { if (executeOperation2 == null) { executeOperation2 = childFirstClassLoaderServices.getClass().getMethod("executeOperation", childFirstClassLoader.loadClass(ModelNode.class.getName()), childFirstClassLoader.loadClass(ModelController.OperationTransactionControl.class.getName())); } Class<?> opTxControlProxyClass = childFirstClassLoader.loadClass(getOperationTransactionProxyClassName()); Object opTxControl = opTxControlProxyClass.getConstructors()[0].newInstance(txControl); return convertModelNodeFromChildCl( executeOperation2.invoke(childFirstClassLoaderServices, convertModelNodeToChildCl(operation), opTxControl)); } catch (Exception e) { unwrapInvocationTargetRuntimeException(e); throw new RuntimeException(e); } }
Example #3
Source File: DomainModelControllerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public AbstractModelControllerOperationHandlerFactoryService newInstance( final Consumer<AbstractModelControllerOperationHandlerFactoryService> serviceConsumer, final Supplier<ModelController> modelControllerSupplier, final Supplier<ExecutorService> executorSupplier, final Supplier<ScheduledExecutorService> scheduledExecutorSupplier) { return new MasterDomainControllerOperationHandlerService( serviceConsumer, modelControllerSupplier, executorSupplier, scheduledExecutorSupplier, DomainModelControllerService.this, executor, executor, environment.getDomainTempDir(), DomainModelControllerService.this, domainHostExcludeRegistry); }
Example #4
Source File: OperationTransactionControlProxy.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void operationPrepared(OperationTransaction transaction, ModelNode result) { Class<?> mainClass = mainTransactionControl.getClass(); ClassLoader mainCl = mainClass.getClassLoader(); try { Method method = mainClass.getMethod("operationPrepared", mainCl.loadClass(ModelController.OperationTransaction.class.getName()), mainCl.loadClass(ModelNode.class.getName())); method.setAccessible(true); Class<?> mainOpTxClass = mainCl.loadClass(OperationTransactionProxy.class.getName()); Constructor<?> ctor = mainOpTxClass.getConstructors()[0]; Object mainOpTxProxy = ctor.newInstance(transaction); method.invoke(mainTransactionControl, mainOpTxProxy, convertModelNodeToMainCl(result)); } catch (Exception e) { unwrapInvocationTargetRuntimeException(e); throw new RuntimeException(e); } }
Example #5
Source File: ManagementRemotingServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Set up the services to create a channel listener and operation handler service. * @param serviceTarget the service target to install the services into * @param endpointName the endpoint name to install the services into * @param channelName the name of the channel * @param executorServiceName service name of the executor service to use in the operation handler service * @param scheduledExecutorServiceName service name of the scheduled executor service to use in the operation handler service */ public static void installManagementChannelServices( final ServiceTarget serviceTarget, final ServiceName endpointName, final ModelControllerOperationHandlerFactory operationHandlerServiceFactory, final ServiceName modelControllerName, final String channelName, final ServiceName executorServiceName, final ServiceName scheduledExecutorServiceName) { final OptionMap options = OptionMap.EMPTY; final ServiceName operationHandlerName = endpointName.append(channelName).append(ModelControllerClientOperationHandlerFactoryService.OPERATION_HANDLER_NAME_SUFFIX); final ServiceBuilder<?> builder = serviceTarget.addService(operationHandlerName); final Consumer<AbstractModelControllerOperationHandlerFactoryService> serviceConsumer = builder.provides(operationHandlerName); final Supplier<ModelController> mcSupplier = builder.requires(modelControllerName); final Supplier<ExecutorService> eSupplier = builder.requires(executorServiceName); final Supplier<ScheduledExecutorService> seSupplier = builder.requires(scheduledExecutorServiceName); builder.setInstance(operationHandlerServiceFactory.newInstance(serviceConsumer, mcSupplier, eSupplier, seSupplier)); builder.install(); installManagementChannelOpenListenerService(serviceTarget, endpointName, channelName, operationHandlerName, options, false); }
Example #6
Source File: MBeanServerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public static ServiceController<?> addService(final OperationContext context, final String resolvedDomainName, final String expressionsDomainName, final boolean legacyWithProperPropertyFormat, final boolean coreMBeanSensitivity, final ManagedAuditLogger auditLoggerInfo, final JmxAuthorizer authorizer, final Supplier<SecurityIdentity> securityIdentitySupplier, final JmxEffect jmxEffect, final ProcessType processType, final boolean isMasterHc) { final MBeanServerService service = new MBeanServerService(resolvedDomainName, expressionsDomainName, legacyWithProperPropertyFormat, coreMBeanSensitivity, auditLoggerInfo, authorizer, securityIdentitySupplier, jmxEffect, processType, isMasterHc); final ServiceName modelControllerName = processType.isHostController() ? DOMAIN_CONTROLLER_NAME : Services.JBOSS_SERVER_CONTROLLER; return context.getServiceTarget().addService(MBeanServerService.SERVICE_NAME, service) .setInitialMode(ServiceController.Mode.ACTIVE) .addDependency(modelControllerName, ModelController.class, service.modelControllerValue) .addDependency(context.getCapabilityServiceName("org.wildfly.management.notification-handler-registry", null), NotificationHandlerRegistry.class, service.notificationRegistryValue) .addDependency(ManagementModelIntegration.SERVICE_NAME, ManagementModelIntegration.ManagementModelProvider.class, service.managementModelProviderValue) .addAliases(LEGACY_MBEAN_SERVER_NAME) .install(); }
Example #7
Source File: ReadResourceWithRuntimeResourceTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void execute(ModelNode operation, OperationMessageHandler handler, final ProxyOperationControl control, OperationAttachments attachments, BlockingTimeout blockingTimeout) { final ModelNode response = new ModelNode(); response.get("outcome").set("success"); response.get("result", "attr").set(true); control.operationPrepared(new ModelController.OperationTransaction() { @Override public void commit() { control.operationCompleted(OperationResponse.Factory.createSimple(response)); } @Override public void rollback() { control.operationCompleted(OperationResponse.Factory.createSimple(response)); } }, response); }
Example #8
Source File: MasterDomainControllerOperationHandlerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public MasterDomainControllerOperationHandlerService( final Consumer<AbstractModelControllerOperationHandlerFactoryService> serviceConsumer, final Supplier<ModelController> modelControllerSupplier, final Supplier<ExecutorService> executorSupplier, final Supplier<ScheduledExecutorService> scheduledExecutorSupplier, final DomainController domainController, final HostControllerRegistrationHandler.OperationExecutor operationExecutor, final TransactionalOperationExecutor txOperationExecutor, final File tempDir, final HostRegistrations slaveHostRegistrations, DomainHostExcludeRegistry domainHostExcludeRegistry) { super(serviceConsumer, modelControllerSupplier, executorSupplier, scheduledExecutorSupplier); this.domainController = domainController; this.operationExecutor = operationExecutor; this.txOperationExecutor = txOperationExecutor; this.tempDir = tempDir; this.slaveHostRegistrations = slaveHostRegistrations; this.domainHostExcludeRegistry = domainHostExcludeRegistry; }
Example #9
Source File: AbstractControllerTestBase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Before public void setupController() throws InterruptedException { container = ServiceContainer.Factory.create("test"); ServiceTarget target = container.subTarget(); if (useDelegateRootResourceDefinition) { initializer = createInitializer(); controllerService = new ModelControllerService(getAuditLogger(), rootResourceDefinition); } else { controllerService = new ModelControllerService(getAuditLogger()); } ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), controllerService); builder.install(); controllerService.awaitStartup(30, TimeUnit.SECONDS); controller = controllerService.getValue(); //ModelNode setup = Util.getEmptyOperation("setup", new ModelNode()); //controller.execute(setup, null, null, null); }
Example #10
Source File: NativeRemotingManagementAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceName endpointName = RemotingServices.SUBSYSTEM_ENDPOINT; ManagementChannelRegistryService.addService(serviceTarget, endpointName); ManagementRemotingServices.installManagementChannelServices(serviceTarget, endpointName, new ModelControllerOperationHandlerFactory() { @Override public AbstractModelControllerOperationHandlerFactoryService newInstance( final Consumer<AbstractModelControllerOperationHandlerFactoryService> serviceConsumer, final Supplier<ModelController> modelControllerSupplier, final Supplier<ExecutorService> executorSupplier, final Supplier<ScheduledExecutorService> scheduledExecutorSupplier) { return new ModelControllerClientOperationHandlerFactoryService(serviceConsumer, modelControllerSupplier, executorSupplier, scheduledExecutorSupplier); } }, Services.JBOSS_SERVER_CONTROLLER, ManagementRemotingServices.MANAGEMENT_CHANNEL, ServerService.EXECUTOR_CAPABILITY.getCapabilityServiceName(), ServerService.JBOSS_SERVER_SCHEDULED_EXECUTOR); List<ServiceName> requiredServices = Collections.singletonList(RemotingServices.channelServiceName(endpointName, ManagementRemotingServices.MANAGEMENT_CHANNEL)); addVerifyInstallationStep(context, requiredServices); }
Example #11
Source File: HostControllerClient.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void reconnect(final URI uri, final String authKey, final boolean mgmtSubsystemEndpoint) throws IOException, URISyntaxException { // In case the server is out of sync after the reconnect, set reload required final boolean mgmtEndpointChanged = this.managementSubsystemEndpoint != mgmtSubsystemEndpoint; connection.asyncReconnect(uri, authKey, new HostControllerConnection.ReconnectCallback() { @Override public void reconnected(boolean inSync) { if (!inSync || mgmtEndpointChanged) { Function<ModelController, ModelNode> function = new Function<ModelController, ModelNode>() { @Override public ModelNode apply(ModelController modelController) { return InVmAccess.runInVm((PrivilegedAction<ModelNode>) () -> executeRequireReload(modelController)); } }; privilegedExecution().execute(function, controller); } } }); }
Example #12
Source File: HostControllerConnection.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Connect to the HC and retrieve the current model updates. * * @param controller the server controller * @param callback the operation completed callback * * @throws IOException for any error */ synchronized void openConnection(final ModelController controller, final ActiveOperation.CompletedCallback<ModelNode> callback) throws Exception { boolean ok = false; final Connection connection = connectionManager.connect(); try { channelHandler.executeRequest(new ServerRegisterRequest(), null, callback); // HC is the same version, so it will support sending the subject channelHandler.getAttachments().attach(TransactionalProtocolClient.SEND_IDENTITY, Boolean.TRUE); channelHandler.getAttachments().attach(TransactionalProtocolClient.SEND_IN_VM, Boolean.TRUE); channelHandler.addHandlerFactory(new TransactionalProtocolOperationHandler(controller, channelHandler, responseAttachmentSupport)); ok = true; } finally { if(!ok) { connection.close(); } } }
Example #13
Source File: MetricsServiceActivator.java From thorntail with Apache License 2.0 | 6 votes |
@Override public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException { ServiceTarget target = serviceActivatorContext.getServiceTarget(); MetricsService service = new MetricsService(); ServiceBuilder<MetricsService> metricsServiceBuilder = target.addService(MetricsService.SERVICE_NAME, service); ServiceBuilder<MetricsService> serviceBuilder = metricsServiceBuilder .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.getServerEnvironmentInjector()) .addDependency(ServiceName.parse("jboss.eclipse.microprofile.config.marker")) .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector()); serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE) .install(); BinderService binderService = new BinderService(SWARM_MP_METRICS, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, SWARM_MP_METRICS), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example #14
Source File: ModelControllerClientOperationHandlerFactoryService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public ModelControllerClientOperationHandlerFactoryService( final Consumer<AbstractModelControllerOperationHandlerFactoryService> serviceConsumer, final Supplier<ModelController> modelControllerSupplier, final Supplier<ExecutorService> executorSupplier, final Supplier<ScheduledExecutorService> scheduledExecutorSupplier ) { super(serviceConsumer, modelControllerSupplier, executorSupplier, scheduledExecutorSupplier); }
Example #15
Source File: TransactionalProtocolClientImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected PreparedOperationImpl(T operation, ModelNode preparedResult, AsyncFuture<OperationResponse> finalResult, ModelController.OperationTransaction transaction) { assert finalResult != null : "null result"; this.operation = operation; this.preparedResult = preparedResult; this.finalResult = finalResult; this.transaction = transaction; }
Example #16
Source File: RemoteDomainConnectionService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private RemoteDomainConnectionService(final ModelController controller, final ExtensionRegistry extensionRegistry, final LocalHostControllerInfo localHostControllerInfo, final RemoteFileRepository remoteFileRepository, final ContentRepository contentRepository, final IgnoredDomainResourceRegistry ignoredDomainResourceRegistry, final HostControllerRegistrationHandler.OperationExecutor operationExecutor, final DomainController domainController, final HostControllerEnvironment hostControllerEnvironment, final ExecutorService executor, final RunningMode runningMode, final Map<String, ProxyController> serverProxies, final AtomicBoolean domainConfigAvailable){ this.controller = controller; this.extensionRegistry = extensionRegistry; this.productConfig = hostControllerEnvironment.getProductConfig(); this.localHostInfo = localHostControllerInfo; this.remoteFileRepository = remoteFileRepository; this.contentRepository = contentRepository; remoteFileRepository.setRemoteFileRepositoryExecutor(remoteFileRepositoryExecutor); this.ignoredDomainResourceRegistry = ignoredDomainResourceRegistry; this.operationExecutor = operationExecutor; this.domainController = domainController; this.hostControllerEnvironment = hostControllerEnvironment; this.executor = executor; this.runningMode = runningMode; this.tempDir = hostControllerEnvironment.getDomainTempDir(); this.serverProxies = serverProxies; this.domainConfigAvailable = domainConfigAvailable; }
Example #17
Source File: ModelControllerClientOperationHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public ModelControllerClientOperationHandler(final ModelController controller, final ManagementChannelAssociation channelAssociation, final ResponseAttachmentInputStreamSupport responseAttachmentSupport, final ExecutorService clientRequestExecutor, final SecurityIdentity connectionIdentity) { this.controller = controller; this.channelAssociation = channelAssociation; this.responseAttachmentSupport = responseAttachmentSupport; this.connectionIdentity = connectionIdentity; this.clientRequestExecutor = clientRequestExecutor; }
Example #18
Source File: TransactionalProtocolOperationHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void operationPrepared(final ModelController.OperationTransaction transaction, final ModelNode result) { requestContext.prepare(transaction, result); try { // Wait for the commit or rollback message requestContext.txCompletedLatch.await(); } catch (InterruptedException e) { // requestContext.getResultHandler().failed(e); ROOT_LOGGER.tracef("Clearing interrupted status from client request %d", requestContext.getOperationId()); Thread.currentThread().interrupt(); } }
Example #19
Source File: TransactionalProtocolOperationHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public synchronized void failed(Exception e) { if(prepared) { final ModelController.OperationTransaction transaction = activeTx; activeTx = null; if(transaction != null) { try { transaction.rollback(); } finally { txCompletedLatch.countDown(); } } } else if (responseChannel != null) { rollbackOnPrepare = true; // Failed in a step before prepare, send error response final String message = e.getMessage() != null ? e.getMessage() : "failure before rollback " + e.getClass().getName(); final ModelNode response = new ModelNode(); response.get(OUTCOME).set(FAILED); response.get(FAILURE_DESCRIPTION).set(message); ControllerLogger.MGMT_OP_LOGGER.tracef("sending pre-prepare failed response for %d --- interrupted: %s", getOperationId(), (Object) Thread.currentThread().isInterrupted()); try { sendResponse(responseChannel, ModelControllerProtocol.PARAM_OPERATION_FAILED, response); responseChannel = null; } catch (IOException ignored) { ControllerLogger.MGMT_OP_LOGGER.failedSendingFailedResponse(ignored, response, getOperationId()); } } }
Example #20
Source File: AbstractProxyControllerTest.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Before public void setupController() throws Exception { executor = Executors.newCachedThreadPool(); container = ServiceContainer.Factory.create("test"); ServiceTarget target = container.subTarget(); ControlledProcessState processState = new ControlledProcessState(true); ProxyModelControllerService proxyService = new ProxyModelControllerService(processState); target.addService(ServiceName.of("ProxyModelController")).setInstance(proxyService).install(); ServiceBuilder<?> mainBuilder = target.addService(ServiceName.of("MainModelController")); Supplier<ModelController> proxy = mainBuilder.requires(ServiceName.of("ProxyModelController")); MainModelControllerService mainService = new MainModelControllerService(proxy, processState); mainBuilder.setInstance(mainService); mainBuilder.install(); proxyService.awaitStartup(30, TimeUnit.SECONDS); mainService.awaitStartup(30, TimeUnit.SECONDS); // execute operation to initialize the controller model final ModelNode operation = new ModelNode(); operation.get(OP).set("setup"); operation.get(OP_ADDR).setEmptyList(); mainControllerClient = mainService.getValue().createClient(executor); mainControllerClient.execute(operation); proxiedControllerClient = proxyService.getValue().createClient(executor); proxiedControllerClient.execute(operation); }
Example #21
Source File: RemoteProxyControllerProtocolTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testFailAfterPrepare() throws Exception { final ModelNode node = new ModelNode(); final ModelController controller = new MockModelController() { @Override public ModelNode execute(ModelNode operation, OperationMessageHandler handler, OperationTransactionControl control, OperationAttachments attachments) { control.operationPrepared(new OperationTransaction() { @Override public void commit() { // } @Override public void rollback() { // } }, node); // Fail after the commit or rollback was called throw new IllegalStateException(); } }; final ModelNode result = new ModelNode(); final RemoteProxyController proxyController = setupProxyHandlers(controller); final CommitProxyOperationControl commitControl = new CommitProxyOperationControl() { @Override public void operationCompleted(OperationResponse response) { super.operationCompleted(response); result.set(response.getResponseNode()); } }; proxyController.execute(node, null, commitControl, null, null); commitControl.tx.commit(); // Needs to call operation-completed Assert.assertEquals(2, commitControl.txCompletionStatus.get()); Assert.assertTrue(result.isDefined()); Assert.assertEquals("failed", result.get("outcome").asString()); Assert.assertTrue(result.hasDefined("failure-description")); }
Example #22
Source File: DomainApiCheckHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
DomainApiCheckHandler(final ModelController modelController, final Collection<String> allowedOrigins, final ConsoleAvailability consoleAvailability) { this.consoleAvailability = consoleAvailability; domainApiHandler = new EncodingHandler.Builder().build(Collections.<String,Object>emptyMap()).wrap(new DomainApiHandler(modelController)); addContentHandler = new DomainApiUploadHandler(modelController); genericOperationHandler = new EncodingHandler.Builder().build(Collections.<String,Object>emptyMap()).wrap(new DomainApiGenericOperationHandler(modelController)); if (allowedOrigins != null) { for (String allowedOrigin : allowedOrigins) { this.allowedOrigins.add(CorsUtil.sanitizeDefaultPort(allowedOrigin)); } } }
Example #23
Source File: EarlyResponseTransactionControl.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void operationPrepared(ModelController.OperationTransaction transaction, final ModelNode preparedResult, OperationContext context) { transaction.commit(); if (context == null || !reload) { // TODO deal with shutdown as well, the handlers for which have some // subtleties that need thought sendResponse(preparedResult); } else { context.attach(EarlyResponseSendListener.ATTACHMENT_KEY, new EarlyResponseSendListener() { @Override public void sendEarlyResponse(OperationContext.ResultAction resultAction) { sendResponse(preparedResult); } }); } }
Example #24
Source File: NativeManagementServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static synchronized void installRemotingServicesIfNotInstalled(final ServiceTarget serviceTarget, final String hostName, final ServiceRegistry serviceContainer) { if (serviceContainer.getService(ManagementRemotingServices.MANAGEMENT_ENDPOINT) == null) { ManagementChannelRegistryService.addService(serviceTarget, ManagementRemotingServices.MANAGEMENT_ENDPOINT); ManagementRemotingServices.installRemotingManagementEndpoint(serviceTarget, ManagementRemotingServices.MANAGEMENT_ENDPOINT, hostName, EndpointService.EndpointType.MANAGEMENT, OPTIONS); ManagementRemotingServices.installManagementChannelServices(serviceTarget, ManagementRemotingServices.MANAGEMENT_ENDPOINT, new ModelControllerOperationHandlerFactory() { @Override public AbstractModelControllerOperationHandlerFactoryService newInstance( final Consumer<AbstractModelControllerOperationHandlerFactoryService> serviceConsumer, final Supplier<ModelController> modelControllerSupplier, final Supplier<ExecutorService> executorSupplier, final Supplier<ScheduledExecutorService> scheduledExecutorSupplier) { return new ModelControllerClientOperationHandlerFactoryService(serviceConsumer, modelControllerSupplier, executorSupplier, scheduledExecutorSupplier); } }, Services.JBOSS_SERVER_CONTROLLER, ManagementRemotingServices.MANAGEMENT_CHANNEL, ServerService.EXECUTOR_CAPABILITY.getCapabilityServiceName(), ServerService.JBOSS_SERVER_SCHEDULED_EXECUTOR); } }
Example #25
Source File: TransactionalProtocolOperationHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** Signal from ProxyOperationTransactionControl that the operation is prepared */ synchronized void prepare(final ModelController.OperationTransaction tx, final ModelNode result) { assert !prepared; prepared = true; if(rollbackOnPrepare) { try { tx.rollback(); ControllerLogger.MGMT_OP_LOGGER.tracef("rolled back on prepare for %d --- interrupted: %s", getOperationId(), (Object) Thread.currentThread().isInterrupted()); } finally { txCompletedLatch.countDown(); } // no response to remote side here; the response will go out when this thread executing // the now rolled-back op returns in ExecuteRequestHandler.doExecute } else { assert activeTx == null; assert responseChannel != null; activeTx = tx; ControllerLogger.MGMT_OP_LOGGER.tracef("sending prepared response for %d --- interrupted: %s", getOperationId(), (Object) Thread.currentThread().isInterrupted()); try { sendResponse(responseChannel, ModelControllerProtocol.PARAM_OPERATION_PREPARED, result); responseChannel = null; // we've now sent a response to the original request, so we can't use this one further } catch (IOException e) { getResultHandler().failed(e); // this will eventually call back into failed(e) above and roll back the tx } } }
Example #26
Source File: ModelTestModelControllerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@SuppressWarnings("deprecation") @Override protected ModelNode internalExecute(final ModelNode operation, final OperationMessageHandler handler, final ModelController.OperationTransactionControl control, final OperationAttachments attachments, final OperationStepHandler prepareStep) { return super.internalExecute(operation, handler, control, attachments, prepareStep); }
Example #27
Source File: MonitorServiceActivator.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { Optional<String> securityRealm = Optional.empty(); if (!healthFractionInstance.isUnsatisfied()) { securityRealm = healthFractionInstance.get().securityRealm(); } ServiceTarget target = context.getServiceTarget(); MonitorService service = new MonitorService(securityRealm); ServiceBuilder<MonitorService> monitorServiceServiceBuilder = target.addService(MonitorService.SERVICE_NAME, service); ServiceBuilder<MonitorService> serviceBuilder = monitorServiceServiceBuilder .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.getServerEnvironmentInjector()) .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector()); if (securityRealm.isPresent()) { // configured through the fraction interface serviceBuilder.addDependency( createRealmName(securityRealm.get()), SecurityRealm.class, service.getSecurityRealmInjector() ); } serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE) .install(); BinderService binderService = new BinderService(Monitor.JNDI_NAME, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Monitor.JNDI_NAME), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(service)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example #28
Source File: RemoteDomainConnectionService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Apply the remote domain model to the local host controller. * * @param bootOperations the result of the remote read-domain-model op * @return {@code true} if the model was applied successfully, {@code false} otherwise */ private boolean applyRemoteDomainModel(final List<ModelNode> bootOperations, final HostInfo hostInfo) { try { HostControllerLogger.ROOT_LOGGER.debug("Applying domain level boot operations provided by master"); SyncModelParameters parameters = new SyncModelParameters(domainController, ignoredDomainResourceRegistry, hostControllerEnvironment, extensionRegistry, operationExecutor, true, serverProxies, remoteFileRepository, contentRepository); final SyncDomainModelOperationHandler handler = new SyncDomainModelOperationHandler(hostInfo, parameters); final ModelNode operation = APPLY_DOMAIN_MODEL.clone(); operation.get(DOMAIN_MODEL).set(bootOperations); final ModelNode result = operationExecutor.execute(OperationBuilder.create(operation).build(), OperationMessageHandler.DISCARD, ModelController.OperationTransactionControl.COMMIT, handler); final String outcome = result.get(OUTCOME).asString(); final boolean success = SUCCESS.equals(outcome); // check if anything we synced triggered reload-required or restart-required. // if they did we log a warning on the synced slave. if (result.has(RESPONSE_HEADERS)) { final ModelNode headers = result.get(RESPONSE_HEADERS); if (headers.hasDefined(OPERATION_REQUIRES_RELOAD) && headers.get(OPERATION_REQUIRES_RELOAD).asBoolean()) { HostControllerLogger.ROOT_LOGGER.domainModelAppliedButReloadIsRequired(); } if (headers.hasDefined(OPERATION_REQUIRES_RESTART) && headers.get(OPERATION_REQUIRES_RESTART).asBoolean()) { HostControllerLogger.ROOT_LOGGER.domainModelAppliedButRestartIsRequired(); } } if (!success) { ModelNode failureDesc = result.hasDefined(FAILURE_DESCRIPTION) ? result.get(FAILURE_DESCRIPTION) : new ModelNode(); HostControllerLogger.ROOT_LOGGER.failedToApplyDomainConfig(outcome, failureDesc); return false; } else { return true; } } catch (Exception e) { HostControllerLogger.ROOT_LOGGER.failedToApplyDomainConfig(e); return false; } }
Example #29
Source File: RemoteDomainConnectionService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static Future<MasterDomainControllerClient> install(final ServiceTarget serviceTarget, final ModelController controller, final ExtensionRegistry extensionRegistry, final LocalHostControllerInfo localHostControllerInfo, final ServiceName authenticationContext, final String securityRealm, final RemoteFileRepository remoteFileRepository, final ContentRepository contentRepository, final IgnoredDomainResourceRegistry ignoredDomainResourceRegistry, final HostControllerRegistrationHandler.OperationExecutor operationExecutor, final DomainController domainController, final HostControllerEnvironment hostControllerEnvironment, final ExecutorService executor, final RunningMode currentRunningMode, final Map<String, ProxyController> serverProxies, final AtomicBoolean domainConfigAvailable) { RemoteDomainConnectionService service = new RemoteDomainConnectionService(controller, extensionRegistry, localHostControllerInfo, remoteFileRepository, contentRepository, ignoredDomainResourceRegistry, operationExecutor, domainController, hostControllerEnvironment, executor, currentRunningMode, serverProxies, domainConfigAvailable); ServiceBuilder<MasterDomainControllerClient> builder = serviceTarget.addService(MasterDomainControllerClient.SERVICE_NAME, service) .addDependency(ManagementRemotingServices.MANAGEMENT_ENDPOINT, Endpoint.class, service.endpointInjector) .addDependency(ServerInventoryService.SERVICE_NAME, ServerInventory.class, service.serverInventoryInjector) .addDependency(HostControllerService.HC_SCHEDULED_EXECUTOR_SERVICE_NAME, ScheduledExecutorService.class, service.scheduledExecutorInjector) .setInitialMode(ServiceController.Mode.ACTIVE); if (authenticationContext != null) { builder.addDependency(authenticationContext, AuthenticationContext.class, service.authenticationContextInjector); } if (securityRealm != null) { SecurityRealm.ServiceUtil.addDependency(builder, service.securityRealmInjector, securityRealm); } builder.install(); return service.futureClient; }
Example #30
Source File: AbstractModelControllerOperationHandlerFactoryService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected AbstractModelControllerOperationHandlerFactoryService( final Consumer<AbstractModelControllerOperationHandlerFactoryService> serviceConsumer, final Supplier<ModelController> modelControllerSupplier, final Supplier<ExecutorService> executorSupplier, final Supplier<ScheduledExecutorService> scheduledExecutorSupplier ) { this.serviceConsumer = serviceConsumer; this.modelControllerSupplier = modelControllerSupplier; this.executorSupplier = executorSupplier; this.scheduledExecutorSupplier = scheduledExecutorSupplier; }