Search in sources :

Example 1 with Attribute

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));
    }
}
Also used : Attribute(org.jboss.as.clustering.controller.Attribute)

Example 2 with Attribute

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);
    }
}
Also used : Attribute(org.jboss.as.clustering.controller.Attribute) Stream(java.util.stream.Stream)

Example 3 with 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);
        }
    }
}
Also used : Attribute(org.jboss.as.clustering.controller.Attribute) AttributeDefinition(org.jboss.as.controller.AttributeDefinition)

Example 4 with Attribute

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());
}
Also used : Attribute(org.jboss.as.clustering.controller.Attribute) SimpleAttribute(org.jboss.as.clustering.controller.SimpleAttribute) SimpleAttribute(org.jboss.as.clustering.controller.SimpleAttribute) PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 5 with Attribute

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();
        }
    }
}
Also used : DeprecatedAttribute(org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition.DeprecatedAttribute) Attribute(org.jboss.as.clustering.controller.Attribute) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

Attribute (org.jboss.as.clustering.controller.Attribute)7 ModelNode (org.jboss.dmr.ModelNode)4 DeprecatedAttribute (org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition.DeprecatedAttribute)3 Stream (java.util.stream.Stream)1 SimpleAttribute (org.jboss.as.clustering.controller.SimpleAttribute)1 HotRodStoreResourceDefinition (org.jboss.as.clustering.infinispan.subsystem.remote.HotRodStoreResourceDefinition)1 RemoteTransactionResourceDefinition (org.jboss.as.clustering.infinispan.subsystem.remote.RemoteTransactionResourceDefinition)1 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)1 PathAddress (org.jboss.as.controller.PathAddress)1 KernelServices (org.jboss.as.subsystem.test.KernelServices)1 Property (org.jboss.dmr.Property)1 Test (org.junit.Test)1 CompositeIterable (org.wildfly.clustering.ee.CompositeIterable)1