IK.AM

@making's tech note


Try Apache Geode quickly with Docker

🗃 {Middleware/DistributedSystem/InMemoryDataGrid/ApacheGeode}
🏷 Apache Geode 🏷 Docker 
🗓 Updated at 2015-06-17T17:27:16Z  🗓 Created at 2015-06-17T17:27:16Z   🌎 English Page

Apache Geode is OSS version of Pivotal Gemfire which is a distributed in-memory data grid.

I found Docker image for Apache Geode has been published.

So, I tried it. It's really easy if you have already installed Docker!!

(If you not, see how to prepare Docker environment on Mac.)

Run Geode

$ docker run --name geode --rm -it -p 10334:10334 -p 7575:7575 -p 1099:1099  apachegeode/geode:nightly 
    _________________________     __
   / _____/ ______/ ______/ /____/ /
  / /  __/ /___  /_____  / _____  / 
 / /__/ / ____/  _____/ / /    / /  
/______/_/      /______/_/    /_/    v1.0.0-incubating-SNAPSHOT

Monitor and Manage GemFire
gfsh>start locator --name=locator 
Starting a GemFire Locator in /locator...
..................................
Locator in /locator on 45026e875be2[10334] as locator is currently online.
Process ID: 156
Uptime: 18 seconds
GemFire Version: 1.0.0-incubating-SNAPSHOT
Java Version: 1.8.0_45
Log File: /locator/locator.log
JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
Class-Path: /incubator-geode/gemfire-assembly/build/install/apache-geode/lib/gemfire-core-1.0.0-incubating-SNAPSHOT.jar:/incubator-geode/gemfire-assembly/build/install/apache-geode/lib/gemfire-core-dependencies.jar

Successfully connected to: [host=45026e875be2, port=1099]

Cluster configuration service is up and running.

gfsh>start server --name=server
Starting a GemFire Server in /server...
........
Server in /server on 45026e875be2[40404] as server is currently online.
Process ID: 309
Uptime: 4 seconds
GemFire Version: 1.0.0-incubating-SNAPSHOT
Java Version: 1.8.0_45
Log File: /server/server.log
JVM Arguments: -Dgemfire.default.locators=172.17.0.5[10334] -Dgemfire.use-cluster-configuration=true -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
Class-Path: /incubator-geode/gemfire-assembly/build/install/apache-geode/lib/gemfire-core-1.0.0-incubating-SNAPSHOT.jar:/incubator-geode/gemfire-assembly/build/install/apache-geode/lib/gemfire-core-dependencies.jar

gfsh>create region --name=region --type=REPLICATE 
Member | Status
------ | ------------------------------------
server | Region "/region" created on "server"

Write a client application

To skip preparing the developing environment, it's convenient to enter the docker container above ;)

In another tab:

$ docker exec -ti geode bash
[root@45026e875be2 /]# vi HelloWorld.java

In the docker container, open HelloWorld.java with vi:

$ vi HelloWorld.java
import java.util.Map;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.client.*;
 
public class HelloWorld {
  public static void main(String[] args) throws Exception {
    ClientCache cache = new ClientCacheFactory()
      .addPoolLocator("localhost", 10334)
      .create();
    Region<String, String> region = cache
      .<String, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
      .create("region");
 
    region.put("1", "Hello");
    region.put("2", "World");
 
    for (Map.Entry<String, String>  entry : region.entrySet()) {
      System.out.format("key = %s, value = %s\n", entry.getKey(), entry.getValue());
    }
    cache.close();
  }
}

Compile and run with the dependency in the container:

$ javac -cp /incubator-geode/gemfire-assembly/build/install/apache-geode/lib/gemfire-core-dependencies.jar HelloWorld.java
$ java -cp .:/incubator-geode/gemfire-assembly/build/install/apache-geode/lib/gemfire-core-dependencies.jar HelloWorld
[info 2015/06/17 17:29:24.326 UTC <main> tid=0x1] 
---------------------------------------------------------------------------

  Copyright (C) 1997-2015 Pivotal Software, Inc. All rights reserved. This
  product is protected by U.S. and international copyright and intellectual
  property laws. Pivotal products are covered by one or more patents listed
  at http://www.pivotal.io/patents.  Pivotal is a registered trademark
  of trademark of Pivotal Software, Inc. in the United States and/or other
  jurisdictions.  All other marks and names mentioned herein may be
  trademarks of their respective companies.

---------------------------------------------------------------------------
Java version:   1.0.0-incubating-SNAPSHOT null 060215 2015-06-02 01:19:06 +0000 javac 1.8.0_45
Native version: native code unavailable
Source revision: 1366ff2d4fcbf54bfad684e9ba9822db2a2b0ff5
Source repository: master
Running on: 45026e875be2/172.17.0.5, 4 cpu(s), amd64 Linux 3.18.11-tinycore64
Process ID: 465
User: root
Current dir: /
Home dir: /root
Class Path:
  .
  /incubator-geode/gemfire-assembly/build/install/apache-geode/lib/gemfire-core-dependencies.jar
Library Path:
  /usr/java/packages/lib/amd64
  /usr/lib64
  /lib64
  /lib
  /usr/lib
System Properties:
    awt.toolkit = sun.awt.X11.XToolkit
    file.encoding = ANSI_X3.4-1968
    file.encoding.pkg = sun.io
    file.separator = /
    java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
    java.awt.printerjob = sun.print.PSPrinterJob
    java.class.version = 52.0
    java.endorsed.dirs = /jdk1.8.0_45/jre/lib/endorsed
    java.ext.dirs = /jdk1.8.0_45/jre/lib/ext:/usr/java/packages/lib/ext
    java.home = /jdk1.8.0_45/jre
    java.io.tmpdir = /tmp
    java.runtime.name = Java(TM) SE Runtime Environment
    java.runtime.version = 1.8.0_45-b14
    java.specification.name = Java Platform API Specification
    java.specification.vendor = Oracle Corporation
    java.specification.version = 1.8
    java.vendor = Oracle Corporation
    java.vendor.url = http://java.oracle.com/
    java.vendor.url.bug = http://bugreport.sun.com/bugreport/
    java.version = 1.8.0_45
    java.vm.info = mixed mode
    java.vm.name = Java HotSpot(TM) 64-Bit Server VM
    java.vm.specification.name = Java Virtual Machine Specification
    java.vm.specification.vendor = Oracle Corporation
    java.vm.specification.version = 1.8
    java.vm.vendor = Oracle Corporation
    java.vm.version = 25.45-b02
    line.separator = 

    log4j.configurationFile = jar:file:/incubator-geode/gemfire-assembly/build/install/apache-geode/lib/gemfire-core-1.0.0-incubating-SNAPSHOT.jar!/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml
    os.version = 3.18.11-tinycore64
    p2p.useSSL = false
    path.separator = :
    sun.arch.data.model = 64
    sun.boot.class.path = /jdk1.8.0_45/jre/lib/resources.jar:/jdk1.8.0_45/jre/lib/rt.jar:/jdk1.8.0_45/jre/lib/sunrsasign.jar:/jdk1.8.0_45/jre/lib/jsse.jar:/jdk1.8.0_45/jre/lib/jce.jar:/jdk1.8.0_45/jre/lib/charsets.jar:/jdk1.8.0_45/jre/lib/jfr.jar:/jdk1.8.0_45/jre/classes
    sun.boot.library.path = /jdk1.8.0_45/jre/lib/amd64
    sun.cpu.endian = little
    sun.cpu.isalist = 
    sun.io.unicode.encoding = UnicodeLittle
    sun.java.command = HelloWorld
    sun.java.launcher = SUN_STANDARD
    sun.jnu.encoding = ANSI_X3.4-1968
    sun.management.compiler = HotSpot 64-Bit Tiered Compilers
    sun.nio.ch.bugLevel = 
    sun.os.patch.level = unknown
    user.country = US
    user.language = en
    user.timezone = UTC
---------------------------------------------------------------------------


[info 2015/06/17 17:29:24.337 UTC <main> tid=0x1] Running in local mode since mcast-port was 0 and locators was empty.

[info 2015/06/17 17:29:25.059 UTC <main> tid=0x1] Pool DEFAULT started with multiuser-authentication=false

[info 2015/06/17 17:29:25.108 UTC <poolTimer-DEFAULT-3> tid=0x17] Updating membership port.  Port changed from 0 to 53,329.

[info 2015/06/17 17:29:25.111 UTC <poolTimer-DEFAULT-2> tid=0x16] AutoConnectionSource discovered new locators [45026e875be2/172.17.0.5:10334]

key = 1, value = Hello
key = 2, value = World
[info 2015/06/17 17:29:25.534 UTC <main> tid=0x1] GemFireCache[id = 936653983; isClosing = true; isShutDownAll = false; created = Wed Jun 17 17:29:24 UTC 2015; server = false; copyOnRead = false; lockLease = 120; lockTimeout = 60]: Now closing.

[info 2015/06/17 17:29:25.571 UTC <main> tid=0x1] Resetting original MemoryPoolMXBean heap threshold bytes 0 on pool Tenured Gen

[info 2015/06/17 17:29:25.642 UTC <main> tid=0x1] Destroying connection pool DEFAULT

It seems I have succeeded :)

Actually I don't understand what locater, server, region are and HelloWorld.java means.

I'll study from now.


✒️️ Edit  ⏰ History  🗑 Delete