Ignite 之计算运用的 Hello world

Ignite是:
1.一个以内存为中心的数据平台
2.可持久化、强一致和高可用
3.强大的SQL、键-值存储及相关的API

安装

环境准备

Apache Ignite官方在如下环境中进行的测试:

  • JDK:Oracle JDK7及以上,Open JDK7及以上,IBM JDK7及以上
  • OS:Linux(任何版本),Mac OS X(10.6及以上),Windows(XP及以上),Windows Server(2008及以上),Oracle Solaris,本文以win10为例
  • 网络:没有限制(建议10G)
  • 架构:x86,x64,SPARC,PowerPC

下载安装

进入官网下载Apache Ignite的zip压缩包,将zip压缩包解压到系统安装文件夹,设置IGNITE_HOME环境变量指向安装文件夹(这一步是可选项,但建议操作)。

命名行启动

D:\apache-ignite-fabric-2.3.0-bin\bin>ignite.bat
Ignite 之计算运用的 Hello world_第1张图片
命令行启动界面.png

创建集群

再打开一个终端窗口,还是输入上次的命令:

D:\apache-ignite-fabric-2.3.0-bin\bin>ignite.bat
Ignite 之计算运用的 Hello world_第2张图片
add a server.png

再看之前打开的终端,也会动态扩展显示整个集群的信息,如下图:


Ignite 之计算运用的 Hello world_第3张图片
Terminal 1 : add a server.png

Ignite具有非常先进的集群能力,包括逻辑集群组和自动发现。
Ignite节点之间会自动发现对方,这有助于必要时扩展集群,而不需要重启整个集群。

Java 实现Ignite的 hello world

主要的maven依赖:

       
            org.apache.ignite
            ignite-core
            ${ignite.version}
        
        
            org.apache.ignite
            ignite-spring
            ${ignite.version}
        
        
            org.apache.ignite
            ignite-indexing
            ${ignite.version}
        

         
             2.3.0
         

主要逻辑代码

package com.jc.searchengine;

import com.jc.searchengine.po.Person;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;

/**
 * @Author: wangjie
 * @Description: put data and get data
 * @Date: Created in 13:38 2018/3/22
 */
public class HelloWorld
{
    public static void main(String[] args) throws IgniteException {
        try (Ignite ignite = Ignition.start("D:\\apache-ignite-fabric-2.3.0-bin\\examples\\config\\example-cache.xml")) {
            // Put values in cache.
            IgniteCache cache = ignite.getOrCreateCache("myCache");

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

            // Get values from cache and broadcast 'Hello World' on all the nodes in the cluster.
            ignite.compute().broadcast(() -> {
                Person s1 = cache.get(1);
                Person s2 = cache.get(2);

                System.out.println(s1.toString() + " " + s2.toString());
            });
        }
    }
}

控制台输出

运行上诉代码,控制台如下输出:


Ignite 之计算运用的 Hello world_第4张图片
the log of console.png

工程的github地址

程序媛小白一枚,如有错误,烦请批评指正!(#.#)

你可能感兴趣的:(Ignite 之计算运用的 Hello world)