Search in sources :

Example 1 with Features

use of org.infinispan.commons.util.Features in project infinispan by infinispan.

the class ConfigurationBuilder method create.

@Override
public Configuration create() {
    List<ServerConfiguration> servers = new ArrayList<>();
    if (this.servers.size() > 0)
        for (ServerConfigurationBuilder server : this.servers) {
            servers.add(server.create());
        }
    else {
        servers.add(new ServerConfiguration("127.0.0.1", ConfigurationProperties.DEFAULT_HOTROD_PORT));
    }
    List<ClusterConfiguration> serverClusterConfigs = clusters.stream().map(ClusterConfigurationBuilder::create).collect(Collectors.toList());
    Marshaller buildMarshaller = this.marshaller;
    if (buildMarshaller == null && marshallerClass == null) {
        buildMarshaller = handleNullMarshaller();
    }
    Class<? extends Marshaller> buildMarshallerClass = this.marshallerClass;
    if (buildMarshallerClass == null) {
        // Populate the marshaller class as well, so it can be exported to properties
        buildMarshallerClass = buildMarshaller.getClass();
    } else {
        if (buildMarshaller != null && !buildMarshallerClass.isInstance(buildMarshaller))
            throw new IllegalArgumentException("Both marshaller and marshallerClass attributes are present, but marshaller is not an instance of marshallerClass");
    }
    Map<String, RemoteCacheConfiguration> remoteCaches = remoteCacheBuilders.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().create()));
    return new Configuration(asyncExecutorFactory.create(), balancingStrategyFactory, classLoader == null ? null : classLoader.get(), clientIntelligence, connectionPool.create(), connectionTimeout, consistentHashImpl, forceReturnValues, keySizeEstimate, buildMarshaller, buildMarshallerClass, protocolVersion, servers, socketTimeout, security.create(), tcpNoDelay, tcpKeepAlive, valueSizeEstimate, maxRetries, nearCache.create(), serverClusterConfigs, allowListRegExs, batchSize, transaction.create(), statistics.create(), features, contextInitializers, remoteCaches, transportFactory);
}
Also used : Arrays(java.util.Arrays) StringPropertyReplacer(org.infinispan.commons.util.StringPropertyReplacer) HotRodURI(org.infinispan.client.hotrod.impl.HotRodURI) Log(org.infinispan.client.hotrod.logging.Log) ConsistentHashV2(org.infinispan.client.hotrod.impl.consistenthash.ConsistentHashV2) HashMap(java.util.HashMap) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) HashSet(java.util.HashSet) LogFactory(org.infinispan.client.hotrod.logging.LogFactory) Matcher(java.util.regex.Matcher) SerializationContextInitializer(org.infinispan.protostream.SerializationContextInitializer) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) Features(org.infinispan.commons.util.Features) TypedProperties(org.infinispan.commons.util.TypedProperties) URI(java.net.URI) WeakReference(java.lang.ref.WeakReference) FailoverRequestBalancingStrategy(org.infinispan.client.hotrod.FailoverRequestBalancingStrategy) TransportFactory(org.infinispan.client.hotrod.TransportFactory) HOTROD(org.infinispan.client.hotrod.logging.Log.HOTROD) SegmentConsistentHash(org.infinispan.client.hotrod.impl.consistenthash.SegmentConsistentHash) Builder(org.infinispan.commons.configuration.Builder) Properties(java.util.Properties) ConfigurationProperties(org.infinispan.client.hotrod.impl.ConfigurationProperties) Util(org.infinispan.commons.util.Util) Set(java.util.Set) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) ProtocolVersion(org.infinispan.client.hotrod.ProtocolVersion) ConsistentHash(org.infinispan.client.hotrod.impl.consistenthash.ConsistentHash) Pattern(java.util.regex.Pattern) ProtoStreamMarshaller(org.infinispan.commons.marshall.ProtoStreamMarshaller) Collections(java.util.Collections) RoundRobinBalancingStrategy(org.infinispan.client.hotrod.impl.transport.tcp.RoundRobinBalancingStrategy) Marshaller(org.infinispan.commons.marshall.Marshaller) ProtoStreamMarshaller(org.infinispan.commons.marshall.ProtoStreamMarshaller) Marshaller(org.infinispan.commons.marshall.Marshaller) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with Features

