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/InfinispanExtensionTransformerRegistration.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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 org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.transform.ExtensionTransformerRegistration;
import org.jboss.as.controller.transform.SubsystemTransformerRegistration;
import org.jboss.as.controller.transform.description.TransformationDescription;
import org.kohsuke.MetaInfServices;
/**
* @author Paul Ferraro
*/
@MetaInfServices(ExtensionTransformerRegistration.class)
public class InfinispanExtensionTransformerRegistration implements ExtensionTransformerRegistration {
@Override
public String getSubsystemName() {
return InfinispanExtension.SUBSYSTEM_NAME;
}
@Override
public void registerTransformers(SubsystemTransformerRegistration registration) {
// Register transformers for all but the current model
for (InfinispanSubsystemModel model : EnumSet.complementOf(EnumSet.of(InfinispanSubsystemModel.CURRENT))) {
ModelVersion version = model.getVersion();
TransformationDescription.Tools.register(new InfinispanSubsystemResourceTransformer().apply(version), registration, version);
}
}
}
| 2,211
| 40.735849
| 137
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/SegmentedCacheResourceTransformer.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 SegmentedCacheResourceTransformer extends SharedStateCacheResourceTransformer {
SegmentedCacheResourceTransformer(ResourceTransformationDescriptionBuilder builder) {
super(builder);
}
}
| 1,423
| 38.555556
| 94
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheRuntimeResourceProvider.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.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap;
import org.jboss.as.clustering.controller.ChildResourceProvider;
import org.jboss.as.clustering.controller.ComplexResource;
import org.jboss.as.clustering.controller.SimpleChildResourceProvider;
import org.jboss.as.controller.registry.PlaceholderResource;
import org.wildfly.common.function.Functions;
/**
* @author Paul Ferraro
*/
public class CacheRuntimeResourceProvider extends SimpleChildResourceProvider {
private static final ChildResourceProvider CHILD_PROVIDER = new SimpleChildResourceProvider(Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
LockingRuntimeResourceDefinition.PATH.getValue(),
PersistenceRuntimeResourceDefinition.PATH.getValue(),
PartitionHandlingRuntimeResourceDefinition.PATH.getValue(),
TransactionRuntimeResourceDefinition.PATH.getValue()))));
public CacheRuntimeResourceProvider() {
super(ConcurrentHashMap.newKeySet(), Functions.constantSupplier(new ComplexResource(PlaceholderResource.INSTANCE, Collections.singletonMap(CacheComponentRuntimeResourceDefinition.WILDCARD_PATH.getKey(), CHILD_PROVIDER))));
}
}
| 2,331
| 44.72549
| 230
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/GlobalConfigurationServiceConfigurator.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.CacheContainerResourceDefinition.Attribute.DEFAULT_CACHE;
import static org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Attribute.MARSHALLER;
import static org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Attribute.STATISTICS_ENABLED;
import static org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Capability.CONFIGURATION;
import java.io.File;
import java.io.UncheckedIOException;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import javax.management.MBeanServer;
import org.infinispan.commands.module.ModuleCommandExtensions;
import org.infinispan.commons.marshall.Marshaller;
import org.infinispan.commons.util.AggregatedClassLoader;
import org.infinispan.configuration.global.GlobalConfiguration;
import org.infinispan.configuration.global.ShutdownHookBehavior;
import org.infinispan.configuration.global.ThreadPoolConfiguration;
import org.infinispan.configuration.global.TransportConfiguration;
import org.infinispan.configuration.internal.PrivateGlobalConfigurationBuilder;
import org.infinispan.globalstate.ConfigurationStorage;
import org.infinispan.protostream.SerializationContext;
import org.infinispan.protostream.SerializationContextInitializer;
import org.jboss.as.clustering.controller.CapabilityServiceNameProvider;
import org.jboss.as.clustering.controller.CommonRequirement;
import org.jboss.as.clustering.controller.ResourceServiceConfigurator;
import org.jboss.as.clustering.infinispan.jmx.MBeanServerProvider;
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.as.server.ServerEnvironment;
import org.jboss.as.server.ServerEnvironmentService;
import org.jboss.as.server.Services;
import org.jboss.dmr.ModelNode;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleLoader;
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.wildfly.clustering.infinispan.marshall.InfinispanMarshallerFactory;
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.ServiceSupplierDependency;
import org.wildfly.clustering.service.SupplierDependency;
/**
* @author Paul Ferraro
*/
public class GlobalConfigurationServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, Supplier<GlobalConfiguration> {
private final SupplierDependency<ModuleLoader> loader;
private final SupplierDependency<List<Module>> modules;
private final SupplierDependency<TransportConfiguration> transport;
private final SupplierDependency<ServerEnvironment> environment;
private final Map<ThreadPoolResourceDefinition, SupplierDependency<ThreadPoolConfiguration>> pools = new EnumMap<>(ThreadPoolResourceDefinition.class);
private final Map<ScheduledThreadPoolResourceDefinition, SupplierDependency<ThreadPoolConfiguration>> scheduledPools = new EnumMap<>(ScheduledThreadPoolResourceDefinition.class);
private final String name;
private volatile SupplierDependency<MBeanServer> server;
private volatile String defaultCache;
private volatile boolean statisticsEnabled;
private volatile InfinispanMarshallerFactory marshallerFactory;
GlobalConfigurationServiceConfigurator(PathAddress address) {
super(CONFIGURATION, address);
this.name = address.getLastElement().getValue();
this.loader = new ServiceSupplierDependency<>(Services.JBOSS_SERVICE_MODULE_LOADER);
this.modules = new ServiceSupplierDependency<>(CacheContainerComponent.MODULES.getServiceName(address));
this.transport = new ServiceSupplierDependency<>(CacheContainerComponent.TRANSPORT.getServiceName(address));
this.environment = new ServiceSupplierDependency<>(ServerEnvironmentService.SERVICE_NAME);
for (ThreadPoolResourceDefinition pool : EnumSet.of(ThreadPoolResourceDefinition.LISTENER, ThreadPoolResourceDefinition.BLOCKING, ThreadPoolResourceDefinition.NON_BLOCKING)) {
this.pools.put(pool, new ServiceSupplierDependency<>(pool.getServiceName(address)));
}
for (ScheduledThreadPoolResourceDefinition pool : EnumSet.allOf(ScheduledThreadPoolResourceDefinition.class)) {
this.scheduledPools.put(pool, new ServiceSupplierDependency<>(pool.getServiceName(address)));
}
}
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.server = context.hasOptionalCapability(CommonRequirement.MBEAN_SERVER.getName(), null, null) ? new ServiceSupplierDependency<>(CommonRequirement.MBEAN_SERVER.getServiceName(context)) : null;
this.defaultCache = DEFAULT_CACHE.resolveModelAttribute(context, model).asStringOrNull();
this.statisticsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
this.marshallerFactory = InfinispanMarshallerFactory.valueOf(MARSHALLER.resolveModelAttribute(context, model).asString());
return this;
}
@Override
public GlobalConfiguration get() {
org.infinispan.configuration.global.GlobalConfigurationBuilder builder = new org.infinispan.configuration.global.GlobalConfigurationBuilder();
builder.cacheManagerName(this.name)
.defaultCacheName(this.defaultCache)
.cacheContainer().statistics(this.statisticsEnabled)
;
builder.transport().read(this.transport.get());
List<Module> modules = this.modules.get();
Marshaller marshaller = this.marshallerFactory.apply(this.loader.get(), modules);
InfinispanLogger.ROOT_LOGGER.debugf("%s cache-container will use %s", this.name, marshaller.getClass().getName());
// Register dummy serialization context initializer, to bypass service loading in org.infinispan.marshall.protostream.impl.SerializationContextRegistryImpl
// Otherwise marshaller auto-detection will not work
builder.serialization().marshaller(marshaller).addContextInitializer(new SerializationContextInitializer() {
@Deprecated
@Override
public String getProtoFile() throws UncheckedIOException {
return null;
}
@Deprecated
@Override
public String getProtoFileName() {
return null;
}
@Override
public void registerMarshallers(SerializationContext context) {
}
@Override
public void registerSchema(SerializationContext context) {
}
});
ClassLoader loader = modules.size() > 1 ? new AggregatedClassLoader(modules.stream().map(Module::getClassLoader).collect(Collectors.toList())) : modules.get(0).getClassLoader();
builder.classLoader(loader);
builder.blockingThreadPool().read(this.pools.get(ThreadPoolResourceDefinition.BLOCKING).get());
builder.listenerThreadPool().read(this.pools.get(ThreadPoolResourceDefinition.LISTENER).get());
builder.nonBlockingThreadPool().read(this.pools.get(ThreadPoolResourceDefinition.NON_BLOCKING).get());
builder.expirationThreadPool().read(this.scheduledPools.get(ScheduledThreadPoolResourceDefinition.EXPIRATION).get());
builder.shutdown().hookBehavior(ShutdownHookBehavior.DONT_REGISTER);
// Disable registration of MicroProfile Metrics
builder.metrics().gauges(false).histograms(false).accurateSize(true);
builder.jmx().domain("org.wildfly.clustering.infinispan")
.mBeanServerLookup((this.server != null) ? new MBeanServerProvider(this.server.get()) : null)
.enabled(this.server != null)
;
// Disable triangle algorithm - we optimize for originator as primary owner
// Do not enable server-mode for the Hibernate 2LC use case:
// * The 2LC stack already overrides the interceptor for distribution caches
// * This renders Infinispan default 2LC configuration unusable as it results in a default media type of application/unknown for keys and values
// See ISPN-12252 for details
builder.addModule(PrivateGlobalConfigurationBuilder.class).serverMode(!ServiceLoader.load(ModuleCommandExtensions.class, loader).iterator().hasNext());
String path = InfinispanExtension.SUBSYSTEM_NAME + File.separatorChar + this.name;
ServerEnvironment environment = this.environment.get();
builder.globalState().enable()
.configurationStorage(ConfigurationStorage.VOLATILE)
.persistentLocation(path, environment.getServerDataDir().getPath())
.temporaryLocation(path, environment.getServerTempDir().getPath())
;
return builder.build();
}
@Override
public ServiceBuilder<?> build(ServiceTarget target) {
ServiceBuilder<?> builder = target.addService(this.getServiceName());
Consumer<GlobalConfiguration> global = new CompositeDependency(this.loader, this.modules, this.transport, this.server, this.environment).register(builder).provides(this.getServiceName());
for (Dependency dependency: this.pools.values()) {
dependency.register(builder);
}
for (Dependency dependency: this.scheduledPools.values()) {
dependency.register(builder);
}
Service service = new FunctionalService<>(global, Function.identity(), this);
return builder.setInstance(service).setInitialMode(ServiceController.Mode.PASSIVE);
}
}
| 11,339
| 53.782609
| 203
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanSubsystemXMLWriter.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.Arrays;
import java.util.EnumSet;
import java.util.Set;
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.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.persistence.SubsystemMarshallingContext;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.staxmapper.XMLElementWriter;
import org.jboss.staxmapper.XMLExtendedStreamWriter;
import org.wildfly.common.iteration.CompositeIterable;
/**
* XML writer for current Infinispan subsystem schema version.
* @author Paul Ferraro
* @author Richard Achmatowicz (c) 2011 Red Hat Inc.
* @author Tristan Tarrant
*/
public class InfinispanSubsystemXMLWriter implements XMLElementWriter<SubsystemMarshallingContext> {
@SuppressWarnings("deprecation")
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
context.startSubsystemElement(InfinispanSubsystemSchema.CURRENT.getNamespace().getUri(), false);
ModelNode model = context.getModelNode();
if (model.isDefined()) {
if (model.hasDefined(CacheContainerResourceDefinition.WILDCARD_PATH.getKey())) {
for (Property entry: model.get(CacheContainerResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
String containerName = entry.getName();
ModelNode container = entry.getValue();
writer.writeStartElement(XMLElement.CACHE_CONTAINER.getLocalName());
writer.writeAttribute(XMLAttribute.NAME.getLocalName(), containerName);
writeAttributes(writer, container, CacheContainerResourceDefinition.Attribute.class);
writeAttributes(writer, container, CacheContainerResourceDefinition.ListAttribute.class);
if (container.hasDefined(JGroupsTransportResourceDefinition.PATH.getKeyValuePair())) {
writer.writeStartElement(XMLElement.TRANSPORT.getLocalName());
ModelNode transport = container.get(JGroupsTransportResourceDefinition.PATH.getKeyValuePair());
writeAttributes(writer, transport, EnumSet.allOf(JGroupsTransportResourceDefinition.Attribute.class));
writer.writeEndElement();
}
// write any configured thread pools
if (container.hasDefined(ThreadPoolResourceDefinition.WILDCARD_PATH.getKey())) {
writeThreadPoolElements(XMLElement.BLOCKING_THREAD_POOL, ThreadPoolResourceDefinition.BLOCKING, writer, container);
writeThreadPoolElements(XMLElement.LISTENER_THREAD_POOL, ThreadPoolResourceDefinition.LISTENER, writer, container);
writeThreadPoolElements(XMLElement.NON_BLOCKING_THREAD_POOL, ThreadPoolResourceDefinition.NON_BLOCKING, writer, container);
writeScheduledThreadPoolElements(XMLElement.EXPIRATION_THREAD_POOL, ScheduledThreadPoolResourceDefinition.EXPIRATION, writer, container);
}
// write any existent cache types
if (container.hasDefined(LocalCacheResourceDefinition.WILDCARD_PATH.getKey())) {
for (Property property : container.get(LocalCacheResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
ModelNode cache = property.getValue();
writer.writeStartElement(XMLElement.LOCAL_CACHE.getLocalName());
writeCacheAttributes(writer, property.getName(), cache);
writeCacheElements(writer, cache);
writer.writeEndElement();
}
}
if (container.hasDefined(InvalidationCacheResourceDefinition.WILDCARD_PATH.getKey())) {
for (Property property : container.get(InvalidationCacheResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
ModelNode cache = property.getValue();
writer.writeStartElement(XMLElement.INVALIDATION_CACHE.getLocalName());
writeClusteredCacheAttributes(writer, property.getName(), cache);
writeCacheElements(writer, cache);
writer.writeEndElement();
}
}
if (container.hasDefined(ReplicatedCacheResourceDefinition.WILDCARD_PATH.getKey())) {
for (Property property : container.get(ReplicatedCacheResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
ModelNode cache = property.getValue();
writer.writeStartElement(XMLElement.REPLICATED_CACHE.getLocalName());
writeClusteredCacheAttributes(writer, property.getName(), cache);
writeCacheElements(writer, cache);
writer.writeEndElement();
}
}
if (container.hasDefined(DistributedCacheResourceDefinition.WILDCARD_PATH.getKey())) {
for (Property property : container.get(DistributedCacheResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
ModelNode cache = property.getValue();
writer.writeStartElement(XMLElement.DISTRIBUTED_CACHE.getLocalName());
writeSegmentedCacheAttributes(writer, property.getName(), cache);
writeAttributes(writer, cache, EnumSet.allOf(DistributedCacheResourceDefinition.Attribute.class));
writeCacheElements(writer, cache);
writer.writeEndElement();
}
}
if (container.hasDefined(ScatteredCacheResourceDefinition.WILDCARD_PATH.getKey())) {
for (Property property : container.get(ScatteredCacheResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
ModelNode cache = property.getValue();
writer.writeStartElement(XMLElement.SCATTERED_CACHE.getLocalName());
writeSegmentedCacheAttributes(writer, property.getName(), cache);
writeAttributes(writer, cache, EnumSet.allOf(ScatteredCacheResourceDefinition.Attribute.class));
writeCacheElements(writer, cache);
writer.writeEndElement();
}
}
writer.writeEndElement();
}
}
if (model.hasDefined(RemoteCacheContainerResourceDefinition.WILDCARD_PATH.getKey())) {
for (Property entry : model.get(RemoteCacheContainerResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
String remoteContainerName = entry.getName();
ModelNode remoteContainer = entry.getValue();
writer.writeStartElement(XMLElement.REMOTE_CACHE_CONTAINER.getLocalName());
writer.writeAttribute(XMLAttribute.NAME.getLocalName(), remoteContainerName);
writeAttributes(writer, remoteContainer, EnumSet.complementOf(EnumSet.of(RemoteCacheContainerResourceDefinition.Attribute.PROPERTIES)));
writeAttributes(writer, remoteContainer, RemoteCacheContainerResourceDefinition.ListAttribute.class);
writeAttributes(writer, remoteContainer, EnumSet.allOf(RemoteCacheContainerResourceDefinition.DeprecatedAttribute.class));
writeThreadPoolElements(XMLElement.ASYNC_THREAD_POOL, ThreadPoolResourceDefinition.CLIENT, writer, remoteContainer);
ModelNode connectionPool = remoteContainer.get(ConnectionPoolResourceDefinition.PATH.getKeyValuePair());
Set<ConnectionPoolResourceDefinition.Attribute> attributes = EnumSet.allOf(ConnectionPoolResourceDefinition.Attribute.class);
if (hasDefined(connectionPool, attributes)) {
writer.writeStartElement(XMLElement.CONNECTION_POOL.getLocalName());
writeAttributes(writer, connectionPool, attributes);
writer.writeEndElement();
}
writeElement(writer, remoteContainer, StoreResourceDefinition.Attribute.PROPERTIES);
writer.writeStartElement(XMLElement.REMOTE_CLUSTERS.getLocalName());
for (Property clusterEntry : remoteContainer.get(RemoteClusterResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
writer.writeStartElement(XMLElement.REMOTE_CLUSTER.getLocalName());
String remoteClusterName = clusterEntry.getName();
ModelNode remoteCluster = clusterEntry.getValue();
writer.writeAttribute(XMLAttribute.NAME.getLocalName(), remoteClusterName);
writeAttributes(writer, remoteCluster, RemoteClusterResourceDefinition.Attribute.class);
writer.writeEndElement();
}
writer.writeEndElement(); // </remote-clusters>
ModelNode securityModel = remoteContainer.get(SecurityResourceDefinition.PATH.getKeyValuePair());
Set<SecurityResourceDefinition.Attribute> securityAttributes = EnumSet.allOf(SecurityResourceDefinition.Attribute.class);
if (hasDefined(securityModel, securityAttributes)) {
writer.writeStartElement(XMLElement.SECURITY.getLocalName());
writeAttributes(writer, securityModel, securityAttributes);
writer.writeEndElement();
}
writer.writeEndElement(); // </remote-cache-container>
}
}
}
writer.writeEndElement();
}
private static void writeCacheAttributes(XMLExtendedStreamWriter writer, String name, ModelNode cache) throws XMLStreamException {
writer.writeAttribute(XMLAttribute.NAME.getLocalName(), name);
writeAttributes(writer, cache, CacheResourceDefinition.Attribute.class);
writeAttributes(writer, cache, CacheResourceDefinition.ListAttribute.class);
}
private static void writeClusteredCacheAttributes(XMLExtendedStreamWriter writer, String name, ModelNode cache) throws XMLStreamException {
writeCacheAttributes(writer, name, cache);
writeAttributes(writer, cache, ClusteredCacheResourceDefinition.Attribute.class);
}
private static void writeSegmentedCacheAttributes(XMLExtendedStreamWriter writer, String name, ModelNode cache) throws XMLStreamException {
writeClusteredCacheAttributes(writer, name, cache);
writeAttributes(writer, cache, SegmentedCacheResourceDefinition.Attribute.class);
}
@SuppressWarnings("deprecation")
private static void writeCacheElements(XMLExtendedStreamWriter writer, ModelNode cache) throws XMLStreamException {
if (cache.hasDefined(LockingResourceDefinition.PATH.getKeyValuePair())) {
ModelNode locking = cache.get(LockingResourceDefinition.PATH.getKeyValuePair());
Set<LockingResourceDefinition.Attribute> attributes = EnumSet.allOf(LockingResourceDefinition.Attribute.class);
if (hasDefined(locking, attributes)) {
writer.writeStartElement(XMLElement.LOCKING.getLocalName());
writeAttributes(writer, locking, attributes);
writer.writeEndElement();
}
}
if (cache.hasDefined(TransactionResourceDefinition.PATH.getKeyValuePair())) {
ModelNode transaction = cache.get(TransactionResourceDefinition.PATH.getKeyValuePair());
Set<TransactionResourceDefinition.Attribute> attributes = EnumSet.allOf(TransactionResourceDefinition.Attribute.class);
if (hasDefined(transaction, attributes)) {
writer.writeStartElement(XMLElement.TRANSACTION.getLocalName());
writeAttributes(writer, transaction, attributes);
writer.writeEndElement();
}
}
if (cache.hasDefined(HeapMemoryResourceDefinition.PATH.getKeyValuePair())) {
ModelNode memory = cache.get(HeapMemoryResourceDefinition.PATH.getKeyValuePair());
Iterable<Attribute> attributes = new CompositeIterable<>(EnumSet.allOf(MemoryResourceDefinition.Attribute.class), EnumSet.allOf(HeapMemoryResourceDefinition.Attribute.class));
if (hasDefined(memory, attributes)) {
writer.writeStartElement(XMLElement.HEAP_MEMORY.getLocalName());
writeAttributes(writer, memory, attributes);
writer.writeEndElement();
}
} else if (cache.hasDefined(OffHeapMemoryResourceDefinition.PATH.getKeyValuePair())) {
ModelNode memory = cache.get(OffHeapMemoryResourceDefinition.PATH.getKeyValuePair());
Iterable<Attribute> attributes = new CompositeIterable<>(EnumSet.allOf(MemoryResourceDefinition.Attribute.class), EnumSet.allOf(OffHeapMemoryResourceDefinition.Attribute.class));
if (hasDefined(memory, attributes)) {
writer.writeStartElement(XMLElement.OFF_HEAP_MEMORY.getLocalName());
writeAttributes(writer, memory, attributes);
writer.writeEndElement();
}
}
if (cache.hasDefined(ExpirationResourceDefinition.PATH.getKeyValuePair())) {
ModelNode expiration = cache.get(ExpirationResourceDefinition.PATH.getKeyValuePair());
Set<ExpirationResourceDefinition.Attribute> attributes = EnumSet.allOf(ExpirationResourceDefinition.Attribute.class);
if (hasDefined(expiration, attributes)) {
writer.writeStartElement(XMLElement.EXPIRATION.getLocalName());
writeAttributes(writer, expiration, attributes);
writer.writeEndElement();
}
}
Set<StoreResourceDefinition.Attribute> storeAttributes = EnumSet.complementOf(EnumSet.of(StoreResourceDefinition.Attribute.PROPERTIES));
if (cache.hasDefined(CustomStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(CustomStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.STORE.getLocalName());
writeAttributes(writer, store, CustomStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, JDBCStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writer.writeEndElement();
}
if (cache.hasDefined(FileStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(FileStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.FILE_STORE.getLocalName());
writeAttributes(writer, store, FileStoreResourceDefinition.DeprecatedAttribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writer.writeEndElement();
}
if (cache.hasDefined(JDBCStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(JDBCStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.JDBC_STORE.getLocalName());
writeAttributes(writer, store, JDBCStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writeJDBCStoreTable(writer, XMLElement.TABLE, store, StringTableResourceDefinition.PATH, StringTableResourceDefinition.Attribute.PREFIX);
writer.writeEndElement();
}
if (cache.hasDefined(RemoteStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(RemoteStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.REMOTE_STORE.getLocalName());
writeAttributes(writer, store, RemoteStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writer.writeEndElement();
}
if (cache.hasDefined(HotRodStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(HotRodStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.HOTROD_STORE.getLocalName());
writeAttributes(writer, store, HotRodStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writer.writeEndElement();
}
if (cache.hasDefined(PartitionHandlingResourceDefinition.PATH.getKeyValuePair())) {
ModelNode partitionHandling = cache.get(PartitionHandlingResourceDefinition.PATH.getKeyValuePair());
EnumSet<PartitionHandlingResourceDefinition.Attribute> attributes = EnumSet.allOf(PartitionHandlingResourceDefinition.Attribute.class);
if (hasDefined(partitionHandling, attributes)) {
writer.writeStartElement(XMLElement.PARTITION_HANDLING.getLocalName());
writeAttributes(writer, partitionHandling, attributes);
writer.writeEndElement();
}
}
if (cache.hasDefined(StateTransferResourceDefinition.PATH.getKeyValuePair())) {
ModelNode stateTransfer = cache.get(StateTransferResourceDefinition.PATH.getKeyValuePair());
EnumSet<StateTransferResourceDefinition.Attribute> attributes = EnumSet.allOf(StateTransferResourceDefinition.Attribute.class);
if (hasDefined(stateTransfer, attributes)) {
writer.writeStartElement(XMLElement.STATE_TRANSFER.getLocalName());
writeAttributes(writer, stateTransfer, attributes);
writer.writeEndElement();
}
}
if (cache.hasDefined(BackupsResourceDefinition.PATH.getKeyValuePair())) {
ModelNode backups = cache.get(BackupsResourceDefinition.PATH.getKeyValuePair());
if (backups.hasDefined(BackupResourceDefinition.WILDCARD_PATH.getKey())) {
writer.writeStartElement(XMLElement.BACKUPS.getLocalName());
for (Property property: backups.get(BackupResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
writer.writeStartElement(XMLElement.BACKUP.getLocalName());
writer.writeAttribute(XMLAttribute.SITE.getLocalName(), property.getName());
ModelNode backup = property.getValue();
writeAttributes(writer, backup, BackupResourceDefinition.Attribute.class);
writeAttributes(writer, backup, BackupResourceDefinition.DeprecatedAttribute.class);
EnumSet<BackupResourceDefinition.TakeOfflineAttribute> takeOfflineAttributes = EnumSet.allOf(BackupResourceDefinition.TakeOfflineAttribute.class);
if (hasDefined(backup, takeOfflineAttributes)) {
writer.writeStartElement(XMLElement.TAKE_OFFLINE.getLocalName());
writeAttributes(writer, backup, takeOfflineAttributes);
writer.writeEndElement();
}
writer.writeEndElement();
}
writer.writeEndElement();
}
}
}
private static void writeJDBCStoreTable(XMLExtendedStreamWriter writer, XMLElement element, ModelNode store, PathElement path, Attribute prefixAttribute) throws XMLStreamException {
if (store.hasDefined(path.getKeyValuePair())) {
ModelNode table = store.get(path.getKeyValuePair());
writer.writeStartElement(element.getLocalName());
writeAttributes(writer, table, TableResourceDefinition.Attribute.class);
writeAttribute(writer, table, prefixAttribute);
for (TableResourceDefinition.ColumnAttribute attribute : EnumSet.allOf(TableResourceDefinition.ColumnAttribute.class)) {
if (table.hasDefined(attribute.getName())) {
ModelNode column = table.get(attribute.getName());
writer.writeStartElement(attribute.getDefinition().getXmlName());
writeAttribute(writer, column, attribute.getColumnName());
writeAttribute(writer, column, attribute.getColumnType());
writer.writeEndElement();
}
}
writer.writeEndElement();
}
}
private static void writeStoreElements(XMLExtendedStreamWriter writer, ModelNode store) throws XMLStreamException {
if (store.hasDefined(StoreWriteBehindResourceDefinition.PATH.getKeyValuePair())) {
ModelNode writeBehind = store.get(StoreWriteBehindResourceDefinition.PATH.getKeyValuePair());
Set<StoreWriteBehindResourceDefinition.Attribute> attributes = EnumSet.allOf(StoreWriteBehindResourceDefinition.Attribute.class);
if (hasDefined(writeBehind, attributes)) {
writer.writeStartElement(XMLElement.WRITE_BEHIND.getLocalName());
writeAttributes(writer, writeBehind, attributes);
writer.writeEndElement();
}
}
writeElement(writer, store, StoreResourceDefinition.Attribute.PROPERTIES);
}
private static boolean hasDefined(ModelNode model, Iterable<? extends Attribute> attributes) {
for (Attribute attribute : attributes) {
if (model.hasDefined(attribute.getName())) return true;
}
return false;
}
private static <A extends Enum<A> & Attribute> void writeAttributes(XMLExtendedStreamWriter writer, ModelNode model, Class<A> attributeClass) throws XMLStreamException {
writeAttributes(writer, model, EnumSet.allOf(attributeClass));
}
private static void writeAttributes(XMLExtendedStreamWriter writer, ModelNode model, Iterable<? extends Attribute> attributes) throws XMLStreamException {
for (Attribute attribute : attributes) {
writeAttribute(writer, model, attribute);
}
}
private static void writeAttribute(XMLExtendedStreamWriter writer, ModelNode model, Attribute attribute) throws XMLStreamException {
attribute.getDefinition().getMarshaller().marshallAsAttribute(attribute.getDefinition(), model, true, writer);
}
private static void writeElement(XMLExtendedStreamWriter writer, ModelNode model, Attribute attribute) throws XMLStreamException {
attribute.getDefinition().getMarshaller().marshallAsElement(attribute.getDefinition(), model, true, writer);
}
private static <P extends ThreadPoolDefinition & ResourceDefinitionProvider> void writeThreadPoolElements(XMLElement element, P pool, XMLExtendedStreamWriter writer, ModelNode container) throws XMLStreamException {
if (container.get(pool.getPathElement().getKey()).hasDefined(pool.getPathElement().getValue())) {
ModelNode threadPool = container.get(pool.getPathElement().getKeyValuePair());
Iterable<Attribute> attributes = Arrays.asList(pool.getMinThreads(), pool.getMaxThreads(), pool.getQueueLength(), pool.getKeepAliveTime());
if (hasDefined(threadPool, attributes)) {
writer.writeStartElement(element.getLocalName());
writeAttributes(writer, threadPool, attributes);
writer.writeEndElement();
}
}
}
private static <P extends ScheduledThreadPoolDefinition & ResourceDefinitionProvider> void writeScheduledThreadPoolElements(XMLElement element, P pool, XMLExtendedStreamWriter writer, ModelNode container) throws XMLStreamException {
if (container.get(pool.getPathElement().getKey()).hasDefined(pool.getPathElement().getValue())) {
ModelNode threadPool = container.get(pool.getPathElement().getKeyValuePair());
Iterable<Attribute> attributes = Arrays.asList(pool.getMinThreads(), pool.getKeepAliveTime());
if (hasDefined(threadPool, attributes)) {
writer.writeStartElement(element.getLocalName());
writeAttributes(writer, threadPool, attributes);
writer.writeEndElement();
}
}
}
}
| 26,977
| 57.775599
| 236
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LockingMetric.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.function.UnaryOperator;
import org.infinispan.util.concurrent.locks.impl.DefaultLockManager;
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 locking management metrics for a cache.
*
* @author Paul Ferraro
*/
public enum LockingMetric implements Metric<DefaultLockManager>, UnaryOperator<SimpleAttributeDefinitionBuilder> {
CURRENT_CONCURRENCY_LEVEL("current-concurrency-level", ModelType.INT, AttributeAccess.Flag.GAUGE_METRIC) {
@Override
public ModelNode execute(DefaultLockManager manager) {
return new ModelNode(manager.getConcurrencyLevel());
}
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setDeprecated(InfinispanSubsystemModel.VERSION_17_0_0.getVersion());
}
},
NUMBER_OF_LOCKS_AVAILABLE("number-of-locks-available", ModelType.INT, AttributeAccess.Flag.GAUGE_METRIC) {
@Override
public ModelNode execute(DefaultLockManager manager) {
return new ModelNode(manager.getNumberOfLocksAvailable());
}
},
NUMBER_OF_LOCKS_HELD("number-of-locks-held", ModelType.INT, AttributeAccess.Flag.GAUGE_METRIC) {
@Override
public ModelNode execute(DefaultLockManager manager) {
return new ModelNode(manager.getNumberOfLocksHeld());
}
},
;
private final AttributeDefinition definition;
LockingMetric(String name, ModelType type, AttributeAccess.Flag metricType) {
this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type)
.setFlags(metricType)
.setStorageRuntime()
).build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder;
}
}
| 3,305
| 38.357143
| 114
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/NoTransportServiceHandler.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.LocalGroupServiceConfiguratorProvider;
import org.wildfly.clustering.server.service.ProvidedIdentityGroupServiceConfigurator;
/**
* @author Paul Ferraro
*/
public class NoTransportServiceHandler 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();
new NoTransportServiceConfigurator(address).build(target).install();
new ProvidedIdentityGroupServiceConfigurator(name, LocalGroupServiceConfiguratorProvider.LOCAL).configure(context).build(target).install();
}
@Override
public void removeServices(OperationContext context, ModelNode model) {
PathAddress address = context.getCurrentAddress();
PathAddress containerAddress = address.getParent();
String name = containerAddress.getLastElement().getValue();
new ProvidedIdentityGroupServiceConfigurator(name, LocalGroupServiceConfiguratorProvider.LOCAL).remove(context);
context.removeService(new NoTransportServiceConfigurator(address).getServiceName());
}
}
| 2,756
| 42.761905
| 147
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerServiceHandler.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.CacheContainerResourceDefinition.DEFAULT_CAPABILITIES;
import static org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Attribute.DEFAULT_CACHE;
import static org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.ListAttribute.MODULES;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Map;
import org.infinispan.Cache;
import org.infinispan.manager.EmbeddedCacheManager;
import org.jboss.as.clustering.controller.Capability;
import org.jboss.as.clustering.controller.ModulesServiceConfigurator;
import org.jboss.as.clustering.controller.ResourceServiceHandler;
import org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator;
import org.jboss.as.clustering.controller.ServiceValueRegistry;
import org.jboss.as.clustering.naming.BinderServiceConfigurator;
import org.jboss.as.clustering.naming.JndiNameFactory;
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.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.clustering.infinispan.lifecycle.WildFlyInfinispanModuleLifecycle;
import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement;
import org.wildfly.clustering.server.service.ProvidedIdentityCacheServiceConfigurator;
import org.wildfly.clustering.service.IdentityServiceConfigurator;
/**
* @author Paul Ferraro
*/
public class CacheContainerServiceHandler implements ResourceServiceHandler {
private final ServiceValueRegistry<EmbeddedCacheManager> containerRegistry;
private final ServiceValueRegistry<Cache<?, ?>> cacheRegistry;
public CacheContainerServiceHandler(ServiceValueRegistry<EmbeddedCacheManager> containerRegistry, ServiceValueRegistry<Cache<?, ?>> cacheRegistry) {
this.containerRegistry = containerRegistry;
this.cacheRegistry = cacheRegistry;
}
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
String name = context.getCurrentAddressValue();
ServiceTarget target = context.getServiceTarget();
new ModulesServiceConfigurator(CacheContainerComponent.MODULES.getServiceName(address), MODULES, Collections.singletonList(Module.forClass(WildFlyInfinispanModuleLifecycle.class))).configure(context, model).build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
GlobalConfigurationServiceConfigurator configBuilder = new GlobalConfigurationServiceConfigurator(address);
configBuilder.configure(context, model).build(target).install();
CacheContainerServiceConfigurator containerBuilder = new CacheContainerServiceConfigurator(address, this.cacheRegistry).configure(context, model);
containerBuilder.build(target).install();
new ServiceValueCaptorServiceConfigurator<>(this.containerRegistry.add(containerBuilder.getServiceName())).build(target).install();
new KeyAffinityServiceFactoryServiceConfigurator(address).build(target).install();
new BinderServiceConfigurator(InfinispanBindingFactory.createCacheContainerBinding(name), containerBuilder.getServiceName()).build(target).install();
String defaultCache = DEFAULT_CACHE.resolveModelAttribute(context, model).asString(null);
if (defaultCache != null) {
for (Map.Entry<InfinispanCacheRequirement, Capability> entry : DEFAULT_CAPABILITIES.entrySet()) {
new IdentityServiceConfigurator<>(entry.getValue().getServiceName(address), entry.getKey().getServiceName(context, name, defaultCache)).build(target).install();
}
if (!defaultCache.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
ServiceName lazyCacheServiceName = DEFAULT_CAPABILITIES.get(InfinispanCacheRequirement.CACHE).getServiceName(address).append("lazy");
new LazyCacheServiceConfigurator(lazyCacheServiceName, name, defaultCache).configure(context).build(target).install();
new BinderServiceConfigurator(InfinispanBindingFactory.createCacheBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME), lazyCacheServiceName).build(target).install();
new BinderServiceConfigurator(InfinispanBindingFactory.createCacheConfigurationBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME), DEFAULT_CAPABILITIES.get(InfinispanCacheRequirement.CONFIGURATION).getServiceName(address)).build(target).install();
}
new ProvidedIdentityCacheServiceConfigurator(name, null, defaultCache).configure(context).build(target).install();
}
}
@Override
public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
String name = context.getCurrentAddressValue();
String defaultCache = DEFAULT_CACHE.resolveModelAttribute(context, model).asString(null);
if (defaultCache != null) {
new ProvidedIdentityCacheServiceConfigurator(name, null, defaultCache).remove(context);
if (!defaultCache.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
context.removeService(InfinispanBindingFactory.createCacheBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME).getBinderServiceName());
context.removeService(InfinispanBindingFactory.createCacheConfigurationBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME).getBinderServiceName());
}
for (Capability capability : DEFAULT_CAPABILITIES.values()) {
context.removeService(capability.getServiceName(address));
}
}
context.removeService(InfinispanBindingFactory.createCacheContainerBinding(name).getBinderServiceName());
context.removeService(CacheContainerComponent.MODULES.getServiceName(address));
for (Capability capability : EnumSet.allOf(CacheContainerResourceDefinition.Capability.class)) {
context.removeService(capability.getServiceName(address));
}
context.removeService(new ServiceValueCaptorServiceConfigurator<>(this.containerRegistry.remove(CacheContainerResourceDefinition.Capability.CONTAINER.getServiceName(address))).getServiceName());
}
}
| 7,647
| 55.235294
| 286
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StoreMetric.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.CacheLoaderInterceptor;
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 store.
*
* @author Paul Ferraro
*/
@SuppressWarnings("rawtypes")
public enum StoreMetric implements Metric<CacheLoaderInterceptor> {
CACHE_LOADER_LOADS("cache-loader-loads", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) {
@Override
public ModelNode execute(CacheLoaderInterceptor interceptor) {
return new ModelNode(interceptor.getCacheLoaderLoads());
}
},
CACHE_LOADER_MISSES("cache-loader-misses", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) {
@Override
public ModelNode execute(CacheLoaderInterceptor interceptor) {
return new ModelNode(interceptor.getCacheLoaderMisses());
}
},
;
private final AttributeDefinition definition;
StoreMetric(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,596
| 38.348485
| 101
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InvalidationCacheResourceTransformer.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 InvalidationCacheResourceTransformer extends ClusteredCacheResourceTransformer {
InvalidationCacheResourceTransformer(ResourceTransformationDescriptionBuilder parent) {
super(parent.addChildResource(InvalidationCacheResourceDefinition.WILDCARD_PATH));
}
}
| 1,493
| 40.5
| 94
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ClusteredCacheResourceTransformer.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 ClusteredCacheResourceTransformer extends CacheResourceTransformer {
ClusteredCacheResourceTransformer(ResourceTransformationDescriptionBuilder builder) {
super(builder);
}
}
| 1,412
| 38.25
| 94
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TableResourceDefinition.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.ResourceDescriptor;
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.controller.AttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* @author Paul Ferraro
*/
public abstract class TableResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> {
static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE);
static PathElement pathElement(String value) {
return PathElement.pathElement("table", value);
}
enum Attribute implements org.jboss.as.clustering.controller.Attribute {
FETCH_SIZE("fetch-size", ModelType.INT, new ModelNode(100)),
CREATE_ON_START("create-on-start", ModelType.BOOLEAN, ModelNode.TRUE),
DROP_ON_STOP("drop-on-stop", ModelType.BOOLEAN, ModelNode.FALSE),
;
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;
}
}
enum ColumnAttribute implements org.jboss.as.clustering.controller.Attribute {
ID("id-column", "id", "VARCHAR"),
DATA("data-column", "datum", "BINARY"),
SEGMENT("segment-column", "segment", "INTEGER"),
TIMESTAMP("timestamp-column", "version", "BIGINT"),
;
private final org.jboss.as.clustering.controller.Attribute name;
private final org.jboss.as.clustering.controller.Attribute type;
private final AttributeDefinition definition;
ColumnAttribute(String name, String defaultName, String defaultType) {
this.name = new SimpleAttribute(new SimpleAttributeDefinitionBuilder("name", ModelType.STRING)
.setAllowExpression(true)
.setRequired(false)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setDefaultValue(new ModelNode(defaultName))
.build());
this.type = new SimpleAttribute(new SimpleAttributeDefinitionBuilder("type", ModelType.STRING)
.setAllowExpression(true)
.setRequired(false)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setDefaultValue(new ModelNode(defaultType))
.build());
this.definition = ObjectTypeAttributeDefinition.Builder.of(name, this.name.getDefinition(), this.type.getDefinition())
.setRequired(false)
.setSuffix("column")
.build();
}
org.jboss.as.clustering.controller.Attribute getColumnName() {
return this.name;
}
org.jboss.as.clustering.controller.Attribute getColumnType() {
return this.type;
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
}
private final org.jboss.as.clustering.controller.Attribute prefixAttribute;
TableResourceDefinition(PathElement path, org.jboss.as.clustering.controller.Attribute prefixAttribute) {
super(path, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(path, WILDCARD_PATH));
this.prefixAttribute = prefixAttribute;
}
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = parent.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver())
.addAttributes(this.prefixAttribute)
.addAttributes(Attribute.class)
.addAttributes(ColumnAttribute.class)
;
ResourceServiceHandler handler = new SimpleResourceServiceHandler(address -> new TableServiceConfigurator(this.prefixAttribute, address));
new SimpleResourceRegistrar(descriptor, handler).register(registration);
return registration;
}
}
| 6,126
| 43.722628
| 146
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/NoTransportResourceDefinition.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.UnaryOperator;
import org.jboss.as.controller.PathElement;
/**
* @author Paul Ferraro
*/
public class NoTransportResourceDefinition extends TransportResourceDefinition {
static final PathElement PATH = pathElement("none");
NoTransportResourceDefinition() {
super(PATH, UnaryOperator.identity(), new NoTransportServiceHandler());
}
}
| 1,463
| 36.538462
| 80
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ClusteredCacheServiceHandler.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.ResourceServiceConfiguratorFactory;
import org.wildfly.clustering.server.service.DistributedCacheServiceConfiguratorProvider;
/**
* @author Paul Ferraro
*/
public class ClusteredCacheServiceHandler extends CacheServiceHandler<DistributedCacheServiceConfiguratorProvider> {
ClusteredCacheServiceHandler(ResourceServiceConfiguratorFactory configuratorFactory) {
super(configuratorFactory, DistributedCacheServiceConfiguratorProvider.class);
}
}
| 1,584
| 41.837838
| 116
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheInvalidationInterceptorMetric.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.InvalidationInterceptor;
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 invalidation metrics.
* @author Paul Ferraro
*/
public enum CacheInvalidationInterceptorMetric implements Metric<InvalidationInterceptor> {
INVALIDATIONS("invalidations", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) {
@Override
public ModelNode execute(InvalidationInterceptor interceptor) {
return new ModelNode(interceptor.getInvalidations());
}
},
;
private final AttributeDefinition definition;
CacheInvalidationInterceptorMetric(String name, ModelType type, AttributeAccess.Flag metricType) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setStorageRuntime()
.build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
}
| 2,260
| 37.322034
| 102
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheServiceHandler.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.Capability.CACHE;
import static org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Capability.CONFIGURATION;
import static org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.ListAttribute.MODULES;
import static org.jboss.as.clustering.infinispan.subsystem.TransactionResourceDefinition.TransactionRequirement.XA_RESOURCE_RECOVERY_REGISTRY;
import java.util.Collections;
import java.util.EnumSet;
import org.jboss.as.clustering.controller.ModulesServiceConfigurator;
import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory;
import org.jboss.as.clustering.controller.ResourceServiceHandler;
import org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Capability;
import org.jboss.as.clustering.naming.BinderServiceConfigurator;
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.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.clustering.infinispan.service.CacheServiceConfigurator;
import org.wildfly.clustering.server.service.CacheServiceConfiguratorProvider;
import org.wildfly.clustering.server.service.ProvidedCacheServiceConfigurator;
import org.wildfly.clustering.service.IdentityServiceConfigurator;
/**
* @author Paul Ferraro
*/
public class CacheServiceHandler<P extends CacheServiceConfiguratorProvider> implements ResourceServiceHandler {
private final ResourceServiceConfiguratorFactory configuratorFactory;
private final Class<P> providerClass;
CacheServiceHandler(ResourceServiceConfiguratorFactory configuratorFactory, Class<P> providerClass) {
this.configuratorFactory = configuratorFactory;
this.providerClass = providerClass;
}
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress cacheAddress = context.getCurrentAddress();
PathAddress containerAddress = cacheAddress.getParent();
String containerName = containerAddress.getLastElement().getValue();
String cacheName = cacheAddress.getLastElement().getValue();
ServiceTarget target = context.getServiceTarget();
ServiceName moduleServiceName = CacheComponent.MODULES.getServiceName(cacheAddress);
if (model.hasDefined(MODULES.getName())) {
new ModulesServiceConfigurator(moduleServiceName, MODULES, Collections.emptyList()).configure(context, model).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
} else {
new IdentityServiceConfigurator<>(moduleServiceName, CacheContainerComponent.MODULES.getServiceName(containerAddress)).build(target).install();
}
this.configuratorFactory.createServiceConfigurator(cacheAddress).configure(context, model).build(target).install();
ServiceName cacheServiceName = CACHE.getServiceName(cacheAddress);
new CacheServiceConfigurator<>(cacheServiceName, containerName, cacheName).configure(context).build(target).install();
if (context.hasOptionalCapability(XA_RESOURCE_RECOVERY_REGISTRY.getName(), null, null)) {
new XAResourceRecoveryServiceConfigurator(cacheAddress).configure(context).build(target).install();
}
ServiceName lazyCacheServiceName = cacheServiceName.append("lazy");
new LazyCacheServiceConfigurator(lazyCacheServiceName, containerName, cacheName).configure(context).build(target).install();
new BinderServiceConfigurator(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName), CONFIGURATION.getServiceName(cacheAddress)).build(target).install();
new BinderServiceConfigurator(InfinispanBindingFactory.createCacheBinding(containerName, cacheName), lazyCacheServiceName).build(target).install();
new ProvidedCacheServiceConfigurator<>(this.providerClass, containerName, cacheName).configure(context).build(target).install();
}
@Override
public void removeServices(OperationContext context, ModelNode model) {
PathAddress cacheAddress = context.getCurrentAddress();
PathAddress containerAddress = cacheAddress.getParent();
String containerName = containerAddress.getLastElement().getValue();
String cacheName = cacheAddress.getLastElement().getValue();
new ProvidedCacheServiceConfigurator<>(this.providerClass, containerName, cacheName).remove(context);
context.removeService(InfinispanBindingFactory.createCacheBinding(containerName, cacheName).getBinderServiceName());
context.removeService(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName).getBinderServiceName());
context.removeService(new XAResourceRecoveryServiceConfigurator(cacheAddress).getServiceName());
context.removeService(CacheComponent.MODULES.getServiceName(cacheAddress));
for (Capability capability : EnumSet.allOf(Capability.class)) {
context.removeService(capability.getServiceName(cacheAddress));
}
}
}
| 6,388
| 53.144068
| 195
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StoreWriteBehindResourceDefinition.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.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.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/store=Z/write-behind=WRITE_BEHIND
*
* @author Richard Achmatowicz (c) 2011 Red Hat Inc.
*/
public class StoreWriteBehindResourceDefinition extends StoreWriteResourceDefinition {
static final PathElement PATH = pathElement("behind");
enum Attribute implements org.jboss.as.clustering.controller.Attribute {
MODIFICATION_QUEUE_SIZE("modification-queue-size", ModelType.INT, new ModelNode(1024)),
;
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;
}
}
StoreWriteBehindResourceDefinition() {
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(StoreWriteBehindServiceConfigurator::new);
new SimpleResourceRegistrar(descriptor, handler).register(registration);
return registration;
}
}
| 3,496
| 40.141176
| 116
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheOperationExecutor.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.function.Function;
import org.infinispan.Cache;
import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver;
import org.jboss.as.clustering.controller.FunctionExecutor;
import org.jboss.as.clustering.controller.FunctionExecutorRegistry;
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.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 CacheOperationExecutor<C> implements OperationExecutor<C>, Function<Cache<?, ?>, C> {
private final FunctionExecutorRegistry<Cache<?, ?>> executors;
private final BinaryCapabilityNameResolver resolver;
CacheOperationExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors) {
this(executors, BinaryCapabilityNameResolver.PARENT_CHILD);
}
CacheOperationExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors, BinaryCapabilityNameResolver resolver) {
this.executors = executors;
this.resolver = resolver;
}
@Override
public ModelNode execute(OperationContext context, ModelNode op, Operation<C> operation) throws OperationFailedException {
ServiceName name = InfinispanCacheRequirement.CACHE.getServiceName(context, this.resolver);
FunctionExecutor<Cache<?, ?>> executor = this.executors.get(name);
return (executor != null) ? executor.execute(new OperationFunction<>(context, op, this, operation)) : null;
}
}
| 2,831
| 43.25
| 126
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/StoreWriteThroughServiceConfigurator.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.AsyncStoreConfiguration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.jboss.as.controller.PathAddress;
/**
* @author Paul Ferraro
*/
public class StoreWriteThroughServiceConfigurator extends ComponentServiceConfigurator<AsyncStoreConfiguration> {
StoreWriteThroughServiceConfigurator(PathAddress address) {
super(CacheComponent.STORE_WRITE, address.getParent());
}
@Override
public AsyncStoreConfiguration get() {
return new ConfigurationBuilder().persistence().addSoftIndexFileStore().async().disable().create();
}
}
| 1,710
| 38.790698
| 113
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LockingResourceDefinition.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.util.concurrent.IsolationLevel;
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.operations.validation.EnumValidator;
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/locking=LOCKING
*
* @author Richard Achmatowicz (c) 2011 Red Hat Inc.
*/
public class LockingResourceDefinition extends ComponentResourceDefinition {
static final PathElement PATH = pathElement("locking");
enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> {
ACQUIRE_TIMEOUT("acquire-timeout", ModelType.LONG, new ModelNode(TimeUnit.SECONDS.toMillis(15))) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setMeasurementUnit(MeasurementUnit.MILLISECONDS);
}
},
CONCURRENCY("concurrency-level", ModelType.INT, new ModelNode(1000)) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setDeprecated(InfinispanSubsystemModel.VERSION_17_0_0.getVersion());
}
},
ISOLATION("isolation", ModelType.STRING, new ModelNode(IsolationLevel.READ_COMMITTED.name())) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setValidator(EnumValidator.create(IsolationLevel.class));
}
},
STRIPING("striping", ModelType.BOOLEAN, ModelNode.FALSE),
;
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;
}
}
LockingResourceDefinition() {
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(LockingServiceConfigurator::new);
new SimpleResourceRegistrar(descriptor, handler).register(registration);
return registration;
}
}
| 4,866
| 43.245455
| 133
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/MemoryServiceConfigurator.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.ConfigurationBuilder;
import org.infinispan.configuration.cache.MemoryConfiguration;
import org.infinispan.configuration.cache.MemoryConfigurationBuilder;
import org.infinispan.configuration.cache.StorageType;
import org.infinispan.eviction.EvictionStrategy;
import org.jboss.as.clustering.controller.Attribute;
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 MemoryServiceConfigurator extends ComponentServiceConfigurator<MemoryConfiguration> {
private final StorageType storageType;
private final Attribute sizeUnitAttribute;
private volatile long size;
private volatile MemorySizeUnit unit;
MemoryServiceConfigurator(StorageType storageType, PathAddress address, Attribute sizeUnitAttribute) {
super(CacheComponent.MEMORY, address);
this.storageType = storageType;
this.sizeUnitAttribute = sizeUnitAttribute;
}
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.size = MemoryResourceDefinition.Attribute.SIZE.resolveModelAttribute(context, model).asLong(-1L);
this.unit = MemorySizeUnit.valueOf(this.sizeUnitAttribute.resolveModelAttribute(context, model).asString());
return this;
}
@Override
public MemoryConfiguration get() {
EvictionStrategy strategy = this.size > 0 ? EvictionStrategy.REMOVE : EvictionStrategy.MANUAL;
MemoryConfigurationBuilder builder = new ConfigurationBuilder().memory()
.storage(this.storageType)
.whenFull(strategy)
;
if (strategy.isEnabled()) {
if (this.unit == MemorySizeUnit.ENTRIES) {
builder.maxCount(this.size);
} else {
builder.maxSize(Long.toString(this.unit.applyAsLong(this.size)));
}
}
return builder.create();
}
}
| 3,251
| 41.233766
| 117
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanSubsystemResourceTransformer.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.Function;
import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceTransformer;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder;
import org.jboss.as.controller.transform.description.TransformationDescription;
import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder;
/**
* Transformer for the Infinispan subsystem resource.
* @author Paul Ferraro
*/
public class InfinispanSubsystemResourceTransformer implements Function<ModelVersion, TransformationDescription> {
private final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
@Override
public TransformationDescription apply(ModelVersion version) {
new CacheContainerResourceTransformer(this.builder).accept(version);
new RemoteCacheContainerResourceTransformer(this.builder).accept(version);
return this.builder.build();
}
}
| 2,152
| 42.06
| 136
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerServiceConfigurator.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 static org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Capability.CONTAINER;
import static org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.ListAttribute.ALIASES;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;
import org.infinispan.Cache;
import org.infinispan.configuration.global.GlobalConfiguration;
import org.infinispan.configuration.global.GlobalConfigurationBuilder;
import org.infinispan.configuration.parsing.ConfigurationBuilderHolder;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.notifications.Listener;
import org.infinispan.notifications.cachemanagerlistener.annotation.CacheStarted;
import org.infinispan.notifications.cachemanagerlistener.annotation.CacheStopped;
import org.infinispan.notifications.cachemanagerlistener.event.CacheStartedEvent;
import org.infinispan.notifications.cachemanagerlistener.event.CacheStoppedEvent;
import org.infinispan.util.concurrent.BlockingManager;
import org.jboss.as.clustering.controller.CapabilityServiceNameProvider;
import org.jboss.as.clustering.controller.ResourceServiceConfigurator;
import org.jboss.as.clustering.controller.ServiceValueCaptor;
import org.jboss.as.clustering.controller.ServiceValueRegistry;
import org.jboss.as.clustering.infinispan.logging.InfinispanLogger;
import org.jboss.as.clustering.infinispan.manager.DefaultCacheContainer;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.server.Services;
import org.jboss.dmr.ModelNode;
import org.jboss.modules.ModuleLoader;
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.Registrar;
import org.wildfly.clustering.Registration;
import org.wildfly.clustering.infinispan.service.InfinispanRequirement;
import org.wildfly.clustering.service.AsyncServiceConfigurator;
import org.wildfly.clustering.service.CompositeDependency;
import org.wildfly.clustering.service.FunctionalService;
import org.wildfly.clustering.service.ServiceSupplierDependency;
import org.wildfly.clustering.service.SupplierDependency;
/**
* @author Paul Ferraro
*/
@Listener
public class CacheContainerServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, UnaryOperator<EmbeddedCacheManager>, Supplier<EmbeddedCacheManager>, Consumer<EmbeddedCacheManager> {
private final ServiceValueRegistry<Cache<?, ?>> registry;
private final Map<String, Registration> registrations = new ConcurrentHashMap<>();
private final PathAddress address;
private final String name;
private final SupplierDependency<GlobalConfiguration> configuration;
private final SupplierDependency<ModuleLoader> loader;
private volatile Registrar<String> registrar;
private volatile ServiceName[] names;
public CacheContainerServiceConfigurator(PathAddress address, ServiceValueRegistry<Cache<?, ?>> registry) {
super(CONTAINER, address);
this.address = address;
this.name = address.getLastElement().getValue();
this.configuration = new ServiceSupplierDependency<>(CacheContainerResourceDefinition.Capability.CONFIGURATION.getServiceName(address));
this.loader = new ServiceSupplierDependency<>(Services.JBOSS_SERVICE_MODULE_LOADER);
this.registry = registry;
}
@Override
public EmbeddedCacheManager apply(EmbeddedCacheManager manager) {
return new DefaultCacheContainer(manager, this.loader.get());
}
@Override
public EmbeddedCacheManager get() {
GlobalConfiguration config = this.configuration.get();
String defaultCacheName = config.defaultCacheName().orElse(null);
ConfigurationBuilderHolder holder = new ConfigurationBuilderHolder(config.classLoader(), new GlobalConfigurationBuilder().read(config));
// We need to create a dummy default configuration if cache has a default cache
if (defaultCacheName != null) {
holder.newConfigurationBuilder(defaultCacheName);
}
EmbeddedCacheManager manager = new DefaultCacheManager(holder, false);
// Undefine the default cache, if we defined one
if (defaultCacheName != null) {
manager.undefineConfiguration(defaultCacheName);
}
manager.start();
manager.addListener(this);
InfinispanLogger.ROOT_LOGGER.debugf("%s cache container started", this.name);
return manager;
}
@Override
public void accept(EmbeddedCacheManager manager) {
manager.removeListener(this);
manager.stop();
InfinispanLogger.ROOT_LOGGER.debugf("%s cache container stopped", this.name);
}
@Override
public CacheContainerServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
List<ModelNode> aliases = ALIASES.resolveModelAttribute(context, model).asListOrEmpty();
this.names = new ServiceName[aliases.size() + 1];
this.names[0] = this.getServiceName();
for (int i = 0; i < aliases.size(); ++i) {
this.names[i + 1] = InfinispanRequirement.CONTAINER.getServiceName(context.getCapabilityServiceSupport(), aliases.get(i).asString());
}
this.registrar = (CacheContainerResource) context.readResource(PathAddress.EMPTY_ADDRESS);
return this;
}
@Override
public ServiceBuilder<?> build(ServiceTarget target) {
ServiceBuilder<?> builder = new AsyncServiceConfigurator(this.getServiceName()).build(target);
Consumer<EmbeddedCacheManager> container = new CompositeDependency(this.configuration, this.loader).register(builder).provides(this.names);
Service service = new FunctionalService<>(container, this, this, this);
return builder.setInstance(service).setInitialMode(ServiceController.Mode.PASSIVE);
}
private ServiceName createCacheServiceName(String cacheName) {
return CacheResourceDefinition.Capability.CACHE.getServiceName(this.address.append(CacheRuntimeResourceDefinition.pathElement(cacheName)));
}
@CacheStarted
public CompletionStage<Void> cacheStarted(CacheStartedEvent event) {
String cacheName = event.getCacheName();
InfinispanLogger.ROOT_LOGGER.cacheStarted(cacheName, this.name);
this.registrations.put(cacheName, this.registrar.register(cacheName));
ServiceValueCaptor<Cache<?, ?>> captor = this.registry.add(this.createCacheServiceName(cacheName));
EmbeddedCacheManager container = event.getCacheManager();
// Use getCacheAsync(), once available
@SuppressWarnings("deprecation")
BlockingManager blocking = container.getGlobalComponentRegistry().getComponent(BlockingManager.class);
blocking.asExecutor(event.getCacheName()).execute(() -> captor.accept(container.getCache(cacheName)));
return CompletableFuture.completedStage(null);
}
@CacheStopped
public CompletionStage<Void> cacheStopped(CacheStoppedEvent event) {
String cacheName = event.getCacheName();
ServiceValueCaptor<Cache<?, ?>> captor = this.registry.remove(this.createCacheServiceName(cacheName));
if (captor != null) {
captor.accept(null);
}
try (Registration registration = this.registrations.remove(cacheName)) {
InfinispanLogger.ROOT_LOGGER.cacheStopped(cacheName, this.name);
}
return CompletableFuture.completedStage(null);
}
}
| 9,089
| 48.672131
| 226
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanSubsystemServiceHandler.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.clustering.infinispan.logging.InfinispanLogger;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.clustering.jgroups.spi.JGroupsRequirement;
import org.wildfly.clustering.server.service.LocalGroupServiceConfiguratorProvider;
import org.wildfly.clustering.server.service.ProvidedGroupServiceConfigurator;
import org.wildfly.clustering.server.service.ProvidedIdentityGroupServiceConfigurator;
/**
* @author Paul Ferraro
*/
public class InfinispanSubsystemServiceHandler implements ResourceServiceHandler {
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
InfinispanLogger.ROOT_LOGGER.activatingSubsystem();
ServiceTarget target = context.getServiceTarget();
// Install local group services
new ProvidedGroupServiceConfigurator<>(LocalGroupServiceConfiguratorProvider.class, LocalGroupServiceConfiguratorProvider.LOCAL).configure(context).build(target).install();
// If JGroups subsystem is not available, install default group aliases to local group.
if (!context.hasOptionalCapability(JGroupsRequirement.CHANNEL.getDefaultRequirement().getName(), null, null)) {
new ProvidedIdentityGroupServiceConfigurator(null, LocalGroupServiceConfiguratorProvider.LOCAL).configure(context).build(target).install();
}
}
@Override
public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException {
new ProvidedGroupServiceConfigurator<>(LocalGroupServiceConfiguratorProvider.class, LocalGroupServiceConfiguratorProvider.LOCAL).remove(context);
if (!context.hasOptionalCapability(JGroupsRequirement.CHANNEL.getDefaultRequirement().getName(), null, null)) {
new ProvidedIdentityGroupServiceConfigurator(null, LocalGroupServiceConfiguratorProvider.LOCAL).remove(context);
}
}
}
| 3,216
| 47.742424
| 180
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheMetric.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.function.UnaryOperator;
import org.infinispan.interceptors.impl.CacheMgmtInterceptor;
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 cache.
* @author Paul Ferraro
*/
public enum CacheMetric implements Metric<CacheMgmtInterceptor>, UnaryOperator<SimpleAttributeDefinitionBuilder> {
AVERAGE_READ_TIME("average-read-time", ModelType.LONG, MeasurementUnit.MILLISECONDS) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getAverageReadTime());
}
},
AVERAGE_REMOVE_TIME("average-remove-time", ModelType.LONG, MeasurementUnit.MILLISECONDS) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getAverageRemoveTime());
}
},
AVERAGE_WRITE_TIME("average-write-time", ModelType.LONG, MeasurementUnit.MILLISECONDS) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getAverageWriteTime());
}
},
EVICTIONS("evictions", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getEvictions());
}
},
HIT_RATIO("hit-ratio", ModelType.DOUBLE, AttributeAccess.Flag.GAUGE_METRIC) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getHitRatio());
}
},
HITS("hits", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getHits());
}
},
MISSES("misses", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getMisses());
}
},
@Deprecated NUMBER_OF_ENTRIES("number-of-entries", ModelType.INT, AttributeAccess.Flag.GAUGE_METRIC) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getNumberOfEntries());
}
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setDeprecated(InfinispanSubsystemModel.VERSION_16_0_0.getVersion());
}
},
@Deprecated NUMBER_OF_ENTRIES_IN_MEMORY("number-of-entries-in-memory", ModelType.INT, AttributeAccess.Flag.GAUGE_METRIC) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getNumberOfEntriesInMemory());
}
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setDeprecated(InfinispanSubsystemModel.VERSION_16_0_0.getVersion());
}
},
READ_WRITE_RATIO("read-write-ratio", ModelType.DOUBLE, AttributeAccess.Flag.GAUGE_METRIC) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getReadWriteRatio());
}
},
REMOVE_HITS("remove-hits", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getRemoveHits());
}
},
REMOVE_MISSES("remove-misses", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getRemoveMisses());
}
},
TIME_SINCE_RESET("time-since-reset", ModelType.LONG, MeasurementUnit.SECONDS) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getTimeSinceReset());
}
},
TIME_SINCE_START("time-since-start", ModelType.LONG, MeasurementUnit.SECONDS) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getTimeSinceStart());
}
},
WRITES("writes", ModelType.LONG, AttributeAccess.Flag.COUNTER_METRIC) {
@Override
public ModelNode execute(CacheMgmtInterceptor interceptor) {
return new ModelNode(interceptor.getStores());
}
},
;
private final AttributeDefinition definition;
CacheMetric(String name, ModelType type, AttributeAccess.Flag metricType) {
this(name, type, metricType, null);
}
CacheMetric(String name, ModelType type, MeasurementUnit unit) {
this(name, type, AttributeAccess.Flag.GAUGE_METRIC, unit);
}
CacheMetric(String name, ModelType type, AttributeAccess.Flag metricType, MeasurementUnit unit) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setFlags(metricType)
.setMeasurementUnit(unit)
.setStorageRuntime()
.build();
}
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder;
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
}
| 6,956
| 40.16568
| 126
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/BackupsResourceDefinition.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.Cache;
import org.jboss.as.clustering.controller.ManagementResourceRegistration;
import org.jboss.as.clustering.controller.ParentResourceServiceHandler;
import org.jboss.as.clustering.controller.ResourceDescriptor;
import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory;
import org.jboss.as.clustering.controller.FunctionExecutorRegistry;
import org.jboss.as.clustering.controller.ResourceServiceHandler;
import org.jboss.as.clustering.controller.SimpleResourceRegistrar;
import org.jboss.as.controller.PathElement;
/**
* Definition of a backups resource.
*
* /subsystem=infinispan/cache-container=X/cache=Y/component=backups
*
* @author Paul Ferraro
*/
public class BackupsResourceDefinition extends ComponentResourceDefinition {
static final PathElement PATH = pathElement("backups");
private final FunctionExecutorRegistry<Cache<?, ?>> executors;
public BackupsResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) {
super(PATH);
this.executors = executors;
}
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = parent.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver());
ResourceServiceConfiguratorFactory serviceConfiguratorFactory = BackupsServiceConfigurator::new;
ResourceServiceHandler handler = new ParentResourceServiceHandler(serviceConfiguratorFactory);
new SimpleResourceRegistrar(descriptor, handler).register(registration);
new BackupResourceDefinition(serviceConfiguratorFactory, this.executors).register(registration);
return registration;
}
}
| 2,871
| 41.865672
| 104
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/NoTransportServiceConfigurator.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.global.GlobalConfigurationBuilder;
import org.infinispan.configuration.global.TransportConfiguration;
import org.jboss.as.controller.PathAddress;
import org.jboss.msc.service.ServiceController;
/**
* @author Paul Ferraro
*/
public class NoTransportServiceConfigurator extends GlobalComponentServiceConfigurator<TransportConfiguration> {
NoTransportServiceConfigurator(PathAddress address) {
super(CacheContainerComponent.TRANSPORT, address, ServiceController.Mode.ON_DEMAND);
}
@Override
public TransportConfiguration get() {
return new GlobalConfigurationBuilder().transport().transport(null).create();
}
}
| 1,764
| 39.113636
| 112
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/SegmentedCacheServiceConfigurator.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 static org.jboss.as.clustering.infinispan.subsystem.SegmentedCacheResourceDefinition.Attribute.SEGMENTS;
import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.global.GlobalConfiguration;
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.ServiceConfigurator;
import org.wildfly.clustering.service.ServiceSupplierDependency;
import org.wildfly.clustering.service.SupplierDependency;
/**
* @author Paul Ferraro
*/
public class SegmentedCacheServiceConfigurator extends SharedStateCacheServiceConfigurator {
private final SupplierDependency<GlobalConfiguration> global;
private volatile int segments;
SegmentedCacheServiceConfigurator(PathAddress address, CacheMode mode) {
super(address, mode);
this.global = new ServiceSupplierDependency<>(CacheContainerResourceDefinition.Capability.CONFIGURATION.getServiceName(address.getParent()));
}
@Override
public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) {
return super.register(this.global.register(builder));
}
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.segments = SEGMENTS.resolveModelAttribute(context, model).asInt();
return super.configure(context, model);
}
@Override
public void accept(ConfigurationBuilder builder) {
super.accept(builder);
builder.clustering().hash().numSegments(this.segments);
}
}
| 2,871
| 38.888889
| 149
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/DistributedCacheServiceConfigurator.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.DistributedCacheResourceDefinition.Attribute.CAPACITY_FACTOR;
import static org.jboss.as.clustering.infinispan.subsystem.DistributedCacheResourceDefinition.Attribute.L1_LIFESPAN;
import static org.jboss.as.clustering.infinispan.subsystem.DistributedCacheResourceDefinition.Attribute.OWNERS;
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 for a distributed cache.
* @author Paul Ferraro
*/
public class DistributedCacheServiceConfigurator extends SegmentedCacheServiceConfigurator {
private volatile float capacityFactor;
private volatile int owners;
private volatile long l1Lifespan;
DistributedCacheServiceConfigurator(PathAddress address) {
super(address, CacheMode.DIST_SYNC);
}
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.capacityFactor = (float) CAPACITY_FACTOR.resolveModelAttribute(context, model).asDouble();
this.l1Lifespan = L1_LIFESPAN.resolveModelAttribute(context, model).asLong();
this.owners = OWNERS.resolveModelAttribute(context, model).asInt();
return super.configure(context, model);
}
@Override
public void accept(ConfigurationBuilder builder) {
super.accept(builder);
builder.clustering()
.hash().capacityFactor(this.capacityFactor).numOwners(this.owners)
.l1().enabled(this.l1Lifespan > 0).lifespan(this.l1Lifespan)
;
}
}
| 2,968
| 41.414286
| 120
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InvalidationCacheResourceDefinition.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/invalidation-cache=*
*
* @author Richard Achmatowicz (c) 2011 Red Hat Inc.
*/
public class InvalidationCacheResourceDefinition extends ClusteredCacheResourceDefinition {
static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE);
static final PathElement pathElement(String name) {
return PathElement.pathElement("invalidation-cache", name);
}
InvalidationCacheResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) {
super(WILDCARD_PATH, UnaryOperator.identity(), new ClusteredCacheServiceHandler(InvalidationCacheServiceConfigurator::new), executors);
}
}
| 1,994
| 41.446809
| 143
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ClusteredCacheMetricExecutor.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.remoting.rpc.RpcManagerImpl;
import org.jboss.as.clustering.controller.FunctionExecutorRegistry;
/**
* Handler for clustered cache metrics.
*
* @author Paul Ferraro
*/
public class ClusteredCacheMetricExecutor extends CacheMetricExecutor<RpcManagerImpl> {
public ClusteredCacheMetricExecutor(FunctionExecutorRegistry<Cache<?, ?>> executors) {
super(executors);
}
@Override
public RpcManagerImpl apply(Cache<?, ?> cache) {
return (RpcManagerImpl) cache.getAdvancedCache().getRpcManager();
}
}
| 1,606
| 38.195122
| 90
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanExtension.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 io.netty.util.internal.logging.InternalLoggerFactory;
import io.netty.util.internal.logging.JdkLoggerFactory;
import org.jboss.as.clustering.controller.SubsystemExtension;
import org.jboss.as.controller.Extension;
import org.jboss.as.controller.descriptions.ParentResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.SubsystemResourceDescriptionResolver;
import org.kohsuke.MetaInfServices;
/**
* Extension that registers the Infinispan subsystem.
*
* @author Paul Ferraro
* @author Richard Achmatowicz
*/
@MetaInfServices(Extension.class)
public class InfinispanExtension extends SubsystemExtension<InfinispanSubsystemSchema> {
public static final String SUBSYSTEM_NAME = "infinispan";
public static final ParentResourceDescriptionResolver SUBSYSTEM_RESOLVER = new SubsystemResourceDescriptionResolver(SUBSYSTEM_NAME, InfinispanExtension.class);
public InfinispanExtension() {
super(SUBSYSTEM_NAME, InfinispanSubsystemModel.CURRENT, InfinispanSubsystemResourceDefinition::new, InfinispanSubsystemSchema.CURRENT, new InfinispanSubsystemXMLWriter());
// Initialize the Netty logger factory
InternalLoggerFactory.setDefaultFactory(JdkLoggerFactory.INSTANCE);
}
}
| 2,316
| 43.557692
| 179
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/FileStoreServiceConfigurator.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.persistence.sifs.configuration.SoftIndexFileStoreConfiguration;
import org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder;
import org.jboss.as.controller.PathAddress;
/**
* @author Paul Ferraro
*/
public class FileStoreServiceConfigurator extends StoreServiceConfigurator<SoftIndexFileStoreConfiguration, SoftIndexFileStoreConfigurationBuilder> {
FileStoreServiceConfigurator(PathAddress address) {
super(address, SoftIndexFileStoreConfigurationBuilder.class);
}
@Override
public void accept(SoftIndexFileStoreConfigurationBuilder builder) {
builder.segmented(true);
}
}
| 1,747
| 39.651163
| 149
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/SharedStateCacheResourceDefinition.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.ManagementResourceRegistration;
import org.jboss.as.clustering.controller.ResourceDescriptor;
import org.jboss.as.controller.PathElement;
/**
* Base class for cache resources which require common cache attributes, clustered cache attributes
* and shared cache attributes.
*
* @author Richard Achmatowicz (c) 2011 Red Hat Inc.
*/
public class SharedStateCacheResourceDefinition extends ClusteredCacheResourceDefinition {
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).addRequiredChildren(PartitionHandlingResourceDefinition.PATH, StateTransferResourceDefinition.PATH, BackupsResourceDefinition.PATH);
}
}
private final FunctionExecutorRegistry<Cache<?, ?>> executors;
SharedStateCacheResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ClusteredCacheServiceHandler handler, FunctionExecutorRegistry<Cache<?, ?>> executors) {
super(path, new ResourceDescriptorConfigurator(configurator), handler, executors);
this.executors = executors;
}
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = super.register(parent);
new PartitionHandlingResourceDefinition().register(registration);
new StateTransferResourceDefinition().register(registration);
new BackupsResourceDefinition(this.executors).register(registration);
return registration;
}
}
| 3,144
| 42.680556
| 193
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/FileStoreResourceDefinition.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.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.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.as.controller.services.path.PathManager;
import org.jboss.as.controller.services.path.ResolvePathHandler;
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 FileStoreResourceDefinition extends StoreResourceDefinition {
static final PathElement PATH = pathElement("file");
enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> {
RELATIVE_PATH("path", ModelType.STRING, InfinispanSubsystemModel.VERSION_16_0_0) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setAllowExpression(true);
}
},
RELATIVE_TO("relative-to", ModelType.STRING, InfinispanSubsystemModel.VERSION_16_0_0) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setCapabilityReference(new CapabilityReference(Capability.PERSISTENCE, CommonUnaryRequirement.PATH));
}
},
;
private final AttributeDefinition definition;
DeprecatedAttribute(String name, ModelType type, InfinispanSubsystemModel deprecation) {
this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type).setRequired(false).setDeprecated(deprecation.getVersion()).setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)).build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
}
FileStoreResourceDefinition() {
super(PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(PATH, WILDCARD_PATH), new SimpleResourceDescriptorConfigurator<>(DeprecatedAttribute.class), FileStoreServiceConfigurator::new);
}
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = super.register(parent);
PathManager pathManager = registration.getPathManager().orElse(null);
if (pathManager != null) {
ResolvePathHandler pathHandler = ResolvePathHandler.Builder.of(pathManager)
.setPathAttribute(DeprecatedAttribute.RELATIVE_PATH.getDefinition())
.setRelativeToAttribute(DeprecatedAttribute.RELATIVE_TO.getDefinition())
.setDeprecated(DeprecatedAttribute.RELATIVE_TO.getDefinition().getDeprecationData().getSince())
.build();
registration.registerOperationHandler(pathHandler.getOperationDefinition(), pathHandler);
}
return registration;
}
}
| 4,528
| 46.673684
| 215
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/PartitionHandlingOperation.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.partitionhandling.AvailabilityMode;
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;
/**
* Enumerates partition handling operations.
* @author Paul Ferraro
*/
public enum PartitionHandlingOperation implements Operation<AdvancedCache<?, ?>> {
FORCE_AVAILABLE("force-available") {
@Override
public ModelNode execute(ExpressionResolver expressionResolver, ModelNode operation, AdvancedCache<?, ?> cache) {
cache.setAvailability(AvailabilityMode.AVAILABLE);
return null;
}
},
;
private final OperationDefinition definition;
PartitionHandlingOperation(String name) {
this.definition = new SimpleOperationDefinitionBuilder(name, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(PartitionHandlingRuntimeResourceDefinition.PATH))
.setRuntimeOnly()
.build();
}
@Override
public OperationDefinition getDefinition() {
return this.definition;
}
}
| 2,326
| 37.783333
| 177
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/HotRodStoreResourceTransformer.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 HotRodStoreResourceTransformer extends StoreResourceTransformer {
HotRodStoreResourceTransformer(ResourceTransformationDescriptionBuilder parent) {
super(parent.addChildResource(HotRodStoreResourceDefinition.PATH));
}
}
| 1,457
| 39.5
| 94
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanSubsystemSchema.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.List;
import javax.xml.stream.XMLStreamException;
import org.jboss.as.controller.SubsystemSchema;
import org.jboss.as.controller.xml.VersionedNamespace;
import org.jboss.dmr.ModelNode;
import org.jboss.staxmapper.IntVersion;
import org.jboss.staxmapper.XMLExtendedStreamReader;
/**
* Enumeration of the supported subsystem xml schemas.
* @author Paul Ferraro
*/
public enum InfinispanSubsystemSchema implements SubsystemSchema<InfinispanSubsystemSchema> {
/* Unsupported, for documentation purposes only.
VERSION_1_0(1, 0), // AS 7.0
VERSION_1_1(1, 1), // AS 7.1.0
VERSION_1_2(1, 2), // AS 7.1.1
VERSION_1_3(1, 3), // AS 7.1.2
VERSION_1_4(1, 4), // AS 7.2.0
*/
VERSION_1_5(1, 5), // EAP 6.3
VERSION_2_0(2, 0), // WildFly 8
VERSION_3_0(3, 0), // WildFly 9
VERSION_4_0(4, 0), // WildFly 10/11
VERSION_5_0(5, 0), // WildFly 12
VERSION_6_0(6, 0), // WildFly 13
VERSION_7_0(7, 0), // WildFly 14-15
VERSION_8_0(8, 0), // WildFly 16
VERSION_9_0(9, 0), // WildFly 17-19
VERSION_9_1(9, 1), // EAP 7.3.4
VERSION_10_0(10, 0), // WildFly 20
VERSION_11_0(11, 0), // WildFly 21
VERSION_12_0(12, 0), // WildFly 23, EAP 7.4
VERSION_13_0(13, 0), // WildFly 24-26
VERSION_14_0(14, 0), // WildFly 27-present
;
static final InfinispanSubsystemSchema CURRENT = VERSION_14_0;
private final VersionedNamespace<IntVersion, InfinispanSubsystemSchema> namespace;
InfinispanSubsystemSchema(int major, int minor) {
this.namespace = SubsystemSchema.createLegacySubsystemURN(InfinispanExtension.SUBSYSTEM_NAME, new IntVersion(major, minor));
}
@Override
public VersionedNamespace<IntVersion, InfinispanSubsystemSchema> getNamespace() {
return this.namespace;
}
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException {
new InfinispanSubsystemXMLReader(this).readElement(reader, operations);
}
}
| 3,083
| 37.55
| 132
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/PartitionHandlingMetric.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.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;
/**
* Enumerates partition handling metrics.
* @author Paul Ferraro
*/
public enum PartitionHandlingMetric implements Metric<AdvancedCache<?, ?>> {
AVAILABILITY("availability", ModelType.STRING, AttributeAccess.Flag.GAUGE_METRIC) {
@Override
public ModelNode execute(AdvancedCache<?, ?> cache) {
return new ModelNode(cache.getAvailability().name());
}
},
;
private final AttributeDefinition definition;
PartitionHandlingMetric(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,243
| 36.4
| 91
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/BackupResourceDefinition.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.configuration.cache.BackupConfiguration.BackupStrategy;
import org.infinispan.Cache;
import org.infinispan.configuration.cache.BackupFailurePolicy;
import org.jboss.as.clustering.controller.ChildResourceDefinition;
import org.jboss.as.clustering.controller.ManagementResourceRegistration;
import org.jboss.as.clustering.controller.OperationHandler;
import org.jboss.as.clustering.controller.ResourceDescriptor;
import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory;
import org.jboss.as.clustering.controller.FunctionExecutorRegistry;
import org.jboss.as.clustering.controller.RestartParentResourceRegistrar;
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.operations.validation.EnumValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* Definition of a backup site resource.
*
* @author Paul Ferraro
*/
public class BackupResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> {
static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE);
static PathElement pathElement(String name) {
return PathElement.pathElement("backup", name);
}
enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> {
FAILURE_POLICY("failure-policy", ModelType.STRING, new ModelNode(BackupFailurePolicy.WARN.name())) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setValidator(EnumValidator.create(BackupFailurePolicy.class));
}
},
STRATEGY("strategy", ModelType.STRING, new ModelNode(BackupStrategy.ASYNC.name())) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setValidator(EnumValidator.create(BackupStrategy.class));
}
},
TIMEOUT("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 = 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;
}
}
enum TakeOfflineAttribute implements org.jboss.as.clustering.controller.Attribute {
AFTER_FAILURES("after-failures", ModelType.INT, new ModelNode(1)),
MIN_WAIT("min-wait", ModelType.LONG, ModelNode.ZERO_LONG),
;
private final AttributeDefinition definition;
TakeOfflineAttribute(String name, ModelType type, ModelNode defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setRequired(false)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
.build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
}
enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute {
ENABLED("enabled", 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 ResourceServiceConfiguratorFactory parentServiceConfiguratorFactory;
private final FunctionExecutorRegistry<Cache<?, ?>> executors;
BackupResourceDefinition(ResourceServiceConfiguratorFactory parentServiceConfiguratorFactory, FunctionExecutorRegistry<Cache<?, ?>> executors) {
super(WILDCARD_PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(WILDCARD_PATH));
this.parentServiceConfiguratorFactory = parentServiceConfiguratorFactory;
this.executors = executors;
}
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = parent.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver())
.addAttributes(Attribute.class)
.addAttributes(TakeOfflineAttribute.class)
.addAttributes(DeprecatedAttribute.class)
;
new RestartParentResourceRegistrar(this.parentServiceConfiguratorFactory, descriptor).register(registration);
if (registration.isRuntimeOnlyRegistrationValid()) {
new OperationHandler<>(new BackupOperationExecutor(this.executors), BackupOperation.class).register(registration);
}
return registration;
}
}
| 7,706
| 43.80814
| 148
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/SharedStateCacheResourceTransformer.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.ModelVersion;
import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder;
/**
* @author Paul Ferraro
*/
public class SharedStateCacheResourceTransformer extends ClusteredCacheResourceTransformer {
SharedStateCacheResourceTransformer(ResourceTransformationDescriptionBuilder builder) {
super(builder);
}
@Override
public void accept(ModelVersion version) {
super.accept(version);
new PartitionHandlingResourceTransformer(this.builder).accept(version);
}
}
| 1,650
| 36.522727
| 94
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/HotRodMarshallerFactory.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.remote;
import java.util.List;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import org.infinispan.commons.marshall.Marshaller;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleLoader;
import org.wildfly.clustering.infinispan.marshalling.MarshallerFactory;
/**
* @author Paul Ferraro
*/
public enum HotRodMarshallerFactory implements BiFunction<ModuleLoader, List<Module>, Marshaller> {
LEGACY() {
private final Set<String> protoStreamModules = Set.of("org.wildfly.clustering.web.hotrod");
private final Predicate<String> protoStreamPredicate = this.protoStreamModules::contains;
@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
// Choose marshaller based on the associated modules
return (modules.stream().map(Module::getName).anyMatch(this.protoStreamPredicate) ? PROTOSTREAM : JBOSS).apply(moduleLoader, modules);
}
},
JBOSS() {
@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
return MarshallerFactory.JBOSS.apply(moduleLoader, modules);
}
},
PROTOSTREAM() {
private final Set<String> clientModules = Set.of("org.infinispan.query.client");
private final Predicate<String> infinispanPredicate = this.clientModules::contains;
@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
// Use default ProtoStream marshaller if container uses remote query
return (modules.stream().map(Module::getName).anyMatch(this.infinispanPredicate) ? MarshallerFactory.DEFAULT : MarshallerFactory.PROTOSTREAM).apply(moduleLoader, modules);
}
},
;
}
| 2,878
| 41.338235
| 183
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheContainerResource.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.remote;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jboss.as.clustering.controller.ChildResourceProvider;
import org.jboss.as.clustering.controller.ComplexResource;
import org.jboss.as.clustering.controller.SimpleChildResourceProvider;
import org.jboss.as.controller.registry.Resource;
import org.wildfly.clustering.Registrar;
import org.wildfly.clustering.Registration;
/**
* @author Paul Ferraro
*/
public class RemoteCacheContainerResource extends ComplexResource implements Registrar<String> {
private static final String CHILD_TYPE = RemoteCacheResourceDefinition.WILDCARD_PATH.getKey();
public RemoteCacheContainerResource(Resource resource) {
this(resource, Collections.singletonMap(CHILD_TYPE, new SimpleChildResourceProvider(ConcurrentHashMap.newKeySet())));
}
private RemoteCacheContainerResource(Resource resource, Map<String, ChildResourceProvider> providers) {
super(resource, providers, RemoteCacheContainerResource::new);
}
@Override
public Registration register(String cache) {
ChildResourceProvider handler = this.apply(CHILD_TYPE);
handler.getChildren().add(cache);
return new Registration() {
@Override
public void close() {
handler.getChildren().remove(cache);
}
};
}
}
| 2,474
| 38.285714
| 125
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheContainerResourceTransformer.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.remote;
import java.util.function.Consumer;
import org.jboss.as.clustering.infinispan.subsystem.InfinispanSubsystemModel;
import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition.Attribute;
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;
/**
* Transformer for remote cache container resources.
* @author Paul Ferraro
*/
public class RemoteCacheContainerResourceTransformer implements Consumer<ModelVersion> {
private final ResourceTransformationDescriptionBuilder builder;
public RemoteCacheContainerResourceTransformer(ResourceTransformationDescriptionBuilder parent) {
this.builder = parent.addChildResource(RemoteCacheContainerResourceDefinition.WILDCARD_PATH);
}
@Override
public void accept(ModelVersion version) {
if (InfinispanSubsystemModel.VERSION_16_0_0.requiresTransformation(version)) {
this.builder.getAttributeBuilder()
.setValueConverter(AttributeConverter.DEFAULT_VALUE, Attribute.PROTOCOL_VERSION.getDefinition())
.end();
}
if (InfinispanSubsystemModel.VERSION_15_0_0.requiresTransformation(version)) {
this.builder.getAttributeBuilder()
.setDiscard(DiscardAttributeChecker.ALWAYS, Attribute.TRANSACTION_TIMEOUT.getDefinition())
.setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, Attribute.MARSHALLER.getDefinition())
.addRejectCheck(new RejectAttributeChecker.SimpleAcceptAttributeChecker(Attribute.MARSHALLER.getDefinition().getDefaultValue()), Attribute.MARSHALLER.getDefinition())
.end();
}
}
}
| 3,071
| 47.761905
| 186
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheContainerResourceDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.remote;
import java.util.EnumSet;
import java.util.concurrent.TimeUnit;
import java.util.function.UnaryOperator;
import org.infinispan.client.hotrod.ProtocolVersion;
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.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.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.clustering.infinispan.subsystem.InfinispanExtension;
import org.jboss.as.clustering.infinispan.subsystem.InfinispanSubsystemModel;
import org.jboss.as.clustering.infinispan.subsystem.ThreadPoolResourceDefinition;
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.client.helpers.MeasurementUnit;
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.client.RemoteCacheContainer;
import org.wildfly.clustering.infinispan.client.service.InfinispanClientRequirement;
import org.wildfly.clustering.service.UnaryRequirement;
/**
* /subsystem=infinispan/remote-cache-container=X
*
* @author Radoslav Husar
*/
public class RemoteCacheContainerResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> {
public static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE);
public static PathElement pathElement(String containerName) {
return PathElement.pathElement("remote-cache-container", containerName);
}
public enum Capability implements CapabilityProvider {
CONTAINER(InfinispanClientRequirement.REMOTE_CONTAINER),
CONFIGURATION(InfinispanClientRequirement.REMOTE_CONTAINER_CONFIGURATION),
;
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;
}
}
public enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> {
CONNECTION_TIMEOUT("connection-timeout", ModelType.INT, new ModelNode(60000)),
DEFAULT_REMOTE_CLUSTER("default-remote-cluster", ModelType.STRING, null) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setAllowExpression(false).setCapabilityReference(new CapabilityReference(Capability.CONFIGURATION, RemoteClusterResourceDefinition.Requirement.REMOTE_CLUSTER, WILDCARD_PATH));
}
},
MARSHALLER("marshaller", ModelType.STRING, new ModelNode(HotRodMarshallerFactory.LEGACY.name())) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setValidator(new ParameterValidator() {
private final ParameterValidator validator = EnumValidator.create(HotRodMarshallerFactory.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, HotRodMarshallerFactory.LEGACY, EnumSet.complementOf(EnumSet.of(HotRodMarshallerFactory.LEGACY)));
}
}
});
}
},
MAX_RETRIES("max-retries", ModelType.INT, new ModelNode(10)),
PROPERTIES("properties"),
PROTOCOL_VERSION("protocol-version", ModelType.STRING, new ModelNode(ProtocolVersion.PROTOCOL_VERSION_40.toString())) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setValidator(new org.jboss.as.controller.operations.validation.EnumValidator<>(ProtocolVersion.class, EnumSet.complementOf(EnumSet.of(ProtocolVersion.PROTOCOL_VERSION_AUTO))));
}
},
SOCKET_TIMEOUT("socket-timeout", ModelType.INT, new ModelNode(60000)),
STATISTICS_ENABLED(ModelDescriptionConstants.STATISTICS_ENABLED, ModelType.BOOLEAN, ModelNode.FALSE),
TCP_NO_DELAY("tcp-no-delay", ModelType.BOOLEAN, ModelNode.TRUE),
TCP_KEEP_ALIVE("tcp-keep-alive", ModelType.BOOLEAN, ModelNode.FALSE),
TRANSACTION_TIMEOUT("transaction-timeout", ModelType.LONG, new ModelNode(TimeUnit.MINUTES.toMillis(1))) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setMeasurementUnit(MeasurementUnit.MILLISECONDS);
}
},
;
private final AttributeDefinition definition;
Attribute(String name) {
this.definition = new PropertiesAttributeDefinition.Builder(name)
.setAllowExpression(true)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.build();
}
Attribute(String name, ModelType type, ModelNode defaultValue) {
this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setRequired(defaultValue == null)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
).build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder;
}
}
public 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)
.setAllowExpression(true)
.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;
}
}
public enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> {
KEY_SIZE_ESTIMATE("key-size-estimate", ModelType.INT, InfinispanSubsystemModel.VERSION_15_0_0) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setDefaultValue(new ModelNode(64));
}
},
VALUE_SIZE_ESTIMATE("value-size-estimate", ModelType.INT, InfinispanSubsystemModel.VERSION_15_0_0) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setDefaultValue(new ModelNode(512));
}
}
;
private final AttributeDefinition definition;
DeprecatedAttribute(String name, ModelType type, InfinispanSubsystemModel deprecation) {
this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setRequired(false)
.setDeprecated(deprecation.getVersion())
.setFlags(AttributeAccess.Flag.RESTART_NONE)
).build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder;
}
}
public RemoteCacheContainerResourceDefinition() {
super(WILDCARD_PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(WILDCARD_PATH));
}
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parentRegistration) {
ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver())
.addAttributes(Attribute.class)
.addAttributes(ListAttribute.class)
.addAttributes(DeprecatedAttribute.class)
.addCapabilities(Capability.class)
.addRequiredChildren(ConnectionPoolResourceDefinition.PATH, ThreadPoolResourceDefinition.CLIENT.getPathElement(), SecurityResourceDefinition.PATH)
.setResourceTransformation(RemoteCacheContainerResource::new)
;
ServiceValueExecutorRegistry<RemoteCacheContainer> executors = new ServiceValueExecutorRegistry<>();
ResourceServiceConfiguratorFactory factory = RemoteCacheContainerConfigurationServiceConfigurator::new;
ResourceServiceHandler handler = new RemoteCacheContainerServiceHandler(factory, executors);
new SimpleResourceRegistrar(descriptor, handler).register(registration);
new ConnectionPoolResourceDefinition().register(registration);
new RemoteClusterResourceDefinition(factory, executors).register(registration);
new SecurityResourceDefinition().register(registration);
ThreadPoolResourceDefinition.CLIENT.register(registration);
if (registration.isRuntimeOnlyRegistrationValid()) {
new MetricHandler<>(new RemoteCacheContainerMetricExecutor(executors), RemoteCacheContainerMetric.class).register(registration);
new RemoteCacheResourceDefinition(executors).register(registration);
}
return registration;
}
}
| 13,095
| 48.048689
| 207
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheResourceDefinition.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.remote;
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.clustering.infinispan.subsystem.InfinispanExtension;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.wildfly.clustering.infinispan.client.RemoteCacheContainer;
/**
* @author Paul Ferraro
*/
public class RemoteCacheResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> {
static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE);
static PathElement pathElement(String name) {
return PathElement.pathElement("remote-cache", name);
}
private final FunctionExecutorRegistry<RemoteCacheContainer> executors;
public RemoteCacheResourceDefinition(FunctionExecutorRegistry<RemoteCacheContainer> 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 RemoteCacheMetricExecutor(this.executors), RemoteCacheMetric.class).register(registration);
new OperationHandler<>(new RemoteCacheOperationExecutor(this.executors), RemoteCacheOperation.class).register(registration);
return registration;
}
}
| 2,785
| 46.220339
| 133
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheMetric.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.remote;
import java.util.function.ToLongFunction;
import org.infinispan.client.hotrod.jmx.RemoteCacheClientStatisticsMXBean;
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.Flag;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* @author Paul Ferraro
*/
public enum RemoteCacheMetric implements Metric<RemoteCacheClientStatisticsMXBean>, ToLongFunction<RemoteCacheClientStatisticsMXBean> {
AVERAGE_READ_TIME("average-read-time", MeasurementUnit.MILLISECONDS) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getAverageRemoteReadTime();
}
},
AVERAGE_REMOVE_TIME("average-remove-time", MeasurementUnit.MILLISECONDS) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getAverageRemoteRemovesTime();
}
},
AVERAGE_WRITE_TIME("average-write-time", MeasurementUnit.MILLISECONDS) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getAverageRemoteStoreTime();
}
},
NEAR_CACHE_HITS("near-cache-hits", Flag.COUNTER_METRIC) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getNearCacheHits();
}
},
NEAR_CACHE_INVALIDATIONS("near-cache-invalidations", Flag.COUNTER_METRIC) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getNearCacheInvalidations();
}
},
NEAR_CACHE_MISSES("near-cache-misses", Flag.COUNTER_METRIC) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getNearCacheMisses();
}
},
NEAR_CACHE_SIZE("near-cache-size", Flag.GAUGE_METRIC) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getNearCacheSize();
}
},
HITS("hits", Flag.COUNTER_METRIC) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getRemoteHits();
}
},
MISSES("misses", Flag.COUNTER_METRIC) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getRemoteMisses();
}
},
REMOVES("removes", Flag.COUNTER_METRIC) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getRemoteRemoves();
}
},
WRITES("writes", Flag.COUNTER_METRIC) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getRemoteStores();
}
},
TIME_SINCE_RESET("time-since-reset", MeasurementUnit.SECONDS) {
@Override
public long applyAsLong(RemoteCacheClientStatisticsMXBean statistics) {
return statistics.getTimeSinceReset();
}
},
;
private final AttributeDefinition definition;
RemoteCacheMetric(String name, Flag metricType) {
this(name, metricType, null);
}
RemoteCacheMetric(String name, MeasurementUnit unit) {
this(name, Flag.GAUGE_METRIC, unit);
}
RemoteCacheMetric(String name, Flag metricType, MeasurementUnit unit) {
this.definition = new SimpleAttributeDefinitionBuilder(name, ModelType.LONG)
.setFlags(metricType)
.setMeasurementUnit(unit)
.setStorageRuntime()
.build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
@Override
public ModelNode execute(RemoteCacheClientStatisticsMXBean statistics) {
return new ModelNode(this.applyAsLong(statistics));
}
}
| 5,325
| 36.507042
| 135
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/SecurityServiceConfigurator.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.remote;
import static org.jboss.as.clustering.infinispan.subsystem.remote.SecurityResourceDefinition.Attribute.SSL_CONTEXT;
import javax.net.ssl.SSLContext;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.SecurityConfiguration;
import org.infinispan.client.hotrod.configuration.SecurityConfigurationBuilder;
import org.jboss.as.clustering.controller.CommonUnaryRequirement;
import org.jboss.as.clustering.infinispan.subsystem.ComponentServiceConfigurator;
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.ServiceConfigurator;
import org.wildfly.clustering.service.ServiceSupplierDependency;
import org.wildfly.clustering.service.SupplierDependency;
/**
* @author Radoslav Husar
*/
public class SecurityServiceConfigurator extends ComponentServiceConfigurator<SecurityConfiguration> {
private volatile SupplierDependency<SSLContext> sslContextDependency;
SecurityServiceConfigurator(PathAddress address) {
super(RemoteCacheContainerComponent.SECURITY, address);
}
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
String sslContext = SSL_CONTEXT.resolveModelAttribute(context, model).asStringOrNull();
this.sslContextDependency = (sslContext != null) ? new ServiceSupplierDependency<>(CommonUnaryRequirement.SSL_CONTEXT.getServiceName(context, sslContext)) : null;
return this;
}
@Override
public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) {
return super.register((this.sslContextDependency != null) ? this.sslContextDependency.register(builder) : builder);
}
@Override
public SecurityConfiguration get() {
SecurityConfigurationBuilder securityBuilder = new ConfigurationBuilder().security();
SSLContext sslContext = (this.sslContextDependency != null) ? this.sslContextDependency.get() : null;
securityBuilder.ssl().sslContext(sslContext).enabled(sslContext != null);
return securityBuilder.create();
}
}
| 3,392
| 44.851351
| 170
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheContainerMetricExecutor.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.remote;
import org.infinispan.client.hotrod.jmx.RemoteCacheManagerMXBean;
import org.jboss.as.clustering.controller.FunctionExecutor;
import org.jboss.as.clustering.controller.FunctionExecutorRegistry;
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.UnaryCapabilityNameResolver;
import org.jboss.as.clustering.function.Functions;
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.client.RemoteCacheContainer;
import org.wildfly.clustering.infinispan.client.service.InfinispanClientRequirement;
/**
* @author Paul Ferraro
*/
public class RemoteCacheContainerMetricExecutor implements MetricExecutor<RemoteCacheManagerMXBean> {
private final FunctionExecutorRegistry<RemoteCacheContainer> executors;
public RemoteCacheContainerMetricExecutor(FunctionExecutorRegistry<RemoteCacheContainer> executors) {
this.executors = executors;
}
@Override
public ModelNode execute(OperationContext context, Metric<RemoteCacheManagerMXBean> metric) throws OperationFailedException {
ServiceName name = InfinispanClientRequirement.REMOTE_CONTAINER.getServiceName(context, UnaryCapabilityNameResolver.DEFAULT);
FunctionExecutor<RemoteCacheContainer> executor = this.executors.get(name);
return (executor != null) ? executor.execute(new MetricFunction<>(Functions.identity(), metric)) : null;
}
}
| 2,748
| 46.396552
| 133
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteClusterOperationExecutor.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.remote;
import java.util.AbstractMap;
import java.util.Map;
import java.util.function.Function;
import org.infinispan.client.hotrod.jmx.RemoteCacheManagerMXBean;
import org.jboss.as.clustering.controller.FunctionExecutor;
import org.jboss.as.clustering.controller.FunctionExecutorRegistry;
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.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.client.RemoteCacheContainer;
import org.wildfly.clustering.infinispan.client.service.InfinispanClientRequirement;
/**
* @author Paul Ferraro
*/
public class RemoteClusterOperationExecutor implements OperationExecutor<Map.Entry<String, RemoteCacheManagerMXBean>> {
private final FunctionExecutorRegistry<RemoteCacheContainer> executors;
public RemoteClusterOperationExecutor(FunctionExecutorRegistry<RemoteCacheContainer> executors) {
this.executors = executors;
}
@Override
public ModelNode execute(OperationContext context, ModelNode op, Operation<Map.Entry<String, RemoteCacheManagerMXBean>> operation) throws OperationFailedException {
ServiceName name = InfinispanClientRequirement.REMOTE_CONTAINER.getServiceName(context, UnaryCapabilityNameResolver.PARENT);
FunctionExecutor<RemoteCacheContainer> executor = this.executors.get(name);
Function<RemoteCacheContainer, Map.Entry<String, RemoteCacheManagerMXBean>> mapper = new Function<>() {
@Override
public Map.Entry<String, RemoteCacheManagerMXBean> apply(RemoteCacheContainer container) {
String cluster = context.getCurrentAddressValue();
return new AbstractMap.SimpleImmutableEntry<>(cluster, container);
}
};
return (executor != null) ? executor.execute(new OperationFunction<>(context, op, mapper, operation)) : null;
}
}
| 3,264
| 47.014706
| 168
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheContainerMetric.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.remote;
import java.util.function.ToIntFunction;
import org.infinispan.client.hotrod.jmx.RemoteCacheManagerMXBean;
import org.jboss.as.clustering.controller.Metric;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationFailedException;
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 RemoteCacheContainerMetric implements Metric<RemoteCacheManagerMXBean>, ToIntFunction<RemoteCacheManagerMXBean> {
ACTIVE_CONNECTIONS("active-connections") {
@Override
public int applyAsInt(RemoteCacheManagerMXBean manager) {
return manager.getActiveConnectionCount();
}
},
CONNECTIONS("connections") {
@Override
public int applyAsInt(RemoteCacheManagerMXBean manager) {
return manager.getConnectionCount();
}
},
IDLE_CONNECTIONS("idle-connections") {
@Override
public int applyAsInt(RemoteCacheManagerMXBean manager) {
return manager.getIdleConnectionCount();
}
}
;
private final AttributeDefinition definition;
RemoteCacheContainerMetric(String name) {
this.definition = new SimpleAttributeDefinitionBuilder(name, ModelType.INT)
.setFlags(AttributeAccess.Flag.GAUGE_METRIC)
.setStorageRuntime()
.build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
@Override
public ModelNode execute(RemoteCacheManagerMXBean manager) throws OperationFailedException {
return new ModelNode(this.applyAsInt(manager));
}
}
| 2,877
| 34.975
| 125
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/ConnectionPoolServiceConfigurator.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.remote;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.ConnectionPoolConfiguration;
import org.infinispan.client.hotrod.configuration.ExhaustedAction;
import org.jboss.as.clustering.infinispan.subsystem.ComponentServiceConfigurator;
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 Radoslav Husar
*/
public class ConnectionPoolServiceConfigurator extends ComponentServiceConfigurator<ConnectionPoolConfiguration> {
private volatile ExhaustedAction exhaustedAction;
private volatile int maxActive;
private volatile long maxWait;
private volatile long minEvictableIdleTime;
private volatile int minIdle;
ConnectionPoolServiceConfigurator(PathAddress address) {
super(RemoteCacheContainerComponent.CONNECTION_POOL, address);
}
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.exhaustedAction = ExhaustedAction.valueOf(ConnectionPoolResourceDefinition.Attribute.EXHAUSTED_ACTION.resolveModelAttribute(context, model).asString());
this.maxActive = ConnectionPoolResourceDefinition.Attribute.MAX_ACTIVE.resolveModelAttribute(context, model).asInt(-1);
this.maxWait = ConnectionPoolResourceDefinition.Attribute.MAX_WAIT.resolveModelAttribute(context, model).asLong(-1L);
this.minEvictableIdleTime = ConnectionPoolResourceDefinition.Attribute.MIN_EVICTABLE_IDLE_TIME.resolveModelAttribute(context, model).asLong();
this.minIdle = ConnectionPoolResourceDefinition.Attribute.MIN_IDLE.resolveModelAttribute(context, model).asInt();
return this;
}
@Override
public ConnectionPoolConfiguration get() {
return new ConfigurationBuilder().connectionPool()
.exhaustedAction(this.exhaustedAction)
.maxActive(this.maxActive)
.maxWait(this.maxWait)
.minEvictableIdleTime(this.minEvictableIdleTime)
.minIdle(this.minIdle)
.create();
}
}
| 3,374
| 46.535211
| 165
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheMetricExecutor.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.remote;
import org.infinispan.client.hotrod.jmx.RemoteCacheClientStatisticsMXBean;
import org.jboss.as.clustering.controller.FunctionExecutor;
import org.jboss.as.clustering.controller.FunctionExecutorRegistry;
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.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.client.RemoteCacheContainer;
import org.wildfly.clustering.infinispan.client.service.InfinispanClientRequirement;
/**
* @author Paul Ferraro
*/
public class RemoteCacheMetricExecutor implements MetricExecutor<RemoteCacheClientStatisticsMXBean> {
private final FunctionExecutorRegistry<RemoteCacheContainer> executors;
public RemoteCacheMetricExecutor(FunctionExecutorRegistry<RemoteCacheContainer> executors) {
this.executors = executors;
}
@Override
public ModelNode execute(OperationContext context, Metric<RemoteCacheClientStatisticsMXBean> metric) throws OperationFailedException {
ServiceName name = InfinispanClientRequirement.REMOTE_CONTAINER.getServiceName(context, UnaryCapabilityNameResolver.PARENT);
FunctionExecutor<RemoteCacheContainer> executor = this.executors.get(name);
return (executor != null) ? executor.execute(new MetricFunction<>(new RemoteCacheClientStatisticsFactory(context.getCurrentAddressValue()), metric)) : null;
}
}
| 2,757
| 47.385965
| 164
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/ClientThreadPoolServiceConfigurator.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.remote;
import java.util.Properties;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.ExecutorFactoryConfiguration;
import org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory;
import org.infinispan.commons.executors.ExecutorFactory;
import org.infinispan.commons.util.concurrent.BlockingRejectedExecutionHandler;
import org.infinispan.commons.util.concurrent.NonBlockingRejectedExecutionHandler;
import org.jboss.as.clustering.infinispan.executors.DefaultNonBlockingThreadFactory;
import org.jboss.as.clustering.infinispan.subsystem.ComponentServiceConfigurator;
import org.jboss.as.clustering.infinispan.subsystem.ThreadPoolDefinition;
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.context.DefaultThreadFactory;
import org.wildfly.clustering.service.ServiceConfigurator;
/**
* @author Radoslav Husar
*/
public class ClientThreadPoolServiceConfigurator extends ComponentServiceConfigurator<ExecutorFactoryConfiguration> {
private final ThreadPoolDefinition definition;
private volatile ExecutorFactory factory;
public ClientThreadPoolServiceConfigurator(ThreadPoolDefinition definition, PathAddress address) {
super(definition, address);
this.definition = definition;
}
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
int maxThreads = this.definition.getMaxThreads().resolveModelAttribute(context, model).asInt();
int minThreads = this.definition.getMinThreads().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();
this.factory = new ExecutorFactory() {
@Override
public ExecutorService getExecutor(Properties property) {
BlockingQueue<Runnable> queue = queueLength == 0 ? new SynchronousQueue<>() : new LinkedBlockingQueue<>(queueLength);
ThreadFactory factory = new DefaultThreadFactory(new DaemonThreadFactory(DefaultAsyncExecutorFactory.THREAD_NAME));
if (nonBlocking) {
factory = new DefaultNonBlockingThreadFactory(factory);
}
RejectedExecutionHandler handler = nonBlocking ? NonBlockingRejectedExecutionHandler.getInstance() : BlockingRejectedExecutionHandler.getInstance();
return new ThreadPoolExecutor(minThreads, maxThreads, keepAliveTime, TimeUnit.MILLISECONDS, queue, factory, handler);
}
};
return this;
}
@Override
public ExecutorFactoryConfiguration get() {
return new ConfigurationBuilder().asyncExecutorFactory().factory(this.factory).create();
}
private static class DaemonThreadFactory implements ThreadFactory {
private final AtomicInteger index = new AtomicInteger(0);
private final String name;
DaemonThreadFactory(String name) {
this.name = name;
}
@Override
public Thread newThread(Runnable task) {
Thread thread = new Thread(task, String.join("-", this.name, String.valueOf(this.index.getAndIncrement())));
thread.setDaemon(true);
return thread;
}
}
}
| 5,163
| 44.699115
| 164
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheOperation.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.remote;
import org.infinispan.client.hotrod.jmx.RemoteCacheClientStatisticsMXBean;
import org.jboss.as.clustering.controller.Operation;
import org.jboss.as.clustering.infinispan.subsystem.InfinispanExtension;
import org.jboss.as.controller.ExpressionResolver;
import org.jboss.as.controller.OperationDefinition;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* @author Paul Ferraro
*/
public enum RemoteCacheOperation implements Operation<RemoteCacheClientStatisticsMXBean> {
RESET_STATISTICS("reset-statistics", ModelType.UNDEFINED) {
@Override
public ModelNode execute(ExpressionResolver resolver, ModelNode operation, RemoteCacheClientStatisticsMXBean statistics) throws OperationFailedException {
statistics.resetStatistics();
return null;
}
},
;
private final OperationDefinition definition;
RemoteCacheOperation(String name, ModelType replyType) {
this.definition = new SimpleOperationDefinitionBuilder(name, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(RemoteCacheResourceDefinition.WILDCARD_PATH))
.setReplyType(replyType)
.setRuntimeOnly()
.build();
}
@Override
public OperationDefinition getDefinition() {
return this.definition;
}
}
| 2,532
| 40.52459
| 173
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheContainerServiceConfigurator.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.remote;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.configuration.Configuration;
import org.jboss.as.clustering.controller.CapabilityServiceNameProvider;
import org.jboss.as.clustering.controller.ResourceServiceConfigurator;
import org.jboss.as.clustering.infinispan.client.ManagedRemoteCacheContainer;
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.as.server.Services;
import org.jboss.dmr.ModelNode;
import org.jboss.modules.ModuleLoader;
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.wildfly.clustering.Registrar;
import org.wildfly.clustering.infinispan.client.RemoteCacheContainer;
import org.wildfly.clustering.infinispan.client.service.InfinispanClientRequirement;
import org.wildfly.clustering.service.AsyncServiceConfigurator;
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.SupplierDependency;
/**
* Configures a service providing a {@link RemoteCacheContainer}.
* @author Radoslav Husar
* @author Paul Ferraro
*/
public class RemoteCacheContainerServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, Function<RemoteCacheManager, RemoteCacheContainer>, Supplier<RemoteCacheManager>, Consumer<RemoteCacheManager> {
private final String name;
private final SupplierDependency<ModuleLoader> loader;
private volatile SupplierDependency<Configuration> configuration;
private volatile Registrar<String> registrar;
public RemoteCacheContainerServiceConfigurator(PathAddress address) {
super(RemoteCacheContainerResourceDefinition.Capability.CONTAINER, address);
this.name = address.getLastElement().getValue();
this.loader = new ServiceSupplierDependency<>(Services.JBOSS_SERVICE_MODULE_LOADER);
}
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.configuration = new ServiceSupplierDependency<>(InfinispanClientRequirement.REMOTE_CONTAINER_CONFIGURATION.getServiceName(context, this.name));
this.registrar = (RemoteCacheContainerResource) context.readResource(PathAddress.EMPTY_ADDRESS);
return this;
}
@Override
public ServiceBuilder<?> build(ServiceTarget target) {
ServiceBuilder<?> builder = new AsyncServiceConfigurator(this.getServiceName()).build(target);
Consumer<RemoteCacheContainer> container = new CompositeDependency(this.configuration, this.loader).register(builder).provides(this.getServiceName());
Service service = new FunctionalService<>(container, this, this, this);
return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
@Override
public RemoteCacheManager get() {
Configuration configuration = this.configuration.get();
RemoteCacheManager manager = new RemoteCacheManager(configuration);
manager.start();
InfinispanLogger.ROOT_LOGGER.remoteCacheContainerStarted(this.name);
return manager;
}
@Override
public void accept(RemoteCacheManager manager) {
manager.stop();
InfinispanLogger.ROOT_LOGGER.remoteCacheContainerStopped(this.name);
}
@Override
public RemoteCacheContainer apply(RemoteCacheManager container) {
return new ManagedRemoteCacheContainer(container, this.name, this.loader.get(), this.registrar);
}
}
| 5,122
| 46
| 243
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheContainerServiceHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.remote;
import static org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition.ListAttribute.MODULES;
import java.util.Collections;
import java.util.EnumSet;
import org.jboss.as.clustering.controller.ModulesServiceConfigurator;
import org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator;
import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory;
import org.jboss.as.clustering.controller.ServiceValueRegistry;
import org.jboss.as.clustering.controller.SimpleResourceServiceHandler;
import org.jboss.as.clustering.infinispan.subsystem.InfinispanBindingFactory;
import org.jboss.as.clustering.naming.BinderServiceConfigurator;
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.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.clustering.infinispan.client.RemoteCacheContainer;
import org.wildfly.clustering.service.ServiceConfigurator;
/**
* @author Radoslav Husar
*/
public class RemoteCacheContainerServiceHandler extends SimpleResourceServiceHandler {
private final ServiceValueRegistry<RemoteCacheContainer> registry;
RemoteCacheContainerServiceHandler(ResourceServiceConfiguratorFactory configuratorFactory, ServiceValueRegistry<RemoteCacheContainer> registry) {
super(configuratorFactory);
this.registry = registry;
}
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
super.installServices(context, model);
PathAddress address = context.getCurrentAddress();
String name = context.getCurrentAddressValue();
ServiceTarget target = context.getServiceTarget();
Module defaultModule = Module.forClass(RemoteCacheContainer.class);
new ModulesServiceConfigurator(RemoteCacheContainerComponent.MODULES.getServiceName(address), MODULES, Collections.singletonList(defaultModule)).configure(context, model).build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
ServiceConfigurator containerBuilder = new RemoteCacheContainerServiceConfigurator(address).configure(context, model);
containerBuilder.build(target).install();
new ServiceValueCaptorServiceConfigurator<>(this.registry.add(containerBuilder.getServiceName())).build(target).install();
new BinderServiceConfigurator(InfinispanBindingFactory.createRemoteCacheContainerBinding(name), containerBuilder.getServiceName()).build(target).install();
}
@Override
public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
String name = context.getCurrentAddressValue();
context.removeService(InfinispanBindingFactory.createRemoteCacheContainerBinding(name).getBinderServiceName());
context.removeService(new ServiceValueCaptorServiceConfigurator<>(this.registry.remove(new RemoteCacheContainerServiceConfigurator(address).getServiceName())).getServiceName());
for (RemoteCacheContainerResourceDefinition.Capability component : EnumSet.allOf(RemoteCacheContainerResourceDefinition.Capability.class)) {
ServiceName serviceName = component.getServiceName(address);
context.removeService(serviceName);
}
context.removeService(RemoteCacheContainerComponent.MODULES.getServiceName(address));
super.removeServices(context, model);
}
}
| 4,811
| 48.102041
| 250
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteClusterOperation.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.remote;
import java.util.Map;
import org.infinispan.client.hotrod.jmx.RemoteCacheManagerMXBean;
import org.jboss.as.clustering.controller.Operation;
import org.jboss.as.clustering.infinispan.subsystem.InfinispanExtension;
import org.jboss.as.controller.ExpressionResolver;
import org.jboss.as.controller.OperationDefinition;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* @author Paul Ferraro
*/
public enum RemoteClusterOperation implements Operation<Map.Entry<String, RemoteCacheManagerMXBean>> {
SWITCH_CLUSTER("switch-cluster", ModelType.BOOLEAN) {
@Override
public ModelNode execute(ExpressionResolver resolver, ModelNode operation, Map.Entry<String, RemoteCacheManagerMXBean> entry) throws OperationFailedException {
return new ModelNode(entry.getValue().switchToCluster(entry.getKey()));
}
},
;
private final OperationDefinition definition;
RemoteClusterOperation(String name, ModelType replyType) {
this.definition = new SimpleOperationDefinitionBuilder(name, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(RemoteClusterResourceDefinition.WILDCARD_PATH))
.setReplyType(replyType)
.setRuntimeOnly()
.build();
}
@Override
public OperationDefinition getDefinition() {
return this.definition;
}
}
| 2,580
| 39.328125
| 175
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/SecurityResourceDefinition.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.remote;
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.clustering.controller.ResourceServiceHandler;
import org.jboss.as.clustering.controller.SimpleResourceRegistrar;
import org.jboss.as.clustering.controller.SimpleResourceServiceHandler;
import org.jboss.as.clustering.controller.UnaryCapabilityNameResolver;
import org.jboss.as.clustering.infinispan.subsystem.ComponentResourceDefinition;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.dmr.ModelType;
/**
* /subsystem=infinispan/remote-cache-container=X/component=security
*
* @author Radoslav Husar
*/
public class SecurityResourceDefinition extends ComponentResourceDefinition {
public static final PathElement PATH = pathElement("security");
public enum Attribute implements org.jboss.as.clustering.controller.Attribute {
SSL_CONTEXT("ssl-context", ModelType.STRING, new CapabilityReference(Capability.SECURITY_SSL, CommonUnaryRequirement.SSL_CONTEXT)),
;
private final AttributeDefinition definition;
Attribute(String attributeName, ModelType type, CapabilityReference capabilityReference) {
this.definition = new SimpleAttributeDefinitionBuilder(attributeName, type)
.setRequired(false)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setAllowExpression(false)
.setCapabilityReference(capabilityReference)
.setValidator(new StringLengthValidator(1))
.setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SSL_REF)
.build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
}
enum Capability implements org.jboss.as.clustering.controller.Capability {
SECURITY_SSL("org.wildfly.clustering.infinispan.remote-cache-container.security.ssl-context"),
;
private final RuntimeCapability<Void> definition;
Capability(String name) {
this.definition = RuntimeCapability.Builder.of(name, true).setDynamicNameMapper(UnaryCapabilityNameResolver.PARENT).build();
}
@Override
public RuntimeCapability<Void> getDefinition() {
return this.definition;
}
}
SecurityResourceDefinition() {
super(PATH);
}
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parentRegistration) {
ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver())
.addAttributes(Attribute.class)
.addCapabilities(Capability.class)
;
ResourceServiceHandler handler = new SimpleResourceServiceHandler(SecurityServiceConfigurator::new);
new SimpleResourceRegistrar(descriptor, handler).register(registration);
return registration;
}
}
| 4,757
| 43.46729
| 139
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheContainerConfigurationServiceConfigurator.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.remote;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import javax.management.MBeanServer;
import org.infinispan.client.hotrod.ProtocolVersion;
import org.infinispan.client.hotrod.configuration.ClusterConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.Configuration;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.ConnectionPoolConfiguration;
import org.infinispan.client.hotrod.configuration.ExecutorFactoryConfiguration;
import org.infinispan.client.hotrod.configuration.SecurityConfiguration;
import org.infinispan.commons.marshall.Marshaller;
import org.infinispan.commons.util.AggregatedClassLoader;
import org.jboss.as.clustering.controller.CapabilityServiceNameProvider;
import org.jboss.as.clustering.controller.CommonRequirement;
import org.jboss.as.clustering.controller.CommonUnaryRequirement;
import org.jboss.as.clustering.controller.ResourceServiceConfigurator;
import org.jboss.as.clustering.infinispan.jmx.MBeanServerProvider;
import org.jboss.as.clustering.infinispan.subsystem.ThreadPoolResourceDefinition;
import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition.Attribute;
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.controller.registry.Resource;
import org.jboss.as.network.OutboundSocketBinding;
import org.jboss.as.server.Services;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleLoader;
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.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.ServiceSupplierDependency;
import org.wildfly.clustering.service.SupplierDependency;
/**
* @author Radoslav Husar
* @author Paul Ferraro
*/
public class RemoteCacheContainerConfigurationServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, Supplier<Configuration> {
private final Map<String, List<SupplierDependency<OutboundSocketBinding>>> clusters = new HashMap<>();
private final Map<ThreadPoolResourceDefinition, SupplierDependency<ExecutorFactoryConfiguration>> threadPools = new EnumMap<>(ThreadPoolResourceDefinition.class);
private final SupplierDependency<ModuleLoader> loader;
private final SupplierDependency<List<Module>> modules;
private final Properties properties = new Properties();
private final SupplierDependency<ConnectionPoolConfiguration> connectionPool;
private final SupplierDependency<SecurityConfiguration> security;
private volatile SupplierDependency<MBeanServer> server;
private volatile int connectionTimeout;
private volatile String defaultRemoteCluster;
private volatile int maxRetries;
private volatile String protocolVersion;
private volatile int socketTimeout;
private volatile boolean tcpNoDelay;
private volatile boolean tcpKeepAlive;
private volatile boolean statisticsEnabled;
private volatile long transactionTimeout;
private volatile HotRodMarshallerFactory marshallerFactory;
RemoteCacheContainerConfigurationServiceConfigurator(PathAddress address) {
super(RemoteCacheContainerResourceDefinition.Capability.CONFIGURATION, address);
this.loader = new ServiceSupplierDependency<>(Services.JBOSS_SERVICE_MODULE_LOADER);
this.threadPools.put(ThreadPoolResourceDefinition.CLIENT, new ServiceSupplierDependency<>(ThreadPoolResourceDefinition.CLIENT.getServiceName(address)));
this.modules = new ServiceSupplierDependency<>(RemoteCacheContainerComponent.MODULES.getServiceName(address));
this.connectionPool = new ServiceSupplierDependency<>(RemoteCacheContainerComponent.CONNECTION_POOL.getServiceName(address));
this.security = new ServiceSupplierDependency<>(RemoteCacheContainerComponent.SECURITY.getServiceName(address));
}
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.connectionTimeout = Attribute.CONNECTION_TIMEOUT.resolveModelAttribute(context, model).asInt();
this.defaultRemoteCluster = Attribute.DEFAULT_REMOTE_CLUSTER.resolveModelAttribute(context, model).asString();
this.maxRetries = Attribute.MAX_RETRIES.resolveModelAttribute(context, model).asInt();
this.protocolVersion = Attribute.PROTOCOL_VERSION.resolveModelAttribute(context, model).asString();
this.socketTimeout = Attribute.SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt();
this.tcpNoDelay = Attribute.TCP_NO_DELAY.resolveModelAttribute(context, model).asBoolean();
this.tcpKeepAlive = Attribute.TCP_KEEP_ALIVE.resolveModelAttribute(context, model).asBoolean();
this.statisticsEnabled = Attribute.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
this.transactionTimeout = Attribute.TRANSACTION_TIMEOUT.resolveModelAttribute(context, model).asLong();
this.marshallerFactory = HotRodMarshallerFactory.valueOf(Attribute.MARSHALLER.resolveModelAttribute(context, model).asString());
this.clusters.clear();
Resource container = context.readResource(PathAddress.EMPTY_ADDRESS);
for (Resource.ResourceEntry entry : container.getChildren(RemoteClusterResourceDefinition.WILDCARD_PATH.getKey())) {
String clusterName = entry.getName();
ModelNode cluster = entry.getModel();
List<String> bindings = StringListAttributeDefinition.unwrapValue(context, RemoteClusterResourceDefinition.Attribute.SOCKET_BINDINGS.resolveModelAttribute(context, cluster));
List<SupplierDependency<OutboundSocketBinding>> bindingDependencies = new ArrayList<>(bindings.size());
for (String binding : bindings) {
bindingDependencies.add(new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, binding)));
}
this.clusters.put(clusterName, bindingDependencies);
}
this.server = context.hasOptionalCapability(CommonRequirement.MBEAN_SERVER.getName(), null, null) ? new ServiceSupplierDependency<>(CommonRequirement.MBEAN_SERVER.getServiceName(context)) : null;
this.properties.clear();
for (Property property : Attribute.PROPERTIES.resolveModelAttribute(context, model).asPropertyListOrEmpty()) {
this.properties.setProperty(property.getName(), property.getValue().asString());
}
return this;
}
@Override
public ServiceBuilder<?> build(ServiceTarget target) {
ServiceBuilder<?> builder = target.addService(this.getServiceName());
Consumer<Configuration> configuration = new CompositeDependency(this.loader, this.modules, this.connectionPool, this.security, this.server).register(builder).provides(this.getServiceName());
for (Dependency dependency : this.threadPools.values()) {
dependency.register(builder);
}
for (List<SupplierDependency<OutboundSocketBinding>> dependencies : this.clusters.values()) {
for (Dependency dependency : dependencies) {
dependency.register(builder);
}
}
Service service = new FunctionalService<>(configuration, Function.identity(), this);
return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
@Override
public Configuration get() {
String name = this.getServiceName().getSimpleName();
ConfigurationBuilder builder = new ConfigurationBuilder();
// Configure formal security first
builder.security().read(this.security.get());
// Apply properties next, which may override formal security configuration
builder.withProperties(this.properties)
.connectionTimeout(this.connectionTimeout)
.maxRetries(this.maxRetries)
.version(ProtocolVersion.parseVersion(this.protocolVersion))
.socketTimeout(this.socketTimeout)
.statistics()
.enabled(this.statisticsEnabled)
.jmxDomain("org.wildfly.clustering.infinispan")
.jmxEnabled(this.server != null)
.jmxName(name)
.mBeanServerLookup((this.server != null) ? new MBeanServerProvider(this.server.get()) : null)
.tcpNoDelay(this.tcpNoDelay)
.tcpKeepAlive(this.tcpKeepAlive)
.transactionTimeout(this.transactionTimeout, TimeUnit.MILLISECONDS)
;
List<Module> modules = this.modules.get();
Marshaller marshaller = this.marshallerFactory.apply(this.loader.get(), modules);
builder.marshaller(marshaller);
builder.classLoader(modules.size() > 1 ? new AggregatedClassLoader(modules.stream().map(Module::getClassLoader).collect(Collectors.toList())) : modules.get(0).getClassLoader());
builder.connectionPool().read(this.connectionPool.get());
builder.asyncExecutorFactory().read(this.threadPools.get(ThreadPoolResourceDefinition.CLIENT).get());
for (Map.Entry<String, List<SupplierDependency<OutboundSocketBinding>>> cluster : this.clusters.entrySet()) {
String clusterName = cluster.getKey();
List<SupplierDependency<OutboundSocketBinding>> bindingDependencies = cluster.getValue();
if (this.defaultRemoteCluster.equals(clusterName)) {
for (Supplier<OutboundSocketBinding> bindingDependency : bindingDependencies) {
OutboundSocketBinding binding = bindingDependency.get();
builder.addServer().host(binding.getUnresolvedDestinationAddress()).port(binding.getDestinationPort());
}
} else {
ClusterConfigurationBuilder clusterConfigurationBuilder = builder.addCluster(clusterName);
for (Supplier<OutboundSocketBinding> bindingDependency : bindingDependencies) {
OutboundSocketBinding binding = bindingDependency.get();
clusterConfigurationBuilder.addClusterNode(binding.getUnresolvedDestinationAddress(), binding.getDestinationPort());
}
}
}
return builder.build();
}
}
| 12,202
| 55.49537
| 203
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/ConnectionPoolResourceDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.remote;
import java.util.concurrent.TimeUnit;
import java.util.function.UnaryOperator;
import org.infinispan.client.hotrod.configuration.ExhaustedAction;
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.infinispan.subsystem.ComponentResourceDefinition;
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.operations.validation.EnumValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* /subsystem=infinispan/remote-cache-container=X/component=connection-pool
*
* @author Radoslav Husar
*/
public class ConnectionPoolResourceDefinition extends ComponentResourceDefinition {
public static final PathElement PATH = pathElement("connection-pool");
public enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> {
EXHAUSTED_ACTION("exhausted-action", ModelType.STRING, new ModelNode(ExhaustedAction.WAIT.name())) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setValidator(EnumValidator.create(ExhaustedAction.class));
}
},
MAX_ACTIVE("max-active", ModelType.INT, null),
MAX_WAIT("max-wait", ModelType.LONG, null),
MIN_EVICTABLE_IDLE_TIME("min-evictable-idle-time", ModelType.LONG, new ModelNode(TimeUnit.MINUTES.toMillis(30))),
MIN_IDLE("min-idle", ModelType.INT, new ModelNode(1)),
;
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)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
).build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder;
}
}
ConnectionPoolResourceDefinition() {
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(ConnectionPoolServiceConfigurator::new);
new SimpleResourceRegistrar(descriptor, handler).register(registration);
return registration;
}
}
| 4,648
| 42.858491
| 132
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheContainerComponent.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.remote;
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;
/**
* Enumerates components of the remote cache container.
*
* @author Radoslav Husar
*/
public enum RemoteCacheContainerComponent implements ResourceServiceNameFactory {
CONNECTION_POOL(ConnectionPoolResourceDefinition.PATH),
MODULES("modules"),
SECURITY(SecurityResourceDefinition.PATH),
;
private final String[] components;
RemoteCacheContainerComponent(PathElement path) {
this(path.isWildcard() ? path.getKey() : path.getValue());
}
RemoteCacheContainerComponent(String... components) {
this.components = components;
}
@Override
public ServiceName getServiceName(PathAddress remoteContainerAddress) {
return RemoteCacheContainerResourceDefinition.Capability.CONFIGURATION.getServiceName(remoteContainerAddress).append(this.components);
}
}
| 2,113
| 36.087719
| 142
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteClusterResourceDefinition.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.remote;
import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver;
import org.jboss.as.clustering.controller.CapabilityReference;
import org.jboss.as.clustering.controller.ChildResourceDefinition;
import org.jboss.as.clustering.controller.CommonUnaryRequirement;
import org.jboss.as.clustering.controller.FunctionExecutorRegistry;
import org.jboss.as.clustering.controller.ManagementResourceRegistration;
import org.jboss.as.clustering.controller.OperationHandler;
import org.jboss.as.clustering.controller.ResourceDescriptor;
import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory;
import org.jboss.as.clustering.controller.RestartParentResourceRegistrar;
import org.jboss.as.clustering.infinispan.subsystem.InfinispanExtension;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.CapabilityReferenceRecorder;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.registry.AttributeAccess;
import org.wildfly.clustering.infinispan.client.RemoteCacheContainer;
import org.wildfly.clustering.service.BinaryRequirement;
/**
* /subsystem=infinispan/remote-cache-container=X/remote-cluster=Y
*
* @author Radoslav Husar
*/
public class RemoteClusterResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> {
public static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE);
public static PathElement pathElement(String name) {
return PathElement.pathElement("remote-cluster", name);
}
public enum Attribute implements org.jboss.as.clustering.controller.Attribute {
SOCKET_BINDINGS("socket-bindings", new CapabilityReference(Capability.REMOTE_CLUSTER, CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING)),
;
private final AttributeDefinition definition;
Attribute(String name, CapabilityReferenceRecorder reference) {
this.definition = new StringListAttributeDefinition.Builder(name)
.setAllowExpression(false)
.setRequired(true)
.setCapabilityReference(reference)
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
.build();
}
@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
}
enum Requirement implements BinaryRequirement {
REMOTE_CLUSTER("org.wildfly.clustering.infinispan.remote-cache-container.remote-cluster", Void.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 {
REMOTE_CLUSTER("org.wildfly.clustering.infinispan.remote-cache-container.remote-cluster"),
;
private final RuntimeCapability<Void> definition;
Capability(String name) {
this.definition = RuntimeCapability.Builder.of(name, true).setDynamicNameMapper(BinaryCapabilityNameResolver.PARENT_CHILD).build();
}
@Override
public RuntimeCapability<Void> getDefinition() {
return this.definition;
}
}
private final ResourceServiceConfiguratorFactory serviceConfiguratorFactory;
private final FunctionExecutorRegistry<RemoteCacheContainer> executors;
RemoteClusterResourceDefinition(ResourceServiceConfiguratorFactory serviceConfiguratorFactory, FunctionExecutorRegistry<RemoteCacheContainer> executors) {
super(WILDCARD_PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(WILDCARD_PATH));
this.serviceConfiguratorFactory = serviceConfiguratorFactory;
this.executors = executors;
}
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parentRegistration) {
ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver())
.addAttributes(Attribute.class)
.addCapabilities(Capability.class);
new RestartParentResourceRegistrar(this.serviceConfiguratorFactory, descriptor).register(registration);
if (registration.isRuntimeOnlyRegistrationValid()) {
new OperationHandler<>(new RemoteClusterOperationExecutor(this.executors), RemoteClusterOperation.class).register(registration);
}
return registration;
}
}
| 6,009
| 41.624113
| 158
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheClientStatisticsFactory.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.remote;
import java.util.function.Function;
import org.infinispan.client.hotrod.jmx.RemoteCacheClientStatisticsMXBean;
import org.wildfly.clustering.infinispan.client.RemoteCacheContainer;
/**
* @author Paul Ferraro
*/
public class RemoteCacheClientStatisticsFactory implements Function<RemoteCacheContainer, RemoteCacheClientStatisticsMXBean> {
private final String cacheName;
public RemoteCacheClientStatisticsFactory(String cacheName) {
this.cacheName = cacheName;
}
@Override
public RemoteCacheClientStatisticsMXBean apply(RemoteCacheContainer container) {
return container.getCacheNames().contains(this.cacheName) ? container.getCache(this.cacheName).clientStatistics() : null;
}
}
| 1,812
| 38.413043
| 129
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/remote/RemoteCacheOperationExecutor.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.remote;
import org.infinispan.client.hotrod.jmx.RemoteCacheClientStatisticsMXBean;
import org.jboss.as.clustering.controller.FunctionExecutor;
import org.jboss.as.clustering.controller.FunctionExecutorRegistry;
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.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.client.RemoteCacheContainer;
import org.wildfly.clustering.infinispan.client.service.InfinispanClientRequirement;
/**
* @author Paul Ferraro
*/
public class RemoteCacheOperationExecutor implements OperationExecutor<RemoteCacheClientStatisticsMXBean> {
private final FunctionExecutorRegistry<RemoteCacheContainer> executors;
public RemoteCacheOperationExecutor(FunctionExecutorRegistry<RemoteCacheContainer> executors) {
this.executors = executors;
}
@Override
public ModelNode execute(OperationContext context, ModelNode op, Operation<RemoteCacheClientStatisticsMXBean> operation) throws OperationFailedException {
ServiceName name = InfinispanClientRequirement.REMOTE_CONTAINER.getServiceName(context, UnaryCapabilityNameResolver.PARENT);
FunctionExecutor<RemoteCacheContainer> executor = this.executors.get(name);
return (executor != null) ? executor.execute(new OperationFunction<>(context, op, new RemoteCacheClientStatisticsFactory(context.getCurrentAddressValue()), operation)) : null;
}
}
| 2,814
| 48.385965
| 183
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/executors/DefaultNonBlockingThreadFactory.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.executors;
import java.util.concurrent.ThreadFactory;
import org.infinispan.commons.executors.NonBlockingResource;
import org.wildfly.clustering.context.DefaultThreadFactory;
/**
* Thread factory for non-blocking threads.
* @author Paul Ferraro
*/
public class DefaultNonBlockingThreadFactory extends DefaultThreadFactory implements NonBlockingResource {
public DefaultNonBlockingThreadFactory(Class<?> targetClass) {
super(targetClass);
}
public DefaultNonBlockingThreadFactory(ThreadFactory factory) {
super(factory);
}
public DefaultNonBlockingThreadFactory(ThreadFactory factory, Class<?> targetClass) {
super(factory, targetClass);
}
}
| 1,764
| 36.553191
| 106
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/jmx/MBeanServerProvider.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.jmx;
import java.util.Properties;
import javax.management.MBeanServer;
import org.infinispan.commons.jmx.MBeanServerLookup;
/**
* @author Paul Ferraro
*/
public class MBeanServerProvider implements MBeanServerLookup {
private final MBeanServer server;
public MBeanServerProvider(MBeanServer server) {
this.server = server;
}
/**
* {@inheritDoc}
* @see org.infinispan.jmx.MBeanServerLookup#getMBeanServer(java.util.Properties)
*/
@Override
public MBeanServer getMBeanServer(Properties properties) {
return this.server;
}
}
| 1,657
| 31.509804
| 85
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/dataconversion/MediaTypeFactory.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.dataconversion;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
import org.infinispan.commons.dataconversion.MediaType;
import org.jboss.as.server.moduleservice.ServiceModuleLoader;
import org.jboss.modules.Module;
/**
* Factory for key/value media types for a given {@link ClassLoader}.
* @author Paul Ferraro
*/
public enum MediaTypeFactory implements Function<ClassLoader, Map.Entry<MediaType, MediaType>> {
INSTANCE;
private static final String MEDIA_TYPE_PATTERN = "application/%s; type=%s";
private static final Map.Entry<MediaType, MediaType> DEFAULT_MEDIA_TYPES = Map.entry(MediaType.APPLICATION_OBJECT, MediaType.APPLICATION_OBJECT);
@Override
public Map.Entry<MediaType, MediaType> apply(ClassLoader loader) {
Module module = Module.forClassLoader(loader, false);
if ((module == null) || !module.getName().startsWith(ServiceModuleLoader.MODULE_PREFIX)) {
return DEFAULT_MEDIA_TYPES;
}
// Generate key/value media types for this module
String moduleName = module.getName().replaceAll("/", "|");
MediaType keyMediaType = MediaType.fromString(String.format(Locale.ROOT, MEDIA_TYPE_PATTERN, moduleName, "key"));
MediaType valueMediaType = MediaType.fromString(String.format(Locale.ROOT, MEDIA_TYPE_PATTERN, moduleName, "value"));
return Map.entry(keyMediaType, valueMediaType);
}
}
| 2,498
| 43.625
| 149
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/tx/TransactionManagerProvider.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.tx;
import jakarta.transaction.TransactionManager;
import org.infinispan.commons.tx.lookup.TransactionManagerLookup;
/**
* @author Paul Ferraro
*/
public class TransactionManagerProvider implements TransactionManagerLookup {
private final TransactionManager tm;
public TransactionManagerProvider(TransactionManager tm) {
this.tm = tm;
}
/**
* {@inheritDoc}
* @see org.infinispan.transaction.lookup.TransactionManagerLookup#getTransactionManager()
*/
@Override
public TransactionManager getTransactionManager() {
return this.tm;
}
}
| 1,666
| 33.020408
| 94
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/tx/InfinispanXAResourceRecovery.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.tx;
import javax.transaction.xa.XAResource;
import org.infinispan.Cache;
import org.jboss.tm.XAResourceRecovery;
/**
* {@link XAResourceRecovery} for an Infinispan cache.
* @author Paul Ferraro
*/
public class InfinispanXAResourceRecovery implements XAResourceRecovery {
private final Cache<?, ?> cache;
public InfinispanXAResourceRecovery(Cache<?, ?> cache) {
this.cache = cache;
}
@Override
public XAResource[] getXAResources() {
return new XAResource[] { this.cache.getAdvancedCache().getXAResource() };
}
@Override
public int hashCode() {
return this.cache.getCacheManager().getCacheManagerConfiguration().cacheManagerName().hashCode() ^ this.cache.getName().hashCode();
}
@Override
public boolean equals(Object object) {
if ((object == null) || !(object instanceof InfinispanXAResourceRecovery)) return false;
InfinispanXAResourceRecovery recovery = (InfinispanXAResourceRecovery) object;
return this.cache.getCacheManager().getCacheManagerConfiguration().cacheManagerName().equals(recovery.cache.getCacheManager().getCacheManagerConfiguration().cacheManagerName()) && this.cache.getName().equals(recovery.cache.getName());
}
@Override
public String toString() {
return this.cache.getCacheManager().getCacheManagerConfiguration().cacheManagerName() + "." + this.cache.getName();
}
}
| 2,481
| 39.032258
| 242
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/tx/TransactionSynchronizationRegistryProvider.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.tx;
import jakarta.transaction.TransactionSynchronizationRegistry;
import org.infinispan.transaction.lookup.TransactionSynchronizationRegistryLookup;
/**
* Passes the TransactionSynchronizationRegistry to Infinispan.
*
* @author Scott Marlow
*/
public class TransactionSynchronizationRegistryProvider implements TransactionSynchronizationRegistryLookup {
private final TransactionSynchronizationRegistry tsr;
public TransactionSynchronizationRegistryProvider(TransactionSynchronizationRegistry tsr) {
this.tsr = tsr;
}
@Override
public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() {
return this.tsr;
}
}
| 1,751
| 36.276596
| 109
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/persistence/jdbc/DataSourceConnectionFactoryConfiguration.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.persistence.jdbc;
import javax.sql.DataSource;
import org.infinispan.commons.configuration.BuiltBy;
import org.infinispan.persistence.jdbc.common.configuration.ConnectionFactoryConfiguration;
import org.infinispan.persistence.jdbc.common.connectionfactory.ConnectionFactory;
/**
* Configuration for {@link DataSourceConnectionFactory}.
* @author Paul Ferraro
*/
@BuiltBy(DataSourceConnectionFactoryConfigurationBuilder.class)
public class DataSourceConnectionFactoryConfiguration implements ConnectionFactoryConfiguration {
private final DataSource dataSource;
public DataSourceConnectionFactoryConfiguration(DataSource dataSource) {
this.dataSource = dataSource;
}
public DataSource getDataSource() {
return this.dataSource;
}
@Override
public Class<? extends ConnectionFactory> connectionFactoryClass() {
return DataSourceConnectionFactory.class;
}
}
| 1,986
| 36.490566
| 97
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/persistence/jdbc/DataSourceConnectionFactory.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.persistence.jdbc;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.infinispan.persistence.jdbc.common.configuration.ConnectionFactoryConfiguration;
import org.infinispan.persistence.jdbc.common.connectionfactory.ConnectionFactory;
import org.infinispan.persistence.spi.PersistenceException;
import org.jboss.as.clustering.infinispan.logging.InfinispanLogger;
/**
* A connection factory using an injected {@link DataSource}.
* @author Paul Ferraro
*/
public class DataSourceConnectionFactory extends ConnectionFactory {
private volatile DataSource factory;
@Override
public void start(ConnectionFactoryConfiguration configuration, ClassLoader classLoader) throws PersistenceException {
this.factory = ((DataSourceConnectionFactoryConfiguration) configuration).getDataSource();
}
@Override
public void stop() {
this.factory = null;
}
@Override
public Connection getConnection() throws PersistenceException {
try {
return this.factory.getConnection();
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
@Override
public void releaseConnection(Connection connection) {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
InfinispanLogger.ROOT_LOGGER.debug(e.getMessage(), e);
}
}
}
}
| 2,550
| 33.945205
| 122
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/persistence/jdbc/DataSourceConnectionFactoryConfigurationBuilder.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.persistence.jdbc;
import java.util.function.Supplier;
import javax.sql.DataSource;
import org.infinispan.commons.configuration.attributes.AttributeSet;
import org.infinispan.configuration.global.GlobalConfiguration;
import org.infinispan.persistence.jdbc.common.configuration.AbstractJdbcStoreConfigurationBuilder;
import org.infinispan.persistence.jdbc.common.configuration.AbstractJdbcStoreConfigurationChildBuilder;
import org.infinispan.persistence.jdbc.common.configuration.ConnectionFactoryConfigurationBuilder;
import org.wildfly.clustering.service.SimpleSupplierDependency;
/**
* Builds a {@link DataSourceConnectionFactoryConfiguration}.
* @author Paul Ferraro
*/
public class DataSourceConnectionFactoryConfigurationBuilder<S extends AbstractJdbcStoreConfigurationBuilder<?, S>> extends AbstractJdbcStoreConfigurationChildBuilder<S> implements ConnectionFactoryConfigurationBuilder<DataSourceConnectionFactoryConfiguration> {
private volatile Supplier<DataSource> dependency;
public DataSourceConnectionFactoryConfigurationBuilder(AbstractJdbcStoreConfigurationBuilder<?, S> builder) {
super(builder);
}
public DataSourceConnectionFactoryConfigurationBuilder<S> setDataSourceDependency(Supplier<DataSource> dependency) {
this.dependency = dependency;
return this;
}
@Override
public void validate() {
// Nothing to validate
}
@Override
public void validate(GlobalConfiguration globalConfig) {
// Nothing to validate
}
@Override
public DataSourceConnectionFactoryConfiguration create() {
return new DataSourceConnectionFactoryConfiguration(this.dependency.get());
}
@Override
public DataSourceConnectionFactoryConfigurationBuilder<S> read(DataSourceConnectionFactoryConfiguration template) {
this.dependency = new SimpleSupplierDependency<>(template.getDataSource());
return this;
}
@Override
public AttributeSet attributes() {
return AttributeSet.EMPTY;
}
}
| 3,102
| 38.278481
| 262
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/persistence/hotrod/HotRodStore.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.persistence.hotrod;
import java.io.IOException;
import java.util.EnumSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.PrimitiveIterator;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Flowable;
import org.infinispan.Cache;
import org.infinispan.client.hotrod.DefaultTemplate;
import org.infinispan.client.hotrod.Flag;
import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.configuration.NearCacheMode;
import org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.TransactionMode;
import org.infinispan.commons.configuration.ConfiguredBy;
import org.infinispan.commons.io.ByteBuffer;
import org.infinispan.commons.util.IntSet;
import org.infinispan.commons.util.IntSets;
import org.infinispan.marshall.persistence.PersistenceMarshaller;
import org.infinispan.metadata.Metadata;
import org.infinispan.persistence.spi.InitializationContext;
import org.infinispan.persistence.spi.MarshallableEntry;
import org.infinispan.persistence.spi.MarshallableEntryFactory;
import org.infinispan.persistence.spi.MarshalledValue;
import org.infinispan.persistence.spi.NonBlockingStore;
import org.infinispan.persistence.spi.PersistenceException;
import org.infinispan.util.concurrent.BlockingManager;
import org.jboss.as.clustering.infinispan.logging.InfinispanLogger;
import org.reactivestreams.Publisher;
import org.wildfly.clustering.infinispan.client.RemoteCacheContainer;
import org.wildfly.common.function.Functions;
/**
* Variation of {@link org.infinispan.persistence.remote.RemoteStore} configured with a started container-managed {@link RemoteCacheContainer} instance.
* Remote caches are auto-created on the remote server if supported by the protocol.
* Supports segmentation by using a separate remote cache per segment.
*
* @author Radoslav Husar
* @author Paul Ferraro
*/
@ConfiguredBy(HotRodStoreConfiguration.class)
public class HotRodStore<K, V> implements NonBlockingStore<K, V> {
private static final Set<Characteristic> CHARACTERISTICS = EnumSet.of(Characteristic.SHAREABLE, Characteristic.BULK_READ, Characteristic.EXPIRATION, Characteristic.SEGMENTABLE);
private volatile RemoteCacheContainer container;
private volatile AtomicReferenceArray<RemoteCache<ByteBuffer, ByteBuffer>> caches;
private volatile BlockingManager blockingManager;
private volatile PersistenceMarshaller marshaller;
private volatile MarshallableEntryFactory<K,V> entryFactory;
private volatile int batchSize;
private volatile String cacheName;
private volatile int segments;
@Override
public CompletionStage<Void> start(InitializationContext context) {
Cache<?, ?> cache = context.getCache();
HotRodStoreConfiguration configuration = context.getConfiguration();
if (configuration.preload()) {
throw new IllegalStateException();
}
this.container = configuration.remoteCacheContainer();
this.cacheName = cache.getName();
this.blockingManager = context.getBlockingManager();
this.batchSize = configuration.maxBatchSize();
this.marshaller = context.getPersistenceMarshaller();
this.entryFactory = context.getMarshallableEntryFactory();
String template = configuration.cacheConfiguration();
String templateName = (template != null) ? template : DefaultTemplate.DIST_SYNC.getTemplateName();
Consumer<RemoteCacheConfigurationBuilder> configurator = new Consumer<>() {
@Override
public void accept(RemoteCacheConfigurationBuilder builder) {
builder.forceReturnValues(false).transactionMode(TransactionMode.NONE).nearCacheMode(NearCacheMode.DISABLED).templateName(templateName);
}
};
this.segments = configuration.segmented() && (cache.getAdvancedCache().getDistributionManager() != null) ? cache.getCacheConfiguration().clustering().hash().numSegments() : 1;
this.caches = new AtomicReferenceArray<>(this.segments);
for (int i = 0; i < this.segments; ++i) {
this.container.getConfiguration().addRemoteCache(this.segmentCacheName(i), configurator);
}
// When unshared, add/removeSegments(...) will be triggered as needed.
return configuration.shared() ? this.addSegments(IntSets.immutableRangeSet(this.segments)) : CompletableFuture.completedStage(null);
}
@Override
public CompletionStage<Void> stop() {
CompletableFuture<Void> result = CompletableFuture.completedFuture(null);
for (int i = 0; i < this.caches.length(); ++i) {
RemoteCache<ByteBuffer, ByteBuffer> cache = this.caches.get(i);
if (cache != null) {
result = CompletableFuture.allOf(result, this.blockingManager.runBlocking(() -> {
cache.stop();
cache.getRemoteCacheContainer().getConfiguration().removeRemoteCache(cache.getName());
}, "hotrod-store-stop").toCompletableFuture());
}
}
return result;
}
private String segmentCacheName(int segment) {
return (this.segments > 1) ? this.cacheName + '.' + segment : this.cacheName;
}
private int segmentIndex(int segment) {
return (this.segments > 1) ? segment : 0;
}
private RemoteCache<ByteBuffer, ByteBuffer> segmentCache(int segment) {
return this.caches.get(this.segmentIndex(segment));
}
private PrimitiveIterator.OfInt segmentIterator(IntSet segments) {
return (this.segments > 1) ? segments.iterator() : IntStream.of(0).iterator();
}
@Override
public Set<Characteristic> characteristics() {
return CHARACTERISTICS;
}
@Override
public CompletionStage<MarshallableEntry<K, V>> load(int segment, Object key) {
RemoteCache<ByteBuffer, ByteBuffer> cache = this.segmentCache(segment);
if (cache == null) return CompletableFuture.completedStage(null);
try {
return cache.getAsync(this.marshalKey(key)).thenApply(value -> (value != null) ? this.entryFactory.create(key, this.unmarshalValue(value)) : null);
} catch (PersistenceException e) {
return CompletableFuture.failedStage(e);
}
}
@Override
public CompletionStage<Void> write(int segment, MarshallableEntry<? extends K, ? extends V> entry) {
RemoteCache<ByteBuffer, ByteBuffer> cache = this.segmentCache(segment);
if (cache == null) return CompletableFuture.completedStage(null);
Metadata metadata = entry.getMetadata();
try {
return cache.putAsync(entry.getKeyBytes(), this.marshalValue(entry.getMarshalledValue()), metadata.lifespan(), TimeUnit.MILLISECONDS, metadata.maxIdle(), TimeUnit.MILLISECONDS).thenAccept(Functions.discardingConsumer());
} catch (PersistenceException e) {
return CompletableFuture.failedStage(e);
}
}
@Override
public CompletionStage<Boolean> delete(int segment, Object key) {
RemoteCache<ByteBuffer, ByteBuffer> cache = this.segmentCache(segment);
if (cache == null) return CompletableFuture.completedStage(null);
try {
return cache.withFlags(Flag.FORCE_RETURN_VALUE).removeAsync(this.marshalKey(key)).thenApply(Objects::nonNull);
} catch (PersistenceException e) {
return CompletableFuture.failedStage(e);
}
}
@Override
public CompletionStage<Void> batch(int publisherCount, Publisher<SegmentedPublisher<Object>> removePublisher, Publisher<SegmentedPublisher<MarshallableEntry<K, V>>> writePublisher) {
Completable removeCompletable = Flowable.fromPublisher(removePublisher)
.flatMap(sp -> Flowable.fromPublisher(sp).map(key -> Map.entry(key, sp.getSegment())), publisherCount)
.flatMapCompletable(this::remove, false, this.batchSize);
Completable writeCompletable = Flowable.fromPublisher(writePublisher)
.flatMap(sp -> Flowable.fromPublisher(sp).map(entry -> Map.entry(entry, sp.getSegment())), publisherCount)
.flatMapCompletable(this::write, false, this.batchSize);
return removeCompletable.mergeWith(writeCompletable).toCompletionStage(null);
}
private Completable write(Map.Entry<MarshallableEntry<K, V>, Integer> entry) {
return Completable.fromCompletionStage(this.write(entry.getValue(), entry.getKey()));
}
private Completable remove(Map.Entry<Object, Integer> entry) {
return Completable.fromCompletionStage(this.delete(entry.getValue(), entry.getKey()));
}
@Override
public Flowable<K> publishKeys(IntSet segments, Predicate<? super K> filter) {
Stream<K> keys = Stream.empty();
PrimitiveIterator.OfInt iterator = this.segmentIterator(segments);
try {
while (iterator.hasNext()) {
int segment = iterator.nextInt();
RemoteCache<ByteBuffer, ByteBuffer> cache = this.segmentCache(segment);
if (cache != null) {
keys = Stream.concat(keys, cache.keySet().stream().map(this::unmarshalKey));
}
}
Stream<K> filteredKeys = (filter != null) ? keys.filter(filter) : keys;
return Flowable.fromPublisher(this.blockingManager.blockingPublisher(Flowable.defer(() -> Flowable.fromStream(filteredKeys).doFinally(filteredKeys::close))));
} catch (PersistenceException e) {
return Flowable.fromCompletionStage(CompletableFuture.failedStage(e));
}
}
@Override
public Publisher<MarshallableEntry<K, V>> publishEntries(IntSet segments, Predicate<? super K> filter, boolean includeValues) {
return includeValues ? this.publishEntries(segments, filter) : this.publishKeys(segments, filter).map(this.entryFactory::create);
}
private Flowable<MarshallableEntry<K, V>> publishEntries(IntSet segments, Predicate<? super K> filter) {
Stream<MarshallableEntry<K, V>> entries = Stream.empty();
PrimitiveIterator.OfInt iterator = this.segmentIterator(segments);
try {
while (iterator.hasNext()) {
int segment = iterator.nextInt();
RemoteCache<ByteBuffer, ByteBuffer> cache = this.segmentCache(segment);
if (cache != null) {
entries = Stream.concat(entries, cache.entrySet().stream().map(this::unmarshalEntry));
}
}
Stream<MarshallableEntry<K, V>> filteredEntries = (filter != null) ? entries.filter(entry -> filter.test(entry.getKey())) : entries;
return Flowable.fromPublisher(this.blockingManager.blockingPublisher(Flowable.defer(() -> Flowable.fromStream(filteredEntries).doFinally(filteredEntries::close))));
} catch (PersistenceException e) {
return Flowable.fromCompletionStage(CompletableFuture.failedStage(e));
}
}
@Override
public CompletionStage<Void> clear() {
CompletableFuture<Void> result = CompletableFuture.completedFuture(null);
for (int i = 0; i < this.caches.length(); ++i) {
RemoteCache<ByteBuffer, ByteBuffer> cache = this.caches.get(i);
if (cache != null) {
result = CompletableFuture.allOf(result, cache.clearAsync());
}
}
return result;
}
@Override
public CompletionStage<Boolean> containsKey(int segment, Object key) {
RemoteCache<ByteBuffer, ByteBuffer> cache = this.segmentCache(segment);
if (cache == null) return CompletableFuture.completedStage(false);
try {
return cache.containsKeyAsync(this.marshalKey(key));
} catch (PersistenceException e) {
return CompletableFuture.failedStage(e);
}
}
@Override
public CompletionStage<Boolean> isAvailable() {
return this.container.isAvailable();
}
@Override
public CompletionStage<Long> size(IntSet segments) {
CompletableFuture<Long> result = CompletableFuture.completedFuture(0L);
PrimitiveIterator.OfInt iterator = this.segmentIterator(segments);
while (iterator.hasNext()) {
int segment = iterator.nextInt();
RemoteCache<ByteBuffer, ByteBuffer> cache = this.caches.get(segment);
result = result.thenCombine(cache.sizeAsync(), Long::sum);
}
return result;
}
@Override
public CompletionStage<Void> addSegments(IntSet segments) {
CompletableFuture<Void> result = CompletableFuture.completedFuture(null);
PrimitiveIterator.OfInt iterator = segments.iterator();
while (iterator.hasNext()) {
int segment = iterator.nextInt();
String cacheName = this.segmentCacheName(segment);
int index = this.segmentIndex(segment);
result = CompletableFuture.allOf(result, this.blockingManager.runBlocking(() -> {
RemoteCache<ByteBuffer, ByteBuffer> cache = this.container.getCache(cacheName);
if (cache == null) {
// Administration support was introduced in protocol version 2.7
throw InfinispanLogger.ROOT_LOGGER.remoteCacheMustBeDefined(this.container.getConfiguration().version().toString(), cacheName);
}
cache.start();
this.caches.set(index, cache);
}, "hotrod-store-add-segments").toCompletableFuture());
}
return result;
}
@Override
public CompletionStage<Void> removeSegments(IntSet segments) {
CompletableFuture<Void> result = CompletableFuture.completedFuture(null);
PrimitiveIterator.OfInt iterator = segments.iterator();
while (iterator.hasNext()) {
int segment = iterator.nextInt();
RemoteCache<ByteBuffer, ByteBuffer> cache = this.caches.get(segment);
if (cache != null) {
this.caches.set(segment, null);
result = CompletableFuture.allOf(result, cache.clearAsync().thenRun(cache::stop).toCompletableFuture());
}
}
return result;
}
@Override
public Publisher<MarshallableEntry<K, V>> purgeExpired() {
return Flowable.empty();
}
private ByteBuffer marshalKey(Object key) {
return this.entryFactory.create(key).getKeyBytes();
}
@SuppressWarnings("unchecked")
private K unmarshalKey(ByteBuffer key) {
try {
return (K) this.marshaller.objectFromByteBuffer(key.getBuf(), key.getOffset(), key.getLength());
} catch (IOException | ClassNotFoundException e) {
throw new PersistenceException(e);
}
}
private MarshallableEntry<K, V> unmarshalEntry(Map.Entry<ByteBuffer, ByteBuffer> entry) {
return this.entryFactory.create(this.unmarshalKey(entry.getKey()), this.unmarshalValue(entry.getValue()));
}
private ByteBuffer marshalValue(MarshalledValue value) {
try {
return this.marshaller.objectToBuffer(value);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
}
}
private MarshalledValue unmarshalValue(ByteBuffer buffer) {
if (buffer == null) return null;
try {
return (MarshalledValue) this.marshaller.objectFromByteBuffer(buffer.getBuf(), buffer.getOffset(), buffer.getLength());
} catch (IOException | ClassNotFoundException e) {
throw new PersistenceException(e);
}
}
}
| 17,213
| 44.904
| 232
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/persistence/hotrod/HotRodStoreConfigurationBuilder.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.persistence.hotrod;
import static org.jboss.as.clustering.infinispan.persistence.hotrod.HotRodStoreConfiguration.CACHE_CONFIGURATION;
import static org.jboss.as.clustering.infinispan.persistence.hotrod.HotRodStoreConfiguration.REMOTE_CACHE_CONTAINER;
import org.infinispan.commons.configuration.attributes.AttributeSet;
import org.infinispan.configuration.cache.AbstractStoreConfiguration;
import org.infinispan.configuration.cache.AbstractStoreConfigurationBuilder;
import org.infinispan.configuration.cache.PersistenceConfigurationBuilder;
import org.wildfly.clustering.infinispan.client.RemoteCacheContainer;
/**
* @author Radoslav Husar
*/
public class HotRodStoreConfigurationBuilder extends AbstractStoreConfigurationBuilder<HotRodStoreConfiguration, HotRodStoreConfigurationBuilder> {
public HotRodStoreConfigurationBuilder(PersistenceConfigurationBuilder builder) {
super(builder, new AttributeSet(HotRodStoreConfiguration.class, AbstractStoreConfiguration.attributeDefinitionSet(), CACHE_CONFIGURATION, REMOTE_CACHE_CONTAINER));
}
public HotRodStoreConfigurationBuilder cacheConfiguration(String cacheConfiguration) {
this.attributes.attribute(CACHE_CONFIGURATION).set(cacheConfiguration);
return this;
}
public HotRodStoreConfigurationBuilder remoteCacheContainer(RemoteCacheContainer remoteCacheContainer) {
this.attributes.attribute(REMOTE_CACHE_CONTAINER).set(remoteCacheContainer);
return this;
}
@Override
public HotRodStoreConfiguration create() {
return new HotRodStoreConfiguration(this.attributes.protect(), this.async.create());
}
@Override
public HotRodStoreConfigurationBuilder self() {
return this;
}
}
| 2,808
| 42.890625
| 171
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/persistence/hotrod/HotRodStoreConfiguration.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.persistence.hotrod;
import org.infinispan.commons.configuration.BuiltBy;
import org.infinispan.commons.configuration.ConfigurationFor;
import org.infinispan.commons.configuration.attributes.AttributeDefinition;
import org.infinispan.commons.configuration.attributes.AttributeSet;
import org.infinispan.configuration.cache.AbstractStoreConfiguration;
import org.infinispan.configuration.cache.AsyncStoreConfiguration;
import org.wildfly.clustering.infinispan.client.RemoteCacheContainer;
/**
* @author Radoslav Husar
*/
@BuiltBy(HotRodStoreConfigurationBuilder.class)
@ConfigurationFor(HotRodStore.class)
public class HotRodStoreConfiguration extends AbstractStoreConfiguration {
static final AttributeDefinition<RemoteCacheContainer> REMOTE_CACHE_CONTAINER = AttributeDefinition.builder("remoteCacheContainer", null, RemoteCacheContainer.class).build();
static final AttributeDefinition<String> CACHE_CONFIGURATION = AttributeDefinition.builder("cacheConfiguration", null, String.class).build();
public HotRodStoreConfiguration(AttributeSet attributes, AsyncStoreConfiguration async) {
super(attributes, async);
}
public RemoteCacheContainer remoteCacheContainer() {
return this.attributes().attribute(HotRodStoreConfiguration.REMOTE_CACHE_CONTAINER).get();
}
public String cacheConfiguration() {
return this.attributes.attribute(CACHE_CONFIGURATION).get();
}
@Override
public String toString() {
return "HotRodStoreConfiguration{attributes=" + this.attributes + '}';
}
}
| 2,625
| 42.04918
| 178
|
java
|
null |
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/transport/ChannelConfigurator.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.transport;
import java.util.List;
import org.infinispan.remoting.transport.jgroups.JGroupsChannelConfigurator;
import org.jgroups.ChannelListener;
import org.jgroups.JChannel;
import org.jgroups.conf.ProtocolConfiguration;
import org.jgroups.util.SocketFactory;
import org.wildfly.clustering.jgroups.spi.ChannelFactory;
/**
* @author Paul Ferraro
*/
public class ChannelConfigurator implements JGroupsChannelConfigurator {
private final ChannelFactory factory;
private final String name;
public ChannelConfigurator(ChannelFactory factory, String name) {
this.factory = factory;
this.name = name;
}
@Override
public String getProtocolStackString() {
return null;
}
@Override
public List<ProtocolConfiguration> getProtocolStack() {
return null;
}
@Override
public String getName() {
return this.name;
}
@Override
public JChannel createChannel(String name) throws Exception {
return this.factory.createChannel(this.name);
}
@Override
public void setSocketFactory(SocketFactory socketFactory) {
// Do nothing
}
@Override
public void addChannelListener(ChannelListener listener) {
// Do nothing
}
}
| 2,326
| 29.220779
| 76
|
java
|
null |
wildfly-main/clustering/infinispan/client/service/src/main/java/org/wildfly/clustering/infinispan/client/service/RemoteCacheServiceConfigurator.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.wildfly.clustering.infinispan.client.service;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder;
import org.jboss.as.clustering.controller.CapabilityServiceConfigurator;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
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.client.RemoteCacheContainer;
import org.wildfly.clustering.service.AsyncServiceConfigurator;
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;
/**
* Installs a service providing a dynamically created remote-cache with a custom near-cache factory with auto-managed lifecycle.
* @author Paul Ferraro
* @param K cache key
* @param V cache value
*/
public class RemoteCacheServiceConfigurator<K, V> extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, Supplier<RemoteCache<K, V>>, Consumer<RemoteCache<K, V>> {
private final String containerName;
private final String cacheName;
private final Consumer<RemoteCacheConfigurationBuilder> configurator;
private volatile SupplierDependency<RemoteCacheContainer> container;
public RemoteCacheServiceConfigurator(ServiceName name, String containerName, String cacheName, Consumer<RemoteCacheConfigurationBuilder> configurator) {
super(name);
this.containerName = containerName;
this.cacheName = cacheName;
this.configurator = configurator;
}
@Override
public RemoteCache<K, V> get() {
RemoteCacheContainer container = this.container.get();
container.getConfiguration().addRemoteCache(this.cacheName, this.configurator);
RemoteCache<K, V> cache = container.getCache(this.cacheName);
cache.start();
return cache;
}
@Override
public void accept(RemoteCache<K, V> cache) {
cache.stop();
this.container.get().getConfiguration().removeRemoteCache(this.cacheName);
}
@Override
public ServiceConfigurator configure(CapabilityServiceSupport support) {
this.container = new ServiceSupplierDependency<>(InfinispanClientRequirement.REMOTE_CONTAINER.getServiceName(support, this.containerName));
return this;
}
@Override
public final ServiceBuilder<?> build(ServiceTarget target) {
ServiceBuilder<?> builder = new AsyncServiceConfigurator(this.getServiceName()).build(target);
Consumer<RemoteCache<K, V>> cache = this.container.register(builder).provides(this.getServiceName());
Service service = new FunctionalService<>(cache, Function.identity(), this, this);
return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
}
| 4,291
| 43.708333
| 184
|
java
|
null |
wildfly-main/clustering/infinispan/client/service/src/main/java/org/wildfly/clustering/infinispan/client/service/InfinispanClientRequirement.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.wildfly.clustering.infinispan.client.service;
import org.infinispan.client.hotrod.RemoteCacheContainer;
import org.infinispan.client.hotrod.configuration.Configuration;
import org.jboss.as.clustering.controller.UnaryRequirementServiceNameFactory;
import org.jboss.as.clustering.controller.UnaryServiceNameFactory;
import org.jboss.as.clustering.controller.UnaryServiceNameFactoryProvider;
import org.wildfly.clustering.service.UnaryRequirement;
/**
* @author Paul Ferraro
*/
public enum InfinispanClientRequirement implements UnaryRequirement, UnaryServiceNameFactoryProvider {
REMOTE_CONTAINER("org.wildfly.clustering.infinispan.remote-cache-container", RemoteCacheContainer.class),
REMOTE_CONTAINER_CONFIGURATION("org.wildfly.clustering.infinispan.remote-cache-container-configuration", Configuration.class),
;
private final String name;
private final Class<?> type;
private final UnaryServiceNameFactory factory = new UnaryRequirementServiceNameFactory(this);
InfinispanClientRequirement(String name, Class<?> type) {
this.name = name;
this.type = type;
}
@Override
public String getName() {
return this.name;
}
@Override
public Class<?> getType() {
return this.type;
}
@Override
public UnaryServiceNameFactory getServiceNameFactory() {
return this.factory;
}
}
| 2,418
| 36.796875
| 130
|
java
|
null |
wildfly-main/clustering/infinispan/client/spi/src/main/java/org/wildfly/clustering/infinispan/client/near/SimpleKeyWeigher.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.wildfly.clustering.infinispan.client.near;
import java.util.function.Predicate;
import com.github.benmanes.caffeine.cache.Weigher;
/**
* Weigher that only considers keys passing a given predicate.
* @author Paul Ferraro
*/
public class SimpleKeyWeigher implements Weigher<Object, Object> {
private final Predicate<Object> evictable;
public SimpleKeyWeigher(Predicate<Object> evictable) {
this.evictable = evictable;
}
@Override
public int weigh(Object key, Object value) {
return this.evictable.test(key) ? 1 : 0;
}
}
| 1,602
| 34.622222
| 70
|
java
|
null |
wildfly-main/clustering/infinispan/client/spi/src/main/java/org/wildfly/clustering/infinispan/client/near/EvictionListener.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.wildfly.clustering.infinispan.client.near;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import org.infinispan.client.hotrod.MetadataValue;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.RemovalCause;
import com.github.benmanes.caffeine.cache.RemovalListener;
/**
* Removal listener that triggers the specified listener when the removal cause is {@link RemovalCause#SIZE}.
* @author Paul Ferraro
*/
public class EvictionListener<K, V> implements RemovalListener<K, MetadataValue<V>>, Consumer<Cache<K, MetadataValue<V>>> {
private final BiConsumer<K, MetadataValue<V>> defaultListener;
private final BiConsumer<Cache<Object, MetadataValue<Object>>, Map.Entry<Object, Object>> listener;
private Cache<Object, MetadataValue<Object>> cache;
public EvictionListener(BiConsumer<K, MetadataValue<V>> defaultListener, BiConsumer<Cache<Object, MetadataValue<Object>>, Map.Entry<Object, Object>> listener) {
this.defaultListener = defaultListener;
this.listener = listener;
}
@SuppressWarnings("unchecked")
@Override
public void accept(Cache<K, MetadataValue<V>> cache) {
this.cache = (Cache<Object, MetadataValue<Object>>) (Cache<?, ?>) cache;
}
@Override
public void onRemoval(K key, MetadataValue<V> value, RemovalCause cause) {
this.defaultListener.accept(key, value);
if (cause == RemovalCause.SIZE) {
this.listener.accept(this.cache, Map.entry(key, value.getValue()));
}
}
}
| 2,621
| 39.96875
| 164
|
java
|
null |
wildfly-main/clustering/infinispan/client/spi/src/main/java/org/wildfly/clustering/infinispan/client/near/CaffeineNearCacheService.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.wildfly.clustering.infinispan.client.near;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import org.infinispan.client.hotrod.MetadataValue;
import org.infinispan.client.hotrod.configuration.NearCacheConfiguration;
import org.infinispan.client.hotrod.configuration.NearCacheMode;
import org.infinispan.client.hotrod.event.impl.ClientListenerNotifier;
import org.infinispan.client.hotrod.near.NearCache;
import org.infinispan.client.hotrod.near.NearCacheService;
import com.github.benmanes.caffeine.cache.Cache;
/**
* Near cache service that constructs its near cache using a generic factory.
* @author Paul Ferraro
*/
public class CaffeineNearCacheService<K, V> extends NearCacheService<K, V> {
private final Supplier<Cache<K, MetadataValue<V>>> factory;
public CaffeineNearCacheService(Supplier<Cache<K, MetadataValue<V>>> factory, ClientListenerNotifier listenerNotifier) {
super(new NearCacheConfiguration(NearCacheMode.INVALIDATED, 0, false), listenerNotifier);
this.factory = factory;
}
@Override
protected NearCache<K, V> createNearCache(NearCacheConfiguration config, BiConsumer<K, MetadataValue<V>> removedConsumer) {
return new CaffeineNearCache<>(this.factory.get());
}
}
| 2,302
| 41.648148
| 127
|
java
|
null |
wildfly-main/clustering/infinispan/client/spi/src/main/java/org/wildfly/clustering/infinispan/client/near/CaffeineNearCache.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.wildfly.clustering.infinispan.client.near;
import java.util.Iterator;
import java.util.Map;
import org.infinispan.client.hotrod.MetadataValue;
import org.infinispan.client.hotrod.near.NearCache;
import com.github.benmanes.caffeine.cache.Cache;
/**
* Near cache implementation based on a Caffeine cache.
* @author Paul Ferraro
*/
public class CaffeineNearCache<K, V> implements NearCache<K, V> {
private final Map<K, MetadataValue<V>> map;
public CaffeineNearCache(Cache<K, MetadataValue<V>> cache) {
this.map = cache.asMap();
}
@Override
public void put(K key, MetadataValue<V> value) {
this.map.put(key, value);
}
@Override
public void putIfAbsent(K key, MetadataValue<V> value) {
this.map.putIfAbsent(key, value);
}
@Override
public boolean remove(K key) {
return this.map.remove(key) != null;
}
@Override
public MetadataValue<V> get(K key) {
return this.map.get(key);
}
@Override
public void clear() {
this.map.clear();
}
@Override
public int size() {
return this.map.size();
}
@Override
public Iterator<Map.Entry<K, MetadataValue<V>>> iterator() {
return this.map.entrySet().iterator();
}
}
| 2,307
| 27.85
| 70
|
java
|
null |
wildfly-main/clustering/infinispan/client/api/src/main/java/org/wildfly/clustering/infinispan/client/RemoteCacheContainer.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.wildfly.clustering.infinispan.client;
import java.util.concurrent.CompletionStage;
import jakarta.transaction.TransactionManager;
import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.RemoteCacheManagerAdmin;
import org.infinispan.client.hotrod.configuration.TransactionMode;
import org.infinispan.client.hotrod.jmx.RemoteCacheManagerMXBean;
/**
* Extends Infinispan's {@link org.wildfly.clustering.infinispan.client.client.hotrod.RemoteCacheContainer} additionally exposing the name of the
* remote cache container, an administration utility, and a mechanism for configuring near caching per remote cache.
*
* @author Radoslav Husar
* @author Paul Ferraro
*/
public interface RemoteCacheContainer extends org.infinispan.client.hotrod.RemoteCacheContainer, RemoteCacheManagerMXBean {
/**
* Returns the name of this remote cache container.
*
* @return the remote cache container name
*/
String getName();
@Deprecated
@Override
default <K, V> RemoteCache<K, V> getCache(boolean forceReturnValue) {
return this.getCache();
}
@Deprecated
@Override
default <K, V> RemoteCache<K, V> getCache(String cacheName, boolean forceReturnValue) {
return this.getCache(cacheName);
}
@Deprecated
@Override
default <K, V> RemoteCache<K, V> getCache(String cacheName, TransactionMode transactionMode) {
return this.getCache(cacheName);
}
@Deprecated
@Override
default <K, V> RemoteCache<K, V> getCache(String cacheName, TransactionManager transactionManager) {
return this.getCache(cacheName);
}
@Deprecated
@Override
default <K, V> RemoteCache<K, V> getCache(String cacheName, boolean forceReturnValue, TransactionMode transactionMode) {
return this.getCache(cacheName);
}
@Deprecated
@Override
default <K, V> RemoteCache<K, V> getCache(String cacheName, boolean forceReturnValue, TransactionManager transactionManager) {
return this.getCache(cacheName);
}
@Deprecated
@Override
default <K, V> RemoteCache<K, V> getCache(String cacheName, TransactionMode transactionMode, TransactionManager transactionManager) {
return this.getCache(cacheName);
}
@Deprecated
@Override
default <K, V> RemoteCache<K, V> getCache(String cacheName, boolean forceReturnValue, TransactionMode transactionMode, TransactionManager transactionManager) {
return this.getCache(cacheName);
}
/**
* Returns administration utility to administer (create, remove or reindex) caches.
*
* @return administration utility
*/
RemoteCacheManagerAdmin administration();
CompletionStage<Boolean> isAvailable();
}
| 3,796
| 34.485981
| 163
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/ByteBufferMarshallerFactory.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.wildfly.clustering.infinispan.marshalling;
import java.util.AbstractMap;
import java.util.Map;
import java.util.function.Function;
import org.infinispan.commons.dataconversion.MediaType;
import org.jboss.marshalling.ClassResolver;
import org.jboss.marshalling.MarshallingConfiguration;
import org.jboss.marshalling.ModularClassResolver;
import org.jboss.modules.ModuleLoader;
import org.wildfly.clustering.infinispan.marshalling.protostream.WrappedMessageByteBufferMarshaller;
import org.wildfly.clustering.infinispan.marshalling.protostream.ProtoStreamMarshaller;
import org.wildfly.clustering.marshalling.jboss.DynamicClassTable;
import org.wildfly.clustering.marshalling.jboss.DynamicExternalizerObjectTable;
import org.wildfly.clustering.marshalling.jboss.JBossByteBufferMarshaller;
import org.wildfly.clustering.marshalling.jboss.SimpleMarshallingConfigurationRepository;
import org.wildfly.clustering.marshalling.protostream.ModuleClassLoaderMarshaller;
import org.wildfly.clustering.marshalling.protostream.ProtoStreamByteBufferMarshaller;
import org.wildfly.clustering.marshalling.protostream.SerializationContextBuilder;
import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller;
/**
* Creates a {@link ByteBufferMarshaller} suitable for the given {@link MediaType}.
* @author Paul Ferraro
*/
public class ByteBufferMarshallerFactory implements Function<ClassLoader, ByteBufferMarshaller> {
enum MarshallingVersion implements Function<Map.Entry<ClassResolver, ClassLoader>, MarshallingConfiguration> {
VERSION_1() {
@Override
public MarshallingConfiguration apply(Map.Entry<ClassResolver, ClassLoader> entry) {
MarshallingConfiguration config = new MarshallingConfiguration();
ClassLoader loader = entry.getValue();
config.setClassResolver(entry.getKey());
config.setClassTable(new DynamicClassTable(loader));
config.setObjectTable(new DynamicExternalizerObjectTable(loader));
return config;
}
},
;
static final MarshallingVersion CURRENT = VERSION_1;
}
private final MediaType type;
private final ModuleLoader loader;
public ByteBufferMarshallerFactory(MediaType type, ModuleLoader loader) {
this.type = type;
this.loader = loader;
}
@Override
public ByteBufferMarshaller apply(ClassLoader loader) {
switch (this.type.toString()) {
case ProtoStreamMarshaller.MEDIA_TYPE_NAME:
return new ProtoStreamByteBufferMarshaller(new SerializationContextBuilder(new ModuleClassLoaderMarshaller(this.loader)).load(loader).build());
case MediaType.APPLICATION_JBOSS_MARSHALLING_TYPE:
return new JBossByteBufferMarshaller(new SimpleMarshallingConfigurationRepository(MarshallingVersion.class, MarshallingVersion.CURRENT, new AbstractMap.SimpleImmutableEntry<>(ModularClassResolver.getInstance(this.loader), loader)), loader);
case MediaType.APPLICATION_PROTOSTREAM_TYPE:
return new WrappedMessageByteBufferMarshaller(loader);
default:
throw new IllegalArgumentException(this.type.toString());
}
}
}
| 4,294
| 47.258427
| 256
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/AbstractMarshaller.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.wildfly.clustering.infinispan.marshalling;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.infinispan.commons.io.ByteBuffer;
import org.infinispan.commons.io.ByteBufferImpl;
import org.infinispan.commons.io.LazyByteArrayOutputStream;
import org.infinispan.commons.marshall.BufferSizePredictor;
import org.infinispan.commons.marshall.MarshallableTypeHints;
import org.infinispan.commons.marshall.Marshaller;
import org.infinispan.commons.marshall.StreamAwareMarshaller;
/**
* Abstract marshaller implementation.
* @author Paul Ferraro
*/
public abstract class AbstractMarshaller implements Marshaller, StreamAwareMarshaller {
private final MarshallableTypeHints hints = new MarshallableTypeHints();
@Override
public void stop() {
this.hints.clear();
}
@Override
public int sizeEstimate(Object object) {
return this.getBufferSizePredictor(object).nextSize(object);
}
@Override
public BufferSizePredictor getBufferSizePredictor(Object object) {
return this.hints.getBufferSizePredictor(object);
}
@Override
public Object objectFromByteBuffer(byte[] bytes) throws IOException, ClassNotFoundException {
return this.objectFromByteBuffer(bytes, 0, bytes.length);
}
@Override
public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException, ClassNotFoundException {
ByteArrayInputStream input = new ByteArrayInputStream(buf, offset, length);
return this.readObject(input);
}
@Override
public byte[] objectToByteBuffer(Object object) throws IOException {
if (object == null) {
return this.objectToByteBuffer(null, 1);
}
int estimatedSize = this.sizeEstimate(object);
byte[] bytes = this.objectToByteBuffer(object, estimatedSize);
int actualSize = bytes.length - Byte.BYTES;
this.getBufferSizePredictor(object).recordSize(actualSize);
return bytes;
}
@Override
public ByteBuffer objectToBuffer(Object object) throws IOException {
if (object == null) {
return this.objectToBuffer(null, 1);
}
int estimatedSize = this.sizeEstimate(object);
ByteBuffer buffer = this.objectToBuffer(object, estimatedSize);
int actualSize = buffer.getLength() - Byte.BYTES;
// If the prediction is way off, then trim it
if (estimatedSize > (actualSize * 4)) {
byte[] bytes = trim(buffer);
buffer = ByteBufferImpl.create(bytes);
}
this.getBufferSizePredictor(object).recordSize(actualSize);
return buffer;
}
@Override
public byte[] objectToByteBuffer(Object obj, int estimatedSize) throws IOException {
ByteBuffer b = this.objectToBuffer(obj, estimatedSize);
return trim(b);
}
private ByteBuffer objectToBuffer(Object object, int estimatedSize) throws IOException {
LazyByteArrayOutputStream output = new LazyByteArrayOutputStream(estimatedSize + Byte.BYTES);
this.writeObject(object, output);
return ByteBufferImpl.create(output.getRawBuffer(), 0, output.size());
}
private static byte[] trim(ByteBuffer buffer) {
byte[] bytes = buffer.getBuf();
int offset = buffer.getOffset();
int length = buffer.getLength();
// Nothing to trim?
if ((offset == 0) && (bytes.length == length)) return bytes;
byte[] result = new byte[length];
System.arraycopy(bytes, offset, result, 0, length);
return result;
}
}
| 4,622
| 36.893443
| 119
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/UserMarshaller.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.wildfly.clustering.infinispan.marshalling;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.OptionalInt;
import org.infinispan.commons.dataconversion.MediaType;
import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller;
/**
* A user marshaller that delegates marshalling to a {@link ByteBufferMarshaller}.
* @author Paul Ferraro
*/
public class UserMarshaller extends AbstractMarshaller {
private final MediaType type;
private final ByteBufferMarshaller marshaller;
public UserMarshaller(MediaType type, ByteBufferMarshaller marshaller) {
this.type = type;
this.marshaller = marshaller;
}
@Override
public int sizeEstimate(Object object) {
OptionalInt size = this.marshaller.size(object);
return size.isPresent() ? size.getAsInt() : super.sizeEstimate(object);
}
@Override
public boolean isMarshallable(Object object) {
return this.marshaller.isMarshallable(object);
}
@Override
public Object readObject(InputStream input) throws ClassNotFoundException, IOException {
return this.marshaller.readFrom(input);
}
@Override
public void writeObject(Object object, OutputStream output) throws IOException {
this.marshaller.writeTo(output, object);
}
@Override
public MediaType mediaType() {
return this.type;
}
}
| 2,458
| 32.684932
| 92
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/MarshallerFactory.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.wildfly.clustering.infinispan.marshalling;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import org.infinispan.commons.marshall.Marshaller;
import org.infinispan.commons.util.AggregatedClassLoader;
import org.infinispan.protostream.ProtobufUtil;
import org.infinispan.protostream.SerializationContext;
import org.infinispan.protostream.SerializationContextInitializer;
import org.jboss.marshalling.ModularClassResolver;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleLoader;
import org.wildfly.clustering.infinispan.marshalling.jboss.JBossMarshaller;
import org.wildfly.clustering.infinispan.marshalling.protostream.ProtoStreamMarshaller;
import org.wildfly.clustering.marshalling.protostream.ModuleClassLoaderMarshaller;
import org.wildfly.clustering.marshalling.protostream.SerializationContextBuilder;
/**
* @author Paul Ferraro
*/
public enum MarshallerFactory implements BiFunction<ModuleLoader, List<Module>, Marshaller> {
DEFAULT() {
@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
SerializationContext context = ProtobufUtil.newSerializationContext();
for (Module module : modules) {
for (SerializationContextInitializer initializer : module.loadService(SerializationContextInitializer.class)) {
initializer.registerSchema(context);
initializer.registerMarshallers(context);
}
}
return new org.infinispan.commons.marshall.ProtoStreamMarshaller(context);
}
},
JBOSS() {
@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
ClassLoader classLoader = modules.size() > 1 ? new AggregatedClassLoader(modules.stream().map(Module::getClassLoader).collect(Collectors.toList())) : modules.get(0).getClassLoader();
return new JBossMarshaller(ModularClassResolver.getInstance(moduleLoader), classLoader);
}
},
PROTOSTREAM() {
@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
return new ProtoStreamMarshaller(new ModuleClassLoaderMarshaller(moduleLoader), new UnaryOperator<SerializationContextBuilder>() {
@Override
public SerializationContextBuilder apply(SerializationContextBuilder builder) {
for (Module module : modules) {
builder.load(module.getClassLoader());
}
return builder;
}
});
}
},
;
}
| 3,753
| 43.690476
| 194
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/MarshalledValueTranscoder.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.wildfly.clustering.infinispan.marshalling;
import static org.infinispan.commons.logging.Log.CONTAINER;
import java.io.IOException;
import org.infinispan.commons.CacheException;
import org.infinispan.commons.dataconversion.MediaType;
import org.infinispan.commons.dataconversion.OneToManyTranscoder;
import org.infinispan.commons.util.Util;
import org.wildfly.clustering.marshalling.spi.MarshalledValue;
import org.wildfly.clustering.marshalling.spi.MarshalledValueFactory;
/**
* A transcoder that converts between an object and a {@link MarshalledValue}.
* @author Paul Ferraro
*/
public class MarshalledValueTranscoder<C> extends OneToManyTranscoder {
private final MarshalledValueFactory<C> factory;
private final MediaType type;
public MarshalledValueTranscoder(MediaType type, MarshalledValueFactory<C> factory) {
super(type, MediaType.APPLICATION_OBJECT);
this.type = type;
this.factory = factory;
}
@Override
protected Object doTranscode(Object content, MediaType contentType, MediaType destinationType) {
if (this.type.match(destinationType)) {
if (this.type.match(contentType)) {
return content;
}
@SuppressWarnings("unchecked")
MarshalledValue<Object, C> value = (MarshalledValue<Object, C>) content;
try {
return value.get(this.factory.getMarshallingContext());
} catch (IOException e) {
throw new CacheException(e);
}
}
if (destinationType.match(MediaType.APPLICATION_OBJECT)) {
return this.factory.createMarshalledValue(content);
}
throw CONTAINER.unsupportedConversion(Util.toStr(content), contentType, destinationType);
}
}
| 2,820
| 38.732394
| 100
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/ByteBufferExternalizer.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.wildfly.clustering.infinispan.marshalling;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.infinispan.commons.io.ByteBufferImpl;
import org.wildfly.clustering.marshalling.Externalizer;
import org.wildfly.clustering.marshalling.spi.IndexSerializer;
/**
* Externalizer for a {@link ByteBufferImpl}.
* @author Paul Ferraro
*/
public enum ByteBufferExternalizer implements Externalizer<ByteBufferImpl> {
INSTANCE;
@Override
public void writeObject(ObjectOutput output, ByteBufferImpl buffer) throws IOException {
IndexSerializer.VARIABLE.writeInt(output, (buffer != null) ? buffer.getLength() : 0);
if (buffer != null) {
output.write(buffer.getBuf(), buffer.getOffset(), buffer.getLength());
}
}
@Override
public ByteBufferImpl readObject(ObjectInput input) throws IOException, ClassNotFoundException {
int length = IndexSerializer.VARIABLE.readInt(input);
if (length == 0) {
return null;
}
byte[] bytes = new byte[length];
input.readFully(bytes);
return ByteBufferImpl.create(bytes);
}
@Override
public Class<ByteBufferImpl> getTargetClass() {
return ByteBufferImpl.class;
}
}
| 2,311
| 35.125
| 100
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/protostream/ProtoStreamMarshaller.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.wildfly.clustering.infinispan.marshalling.protostream;
import java.util.function.UnaryOperator;
import org.infinispan.commons.dataconversion.MediaType;
import org.infinispan.protostream.ImmutableSerializationContext;
import org.wildfly.clustering.infinispan.marshalling.UserMarshaller;
import org.wildfly.clustering.marshalling.protostream.ClassLoaderMarshaller;
import org.wildfly.clustering.marshalling.protostream.ProtoStreamByteBufferMarshaller;
import org.wildfly.clustering.marshalling.protostream.SerializationContextBuilder;
/**
* @author Paul Ferraro
*/
public class ProtoStreamMarshaller extends UserMarshaller {
public static final String MEDIA_TYPE_NAME = MediaType.APPLICATION_OCTET_STREAM_TYPE;
public static final MediaType MEDIA_TYPE = MediaType.APPLICATION_OCTET_STREAM;
public ProtoStreamMarshaller(ClassLoaderMarshaller loaderMarshaller, UnaryOperator<SerializationContextBuilder> builder) {
this(builder.apply(new SerializationContextBuilder(loaderMarshaller).register(new IOSerializationContextInitializer())).build());
}
public ProtoStreamMarshaller(ImmutableSerializationContext context) {
super(MEDIA_TYPE, new ProtoStreamByteBufferMarshaller(context));
}
}
| 2,265
| 45.244898
| 137
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/protostream/IOSerializationContextInitializer.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.wildfly.clustering.infinispan.marshalling.protostream;
import org.infinispan.protostream.SerializationContext;
import org.wildfly.clustering.marshalling.protostream.AbstractSerializationContextInitializer;
/**
* @author Paul Ferraro
*/
public class IOSerializationContextInitializer extends AbstractSerializationContextInitializer {
public IOSerializationContextInitializer() {
super("org.infinispan.commons.io.proto");
}
@Override
public void registerMarshallers(SerializationContext context) {
context.registerMarshaller(ByteBufferMarshaller.INSTANCE);
}
}
| 1,637
| 38
| 96
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/protostream/WrappedMessageByteBufferMarshaller.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.wildfly.clustering.infinispan.marshalling.protostream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.PrivilegedAction;
import java.util.OptionalInt;
import java.util.ServiceLoader;
import org.infinispan.protostream.ImmutableSerializationContext;
import org.infinispan.protostream.ProtobufUtil;
import org.infinispan.protostream.SerializationContext;
import org.infinispan.protostream.SerializationContextInitializer;
import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller;
import org.wildfly.security.manager.WildFlySecurityManager;
/**
* A {@link ByteBufferMarshaller} based on a ProtoStream {@link org.infinispan.protostream.WrappedMessage}.
* @author Paul Ferraro
*/
public class WrappedMessageByteBufferMarshaller implements ByteBufferMarshaller {
private final ImmutableSerializationContext context;
public WrappedMessageByteBufferMarshaller(ClassLoader loader) {
this(createSerializationContext(loader));
}
private static ImmutableSerializationContext createSerializationContext(ClassLoader loader) {
SerializationContext context = ProtobufUtil.newSerializationContext();
WildFlySecurityManager.doUnchecked(new PrivilegedAction<>() {
@Override
public Void run() {
for (SerializationContextInitializer initializer : ServiceLoader.load(SerializationContextInitializer.class, loader)) {
initializer.registerSchema(context);
initializer.registerMarshallers(context);
}
return null;
}
});
return context;
}
public WrappedMessageByteBufferMarshaller(ImmutableSerializationContext context) {
this.context = context;
}
@Override
public boolean isMarshallable(Object object) {
return this.context.canMarshall(object);
}
@Override
public Object readFrom(InputStream input) throws IOException {
return ProtobufUtil.fromWrappedStream(this.context, input);
}
@Override
public void writeTo(OutputStream output, Object object) throws IOException {
ProtobufUtil.toWrappedStream(this.context, output, object);
}
@Override
public OptionalInt size(Object object) {
try {
return OptionalInt.of(ProtobufUtil.computeWrappedMessageSize(this.context, object));
} catch (IOException e) {
return OptionalInt.empty();
}
}
}
| 3,545
| 36.723404
| 135
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/protostream/ByteBufferMarshaller.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.wildfly.clustering.infinispan.marshalling.protostream;
import java.io.IOException;
import org.infinispan.commons.io.ByteBufferImpl;
import org.infinispan.protostream.descriptors.WireType;
import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller;
import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader;
import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter;
/**
* Marshaller for an Infinispan ByteBuffer.
* @author Paul Ferraro
*/
public enum ByteBufferMarshaller implements ProtoStreamMarshaller<ByteBufferImpl> {
INSTANCE;
private static final int BUFFER_INDEX = 1;
@Override
public ByteBufferImpl readFrom(ProtoStreamReader reader) throws IOException {
ByteBufferImpl buffer = ByteBufferImpl.EMPTY_INSTANCE;
while (!reader.isAtEnd()) {
int tag = reader.readTag();
switch (WireType.getTagFieldNumber(tag)) {
case BUFFER_INDEX:
buffer = ByteBufferImpl.create(reader.readByteArray());
break;
default:
reader.skipField(tag);
}
}
return buffer;
}
@Override
public void writeTo(ProtoStreamWriter writer, ByteBufferImpl buffer) throws IOException {
int length = buffer.getLength();
if (length > 0) {
writer.writeBytes(BUFFER_INDEX, buffer.getBuf(), buffer.getOffset(), length);
}
}
@Override
public Class<? extends ByteBufferImpl> getJavaClass() {
return ByteBufferImpl.class;
}
}
| 2,624
| 35.971831
| 93
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/jboss/JBossMarshallingVersion.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.wildfly.clustering.infinispan.marshalling.jboss;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.jboss.marshalling.ClassResolver;
import org.jboss.marshalling.MarshallingConfiguration;
import org.wildfly.clustering.infinispan.marshalling.ByteBufferExternalizer;
import org.wildfly.clustering.marshalling.jboss.DynamicClassTable;
import org.wildfly.clustering.marshalling.jboss.DynamicExternalizerObjectTable;
/**
* @author Paul Ferraro
*/
public enum JBossMarshallingVersion implements Function<Map.Entry<ClassResolver, ClassLoader>, MarshallingConfiguration> {
VERSION_1() {
@Override
public MarshallingConfiguration apply(Map.Entry<ClassResolver, ClassLoader> entry) {
MarshallingConfiguration config = new MarshallingConfiguration();
ClassLoader loader = entry.getValue();
config.setClassResolver(entry.getKey());
config.setClassTable(new DynamicClassTable(loader));
config.setObjectTable(new DynamicExternalizerObjectTable(List.of(ByteBufferExternalizer.INSTANCE), List.of(loader)));
return config;
}
},
;
public static final JBossMarshallingVersion CURRENT = VERSION_1;
}
| 2,274
| 41.924528
| 129
|
java
|
null |
wildfly-main/clustering/infinispan/marshalling/src/main/java/org/wildfly/clustering/infinispan/marshalling/jboss/JBossMarshaller.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.wildfly.clustering.infinispan.marshalling.jboss;
import java.util.AbstractMap;
import org.infinispan.commons.dataconversion.MediaType;
import org.jboss.marshalling.ClassResolver;
import org.wildfly.clustering.infinispan.marshalling.UserMarshaller;
import org.wildfly.clustering.marshalling.jboss.JBossByteBufferMarshaller;
import org.wildfly.clustering.marshalling.jboss.MarshallingConfigurationRepository;
import org.wildfly.clustering.marshalling.jboss.SimpleMarshallingConfigurationRepository;
/**
* @author Paul Ferraro
*/
public class JBossMarshaller extends UserMarshaller {
public JBossMarshaller(ClassResolver resolver, ClassLoader loader) {
this(new SimpleMarshallingConfigurationRepository(JBossMarshallingVersion.class, JBossMarshallingVersion.CURRENT, new AbstractMap.SimpleImmutableEntry<>(resolver, loader)), loader);
}
public JBossMarshaller(MarshallingConfigurationRepository repository, ClassLoader loader) {
super(MediaType.APPLICATION_JBOSS_MARSHALLING, new JBossByteBufferMarshaller(repository, loader));
}
}
| 2,104
| 43.787234
| 189
|
java
|
null |
wildfly-main/clustering/infinispan/embedded/service/src/main/java/org/wildfly/clustering/infinispan/service/CacheServiceConfigurator.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.wildfly.clustering.infinispan.service;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.infinispan.AdvancedCache;
import org.infinispan.Cache;
import org.infinispan.cache.impl.AbstractDelegatingAdvancedCache;
import org.infinispan.manager.EmbeddedCacheManager;
import org.jboss.as.clustering.controller.CapabilityServiceConfigurator;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
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.AsyncServiceConfigurator;
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;
/**
* Service that provides a cache and handles its lifecycle
* @author Paul Ferraro
* @param <K> the cache key type
* @param <V> the cache value type
*/
public class CacheServiceConfigurator<K, V> extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, Supplier<Cache<K, V>>, Consumer<Cache<K, V>> {
private final String containerName;
private final String cacheName;
private volatile SupplierDependency<EmbeddedCacheManager> container;
private volatile Dependency configuration;
public CacheServiceConfigurator(ServiceName name, String containerName, String cacheName) {
super(name);
this.containerName = containerName;
this.cacheName = cacheName;
}
@Override
public Cache<K, V> get() {
Cache<K, V> cache = this.container.get().getCache(this.cacheName);
cache.start();
return cache;
}
@Override
public void accept(Cache<K, V> cache) {
cache.stop();
}
@Override
public ServiceConfigurator configure(CapabilityServiceSupport support) {
this.container = new ServiceSupplierDependency<>(InfinispanRequirement.CONTAINER.getServiceName(support, this.containerName));
this.configuration = new ServiceDependency(InfinispanCacheRequirement.CONFIGURATION.getServiceName(support, this.containerName, this.cacheName));
return this;
}
@Override
public final ServiceBuilder<?> build(ServiceTarget target) {
ServiceBuilder<?> builder = new AsyncServiceConfigurator(this.getServiceName()).build(target);
Consumer<Cache<K, V>> cache = new CompositeDependency(this.configuration, this.container).register(builder).provides(this.getServiceName());
Service service = new FunctionalService<>(cache, ManagedCache::new, this, this);
return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
private static class ManagedCache<K, V> extends AbstractDelegatingAdvancedCache<K, V> {
ManagedCache(Cache<K, V> cache) {
this(cache.getAdvancedCache());
}
private ManagedCache(AdvancedCache<K, V> cache) {
super(cache.getAdvancedCache());
}
@SuppressWarnings("unchecked")
@Override
public AdvancedCache rewrap(AdvancedCache delegate) {
return new ManagedCache<>(delegate);
}
@Override
public void start() {
// No-op. Lifecycle managed by container.
}
@Override
public void stop() {
// No-op. Lifecycle managed by container.
}
}
}
| 4,850
| 39.090909
| 166
|
java
|
null |
wildfly-main/clustering/infinispan/embedded/service/src/main/java/org/wildfly/clustering/infinispan/service/TemplateConfigurationServiceConfigurator.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.wildfly.clustering.infinispan.service;
import java.util.function.Consumer;
import org.infinispan.configuration.cache.Configuration;
import org.jboss.as.clustering.controller.CapabilityServiceConfigurator;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.clustering.service.ServiceConfigurator;
import org.wildfly.clustering.service.ServiceSupplierDependency;
import org.wildfly.clustering.service.SupplierDependency;
/**
* Configures a {@link org.jboss.msc.Service} providing a cache configuration based on a configuration template.
* @author Paul Ferraro
*/
public class TemplateConfigurationServiceConfigurator implements CapabilityServiceConfigurator, Consumer<org.infinispan.configuration.cache.ConfigurationBuilder> {
private final ConfigurationServiceConfigurator configurator;
private final String containerName;
private final String templateCacheName;
private volatile SupplierDependency<Configuration> template;
/**
* Constructs a new cache configuration builder.
* @param containerName the name of the cache container
* @param cacheName the name of the target cache
* @param templateCacheName the name of the template cache
*/
public TemplateConfigurationServiceConfigurator(ServiceName name, String containerName, String cacheName, String templateCacheName) {
this(name, containerName, cacheName, templateCacheName, builder -> {});
}
public TemplateConfigurationServiceConfigurator(ServiceName name, String containerName, String cacheName, String templateCacheName, Consumer<org.infinispan.configuration.cache.ConfigurationBuilder> templateConsumer) {
this.configurator = new ConfigurationServiceConfigurator(name, containerName, cacheName, this.andThen(templateConsumer));
this.containerName = containerName;
this.templateCacheName = templateCacheName;
}
@Override
public void accept(org.infinispan.configuration.cache.ConfigurationBuilder builder) {
builder.read(this.template.get());
}
@Override
public ServiceName getServiceName() {
return this.configurator.getServiceName();
}
@Override
public ServiceConfigurator configure(CapabilityServiceSupport support) {
this.template = new ServiceSupplierDependency<>(InfinispanCacheRequirement.CONFIGURATION.getServiceName(support, this.containerName, this.templateCacheName));
this.configurator.configure(support);
return this;
}
@Override
public ServiceBuilder<?> build(ServiceTarget target) {
return this.configurator.require(this.template).build(target);
}
}
| 3,827
| 43.511628
| 221
|
java
|
null |
wildfly-main/clustering/infinispan/embedded/service/src/main/java/org/wildfly/clustering/infinispan/service/InfinispanDefaultCacheRequirement.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.wildfly.clustering.infinispan.service;
import org.infinispan.Cache;
import org.infinispan.configuration.cache.Configuration;
import org.jboss.as.clustering.controller.UnaryRequirementServiceNameFactory;
import org.jboss.as.clustering.controller.UnaryServiceNameFactory;
import org.jboss.as.clustering.controller.UnaryServiceNameFactoryProvider;
import org.wildfly.clustering.service.UnaryRequirement;
/**
* @author Paul Ferraro
*/
public enum InfinispanDefaultCacheRequirement implements UnaryRequirement, UnaryServiceNameFactoryProvider {
CACHE("org.wildfly.clustering.infinispan.default-cache", Cache.class),
CONFIGURATION("org.wildfly.clustering.infinispan.default-cache-configuration", Configuration.class),
;
private final String name;
private final Class<?> type;
private final UnaryServiceNameFactory factory = new UnaryRequirementServiceNameFactory(this);
InfinispanDefaultCacheRequirement(String name, Class<?> type) {
this.name = name;
this.type = type;
}
@Override
public String getName() {
return this.name;
}
@Override
public Class<?> getType() {
return this.type;
}
@Override
public UnaryServiceNameFactory getServiceNameFactory() {
return this.factory;
}
}
| 2,325
| 35.34375
| 108
|
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.