Skip to content

Commit

Permalink
Adding GraalVM Dashboard Support..
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzajg committed May 7, 2021
1 parent 65eec02 commit d307d02
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 0 deletions.
100 changes: 100 additions & 0 deletions GraalVM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# VLINGO XOOM Platform - GraalVM Support

Use the VLINGO XOOM OSS platform SDK for rapid delivery of low-code to full-code Reactive, Event-Driven Microservices and Applications using DOMA, DDD, and other approaches.

Docs: https://docs.vlingo.io/

[Official VLINGO XOOM website](https://vlingo.io/).

## Getting started

Prerequisites:
* Java JDK 8 or greater
* Maven
* [GraalVM 21.1.0 Java 8/11](https://www.graalvm.org/docs/getting-started/)

## Native Image Maven Plugin & GraalVM SDK
```
<properties>
...
<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>
<buildArgs>
--shared
-H:DashboardDump=${project.name} -H:+DashboardAll
-H:+DashboardJson -H:+DashboardPretty
--allow-incomplete-classpath
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
...
</profiles>
```
## Class Library Build
- We need to have at least one entry point method for a native image to be useful. \
For shared libraries, Native Image provides the @CEntryPoint annotation to specify entry point methods that should be exported and callable from C.
```
package io.vlingo.xoom.actors.implnative;
import org.graalvm.nativeimage.c.function.CEntryPoint;
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.nativeimage.c.type.CTypeConversion;
import io.vlingo.xoom.actors.plugin.logging.slf4j.Slf4jLoggerPlugin;
public final class NativeImpl {
@CEntryPoint(name = "Java_io_vlingo_xoom_actorsnative_Native_start")
public static int start(@CEntryPoint.IsolateThreadContext long isolateId, CCharPointer name) {
final String nameString = CTypeConversion.toJavaString(name);
Configuration configuration = Configuration.define()
.with(Slf4jLoggerPlugin.Slf4jLoggerPluginConfiguration.define().defaultLogger().name("XOOM"));
World.start(nameString, configuration);
return 0;
}
}
```
- To build the native image run:
```bash
mvn clean install -Pnative-image
```
- Inside target/, will find the generated lib, and the GraalVM Dashboard Dump files (${project.name}.dbv/.dump)\
Go to [GraalVM Dashboard](https://www.graalvm.org/docs/tools/dashboard/) and upload the file..

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ dependencies {
compile 'io.vlingo.xoom:xoom-actors:1.7.6'
}
```
### GraalVM native image build

```bash
mvn clean install -Pmodules -Pnative-image
```
More Details [GraalVM](GraalVM.md)
License (See LICENSE file for full license)
-------------------------------------------
Copyright © 2012-2021 VLINGO LABS. All rights reserved.
Expand Down
36 changes: 36 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<graalvm.version>21.1.0</graalvm.version>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -107,6 +108,12 @@
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>${graalvm.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<repositories>
Expand All @@ -119,6 +126,35 @@
</repositories>

<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>
<buildArgs>
--shared
-H:DashboardDump=${project.name} -H:+DashboardAll
-H:+DashboardJson -H:+DashboardPretty
--allow-incomplete-classpath
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>sign-artifacts</id>
<activation>
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/io/vlingo/xoom/actors/implnative/NativeImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.vlingo.xoom.actors.implnative;

import io.vlingo.xoom.actors.Configuration;
import io.vlingo.xoom.actors.World;
import io.vlingo.xoom.actors.plugin.logging.slf4j.Slf4jLoggerPlugin;
import org.graalvm.nativeimage.c.function.CEntryPoint;
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.nativeimage.c.type.CTypeConversion;

public final class NativeImpl {
@CEntryPoint(name = "Java_io_vlingo_xoom_actorsnative_Native_start")
public static int start(@CEntryPoint.IsolateThreadContext long isolateId, CCharPointer name) {
final String nameString = CTypeConversion.toJavaString(name);

Configuration configuration = Configuration.define()
.with(Slf4jLoggerPlugin.Slf4jLoggerPluginConfiguration.define().defaultLogger().name("XOOM"));
World.start(nameString, configuration);
return 0;
}
}

0 comments on commit d307d02

Please sign in to comment.