DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Migrate, Modernize and Build Java Web Apps on Azure: This live workshop will cover methods to enhance Java application development workflow.

Modern Digital Website Security: Prepare to face any form of malicious web activity and enable your sites to optimally serve your customers.

Kubernetes in the Enterprise: The latest expert insights on scaling, serverless, Kubernetes-powered AI, cluster security, FinOps, and more.

E-Commerce Development Essentials: Considering starting or working on an e-commerce business? Learn how to create a backend that scales.

Related

  • Quarkus 3: The Future of Java Microservices With Virtual Threads and Beyond
  • A Maven Story
  • Ways To Reduce JVM Docker Image Size
  • The Resurrection of Virtual Threads: Unraveling Their Journey From JDK 1.1 to JDK 21

Trending

  • Enhancing Observability With AI/ML
  • Exploring Apache Airflow for Batch Processing Scenario
  • A Comprehensive Guide to Cloud Monitoring Tools: Ensuring Optimal Performance and Security
  • API-Driven Integration
  1. DZone
  2. Data Engineering
  3. Databases
  4. Getting Started With Apache Ignite

Getting Started With Apache Ignite

This tutorial shows you how to create a simple "Hello World" example in Apache Ignite.

Prachi Garg user avatar by
Prachi Garg
·
Dec. 19, 15 · Tutorial
Like (13)
Save
Tweet
Share
52.8K Views

Join the DZone community and get the full member experience.

Join For Free

The following technologies were used in this example:

  1. Java Development Kit (JDK) 1.8
  2. Apache Ignite 1.5.0-b1
  3. Maven 3.1.1
  4. IntelliJ IDEA 15 CE

Note: JDK 1.7 or above is required.

1. Download and Install Ignite

Download the latest binary distribution from the Apache Ignite website and extract the resulting .zip file to a location of your choice:

$ unzip apache-ignite-fabric-1.5.0-b1-bin.zip
$ cd apache-ignite-fabric-1.5.0-b1-bin

2. Set Environment Variable (Optional)

Set IGNITE_HOME environment variable to point to the installation folder and make sure there is no trailing / in the path. On my Mac, I have set this environment variable in .bash_profile file, like so:

export IGNITE_HOME=<path-to-ignite-installation-folder>

3. Start Ignite Cluster

Start a node using bin/ignite.sh command and specify an example configuration file provided in the Ignite installation:

$ bin/ignite.sh examples/config/example-ignite.xml

If the installation was successful, your Ignite node startup message should look like this:

Image title

Click on the image to view full size.

I have started one more node in another terminal, by repeating the above command (in step 3). 

Image title

Click on the image to view full size.

I now have an Ignite cluster setup with two server nodes running. You can start as many nodes as you like. Ignite will automatically discover all the nodes.

4. Add Ignite Maven Dependency

Add the following Ignite dependencies in your project’s pom.xml file:

<dependency>
    <groupid>org.apache.ignite</groupid>
    <artifactid>ignite-core</artifactid>
    <version>1.5.0-b1</version>
</dependency>

<dependency>
    <groupid>org.apache.ignite</groupid>
    <artifactid>ignite-spring</artifactid>
    <version>1.5.0-b1</version>
</dependency>

5. HelloWorld.java

Here is a sample HelloWord.java file that prints ‘Hello World’ on all the nodes in the cluster.

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;

public class HelloWorld {
  public static void main(String[] args) throws IgniteException {
    try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
      // Put values in cache.
      IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCache");

      cache.put(1, "Hello");
      cache.put(2, "World!");

      // Get values from cache
      // Broadcast 'Hello World' on all the nodes in the cluster.
      ignite.compute().broadcast(()->System.out.println(cache.get(1) + " " + cache.get(2)));
    }
  }
}

6. Project Structure

Review project directory structure:

Image title

7. Set VM Options in IDEA

Go to Run —> Edit Configurations —> VM options (under Configuration tab) and enter:

-DIGNITE_HOME=<path-to-Ignite-installation-folder>

This step is required only because we are trying to provide a relative path to the configuration file in our code (line #7). You can skip this step and provide an absolute path instead.

8. Output

Run HelloWorld.java. You will see ‘Hello World!’ printed on all three nodes. 

On IDEA console:

Image title

Click on the image to view full size.

On both terminals:

Image title

Click on the image to view full size.

Screencast

If you prefer to watch a running example, here is a short screencast.


For more information, documentation, and screencasts, visit the Apache Ignite website.

Apache Ignite intellij Java Development Kit

Opinions expressed by DZone contributors are their own.

Related

  • Quarkus 3: The Future of Java Microservices With Virtual Threads and Beyond
  • A Maven Story
  • Ways To Reduce JVM Docker Image Size
  • The Resurrection of Virtual Threads: Unraveling Their Journey From JDK 1.1 to JDK 21

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: