読者です 読者をやめる 読者になる 読者になる

Quitada ブログ HAX

Hatena Blog でも Quitada ブログ

Apache Geode Native Client on macOS

Introduction

Apache Geode is the OSS version of Pivotal GemFire (now, Pivotal GemFire may be the commercial version of Apache Geode, though). Yeah, it's one of the implementation of in-memory data grid based on Java. In other words, it's one of the implementation of in-memory key-value store with event processing feaure and so on.

 

Pivotal GemFire Native Client has been the family product of Pivotal GemFire, which provides GemFire client capability for C# and C++ application running on Windows, Linux and Solaris platform. Now, it's open-sourced as Apache Geode Native Client.

 

The most interesting thing of mine for Apache Geode Native Client is supporting macOS additionally. It means that C++ applications running on macOS can access Apache Geode servers natively (I don't have any ideas how many developers want to develop C++ application on macOS rather than Objective-C or Swift applications). Anyhow, I tried to build and install Apache Geode Native Client on macOS. And also, I tried to compile sample C++ application based on Apache Geode Native Client on macOS (actually, I tried on El Capitan. It's OS X rather than macOS). To tell the truth, I met some traps and I introduce my experiences to build and install Apache Geode Native Client on macOS, and run the C++ application on it in this article.

 

Build and install Apache Geode Native Client on macOS 

You can easily build and install Apache Geode Native Client according to BUILDING.md at geode-native repsitory on GitHub. According to BUILDING.md, you need to install CMake, C++11 compiler, Doxygen, Xcode and Xcode command line developer tools. Regarding CMake and Doxygen, you can install them with using Homebrew. Regarding C++11 compiler, it's installed when installing Xcode at the same time, as far as I know.

Anyhow, you need to get the artifacts such as source code from GitHub. I recommend you to clone them with git command rather than download ZIP archive. First, I tried to build and install by downloading ZIP archive. Somehow, I failed to build with unexpected several unknown reasons. Anyhow, you need to install git command line tool.

And also, you actually need to install Apache Geode itself because it's used at the last stage of building Apache Geode Native Client for test purpose and so on. Anyhow, you have to install Apache Geode in your machine. You can build it from source code but you can get a binary for quick install from here

 

The example steps to build and install Apache Geode Native Client is below. I recommend you to specify the install directory of existing Apache Geode and Native Client (i.e., where you want to install) when executing "cmake ../src".

$ cd /path/to/github_local_repository_dir
$ git init
$ git clone https://github.com/apache/geode-native.git
$ cd geode-native
$ git checkout master
$ mkdir build
$ cd build
$ cmake -G "Xcode" -DGEODE_ROOT=/path/to/apache_geode_root_dir -DCMAKE_INSTALL_PREFIX=/path/to/native_client_install_dir ../src
$ cmake --build . -- -j 8
$ cmake --build . --target docs
$ sudo cmake --build . --target install

It slightly takes a long time to finish build Apache Geode Native Client.

By the way, I could successfully build and install Apache Geode Native Client (so far, version 0.0.42) on OS X 10.11 (El Capitan) although BUILDING.md says it's supported for macOS 10.12 (Sierra).

 

Run the simple C++ application with using Apache Geode Native Client on macOS

The main question could be how to set compiler flags and linker flags to build the C++ application with using Apache Geode Native Client on macOS because there are no actual documents mentioning it (2/14/2017, for now).

 

You generally use Clang as the C++ compiler front end on macOS if installing Xcode. The compiler flags and linker flags for Clang are basically compatible with gcc. So the actual those flags for macOS are basically as same as for Linux in the case of Pivotal GemFire. Anyhow, you can basically set up the environment to build your C++ application with using Apache Geode Native Client on macOS according to the following document althogh it' slightly different.

Developing C++ Programs on Linux

