2007年12月5日 星期三

Java 平台上的 Grid Framework - GridGain

簡介

之前使用了在 .NET 平台上的 Grid Framework - Alchemi

使用了一陣子的結論是.........真的不是很穩定,三不五時 Grid Manager service 就會掛掉.....

於是想找另外一套來試試看,於是找到一個 Java based 的,叫做 GridGain

GridGain 有什麼特色呢? 以下是官方網站的描述:
Grid
GridGain is focused on doing one thing and doing it better than any other product – providing the best grid computing platform for Java that is fun, simple and productive to use.

Java
GridGain is developed in Java and for Java developers and it is a natural extension of the latest Java development methodologies including annotations, integration of Spring and AOP-based grid-enabling.

Open Source & Professionally Supported
GridGain is dual-licensed under LGPL and Apache 2.0 licenses and is built on open source software foundation. GridGain Systems provides full range of services for GridGain project including support, training and consulting.

以下是官方網站的圖表說明:(看起來的確架構很簡單)



接著是簡單的程式與執行方式的圖表說明:

原本的程式:
class BizLogic {
public static Result process(String param) {
//執行程式的地方
........
}
}

class Caller {
public static void Main(String[] args) {
//開始執行
BizLogic.process(args[0]);
}
}
執行方式為:

將其改寫成可以在 GridGain 上面運作:
class BizLogic {
@Gridify() //使用「Gridify」annotation 來註明這是要到 Grid node 去跑的!
public static Result process(String param) {
......
}
}

class Caller {
public static void Main(String[] args) {
//Grid 程式啟動
GridFactory.start();

try {
//原本的程式還是照樣執行
BizLogic.process(args[0]);
}
finally {
//停止 Grid 程式
GridFactory.stop();
}
}
}
透過加入 annotation 後,執行方式就改變為:
大概修改方式就是這樣,其實還蠻容易的!

總而言之,由於 GridGain 是 based on Java,因此不論是裝在 Windows or Linux,都是可以使用的!

再來,主要針對的是 computing 的部分,沒有包含其他複雜的部分(例如:Grid storage),簡單容易使用。

最後,這是免錢的!!

考慮了許久,還是決定把這一套也研究一下,畢竟系統還是穩定、安全為最佳考量!

總不能在論文程式 demo 時,程式突然不能跑了.....那可慘了.... Orz

另外,官方網站上還提供了幾段教學影片,包含了安裝以及簡單的程式開發教學,雖然是講英文且沒字幕,不過應該也不難看懂或聽懂!


行前準備

GridGain 的安裝是相當容易的! 只要從官方網站下載回來後就可以直接安裝了!

但安裝了以後,若要啟動 GridGain service,必須要正確的設定「GRIDGAIN_HOME」與「JAVA_HOME」兩個環境變數。

當 GridGain 安裝好以後,除了包含了啟動 GridGain service 需要的執行檔以外,還有開發程式所需要的 library,說明如下:
  1. 在 $GRIDGAIN_HOME 目錄中所包含的 gridgain-x.x.x.jar 檔案
  2. 在 $GRIDGAIN_HOME/lib 目錄中所包含的所有 jar 檔按

開發程式時必須把以上兩種 library 都加入,程式才可以正常運作!

另外,在之後有兩種 Grid 範例程式開發的說明,分別是:
  1. Hello World
    這個部分是以簡單的字串處理工作來進行說明
  2. Monte-Carlo
    這個是比較複雜的範例,內容大概是投資相關的風險模擬計算,比較貼近一般所要開發程式的方式

在官方網站中,都有針對上面兩種範例,以不同的實作方式進行說明。

沒有留言:

張貼留言