@Override public void installServices(OperationContext context, ModelNode model) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); String name = context.getCurrentAddressValue(); if (context.getProcessType().isServer() && !context.isBooting() && name.equals("ejb")) { PathElement ejbPath = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "ejb3"); Resource ejbResource = safeGetResource(context, ejbPath); if (ejbResource != null && ejbResource.hasChild(PathElement.pathElement("service", "remote"))) { context.addStep(new OperationStepHandler() { String defaultCache = DEFAULT_CACHE.resolveModelAttribute(context, model).asString(null); if (defaultCache != null) { for (Map.Entry<InfinispanCacheRequirement, Capability> entry : DEFAULT_CAPABILITIES.entrySet()) {
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ModelNode model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS)); context.removeResource(PathAddress.EMPTY_ADDRESS); final String name = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue(); final String oldValue = model.hasDefined(VALUE) ? model.get(VALUE).asString() : null; systemPropertyUpdater.isRuntimeSystemPropertyUpdateAllowed(name, oldValue, context.isBooting()); final boolean reload = !applyToRuntime && context.getProcessType().isServer();
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode model = context.createResource(PathAddress.EMPTY_ADDRESS).getModel(); for (AttributeDefinition attr : attributes) { attr.validateAndSet(operation, model); final String name = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue(); final String value = operation.hasDefined(VALUE.getName()) ? operation.get(VALUE.getName()).asString() : null; final boolean applyToRuntime = systemPropertyUpdater != null && systemPropertyUpdater.isRuntimeSystemPropertyUpdateAllowed(name, value, context.isBooting()); final boolean reload = !applyToRuntime && context.getProcessType().isServer();
def.validateOperation(operation); final String opName = operation.require(OP).asString(); PathAddress opAddr = PathAddress.pathAddress(operation.get(OP_ADDR)); final ModelNode feature = describeFeature(Locale.US, registry, CapabilityScope.Factory.create(context.getProcessType(), pa), isProfileScope(context.getProcessType(), pa)); if (pa.size() == 0 && context.getProcessType().isServer()) { //server-root feature spec ModelNode param = new ModelNode(); param.get(ModelDescriptionConstants.NAME).set("server-root"); if (pa.getLastElement() != null && SUBSYSTEM.equals(pa.getLastElement().getKey())) { String extension = getExtension(context, pa.getLastElement().getValue()); if (extension != null) { ModelNode extensionParam = new ModelNode(); final ModelNode childNode = children.get(element.getKey()); childNode.get(FEATURE); final ModelNode rrOp = operation.clone();
ModelNode product = new ModelNode().setEmptyObject(); product.get(HOSTNAME).set(installation.getHostName()); product.get(INSTANCE_ID).set(environment.getInstanceUuid().toString()); PathAddress organizationAddress = PathAddress.EMPTY_ADDRESS; if (context.getProcessType().isHostController()) { organizationAddress = PathAddress.pathAddress(HOST, environment.getHostControllerName()); ModelNode root = context.readResourceFromRoot(organizationAddress, false).getModel(); if (!root.hasDefined(ORGANIZATION) && context.getProcessType().isHostController()) { root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getModel(); if (root.hasDefined(ORGANIZATION)) { product.get(PRODUCT_LAST_UPDATE).set(updateDate); product.get(STANDALONE_DOMAIN_IDENTIFIER).set(context.getProcessType().name()); product.get(OS).set(createOSNode()); product.get(CPU).set(createCPUNode());
throw ControllerLogger.ROOT_LOGGER.stageAlreadyComplete(stage); if (stage == Stage.DOMAIN && !processType.isHostController()) { throw ControllerLogger.ROOT_LOGGER.invalidStage(stage, processType); throw ControllerLogger.ROOT_LOGGER.invalidStepStage(); final PathAddress stepAddress = address != null ? address : PathAddress.pathAddress(operation.get(OP_ADDR)); if (stage == Stage.RUNTIME && !processType.isServer() && stepAddress.size() > 1 && PROFILE.equals(stepAddress.getElement(0).getKey())) { ControllerLogger.ROOT_LOGGER.invalidRuntimeStageForProfile(operation.get(OP).asString(), stepAddress.toCLIStyleString(), stage, processType); return;
if (finalResponse != null) { ModelNode responseNode = finalResponse.getResponseNode(); ModelNode finalResult = responseNode.get(RESULT); PathAddress currentAddress = context.getCurrentAddress(); if (currentAddress.isMultiTarget()) { untranslateResultAddress(currentAddress, finalResult); if (responseNode.hasDefined(FAILURE_DESCRIPTION)) { context.getFailureDescription().set(responseNode.get(FAILURE_DESCRIPTION)); if (finalResult.isDefined()) { context.getResult().set(finalResult); context.getResult().set(finalResult); if (context.getProcessType().isHostController() && responseNode.has(SERVER_GROUPS)) { context.getServerResults().set(responseNode.get(SERVER_GROUPS)); ControllerLogger.MGMT_OP_LOGGER.noFinalProxyOutcomeReceived(operation.get(OP), operation.get(OP_ADDR), proxyController.getProxyNodeAddress().toModelNode());
ROOT_LOGGER.activatingSubsystem(Version.printVersion()); ServiceTarget target = context.getServiceTarget(); PathAddress address = context.getCurrentAddress(); if (context.getProcessType().isServer() && !context.isBooting()) { if (context.readResourceFromRoot(address.getParent(),false).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan"))) { context.addStep((ctx, operation) -> { String defaultChannel = DEFAULT_CHANNEL.resolveModelAttribute(context, model).asStringOrNull(); if (defaultChannel != null) { for (Map.Entry<JGroupsRequirement, Capability> entry : CAPABILITIES.entrySet()) {
/** * Checks if the context is running on a {@linkplain ProcessType#isServer() server} or on a host controller. This * will return {@code true} even if the server is running in {@link org.jboss.as.controller.RunningMode#ADMIN_ONLY}. * * @param context the current operation context * * @return {@code true} if the current context is a server or a host controller */ default boolean isServerOrHostController(final OperationContext context) { return context.getProcessType().isServer() || !ModelDescriptionConstants.PROFILE.equals(context.getCurrentAddress().getElement(0).getKey()); } }
private AuthorizationResponseImpl getBasicAuthorizationResponse(OperationId opId, ModelNode operation) { Caller caller = getCaller(); ImmutableManagementResourceRegistration mrr = modelController.getRootRegistration().getSubModel(opId.address); if (mrr == null) { return null; ProcessType processType = getProcessType(); TargetResource targetResource; if (processType.isManagedDomain()) { HostServerGroupTracker.HostServerGroupEffect hostServerGroupEffect; if (processType.isServer()) { ModelNode rootModel = model.getModel(); String serverGroup = rootModel.get(SERVER_GROUP).asString(); String host = rootModel.get(HOST).asString(); hostServerGroupEffect = HostServerGroupTracker.HostServerGroupEffect.forServer(opId.address, serverGroup, host); } else {
@Override protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException { final PathAddress addr = PathAddress.pathAddress(operation.require(OP_ADDR)); String name = addr.getLastElement().getValue(); boolean found = context.getProcessType().isServer() ? lookForHandlerForServer(context, name) : lookForHandlerForHc(context, name); if (!found) { throw JmxMessages.MESSAGES.noHandlerCalled(name); } resource.getModel().setEmptyObject(); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { Resource resource; if (!context.getProcessType().isServer()) { try { resource = context.readResourceFromRoot(context.getCurrentAddress().getParent(), false); validation(socketBindingGroupName, outboundSocketBindingName, resource, true, new ArrayList<String>()); } catch (Resource.NoSuchResourceException e) { // this occurs in the case of an ignored server-group being added to a slave. // for all other cases, the parent element is always present. return; } }else{ resource = context.readResourceFromRoot(PathAddress.pathAddress(ModelDescriptionConstants.SOCKET_BINDING_GROUP, socketBindingGroupName), false); validation(socketBindingGroupName, outboundSocketBindingName, resource, false, new ArrayList<String>()); } }
String expressionsDomain = getDomainName(context, model, CommonAttributes.EXPRESSION); boolean legacyWithProperPropertyFormat = false; if (model.hasDefined(CommonAttributes.PROPER_PROPERTY_FORMAT)) { legacyWithProperPropertyFormat = ExposeModelResourceExpression.DOMAIN_NAME.resolveModelAttribute(context, model).asBoolean(); boolean coreMBeanSensitivity = JMXSubsystemRootResource.CORE_MBEAN_SENSITIVITY.resolveModelAttribute(context, model).asBoolean(); final boolean isMasterHc; if (context.getProcessType().isHostController()) { isMasterHc = hostInfoAccessor.getHostControllerInfo(context).isMasterHc(); } else { if (context.getProcessType() == ProcessType.DOMAIN_SERVER) { ModelNode rootModel = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getModel(); String hostName = null; if(rootModel.hasDefined(HOST)) {
ModelNode targetServer = TARGET_SERVER.resolveModelAttribute(context, operation); ModelNode targetHost = TARGET_HOST.resolveModelAttribute(context, operation); final BlockPoint blockPoint = BlockPoint.valueOf(BLOCK_POINT.resolveModelAttribute(context, operation).asString()); log.info("block requested by " + CALLER.resolveModelAttribute(context, operation).asString() + " for " + targetHost.asString() + "/" + targetServer.asString() + "(" + blockPoint + ")"); boolean forMe = false; if (context.getProcessType() == ProcessType.STANDALONE_SERVER) { forMe = true; context.acquireControllerLock(); } else { context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS); // To help with WFCORE-263 testing, get the exclusive lock on this process Resource rootResource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); if (targetServer.isDefined()) { if (context.getProcessType().isServer()) { String name = System.getProperty(ServerEnvironment.SERVER_NAME); forMe = targetServer.asString().equals(name); } else if (context.getProcessType().isHostController()) { Set<String> hosts = rootResource.getChildrenNames(HOST); String name; if (hosts.size() > 1) {
public static void validateAtBoot(OperationContext context, ModelNode operation) { assert !context.getProcessType().isServer() : "Not a host controller"; assert context.isBooting() : "Should only be called at boot"; assert operation.require(OP).asString().equals("validate"); //Should only be called by the domain controller service //Only validate once if (context.attachIfAbsent(KEY, DomainModelIncludesValidator.INSTANCE) == null) { context.addStep(DomainModelIncludesValidator.INSTANCE, OperationContext.Stage.MODEL); } }
ModelNode targetServer = TARGET_SERVER.resolveModelAttribute(context, operation); ModelNode targetHost = TARGET_HOST.resolveModelAttribute(context, operation); final ErrorPoint errorPoint = ErrorPoint.valueOf(ERROR_POINT.resolveModelAttribute(context, operation).asString()); log.info("error requested by " + CALLER.resolveModelAttribute(context, operation).asString() + " for " + targetHost.asString() + "/" + targetServer.asString() + "(" + errorPoint + ")"); boolean forMe = false; if (context.getProcessType() == ProcessType.STANDALONE_SERVER) { forMe = true; } else { Resource rootResource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); if (targetServer.isDefined()) { if (context.getProcessType().isServer()) { String name = System.getProperty(ServerEnvironment.SERVER_NAME); forMe = targetServer.asString().equals(name); } else if (context.getProcessType().isHostController()) { Set<String> hosts = rootResource.getChildrenNames(HOST); String name; if (hosts.size() > 1) {
private ExtensionContextImpl(String extensionName, ManagementResourceRegistration profileResourceRegistration, ManagementResourceRegistration deploymentsResourceRegistration, PathManager pathManager, ExtensionRegistryType extensionRegistryType, ManagedAuditLogger auditLogger) { assert pathManager != null || !processType.isServer() : "pathManager is null"; this.pathManager = pathManager; this.extension = getExtensionInfo(extensionName); this.registerTransformers = extensionRegistryType == ExtensionRegistryType.MASTER; this.auditLogger = auditLogger; this.allowSupplement = auditLogger != null; this.profileRegistration = profileResourceRegistration; if (deploymentsResourceRegistration != null) { PathAddress subdepAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SUBDEPLOYMENT)); final ManagementResourceRegistration subdeployments = deploymentsResourceRegistration.getSubModel(subdepAddress); this.deploymentsRegistration = subdeployments == null ? deploymentsResourceRegistration : new DeploymentManagementResourceRegistration(deploymentsResourceRegistration, subdeployments); } else { this.deploymentsRegistration = null; } this.extensionRegistryType = extensionRegistryType; }
private boolean isProfileScope(ProcessType processType, PathAddress address) { return !processType.isServer() && address.size() >= 2 && PROFILE.equals(address.getElement(0).getKey()); }
default String getFeature() { if(PathAddress.EMPTY_ADDRESS.equals(getPathAddress())) { if(getProcessType().isServer()) { return "server-root"; } return ""; } StringJoiner joiner = new StringJoiner("."); final PathAddress pathAddress = getPathAddress(); final String initialKey = pathAddress.getElement(0).getKey(); if (getProcessType().isManagedDomain() && !HOST.equals(initialKey) && !PROFILE.equals(initialKey)) { joiner.add(DOMAIN); } for (int i = 0; i < pathAddress.size(); i++) { PathElement elt = pathAddress.getElement(i); joiner.add(elt.getKey()); if (!elt.isWildcard() && (i > 0 || !HOST.equals(elt.getKey()))) { joiner.add(elt.getValue()); } } return joiner.toString(); }
@Override protected void validateUpdatedModel(OperationContext context, Resource model) throws OperationFailedException { // Add a new step to validate instead of doing it directly in this method. // This allows a composite op to change both attributes and then the // validation occurs after both have done their work. context.addStep((ctx, operation) -> { final ModelNode conf = ctx.readResource(PathAddress.EMPTY_ADDRESS).getModel(); // TODO doesn't cover the admin-only modes if (ctx.getProcessType().isServer() && ( conf.hasDefined(ModelKeys.DEFAULT_EXECUTOR) || conf.hasDefined(ModelKeys.THREAD_FACTORY))) { // That is not supported. throw new OperationFailedException(JGroupsLogger.ROOT_LOGGER.threadsAttributesUsedInRuntime()); } }, OperationContext.Stage.MODEL); } }