use of org.infinispan.commons.util.Features in project infinispan by infinispan.

the class GlobalConfigurationBuilder method validate.

public void validate() {
    features = new Features(cl);
    List<RuntimeException> validationExceptions = new ArrayList<>();
    Arrays.asList(cacheContainerConfiguration, site).forEach(c -> {
        try {
            c.validate();
        } catch (RuntimeException e) {
            validationExceptions.add(e);
        }
    });
    modules.values().forEach(c -> {
        try {
            c.validate();
        } catch (RuntimeException e) {
            validationExceptions.add(e);
        }
    });
    CacheConfigurationException.fromMultipleRuntimeExceptions(validationExceptions).ifPresent(e -> {
        throw e;
    });
}
Also used : ArrayList(java.util.ArrayList) Features(org.infinispan.commons.util.Features)

Example 3 with Features

use of org.infinispan.commons.util.Features in project infinispan by infinispan.

the class AbstractInfinispanServerDriver method prepare.

/**
 * Prepare a server layout
 */
@Override
public void prepare(String name) {
    this.name = name;
    if (configuration.getFeatures() != null) {
        // if the feature isn't enabled, the test will be skipped
        Features features = new Features(this.getClass().getClassLoader());
        for (String feature : configuration.getFeatures()) {
            Assume.assumeTrue(String.format("%s is disabled", feature), features.isAvailable(feature));
        }
    }
    String siteName = configuration.site() == null ? "" : configuration.site();
    String testDir = CommonsTestingUtil.tmpDirectory(siteName + name);
    Util.recursiveFileRemove(testDir);
    rootDir = new File(testDir);
    confDir = new File(rootDir, Server.DEFAULT_SERVER_CONFIG);
    if (!confDir.mkdirs()) {
        throw new RuntimeException("Failed to create server configuration directory " + confDir);
    }
    // if the file is not a default file, we need to copy the file from the resources folder to the server conf dir
    if (!configuration.isDefaultFile()) {
        copyProvidedServerConfigurationFile();
    }
    createUserFile("default");
    createKeyStores();
}
Also used : Features(org.infinispan.commons.util.Features) File(java.io.File)

Example 4 with Features

use of org.infinispan.commons.util.Features in project infinispan by infinispan.

the class FeaturesListener method intercept.

@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
    Object instance = methods.get(0).getMethod().getInstance();
    Features features = new Features(instance.getClass().getClassLoader());
    AbstractInfinispanTest.FeatureCondition featureCondition = instance.getClass().getAnnotation(AbstractInfinispanTest.FeatureCondition.class);
    if (featureCondition != null && !features.isAvailable(featureCondition.feature())) {
        for (IMethodInstance methodInstance : methods) {
            methodInstance.getMethod().setMissingGroup(featureCondition.feature() + " is disabled.");
        }
        // the annotation is based on the class
        BaseTestMethod baseTestMethod = getBaseMethod(methods.get(0));
        clearBeforeAfterClassMethods(baseTestMethod.getTestClass());
    }
    return methods;
}
Also used : Features(org.infinispan.commons.util.Features) IMethodInstance(org.testng.IMethodInstance) BaseTestMethod(org.testng.internal.BaseTestMethod)

Aggregations

Features (org.infinispan.commons.util.Features)4 ArrayList (java.util.ArrayList)2 File (java.io.File)1 WeakReference (java.lang.ref.WeakReference)1 URI (java.net.URI)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Set (java.util.Set)1 TimeUnit (java.util.concurrent.TimeUnit)1 BiConsumer (java.util.function.BiConsumer)1 Supplier (java.util.function.Supplier)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 FailoverRequestBalancingStrategy (org.infinispan.client.hotrod.FailoverRequestBalancingStrategy)1