org.jboss.dmr.Property Java Examples
The following examples show how to use
org.jboss.dmr.Property.
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: ManagedServerOperationsFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void addSystemProperties(final ModelNode source, final Map<String, String> props, boolean boottimeOnly) { if (source.hasDefined(SYSTEM_PROPERTY)) { for (Property prop : source.get(SYSTEM_PROPERTY).asPropertyList()) { ModelNode propResource = prop.getValue(); try { if (boottimeOnly && !SystemPropertyResourceDefinition.BOOT_TIME.resolveModelAttribute(domainController.getExpressionResolver(), propResource).asBoolean()) { continue; } } catch (OperationFailedException e) { throw new IllegalStateException(e); } String val = propResource.hasDefined(VALUE) ? propResource.get(VALUE).asString() : null; props.put(prop.getName(), val); } } }
Example #2
Source File: FormatterOperationsTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void validateValue(final KernelServices kernelServices, final ModelNode address, final String attributeName, final Map<String, String> expectedValues) { final ModelNode value = executeOperation(kernelServices, SubsystemOperations.createReadAttributeOperation(address, attributeName)); Assert.assertEquals(ModelType.OBJECT, value.getType()); final Map<String, String> remainingKeys = new LinkedHashMap<>(expectedValues); for (Property property : SubsystemOperations.readResult(value).asPropertyList()) { final String key = property.getName(); final String expectedValue = remainingKeys.remove(key); if (expectedValue == null) { Assert.assertFalse(property.getValue().isDefined()); } else { Assert.assertEquals(expectedValue, property.getValue().asString()); } } Assert.assertTrue(String.format("Missing keys in model:%nKeys: %s%nModel%s%n", remainingKeys, SubsystemOperations.readResult(value)), remainingKeys.isEmpty()); }
Example #3
Source File: AttributeTransformationRequirementChecker.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Check an attribute for expressions. * * @param node the attribute value * @return whether an expression was found or not */ private boolean checkForExpression(final ModelNode node) { if (!node.isDefined()) { return false; } final ModelNode resolved = node.clone(); if (node.getType() == ModelType.EXPRESSION || node.getType() == ModelType.STRING) { return checkForExpression(resolved.asString()); } else if (node.getType() == ModelType.OBJECT) { for (Property prop : resolved.asPropertyList()) { if(checkForExpression(prop.getValue())) { return true; } } } else if (node.getType() == ModelType.LIST) { for (ModelNode current : resolved.asList()) { if(checkForExpression(current)) { return true; } } } else if (node.getType() == ModelType.PROPERTY) { return checkForExpression(resolved.asProperty().getValue()); } return false; }
Example #4
Source File: ManagementVersionTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testExtensions() throws Exception { ModelNode op = createOpNode(null, "read-children-resources"); op.get("child-type").set("extension"); op.get("recursive").set(true); op.get("include-runtime").set(true); ModelNode result = executeOperation(op); for (Property extension : result.asPropertyList()) { String extensionName = extension.getName(); ModelNode subsystems = extension.getValue().get("subsystem"); Assert.assertEquals(extensionName + " has no subsystems", ModelType.OBJECT, subsystems.getType()); for (Property subsystem : subsystems.asPropertyList()) { String subsystemName = subsystem.getName(); ModelNode value = subsystem.getValue(); Assert.assertEquals(subsystemName + " has major version", ModelType.INT, value.get("management-major-version").getType()); Assert.assertEquals(subsystemName + " has minor version", ModelType.INT, value.get("management-minor-version").getType()); Assert.assertEquals(subsystemName + " has micro version", ModelType.INT, value.get("management-micro-version").getType()); Assert.assertEquals(subsystemName + " has namespaces", ModelType.LIST, value.get("xml-namespaces").getType()); Assert.assertTrue(subsystemName + " has positive major version", value.get("management-major-version").asInt() > 0); Assert.assertTrue(subsystemName + " has positive minor version", value.get("management-minor-version").asInt() >= 0); Assert.assertTrue(subsystemName + " has positive micro version", value.get("management-micro-version").asInt() >= 0); Assert.assertTrue(subsystemName + " has more than zero namespaces", value.get("xml-namespaces").asInt() > 0); } } }
Example #5
Source File: AbstractITest.java From hawkular-agent with Apache License 2.0 | 6 votes |
protected void assertResourceCount(ModelControllerClient mcc, ModelNode address, String childType, int expectedCount) throws IOException { ModelNode request = new ModelNode(); request.get(ModelDescriptionConstants.ADDRESS).set(address); request.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.READ_CHILDREN_RESOURCES_OPERATION); request.get(ModelDescriptionConstants.CHILD_TYPE).set(childType); request.get(ModelDescriptionConstants.INCLUDE_RUNTIME).set(true); ModelNode response = mcc.execute(request); if (response.hasDefined(ModelDescriptionConstants.OUTCOME) && response.get(ModelDescriptionConstants.OUTCOME) .asString().equals(ModelDescriptionConstants.SUCCESS)) { ModelNode result = response.get(ModelDescriptionConstants.RESULT); List<Property> nodes = result.asPropertyList(); AssertJUnit.assertEquals("Number of child nodes of [" + address + "] " + response, expectedCount, nodes.size()); } else if (expectedCount != 0) { AssertJUnit .fail("Path [" + address + "] has no child nodes, expected [" + expectedCount + "]: " + response); } }
Example #6
Source File: Address.java From hawkular-agent with Apache License 2.0 | 6 votes |
/** * @return returns the address split into its individual parts. * e.g. "/one=two" will return a 2-element array {"one", "two"}. */ public String[] toAddressParts() { if (isRoot()) { return new String[0]; } List<Property> properties = addressNode.asPropertyList(); String[] parts = new String[properties.size() * 2]; int i = 0; for (Property property : properties) { String name = property.getName(); String value = property.getValue().asString(); parts[i++] = name; parts[i++] = value; } return parts; }
Example #7
Source File: DefaultOperationCandidatesProvider.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private boolean canAppearNext(Property prop) { if (presentProperties.contains(prop.getName())) { return false; } // If user typed something, complete if possible. // Invalid properties will be exposed in this case. if (radical != null && !radical.isEmpty()) { return prop.getName().startsWith(radical); } // The invalid alternatives if (invalidProperties.contains(prop.getName())) { return false; } return true; }
Example #8
Source File: DataSourceAddCompositeHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { final ModelNode req = super.buildRequestWithoutHeaders(ctx); final ModelNode steps = req.get(Util.STEPS); final ModelNode conPropsNode = conProps.toModelNode(ctx); if(conPropsNode != null) { final List<Property> propsList = conPropsNode.asPropertyList(); for(Property prop : propsList) { final ModelNode address = this.buildOperationAddress(ctx); address.add(CONNECTION_PROPERTIES, prop.getName()); final ModelNode addProp = new ModelNode(); addProp.get(Util.ADDRESS).set(address); addProp.get(Util.OPERATION).set(Util.ADD); addProp.get(Util.VALUE).set(prop.getValue()); steps.add(addProp); } } return req; }
Example #9
Source File: DefaultDeploymentOperations.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public Set<String> getUnrelatedDeployments(ModelNode owner) { final ModelNode op = Util.getEmptyOperation(READ_CHILDREN_RESOURCES_OPERATION, new ModelNode()); op.get(CHILD_TYPE).set(DEPLOYMENT); ModelNode response = privilegedExecution().execute(controllerClient::execute, op); // Ensure the operation succeeded before we use the result if(response.get(OUTCOME).isDefined() && !SUCCESS.equals(response.get(OUTCOME).asString())) throw ROOT_LOGGER.deployModelOperationFailed(response.get(FAILURE_DESCRIPTION).asString()); final ModelNode result = response.get(RESULT); final Set<String> deployments = new HashSet<String>(); if (result.isDefined()) { for (Property property : result.asPropertyList()) { if(!owner.equals(property.getValue().get(OWNER))) { deployments.add(property.getName()); } } } return deployments; }
Example #10
Source File: DiscoveryOptionsResource.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected Resource getOption(String type, String name) { final ModelNode options = delegate.getModel().get(ModelDescriptionConstants.OPTIONS); if (!options.isDefined()) { return null; } final boolean staticOption = ModelDescriptionConstants.STATIC_DISCOVERY.equals(type); for (Property prop : options.asPropertyList()) { if (staticOption) { if (prop.getName().equals(ModelDescriptionConstants.STATIC_DISCOVERY) && prop.getValue().has(ModelDescriptionConstants.NAME) && prop.getValue().get(ModelDescriptionConstants.NAME).asString().equals(name)) { return getResource(prop); } } else if (prop.getName().equals(ModelDescriptionConstants.CUSTOM_DISCOVERY) && prop.getValue().has(ModelDescriptionConstants.NAME) && prop.getValue().get(ModelDescriptionConstants.NAME).asString().equals(name)) { return getResource(prop); } } return null; }
Example #11
Source File: LoggingPropertiesTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testDeploymentConfigurationResource() throws Exception { final ModelNode loggingConfiguration = readDeploymentResource(DEPLOYMENT_NAME); // The address should have jboss-log4j.xml final LinkedList<Property> resultAddress = new LinkedList<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList()); Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties")); final ModelNode handler = loggingConfiguration.get("handler", "FILE"); Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined()); Assert.assertTrue(handler.hasDefined("properties")); String fileName = null; // Find the fileName property for (Property property : handler.get("properties").asPropertyList()) { if ("fileName".equals(property.getName())) { fileName = property.getValue().asString(); break; } } Assert.assertNotNull("fileName property not found", fileName); Assert.assertTrue(fileName.endsWith("logging-properties-test.log")); }
Example #12
Source File: DeploymentResourceTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testRuntimeName() throws Exception { final JavaArchive deployment = createDeployment(); deploy(deployment, RUNTIME_NAME); final ModelNode loggingConfiguration = readDeploymentResource(DEPLOYMENT_NAME); // The address should have logging.properties final LinkedList<Property> resultAddress = new LinkedList<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList()); Assert.assertEquals("The configuration path did not contain default", "default", resultAddress.getLast().getValue().asString()); final ModelNode handler = loggingConfiguration.get("handler", "FILE"); Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined()); Assert.assertTrue("The attribute properties was not found on the file handler", handler.hasDefined("properties")); String fileName = null; // Find the fileName property for (Property property : handler.get("properties").asPropertyList()) { if ("fileName".equals(property.getName())) { fileName = property.getValue().asString(); break; } } Assert.assertNotNull("fileName property not found", fileName); Assert.assertTrue("Expected the file name to end in server.log", fileName.endsWith("server.log")); }
Example #13
Source File: DeploymentResourceTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testLoggingProfileRuntimeName() throws Exception { final JavaArchive deployment = createDeployment() .addAsResource(new StringAsset("Dependencies: io.undertow.core\nLogging-Profile: " + PROFILE_NAME), "META-INF/MANIFEST.MF"); deploy(deployment, RUNTIME_NAME); final ModelNode loggingConfiguration = readDeploymentResource(DEPLOYMENT_NAME); // The address should have logging.properties final LinkedList<Property> resultAddress = new LinkedList<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList()); Assert.assertEquals("The configuration path did not include profile-" + PROFILE_NAME, "profile-" + PROFILE_NAME, resultAddress.getLast().getValue().asString()); final ModelNode handler = loggingConfiguration.get("handler", "FILE"); Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined()); Assert.assertTrue("The attribute properties was not found on the file handler", handler.hasDefined("properties")); String fileName = null; // Find the fileName property for (Property property : handler.get("properties").asPropertyList()) { if ("fileName".equals(property.getName())) { fileName = property.getValue().asString(); break; } } Assert.assertNotNull("fileName property not found", fileName); Assert.assertTrue("Expected the file name to end in server.log", fileName.endsWith(PROFILE_LOG_NAME)); }
Example #14
Source File: DeploymentResourceTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testPerDeploymentRuntimeName() throws Exception { final JavaArchive deployment = createDeployment() .addAsResource(DeploymentBaseTestCase.class.getPackage(), "logging.properties", "META-INF/logging.properties"); deploy(deployment, RUNTIME_NAME); final ModelNode loggingConfiguration = readDeploymentResource(DEPLOYMENT_NAME); // The address should have logging.properties final LinkedList<Property> resultAddress = new LinkedList<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList()); Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties")); final ModelNode handler = loggingConfiguration.get("handler", "FILE"); Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined()); Assert.assertTrue("Properties were not defined on the FILE handler", handler.hasDefined("properties")); String fileName = null; // Find the fileName property for (Property property : handler.get("properties").asPropertyList()) { if ("fileName".equals(property.getName())) { fileName = property.getValue().asString(); break; } } Assert.assertNotNull("fileName property not found", fileName); Assert.assertTrue(String.format("Expected the file name to end in %s but was %s", PER_DEPLOY_LOG_NAME, fileName), fileName.endsWith(PER_DEPLOY_LOG_NAME)); }
Example #15
Source File: ArgumentValueParsingTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testObjectWithPropertyList() throws Exception { final ModelNode value = parse("a=b,c=[d=e,f=g]"); assertNotNull(value); assertEquals(ModelType.OBJECT, value.getType()); final List<Property> list = value.asPropertyList(); assertEquals(2, list.size()); Property prop = list.get(0); assertNotNull(prop); assertEquals("a", prop.getName()); assertEquals("b", prop.getValue().asString()); prop = list.get(1); assertNotNull(prop); assertEquals("c", prop.getName()); final ModelNode c = prop.getValue(); assertEquals(ModelType.LIST, c.getType()); final List<Property> propList = c.asPropertyList(); assertEquals(2, propList.size()); prop = propList.get(0); assertEquals("d", prop.getName()); assertEquals("e", prop.getValue().asString()); prop = propList.get(1); assertEquals("f", prop.getName()); assertEquals("g", prop.getValue().asString()); }
Example #16
Source File: DomainServerUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public static Set<ServerIdentity> getServersForGroup(String groupName, ModelNode hostModel, final String localHostName, final Map<String, ProxyController> serverProxies) { Set<ServerIdentity> result; if (hostModel.hasDefined(SERVER_CONFIG)) { result = new HashSet<ServerIdentity>(); for (Property prop : hostModel.get(SERVER_CONFIG).asPropertyList()) { String serverName = prop.getName(); if (serverProxies.get(serverName) == null) { continue; } ModelNode server = prop.getValue(); String serverGroupName = server.require(GROUP).asString(); if (groupName != null && !groupName.equals(serverGroupName)) { continue; } ServerIdentity groupedServer = new ServerIdentity(localHostName, serverGroupName, serverName); result.add(groupedServer); } } else { result = Collections.emptySet(); } return result; }
Example #17
Source File: LoggingSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public ModelNode fixModel(final ModelNode modelNode) { // Recursively remove the attributes if (modelNode.getType() == ModelType.OBJECT) { for (Property property : modelNode.asPropertyList()) { final String name = property.getName(); final ModelNode value = property.getValue(); if (value.isDefined()) { if (value.getType() == ModelType.OBJECT) { modelNode.get(name).set(fixModel(value)); } else if (value.getType() == ModelType.STRING) { if (name.equals(attribute.getName())) { modelNode.get(name).set(value.asString().replace(from, to)); } } } } } return modelNode; }
Example #18
Source File: CapabilityReloadRequiredUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void assertRequiresReload(ModelNode op, boolean expectRequires, String... serverGroups) throws IOException { ModelNode origResp = executeOp(op); for (String sg : serverGroups) { for (Property prop : origResp.get(SERVER_GROUPS, sg, HOST).asPropertyList()) { String host = prop.getName(); for (Property prop2 : prop.getValue().asPropertyList()) { String server = prop2.getName(); ModelNode response = prop2.getValue().get(RESPONSE); // Hack for composites if (COMPOSITE.equals(op.get(OP).asString())) { response = response.get(RESULT, "step-1"); } String target = " " + sg + "/" + host + "/" + server; if (expectRequires) { assertTrue(origResp.toString() + target, response.hasDefined(RESPONSE_HEADERS, OPERATION_REQUIRES_RELOAD)); assertTrue(origResp.toString() + target, response.get(RESPONSE_HEADERS, OPERATION_REQUIRES_RELOAD).asBoolean()); } else { assertFalse(origResp.toString() + target, response.hasDefined(RESPONSE_HEADERS, OPERATION_REQUIRES_RELOAD)); } } } } }
Example #19
Source File: MapValidator.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined()) { List<Property> list = value.asPropertyList(); int size = list.size(); if (size < min) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidMinSize(size, parameterName, min)); } else if (size > max) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidMaxSize(size, parameterName, max)); } else { for (Property property : list) { elementValidator.validateParameter(parameterName, property.getValue()); } } } }
Example #20
Source File: ExtensionManagementTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void extensionVersionTest(ModelControllerClient client, String addressPrefix) throws Exception { String address = addressPrefix == null ? ADDRESS : addressPrefix + '/' + ADDRESS; ModelNode op = createOpNode(address, "read-resource"); op.get("recursive").set(true); op.get("include-runtime").set(true); ModelNode result = executeForResult(op, client); ModelNode subsystems = result.get("subsystem"); Assert.assertEquals("extension has no subsystems", ModelType.OBJECT, subsystems.getType()); for (Property subsystem : subsystems.asPropertyList()) { String subsystemName = subsystem.getName(); int version = Integer.parseInt(subsystemName); ModelNode value = subsystem.getValue(); Assert.assertEquals(subsystemName + " has major version", ModelType.INT, value.get("management-major-version").getType()); Assert.assertEquals(subsystemName + " has minor version", ModelType.INT, value.get("management-minor-version").getType()); Assert.assertEquals(subsystemName + " has micro version", ModelType.INT, value.get("management-micro-version").getType()); Assert.assertEquals(subsystemName + " has namespaces", ModelType.LIST, value.get("xml-namespaces").getType()); Assert.assertEquals(subsystemName + " has correct major version", version, value.get("management-major-version").asInt()); Assert.assertEquals(subsystemName + " has correct minor version", version, value.get("management-minor-version").asInt()); Assert.assertEquals(subsystemName + " has correct micro version", version, value.get("management-micro-version").asInt()); Assert.assertTrue(subsystemName + " has more than zero namespaces", value.get("xml-namespaces").asInt() > 0); } }
Example #21
Source File: SchemaLocationRemoveHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ModelNode model = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel(); ModelNode param = URI.resolveModelAttribute(context, operation); ModelNode locations = model.get(SCHEMA_LOCATIONS); Property toRemove = null; ModelNode newList = new ModelNode().setEmptyList(); String uri = param.asString(); if (locations.isDefined()) { for (Property location : locations.asPropertyList()) { if (uri.equals(location.getName())) { toRemove = location; } else { newList.add(location.getName(), location.getValue()); } } } if (toRemove != null) { locations.set(newList); } else { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.schemaNotFound(uri)); } }
Example #22
Source File: ArgumentValueConverterTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testObject_SimpleCommaSeparatedInCurlyBraces() throws Exception { final ModelNode value = parseObject("{a=b,c=d}"); assertNotNull(value); assertEquals(ModelType.OBJECT, value.getType()); final List<Property> list = value.asPropertyList(); assertEquals(2, list.size()); Property prop = list.get(0); assertNotNull(prop); assertEquals("a", prop.getName()); assertEquals("b", prop.getValue().asString()); prop = list.get(1); assertNotNull(prop); assertEquals("c", prop.getName()); assertEquals("d", prop.getValue().asString()); }
Example #23
Source File: DefaultOperationCandidatesProviderTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testGetPropertiesFromPropList() throws Exception { List<Property> propList = new ArrayList<>(); propList.add(new Property("blocking", ModelNode.fromString(list_content))); propList.add(new Property("blocking-param", ModelNode.fromString(list_content))); propList.add(new Property("start-mode", ModelNode.fromString(list_content))); MockCommandContext ctx = new MockCommandContext(); String operationName = "operationName"; ctx.parseCommandLine(":" + operationName + "(!blocking", false); DefaultOperationRequestAddress address = new DefaultOperationRequestAddress(); DefaultOperationCandidatesProvider candidatesProvider = new DefaultOperationCandidatesProvider(); List<CommandArgument> candidates = candidatesProvider .getPropertiesFromPropList(propList, ctx, operationName, address); assertEquals(propList.size(), candidates.size()); for (CommandArgument candidate : candidates) { if(candidate.getFullName().equals("blocking")) assertFalse("Property blocking can't appear next, since it's completely specified" + " on the commandline as !blocking", candidate.canAppearNext(ctx)); else assertTrue(candidate.canAppearNext(ctx)); } }
Example #24
Source File: ManagedServerBootCmdFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void addSystemProperties(final ModelNode source, final Map<String, String> props, boolean boottimeOnly) { if (source.hasDefined(SYSTEM_PROPERTY)) { for (Property prop : source.get(SYSTEM_PROPERTY).asPropertyList()) { ModelNode propResource = prop.getValue(); try { if (boottimeOnly && !SystemPropertyResourceDefinition.BOOT_TIME.resolveModelAttribute(expressionResolver, propResource).asBoolean()) { continue; } } catch (OperationFailedException e) { throw new IllegalStateException(e); } String val = propResource.hasDefined(VALUE) ? propResource.get(VALUE).asString() : null; props.put(prop.getName(), val); } } }
Example #25
Source File: WorkerAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private static int getGlobalSuggestedCount(final OperationContext context, final ModelNode workers) throws OperationFailedException { int count = 0; if (!workers.isDefined()){ return count; } for (Property property : workers.asPropertyList()) { ModelNode worker = property.getValue(); ModelNode ioThreadsModel = WORKER_IO_THREADS.resolveModelAttribute(context, worker); ModelNode maxTaskThreadsModel = WORKER_TASK_MAX_THREADS.resolveModelAttribute(context, worker); if (ioThreadsModel.isDefined()) { count += ioThreadsModel.asInt(); } else { count += getSuggestedIoThreadCount(); } if (maxTaskThreadsModel.isDefined()) { count += maxTaskThreadsModel.asInt(); } else { count += getSuggestedTaskCount(); } } return count; }
Example #26
Source File: DiscoveryOptionsResource.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected boolean hasOption(String type) { final ModelNode options = delegate.getModel().get(ModelDescriptionConstants.OPTIONS); if (!options.isDefined()) { return false; } final boolean staticOption = ModelDescriptionConstants.STATIC_DISCOVERY.equals(type); for (Property prop : options.asPropertyList()) { if (staticOption) { if (prop.getName().equals(ModelDescriptionConstants.STATIC_DISCOVERY)) { return true; } } else if (prop.getName().equals(ModelDescriptionConstants.CUSTOM_DISCOVERY)) { return true; } } return false; }
Example #27
Source File: ResourceWithNotificationDefinitionTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testReadResourceDescriptionWithNotification() throws Exception { ModelNode readResourceDescription = createOperation(READ_RESOURCE_DESCRIPTION_OPERATION); readResourceDescription.get(NOTIFICATIONS).set(true); ModelNode description = executeForResult(readResourceDescription); assertTrue(description.hasDefined(NOTIFICATIONS)); List<Property> notifications = description.require(NOTIFICATIONS).asPropertyList(); assertEquals(1, notifications.size()); Property notification = notifications.get(0); assertEquals(MY_TYPE, notification.getName()); assertEquals(MY_TYPE, notification.getValue().get(NOTIFICATION_TYPE).asString()); assertEquals(NOTIFICATION_DESCRIPTION, notification.getValue().get(DESCRIPTION).asString()); assertEquals(DATA_TYPE_DESCRIPTION, notification.getValue().get(NOTIFICATION_DATA_TYPE)); }
Example #28
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private static Map<String, String> resolveProperties( final OperationContext context, final ModelNode model) throws OperationFailedException { Map<String, String> configurationProperties; if (model.hasDefined(PROPERTY)) { List<Property> propertyList = model.require(PROPERTY).asPropertyList(); configurationProperties = new HashMap<String, String>(propertyList.size()); for (Property current : propertyList) { String propertyName = current.getName(); ModelNode valueNode = PropertyResourceDefinition.VALUE.resolveModelAttribute(context, current.getValue()); String value = valueNode.isDefined() ? valueNode.asString() : null; configurationProperties.put(propertyName, value); } configurationProperties = Collections.unmodifiableMap(configurationProperties); } else { configurationProperties = Collections.emptyMap(); } return configurationProperties; }
Example #29
Source File: ServerOperationResolver.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private Map<Set<ServerIdentity>, ModelNode> getJVMRestartOperations(final PathAddress address, final ModelNode hostModel) { // See which servers are affected by this JVM change final String pathName = address.getElement(0).getValue(); final Map<Set<ServerIdentity>, ModelNode> result; if (hostModel.hasDefined(SERVER_CONFIG)) { final Set<ServerIdentity> servers = new HashSet<ServerIdentity>(); for (Property prop : hostModel.get(SERVER_CONFIG).asPropertyList()) { final String serverName = prop.getName(); if (serverProxies.get(serverName) == null) { // No running server continue; } final ModelNode server = prop.getValue(); if (server.hasDefined(JVM) && server.get(JVM).keys().contains(pathName)) { final String serverGroupName = server.require(GROUP).asString(); final ServerIdentity groupedServer = new ServerIdentity(localHostName, serverGroupName, serverName); servers.add(groupedServer); } } result = getServerRestartRequiredOperations(servers); } else { result = Collections.emptyMap(); } return result; }
Example #30
Source File: FilterResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected boolean applyUpdate(final OperationContext context, final String attributeName, final String addressName, final ModelNode value, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final FilterConfiguration configuration = logContextConfiguration.getFilterConfiguration(addressName); String modelClass = CLASS.resolveModelAttribute(context, context.readResource(PathAddress.EMPTY_ADDRESS).getModel()).asString(); if (PROPERTIES.getName().equals(attributeName) && configuration.getClassName().equals(modelClass)) { if (value.isDefined()) { for (Property property : value.asPropertyList()) { configuration.setPropertyValueString(property.getName(), property.getValue().asString()); } } else { // Remove all current properties final List<String> names = configuration.getPropertyNames(); for (String name : names) { configuration.removeProperty(name); } } } // Writing a class attribute or module will require the previous filter to be removed and a new filter // added. This also would require each logger or handler that has the filter assigned to reassign the // filter. The configuration API does not handle this so a reload will be required. return CLASS.getName().equals(attributeName) || MODULE.getName().equals(attributeName) || CONSTRUCTOR_PROPERTIES.getName().equals(attributeName); }