The different things are below.

  • Environment variables for dynamic link libraries:
    In the case of GemFire Native Client for Linux, you may use LD_LIBRARY_PATH environment variable. However, you have to use DYLD_LIBRARY_PATH environemnt variable when running your Apache Geode Native Client application on macOS.
  • Linker flag to link the native client C++ cache library to the compiled executable:
    In the case of GemFire Native Client for Linux, you use "-lgfcppcache". However, you set "-lapache-geode" in the case of Apache Geode Native Client.

I prefer to use JetBrains CLion to develop, build and run C++ application as a C++ IDE. Clion uses CMake internally to build applications. My sample CMakeLists.txt file for CLion to build C++ application with using Apache Geode Native Client is below.

cmake_minimum_required(VERSION 3.6)


project(MyFirstNCProjectOnMac)

 

set(CMAKE_CXX_STANDARD 11)

 

set(SOURCE_FILES BasicOperations.cpp BasicOperations.cpp)
add_executable(BasicOperations ${SOURCE_FILES})

 

set(CMAKE_CXX_FLAGS "-D_REENTRANT -m64 -I$ENV{GFCPP}/include")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath,$ENV{GFCPP}/lib -L$ENV{GFCPP}/lib -lapache-geode")

 

message("GFCPP = $ENV{GFCPP}")
message("CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")
message("CMAKE_EXE_LINKER_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}")

 

Regarding the sample C++ application with using Apache Geode Native Client, you can use quickstart applications which you can find at /path/to/native_client_install_dir/SampleCode/quickstart/cpp. "BasicOperations.cpp" is the most simplest application to just test Apache Geode Native Client (as referred at he above sample CMakeLists.txt).

 

Anyhow, let's enjoy Apache Geode Native Client on macOS.

How to install GemFire HTTP session module on JBoss AS 7

According to the following document for GemFire HTTP session module, we can install the module on JBoss AS 7.

Installing the HTTP Module for AppServers 

But, regarding where to locate required jar files, it says "Consult application server's documentation" for JBoss AS 7 although just simply indicates actual location such as "<jboss install dir>/lib" for JBoss AS 5 or "<jboss install dir>/common/lib" for JBoss AS 6.

The main reason is that this kind of shared directory for common libraries has been discontinued since JBoss AS 7 in the part of avoiding "Jar Hell" based on introducing module system inspired by JSR294

I'm not so interested in module system but I tried to locate required jar files for GemFire HTTP session module on JBoss AS7 with using moudle system. Yeah, it works but I don't like it because it's slightly complex to configure. To make it easier to configure GemFire HTTP session module wiht JBoss AS 7 (or WildFly maybe), it's better to deploy your application and GemFire HTTP session module based on ear file with locating required jar files into lib directory of its ear.

