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

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 (this step is 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:

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). 
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 Depedency

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.IgniteCache;
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 and
      // broadcast 'Hello World' on all the nodes in the cluster.
      ignite.compute().broadcast(() -> {
        String hello = cache.get(1);
        String world = cache.get(2);

        System.out.println(hello + " " + world);
      });
    }
  }
}

6.  Project Structure

Review project directory structure.
Click on the image to view full size.

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
Click on the image to view full size.


On both terminals
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.


In a multi-user environment, concurrent transactions on the same set of cache entries can cause deadlocks – an unfavorable situation that adversely affects the performance of any application. Once a system enters a heavy deadlock state, recovery may require a complete cluster re-start. Keeping this in mind, Apache Ignite came up with ACID compliant Deadlock-Free Transactions that can prevent deadlocks and enhance application performance. Before looking into this feature in more detail, let’s briefly go through the basics.

What is a Deadlock?

A deadlock is a situation where a transaction T1 waits indefinitely for a resource R2 that is held by another transaction T2; and T2 waits for a resource R1 that is held by T1.

Data can be loaded directly from any persistent store into Ignite caches. This example shows you how to load data from a MySQL database into an Ignite distributed cache. Here, I am assuming that you already have Apache Ignite installed on your system. If not, you can go through this tutorial first.

1.  Sample PERSON table

To start with, here is what the PERSON data in my database looks like-

2.  Model 

Here is a sample Person.java class corresponding to the PERSON table in the database.

For systems where low latency is critical, there is nothing better than caching the data in memory in a distributed cluster. While storing data in memory provides fast data access, distributing it on a cluster of nodes increases application performance and scalability. And Apache Ignite helps you achieve exactly that.

Ignite data grid is a distributed in-memory key-value store. It can also be viewed as a partitioned hash map that enables caching data in-memory over multiple server nodes.

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

The following technologies were used in this example:

Java Development Kit (JDK) 1.8 Apache Ignite 1.5.0-b1 Maven 3.1.1 IntelliJ IDEA 15 CE

Note: JDK 1.7 or above is required.

1.

Businesses are accumulating data at enormous rates requiring huge amounts of storage. Managing large data is hard, but processing it is even more challenging. With terabytes of data to store and process, it is often the case that developers find themselves in a quandary about how to strike the right balance between speed, scalability, and cost. 

Storing data in cache can significantly enhance the speed of your application.

In a distributed environment, deploying a user-defined data structure as cluster wide service can provide access to all its operations, from anywhere in the grid. For example, you can have your own implementation of a distributed SecureMap, which auto-encrypts its values and is deployed as a service on all the cluster nodes.

In GridGain, you can implement your own custom data structures and deploy them as distributed services on the grid.

When storing data in a distributed cache, Map is the most obvious data structure. But, there are times when applications need to process data in the order it is received. GridGain In-Memory Data Fabric, in addition to providing standard key-value map-like storage, has an implementation of fast Distributed Blocking Queue.

As an implementation of java.util.concurrent.BlockingQueue, GridGain Distributed Queue also supports all operations from java.util.Collection interface.

Failing-over web session caching is problematic when you run multiple application servers. It is not uncommon for web applications to run in a cluster to distribute the load of high volume of web requests. But what if one of the application servers crashes? The load balancer will just route the web request to another available application server, but all of user’s session data is lost.
Blog Archive
Loading
Dynamic Views theme. Powered by Blogger.