repo
stringlengths
1
191
file
stringlengths
23
351
code
stringlengths
0
5.32M
file_length
int64
0
5.32M
avg_line_length
float64
0
2.9k
max_line_length
int64
0
288k
extension_type
stringclasses
1 value
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/XMLElement.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.clustering.infinispan.subsystem.remote.ConnectionPoolResourceDefinition; import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition; import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteClusterResourceDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; /** * Enumerates the elements used in the Infinispan subsystem schema. * * @author Paul Ferraro * @author Richard Achmatowicz (c) 2011 RedHat Inc. * @author Tristan Tarrant */ public enum XMLElement { // must be first UNKNOWN((String) null), @Deprecated ASYNC_OPERATIONS_THREAD_POOL("async-operations-thread-pool"), BACKUP(BackupResourceDefinition.WILDCARD_PATH), @Deprecated BACKUP_FOR("backup-for"), BACKUPS(BackupsResourceDefinition.PATH), BINARY_KEYED_TABLE("binary-keyed-table"), BLOCKING_THREAD_POOL("blocking-thread-pool"), @Deprecated BUCKET_TABLE("bucket-table"), CACHE_CONTAINER(CacheContainerResourceDefinition.WILDCARD_PATH), DATA_COLUMN(TableResourceDefinition.ColumnAttribute.DATA), DISTRIBUTED_CACHE(DistributedCacheResourceDefinition.WILDCARD_PATH), ENTRIES("entries"), @Deprecated ENTRY_TABLE("entry-table"), @Deprecated EVICTION("eviction"), @Deprecated BINARY_MEMORY("binary-memory"), HEAP_MEMORY("heap-memory"), @Deprecated OBJECT_MEMORY("object-memory"), OFF_HEAP_MEMORY("off-heap-memory"), EXPIRATION(ExpirationResourceDefinition.PATH), EXPIRATION_THREAD_POOL("expiration-thread-pool"), FILE_STORE("file-store"), ID_COLUMN(TableResourceDefinition.ColumnAttribute.ID), INVALIDATION_CACHE(InvalidationCacheResourceDefinition.WILDCARD_PATH), LISTENER_THREAD_POOL("listener-thread-pool"), JDBC_STORE("jdbc-store"), STRING_KEYED_JDBC_STORE("string-keyed-jdbc-store"), BINARY_KEYED_JDBC_STORE("binary-keyed-jdbc-store"), MIXED_KEYED_JDBC_STORE("mixed-keyed-jdbc-store"), @Deprecated INDEXING("indexing"), LOCAL_CACHE(LocalCacheResourceDefinition.WILDCARD_PATH), LOCKING(LockingResourceDefinition.PATH), NON_BLOCKING_THREAD_POOL("non-blocking-thread-pool"), PARTITION_HANDLING(PartitionHandlingResourceDefinition.PATH), @Deprecated PERSISTENCE_THREAD_POOL("persistence-thread-pool"), @Deprecated REMOTE_COMMAND_THREAD_POOL("remote-command-thread-pool"), PROPERTY(ModelDescriptionConstants.PROPERTY), REMOTE_SERVER("remote-server"), REMOTE_STORE("remote-store"), REPLICATED_CACHE(ReplicatedCacheResourceDefinition.WILDCARD_PATH), @Deprecated SCATTERED_CACHE(ScatteredCacheResourceDefinition.WILDCARD_PATH), SEGMENT_COLUMN(TableResourceDefinition.ColumnAttribute.SEGMENT), SIZE("size"), STATE_TRANSFER(StateTransferResourceDefinition.PATH), @Deprecated STATE_TRANSFER_THREAD_POOL("state-transfer-thread-pool"), STORE(StoreResourceDefinition.WILDCARD_PATH), STRING_KEYED_TABLE("string-keyed-table"), TABLE(TableResourceDefinition.WILDCARD_PATH), TAKE_OFFLINE("take-offline"), TIMESTAMP_COLUMN(TableResourceDefinition.ColumnAttribute.TIMESTAMP), TRANSACTION(TransactionResourceDefinition.PATH), TRANSPORT(TransportResourceDefinition.WILDCARD_PATH), @Deprecated TRANSPORT_THREAD_POOL("transport-thread-pool"), WRITE_BEHIND("write-behind"), // remote-cache-container REMOTE_CACHE_CONTAINER(RemoteCacheContainerResourceDefinition.WILDCARD_PATH), ASYNC_THREAD_POOL("async-thread-pool"), CONNECTION_POOL(ConnectionPoolResourceDefinition.PATH), INVALIDATION_NEAR_CACHE("invalidation-near-cache"), REMOTE_CLUSTERS("remote-clusters"), REMOTE_CLUSTER(RemoteClusterResourceDefinition.WILDCARD_PATH), SECURITY("security"), HOTROD_STORE("hotrod-store"), ; private final String name; XMLElement(Attribute attribute) { this(attribute.getDefinition().getXmlName()); } XMLElement(PathElement path) { this.name = path.isWildcard() ? path.getKey() : path.getValue(); } XMLElement(String name) { this.name = name; } /** * Get the local name of this element. * * @return the local name */ public String getLocalName() { return this.name; } private static final Map<String, XMLElement> elements; static { final Map<String, XMLElement> map = new HashMap<>(); for (XMLElement element : EnumSet.allOf(XMLElement.class)) { final String name = element.getLocalName(); if (name != null) { assert !map.containsKey(name) : element; map.put(name, element); } } elements = map; } public static XMLElement forName(String localName) { final XMLElement element = elements.get(localName); return element == null ? UNKNOWN : element; } }
6,120
39.006536
98
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/NoStoreServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.CacheComponent.PERSISTENCE; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.PersistenceConfiguration; import org.jboss.as.controller.PathAddress; /** * @author Paul Ferraro */ public class NoStoreServiceConfigurator extends ComponentServiceConfigurator<PersistenceConfiguration> { NoStoreServiceConfigurator(PathAddress address) { super(PERSISTENCE, address); } @Override public PersistenceConfiguration get() { return new ConfigurationBuilder().persistence().passivation(false).create(); } }
1,731
37.488889
104
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheComponentMetricExecutor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.Cache; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; /** * Executor for metrics based on cache components. * @author Paul Ferraro */ public class CacheComponentMetricExecutor<C> extends CacheMetricExecutor<C> { private final Class<C> componentClass; public CacheComponentMetricExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors, Class<C> componentClass) { super(executors); this.componentClass = componentClass; } @SuppressWarnings("deprecation") @Override public C apply(Cache<?, ?> cache) { return cache.getAdvancedCache().getComponentRegistry().getLocalComponent(this.componentClass); } }
1,780
36.893617
115
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheRuntimeResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.Cache; import org.infinispan.eviction.impl.ActivationManager; import org.infinispan.eviction.impl.PassivationManager; import org.infinispan.interceptors.impl.CacheMgmtInterceptor; import org.infinispan.interceptors.impl.InvalidationInterceptor; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.MetricHandler; import org.jboss.as.clustering.controller.OperationHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.registry.ManagementResourceRegistration; /** * @author Paul Ferraro */ public class CacheRuntimeResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static PathElement pathElement(String name) { return PathElement.pathElement("cache", name); } private final FunctionExecutorRegistry<Cache<?, ?>> executors; CacheRuntimeResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(new Parameters(WILDCARD_PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(WILDCARD_PATH)).setRuntime()); this.executors = executors; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); new MetricHandler<>(new CacheInterceptorMetricExecutor<>(this.executors, CacheMgmtInterceptor.class), CacheMetric.class).register(registration); new MetricHandler<>(new CacheInterceptorMetricExecutor<>(this.executors, InvalidationInterceptor.class), CacheInvalidationInterceptorMetric.class).register(registration); new MetricHandler<>(new CacheComponentMetricExecutor<>(this.executors, ActivationManager.class), CacheActivationMetric.class).register(registration); new MetricHandler<>(new CacheComponentMetricExecutor<>(this.executors, PassivationManager.class), CachePassivationMetric.class).register(registration); new MetricHandler<>(new ClusteredCacheMetricExecutor(this.executors), ClusteredCacheMetric.class).register(registration); new OperationHandler<>(new CacheInterceptorOperationExecutor<>(this.executors, CacheMgmtInterceptor.class), CacheOperation.class).register(registration); new LockingRuntimeResourceDefinition(this.executors).register(registration); new PartitionHandlingRuntimeResourceDefinition(this.executors).register(registration); new PersistenceRuntimeResourceDefinition(this.executors).register(registration); new TransactionRuntimeResourceDefinition(this.executors).register(registration); return registration; } }
3,918
52.684932
178
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CustomStoreResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * @author Paul Ferraro */ public class CustomStoreResourceTransformer extends StoreResourceTransformer { CustomStoreResourceTransformer(ResourceTransformationDescriptionBuilder parent) { super(parent.addChildResource(CustomStoreResourceDefinition.PATH)); } }
1,457
39.5
94
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ReplicatedCacheResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * @author Paul Ferraro */ public class ReplicatedCacheResourceTransformer extends SharedStateCacheResourceTransformer { ReplicatedCacheResourceTransformer(ResourceTransformationDescriptionBuilder parent) { super(parent.addChildResource(ReplicatedCacheResourceDefinition.WILDCARD_PATH)); } }
1,489
40.388889
94
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/HotRodStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.CapabilityReference; import org.jboss.as.clustering.controller.SimpleResourceDescriptorConfigurator; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelType; import org.wildfly.clustering.infinispan.client.service.InfinispanClientRequirement; /** * Resource description for the addressable resource: * * /subsystem=infinispan/cache-container=X/cache=Y/store=hotrod * * @author Radoslav Husar */ public class HotRodStoreResourceDefinition extends StoreResourceDefinition { static final PathElement PATH = pathElement("hotrod"); enum Attribute implements org.jboss.as.clustering.controller.Attribute { CACHE_CONFIGURATION("cache-configuration", ModelType.STRING, null), REMOTE_CACHE_CONTAINER("remote-cache-container", ModelType.STRING, new CapabilityReference(Capability.PERSISTENCE, InfinispanClientRequirement.REMOTE_CONTAINER)), ; private final AttributeDefinition definition; Attribute(String attributeName, ModelType type, CapabilityReference capabilityReference) { this.definition = new SimpleAttributeDefinitionBuilder(attributeName, type) .setAllowExpression(capabilityReference == null) .setRequired(capabilityReference != null) .setCapabilityReference(capabilityReference) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } HotRodStoreResourceDefinition() { super(PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(PATH, WILDCARD_PATH), new SimpleResourceDescriptorConfigurator<>(Attribute.class), HotRodStoreServiceConfigurator::new); } }
3,116
42.901408
199
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ExpirationServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.ExpirationResourceDefinition.Attribute.INTERVAL; import static org.jboss.as.clustering.infinispan.subsystem.ExpirationResourceDefinition.Attribute.LIFESPAN; import static org.jboss.as.clustering.infinispan.subsystem.ExpirationResourceDefinition.Attribute.MAX_IDLE; import java.util.concurrent.TimeUnit; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.ExpirationConfiguration; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; /** * @author Paul Ferraro */ public class ExpirationServiceConfigurator extends ComponentServiceConfigurator<ExpirationConfiguration> { private volatile long interval; private volatile long lifespan; private volatile long maxIdle; ExpirationServiceConfigurator(PathAddress address) { super(CacheComponent.EXPIRATION, address); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.interval = INTERVAL.resolveModelAttribute(context, model).asLong(); this.lifespan = LIFESPAN.resolveModelAttribute(context, model).asLong(-1L); this.maxIdle = MAX_IDLE.resolveModelAttribute(context, model).asLong(-1L); return this; } @Override public ExpirationConfiguration get() { return new ConfigurationBuilder().expiration() .lifespan(this.lifespan, TimeUnit.MILLISECONDS) .maxIdle(this.maxIdle, TimeUnit.MILLISECONDS) .reaperEnabled(this.interval > 0) .wakeUpInterval(this.interval, TimeUnit.MILLISECONDS) .create(); } }
2,980
41.585714
117
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/KeyAffinityServiceFactoryServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Capability.KEY_AFFINITY_FACTORY; import java.util.function.Consumer; import org.jboss.as.clustering.controller.CapabilityServiceNameProvider; import org.jboss.as.controller.PathAddress; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.infinispan.affinity.KeyAffinityServiceFactory; import org.wildfly.clustering.infinispan.affinity.impl.DefaultKeyAffinityServiceFactory; import org.wildfly.clustering.service.ServiceConfigurator; /** * Key affinity service factory that will only generates keys for use by the local node. * Returns a trivial implementation if the specified cache is not distributed. * @author Paul Ferraro */ public class KeyAffinityServiceFactoryServiceConfigurator extends CapabilityServiceNameProvider implements ServiceConfigurator { public KeyAffinityServiceFactoryServiceConfigurator(PathAddress address) { super(KEY_AFFINITY_FACTORY, address); } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<KeyAffinityServiceFactory> affinityFactory = builder.provides(name); Service service = Service.newInstance(affinityFactory, new DefaultKeyAffinityServiceFactory()); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } }
2,732
44.55
128
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/BackupOperation.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.Map; import org.infinispan.xsite.XSiteAdminOperations; import org.jboss.as.clustering.controller.Operation; import org.jboss.as.controller.ExpressionResolver; import org.jboss.as.controller.OperationDefinition; import org.jboss.as.controller.SimpleOperationDefinitionBuilder; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Backup site operations. * @author Paul Ferraro */ public enum BackupOperation implements Operation<Map.Entry<String, XSiteAdminOperations>> { BRING_SITE_ONLINE("bring-site-online", false) { @Override public ModelNode execute(ExpressionResolver expressionResolver, ModelNode operation, Map.Entry<String, XSiteAdminOperations> context) { return new ModelNode(context.getValue().bringSiteOnline(context.getKey())); } }, TAKE_SITE_OFFLINE("take-site-offline", false) { @Override public ModelNode execute(ExpressionResolver expressionResolver, ModelNode operation, Map.Entry<String, XSiteAdminOperations> context) { return new ModelNode(context.getValue().takeSiteOffline(context.getKey())); } }, SITE_STATUS("site-status", true) { @Override public ModelNode execute(ExpressionResolver expressionResolver, ModelNode operation, Map.Entry<String, XSiteAdminOperations> context) { return new ModelNode(context.getValue().siteStatus(context.getKey())); } }, ; private final OperationDefinition definition; BackupOperation(String name, boolean readOnly) { SimpleOperationDefinitionBuilder builder = new SimpleOperationDefinitionBuilder(name, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(BackupResourceDefinition.WILDCARD_PATH)); if (readOnly) { builder.setReadOnly(); } this.definition = builder.setReplyType(ModelType.STRING).setRuntimeOnly().build(); } @Override public OperationDefinition getDefinition() { return this.definition; } }
3,103
40.945946
194
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InvalidationCacheServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.configuration.cache.CacheMode; import org.jboss.as.controller.PathAddress; /** * @author Paul Ferraro */ public class InvalidationCacheServiceConfigurator extends ClusteredCacheServiceConfigurator { InvalidationCacheServiceConfigurator(PathAddress address) { super(address, CacheMode.INVALIDATION_SYNC); } }
1,429
37.648649
93
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/HeapMemoryResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.EnumSet; import java.util.function.UnaryOperator; import org.infinispan.configuration.cache.StorageType; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; /** * Definition for the /memory=object resource. * @author Paul Ferraro */ public class HeapMemoryResourceDefinition extends MemoryResourceDefinition { static final PathElement PATH = pathElement("heap"); enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { SIZE_UNIT(SharedAttribute.SIZE_UNIT) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new EnumValidator<>(MemorySizeUnit.class, EnumSet.of(MemorySizeUnit.ENTRIES))); } }, ; private final AttributeDefinition definition; Attribute(org.jboss.as.clustering.controller.Attribute basis) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder((SimpleAttributeDefinition) basis.getDefinition())).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } static class ResourceDescriptorConfigurator implements UnaryOperator<ResourceDescriptor> { @Override public ResourceDescriptor apply(ResourceDescriptor descriptor) { return descriptor.addAttributes(Attribute.class); } } HeapMemoryResourceDefinition() { super(StorageType.HEAP, PATH, new ResourceDescriptorConfigurator(), Attribute.SIZE_UNIT); } }
3,032
39.44
138
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StateTransferResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.concurrent.TimeUnit; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.clustering.controller.validation.IntRangeValidatorBuilder; import org.jboss.as.clustering.controller.validation.LongRangeValidatorBuilder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Resource description for the addressable resource and its alias * * /subsystem=infinispan/cache-container=X/cache=Y/component=state-transfer * /subsystem=infinispan/cache-container=X/cache=Y/state-transfer=STATE_TRANSFER * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class StateTransferResourceDefinition extends ComponentResourceDefinition { static final PathElement PATH = pathElement("state-transfer"); enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { CHUNK_SIZE("chunk-size", ModelType.INT, new ModelNode(512)) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new IntRangeValidatorBuilder().min(1).configure(builder).build()); } }, TIMEOUT("timeout", ModelType.LONG, new ModelNode(TimeUnit.MINUTES.toMillis(4))) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new LongRangeValidatorBuilder().min(0).configure(builder).build()) .setMeasurementUnit(MeasurementUnit.MILLISECONDS) ; } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } StateTransferResourceDefinition() { super(PATH); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()) .addAttributes(Attribute.class) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(StateTransferServiceConfigurator::new); new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
4,624
43.047619
125
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CustomStoreConfigurationBuilder.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.configuration.cache.AbstractStoreConfiguration; import org.infinispan.configuration.cache.AbstractStoreConfigurationBuilder; import org.infinispan.configuration.cache.PersistenceConfigurationBuilder; /** * @author Paul Ferraro */ public class CustomStoreConfigurationBuilder extends AbstractStoreConfigurationBuilder<CustomStoreConfiguration, CustomStoreConfigurationBuilder> { public CustomStoreConfigurationBuilder(PersistenceConfigurationBuilder builder) { super(builder, AbstractStoreConfiguration.attributeDefinitionSet()); } @Override public CustomStoreConfiguration create() { return new CustomStoreConfiguration(this.attributes.protect(), this.async.create()); } @Override public CustomStoreConfigurationBuilder self() { return this; } }
1,909
38.791667
147
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/PersistenceRuntimeResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.Cache; import org.infinispan.interceptors.impl.CacheLoaderInterceptor; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.MetricHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.registry.ManagementResourceRegistration; /** * @author Paul Ferraro */ public class PersistenceRuntimeResourceDefinition extends CacheComponentRuntimeResourceDefinition { static final PathElement PATH = pathElement("persistence"); private final FunctionExecutorRegistry<Cache<?, ?>> executors; PersistenceRuntimeResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(PATH, StoreResourceDefinition.WILDCARD_PATH); this.executors = executors; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = super.register(parent); new MetricHandler<>(new CacheInterceptorMetricExecutor<>(this.executors, CacheLoaderInterceptor.class, BinaryCapabilityNameResolver.GRANDPARENT_PARENT), StoreMetric.class).register(registration); return registration; } }
2,372
42.944444
203
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/SegmentedCacheResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.UnaryOperator; import org.infinispan.Cache; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.validation.IntRangeValidatorBuilder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * @author Paul Ferraro */ public class SegmentedCacheResourceDefinition extends SharedStateCacheResourceDefinition { enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { SEGMENTS("segments", ModelType.INT, new ModelNode(256)) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new IntRangeValidatorBuilder().min(1).configure(builder).build()); } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } private static class ResourceDescriptorConfigurator implements UnaryOperator<ResourceDescriptor> { private final UnaryOperator<ResourceDescriptor> configurator; ResourceDescriptorConfigurator(UnaryOperator<ResourceDescriptor> configurator) { this.configurator = configurator; } @Override public ResourceDescriptor apply(ResourceDescriptor descriptor) { return this.configurator.apply(descriptor) .addAttributes(Attribute.class) ; } } SegmentedCacheResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ClusteredCacheServiceHandler handler, FunctionExecutorRegistry<Cache<?, ?>> executors) { super(path, new ResourceDescriptorConfigurator(configurator), handler, executors); } }
3,675
41.252874
191
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StateTransferServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.StateTransferResourceDefinition.Attribute.CHUNK_SIZE; import static org.jboss.as.clustering.infinispan.subsystem.StateTransferResourceDefinition.Attribute.TIMEOUT; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.StateTransferConfiguration; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; /** * @author Paul Ferraro */ public class StateTransferServiceConfigurator extends ComponentServiceConfigurator<StateTransferConfiguration> { private volatile int chunkSize; private volatile long timeout; StateTransferServiceConfigurator(PathAddress address) { super(CacheComponent.STATE_TRANSFER, address); } @Override public StateTransferConfiguration get() { boolean timeoutEnabled = this.timeout > 0; return new ConfigurationBuilder().clustering().stateTransfer() .chunkSize(this.chunkSize) .fetchInMemoryState(true) .awaitInitialTransfer(timeoutEnabled) .timeout(timeoutEnabled ? this.timeout : Long.MAX_VALUE) .create(); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.chunkSize = CHUNK_SIZE.resolveModelAttribute(context, model).asInt(); this.timeout = TIMEOUT.resolveModelAttribute(context, model).asLong(); return this; } }
2,770
40.984848
117
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/FileStoreResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * @author Paul Ferraro */ public class FileStoreResourceTransformer extends StoreResourceTransformer { FileStoreResourceTransformer(ResourceTransformationDescriptionBuilder parent) { super(parent.addChildResource(FileStoreResourceDefinition.PATH)); } }
1,451
39.333333
94
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/JDBCStoreResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * @author Paul Ferraro */ public class JDBCStoreResourceTransformer extends StoreResourceTransformer { JDBCStoreResourceTransformer(ResourceTransformationDescriptionBuilder parent) { super(parent.addChildResource(JDBCStoreResourceDefinition.PATH)); } }
1,451
39.333333
94
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TransportResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; import java.util.Set; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.Capability; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.UnaryCapabilityNameResolver; import org.jboss.as.clustering.controller.UnaryRequirementCapability; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.wildfly.clustering.server.service.ClusteringRequirement; /** * @author Paul Ferraro */ public abstract class TransportResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static PathElement pathElement(String value) { return PathElement.pathElement("transport", value); } private final UnaryOperator<ResourceDescriptor> configurator; private final ResourceServiceHandler handler; TransportResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ResourceServiceHandler handler) { super(path, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(path)); this.configurator = configurator; this.handler = handler; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); Set<ClusteringRequirement> requirements = EnumSet.allOf(ClusteringRequirement.class); List<Capability> capabilities = new ArrayList<>(requirements.size()); for (ClusteringRequirement requirement : requirements) { capabilities.add(new UnaryRequirementCapability(requirement, UnaryCapabilityNameResolver.PARENT)); } ResourceDescriptor descriptor = this.configurator.apply(new ResourceDescriptor(this.getResourceDescriptionResolver())) .addCapabilities(capabilities) ; new SimpleResourceRegistrar(descriptor, this.handler).register(registration); return registration; } }
3,499
43.303797
131
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerMetricExecutor.java
/* * JBoss, Home of Professional Open Source * Copyright 2014 Red Hat Inc. and/or its affiliates and other contributors * as indicated by the @author tags. All rights reserved. * See the copyright.txt in the distribution for a * full listing of individual contributors. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU Lesser General Public License, v. 2.1. * This program is distributed in the hope that it will be useful, but WITHOUT A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License, * v.2.1 along with this distribution; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.Function; import org.infinispan.manager.EmbeddedCacheManager; import org.jboss.as.clustering.controller.Metric; import org.jboss.as.clustering.controller.MetricExecutor; import org.jboss.as.clustering.controller.MetricFunction; import org.jboss.as.clustering.controller.FunctionExecutor; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.UnaryCapabilityNameResolver; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceName; import org.wildfly.clustering.infinispan.service.InfinispanRequirement; /** * Executor for cache-container metrics. * * @author Paul Ferraro */ public class CacheContainerMetricExecutor implements MetricExecutor<EmbeddedCacheManager> { private final FunctionExecutorRegistry<EmbeddedCacheManager> executors; public CacheContainerMetricExecutor(FunctionExecutorRegistry<EmbeddedCacheManager> executors) { this.executors = executors; } @Override public ModelNode execute(OperationContext context, Metric<EmbeddedCacheManager> metric) throws OperationFailedException { ServiceName name = InfinispanRequirement.CONTAINER.getServiceName(context, UnaryCapabilityNameResolver.DEFAULT); FunctionExecutor<EmbeddedCacheManager> executor = this.executors.get(name); return (executor != null) ? executor.execute(new MetricFunction<>(Function.identity(), metric)) : null; } }
2,581
45.107143
125
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanSubsystemXMLReader.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.Collections; import java.util.EnumSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.clustering.controller.ResourceDefinitionProvider; import org.jboss.as.clustering.infinispan.subsystem.TableResourceDefinition.ColumnAttribute; import org.jboss.as.clustering.infinispan.subsystem.remote.ConnectionPoolResourceDefinition; import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition; import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteClusterResourceDefinition; import org.jboss.as.clustering.infinispan.subsystem.remote.SecurityResourceDefinition; import org.jboss.as.clustering.logging.ClusteringLogger; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.AttributeParser; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.controller.parsing.Element; import org.jboss.as.controller.parsing.ParseUtils; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLElementReader; import org.jboss.staxmapper.XMLExtendedStreamReader; import org.wildfly.clustering.infinispan.marshall.InfinispanMarshallerFactory; /** * XML reader for the Infinispan subsystem. * * @author Paul Ferraro */ @SuppressWarnings({ "deprecation", "static-method" }) public class InfinispanSubsystemXMLReader implements XMLElementReader<List<ModelNode>> { private final InfinispanSubsystemSchema schema; InfinispanSubsystemXMLReader(InfinispanSubsystemSchema schema) { this.schema = schema; } @Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> result) throws XMLStreamException { Map<PathAddress, ModelNode> operations = new LinkedHashMap<>(); PathAddress address = PathAddress.pathAddress(InfinispanSubsystemResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case CACHE_CONTAINER: { this.parseContainer(reader, address, operations); break; } case REMOTE_CACHE_CONTAINER: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_6_0)) { this.parseRemoteContainer(reader, address, operations); break; } } default: { throw ParseUtils.unexpectedElement(reader); } } } result.addAll(operations.values()); } private void parseContainer(XMLExtendedStreamReader reader, PathAddress subsystemAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { String name = require(reader, XMLAttribute.NAME); PathAddress address = subsystemAddress.append(CacheContainerResourceDefinition.pathElement(name)); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { ParseUtils.requireNoNamespaceAttribute(reader, i); XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: { // Already parsed break; } case DEFAULT_CACHE: { readAttribute(reader, i, operation, CacheContainerResourceDefinition.Attribute.DEFAULT_CACHE); break; } case JNDI_NAME: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case LISTENER_EXECUTOR: case EVICTION_EXECUTOR: case REPLICATION_QUEUE_EXECUTOR: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case START: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_3_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case ALIASES: { readAttribute(reader, i, operation, CacheContainerResourceDefinition.ListAttribute.ALIASES); break; } case MODULE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_12_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } readAttribute(reader, i, operation, CacheContainerResourceDefinition.ListAttribute.MODULES); break; } case STATISTICS_ENABLED: { readAttribute(reader, i, operation, CacheContainerResourceDefinition.Attribute.STATISTICS_ENABLED); break; } case MODULES: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_12_0)) { readAttribute(reader, i, operation, CacheContainerResourceDefinition.ListAttribute.MODULES); break; } } case MARSHALLER: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_13_0)) { readAttribute(reader, i, operation, CacheContainerResourceDefinition.Attribute.MARSHALLER); break; } } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } if (!operation.hasDefined(CacheContainerResourceDefinition.Attribute.MARSHALLER.getName())) { if (!this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { // Apply legacy default value operation.get(CacheContainerResourceDefinition.Attribute.MARSHALLER.getName()).set(new ModelNode(InfinispanMarshallerFactory.LEGACY.name())); } } while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case TRANSPORT: { this.parseTransport(reader, address, operations); break; } case LOCAL_CACHE: { this.parseLocalCache(reader, address, operations); break; } case INVALIDATION_CACHE: { this.parseInvalidationCache(reader, address, operations); break; } case REPLICATED_CACHE: { this.parseReplicatedCache(reader, address, operations); break; } case DISTRIBUTED_CACHE: { this.parseDistributedCache(reader, address, operations); break; } case EXPIRATION_THREAD_POOL: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { this.parseScheduledThreadPool(ScheduledThreadPoolResourceDefinition.EXPIRATION, reader, address, operations); break; } } case LISTENER_THREAD_POOL: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { this.parseThreadPool(ThreadPoolResourceDefinition.LISTENER, reader, address, operations); break; } } case ASYNC_OPERATIONS_THREAD_POOL: case PERSISTENCE_THREAD_POOL: case REMOTE_COMMAND_THREAD_POOL: case STATE_TRANSFER_THREAD_POOL: case TRANSPORT_THREAD_POOL: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { throw ParseUtils.unexpectedElement(reader); } ClusteringLogger.ROOT_LOGGER.elementIgnored(element.getLocalName()); ParseUtils.requireNoContent(reader); break; } case SCATTERED_CACHE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_6_0)) { this.parseScatteredCache(reader, address, operations); break; } } case BLOCKING_THREAD_POOL: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_11_0)) { this.parseThreadPool(ThreadPoolResourceDefinition.BLOCKING, reader, address, operations); break; } } case NON_BLOCKING_THREAD_POOL: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_11_0)) { this.parseThreadPool(ThreadPoolResourceDefinition.NON_BLOCKING, reader, address, operations); break; } } default: { throw ParseUtils.unexpectedElement(reader); } } } } private void parseTransport(XMLExtendedStreamReader reader, PathAddress containerAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = containerAddress.append(JGroupsTransportResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(containerAddress.append(TransportResourceDefinition.WILDCARD_PATH), operation); String stack = null; String cluster = null; for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case STACK: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_3_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } stack = reader.getAttributeValue(i); break; } case EXECUTOR: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case LOCK_TIMEOUT: { readAttribute(reader, i, operation, JGroupsTransportResourceDefinition.Attribute.LOCK_TIMEOUT); break; } case CLUSTER: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_3_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } cluster = reader.getAttributeValue(i); break; } case CHANNEL: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_3_0)) { readAttribute(reader, i, operation, JGroupsTransportResourceDefinition.Attribute.CHANNEL); break; } } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } if (!this.schema.since(InfinispanSubsystemSchema.VERSION_3_0)) { // We need to create a corresponding channel add operation String channel = "ee-" + containerAddress.getLastElement().getValue(); setAttribute(reader, channel, operation, JGroupsTransportResourceDefinition.Attribute.CHANNEL); PathAddress subsystemAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "jgroups")); PathAddress channelAddress = subsystemAddress.append(PathElement.pathElement("channel", channel)); ModelNode channelOperation = Util.createAddOperation(channelAddress); if (stack != null) { channelOperation.get("stack").set(stack); } if (cluster != null) { channelOperation.get("cluster").set(cluster); } operations.put(channelAddress, channelOperation); } ParseUtils.requireNoContent(reader); } private void parseLocalCache(XMLExtendedStreamReader reader, PathAddress containerAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { String name = require(reader, XMLAttribute.NAME); PathAddress address = containerAddress.append(LocalCacheResourceDefinition.pathElement(name)); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { this.parseCacheAttribute(reader, i, address, operations); } while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { this.parseCacheElement(reader, address, operations); } } private void parseReplicatedCache(XMLExtendedStreamReader reader, PathAddress containerAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { String name = require(reader, XMLAttribute.NAME); PathAddress address = containerAddress.append(ReplicatedCacheResourceDefinition.pathElement(name)); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { this.parseClusteredCacheAttribute(reader, i, address, operations); } while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { this.parseSharedStateCacheElement(reader, address, operations); } } @SuppressWarnings("deprecation") private void parseScatteredCache(XMLExtendedStreamReader reader, PathAddress containerAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { String name = require(reader, XMLAttribute.NAME); PathAddress address = containerAddress.append(ScatteredCacheResourceDefinition.pathElement(name)); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case BIAS_LIFESPAN: { readAttribute(reader, i, operation, ScatteredCacheResourceDefinition.Attribute.BIAS_LIFESPAN); break; } case INVALIDATION_BATCH_SIZE: { readAttribute(reader, i, operation, ScatteredCacheResourceDefinition.Attribute.INVALIDATION_BATCH_SIZE); break; } default: { this.parseSegmentedCacheAttribute(reader, i, address, operations); } } } while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { this.parseSharedStateCacheElement(reader, address, operations); } } private void parseDistributedCache(XMLExtendedStreamReader reader, PathAddress containerAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { String name = require(reader, XMLAttribute.NAME); PathAddress address = containerAddress.append(DistributedCacheResourceDefinition.pathElement(name)); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case OWNERS: { readAttribute(reader, i, operation, DistributedCacheResourceDefinition.Attribute.OWNERS); break; } case L1_LIFESPAN: { readAttribute(reader, i, operation, DistributedCacheResourceDefinition.Attribute.L1_LIFESPAN); break; } case CAPACITY_FACTOR: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_3_0)) { readAttribute(reader, i, operation, DistributedCacheResourceDefinition.Attribute.CAPACITY_FACTOR); break; } } default: { this.parseSegmentedCacheAttribute(reader, i, address, operations); } } } while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { this.parseSharedStateCacheElement(reader, address, operations); } } private void parseInvalidationCache(XMLExtendedStreamReader reader, PathAddress containerAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { String name = require(reader, XMLAttribute.NAME); PathAddress address = containerAddress.append(InvalidationCacheResourceDefinition.pathElement(name)); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { this.parseClusteredCacheAttribute(reader, i, address, operations); } while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { this.parseCacheElement(reader, address, operations); } } private void parseCacheAttribute(XMLExtendedStreamReader reader, int index, PathAddress address, Map<PathAddress, ModelNode> operations) throws XMLStreamException { ModelNode operation = operations.get(address); XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(index)); switch (attribute) { case NAME: { // Already read break; } case START: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_3_0)) { throw ParseUtils.unexpectedAttribute(reader, index); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case BATCHING: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_3_0)) { throw ParseUtils.unexpectedAttribute(reader, index); } PathAddress transactionAddress = address.append(TransactionResourceDefinition.PATH); ModelNode transactionOperation = Util.createAddOperation(transactionAddress); transactionOperation.get(TransactionResourceDefinition.Attribute.MODE.getName()).set(new ModelNode(TransactionMode.BATCH.name())); operations.put(transactionAddress, transactionOperation); break; } case JNDI_NAME: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { throw ParseUtils.unexpectedAttribute(reader, index); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case MODULE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_12_0)) { throw ParseUtils.unexpectedAttribute(reader, index); } readAttribute(reader, index, operation, CacheResourceDefinition.ListAttribute.MODULES); break; } case STATISTICS_ENABLED: { readAttribute(reader, index, operation, CacheResourceDefinition.Attribute.STATISTICS_ENABLED); break; } case MODULES: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_12_0)) { readAttribute(reader, index, operation, CacheResourceDefinition.ListAttribute.MODULES); break; } } default: { throw ParseUtils.unexpectedAttribute(reader, index); } } } private void parseSegmentedCacheAttribute(XMLExtendedStreamReader reader, int index, PathAddress address, Map<PathAddress, ModelNode> operations) throws XMLStreamException { ModelNode operation = operations.get(address); XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(index)); switch (attribute) { case SEGMENTS: { readAttribute(reader, index, operation, SegmentedCacheResourceDefinition.Attribute.SEGMENTS); break; } case CONSISTENT_HASH_STRATEGY: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { throw ParseUtils.unexpectedAttribute(reader, index); } if (this.schema.since(InfinispanSubsystemSchema.VERSION_3_0)) { ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } } default: { this.parseClusteredCacheAttribute(reader, index, address, operations); } } } private void parseClusteredCacheAttribute(XMLExtendedStreamReader reader, int index, PathAddress address, Map<PathAddress, ModelNode> operations) throws XMLStreamException { ModelNode operation = operations.get(address); XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(index)); switch (attribute) { case MODE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { throw ParseUtils.unexpectedAttribute(reader, index); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case QUEUE_SIZE: { ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case QUEUE_FLUSH_INTERVAL: { ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case REMOTE_TIMEOUT: { readAttribute(reader, index, operation, ClusteredCacheResourceDefinition.Attribute.REMOTE_TIMEOUT); break; } case ASYNC_MARSHALLING: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { throw ParseUtils.unexpectedAttribute(reader, index); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } default: { this.parseCacheAttribute(reader, index, address, operations); } } } private void parseCacheElement(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case EVICTION: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { throw ParseUtils.unexpectedElement(reader); } this.parseEviction(reader, cacheAddress, operations); break; } case EXPIRATION: { this.parseExpiration(reader, cacheAddress, operations); break; } case LOCKING: { this.parseLocking(reader, cacheAddress, operations); break; } case TRANSACTION: { this.parseTransaction(reader, cacheAddress, operations); break; } case STORE: { this.parseCustomStore(reader, cacheAddress, operations); break; } case FILE_STORE: { this.parseFileStore(reader, cacheAddress, operations); break; } case REMOTE_STORE: { this.parseRemoteStore(reader, cacheAddress, operations); break; } case HOTROD_STORE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_6_0)) { this.parseHotRodStore(reader, cacheAddress, operations); break; } } case JDBC_STORE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { this.parseJDBCStore(reader, cacheAddress, operations); } else { throw ParseUtils.unexpectedElement(reader); } break; } case STRING_KEYED_JDBC_STORE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { throw ParseUtils.unexpectedElement(reader); } this.parseStringKeyedJDBCStore(reader, cacheAddress, operations); break; } case BINARY_KEYED_JDBC_STORE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { throw ParseUtils.unexpectedElement(reader); } this.parseBinaryKeyedJDBCStore(reader, cacheAddress, operations); break; } case MIXED_KEYED_JDBC_STORE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { throw ParseUtils.unexpectedElement(reader); } this.parseMixedKeyedJDBCStore(reader, cacheAddress, operations); break; } case INDEXING: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { throw ParseUtils.unexpectedElement(reader); } this.parseIndexing(reader, cacheAddress, operations); break; } case OBJECT_MEMORY: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_11_0)) { throw ParseUtils.unexpectedElement(reader); } if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { this.parseHeapMemory(reader, cacheAddress, operations); break; } } case BINARY_MEMORY: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_11_0)) { throw ParseUtils.unexpectedElement(reader); } if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { this.parseBinaryMemory(reader, cacheAddress, operations); break; } } case OFF_HEAP_MEMORY: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { this.parseOffHeapMemory(reader, cacheAddress, operations); break; } } case HEAP_MEMORY: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_11_0)) { this.parseHeapMemory(reader, cacheAddress, operations); break; } } default: { throw ParseUtils.unexpectedElement(reader); } } } private void parseSharedStateCacheElement(XMLExtendedStreamReader reader, PathAddress address, Map<PathAddress, ModelNode> operations) throws XMLStreamException { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case STATE_TRANSFER: { this.parseStateTransfer(reader, address, operations); break; } case BACKUPS: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_2_0)) { this.parseBackups(reader, address, operations); break; } } case BACKUP_FOR: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_2_0) && !this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { ClusteringLogger.ROOT_LOGGER.elementIgnored(reader.getLocalName()); ParseUtils.requireNoContent(reader); break; } throw ParseUtils.unexpectedElement(reader); } case PARTITION_HANDLING: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { this.parsePartitionHandling(reader, address, operations); break; } } default: { this.parseCacheElement(reader, address, operations); } } } @SuppressWarnings("deprecation") private void parsePartitionHandling(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(PartitionHandlingResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case ENABLED: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } readAttribute(reader, i, operation, PartitionHandlingResourceDefinition.DeprecatedAttribute.ENABLED); break; } case WHEN_SPLIT: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { readAttribute(reader, i, operation, PartitionHandlingResourceDefinition.Attribute.WHEN_SPLIT); break; } } case MERGE_POLICY: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { readAttribute(reader, i, operation, PartitionHandlingResourceDefinition.Attribute.MERGE_POLICY); break; } } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private void parseStateTransfer(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(StateTransferResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case ENABLED: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case TIMEOUT: { readAttribute(reader, i, operation, StateTransferResourceDefinition.Attribute.TIMEOUT); break; } case CHUNK_SIZE: { readAttribute(reader, i, operation, StateTransferResourceDefinition.Attribute.CHUNK_SIZE); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private void parseBackups(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(BackupsResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case BACKUP: { this.parseBackup(reader, address, operations); break; } default: { throw ParseUtils.unexpectedElement(reader); } } } } @SuppressWarnings({ "static-method", "deprecation" }) private void parseBackup(XMLExtendedStreamReader reader, PathAddress backupsAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { String site = require(reader, XMLAttribute.SITE); PathAddress address = backupsAddress.append(BackupResourceDefinition.pathElement(site)); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case SITE: { // Already parsed break; } case STRATEGY: { readAttribute(reader, i, operation, BackupResourceDefinition.Attribute.STRATEGY); break; } case BACKUP_FAILURE_POLICY: { readAttribute(reader, i, operation, BackupResourceDefinition.Attribute.FAILURE_POLICY); break; } case TIMEOUT: { readAttribute(reader, i, operation, BackupResourceDefinition.Attribute.TIMEOUT); break; } case ENABLED: { readAttribute(reader, i, operation, BackupResourceDefinition.DeprecatedAttribute.ENABLED); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case TAKE_OFFLINE: { for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case TAKE_OFFLINE_AFTER_FAILURES: { readAttribute(reader, i, operation, BackupResourceDefinition.TakeOfflineAttribute.AFTER_FAILURES); break; } case TAKE_OFFLINE_MIN_WAIT: { readAttribute(reader, i, operation, BackupResourceDefinition.TakeOfflineAttribute.MIN_WAIT); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); break; } default: { throw ParseUtils.unexpectedElement(reader); } } } } private void parseLocking(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(LockingResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case ISOLATION: { readAttribute(reader, i, operation, LockingResourceDefinition.Attribute.ISOLATION); break; } case STRIPING: { readAttribute(reader, i, operation, LockingResourceDefinition.Attribute.STRIPING); break; } case ACQUIRE_TIMEOUT: { readAttribute(reader, i, operation, LockingResourceDefinition.Attribute.ACQUIRE_TIMEOUT); break; } case CONCURRENCY_LEVEL: { readAttribute(reader, i, operation, LockingResourceDefinition.Attribute.CONCURRENCY); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private void parseTransaction(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(TransactionResourceDefinition.PATH); ModelNode operation = operations.get(address); if (operation == null) { operation = Util.createAddOperation(address); operations.put(address, operation); } for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case STOP_TIMEOUT: { readAttribute(reader, i, operation, TransactionResourceDefinition.Attribute.STOP_TIMEOUT); break; } case MODE: { readAttribute(reader, i, operation, TransactionResourceDefinition.Attribute.MODE); break; } case LOCKING: { readAttribute(reader, i, operation, TransactionResourceDefinition.Attribute.LOCKING); break; } case COMPLETE_TIMEOUT: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_13_0)) { readAttribute(reader, i, operation, TransactionResourceDefinition.Attribute.COMPLETE_TIMEOUT); break; } } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private void parseEviction(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(HeapMemoryResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case STRATEGY: { ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case MAX_ENTRIES: { readAttribute(reader, i, operation, MemoryResourceDefinition.Attribute.SIZE); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private void parseExpiration(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(ExpirationResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case MAX_IDLE: { readAttribute(reader, i, operation, ExpirationResourceDefinition.Attribute.MAX_IDLE); break; } case LIFESPAN: { readAttribute(reader, i, operation, ExpirationResourceDefinition.Attribute.LIFESPAN); break; } case INTERVAL: { readAttribute(reader, i, operation, ExpirationResourceDefinition.Attribute.INTERVAL); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private void parseIndexing(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case INDEX: { ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { Element element = Element.forName(reader.getLocalName()); switch (element) { case PROPERTY: { ParseUtils.requireSingleAttribute(reader, XMLAttribute.NAME.getLocalName()); reader.getElementText(); ClusteringLogger.ROOT_LOGGER.elementIgnored(reader.getLocalName()); break; } default: { throw ParseUtils.unexpectedElement(reader); } } } } private void parseHeapMemory(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(HeapMemoryResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case SIZE_UNIT: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_11_0)) { readAttribute(reader, i, operation, HeapMemoryResourceDefinition.Attribute.SIZE_UNIT); break; } } default: { this.parseMemoryAttribute(reader, i, operation); } } } ParseUtils.requireNoContent(reader); } private void parseBinaryMemory(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(OffHeapMemoryResourceDefinition.BINARY_PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { this.parseBinaryMemoryAttribute(reader, i, operation); } ParseUtils.requireNoContent(reader); } private void parseOffHeapMemory(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(OffHeapMemoryResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case CAPACITY: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { throw ParseUtils.unexpectedElement(reader); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case SIZE_UNIT: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_11_0)) { readAttribute(reader, i, operation, OffHeapMemoryResourceDefinition.Attribute.SIZE_UNIT); break; } } default: { this.parseBinaryMemoryAttribute(reader, i, operation); } } } ParseUtils.requireNoContent(reader); } private void parseBinaryMemoryAttribute(XMLExtendedStreamReader reader, int index, ModelNode operation) throws XMLStreamException { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(index)); switch (attribute) { case EVICTION_TYPE: { ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } default: { this.parseMemoryAttribute(reader, index, operation); } } } private void parseMemoryAttribute(XMLExtendedStreamReader reader, int index, ModelNode operation) throws XMLStreamException { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(index)); switch (attribute) { case SIZE: { readAttribute(reader, index, operation, MemoryResourceDefinition.Attribute.SIZE); break; } default: { throw ParseUtils.unexpectedAttribute(reader, index); } } } private void applyLegacyStoreAttributeDefaults(ModelNode operation) { if (!this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { for (Attribute attribute : Set.of(StoreResourceDefinition.Attribute.PASSIVATION, StoreResourceDefinition.Attribute.PURGE)) { // If undefined, use default value from legacy schema if (!operation.hasDefined(attribute.getName())) { operation.get(attribute.getName()).set(ModelNode.TRUE); } } } } private void parseCustomStore(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(CustomStoreResourceDefinition.PATH); PathAddress operationKey = cacheAddress.append(StoreResourceDefinition.WILDCARD_PATH); if (operations.containsKey(operationKey)) { throw ParseUtils.unexpectedElement(reader); } ModelNode operation = Util.createAddOperation(address); operations.put(operationKey, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case CLASS: { readAttribute(reader, i, operation, CustomStoreResourceDefinition.Attribute.CLASS); break; } default: { this.parseStoreAttribute(reader, i, operation); } } } if (!operation.hasDefined(CustomStoreResourceDefinition.Attribute.CLASS.getName())) { throw ParseUtils.missingRequired(reader, EnumSet.of(XMLAttribute.CLASS)); } this.applyLegacyStoreAttributeDefaults(operation); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { this.parseStoreElement(reader, address, operations); } } private void parseFileStore(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(FileStoreResourceDefinition.PATH); PathAddress operationKey = cacheAddress.append(StoreResourceDefinition.WILDCARD_PATH); if (operations.containsKey(operationKey)) { throw ParseUtils.unexpectedElement(reader); } ModelNode operation = Util.createAddOperation(address); operations.put(operationKey, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case RELATIVE_TO: { readAttribute(reader, i, operation, FileStoreResourceDefinition.DeprecatedAttribute.RELATIVE_TO); break; } case PATH: { readAttribute(reader, i, operation, FileStoreResourceDefinition.DeprecatedAttribute.RELATIVE_PATH); break; } default: { this.parseStoreAttribute(reader, i, operation); } } } this.applyLegacyStoreAttributeDefaults(operation); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { this.parseStoreElement(reader, address, operations); } } private void parseRemoteStore(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(RemoteStoreResourceDefinition.PATH); PathAddress operationKey = cacheAddress.append(StoreResourceDefinition.WILDCARD_PATH); if (operations.containsKey(operationKey)) { throw ParseUtils.unexpectedElement(reader); } ModelNode operation = Util.createAddOperation(address); operations.put(operationKey, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case CACHE: { readAttribute(reader, i, operation, RemoteStoreResourceDefinition.Attribute.CACHE); break; } case SOCKET_TIMEOUT: { readAttribute(reader, i, operation, RemoteStoreResourceDefinition.Attribute.SOCKET_TIMEOUT); break; } case TCP_NO_DELAY: { readAttribute(reader, i, operation, RemoteStoreResourceDefinition.Attribute.TCP_NO_DELAY); break; } case REMOTE_SERVERS: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { readAttribute(reader, i, operation, RemoteStoreResourceDefinition.Attribute.SOCKET_BINDINGS); break; } } default: { this.parseStoreAttribute(reader, i, operation); } } } this.applyLegacyStoreAttributeDefaults(operation); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case REMOTE_SERVER: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { throw ParseUtils.unexpectedElement(reader); } for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case OUTBOUND_SOCKET_BINDING: { readAttribute(reader, i, operation, RemoteStoreResourceDefinition.Attribute.SOCKET_BINDINGS); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); break; } default: { this.parseStoreElement(reader, address, operations); } } } if (!operation.hasDefined(RemoteStoreResourceDefinition.Attribute.SOCKET_BINDINGS.getName())) { throw ParseUtils.missingRequired(reader, Collections.singleton(XMLAttribute.REMOTE_SERVERS.getLocalName())); } } private void parseHotRodStore(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(HotRodStoreResourceDefinition.PATH); PathAddress operationKey = cacheAddress.append(StoreResourceDefinition.WILDCARD_PATH); if (operations.containsKey(operationKey)) { throw ParseUtils.unexpectedElement(reader); } ModelNode operation = Util.createAddOperation(address); operations.put(operationKey, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case CACHE_CONFIGURATION: { readAttribute(reader, i, operation, HotRodStoreResourceDefinition.Attribute.CACHE_CONFIGURATION); break; } case REMOTE_CACHE_CONTAINER: { readAttribute(reader, i, operation, HotRodStoreResourceDefinition.Attribute.REMOTE_CACHE_CONTAINER); break; } default: { this.parseStoreAttribute(reader, i, operation); } } } this.applyLegacyStoreAttributeDefaults(operation); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { this.parseStoreElement(reader, address, operations); } } private void parseJDBCStore(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(JDBCStoreResourceDefinition.PATH); PathAddress operationKey = cacheAddress.append(StoreResourceDefinition.WILDCARD_PATH); if (operations.containsKey(operationKey)) { throw ParseUtils.unexpectedElement(reader); } ModelNode operation = Util.createAddOperation(address); operations.put(operationKey, operation); this.parseJDBCStoreAttributes(reader, operationKey, operations); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case TABLE: { this.parseJDBCStoreStringTable(reader, address, operations); break; } default: { this.parseStoreElement(reader, address, operations); } } } } private void parseBinaryKeyedJDBCStore(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(JDBCStoreResourceDefinition.PATH); PathAddress operationKey = cacheAddress.append(StoreResourceDefinition.WILDCARD_PATH); if (operations.containsKey(operationKey)) { throw ParseUtils.unexpectedElement(reader); } ModelNode operation = Util.createAddOperation(address); operations.put(operationKey, operation); this.parseJDBCStoreAttributes(reader, operationKey, operations); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case BINARY_KEYED_TABLE: { this.parseJDBCStoreBinaryTable(reader, address, operations); break; } default: { this.parseStoreElement(reader, address, operations); } } } } private void parseStringKeyedJDBCStore(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(JDBCStoreResourceDefinition.PATH); PathAddress operationKey = cacheAddress.append(StoreResourceDefinition.WILDCARD_PATH); if (operations.containsKey(operationKey)) { throw ParseUtils.unexpectedElement(reader); } ModelNode operation = Util.createAddOperation(address); operations.put(operationKey, operation); this.parseJDBCStoreAttributes(reader, operationKey, operations); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case STRING_KEYED_TABLE: { this.parseJDBCStoreStringTable(reader, address, operations); break; } default: { this.parseStoreElement(reader, address, operations); } } } } private void parseMixedKeyedJDBCStore(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(JDBCStoreResourceDefinition.PATH); PathAddress operationKey = cacheAddress.append(StoreResourceDefinition.WILDCARD_PATH); if (operations.containsKey(operationKey)) { throw ParseUtils.unexpectedElement(reader); } ModelNode operation = Util.createAddOperation(address); operations.put(operationKey, operation); this.parseJDBCStoreAttributes(reader, operationKey, operations); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case BINARY_KEYED_TABLE: { this.parseJDBCStoreBinaryTable(reader, address, operations); break; } case STRING_KEYED_TABLE: { this.parseJDBCStoreStringTable(reader, address, operations); break; } default: { this.parseStoreElement(reader, address, operations); } } } } private void parseJDBCStoreAttributes(XMLExtendedStreamReader reader, PathAddress operationKey, Map<PathAddress, ModelNode> operations) throws XMLStreamException { ModelNode operation = operations.get(operationKey); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case DATASOURCE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } // Attempt to convert jndi name to data source name String jndiName = reader.getAttributeValue(i); String dataSourceName = jndiName.substring(jndiName.lastIndexOf('/') + 1); operation.get(JDBCStoreResourceDefinition.Attribute.DATA_SOURCE.getName()).set(dataSourceName); break; } case DIALECT: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_2_0)) { readAttribute(reader, i, operation, JDBCStoreResourceDefinition.Attribute.DIALECT); break; } } case DATA_SOURCE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { readAttribute(reader, i, operation, JDBCStoreResourceDefinition.Attribute.DATA_SOURCE); break; } } default: { this.parseStoreAttribute(reader, i, operation); } } } this.applyLegacyStoreAttributeDefaults(operation); } private void parseJDBCStoreBinaryTable(XMLExtendedStreamReader reader, PathAddress storeAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = storeAddress.append(StringTableResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(storeAddress.getParent().append(StoreResourceDefinition.WILDCARD_PATH).append(StringTableResourceDefinition.PATH), operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case PREFIX: { readAttribute(reader, i, operation, StringTableResourceDefinition.Attribute.PREFIX); break; } default: { this.parseJDBCStoreTableAttribute(reader, i, operation); } } } this.parseJDBCStoreTableElements(reader, operation); } private void parseJDBCStoreStringTable(XMLExtendedStreamReader reader, PathAddress storeAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = storeAddress.append(StringTableResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(storeAddress.getParent().append(StoreResourceDefinition.WILDCARD_PATH).append(StringTableResourceDefinition.PATH), operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case PREFIX: { readAttribute(reader, i, operation, StringTableResourceDefinition.Attribute.PREFIX); break; } default: { this.parseJDBCStoreTableAttribute(reader, i, operation); } } } this.parseJDBCStoreTableElements(reader, operation); } private void parseJDBCStoreTableAttribute(XMLExtendedStreamReader reader, int index, ModelNode operation) throws XMLStreamException { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(index)); switch (attribute) { case FETCH_SIZE: { readAttribute(reader, index, operation, TableResourceDefinition.Attribute.FETCH_SIZE); break; } case BATCH_SIZE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { throw ParseUtils.unexpectedAttribute(reader, index); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case CREATE_ON_START: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_9_0)) { readAttribute(reader, index, operation, TableResourceDefinition.Attribute.CREATE_ON_START); break; } } case DROP_ON_STOP: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_9_0)) { readAttribute(reader, index, operation, TableResourceDefinition.Attribute.DROP_ON_STOP); break; } } default: { throw ParseUtils.unexpectedAttribute(reader, index); } } } private void parseJDBCStoreTableElements(XMLExtendedStreamReader reader, ModelNode operation) throws XMLStreamException { while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case ID_COLUMN: { this.parseJDBCStoreColumn(reader, ColumnAttribute.ID, operation.get(TableResourceDefinition.ColumnAttribute.ID.getName()).setEmptyObject()); break; } case DATA_COLUMN: { this.parseJDBCStoreColumn(reader, ColumnAttribute.DATA, operation.get(TableResourceDefinition.ColumnAttribute.DATA.getName()).setEmptyObject()); break; } case TIMESTAMP_COLUMN: { this.parseJDBCStoreColumn(reader, ColumnAttribute.TIMESTAMP, operation.get(TableResourceDefinition.ColumnAttribute.TIMESTAMP.getName()).setEmptyObject()); break; } case SEGMENT_COLUMN: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_10_0)) { this.parseJDBCStoreColumn(reader, ColumnAttribute.SEGMENT, operation.get(TableResourceDefinition.ColumnAttribute.SEGMENT.getName()).setEmptyObject()); break; } } default: { throw ParseUtils.unexpectedElement(reader); } } } } private void parseJDBCStoreColumn(XMLExtendedStreamReader reader, ColumnAttribute columnAttribute, ModelNode column) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: { readAttribute(reader, i, column, columnAttribute.getColumnName()); break; } case TYPE: { readAttribute(reader, i, column, columnAttribute.getColumnType()); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private void parseStoreAttribute(XMLExtendedStreamReader reader, int index, ModelNode operation) throws XMLStreamException { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(index)); switch (attribute) { case SHARED: { readAttribute(reader, index, operation, StoreResourceDefinition.Attribute.SHARED); break; } case PRELOAD: { readAttribute(reader, index, operation, StoreResourceDefinition.Attribute.PRELOAD); break; } case PASSIVATION: { readAttribute(reader, index, operation, StoreResourceDefinition.Attribute.PASSIVATION); break; } case FETCH_STATE: { readAttribute(reader, index, operation, StoreResourceDefinition.DeprecatedAttribute.FETCH_STATE); break; } case PURGE: { readAttribute(reader, index, operation, StoreResourceDefinition.Attribute.PURGE); break; } case SINGLETON: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { throw ParseUtils.unexpectedAttribute(reader, index); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case MAX_BATCH_SIZE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_5_0)) { readAttribute(reader, index, operation, StoreResourceDefinition.Attribute.MAX_BATCH_SIZE); break; } } case SEGMENTED: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { readAttribute(reader, index, operation, StoreResourceDefinition.Attribute.SEGMENTED); break; } } default: { throw ParseUtils.unexpectedAttribute(reader, index); } } } private void parseStoreElement(XMLExtendedStreamReader reader, PathAddress storeAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { ModelNode operation = operations.get(storeAddress.getParent().append(StoreResourceDefinition.WILDCARD_PATH)); XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case PROPERTY: { ParseUtils.requireSingleAttribute(reader, XMLAttribute.NAME.getLocalName()); readElement(reader, operation, StoreResourceDefinition.Attribute.PROPERTIES); break; } case WRITE_BEHIND: { this.parseStoreWriteBehind(reader, storeAddress, operations); break; } default: { throw ParseUtils.unexpectedElement(reader); } } } private void parseStoreWriteBehind(XMLExtendedStreamReader reader, PathAddress storeAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = storeAddress.append(StoreWriteBehindResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(storeAddress.append(StoreWriteResourceDefinition.WILDCARD_PATH), operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case FLUSH_LOCK_TIMEOUT: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case MODIFICATION_QUEUE_SIZE: { readAttribute(reader, i, operation, StoreWriteBehindResourceDefinition.Attribute.MODIFICATION_QUEUE_SIZE); break; } case SHUTDOWN_TIMEOUT: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_4_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } case THREAD_POOL_SIZE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_11_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } ClusteringLogger.ROOT_LOGGER.attributeIgnored(attribute.getLocalName(), reader.getLocalName()); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private <P extends ThreadPoolDefinition & ResourceDefinitionProvider> void parseThreadPool(P pool, XMLExtendedStreamReader reader, PathAddress parentAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = parentAddress.append(pool.getPathElement()); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case MIN_THREADS: { if (pool.getMinThreads() != null) { readAttribute(reader, i, operation, pool.getMinThreads()); } break; } case MAX_THREADS: { readAttribute(reader, i, operation, pool.getMaxThreads()); break; } case QUEUE_LENGTH: { if (pool.getQueueLength() != null) { readAttribute(reader, i, operation, pool.getQueueLength()); } break; } case KEEPALIVE_TIME: { readAttribute(reader, i, operation, pool.getKeepAliveTime()); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private <P extends ScheduledThreadPoolDefinition & ResourceDefinitionProvider> void parseScheduledThreadPool(P pool, XMLExtendedStreamReader reader, PathAddress parentAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = parentAddress.append(pool.getPathElement()); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case MAX_THREADS: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_10_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } readAttribute(reader, i, operation, pool.getMinThreads()); break; } case KEEPALIVE_TIME: { readAttribute(reader, i, operation, pool.getKeepAliveTime()); break; } case MIN_THREADS: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_10_0)) { readAttribute(reader, i, operation, pool.getMinThreads()); break; } } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private void parseRemoteContainer(XMLExtendedStreamReader reader, PathAddress subsystemAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { String name = require(reader, XMLAttribute.NAME); PathAddress address = subsystemAddress.append(RemoteCacheContainerResourceDefinition.pathElement(name)); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { ParseUtils.requireNoNamespaceAttribute(reader, i); XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: { // Already parsed break; } case CONNECTION_TIMEOUT: { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.Attribute.CONNECTION_TIMEOUT); break; } case DEFAULT_REMOTE_CLUSTER: { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.Attribute.DEFAULT_REMOTE_CLUSTER); break; } case KEY_SIZE_ESTIMATE: { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.DeprecatedAttribute.KEY_SIZE_ESTIMATE); break; } case MAX_RETRIES: { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.Attribute.MAX_RETRIES); break; } case MODULE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_12_0)) { throw ParseUtils.unexpectedAttribute(reader, i); } readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.ListAttribute.MODULES); break; } case PROTOCOL_VERSION: { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.Attribute.PROTOCOL_VERSION); break; } case SOCKET_TIMEOUT: { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.Attribute.SOCKET_TIMEOUT); break; } case TCP_NO_DELAY: { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.Attribute.TCP_NO_DELAY); break; } case TCP_KEEP_ALIVE: { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.Attribute.TCP_KEEP_ALIVE); break; } case VALUE_SIZE_ESTIMATE: { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.DeprecatedAttribute.VALUE_SIZE_ESTIMATE); break; } case STATISTICS_ENABLED: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_9_0)) { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.Attribute.STATISTICS_ENABLED); break; } } case MODULES: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_12_0)) { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.ListAttribute.MODULES); break; } } case MARSHALLER: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_13_0)) { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.Attribute.MARSHALLER); break; } } case TRANSACTION_TIMEOUT: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_13_0)) { readAttribute(reader, i, operation, RemoteCacheContainerResourceDefinition.Attribute.TRANSACTION_TIMEOUT); break; } } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } if (!operation.hasDefined(CacheContainerResourceDefinition.Attribute.MARSHALLER.getName())) { if (!this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { // Apply legacy default value operation.get(CacheContainerResourceDefinition.Attribute.MARSHALLER.getName()).set(new ModelNode(InfinispanMarshallerFactory.LEGACY.name())); } } while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case ASYNC_THREAD_POOL: { this.parseThreadPool(ThreadPoolResourceDefinition.CLIENT, reader, address, operations); break; } case CONNECTION_POOL: { this.parseConnectionPool(reader, address, operations); break; } case INVALIDATION_NEAR_CACHE: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { throw ParseUtils.unexpectedElement(reader); } ClusteringLogger.ROOT_LOGGER.elementIgnored(reader.getLocalName()); ParseUtils.requireNoContent(reader); break; } case REMOTE_CLUSTERS: { this.parseRemoteClusters(reader, address, operations); break; } case SECURITY: { this.parseRemoteCacheContainerSecurity(reader, address, operations); break; } case TRANSACTION: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_14_0)) { throw ParseUtils.unexpectedElement(reader); } if (this.schema.since(InfinispanSubsystemSchema.VERSION_8_0)) { ClusteringLogger.ROOT_LOGGER.elementIgnored(reader.getLocalName()); ParseUtils.requireNoContent(reader); break; } } case PROPERTY: { if (this.schema.since(InfinispanSubsystemSchema.VERSION_11_0) || (this.schema.since(InfinispanSubsystemSchema.VERSION_9_1) && !this.schema.since(InfinispanSubsystemSchema.VERSION_10_0))) { ParseUtils.requireSingleAttribute(reader, XMLAttribute.NAME.getLocalName()); readElement(reader, operation, RemoteCacheContainerResourceDefinition.Attribute.PROPERTIES); break; } } default: { throw ParseUtils.unexpectedElement(reader); } } } } private void parseConnectionPool(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(ConnectionPoolResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case EXHAUSTED_ACTION: { readAttribute(reader, i, operation, ConnectionPoolResourceDefinition.Attribute.EXHAUSTED_ACTION); break; } case MAX_ACTIVE: { readAttribute(reader, i, operation, ConnectionPoolResourceDefinition.Attribute.MAX_ACTIVE); break; } case MAX_WAIT: { readAttribute(reader, i, operation, ConnectionPoolResourceDefinition.Attribute.MAX_WAIT); break; } case MIN_EVICTABLE_IDLE_TIME: { readAttribute(reader, i, operation, ConnectionPoolResourceDefinition.Attribute.MIN_EVICTABLE_IDLE_TIME); break; } case MIN_IDLE: { readAttribute(reader, i, operation, ConnectionPoolResourceDefinition.Attribute.MIN_IDLE); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private void parseRemoteClusters(XMLExtendedStreamReader reader, PathAddress containerAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { ParseUtils.requireNoAttributes(reader); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case REMOTE_CLUSTER: { this.parseRemoteCluster(reader, containerAddress, operations); break; } default: { throw ParseUtils.unexpectedElement(reader); } } } } private void parseRemoteCluster(XMLExtendedStreamReader reader, PathAddress clustersAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { String remoteCluster = require(reader, XMLAttribute.NAME); PathAddress address = clustersAddress.append(RemoteClusterResourceDefinition.pathElement(remoteCluster)); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: { // Already parsed break; } case SOCKET_BINDINGS: { readAttribute(reader, i, operation, RemoteClusterResourceDefinition.Attribute.SOCKET_BINDINGS); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private void parseRemoteCacheContainerSecurity(XMLExtendedStreamReader reader, PathAddress containerAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = containerAddress.append(SecurityResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case SSL_CONTEXT: { readAttribute(reader, i, operation, SecurityResourceDefinition.Attribute.SSL_CONTEXT); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); } private static String require(XMLExtendedStreamReader reader, XMLAttribute attribute) throws XMLStreamException { String value = reader.getAttributeValue(null, attribute.getLocalName()); if (value == null) { throw ParseUtils.missingRequired(reader, attribute.getLocalName()); } return value; } private static void readAttribute(XMLExtendedStreamReader reader, int index, ModelNode operation, Attribute attribute) throws XMLStreamException { setAttribute(reader, reader.getAttributeValue(index), operation, attribute); } private static void setAttribute(XMLExtendedStreamReader reader, String value, ModelNode operation, Attribute attribute) throws XMLStreamException { AttributeDefinition definition = attribute.getDefinition(); definition.getParser().parseAndSetParameter(definition, value, operation, reader); } private static void readElement(XMLExtendedStreamReader reader, ModelNode operation, Attribute attribute) throws XMLStreamException { AttributeDefinition definition = attribute.getDefinition(); AttributeParser parser = definition.getParser(); if (parser.isParseAsElement()) { parser.parseElement(definition, reader, operation); } else { parser.parseAndSetParameter(definition, reader.getElementText(), operation, reader); } } }
93,260
45.491027
247
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.Set; import java.util.function.Consumer; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.transform.TransformationContext; import org.jboss.as.controller.transform.description.AttributeConverter; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; import org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Attribute; import org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.ListAttribute; import org.jboss.dmr.ModelNode; /** * Transformer for cache container resources. * @author Paul Ferraro */ public class CacheContainerResourceTransformer implements Consumer<ModelVersion> { private static final Set<String> SERVER_MODULES = Set.of("org.wildfly.clustering.server.infinispan", "org.wildfly.clustering.singleton.server"); private static final String LEGACY_SERVER_MODULE = "org.wildfly.clustering.server"; private final ResourceTransformationDescriptionBuilder builder; CacheContainerResourceTransformer(ResourceTransformationDescriptionBuilder parent) { this.builder = parent.addChildResource(CacheContainerResourceDefinition.WILDCARD_PATH); } @SuppressWarnings("deprecation") @Override public void accept(ModelVersion version) { if (InfinispanSubsystemModel.VERSION_16_0_0.requiresTransformation(version)) { this.builder.getAttributeBuilder() .setValueConverter(new AttributeConverter.DefaultAttributeConverter() { @Override protected void convertAttribute(PathAddress address, String name, ModelNode modules, TransformationContext context) { if (modules.isDefined()) { // Handle refactoring of org.wildfly.clustering.server module for (ModelNode module : modules.asList()) { if (SERVER_MODULES.contains(module.asString())) { module.set(LEGACY_SERVER_MODULE); } } } } }, ListAttribute.MODULES.getDefinition()) .end(); } if (InfinispanSubsystemModel.VERSION_15_0_0.requiresTransformation(version)) { this.builder.getAttributeBuilder() .setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, Attribute.MARSHALLER.getDefinition()) .addRejectCheck(new RejectAttributeChecker.SimpleAcceptAttributeChecker(Attribute.MARSHALLER.getDefinition().getDefaultValue()), Attribute.MARSHALLER.getDefinition()) .end(); } new ScatteredCacheResourceTransformer(this.builder).accept(version); new DistributedCacheResourceTransformer(this.builder).accept(version); new ReplicatedCacheResourceTransformer(this.builder).accept(version); new InvalidationCacheResourceTransformer(this.builder).accept(version); new LocalCacheResourceTransformer(this.builder).accept(version); } }
4,481
49.931818
186
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/PartitionHandlingOperationExecutor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.AdvancedCache; import org.infinispan.Cache; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; /** * Executor for partition handling operations. * @author Paul Ferraro */ public class PartitionHandlingOperationExecutor extends CacheOperationExecutor<AdvancedCache<?, ?>> { public PartitionHandlingOperationExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(executors, BinaryCapabilityNameResolver.GRANDPARENT_PARENT); } @Override public AdvancedCache<?, ?> apply(Cache<?, ?> cache) { return cache.getAdvancedCache(); } }
1,768
38.311111
101
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/XMLAttribute.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.clustering.infinispan.subsystem.remote.ConnectionPoolResourceDefinition; import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition; import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteClusterResourceDefinition; import org.jboss.as.clustering.infinispan.subsystem.remote.SecurityResourceDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; /** * Enumerates the attributes used in the Infinispan subsystem schema. * @author Paul Ferraro * @author Richard Achmatowicz (c) 2011 RedHat Inc. * @author Tristan Tarrant */ public enum XMLAttribute { // must be first UNKNOWN((String) null), ACQUIRE_TIMEOUT(LockingResourceDefinition.Attribute.ACQUIRE_TIMEOUT), @Deprecated CAPACITY("capacity"), ALIASES(CacheContainerResourceDefinition.ListAttribute.ALIASES), @Deprecated ASYNC_MARSHALLING("async-marshalling"), BACKUP_FAILURE_POLICY(BackupResourceDefinition.Attribute.FAILURE_POLICY), @Deprecated BATCH_SIZE("batch-size"), @Deprecated BATCHING("batching"), @Deprecated BIAS_LIFESPAN(ScatteredCacheResourceDefinition.Attribute.BIAS_LIFESPAN), @Deprecated CACHE(RemoteStoreResourceDefinition.Attribute.CACHE), CAPACITY_FACTOR(DistributedCacheResourceDefinition.Attribute.CAPACITY_FACTOR), CHANNEL(JGroupsTransportResourceDefinition.Attribute.CHANNEL), CHUNK_SIZE(StateTransferResourceDefinition.Attribute.CHUNK_SIZE), CLASS(CustomStoreResourceDefinition.Attribute.CLASS), @Deprecated CLUSTER("cluster"), COMPLETE_TIMEOUT(TransactionResourceDefinition.Attribute.COMPLETE_TIMEOUT), CONCURRENCY_LEVEL(LockingResourceDefinition.Attribute.CONCURRENCY), @Deprecated CONSISTENT_HASH_STRATEGY("consistent-hash-strategy"), CREATE_ON_START(TableResourceDefinition.Attribute.CREATE_ON_START), DATA_SOURCE(JDBCStoreResourceDefinition.Attribute.DATA_SOURCE), @Deprecated DATASOURCE("datasource"), DEFAULT_CACHE(CacheContainerResourceDefinition.Attribute.DEFAULT_CACHE), @Deprecated DEFAULT_CACHE_CONTAINER("default-cache-container"), DIALECT(JDBCStoreResourceDefinition.Attribute.DIALECT), DROP_ON_STOP(TableResourceDefinition.Attribute.DROP_ON_STOP), @Deprecated ENABLED(BackupResourceDefinition.DeprecatedAttribute.ENABLED), @Deprecated EVICTION_EXECUTOR("eviction-executor"), @Deprecated EVICTION_TYPE("eviction-type"), @Deprecated EXECUTOR("executor"), FETCH_SIZE(TableResourceDefinition.Attribute.FETCH_SIZE), @Deprecated FETCH_STATE(StoreResourceDefinition.DeprecatedAttribute.FETCH_STATE), @Deprecated FLUSH_LOCK_TIMEOUT("flush-lock-timeout"), @Deprecated INDEX("index"), INTERVAL(ExpirationResourceDefinition.Attribute.INTERVAL), @Deprecated INVALIDATION_BATCH_SIZE(ScatteredCacheResourceDefinition.Attribute.INVALIDATION_BATCH_SIZE), ISOLATION(LockingResourceDefinition.Attribute.ISOLATION), @Deprecated JNDI_NAME("jndi-name"), KEEPALIVE_TIME(ThreadPoolResourceDefinition.values()[0].getKeepAliveTime()), L1_LIFESPAN(DistributedCacheResourceDefinition.Attribute.L1_LIFESPAN), LIFESPAN(ExpirationResourceDefinition.Attribute.LIFESPAN), @Deprecated LISTENER_EXECUTOR("listener-executor"), LOCK_TIMEOUT(JGroupsTransportResourceDefinition.Attribute.LOCK_TIMEOUT), LOCKING(TransactionResourceDefinition.Attribute.LOCKING), MARSHALLER(CacheContainerResourceDefinition.Attribute.MARSHALLER), MAX_BATCH_SIZE(StoreResourceDefinition.Attribute.MAX_BATCH_SIZE), @Deprecated MAX_ENTRIES("max-entries"), MAX_IDLE(ExpirationResourceDefinition.Attribute.MAX_IDLE), MAX_THREADS(ThreadPoolResourceDefinition.values()[0].getMaxThreads()), MERGE_POLICY(PartitionHandlingResourceDefinition.Attribute.MERGE_POLICY), MIN_THREADS(ThreadPoolResourceDefinition.values()[0].getMinThreads()), MODE(TransactionResourceDefinition.Attribute.MODE), MODIFICATION_QUEUE_SIZE(StoreWriteBehindResourceDefinition.Attribute.MODIFICATION_QUEUE_SIZE), @Deprecated MODULE("module"), MODULES(CacheContainerResourceDefinition.ListAttribute.MODULES), NAME(ModelDescriptionConstants.NAME), OUTBOUND_SOCKET_BINDING("outbound-socket-binding"), OWNERS(DistributedCacheResourceDefinition.Attribute.OWNERS), PASSIVATION(StoreResourceDefinition.Attribute.PASSIVATION), PATH(FileStoreResourceDefinition.DeprecatedAttribute.RELATIVE_PATH), PREFIX(StringTableResourceDefinition.Attribute.PREFIX), PRELOAD(StoreResourceDefinition.Attribute.PRELOAD), PURGE(StoreResourceDefinition.Attribute.PURGE), @Deprecated QUEUE_FLUSH_INTERVAL("queue-flush-interval"), QUEUE_LENGTH(ThreadPoolResourceDefinition.BLOCKING.getQueueLength()), @Deprecated QUEUE_SIZE("queue-size"), RELATIVE_TO(FileStoreResourceDefinition.DeprecatedAttribute.RELATIVE_TO), @Deprecated REMOTE_CACHE("remote-cache"), @Deprecated REMOTE_SERVERS(RemoteStoreResourceDefinition.Attribute.SOCKET_BINDINGS), @Deprecated REMOTE_SITE("remote-site"), REMOTE_TIMEOUT(ClusteredCacheResourceDefinition.Attribute.REMOTE_TIMEOUT), @Deprecated REPLICATION_QUEUE_EXECUTOR("replication-queue-executor"), SEGMENTED(StoreResourceDefinition.Attribute.SEGMENTED), SEGMENTS(SegmentedCacheResourceDefinition.Attribute.SEGMENTS), SHARED(StoreResourceDefinition.Attribute.SHARED), @Deprecated SHUTDOWN_TIMEOUT("shutdown-timeout"), @Deprecated SINGLETON("singleton"), SITE("site"), SIZE(MemoryResourceDefinition.Attribute.SIZE), SIZE_UNIT(MemoryResourceDefinition.SharedAttribute.SIZE_UNIT), @Deprecated STACK("stack"), @Deprecated START("start"), STATISTICS_ENABLED(CacheResourceDefinition.Attribute.STATISTICS_ENABLED), STOP_TIMEOUT(TransactionResourceDefinition.Attribute.STOP_TIMEOUT), STRATEGY(BackupResourceDefinition.Attribute.STRATEGY), STRIPING(LockingResourceDefinition.Attribute.STRIPING), TAKE_OFFLINE_AFTER_FAILURES(BackupResourceDefinition.TakeOfflineAttribute.AFTER_FAILURES), TAKE_OFFLINE_MIN_WAIT(BackupResourceDefinition.TakeOfflineAttribute.MIN_WAIT), @Deprecated THREAD_POOL_SIZE("thread-pool-size"), TIMEOUT(StateTransferResourceDefinition.Attribute.TIMEOUT), TYPE(TableResourceDefinition.ColumnAttribute.ID.getColumnType()), WHEN_SPLIT(PartitionHandlingResourceDefinition.Attribute.WHEN_SPLIT), // hotrod store CACHE_CONFIGURATION(HotRodStoreResourceDefinition.Attribute.CACHE_CONFIGURATION), // remote-cache-container REMOTE_CACHE_CONTAINER(RemoteCacheContainerResourceDefinition.WILDCARD_PATH), CONNECTION_TIMEOUT(RemoteCacheContainerResourceDefinition.Attribute.CONNECTION_TIMEOUT), DEFAULT_REMOTE_CLUSTER(RemoteCacheContainerResourceDefinition.Attribute.DEFAULT_REMOTE_CLUSTER), KEY_SIZE_ESTIMATE(RemoteCacheContainerResourceDefinition.DeprecatedAttribute.KEY_SIZE_ESTIMATE), MAX_RETRIES(RemoteCacheContainerResourceDefinition.Attribute.MAX_RETRIES), PROTOCOL_VERSION(RemoteCacheContainerResourceDefinition.Attribute.PROTOCOL_VERSION), SOCKET_TIMEOUT(RemoteCacheContainerResourceDefinition.Attribute.SOCKET_TIMEOUT), TCP_NO_DELAY(RemoteCacheContainerResourceDefinition.Attribute.TCP_NO_DELAY), TCP_KEEP_ALIVE(RemoteCacheContainerResourceDefinition.Attribute.TCP_KEEP_ALIVE), TRANSACTION_TIMEOUT(RemoteCacheContainerResourceDefinition.Attribute.TRANSACTION_TIMEOUT), VALUE_SIZE_ESTIMATE(RemoteCacheContainerResourceDefinition.DeprecatedAttribute.VALUE_SIZE_ESTIMATE), // remote-cache-container -> connection-pool EXHAUSTED_ACTION(ConnectionPoolResourceDefinition.Attribute.EXHAUSTED_ACTION), MAX_ACTIVE(ConnectionPoolResourceDefinition.Attribute.MAX_ACTIVE), MAX_WAIT(ConnectionPoolResourceDefinition.Attribute.MAX_WAIT), MIN_EVICTABLE_IDLE_TIME(ConnectionPoolResourceDefinition.Attribute.MIN_EVICTABLE_IDLE_TIME), MIN_IDLE(ConnectionPoolResourceDefinition.Attribute.MIN_IDLE), // remote-cache-container -> remote-clusters SOCKET_BINDINGS(RemoteClusterResourceDefinition.Attribute.SOCKET_BINDINGS), // remote-cache-container -> security SSL_CONTEXT(SecurityResourceDefinition.Attribute.SSL_CONTEXT), ; private final String name; XMLAttribute(Attribute attribute) { this(attribute.getDefinition().getXmlName()); } XMLAttribute(PathElement wildcardPath) { this(wildcardPath.getKey()); } XMLAttribute(String name) { this.name = name; } /** * Get the local name of this element. * * @return the local name */ public String getLocalName() { return this.name; } private static final Map<String, XMLAttribute> attributes; static { final Map<String, XMLAttribute> map = new HashMap<>(); for (XMLAttribute attribute : EnumSet.allOf(XMLAttribute.class)) { final String name = attribute.getLocalName(); if (name != null) { assert !map.containsKey(name) : attribute; map.put(name, attribute); } } attributes = map; } public static XMLAttribute forName(String localName) { final XMLAttribute attribute = attributes.get(localName); return attribute == null ? UNKNOWN : attribute; } }
10,533
49.644231
108
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/SegmentsAndVirtualNodeConverter.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.dmr.ModelNode; /** * Convert the 1.4 SEGMENTS value to VIRTUAL_NODES in model and operations, if defined and not an expression * * @author <a href="mailto:tomaz.cerar@redhat.com">Tomaz Cerar</a> * @author Richard Achmatowicz (c) RedHat 2013 */ public class SegmentsAndVirtualNodeConverter { // ratio of segments to virtual nodes to convert between the two public static final int SEGMENTS_PER_VIRTUAL_NODE = 6; public static final int VIRTUAL_NODES_DEFAULT = 1; public static final int SEGMENTS_DEFAULT = SegmentedCacheResourceDefinition.Attribute.SEGMENTS.getDefinition().getDefaultValue().asInt(); /* * Convert a 1.3 virtual nodes value to a 1.4 segments value */ public static int virtualNodesToSegments(int virtualNodes) { return virtualNodes * SEGMENTS_PER_VIRTUAL_NODE; } /* * Convert a 1.4 segments value to a 1.3 virtual nodes value */ public static int segmentsToVirtualNodes(int segments) { // divide by zero should not occur as segments is required to be > 0 return segments / SEGMENTS_PER_VIRTUAL_NODE; } /* * Helper methods */ public static String virtualNodesToSegments(String virtualNodesValue) { int segments = SEGMENTS_DEFAULT; try { segments = virtualNodesToSegments(Integer.parseInt(virtualNodesValue)); } catch(NumberFormatException nfe) { // in case of expression } return Integer.toString(segments); } public static String segmentsToVirtualNodes(String segmentsValue) { int virtualNodes = VIRTUAL_NODES_DEFAULT; try { virtualNodes = segmentsToVirtualNodes(Integer.parseInt(segmentsValue)); } catch(NumberFormatException nfe) { // in case of expression } return Integer.toString(virtualNodes); } public static ModelNode virtualNodesToSegments(ModelNode virtualNodes) { int segments = SEGMENTS_DEFAULT; if (virtualNodes.isDefined()) { segments = virtualNodesToSegments(virtualNodes.asInt()); } return new ModelNode(segments); } public static ModelNode segmentsToVirtualNodes(ModelNode segments) { int virtualNodes = VIRTUAL_NODES_DEFAULT; if (segments.isDefined()) { virtualNodes = segmentsToVirtualNodes(segments.asInt()); } return new ModelNode(virtualNodes); } }
3,560
35.336735
141
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheActivationMetric.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.eviction.impl.ActivationManager; import org.jboss.as.clustering.controller.Metric; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Cache activation metrics. * @author Paul Ferraro */ public enum CacheActivationMetric implements Metric<ActivationManager> { ACTIVATIONS("activations", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) { @Override public ModelNode execute(ActivationManager manager) { return new ModelNode(manager.getActivationCount()); } }, ; private final AttributeDefinition definition; CacheActivationMetric(String name, ModelType type, AttributeAccess.Flag metricType) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setFlags(metricType) .setStorageRuntime() .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } }
2,238
36.316667
89
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StoreResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.Consumer; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.transform.description.AttributeConverter; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * Transformers for cache store resources. * @author Paul Ferraro */ public class StoreResourceTransformer implements Consumer<ModelVersion> { final ResourceTransformationDescriptionBuilder builder; StoreResourceTransformer(ResourceTransformationDescriptionBuilder builder) { this.builder = builder; } @Override public void accept(ModelVersion version) { if (InfinispanSubsystemModel.VERSION_16_0_0.requiresTransformation(version)) { this.builder.getAttributeBuilder() .setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, StoreResourceDefinition.Attribute.SEGMENTED.getDefinition()) .addRejectCheck(RejectAttributeChecker.DEFINED, StoreResourceDefinition.Attribute.SEGMENTED.getDefinition()) .setValueConverter(AttributeConverter.DEFAULT_VALUE, StoreResourceDefinition.Attribute.PASSIVATION.getDefinition()) .setValueConverter(AttributeConverter.DEFAULT_VALUE, StoreResourceDefinition.Attribute.PURGE.getDefinition()) .end(); } } }
2,564
44
131
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.EnumMap; import java.util.EnumSet; import java.util.Map; import java.util.function.UnaryOperator; import java.util.stream.Collectors; import org.infinispan.Cache; import org.infinispan.manager.EmbeddedCacheManager; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.CapabilityReference; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.MetricHandler; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.ServiceValueExecutorRegistry; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.UnaryRequirementCapability; import org.jboss.as.clustering.controller.validation.ModuleIdentifierValidatorBuilder; import org.jboss.as.clustering.infinispan.logging.InfinispanLogger; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.StringListAttributeDefinition; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.operations.validation.ParameterValidator; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.clustering.infinispan.marshall.InfinispanMarshallerFactory; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.InfinispanRequirement; import org.wildfly.clustering.server.service.ClusteringDefaultCacheRequirement; import org.wildfly.clustering.service.UnaryRequirement; import org.wildfly.clustering.singleton.SingletonDefaultCacheRequirement; /** * Resource description for the addressable resource /subsystem=infinispan/cache-container=X * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. * @author Paul Ferraro */ public class CacheContainerResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static PathElement pathElement(String containerName) { return PathElement.pathElement("cache-container", containerName); } enum Capability implements CapabilityProvider { CONTAINER(InfinispanRequirement.CONTAINER), CONFIGURATION(InfinispanRequirement.CONFIGURATION), KEY_AFFINITY_FACTORY(InfinispanRequirement.KEY_AFFINITY_FACTORY), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(UnaryRequirement requirement) { this.capability = new UnaryRequirementCapability(requirement); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } } static final Map<InfinispanCacheRequirement, org.jboss.as.clustering.controller.Capability> DEFAULT_CAPABILITIES = new EnumMap<>(InfinispanCacheRequirement.class); static { for (InfinispanCacheRequirement requirement : EnumSet.allOf(InfinispanCacheRequirement.class)) { DEFAULT_CAPABILITIES.put(requirement, new UnaryRequirementCapability(requirement.getDefaultRequirement())); } } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { DEFAULT_CACHE("default-cache", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setAllowExpression(false).setCapabilityReference(new CapabilityReference(DEFAULT_CAPABILITIES.get(InfinispanCacheRequirement.CONFIGURATION), InfinispanCacheRequirement.CONFIGURATION, WILDCARD_PATH)); } }, STATISTICS_ENABLED(ModelDescriptionConstants.STATISTICS_ENABLED, ModelType.BOOLEAN) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setDefaultValue(ModelNode.FALSE); } }, MARSHALLER("marshaller", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setDefaultValue(new ModelNode(InfinispanMarshallerFactory.LEGACY.name())) .setValidator(new ParameterValidator() { private final ParameterValidator validator = EnumValidator.create(InfinispanMarshallerFactory.class); @Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { this.validator.validateParameter(parameterName, value); if (!value.isDefined() || value.equals(MARSHALLER.getDefinition().getDefaultValue())) { InfinispanLogger.ROOT_LOGGER.marshallerEnumValueDeprecated(parameterName, InfinispanMarshallerFactory.LEGACY, EnumSet.complementOf(EnumSet.of(InfinispanMarshallerFactory.LEGACY))); } } }); } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder; } } enum ListAttribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<StringListAttributeDefinition.Builder> { ALIASES("aliases"), MODULES("modules") { @Override public StringListAttributeDefinition.Builder apply(StringListAttributeDefinition.Builder builder) { return builder.setElementValidator(new ModuleIdentifierValidatorBuilder().configure(builder).build()); } }, ; private final AttributeDefinition definition; ListAttribute(String name) { this.definition = this.apply(new StringListAttributeDefinition.Builder(name) .setRequired(false) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } @Override public StringListAttributeDefinition.Builder apply(StringListAttributeDefinition.Builder builder) { return builder; } } CacheContainerResourceDefinition() { super(WILDCARD_PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(WILDCARD_PATH)); } @SuppressWarnings("deprecation") @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()) .addAttributes(Attribute.class) .addAttributes(ListAttribute.class) .addCapabilities(Capability.class) .addCapabilities(model -> model.hasDefined(Attribute.DEFAULT_CACHE.getName()), DEFAULT_CAPABILITIES.values()) .addCapabilities(model -> model.hasDefined(Attribute.DEFAULT_CACHE.getName()), EnumSet.allOf(ClusteringDefaultCacheRequirement.class).stream().map(UnaryRequirementCapability::new).collect(Collectors.toList())) .addCapabilities(model -> model.hasDefined(Attribute.DEFAULT_CACHE.getName()), EnumSet.allOf(SingletonDefaultCacheRequirement.class).stream().map(UnaryRequirementCapability::new).collect(Collectors.toList())) .addRequiredChildren(EnumSet.complementOf(EnumSet.of(ThreadPoolResourceDefinition.CLIENT))) .addRequiredChildren(ScheduledThreadPoolResourceDefinition.class) .addRequiredSingletonChildren(NoTransportResourceDefinition.PATH) .setResourceTransformation(CacheContainerResource::new) ; ServiceValueExecutorRegistry<EmbeddedCacheManager> managerExecutors = new ServiceValueExecutorRegistry<>(); ServiceValueExecutorRegistry<Cache<?, ?>> cacheExecutors = new ServiceValueExecutorRegistry<>(); ResourceServiceHandler handler = new CacheContainerServiceHandler(managerExecutors, cacheExecutors); new SimpleResourceRegistrar(descriptor, handler).register(registration); if (registration.isRuntimeOnlyRegistrationValid()) { new MetricHandler<>(new CacheContainerMetricExecutor(managerExecutors), CacheContainerMetric.class).register(registration); new CacheRuntimeResourceDefinition(cacheExecutors).register(registration); } new JGroupsTransportResourceDefinition().register(registration); new NoTransportResourceDefinition().register(registration); for (ThreadPoolResourceDefinition pool : EnumSet.complementOf(EnumSet.of(ThreadPoolResourceDefinition.CLIENT))) { pool.register(registration); } for (ScheduledThreadPoolResourceDefinition pool : EnumSet.allOf(ScheduledThreadPoolResourceDefinition.class)) { pool.register(registration); } new LocalCacheResourceDefinition(cacheExecutors).register(registration); new InvalidationCacheResourceDefinition(cacheExecutors).register(registration); new ReplicatedCacheResourceDefinition(cacheExecutors).register(registration); new DistributedCacheResourceDefinition(cacheExecutors).register(registration); new ScatteredCacheResourceDefinition(cacheExecutors).register(registration); return registration; } }
11,832
50.225108
230
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/RemoteStoreResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * @author Paul Ferraro */ @Deprecated public class RemoteStoreResourceTransformer extends StoreResourceTransformer { RemoteStoreResourceTransformer(ResourceTransformationDescriptionBuilder parent) { super(parent.addChildResource(RemoteStoreResourceDefinition.PATH)); } }
1,469
38.72973
94
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/PartitionHandlingRuntimeResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.Cache; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.MetricHandler; import org.jboss.as.clustering.controller.OperationHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.registry.ManagementResourceRegistration; /** * @author Paul Ferraro */ public class PartitionHandlingRuntimeResourceDefinition extends CacheComponentRuntimeResourceDefinition { static final PathElement PATH = pathElement("partition-handling"); private final FunctionExecutorRegistry<Cache<?, ?>> executors; PartitionHandlingRuntimeResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(PATH); this.executors = executors; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = super.register(parent); new MetricHandler<>(new PartitionHandlingMetricExecutor(this.executors), PartitionHandlingMetric.class).register(registration); new OperationHandler<>(new PartitionHandlingOperationExecutor(this.executors), PartitionHandlingOperation.class).register(registration); return registration; } }
2,353
42.592593
144
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ScatteredCacheResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * @author Paul Ferraro */ @Deprecated public class ScatteredCacheResourceTransformer extends SegmentedCacheResourceTransformer { ScatteredCacheResourceTransformer(ResourceTransformationDescriptionBuilder parent) { super(parent.addChildResource(ScatteredCacheResourceDefinition.WILDCARD_PATH)); } }
1,496
39.459459
94
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StoreWriteResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.controller.PathElement; /** * @author Paul Ferraro */ public abstract class StoreWriteResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static PathElement pathElement(String value) { return PathElement.pathElement("write", value); } StoreWriteResourceDefinition(PathElement path) { super(path, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(path)); } }
1,764
39.113636
116
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/RemoteStoreServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.RemoteStoreResourceDefinition.Attribute.CACHE; import static org.jboss.as.clustering.infinispan.subsystem.RemoteStoreResourceDefinition.Attribute.SOCKET_BINDINGS; import static org.jboss.as.clustering.infinispan.subsystem.RemoteStoreResourceDefinition.Attribute.SOCKET_TIMEOUT; import static org.jboss.as.clustering.infinispan.subsystem.RemoteStoreResourceDefinition.Attribute.TCP_NO_DELAY; import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; import org.infinispan.persistence.remote.configuration.RemoteStoreConfiguration; import org.infinispan.persistence.remote.configuration.RemoteStoreConfigurationBuilder; import org.jboss.as.clustering.controller.CommonUnaryRequirement; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.StringListAttributeDefinition; import org.jboss.as.network.OutboundSocketBinding; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceBuilder; import org.wildfly.clustering.service.Dependency; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; /** * @author Paul Ferraro */ @Deprecated public class RemoteStoreServiceConfigurator extends StoreServiceConfigurator<RemoteStoreConfiguration, RemoteStoreConfigurationBuilder> { private volatile List<SupplierDependency<OutboundSocketBinding>> bindings; private volatile String remoteCacheName; private volatile long socketTimeout; private volatile boolean tcpNoDelay; public RemoteStoreServiceConfigurator(PathAddress address) { super(address, RemoteStoreConfigurationBuilder.class); } @Override public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { for (Dependency dependency : this.bindings) { dependency.register(builder); } return super.register(builder); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.remoteCacheName = CACHE.resolveModelAttribute(context, model).asString(); this.socketTimeout = SOCKET_TIMEOUT.resolveModelAttribute(context, model).asLong(); this.tcpNoDelay = TCP_NO_DELAY.resolveModelAttribute(context, model).asBoolean(); List<String> bindings = StringListAttributeDefinition.unwrapValue(context, SOCKET_BINDINGS.resolveModelAttribute(context, model)); this.bindings = new ArrayList<>(bindings.size()); for (String binding : bindings) { this.bindings.add(new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, binding))); } return super.configure(context, model); } @Override public void accept(RemoteStoreConfigurationBuilder builder) { builder.segmented(false) .remoteCacheName(this.remoteCacheName) .socketTimeout(this.socketTimeout) .tcpNoDelay(this.tcpNoDelay) ; for (Supplier<OutboundSocketBinding> bindingDependency : this.bindings) { OutboundSocketBinding binding = bindingDependency.get(); builder.addServer().host(binding.getUnresolvedDestinationAddress()).port(binding.getDestinationPort()); } } }
4,606
46.010204
144
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/BackupsServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.BackupResourceDefinition.Attribute.FAILURE_POLICY; import static org.jboss.as.clustering.infinispan.subsystem.BackupResourceDefinition.Attribute.STRATEGY; import static org.jboss.as.clustering.infinispan.subsystem.BackupResourceDefinition.Attribute.TIMEOUT; import static org.jboss.as.clustering.infinispan.subsystem.BackupResourceDefinition.TakeOfflineAttribute.AFTER_FAILURES; import static org.jboss.as.clustering.infinispan.subsystem.BackupResourceDefinition.TakeOfflineAttribute.MIN_WAIT; import java.util.HashMap; import java.util.Map; import org.infinispan.configuration.cache.BackupConfiguration; import org.infinispan.configuration.cache.BackupConfiguration.BackupStrategy; import org.infinispan.configuration.cache.BackupConfigurationBuilder; import org.infinispan.configuration.cache.BackupFailurePolicy; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.SitesConfiguration; import org.infinispan.configuration.cache.SitesConfigurationBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.jboss.dmr.Property; import org.wildfly.clustering.service.ServiceConfigurator; /** * @author Paul Ferraro */ public class BackupsServiceConfigurator extends ComponentServiceConfigurator<SitesConfiguration> { private final Map<String, BackupConfiguration> backups = new HashMap<>(); BackupsServiceConfigurator(PathAddress address) { super(CacheComponent.BACKUPS, address); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.backups.clear(); if (model.hasDefined(BackupResourceDefinition.WILDCARD_PATH.getKey())) { SitesConfigurationBuilder builder = new ConfigurationBuilder().sites(); for (Property property : model.get(BackupResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) { String siteName = property.getName(); ModelNode backup = property.getValue(); BackupConfigurationBuilder backupBuilder = builder.addBackup(); backupBuilder.site(siteName) .backupFailurePolicy(BackupFailurePolicy.valueOf(FAILURE_POLICY.resolveModelAttribute(context, backup).asString())) .replicationTimeout(TIMEOUT.resolveModelAttribute(context, backup).asLong()) .strategy(BackupStrategy.valueOf(STRATEGY.resolveModelAttribute(context, backup).asString())) .takeOffline() .afterFailures(AFTER_FAILURES.resolveModelAttribute(context, backup).asInt()) .minTimeToWait(MIN_WAIT.resolveModelAttribute(context, backup).asLong()) ; this.backups.put(siteName, backupBuilder.create()); } } return this; } @Override public SitesConfiguration get() { SitesConfigurationBuilder builder = new ConfigurationBuilder().sites(); for (Map.Entry<String, BackupConfiguration> backup : this.backups.entrySet()) { builder.addBackup().read(backup.getValue()); } return builder.create(); } }
4,493
48.384615
139
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/PartitionHandlingServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.PartitionHandlingResourceDefinition.Attribute.*; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.PartitionHandlingConfiguration; import org.infinispan.conflict.MergePolicy; import org.infinispan.partitionhandling.PartitionHandling; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; /** * Builds a service providing a {@link PartitionHandlingConfiguration}. * @author Paul Ferraro */ public class PartitionHandlingServiceConfigurator extends ComponentServiceConfigurator<PartitionHandlingConfiguration> { private volatile PartitionHandling whenSplit; private volatile MergePolicy mergePolicy; PartitionHandlingServiceConfigurator(PathAddress address) { super(CacheComponent.PARTITION_HANDLING, address); } @Override public PartitionHandlingConfiguration get() { return new ConfigurationBuilder().clustering().partitionHandling() .whenSplit(this.whenSplit) .mergePolicy(this.mergePolicy) .create(); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.whenSplit = PartitionHandling.valueOf(WHEN_SPLIT.resolveModelAttribute(context, model).asString()); this.mergePolicy = MergePolicy.valueOf(MERGE_POLICY.resolveModelAttribute(context, model).asString()); return this; } }
2,772
41.661538
120
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StoreServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.CacheComponent.PERSISTENCE; import static org.jboss.as.clustering.infinispan.subsystem.StoreResourceDefinition.Attribute.*; import java.util.Properties; import java.util.function.Consumer; import org.infinispan.configuration.cache.AbstractStoreConfigurationBuilder; import org.infinispan.configuration.cache.AsyncStoreConfiguration; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.PersistenceConfiguration; import org.infinispan.configuration.cache.StoreConfiguration; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.jboss.dmr.Property; import org.jboss.msc.service.ServiceBuilder; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; /** * @author Paul Ferraro */ public abstract class StoreServiceConfigurator<C extends StoreConfiguration, B extends AbstractStoreConfigurationBuilder<C, B>> extends ComponentServiceConfigurator<PersistenceConfiguration> implements Consumer<B> { private final SupplierDependency<AsyncStoreConfiguration> async; private final Class<B> builderClass; private final Properties properties = new Properties(); private volatile boolean passivation; private volatile boolean preload; private volatile boolean purge; private volatile boolean segmented; private volatile boolean shared; private volatile int maxBatchSize; protected StoreServiceConfigurator(PathAddress address, Class<B> builderClass) { super(PERSISTENCE, address); this.builderClass = builderClass; this.async = new ServiceSupplierDependency<>(CacheComponent.STORE_WRITE.getServiceName(address.getParent())); } @Override public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { return super.register(this.async.register(builder)); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.passivation = PASSIVATION.resolveModelAttribute(context, model).asBoolean(); this.preload = PRELOAD.resolveModelAttribute(context, model).asBoolean(); this.purge = PURGE.resolveModelAttribute(context, model).asBoolean(); this.segmented = SEGMENTED.resolveModelAttribute(context, model).asBoolean(); this.shared = SHARED.resolveModelAttribute(context, model).asBoolean(); this.maxBatchSize = MAX_BATCH_SIZE.resolveModelAttribute(context, model).asInt(); this.properties.clear(); for (Property property : PROPERTIES.resolveModelAttribute(context, model).asPropertyListOrEmpty()) { this.properties.setProperty(property.getName(), property.getValue().asString()); } return this; } @Override public PersistenceConfiguration get() { B builder = new ConfigurationBuilder().persistence() .passivation(this.passivation) .addStore(this.builderClass) .maxBatchSize(this.maxBatchSize) .preload(this.preload) .purgeOnStartup(this.purge) .segmented(this.segmented) .shared(this.shared) .withProperties(this.properties) ; this.accept(builder); return builder.async().read(this.async.get()).persistence().create(); } boolean isPurgeOnStartup() { return this.purge; } }
4,815
43.592593
215
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TableServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.TableResourceDefinition.Attribute.CREATE_ON_START; import static org.jboss.as.clustering.infinispan.subsystem.TableResourceDefinition.Attribute.DROP_ON_STOP; import static org.jboss.as.clustering.infinispan.subsystem.TableResourceDefinition.Attribute.FETCH_SIZE; import static org.jboss.as.clustering.infinispan.subsystem.TableResourceDefinition.ColumnAttribute.DATA; import static org.jboss.as.clustering.infinispan.subsystem.TableResourceDefinition.ColumnAttribute.ID; import static org.jboss.as.clustering.infinispan.subsystem.TableResourceDefinition.ColumnAttribute.SEGMENT; import static org.jboss.as.clustering.infinispan.subsystem.TableResourceDefinition.ColumnAttribute.TIMESTAMP; import java.util.AbstractMap; import java.util.EnumMap; import java.util.EnumSet; import java.util.Map; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder; import org.infinispan.persistence.jdbc.configuration.TableManipulationConfiguration; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.clustering.infinispan.subsystem.TableResourceDefinition.ColumnAttribute; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; /** * @author Paul Ferraro */ public class TableServiceConfigurator extends ComponentServiceConfigurator<TableManipulationConfiguration> { private final Attribute prefixAttribute; private final Map<ColumnAttribute, Map.Entry<String, String>> columns = new EnumMap<>(ColumnAttribute.class); private volatile int fetchSize; private volatile String prefix; private volatile boolean createOnStart; private volatile boolean dropOnStop; public TableServiceConfigurator(Attribute prefixAttribute, PathAddress address) { super(CacheComponent.STRING_TABLE, address.getParent()); this.prefixAttribute = prefixAttribute; } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { for (ColumnAttribute column : EnumSet.allOf(ColumnAttribute.class)) { ModelNode columnModel = column.resolveModelAttribute(context, model); String name = column.getColumnName().resolveModelAttribute(context, columnModel).asString(); String type = column.getColumnType().resolveModelAttribute(context, columnModel).asString(); this.columns.put(column, new AbstractMap.SimpleImmutableEntry<>(name, type)); } this.fetchSize = FETCH_SIZE.resolveModelAttribute(context, model).asInt(); this.prefix = this.prefixAttribute.resolveModelAttribute(context, model).asString(); this.createOnStart = CREATE_ON_START.resolveModelAttribute(context, model).asBoolean(); this.dropOnStop = DROP_ON_STOP.resolveModelAttribute(context, model).asBoolean(); return this; } @Override public TableManipulationConfiguration get() { return new ConfigurationBuilder().persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class).table() .createOnStart(this.createOnStart) .dropOnExit(this.dropOnStop) .idColumnName(this.columns.get(ID).getKey()) .idColumnType(this.columns.get(ID).getValue()) .dataColumnName(this.columns.get(DATA).getKey()) .dataColumnType(this.columns.get(DATA).getValue()) .segmentColumnName(this.columns.get(SEGMENT).getKey()) .segmentColumnType(this.columns.get(SEGMENT).getValue()) .timestampColumnName(this.columns.get(TIMESTAMP).getKey()) .timestampColumnType(this.columns.get(TIMESTAMP).getValue()) .fetchSize(this.fetchSize) .tableNamePrefix(this.prefix) .create(); } }
5,181
50.306931
120
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ClusteredCacheServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.ClusteredCacheResourceDefinition.Attribute.REMOTE_TIMEOUT; import java.util.concurrent.TimeUnit; import org.infinispan.configuration.cache.CacheMode; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; /** * Builds the configuration of a clustered cache. * @author Paul Ferraro */ public class ClusteredCacheServiceConfigurator extends CacheConfigurationServiceConfigurator { private volatile long remoteTimeout; ClusteredCacheServiceConfigurator(PathAddress address, CacheMode mode) { super(address, mode.toSync()); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.remoteTimeout = REMOTE_TIMEOUT.resolveModelAttribute(context, model).asLong(); return super.configure(context, model); } @Override public void accept(ConfigurationBuilder builder) { builder.clustering().remoteTimeout(this.remoteTimeout, TimeUnit.MILLISECONDS); super.accept(builder); } }
2,413
38.57377
117
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/JGroupsTransportServiceHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.server.service.ProvidedIdentityGroupServiceConfigurator; /** * @author Paul Ferraro */ public class JGroupsTransportServiceHandler implements ResourceServiceHandler { @Override public void installServices(OperationContext context, ModelNode model) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); PathAddress containerAddress = address.getParent(); String name = containerAddress.getLastElement().getValue(); ServiceTarget target = context.getServiceTarget(); JGroupsTransportServiceConfigurator transportBuilder = new JGroupsTransportServiceConfigurator(address).configure(context, model); transportBuilder.build(target).install(); String channel = transportBuilder.getChannel(); new ProvidedIdentityGroupServiceConfigurator(name, channel).configure(context).build(target).install(); } @Override public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); PathAddress containerAddress = address.getParent(); String name = containerAddress.getLastElement().getValue(); new ProvidedIdentityGroupServiceConfigurator(name, null).remove(context); context.removeService(new JGroupsTransportServiceConfigurator(address).getServiceName()); } }
2,807
42.875
138
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/PartitionHandlingResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.EnumSet; import java.util.function.UnaryOperator; import org.infinispan.conflict.MergePolicy; import org.infinispan.partitionhandling.PartitionHandling; import org.jboss.as.clustering.controller.AttributeTranslation; import org.jboss.as.clustering.controller.AttributeValueTranslator; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Resource definition of the partition handling component of a cache. * @author Paul Ferraro */ public class PartitionHandlingResourceDefinition extends ComponentResourceDefinition { static final PathElement PATH = pathElement("partition-handling"); enum Attribute implements org.jboss.as.clustering.controller.Attribute { WHEN_SPLIT("when-split", PartitionHandling.ALLOW_READ_WRITES, EnumValidator.create(PartitionHandling.class)), MERGE_POLICY("merge-policy", MergePolicy.NONE, EnumValidator.create(MergePolicy.class, EnumSet.complementOf(EnumSet.of(MergePolicy.CUSTOM)))), ; private final AttributeDefinition definition; <E extends Enum<E>> Attribute(String name, E defaultValue, EnumValidator<E> validator) { this(name, ModelType.STRING, new ModelNode(defaultValue.name()), builder -> builder.setValidator(validator)); } Attribute(String name, ModelType type, ModelNode defaultValue, UnaryOperator<SimpleAttributeDefinitionBuilder> configurator) { this.definition = configurator.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setDefaultValue(defaultValue) .setRequired(false) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) ).build() ; } @Override public AttributeDefinition getDefinition() { return this.definition; } } enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute { ENABLED("enabled", ModelType.BOOLEAN, ModelNode.FALSE, InfinispanSubsystemModel.VERSION_16_0_0), ; private final AttributeDefinition definition; DeprecatedAttribute(String name, ModelType type, ModelNode defaultValue, InfinispanSubsystemModel deprecation) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setDeprecated(deprecation.getVersion()) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } PartitionHandlingResourceDefinition() { super(PATH); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()) .addAttributes(Attribute.class) .addAttributeTranslation(DeprecatedAttribute.ENABLED, new AttributeTranslation() { @Override public org.jboss.as.clustering.controller.Attribute getTargetAttribute() { return Attribute.WHEN_SPLIT; } @Override public AttributeValueTranslator getReadTranslator() { return (context, value) -> value.isDefined() ? (value.equals(Attribute.WHEN_SPLIT.getDefinition().getDefaultValue()) ? ModelNode.FALSE : ModelNode.TRUE) : value; } @Override public AttributeValueTranslator getWriteTranslator() { return (context, value) -> value.isDefined() ? new ModelNode((value.asBoolean() ? PartitionHandling.DENY_READ_WRITES : PartitionHandling.ALLOW_READ_WRITES).name()) : value; } }) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(PartitionHandlingServiceConfigurator::new); new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
6,136
45.142857
196
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanSubsystemModel.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.SubsystemModel; /** * Enumerates the supported model versions. * @author Paul Ferraro */ public enum InfinispanSubsystemModel implements SubsystemModel { /* Unsupported model versions - for reference only VERSION_1_6_0(1, 6, 0), // EAP 6.4 VERSION_2_0_0(2, 0, 0), // WildFly 8 VERSION_3_0_0(3, 0, 0), // WildFly 9 VERSION_4_0_0(4, 0, 0), // WildFly 10, EAP 7.0 VERSION_4_1_0(4, 1, 0), // WildFly 10.1 VERSION_5_0_0(5, 0, 0), // WildFly 11, EAP 7.1 VERSION_6_0_0(6, 0, 0), // WildFly 12 */ VERSION_7_0_0(7, 0, 0), // WildFly 13 /* VERSION_8_0_0(8, 0, 0), // WildFly 14-15, EAP 7.2 VERSION_9_0_0(9, 0, 0), // WildFly 16 VERSION_10_0_0(10, 0, 0), // WildFly 17 VERSION_11_0_0(11, 0, 0), // WildFly 18-19, EAP 7.3 VERSION_11_1_0(11, 1, 0), // EAP 7.3.4 VERSION_12_0_0(12, 0, 0), // WildFly 20 VERSION_13_0_0(13, 0, 0), // WildFly 21-22 */ VERSION_14_0_0(14, 0, 0), // WildFly 23, EAP 7.4 VERSION_15_0_0(15, 0, 0), // WildFly 24-26 VERSION_16_0_0(16, 0, 0), // WildFly 27 VERSION_17_0_0(17, 0, 0), // WildFly 28-present ; static final InfinispanSubsystemModel CURRENT = VERSION_17_0_0; private final ModelVersion version; InfinispanSubsystemModel(int major, int minor, int micro) { this.version = ModelVersion.create(major, minor, micro); } @Override public ModelVersion getVersion() { return this.version; } }
2,592
36.57971
70
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TransactionResourceCapabilityReference.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.Set; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.clustering.controller.Capability; import org.jboss.as.clustering.controller.ResourceCapabilityReference; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.registry.Resource; import org.wildfly.clustering.service.Requirement; /** * ResourceCapabilityReference that only records tx requirements if the TransactionMode indicates they are necessary. * @author Brian Stansberry */ public class TransactionResourceCapabilityReference extends ResourceCapabilityReference { private final Attribute transactionModeAttriute; private final Set<TransactionMode> excludedModes; public TransactionResourceCapabilityReference(Capability capability, Requirement requirement, Attribute transactionModeAttribute, Set<TransactionMode> excludedModes) { super(capability, requirement); this.transactionModeAttriute = transactionModeAttribute; this.excludedModes = excludedModes; } @Override public void addCapabilityRequirements(OperationContext context, Resource resource, String attributeName, String... values) { if (this.isTransactionalSupportRequired(context, resource)) { super.addCapabilityRequirements(context, resource, attributeName, values); } } @Override public void removeCapabilityRequirements(OperationContext context, Resource resource, String attributeName, String... values) { if (this.isTransactionalSupportRequired(context, resource)) { super.removeCapabilityRequirements(context, resource, attributeName, values); } } private boolean isTransactionalSupportRequired(OperationContext context, Resource resource) { try { TransactionMode mode = TransactionMode.valueOf(this.transactionModeAttriute.resolveModelAttribute(context, resource.getModel()).asString()); return !this.excludedModes.contains(mode); } catch (OperationFailedException | RuntimeException e) { // OFE would be due to an expression that can't be resolved right now (OperationContext.Stage.MODEL). // Very unlikely an expression is used and that it uses a resolution source not available in MODEL. // In any case we add the requirement. Downside is they are forced to configure the tx subsystem when // they otherwise wouldn't, but that "otherwise wouldn't" also is a less likely scenario. return true; } } }
3,679
47.421053
171
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StoreWriteBehindServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.StoreWriteBehindResourceDefinition.Attribute.MODIFICATION_QUEUE_SIZE; import org.infinispan.configuration.cache.AsyncStoreConfiguration; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; /** * @author Paul Ferraro */ public class StoreWriteBehindServiceConfigurator extends ComponentServiceConfigurator<AsyncStoreConfiguration> { private volatile int queueSize; StoreWriteBehindServiceConfigurator(PathAddress address) { super(CacheComponent.STORE_WRITE, address.getParent()); } @Override public AsyncStoreConfiguration get() { return new ConfigurationBuilder().persistence().addSoftIndexFileStore().async() .enable() .modificationQueueSize(this.queueSize) .create(); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.queueSize = MODIFICATION_QUEUE_SIZE.resolveModelAttribute(context, model).asInt(); return this; } }
2,416
39.283333
128
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LocalCacheResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * @author Paul Ferraro */ public class LocalCacheResourceTransformer extends CacheResourceTransformer { LocalCacheResourceTransformer(ResourceTransformationDescriptionBuilder parent) { super(parent.addChildResource(LocalCacheResourceDefinition.WILDCARD_PATH)); } }
1,463
39.666667
94
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CustomStoreServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.CustomStoreResourceDefinition.Attribute.CLASS; import java.util.List; import java.util.stream.Collectors; import org.infinispan.commons.util.AggregatedClassLoader; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.PersistenceConfiguration; import org.infinispan.configuration.cache.StoreConfiguration; import org.infinispan.configuration.cache.StoreConfigurationBuilder; import org.jboss.as.clustering.infinispan.logging.InfinispanLogger; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.jboss.modules.Module; import org.jboss.msc.service.ServiceBuilder; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; /** * @author Paul Ferraro */ public class CustomStoreServiceConfigurator extends StoreServiceConfigurator<CustomStoreConfiguration, CustomStoreConfigurationBuilder> { private final SupplierDependency<List<Module>> modules; private volatile String className; CustomStoreServiceConfigurator(PathAddress address) { super(address, CustomStoreConfigurationBuilder.class); this.modules = new ServiceSupplierDependency<>(CacheComponent.MODULES.getServiceName(address.getParent())); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.className = CLASS.resolveModelAttribute(context, model).asString(); return super.configure(context, model); } @Override public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { return super.register(this.modules.register(builder)); } @Override public PersistenceConfiguration get() { PersistenceConfiguration persistence = super.get(); StoreConfiguration store = persistence.stores().get(0); List<Module> modules = this.modules.get(); ClassLoader loader = modules.size() > 1 ? new AggregatedClassLoader(modules.stream().map(Module::getClassLoader).collect(Collectors.toList())) : modules.get(0).getClassLoader(); try { @SuppressWarnings("unchecked") Class<StoreConfigurationBuilder<?, ?>> storeClass = (Class<StoreConfigurationBuilder<?, ?>>) loader.loadClass(this.className).asSubclass(StoreConfigurationBuilder.class); return new ConfigurationBuilder().persistence().passivation(persistence.passivation()).addStore(storeClass) .async().read(store.async()) .fetchPersistentState(store.fetchPersistentState()) .preload(store.preload()) .purgeOnStartup(store.purgeOnStartup()) .shared(store.shared()) .withProperties(store.properties()) .persistence().create(); } catch (ClassNotFoundException | ClassCastException e) { throw InfinispanLogger.ROOT_LOGGER.invalidCacheStore(e, this.className); } } @Override public void accept(CustomStoreConfigurationBuilder builder) { // Nothing to configure } }
4,456
44.479592
185
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheMetricExecutor.java
/* * JBoss, Home of Professional Open Source * Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors * as indicated by the @author tags. All rights reserved. * See the copyright.txt in the distribution for a * full listing of individual contributors. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU Lesser General Public License, v. 2.1. * This program is distributed in the hope that it will be useful, but WITHOUT A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License, * v.2.1 along with this distribution; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.Function; import org.infinispan.Cache; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.Metric; import org.jboss.as.clustering.controller.MetricExecutor; import org.jboss.as.clustering.controller.MetricFunction; import org.jboss.as.clustering.controller.FunctionExecutor; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceName; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; /** * @author Paul Ferraro */ public abstract class CacheMetricExecutor<C> implements MetricExecutor<C>, Function<Cache<?, ?>, C> { private final FunctionExecutorRegistry<Cache<?, ?>> executors; private final BinaryCapabilityNameResolver resolver; protected CacheMetricExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors) { this(executors, BinaryCapabilityNameResolver.PARENT_CHILD); } protected CacheMetricExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors, BinaryCapabilityNameResolver resolver) { this.executors = executors; this.resolver = resolver; } @Override public ModelNode execute(OperationContext context, Metric<C> metric) throws OperationFailedException { ServiceName name = InfinispanCacheRequirement.CACHE.getServiceName(context, this.resolver); FunctionExecutor<Cache<?, ?>> executor = this.executors.get(name); return (executor != null) ? executor.execute(new MetricFunction<>(this, metric)) : null; } }
2,733
43.819672
123
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/BackupOperationExecutor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.AbstractMap; import java.util.Map; import java.util.function.Function; import org.infinispan.Cache; import org.infinispan.xsite.XSiteAdminOperations; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.Operation; import org.jboss.as.clustering.controller.OperationExecutor; import org.jboss.as.clustering.controller.OperationFunction; import org.jboss.as.clustering.controller.FunctionExecutor; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceName; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; /** * Operation handler for backup site operations. * @author Paul Ferraro */ public class BackupOperationExecutor implements OperationExecutor<Map.Entry<String, XSiteAdminOperations>> { private final FunctionExecutorRegistry<Cache<?, ?>> executors; public BackupOperationExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors) { this.executors = executors; } @Override public ModelNode execute(OperationContext context, ModelNode operation, Operation<Map.Entry<String, XSiteAdminOperations>> executable) throws OperationFailedException { ServiceName name = InfinispanCacheRequirement.CACHE.getServiceName(context, BinaryCapabilityNameResolver.GRANDPARENT_PARENT); Function<Cache<?, ?>, Map.Entry<String, XSiteAdminOperations>> mapper = new Function<>() { @SuppressWarnings("deprecation") @Override public Map.Entry<String, XSiteAdminOperations> apply(Cache<?, ?> cache) { String site = context.getCurrentAddressValue(); return new AbstractMap.SimpleImmutableEntry<>(site, cache.getAdvancedCache().getComponentRegistry().getLocalComponent(XSiteAdminOperations.class)); } }; FunctionExecutor<Cache<?, ?>> executor = this.executors.get(name); return (executor != null) ? executor.execute(new OperationFunction<>(context, operation, mapper, executable)) : null; } }
3,302
46.869565
172
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheInterceptorOperationExecutor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.Cache; import org.infinispan.interceptors.AsyncInterceptor; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; /** * Executor for metrics based on a cache interceptor. * @author Paul Ferraro */ public class CacheInterceptorOperationExecutor<I extends AsyncInterceptor> extends CacheOperationExecutor<I> { private final Class<I> interceptorClass; public CacheInterceptorOperationExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors, Class<I> interceptorClass) { super(executors); this.interceptorClass = interceptorClass; } @SuppressWarnings("deprecation") @Override public I apply(Cache<?, ?> cache) { return cache.getAdvancedCache().getAsyncInterceptorChain().findInterceptorExtending(this.interceptorClass); } }
1,895
38.5
122
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerMetric.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.remoting.transport.Address; import org.jboss.as.clustering.controller.Metric; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Enumeration of management metrics for a cache container. * @author Paul Ferraro */ public enum CacheContainerMetric implements Metric<EmbeddedCacheManager> { CACHE_MANAGER_STATUS("cache-manager-status", ModelType.STRING) { @Override public ModelNode execute(EmbeddedCacheManager manager) { return new ModelNode(manager.getStatus().toString()); } }, CLUSTER_NAME("cluster-name", ModelType.STRING) { @Override public ModelNode execute(EmbeddedCacheManager manager) { String clusterName = manager.getClusterName(); return (clusterName != null) ? new ModelNode(clusterName) : null; } }, COORDINATOR_ADDRESS("coordinator-address", ModelType.STRING) { @Override public ModelNode execute(EmbeddedCacheManager manager) { Address address = manager.getCoordinator(); return (address != null) ? new ModelNode(address.toString()) : null; } }, IS_COORDINATOR("is-coordinator", ModelType.BOOLEAN) { @Override public ModelNode execute(EmbeddedCacheManager manager) { return new ModelNode(manager.isCoordinator()); } }, LOCAL_ADDRESS("local-address", ModelType.STRING) { @Override public ModelNode execute(EmbeddedCacheManager manager) { Address address = manager.getAddress(); return (address != null) ? new ModelNode(address.toString()) : null; } }, ; private final AttributeDefinition definition; CacheContainerMetric(String name, ModelType type) { this.definition = new SimpleAttributeDefinitionBuilder(name, type, true) .setFlags(AttributeAccess.Flag.GAUGE_METRIC) .setStorageRuntime() .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } }
3,398
38.523256
80
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ReplicatedCacheResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.UnaryOperator; import org.infinispan.Cache; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.controller.PathElement; /** * Resource description for the addressable resource /subsystem=infinispan/cache-container=X/replicated-cache=* * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class ReplicatedCacheResourceDefinition extends SharedStateCacheResourceDefinition { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static PathElement pathElement(String name) { return PathElement.pathElement("replicated-cache", name); } ReplicatedCacheResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(WILDCARD_PATH, UnaryOperator.identity(), new ClusteredCacheServiceHandler(ReplicatedCacheServiceConfigurator::new), executors); } }
1,980
41.148936
141
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StoreWriteThroughResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.controller.PathElement; /** * @author Paul Ferraro */ public class StoreWriteThroughResourceDefinition extends StoreWriteResourceDefinition { static final PathElement PATH = pathElement("through"); StoreWriteThroughResourceDefinition() { super(PATH); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()); ResourceServiceHandler handler = new SimpleResourceServiceHandler(StoreWriteThroughServiceConfigurator::new); new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
2,251
40.703704
117
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TransactionServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.controller.CommonRequirement.LOCAL_TRANSACTION_PROVIDER; import static org.jboss.as.clustering.infinispan.subsystem.TransactionResourceDefinition.Attribute.COMPLETE_TIMEOUT; import static org.jboss.as.clustering.infinispan.subsystem.TransactionResourceDefinition.Attribute.LOCKING; import static org.jboss.as.clustering.infinispan.subsystem.TransactionResourceDefinition.Attribute.MODE; import static org.jboss.as.clustering.infinispan.subsystem.TransactionResourceDefinition.Attribute.STOP_TIMEOUT; import static org.jboss.as.clustering.infinispan.subsystem.TransactionResourceDefinition.TransactionRequirement.TRANSACTION_SYNCHRONIZATION_REGISTRY; import java.util.EnumSet; import jakarta.transaction.TransactionSynchronizationRegistry; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.TransactionConfiguration; import org.infinispan.configuration.cache.TransactionConfigurationBuilder; import org.infinispan.transaction.LockingMode; import org.infinispan.transaction.tm.EmbeddedTransactionManager; import org.jboss.as.clustering.infinispan.tx.TransactionManagerProvider; import org.jboss.as.clustering.infinispan.tx.TransactionSynchronizationRegistryProvider; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceBuilder; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.Dependency; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceDependency; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.transaction.client.ContextTransactionManager; /** * @author Paul Ferraro */ public class TransactionServiceConfigurator extends ComponentServiceConfigurator<TransactionConfiguration> { private volatile LockingMode locking; private volatile long stopTimeout; private volatile long transactionTimeout; private volatile TransactionMode mode; private volatile Dependency transactionDependency; private volatile SupplierDependency<TransactionSynchronizationRegistry> tsrDependency; public TransactionServiceConfigurator(PathAddress address) { super(CacheComponent.TRANSACTION, address); } @Override public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { new CompositeDependency(this.transactionDependency, this.tsrDependency).register(builder); return super.register(builder); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.mode = TransactionMode.valueOf(MODE.resolveModelAttribute(context, model).asString()); this.locking = LockingMode.valueOf(LOCKING.resolveModelAttribute(context, model).asString()); this.stopTimeout = STOP_TIMEOUT.resolveModelAttribute(context, model).asLong(); this.transactionTimeout = COMPLETE_TIMEOUT.resolveModelAttribute(context, model).asLong(); this.transactionDependency = !EnumSet.of(TransactionMode.NONE, TransactionMode.BATCH).contains(this.mode) ? new ServiceDependency(context.getCapabilityServiceName(LOCAL_TRANSACTION_PROVIDER.getName(), null)) : null; this.tsrDependency = this.mode == TransactionMode.NON_XA ? new ServiceSupplierDependency<>(context.getCapabilityServiceName(TRANSACTION_SYNCHRONIZATION_REGISTRY.getName(), null)) : null; return this; } @Override public TransactionConfiguration get() { TransactionConfigurationBuilder builder = new ConfigurationBuilder().transaction() .lockingMode(this.locking) .cacheStopTimeout(this.stopTimeout) .completedTxTimeout(this.transactionTimeout) .transactionMode((this.mode == TransactionMode.NONE) ? org.infinispan.transaction.TransactionMode.NON_TRANSACTIONAL : org.infinispan.transaction.TransactionMode.TRANSACTIONAL) .useSynchronization(this.mode == TransactionMode.NON_XA) .recovery().enabled(this.mode == TransactionMode.FULL_XA).transaction() ; switch (this.mode) { case NONE: { break; } case BATCH: { builder.transactionManagerLookup(new TransactionManagerProvider(EmbeddedTransactionManager.getInstance())); break; } case NON_XA: { builder.transactionSynchronizationRegistryLookup(new TransactionSynchronizationRegistryProvider(this.tsrDependency.get())); // fall through } default: { builder.transactionManagerLookup(new TransactionManagerProvider(ContextTransactionManager.getInstance())); } } return builder.create(); } }
6,142
50.621849
223
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/GlobalComponentServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.ResourceServiceNameFactory; import org.jboss.as.controller.PathAddress; import org.jboss.msc.service.ServiceController; /** * Configures a service supplying a global component. * @author Paul Ferraro */ public abstract class GlobalComponentServiceConfigurator<C> extends ComponentServiceConfigurator<C> { GlobalComponentServiceConfigurator(ResourceServiceNameFactory factory, PathAddress address) { this(factory, address, ServiceController.Mode.PASSIVE); } GlobalComponentServiceConfigurator(ResourceServiceNameFactory factory, PathAddress address, ServiceController.Mode initialMode) { super(factory, address, initialMode); } }
1,788
40.604651
133
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TransactionMetric.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.interceptors.impl.TxInterceptor; import org.jboss.as.clustering.controller.Metric; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Enumeration of transaction management metrics for a cache. * * @author Paul Ferraro */ @SuppressWarnings("rawtypes") public enum TransactionMetric implements Metric<TxInterceptor> { COMMITS("commits", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) { @Override public ModelNode execute(TxInterceptor interceptor) { return new ModelNode(interceptor.getCommits()); } }, PREPARES("prepares", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) { @Override public ModelNode execute(TxInterceptor interceptor) { return new ModelNode(interceptor.getPrepares()); } }, ROLLBACKS("rollbacks", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) { @Override public ModelNode execute(TxInterceptor interceptor) { return new ModelNode(interceptor.getRollbacks()); } }, ; private final AttributeDefinition definition; TransactionMetric(String name, ModelType type, AttributeAccess.Flag metricType) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setFlags(metricType) .setStorageRuntime() .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } }
2,757
37.305556
85
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/JGroupsTransportResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.concurrent.TimeUnit; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityReference; import org.jboss.as.clustering.controller.UnaryCapabilityNameResolver; import org.jboss.as.clustering.controller.ResourceCapabilityReference; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.UnaryRequirementCapability; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jgroups.JChannel; import org.wildfly.clustering.jgroups.spi.JGroupsDefaultRequirement; import org.wildfly.clustering.jgroups.spi.JGroupsRequirement; import org.wildfly.clustering.service.UnaryRequirement; /** * Resource description for the addressable resource and its alias * * /subsystem=infinispan/cache-container=X/transport=jgroups * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class JGroupsTransportResourceDefinition extends TransportResourceDefinition { static final PathElement PATH = pathElement("jgroups"); enum Requirement implements UnaryRequirement { CHANNEL("org.wildfly.clustering.infinispan.transport.channel", JChannel.class), ; private final String name; private final Class<?> type; Requirement(String name, Class<?> type) { this.name = name; this.type = type; } @Override public String getName() { return this.name; } @Override public Class<?> getType() { return this.type; } } enum Capability implements org.jboss.as.clustering.controller.Capability { TRANSPORT_CHANNEL(Requirement.CHANNEL), ; private final RuntimeCapability<Void> definition; Capability(UnaryRequirement requirement) { this.definition = new UnaryRequirementCapability(requirement, UnaryCapabilityNameResolver.PARENT).getDefinition(); } @Override public RuntimeCapability<Void> getDefinition() { return this.definition; } } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { CHANNEL("channel", ModelType.STRING, null) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setAllowExpression(false) .setCapabilityReference(new CapabilityReference(Capability.TRANSPORT_CHANNEL, JGroupsRequirement.CHANNEL_FACTORY)) ; } }, LOCK_TIMEOUT("lock-timeout", ModelType.LONG, new ModelNode(TimeUnit.MINUTES.toMillis(4))) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setMeasurementUnit(MeasurementUnit.MILLISECONDS); } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder; } } static class ResourceDescriptorConfigurator implements UnaryOperator<ResourceDescriptor> { @Override public ResourceDescriptor apply(ResourceDescriptor descriptor) { return descriptor.addAttributes(Attribute.class) .addCapabilities(Capability.class) .addResourceCapabilityReference(new ResourceCapabilityReference(Capability.TRANSPORT_CHANNEL, JGroupsDefaultRequirement.CHANNEL_FACTORY)) ; } } JGroupsTransportResourceDefinition() { super(PATH, new ResourceDescriptorConfigurator(), new JGroupsTransportServiceHandler()); } }
5,803
38.753425
157
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/PartitionHandlingMetricExecutor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.AdvancedCache; import org.infinispan.Cache; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; /** * Executor for partition handling metrics. * @author Paul Ferraro */ public class PartitionHandlingMetricExecutor extends CacheMetricExecutor<AdvancedCache<?, ?>> { public PartitionHandlingMetricExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(executors, BinaryCapabilityNameResolver.GRANDPARENT_PARENT); } @Override public AdvancedCache<?, ?> apply(Cache<?, ?> cache) { return cache.getAdvancedCache(); } }
1,756
38.044444
95
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ReplicatedCacheServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.configuration.cache.CacheMode; import org.jboss.as.controller.PathAddress; /** * @author Paul Ferraro */ public class ReplicatedCacheServiceConfigurator extends SharedStateCacheServiceConfigurator { ReplicatedCacheServiceConfigurator(PathAddress address) { super(address, CacheMode.REPL_SYNC); } }
1,419
37.378378
93
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TransactionMode.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; /** * @author Paul Ferraro */ public enum TransactionMode { NONE, BATCH, NON_XA, NON_DURABLE_XA, FULL_XA, ; }
1,215
32.777778
70
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanBindingFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.naming.JndiNameFactory; import org.jboss.as.naming.deployment.ContextNames; /** * Factory for creating JNDI bindings. * @author Paul Ferraro */ public final class InfinispanBindingFactory { public static ContextNames.BindInfo createCacheContainerBinding(String containerName) { return ContextNames.bindInfoFor(JndiNameFactory.createJndiName(JndiNameFactory.DEFAULT_JNDI_NAMESPACE, InfinispanExtension.SUBSYSTEM_NAME, "container", containerName).getAbsoluteName()); } public static ContextNames.BindInfo createCacheBinding(String containerName, String cacheName) { return ContextNames.bindInfoFor(JndiNameFactory.createJndiName(JndiNameFactory.DEFAULT_JNDI_NAMESPACE, InfinispanExtension.SUBSYSTEM_NAME, "cache", containerName, cacheName).getAbsoluteName()); } public static ContextNames.BindInfo createCacheConfigurationBinding(String containerName, String cacheName) { return ContextNames.bindInfoFor(JndiNameFactory.createJndiName(JndiNameFactory.DEFAULT_JNDI_NAMESPACE, InfinispanExtension.SUBSYSTEM_NAME, "configuration", containerName, cacheName).getAbsoluteName()); } public static ContextNames.BindInfo createRemoteCacheContainerBinding(String remoteContainerName) { return ContextNames.bindInfoFor(JndiNameFactory.createJndiName(JndiNameFactory.DEFAULT_JNDI_NAMESPACE, InfinispanExtension.SUBSYSTEM_NAME, "remote-container", remoteContainerName).getAbsoluteName()); } private InfinispanBindingFactory() { // Hide } }
2,623
48.509434
209
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ThreadPoolResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.concurrent.TimeUnit; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.ResourceDefinitionProvider; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceConfigurator; import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleAttribute; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.clustering.controller.validation.IntRangeValidatorBuilder; import org.jboss.as.clustering.controller.validation.LongRangeValidatorBuilder; import org.jboss.as.clustering.controller.validation.ParameterValidatorBuilder; import org.jboss.as.clustering.infinispan.subsystem.remote.ClientThreadPoolServiceConfigurator; import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.ResourceDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.descriptions.ResourceDescriptionResolver; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jboss.msc.service.ServiceName; /** * Thread pool resource definitions for Infinispan subsystem. See {@link org.infinispan.factories.KnownComponentNames} * and {@link org.infinispan.commons.executors.BlockingThreadPoolExecutorFactory#create} for the hardcoded * Infinispan default values. * * @author Radoslav Husar */ public enum ThreadPoolResourceDefinition implements ResourceDefinitionProvider, ThreadPoolDefinition, ResourceServiceConfiguratorFactory, UnaryOperator<SimpleResourceDefinition.Parameters> { BLOCKING("blocking", 1, 150, 5000, TimeUnit.MINUTES.toMillis(1), false, CacheContainerResourceDefinition.Capability.CONFIGURATION), LISTENER("listener", 1, 1, 1000, TimeUnit.MINUTES.toMillis(1), false, CacheContainerResourceDefinition.Capability.CONFIGURATION), NON_BLOCKING("non-blocking", 2, 2, 1000, TimeUnit.MINUTES.toMillis(1), true, CacheContainerResourceDefinition.Capability.CONFIGURATION), // remote-cache-container CLIENT("async", 99, 99, 0, 0L, true, RemoteCacheContainerResourceDefinition.Capability.CONFIGURATION) { @Override public ResourceServiceConfigurator createServiceConfigurator(PathAddress address) { return new ClientThreadPoolServiceConfigurator(this, address); } }, ; static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); private static PathElement pathElement(String name) { return PathElement.pathElement("thread-pool", name); } private final PathElement path; private final Attribute minThreads; private final Attribute maxThreads; private final Attribute queueLength; private final Attribute keepAliveTime; private final boolean nonBlocking; private final CapabilityProvider baseCapability; ThreadPoolResourceDefinition(String name, int defaultMinThreads, int defaultMaxThreads, int defaultQueueLength, long defaultKeepaliveTime, boolean nonBlocking, CapabilityProvider baseCapability) { this.path = pathElement(name); this.minThreads = new SimpleAttribute(createBuilder("min-threads", ModelType.INT, new ModelNode(defaultMinThreads), new IntRangeValidatorBuilder().min(0)).build()); this.maxThreads = new SimpleAttribute(createBuilder("max-threads", ModelType.INT, new ModelNode(defaultMaxThreads), new IntRangeValidatorBuilder().min(0)).build()); this.queueLength = new SimpleAttribute(createBuilder("queue-length", ModelType.INT, new ModelNode(defaultQueueLength), new IntRangeValidatorBuilder().min(0)).build()); this.keepAliveTime = new SimpleAttribute(createBuilder("keepalive-time", ModelType.LONG, new ModelNode(defaultKeepaliveTime), new LongRangeValidatorBuilder().min(0)).build()); this.nonBlocking = nonBlocking; this.baseCapability = baseCapability; } private static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue, ParameterValidatorBuilder validatorBuilder) { SimpleAttributeDefinitionBuilder builder = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null) ; return builder.setValidator(validatorBuilder.configure(builder).build()); } @Override public SimpleResourceDefinition.Parameters apply(SimpleResourceDefinition.Parameters parameters) { return parameters; } @Override public void register(ManagementResourceRegistration parent) { ResourceDescriptionResolver resolver = InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(this.path, pathElement(PathElement.WILDCARD_VALUE)); ResourceDefinition definition = new SimpleResourceDefinition(this.apply(new SimpleResourceDefinition.Parameters(this.path, resolver))); ManagementResourceRegistration registration = parent.registerSubModel(definition); ResourceDescriptor descriptor = new ResourceDescriptor(resolver) .addAttributes(this.minThreads, this.maxThreads, this.queueLength, this.keepAliveTime) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(this); new SimpleResourceRegistrar(descriptor, handler).register(registration); } @Override public ResourceServiceConfigurator createServiceConfigurator(PathAddress address) { return new ThreadPoolServiceConfigurator(this, address); } @Override public ServiceName getServiceName(PathAddress containerAddress) { return this.baseCapability.getServiceName(containerAddress).append(this.path.getKeyValuePair()); } @Override public Attribute getMinThreads() { return this.minThreads; } @Override public Attribute getMaxThreads() { return this.maxThreads; } @Override public Attribute getQueueLength() { return this.queueLength; } @Override public Attribute getKeepAliveTime() { return this.keepAliveTime; } @Override public boolean isNonBlocking() { return this.nonBlocking; } @Override public PathElement getPathElement() { return this.path; } }
8,259
48.166667
200
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/DistributedCacheResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * @author Paul Ferraro */ public class DistributedCacheResourceTransformer extends SegmentedCacheResourceTransformer { DistributedCacheResourceTransformer(ResourceTransformationDescriptionBuilder parent) { super(parent.addChildResource(DistributedCacheResourceDefinition.WILDCARD_PATH)); } }
1,490
40.416667
94
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.Consumer; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * Transformers for cache resources. * @author Paul Ferraro */ public class CacheResourceTransformer implements Consumer<ModelVersion> { final ResourceTransformationDescriptionBuilder builder; CacheResourceTransformer(ResourceTransformationDescriptionBuilder builder) { this.builder = builder; } @SuppressWarnings("deprecation") @Override public void accept(ModelVersion version) { new TransactionResourceTransformer(this.builder).accept(version); new CustomStoreResourceTransformer(this.builder).accept(version); new FileStoreResourceTransformer(this.builder).accept(version); new HotRodStoreResourceTransformer(this.builder).accept(version); new JDBCStoreResourceTransformer(this.builder).accept(version); new RemoteStoreResourceTransformer(this.builder).accept(version); } }
2,128
39.169811
94
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ClusteredCacheResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.concurrent.TimeUnit; import java.util.function.UnaryOperator; import org.infinispan.Cache; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.ResourceCapabilityReference; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.UnaryCapabilityNameResolver; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.clustering.server.service.DistributedCacheServiceConfiguratorProvider; /** * Base class for cache resources which require common cache attributes and clustered cache attributes. * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class ClusteredCacheResourceDefinition extends CacheResourceDefinition<DistributedCacheServiceConfiguratorProvider> { enum Capability implements org.jboss.as.clustering.controller.Capability { TRANSPORT("org.wildfly.clustering.infinispan.cache-container.cache.transport"), ; private final RuntimeCapability<Void> definition; Capability(String name) { this.definition = RuntimeCapability.Builder.of(name, true).setDynamicNameMapper(BinaryCapabilityNameResolver.PARENT_CHILD).build(); } @Override public RuntimeCapability<?> getDefinition() { return this.definition; } } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { REMOTE_TIMEOUT("remote-timeout", ModelType.LONG, new ModelNode(TimeUnit.SECONDS.toMillis(10))) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setMeasurementUnit(MeasurementUnit.MILLISECONDS); } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } private static class ResourceDescriptorConfigurator implements UnaryOperator<ResourceDescriptor> { private final UnaryOperator<ResourceDescriptor> configurator; ResourceDescriptorConfigurator(UnaryOperator<ResourceDescriptor> configurator) { this.configurator = configurator; } @Override public ResourceDescriptor apply(ResourceDescriptor descriptor) { return this.configurator.apply(descriptor) .addAttributes(Attribute.class) .addCapabilities(Capability.class) .addResourceCapabilityReference(new ResourceCapabilityReference(Capability.TRANSPORT, JGroupsTransportResourceDefinition.Requirement.CHANNEL, UnaryCapabilityNameResolver.PARENT)) ; } } ClusteredCacheResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ClusteredCacheServiceHandler handler, FunctionExecutorRegistry<Cache<?, ?>> executors) { super(path, new ResourceDescriptorConfigurator(configurator), handler, executors); } }
5,033
43.946429
198
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheConfigurationServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Attribute.STATISTICS_ENABLED; import static org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Capability.CONFIGURATION; import java.util.function.Consumer; import org.infinispan.commons.CacheException; import org.infinispan.configuration.cache.CacheMode; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.ExpirationConfiguration; import org.infinispan.configuration.cache.LockingConfiguration; import org.infinispan.configuration.cache.MemoryConfiguration; import org.infinispan.configuration.cache.PersistenceConfiguration; import org.infinispan.configuration.cache.TransactionConfiguration; import org.infinispan.distribution.ch.impl.AffinityPartitioner; import org.infinispan.transaction.tm.EmbeddedTransactionManager; import org.jboss.as.clustering.controller.CapabilityServiceNameProvider; import org.jboss.as.clustering.controller.ResourceServiceConfigurator; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.infinispan.service.ConfigurationServiceConfigurator; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.Dependency; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; /** * Builds a cache configuration from its components. * @author Paul Ferraro */ public class CacheConfigurationServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, Consumer<ConfigurationBuilder>, Dependency { private final ConfigurationServiceConfigurator configurator; private final SupplierDependency<MemoryConfiguration> memory; private final SupplierDependency<ExpirationConfiguration> expiration; private final SupplierDependency<LockingConfiguration> locking; private final SupplierDependency<PersistenceConfiguration> persistence; private final SupplierDependency<TransactionConfiguration> transaction; private final CacheMode mode; private volatile boolean statisticsEnabled; CacheConfigurationServiceConfigurator(PathAddress address, CacheMode mode) { super(CONFIGURATION, address); this.mode = mode; this.memory = new ServiceSupplierDependency<>(CacheComponent.MEMORY.getServiceName(address)); this.expiration = new ServiceSupplierDependency<>(CacheComponent.EXPIRATION.getServiceName(address)); this.locking = new ServiceSupplierDependency<>(CacheComponent.LOCKING.getServiceName(address)); this.persistence = new ServiceSupplierDependency<>(CacheComponent.PERSISTENCE.getServiceName(address)); this.transaction = new ServiceSupplierDependency<>(CacheComponent.TRANSACTION.getServiceName(address)); String containerName = address.getParent().getLastElement().getValue(); String cacheName = address.getLastElement().getValue(); this.configurator = new ConfigurationServiceConfigurator(this.getServiceName(), containerName, cacheName, this).require(this); } @Override public ServiceBuilder<?> build(ServiceTarget target) { return this.configurator.build(target); } @Override public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { return new CompositeDependency(this.memory, this.expiration, this.locking, this.persistence, this.transaction).register(builder); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.statisticsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean(); this.configurator.configure(context); return this; } @Override public void accept(ConfigurationBuilder builder) { TransactionConfiguration tx = this.transaction.get(); builder.clustering().cacheMode(this.mode).hash().keyPartitioner(new AffinityPartitioner()); builder.memory().read(this.memory.get()); builder.expiration().read(this.expiration.get()); builder.locking().read(this.locking.get()); builder.persistence().read(this.persistence.get()); builder.transaction().read(tx); builder.statistics().enabled(this.statisticsEnabled); try { // Configure invocation batching based on transaction configuration builder.invocationBatching().enable(tx.transactionMode().isTransactional() && (tx.transactionManagerLookup().getTransactionManager() == EmbeddedTransactionManager.getInstance())); } catch (Exception e) { throw new CacheException(e); } } }
6,093
48.544715
191
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CustomStoreConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.commons.configuration.attributes.AttributeSet; import org.infinispan.configuration.cache.AbstractStoreConfiguration; import org.infinispan.configuration.cache.AsyncStoreConfiguration; /** * @author Paul Ferraro */ public class CustomStoreConfiguration extends AbstractStoreConfiguration { public CustomStoreConfiguration(AttributeSet attributes, AsyncStoreConfiguration async) { super(attributes, async); } }
1,530
39.289474
93
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/DistributedCacheResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.UnaryOperator; import org.infinispan.Cache; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.SimpleResourceDescriptorConfigurator; import org.jboss.as.clustering.controller.validation.DoubleRangeValidatorBuilder; import org.jboss.as.clustering.controller.validation.IntRangeValidatorBuilder; import org.jboss.as.clustering.controller.validation.LongRangeValidatorBuilder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Resource description for the addressable resource /subsystem=infinispan/cache-container=X/distributed-cache=* * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. * @author Radoslav Husar */ public class DistributedCacheResourceDefinition extends SegmentedCacheResourceDefinition { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static PathElement pathElement(String name) { return PathElement.pathElement("distributed-cache", name); } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { CAPACITY_FACTOR("capacity-factor", ModelType.DOUBLE, new ModelNode(1.0f)) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new DoubleRangeValidatorBuilder().lowerBound(0).upperBound(Float.MAX_VALUE).configure(builder).build()); } }, L1_LIFESPAN("l1-lifespan", ModelType.LONG, ModelNode.ZERO_LONG) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new LongRangeValidatorBuilder().min(0).configure(builder).build()) .setMeasurementUnit(MeasurementUnit.MILLISECONDS) ; } }, OWNERS("owners", ModelType.INT, new ModelNode(2)) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new IntRangeValidatorBuilder().min(1).configure(builder).build()); } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } DistributedCacheResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(WILDCARD_PATH, new SimpleResourceDescriptorConfigurator<>(Attribute.class), new ClusteredCacheServiceHandler(DistributedCacheServiceConfigurator::new), executors); } }
4,537
45.783505
177
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LockingServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.LockingResourceDefinition.Attribute.ACQUIRE_TIMEOUT; import static org.jboss.as.clustering.infinispan.subsystem.LockingResourceDefinition.Attribute.CONCURRENCY; import static org.jboss.as.clustering.infinispan.subsystem.LockingResourceDefinition.Attribute.ISOLATION; import static org.jboss.as.clustering.infinispan.subsystem.LockingResourceDefinition.Attribute.STRIPING; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.LockingConfiguration; import org.infinispan.util.concurrent.IsolationLevel; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; /** * @author Paul Ferraro */ public class LockingServiceConfigurator extends ComponentServiceConfigurator<LockingConfiguration> { private volatile long timeout; private volatile int concurrency; private volatile IsolationLevel isolation; private volatile boolean striping; LockingServiceConfigurator(PathAddress address) { super(CacheComponent.LOCKING, address); } @Override public LockingConfiguration get() { return new ConfigurationBuilder().locking() .lockAcquisitionTimeout(this.timeout) .concurrencyLevel(this.concurrency) .isolationLevel(this.isolation) .useLockStriping(this.striping) .create(); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.timeout = ACQUIRE_TIMEOUT.resolveModelAttribute(context, model).asLong(); this.concurrency = CONCURRENCY.resolveModelAttribute(context, model).asInt(); this.isolation = IsolationLevel.valueOf(ISOLATION.resolveModelAttribute(context, model).asString()); this.striping = STRIPING.resolveModelAttribute(context, model).asBoolean(); return this; } }
3,207
43.555556
117
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/NoStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.controller.PathElement; /** * @author Paul Ferraro */ public class NoStoreResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { static final PathElement PATH = StoreResourceDefinition.pathElement("none"); public NoStoreResourceDefinition() { super(PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(PATH)); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()); ResourceServiceHandler handler = new SimpleResourceServiceHandler(NoStoreServiceConfigurator::new); new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
2,409
42.818182
107
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/JGroupsTransportServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.JGroupsTransportResourceDefinition.Attribute.CHANNEL; import static org.jboss.as.clustering.infinispan.subsystem.JGroupsTransportResourceDefinition.Attribute.LOCK_TIMEOUT; import java.util.Properties; import org.infinispan.configuration.global.GlobalConfigurationBuilder; import org.infinispan.configuration.global.TransportConfiguration; import org.infinispan.configuration.global.TransportConfigurationBuilder; import org.infinispan.remoting.transport.jgroups.JGroupsTransport; import org.jboss.as.clustering.infinispan.transport.ChannelConfigurator; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceBuilder; import org.wildfly.clustering.jgroups.spi.ChannelFactory; import org.wildfly.clustering.jgroups.spi.JGroupsRequirement; import org.wildfly.clustering.jgroups.spi.ProtocolStackConfiguration; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; /** * @author Paul Ferraro */ public class JGroupsTransportServiceConfigurator extends GlobalComponentServiceConfigurator<TransportConfiguration> { private final String containerName; private volatile SupplierDependency<ChannelFactory> factory; private volatile SupplierDependency<String> cluster; private volatile String channel; private volatile long lockTimeout; public JGroupsTransportServiceConfigurator(PathAddress address) { super(CacheContainerComponent.TRANSPORT, address); this.containerName = address.getParent().getLastElement().getValue(); } @Override public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { return super.register(new CompositeDependency(this.factory, this.cluster).register(builder)); } @Override public JGroupsTransportServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.lockTimeout = LOCK_TIMEOUT.resolveModelAttribute(context, model).asLong(); this.channel = CHANNEL.resolveModelAttribute(context, model).asStringOrNull(); this.factory = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, this.channel)); this.cluster = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_CLUSTER.getServiceName(context, this.channel)); return this; } @Override public TransportConfiguration get() { ChannelFactory factory = this.factory.get(); Properties properties = new Properties(); properties.put(JGroupsTransport.CHANNEL_CONFIGURATOR, new ChannelConfigurator(factory, this.containerName)); ProtocolStackConfiguration stack = factory.getProtocolStackConfiguration(); org.wildfly.clustering.jgroups.spi.TransportConfiguration.Topology topology = stack.getTransport().getTopology(); TransportConfigurationBuilder builder = new GlobalConfigurationBuilder().transport() .clusterName(this.cluster.get()) .distributedSyncTimeout(this.lockTimeout) .transport(new JGroupsTransport()) .withProperties(properties) ; if (topology != null) { builder.siteId(topology.getSite()).rackId(topology.getRack()).machineId(topology.getMachine()); } return builder.create(); } String getChannel() { return this.channel; } }
4,750
46.51
133
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ExpirationResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.concurrent.TimeUnit; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Resource description for the addressable resource /subsystem=infinispan/cache-container=X/cache=Y/expiration=EXPIRATION * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class ExpirationResourceDefinition extends ComponentResourceDefinition { static final PathElement PATH = pathElement("expiration"); enum Attribute implements org.jboss.as.clustering.controller.Attribute { INTERVAL("interval", new ModelNode(TimeUnit.MINUTES.toMillis(1))), LIFESPAN("lifespan", null), MAX_IDLE("max-idle", null), ; private final AttributeDefinition definition; Attribute(String name, ModelNode defaultValue) { this.definition = new SimpleAttributeDefinitionBuilder(name, ModelType.LONG) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .setMeasurementUnit(MeasurementUnit.MILLISECONDS) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } ExpirationResourceDefinition() { super(PATH); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class); ResourceServiceHandler handler = new SimpleResourceServiceHandler(ExpirationServiceConfigurator::new); new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
3,643
40.885057
133
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LazyCacheServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.Consumer; import java.util.function.Function; import org.infinispan.Cache; import org.infinispan.manager.EmbeddedCacheManager; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.clustering.infinispan.cache.LazyCache; import org.jboss.as.controller.OperationContext; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.InfinispanRequirement; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.Dependency; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceDependency; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; /** * @author Paul Ferraro */ public class LazyCacheServiceConfigurator extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, Function<EmbeddedCacheManager, Cache<Object, Object>> { private final String containerName; private final String cacheName; private volatile SupplierDependency<EmbeddedCacheManager> container; private volatile Dependency cache; public LazyCacheServiceConfigurator(ServiceName name, String containerName, String cacheName) { super(name); this.containerName = containerName; this.cacheName = cacheName; } @Override public ServiceConfigurator configure(OperationContext context) { this.container = new ServiceSupplierDependency<>(InfinispanRequirement.CONTAINER.getServiceName(context, this.containerName)); this.cache = new ServiceDependency(InfinispanCacheRequirement.CACHE.getServiceName(context, this.containerName, this.cacheName)); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<Cache<Object, Object>> cache = new CompositeDependency(this.container, this.cache).register(builder).provides(name); Service service = new FunctionalService<>(cache, this, this.container); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } @Override public Cache<Object, Object> apply(EmbeddedCacheManager container) { return new LazyCache<>(container, this.cacheName); } }
3,885
43.666667
173
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LockingMetricExecutor.java
/* * JBoss, Home of Professional Open Source * Copyright 2014 Red Hat Inc. and/or its affiliates and other contributors * as indicated by the @author tags. All rights reserved. * See the copyright.txt in the distribution for a * full listing of individual contributors. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU Lesser General Public License, v. 2.1. * This program is distributed in the hope that it will be useful, but WITHOUT A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License, * v.2.1 along with this distribution; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.Cache; import org.infinispan.util.concurrent.locks.impl.DefaultLockManager; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; /** * A handler for cache locking metrics. * * @author Paul Ferraro */ public class LockingMetricExecutor extends CacheMetricExecutor<DefaultLockManager> { public LockingMetricExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(executors, BinaryCapabilityNameResolver.GRANDPARENT_PARENT); } @Override public DefaultLockManager apply(Cache<?, ?> cache) { return (DefaultLockManager) cache.getAdvancedCache().getLockManager(); } }
1,744
40.547619
84
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ScheduledThreadPoolResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.clustering.controller.ResourceDefinitionProvider; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceConfigurator; import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleAttribute; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.clustering.controller.validation.IntRangeValidatorBuilder; import org.jboss.as.clustering.controller.validation.LongRangeValidatorBuilder; import org.jboss.as.clustering.controller.validation.ParameterValidatorBuilder; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.ResourceDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.descriptions.ResourceDescriptionResolver; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jboss.msc.service.ServiceName; /** * Scheduled thread pool resource definitions for Infinispan subsystem. * * See {@link org.infinispan.factories.KnownComponentNames} and {@link org.infinispan.commons.executors.BlockingThreadPoolExecutorFactory#create(int, int)} * for the hardcoded Infinispan default values. * * @author Radoslav Husar */ public enum ScheduledThreadPoolResourceDefinition implements ResourceDefinitionProvider, ScheduledThreadPoolDefinition, ResourceServiceConfiguratorFactory { EXPIRATION("expiration", 1, 60000), // called eviction prior to Infinispan 8 ; static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); private static PathElement pathElement(String name) { return PathElement.pathElement("thread-pool", name); } private final PathElement path; private final Attribute minThreads; private final Attribute keepAliveTime; ScheduledThreadPoolResourceDefinition(String name, int defaultMinThreads, long defaultKeepaliveTime) { this.path = pathElement(name); this.minThreads = new SimpleAttribute(createBuilder("min-threads", ModelType.INT, new ModelNode(defaultMinThreads), new IntRangeValidatorBuilder().min(0), null).build()); this.keepAliveTime = new SimpleAttribute(createBuilder("keepalive-time", ModelType.LONG, new ModelNode(defaultKeepaliveTime), new LongRangeValidatorBuilder().min(0), null).build()); } private static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue, ParameterValidatorBuilder validatorBuilder, InfinispanSubsystemModel deprecation) { SimpleAttributeDefinitionBuilder builder = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags((deprecation != null) ? AttributeAccess.Flag.RESTART_RESOURCE_SERVICES : AttributeAccess.Flag.RESTART_NONE) .setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null) ; return builder.setValidator(validatorBuilder.configure(builder).build()); } @Override public void register(ManagementResourceRegistration parent) { ResourceDescriptionResolver resolver = InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(this.path, pathElement(PathElement.WILDCARD_VALUE)); ResourceDefinition definition = new SimpleResourceDefinition(this.path, resolver); ManagementResourceRegistration registration = parent.registerSubModel(definition); ResourceDescriptor descriptor = new ResourceDescriptor(resolver) .addAttributes(this.minThreads, this.keepAliveTime) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(this); new SimpleResourceRegistrar(descriptor, handler).register(registration); } @Override public ResourceServiceConfigurator createServiceConfigurator(PathAddress address) { return new ScheduledThreadPoolServiceConfigurator(this, address); } @Override public ServiceName getServiceName(PathAddress containerAddress) { return CacheContainerResourceDefinition.Capability.CONFIGURATION.getServiceName(containerAddress).append(this.getPathElement().getKeyValuePair()); } @Override public Attribute getMinThreads() { return this.minThreads; } @Override public Attribute getKeepAliveTime() { return this.keepAliveTime; } @Override public PathElement getPathElement() { return this.path; } }
6,192
48.150794
202
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/OffHeapMemoryResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.UnaryOperator; import org.infinispan.configuration.cache.StorageType; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.SimpleAliasEntry; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; /** * @author Paul Ferraro */ public class OffHeapMemoryResourceDefinition extends MemoryResourceDefinition { static final PathElement PATH = pathElement("off-heap"); static final PathElement BINARY_PATH = pathElement("binary"); enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { SIZE_UNIT(SharedAttribute.SIZE_UNIT) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(EnumValidator.create(MemorySizeUnit.class)); } }, ; private final AttributeDefinition definition; Attribute(org.jboss.as.clustering.controller.Attribute basis) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder((SimpleAttributeDefinition) basis.getDefinition())).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } static class ResourceDescriptorConfigurator implements UnaryOperator<ResourceDescriptor> { @Override public ResourceDescriptor apply(ResourceDescriptor descriptor) { return descriptor.addAttributes(Attribute.class) ; } } OffHeapMemoryResourceDefinition() { super(StorageType.OFF_HEAP, PATH, new ResourceDescriptorConfigurator(), Attribute.SIZE_UNIT); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = super.register(parent); parent.registerAlias(BINARY_PATH, new SimpleAliasEntry(registration)); return registration; } }
3,460
39.244186
138
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CustomStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.SimpleResourceDescriptorConfigurator; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelType; /** * Resource description for the addressable resource /subsystem=infinispan/cache-container=X/cache=Y/store=STORE * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class CustomStoreResourceDefinition extends StoreResourceDefinition { static final PathElement PATH = pathElement("custom"); enum Attribute implements org.jboss.as.clustering.controller.Attribute { CLASS("class", ModelType.STRING) ; private final AttributeDefinition definition; Attribute(String name, ModelType type) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } CustomStoreResourceDefinition() { super(PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(PATH, WILDCARD_PATH), new SimpleResourceDescriptorConfigurator<>(Attribute.class), CustomStoreServiceConfigurator::new); } }
2,610
39.796875
199
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheInterceptorMetricExecutor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.Cache; import org.infinispan.interceptors.AsyncInterceptor; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; /** * Executor for metrics based on a cache interceptor. * @author Paul Ferraro */ public class CacheInterceptorMetricExecutor<I extends AsyncInterceptor> extends CacheMetricExecutor<I> { private final Class<I> interceptorClass; public CacheInterceptorMetricExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors, Class<I> interceptorClass) { super(executors); this.interceptorClass = interceptorClass; } public CacheInterceptorMetricExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors, Class<I> interceptorClass, BinaryCapabilityNameResolver resolver) { super(executors, resolver); this.interceptorClass = interceptorClass; } @SuppressWarnings("deprecation") @Override public I apply(Cache<?, ?> cache) { return cache.getAdvancedCache().getAsyncInterceptorChain().findInterceptorExtending(this.interceptorClass); } }
2,210
39.944444
158
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CachePassivationMetric.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.eviction.impl.PassivationManager; import org.jboss.as.clustering.controller.Metric; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * @author Paul Ferraro */ public enum CachePassivationMetric implements Metric<PassivationManager> { PASSIVATIONS("passivations", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) { @Override public ModelNode execute(PassivationManager manager) { return new ModelNode(manager.getPassivations()); } }, ; private final AttributeDefinition definition; CachePassivationMetric(String name, ModelType type, AttributeAccess.Flag metricType) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setFlags(metricType) .setStorageRuntime() .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } }
2,213
36.525424
90
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ThreadPoolDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.Attribute; /** * @author Paul Ferraro */ public interface ThreadPoolDefinition extends ScheduledThreadPoolDefinition { Attribute getMaxThreads(); Attribute getQueueLength(); boolean isNonBlocking(); }
1,340
34.289474
77
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ScatteredCacheResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.concurrent.TimeUnit; import java.util.function.UnaryOperator; import org.infinispan.Cache; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.SimpleResourceDescriptorConfigurator; import org.jboss.as.clustering.controller.validation.IntRangeValidatorBuilder; import org.jboss.as.clustering.controller.validation.LongRangeValidatorBuilder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Resource definition for a scattered-cache. * @author Paul Ferraro */ @Deprecated public class ScatteredCacheResourceDefinition extends SegmentedCacheResourceDefinition { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static PathElement pathElement(String name) { return PathElement.pathElement("scattered-cache", name); } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { BIAS_LIFESPAN("bias-lifespan", ModelType.LONG, new ModelNode(TimeUnit.MINUTES.toMillis(5))) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new LongRangeValidatorBuilder().min(0).configure(builder).build()) .setMeasurementUnit(MeasurementUnit.MILLISECONDS) ; } }, INVALIDATION_BATCH_SIZE("invalidation-batch-size", ModelType.INT, new ModelNode(128)) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new IntRangeValidatorBuilder().min(0).configure(builder).build()) ; } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } ScatteredCacheResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(WILDCARD_PATH, new SimpleResourceDescriptorConfigurator<>(Attribute.class), new ClusteredCacheServiceHandler(ScatteredCacheServiceConfigurator::new), executors); this.setDeprecated(InfinispanSubsystemModel.VERSION_16_0_0.getVersion()); } }
4,162
43.763441
175
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/MemoryResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.UnaryOperator; import org.infinispan.configuration.cache.StorageType; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.clustering.controller.validation.LongRangeValidatorBuilder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * @author Paul Ferraro */ public class MemoryResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static PathElement pathElement(String value) { return PathElement.pathElement("memory", value); } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { SIZE("size", ModelType.LONG, null) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new LongRangeValidatorBuilder().min(1).configure(builder).build()); } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder; } } enum SharedAttribute implements org.jboss.as.clustering.controller.Attribute { SIZE_UNIT("size-unit", ModelType.STRING, new ModelNode(MemorySizeUnit.ENTRIES.name())), ; private final AttributeDefinition definition; SharedAttribute(String name, ModelType type, ModelNode defaultValue) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } private final UnaryOperator<ResourceDescriptor> configurator; private final ResourceServiceConfiguratorFactory factory; MemoryResourceDefinition(StorageType type, PathElement path, UnaryOperator<ResourceDescriptor> configurator, org.jboss.as.clustering.controller.Attribute sizeUnitAttribute) { super(path, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(path, WILDCARD_PATH)); this.configurator = configurator; this.factory = address -> new MemoryServiceConfigurator(type, address, sizeUnitAttribute); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = this.configurator.apply(new ResourceDescriptor(this.getResourceDescriptionResolver())) .addAttributes(Attribute.class) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(this.factory); new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
5,436
42.150794
178
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ScheduledThreadPoolDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.clustering.controller.ResourceServiceNameFactory; /** * @author Paul Ferraro */ public interface ScheduledThreadPoolDefinition extends ResourceServiceNameFactory { Attribute getMinThreads(); Attribute getKeepAliveTime(); }
1,388
36.540541
83
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/MemorySizeUnit.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.math.BigInteger; import java.util.function.LongUnaryOperator; /** * Units for the size attribute of the memory resource. * @author Paul Ferraro */ public enum MemorySizeUnit implements LongUnaryOperator { ENTRIES(0), BYTES(1), KB(1000, 1), KiB(1024, 1), MB(1000, 2), MiB(1024, 2), GB(1000, 3), GiB(1024, 3), TB(1000, 4), TiB(1024, 4), ; private final long value; MemorySizeUnit(int base, int exponent) { this(BigInteger.valueOf(base).pow(exponent).longValueExact()); } MemorySizeUnit(long value) { this.value = value; } @Override public long applyAsLong(long size) { return size * this.value; } }
1,795
29.440678
70
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LocalCacheResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.UnaryOperator; import org.infinispan.Cache; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.controller.PathElement; import org.wildfly.clustering.server.service.LocalCacheServiceConfiguratorProvider; /** * Resource description for the addressable resource /subsystem=infinispan/cache-container=X/local-cache=* * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class LocalCacheResourceDefinition extends CacheResourceDefinition<LocalCacheServiceConfiguratorProvider> { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static PathElement pathElement(String name) { return PathElement.pathElement("local-cache", name); } LocalCacheResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(WILDCARD_PATH, UnaryOperator.identity(), new LocalCacheServiceHandler(), executors); } }
2,029
41.291667
114
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheComponentRuntimeResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.registry.ManagementResourceRegistration; /** * @author Paul Ferraro */ public class CacheComponentRuntimeResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static final PathElement pathElement(String name) { return PathElement.pathElement("component", name); } CacheComponentRuntimeResourceDefinition(PathElement path) { this(path, path); } CacheComponentRuntimeResourceDefinition(PathElement path, PathElement resolverPath) { super(new Parameters(path, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(resolverPath)).setRuntime()); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { return parent.registerSubModel(this); } }
2,102
38.679245
123
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheOperation.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.interceptors.impl.CacheMgmtInterceptor; import org.jboss.as.clustering.controller.Operation; import org.jboss.as.controller.ExpressionResolver; import org.jboss.as.controller.OperationDefinition; import org.jboss.as.controller.SimpleOperationDefinitionBuilder; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * @author Paul Ferraro */ public enum CacheOperation implements Operation<CacheMgmtInterceptor> { RESET_STATISTICS("reset-statistics", ModelType.UNDEFINED) { @Override public ModelNode execute(ExpressionResolver resolver, ModelNode operation, CacheMgmtInterceptor interceptor) { interceptor.resetStatistics(); return null; } }, ; private final OperationDefinition definition; CacheOperation(String name, ModelType returnType) { this.definition = new SimpleOperationDefinitionBuilder(name, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(CacheRuntimeResourceDefinition.WILDCARD_PATH)) .setReplyType(returnType) .setRuntimeOnly() .build(); } @Override public OperationDefinition getDefinition() { return this.definition; } }
2,318
37.65
174
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ClusteredCacheMetric.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.remoting.rpc.RpcManagerImpl; import org.jboss.as.clustering.controller.Metric; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Enumeration of management metrics for a clustered cache. * @author Paul Ferraro */ public enum ClusteredCacheMetric implements Metric<RpcManagerImpl> { AVERAGE_REPLICATION_TIME("average-replication-time", ModelType.LONG, MeasurementUnit.MILLISECONDS) { @Override public ModelNode execute(RpcManagerImpl manager) { return new ModelNode(manager.getAverageReplicationTime()); } }, REPLICATION_COUNT("replication-count", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) { @Override public ModelNode execute(RpcManagerImpl manager) { return new ModelNode(manager.getReplicationCount()); } }, REPLICATION_FAILURES("replication-failures", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) { @Override public ModelNode execute(RpcManagerImpl manager) { return new ModelNode(manager.getReplicationFailures()); } }, SUCCESS_RATIO("success-ratio", ModelType.DOUBLE, AttributeAccess.Flag.GAUGE_METRIC) { @Override public ModelNode execute(RpcManagerImpl manager) { return new ModelNode(manager.getSuccessRatioFloatingPoint()); } }, ; private final AttributeDefinition definition; ClusteredCacheMetric(String name, ModelType type, AttributeAccess.Flag metricType) { this(name, type, metricType, null); } ClusteredCacheMetric(String name, ModelType type, MeasurementUnit unit) { this(name, type, AttributeAccess.Flag.COUNTER_METRIC, unit); } ClusteredCacheMetric(String name, ModelType type, AttributeAccess.Flag metricType, MeasurementUnit unit) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setFlags(metricType) .setMeasurementUnit(unit) .setStorageRuntime() .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } }
3,483
39.511628
110
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ThreadPoolServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadFactory; import org.infinispan.commons.util.ProcessorInfo; import org.infinispan.configuration.global.ThreadPoolConfiguration; import org.infinispan.configuration.global.ThreadPoolConfigurationBuilder; import org.infinispan.factories.threads.EnhancedQueueExecutorFactory; import org.jboss.as.clustering.infinispan.executors.DefaultNonBlockingThreadFactory; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.jboss.threads.management.ManageableThreadPoolExecutorService; import org.wildfly.clustering.context.DefaultThreadFactory; import org.wildfly.clustering.service.ServiceConfigurator; /** * Configures a service providing a {@link ThreadPoolConfiguration}. * @author Radoslav Husar * @author Paul Ferraro */ public class ThreadPoolServiceConfigurator extends GlobalComponentServiceConfigurator<ThreadPoolConfiguration> { private final ThreadPoolConfigurationBuilder builder = new ThreadPoolConfigurationBuilder(null); private final ThreadPoolDefinition definition; ThreadPoolServiceConfigurator(ThreadPoolDefinition definition, PathAddress address) { super(definition, address); this.definition = definition; } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { int minThreads = this.definition.getMinThreads().resolveModelAttribute(context, model).asInt(); int maxThreads = this.definition.getMaxThreads().resolveModelAttribute(context, model).asInt(); int queueLength = this.definition.getQueueLength().resolveModelAttribute(context, model).asInt(); long keepAliveTime = this.definition.getKeepAliveTime().resolveModelAttribute(context, model).asLong(); boolean nonBlocking = this.definition.isNonBlocking(); if (this.definition == ThreadPoolResourceDefinition.NON_BLOCKING) { int availableProcessors = ProcessorInfo.availableProcessors(); minThreads *= availableProcessors; maxThreads *= availableProcessors; } this.builder.threadPoolFactory(nonBlocking ? new NonBlockingThreadPoolExecutorFactory(maxThreads, minThreads, queueLength, keepAliveTime) : new BlockingThreadPoolExecutorFactory(maxThreads, minThreads, queueLength, keepAliveTime)); return this; } @Override public ThreadPoolConfiguration get() { return this.builder.create(); } private static class BlockingThreadPoolExecutorFactory extends EnhancedQueueExecutorFactory { BlockingThreadPoolExecutorFactory(int maxThreads, int coreThreads, int queueLength, long keepAlive) { super(maxThreads, coreThreads, queueLength, keepAlive); } @Override public ManageableThreadPoolExecutorService createExecutor(ThreadFactory factory) { return super.createExecutor(new DefaultThreadFactory(factory)); } } private static class NonBlockingThreadPoolExecutorFactory extends org.infinispan.factories.threads.NonBlockingThreadPoolExecutorFactory { NonBlockingThreadPoolExecutorFactory(int maxThreads, int coreThreads, int queueLength, long keepAlive) { super(maxThreads, coreThreads, queueLength, keepAlive); } @Override public ExecutorService createExecutor(ThreadFactory factory) { return super.createExecutor(new DefaultNonBlockingThreadFactory(factory)); } } }
4,723
44.864078
239
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerComponent.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.ResourceServiceNameFactory; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.msc.service.ServiceName; /** * @author Paul Ferraro */ public enum CacheContainerComponent implements ResourceServiceNameFactory { MODULES("modules"), TRANSPORT(JGroupsTransportResourceDefinition.PATH), ; private final String component; CacheContainerComponent(PathElement path) { this.component = path.getKey(); } CacheContainerComponent(String component) { this.component = component; } @Override public ServiceName getServiceName(PathAddress containerAddress) { return CacheContainerResourceDefinition.Capability.CONFIGURATION.getServiceName(containerAddress).append(this.component); } }
1,920
35.245283
129
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/JDBCStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.UnaryOperator; import org.infinispan.persistence.jdbc.common.DatabaseType; import org.jboss.as.clustering.controller.CapabilityReference; import org.jboss.as.clustering.controller.CommonUnaryRequirement; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelType; /** * Base class for store resources which require common store attributes and JDBC store attributes * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class JDBCStoreResourceDefinition extends StoreResourceDefinition { static final PathElement PATH = pathElement("jdbc"); enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { DATA_SOURCE("data-source", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setRequired(true) .setCapabilityReference(new CapabilityReference(Capability.PERSISTENCE, CommonUnaryRequirement.DATA_SOURCE)) ; } }, DIALECT("dialect", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setAllowExpression(true) .setRequired(false) .setValidator(EnumValidator.create(DatabaseType.class)) ; } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } static class ResourceDescriptorConfigurator implements UnaryOperator<ResourceDescriptor> { @Override public ResourceDescriptor apply(ResourceDescriptor descriptor) { return descriptor.addAttributes(Attribute.class) .addRequiredChildren(StringTableResourceDefinition.PATH) ; } } JDBCStoreResourceDefinition() { super(PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(PATH, WILDCARD_PATH), new ResourceDescriptorConfigurator(), JDBCStoreServiceConfigurator::new); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = super.register(parent); new StringTableResourceDefinition().register(registration); return registration; } }
4,322
40.567308
174
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StringTableResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * @author Paul Ferraro */ public class StringTableResourceDefinition extends TableResourceDefinition { static final PathElement PATH = pathElement("string"); enum Attribute implements org.jboss.as.clustering.controller.Attribute { PREFIX("prefix", ModelType.STRING, new ModelNode("ispn_entry")), ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } StringTableResourceDefinition() { super(PATH, Attribute.PREFIX); } }
2,364
36.539683
78
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ComponentServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.jboss.as.clustering.controller.ResourceServiceConfigurator; import org.jboss.as.clustering.controller.ResourceServiceNameFactory; import org.jboss.as.controller.PathAddress; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.service.Dependency; import org.wildfly.clustering.service.FunctionalService; /** * Configures a service supplying a cache component. * @author Paul Ferraro */ public abstract class ComponentServiceConfigurator<C> implements ResourceServiceConfigurator, Supplier<C>, Dependency { private final ServiceName name; private final ServiceController.Mode initialMode; protected ComponentServiceConfigurator(ResourceServiceNameFactory factory, PathAddress address) { this(factory, address, ServiceController.Mode.ON_DEMAND); } protected ComponentServiceConfigurator(ResourceServiceNameFactory factory, PathAddress address, ServiceController.Mode initialMode) { this.name = factory.getServiceName(address.getParent()); this.initialMode = initialMode; } @Override public ServiceName getServiceName() { return this.name; } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceBuilder<?> builder = target.addService(this.getServiceName()); Consumer<C> component = this.register(builder).provides(this.getServiceName()); Service service = new FunctionalService<>(component, Function.identity(), this); return builder.setInstance(service).setInitialMode(this.initialMode); } @Override public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { return builder; } }
3,031
38.894737
137
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LocalCacheServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.configuration.cache.CacheMode; import org.jboss.as.controller.PathAddress; /** * @author Paul Ferraro */ public class LocalCacheServiceConfigurator extends CacheConfigurationServiceConfigurator { LocalCacheServiceConfigurator(PathAddress address) { super(address, CacheMode.LOCAL); } }
1,407
37.054054
90
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ComponentResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.controller.PathElement; /** * @author Paul Ferraro */ public abstract class ComponentResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { public static PathElement pathElement(String name) { return PathElement.pathElement("component", name); } public ComponentResourceDefinition(PathElement path) { super(path, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(path)); } }
1,690
40.243902
115
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/XAResourceRecoveryServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Capability.CACHE; import static org.jboss.as.clustering.infinispan.subsystem.TransactionResourceDefinition.TransactionRequirement.XA_RESOURCE_RECOVERY_REGISTRY; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.infinispan.Cache; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.clustering.infinispan.tx.InfinispanXAResourceRecovery; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.PathAddress; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceTarget; import org.jboss.tm.XAResourceRecovery; import org.jboss.tm.XAResourceRecoveryRegistry; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; /** * Builder for a {@link XAResourceRecovery} registration. * @author Paul Ferraro */ public class XAResourceRecoveryServiceConfigurator extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, Supplier<XAResourceRecovery>, Consumer<XAResourceRecovery> { private final SupplierDependency<Cache<?, ?>> cache; private volatile SupplierDependency<XAResourceRecoveryRegistry> registry; /** * Constructs a new {@link XAResourceRecovery} builder. */ public XAResourceRecoveryServiceConfigurator(PathAddress cacheAddress) { super(CACHE.getServiceName(cacheAddress).append("recovery")); this.cache = new ServiceSupplierDependency<>(this.getServiceName().getParent()); } @Override public XAResourceRecovery get() { Cache<?, ?> cache = this.cache.get(); XAResourceRecovery recovery = new InfinispanXAResourceRecovery(cache); if (cache.getCacheConfiguration().transaction().recovery().enabled()) { this.registry.get().addXAResourceRecovery(recovery); } return recovery; } @Override public void accept(XAResourceRecovery recovery) { if (this.cache.get().getCacheConfiguration().transaction().recovery().enabled()) { this.registry.get().removeXAResourceRecovery(recovery); } } @Override public ServiceConfigurator configure(OperationContext context) { this.registry = new ServiceSupplierDependency<>(context.getCapabilityServiceName(XA_RESOURCE_RECOVERY_REGISTRY.getName(), XA_RESOURCE_RECOVERY_REGISTRY.getType())); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceBuilder<?> builder = target.addService(this.getServiceName()); Consumer<XAResourceRecovery> recovery = builder.provides(this.getServiceName()); new CompositeDependency(this.cache, this.registry).register(builder); Service service = new FunctionalService<>(recovery, Function.identity(), this, this); return builder.setInstance(service).setInitialMode(ServiceController.Mode.PASSIVE); } }
4,460
44.060606
187
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/JDBCStoreServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.JDBCStoreResourceDefinition.Attribute.DATA_SOURCE; import static org.jboss.as.clustering.infinispan.subsystem.JDBCStoreResourceDefinition.Attribute.DIALECT; import java.util.List; import java.util.Optional; import javax.sql.DataSource; import org.infinispan.persistence.jdbc.common.DatabaseType; import org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfiguration; import org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder; import org.infinispan.persistence.jdbc.configuration.TableManipulationConfiguration; import org.infinispan.persistence.keymappers.TwoWayKey2StringMapper; import org.jboss.as.clustering.controller.CommonUnaryRequirement; import org.jboss.as.clustering.infinispan.persistence.jdbc.DataSourceConnectionFactoryConfigurationBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.jboss.modules.Module; import org.jboss.msc.service.ServiceBuilder; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; /** * @author Paul Ferraro */ public class JDBCStoreServiceConfigurator extends StoreServiceConfigurator<JdbcStringBasedStoreConfiguration, JdbcStringBasedStoreConfigurationBuilder> { private final SupplierDependency<TableManipulationConfiguration> table; private volatile SupplierDependency<List<Module>> modules; private volatile SupplierDependency<DataSource> dataSource; private volatile DatabaseType dialect; JDBCStoreServiceConfigurator(PathAddress address) { super(address, JdbcStringBasedStoreConfigurationBuilder.class); PathAddress cacheAddress = address.getParent(); PathAddress containerAddress = cacheAddress.getParent(); this.table = new ServiceSupplierDependency<>(CacheComponent.STRING_TABLE.getServiceName(cacheAddress)); this.modules = new ServiceSupplierDependency<>(CacheContainerComponent.MODULES.getServiceName(containerAddress)); } @Override public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { return super.register(new CompositeDependency(this.table, this.modules, this.dataSource).register(builder)); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { String dataSource = DATA_SOURCE.resolveModelAttribute(context, model).asString(); this.dataSource = new ServiceSupplierDependency<>(CommonUnaryRequirement.DATA_SOURCE.getServiceName(context, dataSource)); this.dialect = Optional.ofNullable(DIALECT.resolveModelAttribute(context, model).asStringOrNull()).map(DatabaseType::valueOf).orElse(null); return super.configure(context, model); } @Override public void accept(JdbcStringBasedStoreConfigurationBuilder builder) { builder.table().read(this.table.get()); TwoWayKey2StringMapper mapper = this.findMapper(); if (mapper != null) { builder.key2StringMapper(mapper.getClass()); } builder.segmented(true) .transactional(false) .dialect(this.dialect) .connectionFactory(DataSourceConnectionFactoryConfigurationBuilder.class) .setDataSourceDependency(this.dataSource); } private TwoWayKey2StringMapper findMapper() { for (Module module : this.modules.get()) { for (TwoWayKey2StringMapper mapper : module.loadService(TwoWayKey2StringMapper.class)) { return mapper; } } return null; } }
4,983
46.466667
153
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LockingRuntimeResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.Cache; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.MetricHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.registry.ManagementResourceRegistration; /** * @author Paul Ferraro */ public class LockingRuntimeResourceDefinition extends CacheComponentRuntimeResourceDefinition { static final PathElement PATH = pathElement("locking"); private final FunctionExecutorRegistry<Cache<?, ?>> executors; LockingRuntimeResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(PATH); this.executors = executors; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = super.register(parent); new MetricHandler<>(new LockingMetricExecutor(this.executors), LockingMetric.class).register(registration); return registration; } }
2,097
39.346154
115
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TransactionResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.EnumSet; import java.util.concurrent.TimeUnit; import java.util.function.UnaryOperator; import jakarta.transaction.TransactionSynchronizationRegistry; import org.infinispan.transaction.LockingMode; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.BinaryRequirementCapability; import org.jboss.as.clustering.controller.Capability; import org.jboss.as.clustering.controller.CommonRequirement; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jboss.tm.XAResourceRecoveryRegistry; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.service.Requirement; /** * Resource description for the addressable resource and its alias * * /subsystem=infinispan/cache-container=X/cache=Y/component=transaction * /subsystem=infinispan/cache-container=X/cache=Y/transaction=TRANSACTION * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class TransactionResourceDefinition extends ComponentResourceDefinition { static final PathElement PATH = pathElement("transaction"); enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { LOCKING("locking", ModelType.STRING, new ModelNode(LockingMode.PESSIMISTIC.name())) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(EnumValidator.create(LockingMode.class)); } }, MODE("mode", ModelType.STRING, new ModelNode(TransactionMode.NONE.name())) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(EnumValidator.create(TransactionMode.class)); } }, STOP_TIMEOUT("stop-timeout", ModelType.LONG, new ModelNode(TimeUnit.SECONDS.toMillis(10))) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setMeasurementUnit(MeasurementUnit.MILLISECONDS); } }, COMPLETE_TIMEOUT("complete-timeout", ModelType.LONG, new ModelNode(TimeUnit.SECONDS.toMillis(60))) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setMeasurementUnit(MeasurementUnit.MILLISECONDS); } } ; private final SimpleAttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } enum TransactionRequirement implements Requirement { TRANSACTION_SYNCHRONIZATION_REGISTRY("org.wildfly.transactions.transaction-synchronization-registry", TransactionSynchronizationRegistry.class), XA_RESOURCE_RECOVERY_REGISTRY("org.wildfly.transactions.xa-resource-recovery-registry", XAResourceRecoveryRegistry.class); private final String name; private final Class<?> type; TransactionRequirement(String name, Class<?> type) { this.name = name; this.type = type; } @Override public String getName() { return this.name; } @Override public Class<?> getType() { return this.type; } } TransactionResourceDefinition() { super(PATH); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); Capability dependentCapability = new BinaryRequirementCapability(InfinispanCacheRequirement.CACHE, BinaryCapabilityNameResolver.GRANDPARENT_PARENT); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()) .addAttributes(Attribute.class) // Add a requirement on the tm capability to the parent cache capability .addResourceCapabilityReference(new TransactionResourceCapabilityReference(dependentCapability, CommonRequirement.LOCAL_TRANSACTION_PROVIDER, Attribute.MODE, EnumSet.of(TransactionMode.NONE, TransactionMode.BATCH))) // Add a requirement on the XAResourceRecoveryRegistry capability to the parent cache capability .addResourceCapabilityReference(new TransactionResourceCapabilityReference(dependentCapability, TransactionRequirement.TRANSACTION_SYNCHRONIZATION_REGISTRY, Attribute.MODE, EnumSet.complementOf(EnumSet.of(TransactionMode.NON_XA)))) // Add a requirement on the XAResourceRecoveryRegistry capability to the parent cache capability .addResourceCapabilityReference(new TransactionResourceCapabilityReference(dependentCapability, TransactionRequirement.XA_RESOURCE_RECOVERY_REGISTRY, Attribute.MODE, EnumSet.complementOf(EnumSet.of(TransactionMode.FULL_XA)))); ResourceServiceHandler handler = new SimpleResourceServiceHandler(TransactionServiceConfigurator::new); new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
7,610
48.103226
247
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.EnumSet; import java.util.function.UnaryOperator; import java.util.stream.Collectors; import org.infinispan.Cache; import org.jboss.as.clustering.controller.BinaryRequirementCapability; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.validation.ModuleIdentifierValidatorBuilder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.StringListAttributeDefinition; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.server.service.CacheServiceConfiguratorProvider; import org.wildfly.clustering.server.service.ClusteringCacheRequirement; import org.wildfly.clustering.service.BinaryRequirement; import org.wildfly.clustering.singleton.SingletonCacheRequirement; /** * Base class for cache resources which require common cache attributes only. * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class CacheResourceDefinition<P extends CacheServiceConfiguratorProvider> extends ChildResourceDefinition<ManagementResourceRegistration> { enum Capability implements CapabilityProvider { CACHE(InfinispanCacheRequirement.CACHE), CONFIGURATION(InfinispanCacheRequirement.CONFIGURATION), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(BinaryRequirement requirement) { this.capability = new BinaryRequirementCapability(requirement); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { STATISTICS_ENABLED(ModelDescriptionConstants.STATISTICS_ENABLED, ModelType.BOOLEAN) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setDefaultValue(ModelNode.FALSE); } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type) { this.definition = this.apply(createBuilder(name, type)) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } enum ListAttribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<StringListAttributeDefinition.Builder> { MODULES("modules") { @Override public StringListAttributeDefinition.Builder apply(StringListAttributeDefinition.Builder builder) { return builder.setElementValidator(new ModuleIdentifierValidatorBuilder().configure(builder).build()); } }, ; private final AttributeDefinition definition; ListAttribute(String name) { this.definition = this.apply(new StringListAttributeDefinition.Builder(name) .setRequired(false) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } @Override public StringListAttributeDefinition.Builder apply(StringListAttributeDefinition.Builder builder) { return builder; } } static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type) { return new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) ; } private final UnaryOperator<ResourceDescriptor> configurator; private final ResourceServiceHandler handler; public CacheResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, CacheServiceHandler<P> handler, FunctionExecutorRegistry<Cache<?, ?>> executors) { super(path, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(path, PathElement.pathElement("cache"))); this.configurator = configurator; this.handler = handler; } @SuppressWarnings("deprecation") @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = this.configurator.apply(new ResourceDescriptor(this.getResourceDescriptionResolver())) .addAttributes(Attribute.class) .addAttributes(ListAttribute.class) .addCapabilities(Capability.class) .addCapabilities(EnumSet.allOf(ClusteringCacheRequirement.class).stream().map(BinaryRequirementCapability::new).collect(Collectors.toList())) .addCapabilities(EnumSet.allOf(SingletonCacheRequirement.class).stream().map(BinaryRequirementCapability::new).collect(Collectors.toList())) .addRequiredChildren(ExpirationResourceDefinition.PATH, LockingResourceDefinition.PATH, TransactionResourceDefinition.PATH) .addRequiredSingletonChildren(HeapMemoryResourceDefinition.PATH, NoStoreResourceDefinition.PATH) ; new SimpleResourceRegistrar(descriptor, this.handler).register(registration); new HeapMemoryResourceDefinition().register(registration); new OffHeapMemoryResourceDefinition().register(registration); new ExpirationResourceDefinition().register(registration); new LockingResourceDefinition().register(registration); new TransactionResourceDefinition().register(registration); new NoStoreResourceDefinition().register(registration); new CustomStoreResourceDefinition().register(registration); new FileStoreResourceDefinition().register(registration); new JDBCStoreResourceDefinition().register(registration); new RemoteStoreResourceDefinition().register(registration); new HotRodStoreResourceDefinition().register(registration); return registration; } }
8,143
45.272727
183
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.UnaryOperator; import org.infinispan.configuration.cache.PersistenceConfiguration; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.PropertiesAttributeDefinition; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.descriptions.ResourceDescriptionResolver; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Base class for store resources which require common store attributes only. * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. * @author Paul Ferraro */ public abstract class StoreResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { protected static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); protected static PathElement pathElement(String value) { return PathElement.pathElement("store", value); } protected enum Capability implements org.jboss.as.clustering.controller.Capability { PERSISTENCE("org.wildfly.clustering.infinispan.cache.store", PersistenceConfiguration.class), ; private final RuntimeCapability<Void> definition; Capability(String name, Class<?> type) { this.definition = RuntimeCapability.Builder.of(name, true).setServiceType(type).setDynamicNameMapper(BinaryCapabilityNameResolver.GRANDPARENT_PARENT).build(); } @Override public RuntimeCapability<Void> getDefinition() { return this.definition; } } enum Attribute implements org.jboss.as.clustering.controller.Attribute { MAX_BATCH_SIZE("max-batch-size", ModelType.INT, new ModelNode(100)), PASSIVATION("passivation", ModelType.BOOLEAN, ModelNode.FALSE), PRELOAD("preload", ModelType.BOOLEAN, ModelNode.FALSE), PURGE("purge", ModelType.BOOLEAN, ModelNode.FALSE), SHARED("shared", ModelType.BOOLEAN, ModelNode.FALSE), SEGMENTED("segmented", ModelType.BOOLEAN, ModelNode.TRUE), PROPERTIES("properties"), ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } Attribute(String name) { this.definition = new PropertiesAttributeDefinition.Builder(name) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute { FETCH_STATE("fetch-state", ModelType.BOOLEAN, ModelNode.TRUE, InfinispanSubsystemModel.VERSION_16_0_0), ; private final AttributeDefinition definition; DeprecatedAttribute(String name, ModelType type, ModelNode defaultValue, InfinispanSubsystemModel deprecation) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setDefaultValue(defaultValue) .setDeprecated(deprecation.getVersion()) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } private final UnaryOperator<ResourceDescriptor> configurator; private final ResourceServiceConfiguratorFactory factory; protected StoreResourceDefinition(PathElement path, ResourceDescriptionResolver resolver, UnaryOperator<ResourceDescriptor> configurator, ResourceServiceConfiguratorFactory factory) { super(path, resolver); this.configurator = configurator; this.factory = factory; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = this.configurator.apply(new ResourceDescriptor(this.getResourceDescriptionResolver())) .addAttributes(Attribute.class) .addAttributes(DeprecatedAttribute.class) .addCapabilities(Capability.class) .addRequiredSingletonChildren(StoreWriteThroughResourceDefinition.PATH) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(this.factory); new SimpleResourceRegistrar(descriptor, handler).register(registration); new StoreWriteBehindResourceDefinition().register(registration); new StoreWriteThroughResourceDefinition().register(registration); return registration; } }
7,013
43.961538
187
java