Skip to content

Commit

Permalink
almost got it
Browse files Browse the repository at this point in the history
  • Loading branch information
wburns committed Oct 4, 2021
1 parent 4a56fd2 commit 19c0737
Show file tree
Hide file tree
Showing 12 changed files with 374 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.infinispan.configuration.cache.StoreConfiguration;
import org.infinispan.configuration.cache.StoreConfigurationBuilder;
import org.infinispan.configuration.parsing.ConfigurationParser;
import org.infinispan.configuration.serializing.ConfigurationSerializer;
import org.infinispan.configuration.serializing.SerializedWith;
import org.infinispan.distribution.ch.ConsistentHashFactory;
import org.infinispan.distribution.ch.impl.HashFunctionPartitioner;
import org.infinispan.factories.impl.ModuleMetadataBuilder;
Expand All @@ -30,6 +32,7 @@
import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
import org.infinispan.persistence.spi.CacheLoader;
import org.infinispan.persistence.spi.CacheWriter;
import org.infinispan.persistence.spi.NonBlockingStore;
import org.infinispan.quarkus.embedded.runtime.InfinispanEmbeddedProducer;
import org.infinispan.quarkus.embedded.runtime.InfinispanEmbeddedRuntimeConfig;
import org.infinispan.quarkus.embedded.runtime.InfinispanRecorder;
Expand Down Expand Up @@ -102,7 +105,12 @@ void setup(BuildProducer<FeatureBuildItem> feature, BuildProducer<ReflectiveClas
"default-configs/default-jgroups-kubernetes.xml",
"default-configs/default-jgroups-ec2.xml",
"default-configs/default-jgroups-google.xml",
"default-configs/default-jgroups-azure.xml"));
"default-configs/default-jgroups-azure.xml",
"stacks/udp.xml",
"stacks/tcp.xml",
"stacks/tcp_mping/tcp1.xml",
"stacks/tcp_mping/tcp2.xml"
));

reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, HashFunctionPartitioner.class));
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, JGroupsTransport.class));
Expand Down Expand Up @@ -148,6 +156,8 @@ void setup(BuildProducer<FeatureBuildItem> feature, BuildProducer<ReflectiveClas
addReflectionForClass(CacheLoader.class, true, combinedIndex, reflectiveClass, excludedClasses);
addReflectionForClass(CacheWriter.class, true, combinedIndex, reflectiveClass, excludedClasses);

addReflectionForClass(NonBlockingStore.class, true, combinedIndex, reflectiveClass, excludedClasses);

// We have to include all of our interceptors - technically a custom one is installed before or after ISPN ones
// If we don't want to support custom interceptors this should be removable
// We use reflection to set fields from the properties so those must be exposed as well
Expand All @@ -161,6 +171,9 @@ void setup(BuildProducer<FeatureBuildItem> feature, BuildProducer<ReflectiveClas
addReflectionForName(StoreConfiguration.class.getName(), true, combinedIndex, reflectiveClass, true, false,
excludedClasses);

// We use reflection to find various configuration serializers
addReflectionForClass(ConfigurationSerializer.class, true, combinedIndex, reflectiveClass, excludedClasses);

reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, Util.AddressScope.class));

// Add Infinispan and user listeners to reflection list
Expand All @@ -186,14 +199,11 @@ void setup(BuildProducer<FeatureBuildItem> feature, BuildProducer<ReflectiveClas
// it would be nice to not have this required for Infinispan classes
Collection<AnnotationInstance> serializeWith = combinedIndex
.getAnnotations(DotName.createSimple(SerializeWith.class.getName()));
for (AnnotationInstance instance : serializeWith) {
AnnotationValue withValue = instance.value();
String withValueString = withValue.asString();
DotName targetSerializer = DotName.createSimple(withValueString);
if (!excludedClasses.contains(targetSerializer)) {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, withValueString));
}
}
registerSerializeWith(serializeWith, reflectiveClass, excludedClasses);

// Configuration serializes with classes loaded via serialization
serializeWith = combinedIndex.getAnnotations(DotName.createSimple(SerializedWith.class.getName()));
registerSerializeWith(serializeWith, reflectiveClass, excludedClasses);

// This contains parts from the index from the app itself
Index appOnlyIndex = applicationIndexBuildItem.getIndex();
Expand All @@ -205,6 +215,18 @@ void setup(BuildProducer<FeatureBuildItem> feature, BuildProducer<ReflectiveClas
addReflectionForClass(AbstractExternalizer.class, false, appOnlyIndex, reflectiveClass, Collections.emptySet());
}

private void registerSerializeWith(Collection<AnnotationInstance> serializeWith,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass, Set<DotName> excludedClasses) {
for (AnnotationInstance instance : serializeWith) {
AnnotationValue withValue = instance.value();
String withValueString = withValue.asString();
DotName targetSerializer = DotName.createSimple(withValueString);
if (!excludedClasses.contains(targetSerializer)) {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, withValueString));
}
}
}

