Search in sources :

Example 1 with CompositeIterable

use of org.wildfly.clustering.ee.CompositeIterable in project wildfly by wildfly.

the class InfinispanSubsystemXMLWriter method writeCacheElements.

@SuppressWarnings("deprecation")
private static void writeCacheElements(XMLExtendedStreamWriter writer, ModelNode cache) throws XMLStreamException {
    if (cache.hasDefined(LockingResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode locking = cache.get(LockingResourceDefinition.PATH.getKeyValuePair());
        Set<LockingResourceDefinition.Attribute> attributes = EnumSet.allOf(LockingResourceDefinition.Attribute.class);
        if (hasDefined(locking, attributes)) {
            writer.writeStartElement(XMLElement.LOCKING.getLocalName());
            writeAttributes(writer, locking, attributes);
            writer.writeEndElement();
        }
    }
    if (cache.hasDefined(TransactionResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode transaction = cache.get(TransactionResourceDefinition.PATH.getKeyValuePair());
        Set<TransactionResourceDefinition.Attribute> attributes = EnumSet.allOf(TransactionResourceDefinition.Attribute.class);
        if (hasDefined(transaction, attributes)) {
            writer.writeStartElement(XMLElement.TRANSACTION.getLocalName());
            writeAttributes(writer, transaction, attributes);
            writer.writeEndElement();
        }
    }
    if (cache.hasDefined(HeapMemoryResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode memory = cache.get(HeapMemoryResourceDefinition.PATH.getKeyValuePair());
        Iterable<Attribute> attributes = new CompositeIterable<>(EnumSet.allOf(MemoryResourceDefinition.Attribute.class), EnumSet.allOf(HeapMemoryResourceDefinition.Attribute.class));
        if (hasDefined(memory, attributes)) {
            writer.writeStartElement(XMLElement.HEAP_MEMORY.getLocalName());
            writeAttributes(writer, memory, attributes);
            writer.writeEndElement();
        }
    } else if (cache.hasDefined(OffHeapMemoryResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode memory = cache.get(OffHeapMemoryResourceDefinition.PATH.getKeyValuePair());
        Iterable<Attribute> attributes = new CompositeIterable<>(EnumSet.allOf(MemoryResourceDefinition.Attribute.class), EnumSet.allOf(OffHeapMemoryResourceDefinition.Attribute.class));
        if (hasDefined(memory, attributes)) {
            writer.writeStartElement(XMLElement.OFF_HEAP_MEMORY.getLocalName());
            writeAttributes(writer, memory, attributes);
            writer.writeEndElement();
        }
    }
    if (cache.hasDefined(ExpirationResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode expiration = cache.get(ExpirationResourceDefinition.PATH.getKeyValuePair());
        Set<ExpirationResourceDefinition.Attribute> attributes = EnumSet.allOf(ExpirationResourceDefinition.Attribute.class);
        if (hasDefined(expiration, attributes)) {
            writer.writeStartElement(XMLElement.EXPIRATION.getLocalName());
            writeAttributes(writer, expiration, attributes);
            writer.writeEndElement();
        }
    }
    Set<StoreResourceDefinition.Attribute> storeAttributes = EnumSet.complementOf(EnumSet.of(StoreResourceDefinition.Attribute.PROPERTIES));
    if (cache.hasDefined(CustomStoreResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode store = cache.get(CustomStoreResourceDefinition.PATH.getKeyValuePair());
        writer.writeStartElement(XMLElement.STORE.getLocalName());
        writeAttributes(writer, store, CustomStoreResourceDefinition.Attribute.class);
        writeAttributes(writer, store, JDBCStoreResourceDefinition.Attribute.class);
        writeAttributes(writer, store, storeAttributes);
        writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
        writeStoreElements(writer, store);
        writer.writeEndElement();
    }
    if (cache.hasDefined(FileStoreResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode store = cache.get(FileStoreResourceDefinition.PATH.getKeyValuePair());
        writer.writeStartElement(XMLElement.FILE_STORE.getLocalName());
        writeAttributes(writer, store, FileStoreResourceDefinition.Attribute.class);
        writeAttributes(writer, store, storeAttributes);
        writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
        writeStoreElements(writer, store);
        writer.writeEndElement();
    }
    if (cache.hasDefined(BinaryKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode store = cache.get(BinaryKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair());
        writer.writeStartElement(XMLElement.BINARY_KEYED_JDBC_STORE.getLocalName());
        writeAttributes(writer, store, JDBCStoreResourceDefinition.Attribute.class);
        writeAttributes(writer, store, storeAttributes);
        writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
        writeStoreElements(writer, store);
        writeJDBCStoreTable(writer, XMLElement.BINARY_KEYED_TABLE, store, BinaryTableResourceDefinition.PATH, BinaryTableResourceDefinition.Attribute.PREFIX);
        writer.writeEndElement();
    }
    if (cache.hasDefined(StringKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode store = cache.get(StringKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair());
        writer.writeStartElement(XMLElement.JDBC_STORE.getLocalName());
        writeAttributes(writer, store, JDBCStoreResourceDefinition.Attribute.class);
        writeAttributes(writer, store, storeAttributes);
        writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
        writeStoreElements(writer, store);
        writeJDBCStoreTable(writer, XMLElement.TABLE, store, StringTableResourceDefinition.PATH, StringTableResourceDefinition.Attribute.PREFIX);
        writer.writeEndElement();
    }
    if (cache.hasDefined(MixedKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode store = cache.get(MixedKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair());
        writer.writeStartElement(XMLElement.MIXED_KEYED_JDBC_STORE.getLocalName());
        writeAttributes(writer, store, JDBCStoreResourceDefinition.Attribute.class);
        writeAttributes(writer, store, storeAttributes);
        writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
        writeStoreElements(writer, store);
        writeJDBCStoreTable(writer, XMLElement.BINARY_KEYED_TABLE, store, BinaryTableResourceDefinition.PATH, BinaryTableResourceDefinition.Attribute.PREFIX);
        writeJDBCStoreTable(writer, XMLElement.STRING_KEYED_TABLE, store, StringTableResourceDefinition.PATH, StringTableResourceDefinition.Attribute.PREFIX);
        writer.writeEndElement();
    }
    if (cache.hasDefined(RemoteStoreResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode store = cache.get(RemoteStoreResourceDefinition.PATH.getKeyValuePair());
        writer.writeStartElement(XMLElement.REMOTE_STORE.getLocalName());
        writeAttributes(writer, store, RemoteStoreResourceDefinition.Attribute.class);
        writeAttributes(writer, store, storeAttributes);
        writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
        writeStoreElements(writer, store);
        writer.writeEndElement();
    }
    if (cache.hasDefined(HotRodStoreResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode store = cache.get(HotRodStoreResourceDefinition.PATH.getKeyValuePair());
        writer.writeStartElement(XMLElement.HOTROD_STORE.getLocalName());
        writeAttributes(writer, store, HotRodStoreResourceDefinition.Attribute.class);
        writeAttributes(writer, store, storeAttributes);
        writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
        writeStoreElements(writer, store);
        writer.writeEndElement();
    }
    if (cache.hasDefined(PartitionHandlingResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode partitionHandling = cache.get(PartitionHandlingResourceDefinition.PATH.getKeyValuePair());
        EnumSet<PartitionHandlingResourceDefinition.Attribute> attributes = EnumSet.allOf(PartitionHandlingResourceDefinition.Attribute.class);
        if (hasDefined(partitionHandling, attributes)) {
            writer.writeStartElement(XMLElement.PARTITION_HANDLING.getLocalName());
            writeAttributes(writer, partitionHandling, attributes);
            writer.writeEndElement();
        }
    }
    if (cache.hasDefined(StateTransferResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode stateTransfer = cache.get(StateTransferResourceDefinition.PATH.getKeyValuePair());
        EnumSet<StateTransferResourceDefinition.Attribute> attributes = EnumSet.allOf(StateTransferResourceDefinition.Attribute.class);
        if (hasDefined(stateTransfer, attributes)) {
            writer.writeStartElement(XMLElement.STATE_TRANSFER.getLocalName());
            writeAttributes(writer, stateTransfer, attributes);
            writer.writeEndElement();
        }
    }
    if (cache.hasDefined(BackupsResourceDefinition.PATH.getKeyValuePair())) {
        ModelNode backups = cache.get(BackupsResourceDefinition.PATH.getKeyValuePair());
        if (backups.hasDefined(BackupResourceDefinition.WILDCARD_PATH.getKey())) {
            writer.writeStartElement(XMLElement.BACKUPS.getLocalName());
            for (Property property : backups.get(BackupResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
                writer.writeStartElement(XMLElement.BACKUP.getLocalName());
                writer.writeAttribute(XMLAttribute.SITE.getLocalName(), property.getName());
                ModelNode backup = property.getValue();
                writeAttributes(writer, backup, EnumSet.allOf(BackupResourceDefinition.Attribute.class));
                EnumSet<BackupResourceDefinition.TakeOfflineAttribute> takeOfflineAttributes = EnumSet.allOf(BackupResourceDefinition.TakeOfflineAttribute.class);
                if (hasDefined(backup, takeOfflineAttributes)) {
                    writer.writeStartElement(XMLElement.TAKE_OFFLINE.getLocalName());
                    writeAttributes(writer, backup, takeOfflineAttributes);
                    writer.writeEndElement();
                }
                writer.writeEndElement();
            }
            writer.writeEndElement();
        }
    }
}
Also used : CompositeIterable(org.wildfly.clustering.ee.CompositeIterable) DeprecatedAttribute(org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition.DeprecatedAttribute) Attribute(org.jboss.as.clustering.controller.Attribute) CompositeIterable(org.wildfly.clustering.ee.CompositeIterable) HotRodStoreResourceDefinition(org.jboss.as.clustering.infinispan.subsystem.remote.HotRodStoreResourceDefinition) Property(org.jboss.dmr.Property) RemoteTransactionResourceDefinition(org.jboss.as.clustering.infinispan.subsystem.remote.RemoteTransactionResourceDefinition) HotRodStoreResourceDefinition(org.jboss.as.clustering.infinispan.subsystem.remote.HotRodStoreResourceDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with CompositeIterable

use of org.wildfly.clustering.ee.CompositeIterable in project wildfly by wildfly.

the class InfinispanRoutingProvider method getServiceConfigurators.

@Override
public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String serverName, SupplierDependency<String> route) {
    String containerName = this.config.getContainerName();
    String cacheName = this.config.getCacheName();
    CapabilityServiceConfigurator localRouteConfigurator = new LocalRouteServiceConfigurator(serverName, route);
    CapabilityServiceConfigurator registryEntryConfigurator = new RouteRegistryEntryProviderServiceConfigurator(containerName, serverName);
    CapabilityServiceConfigurator configurationConfigurator = new TemplateConfigurationServiceConfigurator(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CONFIGURATION.getName()).append(containerName, serverName), containerName, serverName, cacheName, this.config);
    CapabilityServiceConfigurator cacheConfigurator = new CacheServiceConfigurator<>(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CACHE.getName()).append(containerName, serverName), containerName, serverName);
    List<Iterable<CapabilityServiceConfigurator>> configurators = new LinkedList<>();
    configurators.add(Arrays.asList(localRouteConfigurator, registryEntryConfigurator, configurationConfigurator, cacheConfigurator));
    ServiceNameRegistry<ClusteringCacheRequirement> registry = new ServiceNameRegistry<ClusteringCacheRequirement>() {

        @Override
        public ServiceName getServiceName(ClusteringCacheRequirement requirement) {
            return REGISTRY_REQUIREMENTS.contains(requirement) ? ServiceNameFactory.parseServiceName(requirement.getName()).append(containerName, serverName) : null;
        }
    };
    for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(DistributedCacheServiceConfiguratorProvider.class, DistributedCacheServiceConfiguratorProvider.class.getClassLoader())) {
        configurators.add(provider.getServiceConfigurators(registry, containerName, serverName));
    }
    return new CompositeIterable<>(configurators);
}
Also used : DistributedCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider) DistributedCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider) CacheServiceConfiguratorProvider(org.wildfly.clustering.spi.CacheServiceConfiguratorProvider) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) CompositeIterable(org.wildfly.clustering.ee.CompositeIterable) LocalRouteServiceConfigurator(org.wildfly.clustering.web.cache.routing.LocalRouteServiceConfigurator) CompositeIterable(org.wildfly.clustering.ee.CompositeIterable) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) LinkedList(java.util.LinkedList) TemplateConfigurationServiceConfigurator(org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationServiceConfigurator) CacheServiceConfigurator(org.wildfly.clustering.infinispan.spi.service.CacheServiceConfigurator) ServiceNameRegistry(org.wildfly.clustering.service.ServiceNameRegistry)

Example 3 with CompositeIterable

use of org.wildfly.clustering.ee.CompositeIterable in project wildfly by wildfly.

the class SingletonServiceConfiguratorFactoryServiceConfiguratorProvider method getServiceConfigurators.

@Override
public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(ServiceNameRegistry<ClusteringCacheRequirement> registry, String containerName, String cacheName) {
    Iterable<CapabilityServiceConfigurator> configurators = super.getServiceConfigurators(registry, containerName, cacheName);
    @SuppressWarnings("deprecation") ServiceName name = registry.getServiceName(ClusteringCacheRequirement.SINGLETON_SERVICE_BUILDER_FACTORY);
    if (name == null)
        return configurators;
    // Add configurator for deprecated capability
    CapabilityServiceConfigurator deprecatedConfigurator = new IdentityCapabilityServiceConfigurator<>(name, ClusteringCacheRequirement.SINGLETON_SERVICE_CONFIGURATOR_FACTORY, containerName, cacheName);
    return new CompositeIterable<>(configurators, Collections.singleton(deprecatedConfigurator));
}
Also used : IdentityCapabilityServiceConfigurator(org.jboss.as.clustering.controller.IdentityCapabilityServiceConfigurator) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ServiceName(org.jboss.msc.service.ServiceName) IdentityCapabilityServiceConfigurator(org.jboss.as.clustering.controller.IdentityCapabilityServiceConfigurator) CompositeIterable(org.wildfly.clustering.ee.CompositeIterable)

Example 4 with CompositeIterable

use of org.wildfly.clustering.ee.CompositeIterable in project wildfly by wildfly.

the class IdentityRegistryFactoryServiceConfiguratorProvider method getServiceConfigurators.

@Override
public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(ServiceNameRegistry<ClusteringCacheRequirement> registry, String containerName, String aliasCacheName, String targetCacheName) {
    Iterable<CapabilityServiceConfigurator> configurators = super.getServiceConfigurators(registry, containerName, aliasCacheName, targetCacheName);
    ServiceName registryServiceName = registry.getServiceName(ClusteringCacheRequirement.REGISTRY);
    ServiceName registryEntryServiceName = registry.getServiceName(ClusteringCacheRequirement.REGISTRY_ENTRY);
    if ((registryServiceName == null) && (registryEntryServiceName == null))
        return configurators;
    List<CapabilityServiceConfigurator> registryConfigurators = new ArrayList<>(2);
    if (registryServiceName != null) {
        registryConfigurators.add(new IdentityCapabilityServiceConfigurator<>(registryServiceName, ClusteringCacheRequirement.REGISTRY, containerName, targetCacheName));
    }
    if (registryEntryServiceName != null) {
        registryConfigurators.add(new IdentityCapabilityServiceConfigurator<>(registryEntryServiceName, ClusteringCacheRequirement.REGISTRY_ENTRY, containerName, targetCacheName));
    }
    return new CompositeIterable<>(configurators, registryConfigurators);
}
Also used : IdentityCapabilityServiceConfigurator(org.jboss.as.clustering.controller.IdentityCapabilityServiceConfigurator) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ServiceName(org.jboss.msc.service.ServiceName) ArrayList(java.util.ArrayList) CompositeIterable(org.wildfly.clustering.ee.CompositeIterable)

Example 5 with CompositeIterable

use of org.wildfly.clustering.ee.CompositeIterable in project wildfly by wildfly.

the class RegistryFactoryServiceConfiguratorProvider method getServiceConfigurators.

@Override
public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(ServiceNameRegistry<ClusteringCacheRequirement> registry, String containerName, String cacheName) {
    Iterable<CapabilityServiceConfigurator> configurators = super.getServiceConfigurators(registry, containerName, cacheName);
    ServiceName registryServiceName = registry.getServiceName(ClusteringCacheRequirement.REGISTRY);
    if (registryServiceName == null)
        return configurators;
    CapabilityServiceConfigurator configurator = new RegistryServiceConfigurator<>(registryServiceName, containerName, cacheName);
    return new CompositeIterable<>(configurators, Collections.singleton(configurator));
}
Also used : CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ServiceName(org.jboss.msc.service.ServiceName) CompositeIterable(org.wildfly.clustering.ee.CompositeIterable)

Aggregations

CompositeIterable (org.wildfly.clustering.ee.CompositeIterable)7 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)6 ServiceName (org.jboss.msc.service.ServiceName)4 LinkedList (java.util.LinkedList)3 CacheServiceConfigurator (org.wildfly.clustering.infinispan.spi.service.CacheServiceConfigurator)3 TemplateConfigurationServiceConfigurator (org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationServiceConfigurator)3 ServiceNameRegistry (org.wildfly.clustering.service.ServiceNameRegistry)3 CacheServiceConfiguratorProvider (org.wildfly.clustering.spi.CacheServiceConfiguratorProvider)3 ClusteringCacheRequirement (org.wildfly.clustering.spi.ClusteringCacheRequirement)3 DistributedCacheServiceConfiguratorProvider (org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider)3 ArrayList (java.util.ArrayList)2 IdentityCapabilityServiceConfigurator (org.jboss.as.clustering.controller.IdentityCapabilityServiceConfigurator)2 Arrays (java.util.Arrays)1 List (java.util.List)1 ServiceLoader (java.util.ServiceLoader)1 Consumer (java.util.function.Consumer)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 ExpirationConfiguration (org.infinispan.configuration.cache.ExpirationConfiguration)1 StorageType (org.infinispan.configuration.cache.StorageType)1 EvictionStrategy (org.infinispan.eviction.EvictionStrategy)1