ignite-redis

Apache Ignite Redis Module

License

License

Categories

Categories

Redis Data Databases
GroupId

GroupId

io.github.aalda
ArtifactId

ArtifactId

ignite-redis
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

ignite-redis
Apache Ignite Redis Module
Project URL

Project URL

http://github.com/aalda/ignite-redis
Source Code Management

Source Code Management

http://github.com/aalda/ignite-redis/tree/master

Download ignite-redis

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.aalda/ignite-redis/ -->
<dependency>
    <groupId>io.github.aalda</groupId>
    <artifactId>ignite-redis</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.aalda/ignite-redis/
implementation 'io.github.aalda:ignite-redis:0.1.0'
// https://jarcasting.com/artifacts/io.github.aalda/ignite-redis/
implementation ("io.github.aalda:ignite-redis:0.1.0")
'io.github.aalda:ignite-redis:jar:0.1.0'
<dependency org="io.github.aalda" name="ignite-redis" rev="0.1.0">
  <artifact name="ignite-redis" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.aalda', module='ignite-redis', version='0.1.0')
)
libraryDependencies += "io.github.aalda" % "ignite-redis" % "0.1.0"
[io.github.aalda/ignite-redis "0.1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.apache.ignite : ignite-core jar 1.7.0
redis.clients : jedis jar 2.8.1

test (8)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.7
org.slf4j : slf4j-log4j12 jar 1.7.7
log4j : log4j jar 1.2.17
com.github.kstyrc : embedded-redis jar 0.6
org.hamcrest : hamcrest-all jar 1.3
org.apache.ignite : ignite-log4j jar 1.7.0
org.apache.ignite : ignite-slf4j jar 1.7.0
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Apache Ignite Redis Module

Build Status Maven Central Javadocs

Apache Ignite Redis module provides a TCP Discovery IP Finder that uses a Redis set to locate other Ignite nodes to connect to.

Currently it does not support Redis clusters.

Importing Apache Ignite Redis Module In Maven Project

If you are using Maven to manage dependencies of your project, you can add the latest version of the Redis module dependency like this:

<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
                        http://maven.apache.org/xsd/maven-4.0.0.xsd">
    ...
    <dependencies>
        ...
        <dependency>
            <groupId>io.github.aalda</groupId>
            <artifactId>ignite-redis</artifactId>
            <version>0.1.0</version>
        </dependency>
        ...
    </dependencies>
    ...
</project>

Configuration

In Ignite, nodes can discover each other by using DiscoverySpi. Ignite provides TcpDiscoverySpi as a default implementation of DiscoverySpi that uses TCP/IP for node discovery. For more information, please refer to the official Apache Ignite Cluster Configuration documentation.

If you're using Redis to coordinate your distributed environment, you can utilize it for a common shared storage of initial IP addresses. This is done via TcpDiscoveryRedisIpFinder.

Here is an example of how to configure this finder via Spring XML file:

<bean class="org.apache.ignite.configuration.IgniteConfiguration">
    ...
    <property name="discoverySpi">
        <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
            <property name="ipFinder">
                 <bean class="io.github.aalda.ignite.spi.discovery.tcp.ipfinder.redis.TcpDiscoveryRedisIpFinder">
                    <property name="redisConnectionString" value="localhost:6379"/>
                    <property name="serviceName" value="myService" />
                 </bean>
            </property>
        </bean>
    </property>
    ...
</bean>

Or programmatically from Java:

TcpDiscoverySpi spi = new TcpDiscoverySpi();

TcpDiscoveryRedisIpFinder ipFinder = new TcpDiscoveryRedisIpFinder();

// Specify Redis connection string.
ipFinder.setRedisConnectionString("127.0.0.1:6379");
ipFinder.serServiceName("myService");

spi.setIpFinder(ipFinder);

IgniteConfiguration cfg = new IgniteConfiguration();

// Override default discovery SPI.
cfg.setDiscoverySpi(spi);

// Start Ignite node.
Ignition.start(cfg);

How it works

Once you have configured the Redis IP Finder, every Ignite node will be able to register its own address in a Set stored in Redis. Such address will follow the pattern "host#port". The format of the key that points to that set will be the concatenation of the service name established through the serviceName property and the suffix "/addresses".

When a node is stopped, it does not unregister itself and remove its address from the Redis set. The coordinator node is responsible for that operation. It frequently runs a clean process that detects left nodes and remove their addresses from the Redis set. You can tune the frequency of this process changing the ipFinderCleanFreq property in the configuration of the TcpDiscoverySpi. By default, it takes the value of 60 seconds.

Note that all nodes are stopped before the clean process is executed, the last node will only be able to unregister its own address but not the remaining ones. So such addresses will remain in the Redis set until a new one node reuse the same ip/port combination. Fortunately, an unreachable IP address will not affect the discovery process.

License

This code is open source software licensed under the Apache 2.0 License.

Versions

Version
0.1.0