Skip to content

Latest commit

 

History

History
148 lines (141 loc) · 3.84 KB

GraalVM.md

File metadata and controls

148 lines (141 loc) · 3.84 KB

xoom-schemata - GraalVM Support

The VLINGO XOOM Schema Registry.

Getting started

Prerequisites:

Maven build

mvn clean package -Pfrontend
  • Generate native image resources Configs
java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/io.vlingo.xoom/xoom-schemata -jar target/xoom-schemata-<version>-SNAPSHOT-jar-with-dependencies.jar dev

Tips to load more resources and reflection for the agent

  • Open browser and Reload all web pages to register all resources files
  • Test functionality
  • Delete from resource-config.json all {"pattern":"\\Qfrontend/<directory>\\E"},
  • Adding missing serialization:
[
  ...
  {
    "name": "java.sql.Timestamp"
  },
  {
    "name": "java.lang.Object"
  },
  {
    "name": "java.lang.Boolean"
  },
  {
    "name": "java.lang.Character"
  },
  {
    "name": "java.lang.Double"
  },
  {
    "name": "java.lang.Float"
  },
  {
    "name": "java.lang.Long"
  },
  {
    "name": "java.lang.Integer"
  },
  {
    "name": "java.lang.Short"
  },
  {
    "name": "java.lang.Byte"
  },
  {
    "name": "java.lang.String"
  },
  ...
]

Native Image Maven Plugin & GraalVM SDK

<properties>
    ...
    <exec.mainClass>io.vlingo.xoom.schemata.XoomInitializer</exec.mainClass>
    <graalvm.version>21.1.0</graalvm.version>
    ...
</properties>
<dependencies>
    ...
    <dependency>
      <groupId>org.graalvm.sdk</groupId>
      <artifactId>graal-sdk</artifactId>
      <version>${graalvm.version}</version>
      <scope>provided</scope>
    </dependency>
    ...
</dependencies>

<profiles>
    ...
    <profile>
      <id>native-image</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.graalvm.nativeimage</groupId>
            <artifactId>native-image-maven-plugin</artifactId>
            <version>${graalvm.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>native-image</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
            <configuration>
              <imageName>${project.name}</imageName>
              <mainClass>${exec.mainClass}</mainClass>
              <buildArgs>
                --no-fallback --no-server --enable-url-protocols=http -H:+AllowIncompleteClasspath
                -H:ReflectionConfigurationFiles=classes/META-INF/native-image/reflect-config.json
                -H:ResourceConfigurationFiles=classes/META-INF/native-image/resource-config.json
                -H:SerializationConfigurationFiles=classes/META-INF/native-image/serialization-config.json
                --initialize-at-run-time=io.netty
                --initialize-at-run-time=io.vlingo.xoom.common.identity.IdentityGeneratorType
                --report-unsupported-elements-at-runtime
                --allow-incomplete-classpath
              </buildArgs>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    ...
</profiles>
  • To build the native image run:
mvn clean package -Pfrontend -Pnative-image
./target/xoom-schemata dev
  • On native image runtime, an exception is always thrown, issue described here: ISSUE

Docker build and run

  • Increase the Docker Memory Resource to +8Go.
  • First build the jar file:
mvn clean package -Pfrontend
  • Build the docker image
docker build -f Dockerfile.native -t vlingo/xoom-schemata .
  • Run the docker image
docker run -it --rm -eXOOM_ENV=dev -p '9019:9019' vlingo/xoom-schemata
  • On native image runtime, a netty native transport epoll issue: PR