Skip to content

Commit

Permalink
Initial Neo4j Nima support
Browse files Browse the repository at this point in the history
  • Loading branch information
dalexandrov committed May 25, 2023
1 parent c3744b5 commit 546c1e8
Show file tree
Hide file tree
Showing 30 changed files with 2,053 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,16 @@
<artifactId>helidon-integrations-neo4j-metrics</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j-nima</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j-health-nima</artifactId>
<version>${helidon.version}</version>
</dependency>
<!-- Bean Validation -->
<dependency>
<groupId>io.helidon.microprofile.bean-validation</groupId>
Expand Down
4 changes: 4 additions & 0 deletions etc/copyright-exclude.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ src/main/java/io/helidon/examples/integrations/neo4j/se/domain/Actor.java
src/main/java/io/helidon/examples/integrations/neo4j/se/domain/Movie.java
src/main/java/io/helidon/examples/integrations/neo4j/se/domain/Person.java
src/main/java/io/helidon/examples/integrations/neo4j/se/domain/MovieRepository.java
src/main/java/io/helidon/examples/integrations/neo4j/nima/domain/Actor.java
src/main/java/io/helidon/examples/integrations/neo4j/nima/domain/Movie.java
src/main/java/io/helidon/examples/integrations/neo4j/nima/domain/Person.java
src/main/java/io/helidon/examples/integrations/neo4j/nima/domain/MovieRepository.java
etc/THIRD_PARTY_LICENSES.xml
etc/HELIDON_THIRD_PARTY_LICENSES.xml
etc/dependency-check-suppression.xml
Expand Down
1 change: 1 addition & 0 deletions examples/integrations/neo4j/neo4j-nima/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/*
164 changes: 164 additions & 0 deletions examples/integrations/neo4j/neo4j-nima/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Helidon SE integration with Neo4J example

## Build and run

Bring up a Neo4j instance via Docker

```bash
docker run --publish=7474:7474 --publish=7687:7687 -e 'NEO4J_AUTH=neo4j/secret' neo4j:4.0
```

Goto the Neo4j browser and play the first step of the movies graph: [`:play movies`](http://localhost:7474/browser/?cmd=play&arg=movies).

Build and run with With JDK11+
```bash
mvn package
java -jar target/helidon-examples-integration-neo4j-se.jar
```

Then access the rest API like this:

````
curl localhost:8080/api/movies
````

# Health and metrics

Neo4jSupport provides health checks and metrics reading from Neo4j.

Enable them in the driver:
```yaml
pool:
metricsEnabled: true
```
````
curl localhost:8080/health
````
````
curl localhost:8080/metrics
````
## Build the Docker Image
```
docker build -t helidon-integrations-heo4j-se .
```

## Start the application with Docker

```
docker run --rm -p 8080:8080 helidon-integrations-heo4j-se:latest
```

Exercise the application as described above

## Deploy the application to Kubernetes

```
kubectl cluster-info # Verify which cluster
kubectl get pods # Verify connectivity to cluster
kubectl create -f app.yaml # Deply application
kubectl get service helidon-integrations-heo4j-se # Get service info
```

## Build a native image with GraalVM

GraalVM allows you to compile your programs ahead-of-time into a native
executable. See https://www.graalvm.org/docs/reference-manual/aot-compilation/
for more information.

You can build a native executable in 2 different ways:
* With a local installation of GraalVM
* Using Docker

### Local build

Download Graal VM at https://www.graalvm.org/downloads. We recommend
version `20.1.0` or later.

```
# Setup the environment
export GRAALVM_HOME=/path
# build the native executable
mvn package -Pnative-image
```

You can also put the Graal VM `bin` directory in your PATH, or pass
`-DgraalVMHome=/path` to the Maven command.

See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plugin#goal-native-image
for more information.

Start the application:

```
./target/helidon-integrations-heo4j-se
```

### Multi-stage Docker build

Build the "native" Docker Image

```
docker build -t helidon-integrations-heo4j-se-native -f Dockerfile.native .
```

Start the application:

```
docker run --rm -p 8080:8080 helidon-integrations-heo4j-se-native:latest
```

## Build a Java Runtime Image using jlink

You can build a custom Java Runtime Image (JRI) containing the application jars and the JDK modules
on which they depend. This image also:

* Enables Class Data Sharing by default to reduce startup time.
* Contains a customized `start` script to simplify CDS usage and support debug and test modes.

You can build a custom JRI in two different ways:
* Local
* Using Docker


### Local build

```
# build the JRI
mvn package -Pjlink-image
```

See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plugin#goal-jlink-image
for more information.

Start the application:

```
./target/helidon-integrations-heo4j-se-jri/bin/start
```

### Multi-stage Docker build

Build the JRI as a Docker Image

```
docker build -t helidon-integrations-heo4j-se-jri -f Dockerfile.jlink .
```

Start the application:

```
docker run --rm -p 8080:8080 helidon-integrations-heo4j-se-jri:latest
```

See the start script help:

```
docker run --rm helidon-integrations-heo4j-se-jri:latest --help
```
134 changes: 134 additions & 0 deletions examples/integrations/neo4j/neo4j-nima/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.applications</groupId>
<artifactId>helidon-nima</artifactId>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../../../../applications/nima/pom.xml</relativePath>
</parent>
<groupId>io.helidon.examples.integrations.neo4j</groupId>
<artifactId>helidon-examples-integration-neo4j-nima</artifactId>
<name>Helidon Integrations Neo4j Nima Example</name>

<properties>
<mainClass>io.helidon.examples.integrations.neo4j.se.Main</mainClass>
<neo4j-harness.version>4.4.3</neo4j-harness.version>
</properties>

<dependencies>
<dependency>
<groupId>io.helidon.nima.webserver</groupId>
<artifactId>helidon-nima-webserver</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.health</groupId>
<artifactId>helidon-health-checks</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.http.media</groupId>
<artifactId>helidon-nima-http-media-jsonp</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-yaml</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.observe</groupId>
<artifactId>helidon-nima-observe</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.observe</groupId>
<artifactId>helidon-nima-observe-health</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j-nima</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j-health-nima</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.nima.webclient</groupId>
<artifactId>helidon-nima-webclient</artifactId>
<scope>test</scope>
</dependency>
<!--Neo4j harness -->
<dependency>
<groupId>org.neo4j.test</groupId>
<artifactId>neo4j-harness</artifactId>
<version>${neo4j-harness.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-libs</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--
This is needed for Java 17, where Neo4j can no longer access
non-public field of Throwable. This is not needed for runtime,
as the database process is separate from the application
-->
<argLine>
--enable-preview
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.nio=ALL-UNNAMED
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 546c1e8

Please sign in to comment.