| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This project contains code examples for Apache Ignite 3.
Examples are shipped as a separate Gradle module, so to start running you simply need to import the provided build.gradle file into your favourite IDE.
The following examples are included:
Pull the docker image
docker pull apacheignite/ignite:3.1.0Prepare an environment variable:
IGNITE_SOURCES=/path/to/ignite-sources-dirStart an Ignite node:
docker run --name ignite3-node -d --rm -p 10300:10300 -p 10800:10800 \
-v $IGNITE_SOURCES/examples/java/config/ignite-config.conf:/opt/ignite/etc/ignite-config.conf apacheignite/ignite:3.1.0Get the IP address of the node:
NODE_IP_ADDRESS=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ignite3-node)Initialize the node:
docker run --rm -it apacheignite/ignite:3.1.0 cli cluster init --url http://$NODE_IP_ADDRESS:10300 --name myCluster1 \
--cluster-management-group defaultNode --metastorage-group defaultNodeRun the example via IDE.
Stop the Ignite node:
docker stop ignite3-nodeOpen the Ignite project in your IDE of choice.
Download the Ignite ZIP package including the database and CLI parts. Alternatively, build these parts from the Ignite sources (see DEVNOTES.md). Unpack.
Prepare the environment variables. IGNITE_HOME is used in the Ignite startup. Therefore, you need to export it:
export IGNITE_HOME=/path/to/ignite3-db-dir
IGNITE_CLI_HOME=/path/to/ignite3-cli-dir
IGNITE_SOURCES=/path/to/ignite3-sources-dirOverride the default configuration file:
echo "CONFIG_FILE=$IGNITE_SOURCES/examples/java/config/ignite-config.conf" >> $IGNITE_HOME/etc/vars.envStart an Ignite node using the startup script from the database part:
$IGNITE_HOME/bin/ignite3db startInitialize the cluster using Ignite CLI from the CLI part:
$IGNITE_CLI_HOME/bin/ignite3 cluster init --name myCluster1Run the example from the IDE.
Stop the Ignite node using the startup script:
$IGNITE_HOME/bin/ignite3db stopCompute and streaming examples require deployment units to be deployed to the cluster. There are several ways to run these examples:
From IDE (IDEA Gradle runner):
Simply run the example from your IDE. The deployment unit JAR (deploymentunit-example-1.0.0.jar) is automatically built before execution via the deploymentUnitJar Gradle task and deployed to the cluster if not already present.
Note: The automatic pre-build of the deployment unit JAR relies on the IDEA Gradle runner, which dynamically creates JavaExec tasks. If your IDE uses a different run configuration (e.g., Micronaut plugin, or runs java directly), the deployment unit JAR resource may not be built automatically. In that case, generate it manually first:
./gradlew :ignite-examples:processResourcesand ensure your run configuration includes the Gradle output resources directory (for example, examples/java/build/resources/main) on the classpath.
From Command Line (Gradle):
./gradlew :ignite-examples:run -PmainClass=<ExampleMainClass>From Command Line (java):
Build the project first (compiles classes and embeds the deployment unit JAR as a classpath resource), then run:
./gradlew :ignite-examples:build
java -cp "examples/java/build/classes/java/main:examples/java/build/resources/main:<runtime-jars>" <ExampleMainClass>Where <runtime-jars> is a colon-separated (semicolon on Windows) list of all runtime dependency JARs. These are available in the Gradle cache after the build and can be obtained by inspecting the runtimeClasspath configuration.
If you prefer to deploy the unit manually:
Build the deployment unit JAR:
./gradlew :ignite-examples:deploymentUnitJarDeploy the JAR as a deployment unit using the CLI:
cluster unit deploy <unitName> \
--version 1.0.0 \
--path=examples/java/build/libs/deploymentunit-example-1.0.0.jarCommon unit names used by examples:
Run the example from the IDE.
| Back | FazBrowse Home | New Git URL |