private void addReflectionForClass(Class<?> classToUse, boolean isInterface, IndexView indexView,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass, Set<DotName> excludedClasses) {
addReflectionForName(classToUse.getName(), isInterface, indexView, reflectiveClass, false, false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.infinispan.quarkus.embedded.runtime.graal;

import java.security.SecureRandom;
import java.util.Random;

import org.jgroups.JChannel;
import org.jgroups.protocols.DELAY;
import org.jgroups.util.UUID;
import org.jgroups.util.Util;

Expand All @@ -22,6 +24,14 @@ final class SubstituteUUID {
protected static volatile SecureRandom numberGenerator;
}

@TargetClass(DELAY.class)
final class SubstitueDELAY {
@Alias
// Force it to null - so it can be reinitialized
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)
protected static volatile Random randomNumberGenerator;
}

// DISCARD protocol uses swing classes
@TargetClass(className = "org.jgroups.protocols.DISCARD")
final class SubstituteDiscardProtocol {
Expand Down
33 changes: 7 additions & 26 deletions integration-tests/embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,18 @@

<profiles>
<profile>
<id>native-image</id>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
Expand All @@ -115,31 +117,10 @@
<goal>verify</goal>
</goals>
<configuration>
<systemProperties>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<id>native-image</id>
<goals>
<goal>native-image</goal>
</goals>
<configuration>
<cleanupServer>true</cleanupServer>
<enableHttpUrlHandler>true</enableHttpUrlHandler>
<!-- We have some example stack files we want to use -->
<additionalBuildArgs>
<additionalBuildArg>-H:ResourceConfigurationFiles=resources-config.json</additionalBuildArg>
</additionalBuildArgs>
<graalvmHome>${graalvmHome}</graalvmHome>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<packaging>pom</packaging>

<properties>
<quarkus.version>1.11.0.Final</quarkus.version>
<quarkus.version>2.2.3.Final</quarkus.version>
</properties>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion server-runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
<executions>
<execution>
<goals>
<goal>native-image</goal>
<goal>build</goal>
</goals>
<configuration>
<!-- Required for cluster communication -->
Expand Down
47 changes: 17 additions & 30 deletions server-runner/src/test/resources/conf/infinispan-local.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:10.0 http://www.infinispan.org/schemas/infinispan-config-10.0.xsd
urn:infinispan:server:10.0 http://www.infinispan.org/schemas/infinispan-server-10.0.xsd"
xmlns="urn:infinispan:config:10.0"
xmlns:server="urn:infinispan:server:10.0">
xsi:schemaLocation="urn:infinispan:config:13.0 https://infinispan.org/schemas/infinispan-config-13.0.xsd
urn:infinispan:server:13.0 https://infinispan.org/schemas/infinispan-server-13.0.xsd"
xmlns="urn:infinispan:config:13.0"
xmlns:server="urn:infinispan:server:13.0">

<cache-container>
<cache-container name="default" statistics="true">
<local-cache name="quarkus-infinispan-server"/>
</cache-container>

<server xmlns="urn:infinispan:server:10.0">
<server xmlns="urn:infinispan:server:13.0">
<interfaces>
<interface name="public">
<inet-address value="${infinispan.bind.address:127.0.0.1}"/>
Expand All @@ -21,30 +21,17 @@
<socket-binding name="memcached" port="11221"/>
</socket-bindings>

<security>
<security-realms>
<security-realm name="default">
<!-- Uncomment to enable TLS on the realm -->
<!-- server-identities>
<ssl>
<keystore path="application.keystore" relative-to="infinispan.server.config.path"
keystore-password="password" alias="server" key-password="password"
generate-self-signed-certificate-host="localhost"/>
</ssl>
</server-identities-->
<properties-realm groups-attribute="Roles">
<user-properties path="users.properties" relative-to="infinispan.server.config.path" plain-text="true"/>
<group-properties path="groups.properties" relative-to="infinispan.server.config.path" />
</properties-realm>
</security-realm>
</security-realms>
</security>

<endpoints socket-binding="default" security-realm="default">
<hotrod-connector name="hotrod"/>
<rest-connector name="rest"/>
<!-- Uncomment to enable the memcached connector -->
<!-- memcached-connector socket-binding="memcached" / -->
<endpoints>
<endpoint socket-binding="default">
<ip-filter>
<reject from="172.16.0.0/16"/>
<accept from="127.0.0.0/8"/>
</ip-filter>
<hotrod-connector name="hotrod"/>
<rest-connector name="rest"/>
<!-- Uncomment to enable the memcached connector -->
<!-- memcached-connector socket-binding="memcached" / -->
</endpoint>
</endpoints>
</server>
</infinispan>
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ void extensionFeatureStuff(BuildProducer<FeatureBuildItem> feature, BuildProduce
"infinispan-cachestore-jdbc",
"infinispan-cachestore-rocksdb",
"infinispan-cachestore-remote",
"infinispan-persistence-soft-index",
"infinispan-clustered-counter",
"infinispan-clustered-lock"
)) {
Expand Down
Loading

0 comments on commit 19c0737

Please sign in to comment.