Follow the following steps to locate and refer required jar files for GemFire HTTP sesseion moudle on JBoss AS 7.

  1. Determine the module name for GemFire session module. Any names could be O.K. but it tends to be based on package name of actual classes in the library. In this article, suppose that it's "io.pivotal.gemfire.session".
  2. Cretate a module folder for locatirng each libraries, module descriptor and so on, based on the module name. In this article, it's "io.pivotal.gemfire.session". So, please create the module folder like the following. 
    $ cd /path/to/JBossA7_install_dir/modules
    $ mkdir -p io/pivotal/gemfire/session/main
  3. Copy the required jar files for GemFire http session module (metioned here) to the module folder which was creted at the step 2 like the following in this case.
    $ cd /path/to/JBossA7_install_dir/modules/io/pivotal/gemfire/session/main
    $ cp /path/to/jar_files/gemfire-modules-<version>.jar
       :
  4. Change directory to the module folder created at the step 2 and create a module discriptor.

    $ cd /path/to/JBossA7_install_dir/modules/io/pivotal/gemfire/session/main
    $ vi module.xml

    The actual content of module.xml is below.

    <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.1" name="io.pivotal.gemfire.session">
        <properties>
        </properties>
        <resources>
          <resource-root path="antlr.jar"/>
          <resource-root path="gemfire.jar"/>
          <resource-root path="gemfire-modules-8.2.0.jar"/>
          <resource-root path="gemfire-modules-session-8.2.0.jar"/>
          <resource-root path="log4j-api-2.1.jar"/>
          <resource-root path="log4j-core-2.1.jar"/>
          <resource-root path="servlet-api-2.5.jar"/>
          <resource-root path="slf4j-api-1.7.7.jar"/>
          <resource-root path="slf4j-jdk14-1.7.7.jar"/>
          <resource-root path="spring-core-3.2.13.RELEASE.jar"/>
          <resource-root path="spring-shell-1.0.0.RELEASE.jar"/>
        </resources>
        <dependencies>
          <module name="javax.servlet.api"/>
          <module name="javax.api"/>
          <module name="javax.transaction.api"/>
        </dependencies>
    </module>

    First of all, you have to specify the module name at name attribute at module element. Second, you have to list the required jar file name at path attribute at resource-root elements as the child element of resouces element. At last, you have to set dependencies to load related module if you see ClassNotFoundException when loding this module. In my case, I need three modules to be set as dependencies.

  5. Additionally, you have to put jboss-deployment-structure.xml file under WEB-INF folder of your target war file to load the above module. The actual file content is like the following.

    <?xml version="1.0" encoding="UTF-8"?>
      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
        <deployment>
          <dependencies>
            <module name="io.pivotal.gemfire.session" />
          </dependencies>
        </deployment>
    </jboss-deployment-structure>

    Basicaly, all you have to do is to specify the module name created for GemFire session module at name attribute of module element as the child element of dependencies element.  

Anyhow, does it work in your environment? Again, I don't like those module configuration, though...

2014/4/6 quitada 的体重・体脂肪率報告

ダイエット

開始年月日の状況 - 2013/4/25 体重:80.9kg/体脂肪率:30% 程度

 

本日(347 日目)の状況 - 体重:76.2kg(-4.7kg)/ 体脂肪率:25%(-5%)

 

健全ロボ・ダイミダラーが気になりますが、太ってあれよりも痩せてあれな方があれなので、ぼくはダイエットする方を選択します。

 

 

2014/3/2 quitada 的体重・体脂肪率報告

ダイエット

開始年月日の状況 - 2013/4/25 体重:80.9kg/体脂肪率:30% 程度

本日(312 日目)の状況 - 体重:76.2kg(-4.7kg)/ 体脂肪率:25%(-5%)

 

明るい廃墟として話題だった、ピエリ守山がついに閉鎖となりました。ぼくの明るい暗黒ダイエットは終わらないようにがんばりたいです。

2014/2/13 quitada 的体重・体脂肪率報告

ダイエット

開始年月日の状況 - 2013/4/25 体重:80.9kg/体脂肪率:30% 程度

 

本日(295 日目)の状況 - 体重:76.4kg(-4.5kg)/ 体脂肪率:23%(-7%)

2014/1/17 quitada 的体重・体脂肪率報告

ダイエット

開始年月日の状況 - 2013/4/25 体重:80.9kg/体脂肪率:30% 程度

本日(268 日目)の状況 - 体重:77.2kg(-3.7kg)/ 体脂肪率:25%(-5%)

日テレの「明日ママがいない」というドラマが熊本の病院から抗議を受けて中止を要求されているようですが、かえって宣伝になってしまったという側面がありますね。私は観ませんけど。私も、体重が 77kg に戻ってしまい、ダイエット業界からの抗議を受けそうです。でも中止はしません。開店休業状態なだけです!

2013/12/9 quitada 的体重・体脂肪率報告

ダイエット

開始年月日の状況 - 2013/4/25 体重:80.9kg/体脂肪率:30% 程度

本日(229 日目)の状況 - 体重:75.6kg(-5.3kg)/ 体脂肪率:25%(-5%)

 

俳優すまけいさんが亡くなられたそうです。ご冥福をお祈りいたします。人間健康第一ですので、すまけいさんのように長生きするためにも、健康的なダイエットに励みたいです。