use of org.jboss.as.clustering.controller.Attribute in project wildfly by wildfly.
the class JGroupsSubsystemXMLWriter method writeProtocolAttributes.
@SuppressWarnings("deprecation")
private static void writeProtocolAttributes(XMLExtendedStreamWriter writer, Property property) throws XMLStreamException {
writeGenericProtocolAttributes(writer, property);
if (ProtocolRegistration.ProtocolType.MULTICAST_SOCKET.contains(property.getName())) {
writeAttributes(writer, property.getValue(), EnumSet.allOf(SocketBindingProtocolResourceDefinition.Attribute.class));
} else if (ProtocolRegistration.ProtocolType.JDBC.contains(property.getName())) {
writeAttributes(writer, property.getValue(), EnumSet.allOf(JDBCProtocolResourceDefinition.Attribute.class));
} else if (ProtocolRegistration.ProtocolType.ENCRYPT.contains(property.getName())) {
EnumSet<EncryptProtocolResourceDefinition.Attribute> elementAttributes = EnumSet.of(EncryptProtocolResourceDefinition.Attribute.CREDENTIAL);
writeAttributes(writer, property.getValue(), EnumSet.complementOf(elementAttributes));
if (hasDefined(property.getValue(), elementAttributes)) {
for (Attribute attribute : elementAttributes) {
writeElement(writer, property.getValue(), attribute);
}
}
} else {
writeAttributes(writer, property.getValue(), EnumSet.allOf(ProtocolResourceDefinition.DeprecatedAttribute.class));
}
}
use of org.jboss.as.clustering.controller.Attribute in project wildfly by wildfly.
the class JGroupsSubsystemXMLWriter method writeAttributes.
private static <A extends Attribute> void writeAttributes(XMLExtendedStreamWriter writer, ModelNode model, Stream<A> stream) throws XMLStreamException {
// Write attributes before elements
Stream.Builder<Attribute> objectAttributes = Stream.builder();
Iterable<A> attributes = stream::iterator;
for (Attribute attribute : attributes) {
if (attribute.getDefinition().getType() == ModelType.OBJECT) {
objectAttributes.add(attribute);
} else {
writeAttribute(writer, model, attribute);
}
}
Iterable<Attribute> elementAttributes = objectAttributes.build()::iterator;
for (Attribute attribute : elementAttributes) {
writeElement(writer, model, attribute);
}
}
use of org.jboss.as.clustering.controller.Attribute in project wildfly by wildfly.
the class JGroupsSubsystemXMLReader method require.
private static void require(XMLExtendedStreamReader reader, ModelNode operation, Attribute... attributes) throws XMLStreamException {
for (Attribute attribute : attributes) {
if (!operation.hasDefined(attribute.getName())) {
AttributeDefinition definition = attribute.getDefinition();
Set<String> names = Collections.singleton(definition.getXmlName());
throw definition.getParser().isParseAsElement() ? ParseUtils.missingRequiredElement(reader, names) : ParseUtils.missingRequired(reader, names);
}
}
}
use of org.jboss.as.clustering.controller.Attribute in project wildfly by wildfly.
the class OperationsTestCase method testStoreProperties.
@SuppressWarnings("deprecation")
@Test
public void testStoreProperties() throws Exception {
KernelServices services = this.createKernelServicesBuilder().setSubsystemXml(this.getSubsystemXml()).build();
PathAddress address = getRemoteCacheStoreAddress("maximal", InvalidationCacheResourceDefinition.WILDCARD_PATH.getKey(), "invalid");
String key = "infinispan.client.hotrod.ping_on_startup";
String value = "true";
ModelNode operation = Operations.createMapPutOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key, value);
ModelNode result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
operation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals(value, result.get(RESULT).asString());
operation = Operations.createMapRemoveOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
operation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
// Validate that properties can still be added/removed/updated via child property resources
PathAddress propertyAddress = address.append(StorePropertyResourceDefinition.pathElement(key));
operation = Operations.createAddOperation(propertyAddress, Collections.<Attribute, ModelNode>singletonMap(new SimpleAttribute(StorePropertyResourceDefinition.VALUE), new ModelNode(value)));
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
operation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals(value, result.get(RESULT).asString());
value = "false";
operation = Operations.createWriteAttributeOperation(propertyAddress, new SimpleAttribute(StorePropertyResourceDefinition.VALUE), new ModelNode(value));
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
operation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals(value, result.get(RESULT).asString());
operation = Operations.createReadAttributeOperation(propertyAddress, new SimpleAttribute(StorePropertyResourceDefinition.VALUE));
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals(value, result.get(RESULT).asString());
operation = Util.createRemoveOperation(propertyAddress);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
operation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
}
use of org.jboss.as.clustering.controller.Attribute in project wildfly by wildfly.
the class InfinispanSubsystemXMLWriter method writeThreadPoolElements.
private static <P extends ThreadPoolDefinition & ResourceDefinitionProvider> void writeThreadPoolElements(XMLElement element, P pool, XMLExtendedStreamWriter writer, ModelNode container) throws XMLStreamException {
if (container.get(pool.getPathElement().getKey()).hasDefined(pool.getPathElement().getValue())) {
ModelNode threadPool = container.get(pool.getPathElement().getKeyValuePair());
Iterable<Attribute> attributes = Arrays.asList(pool.getMinThreads(), pool.getMaxThreads(), pool.getQueueLength(), pool.getKeepAliveTime());
if (hasDefined(threadPool, attributes)) {
writer.writeStartElement(element.getLocalName());
writeAttributes(writer, threadPool, attributes);
writer.writeEndElement();
}
}
}
Aggregations