Setsuna-0.0.2ãªãªã¼ã¹~
Setsunaã®Version-0.0.2ããªãªã¼ã¹ãã¾ããã
Github
Sourceforge.jpダウンロードページ
ä»åã®ãªãªã¼ã¹ã§ä¸çªå¤§ããªè¿½å æ©è½ã¯Serverã¢ã¼ãã®è¿½å ã§ãã
0.0.1ã®æã¯ãSetsunaã«ãã¼ã¿ãå
¥ããæ¹æ³ã¯ãã¤ãå
¥åãããªãã£ãã®ã§ã
ã³ãã³ãã©ã¤ã³ã§ä½ãã®åºåããã¤ãã§Setsunaã«ç¹ããããªãã£ãã®ã§ã
Setsunaãåãã¦ãããµã¼ã以å¤ãããã¼ã¿ãSetsunaã«æµããªãã£ã
ã®ãä¸ä¾¿ã§ãããããã§NetWorkè¶ãã«ãã¼ã¿ãæµããããã«ãã®æ©è½ã追å ãã¾ããã
èµ·åæ¹æ³ã¯ç°¡åã§"-server true"ã¨ãã表è¨ãä»ããã ãã§ãããã Serverã¢ã¼ãã®
å ´åã¯setsuna.jarå
ã«å«ã¾ããªãã©ã¤ãã©ãªã«ãä¾åãã¦ããã®ã§å¾æ¥ã®-jaræå®ã§ã®
èµ·åã¯åºæ¥ãªããªã£ã¦ãã¾ãã以ä¸ãèµ·åãµã³ãã«ã§ãã
(â»ãªãªã¼ã¹ç©ã®setsuna.jarããããã£ã¬ã¯ããªã§å®è¡ãã¦ããæ³å®ã§ã)
java -classpath ./:./lib/msgpack/*:setsuna.jar setsuna.core.SetsunaMain -server true
ããã§Portçªå·10028çªã§ãµã¼ãã§å¾ ã¡åãã¦ãã¾ãã
â»èµ·åãã¼ãçªå·ãå¤æ´ããå ´åã¯"-bindport"ãªãã·ã§ã³ã§å¤æ´ã§ãã¾ãã
ã§ãä»åServerã¢ã¼ããå®è£ ããã«ããã£ã¦ã©ã®ãããªãããã³ã«ã¨ä»çµã¿ã«ãããã
æ©ãã ã®ã§ãããç¬èªã«å®è£ ããã®ã¯æ¢ãã¦ãMessagePack-RPCãå©ç¨ãã¾ããã
MessagePack-RPCã¨ã¦ãé«éã§ãããã¤ãåè¨èªã®ãã¤ã³ãã£ã³ã°ãä½æããã¦ããããã
è¨èªå¥ã§ã¯ã©ã¤ã¢ã³ããå¥éä½æããå¿ è¦ããªããããæ¡ç¨ããã¦ããã ãã¾ããã
MessagePack-RPCの詳しい情報はこちら
ããã¦ããµã¼ãå´ã«å®ç¾©ããã¦ãããªã¢ã¼ãã¡ã½ããã¯ä»¥ä¸ã«ãªãã¾ãã
åãåç´ã«ãã¾ããããã¤ãå ¥åãã¡ã½ããåããã¤ã¡ã¼ã¸ã§ãã
int next (String[] sendData)
å¼æ°ã¯ãã¼ã¿ãã«ã©ã åä½ã§å解ããå¾ã®ãã¼ã¿ãé åã«ãã¦æ¸¡ãã¾ãã
ã¤ã¾ã以ä¸ã®Pingã®çµæã®å ´å
åè§ã¹ãã¼ã¹ã§ã°ããã¦Setsunaã«éãè¾¼ã¿ããå ´å以ä¸ã®ãããªé åã渡ããã¨ã«ãªãã¾ãã
192.168.11.1 ããã®å¿ç: ãã¤ãæ° =32 æé =16ms TTL=64
ä»åãååã®Setsunaã¨åãã§ãSetsunaèµ·åæã«-columnãªãã·ã§ã³ã§ã«ã©ã å®ç¾©ã決ããã°
String[] sendData = new String[7];
sendData[0] = "192.168.11.1";
sendData[1] = "ããã®å¿ç:";
sendData[2] = "ãã¤ãæ°";
sendData[3] = "=32";
sendData[4] = "æé";
sendData[5] = "=16ms";
sendData[6] = "TTL=64";
ãã®å®ç¾©ã«å¾ã£ã¦å é¨DBã«ãã¼ãã«ãä½ããã¾ãããã-columnãæå®ããªããã°ãæåã«éããã¦
ãããã¼ã¿ããã¨ã«ããã¼ãã«ãä½ããã¾ããåºæ¬çã«ãå ¥ãå£ããã¤ãããMessagePackã®ãµã¼ãã«
å¤ãã£ãã ãã§å¾ã®æ©è½ã¯å ¨ã¦åãåãããã¾ãã
ããã¦ããµã¼ãããã®æ»ãå¤ã¯3種é¡ããã¾ãã
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
0=ãã¼ã¿å
¥åæå
-9=ã«ã©ã å®ç¾©ã¨éããã¦ãããã¼ã¿ãåã£ã¦ããªã
-1=ãµã¼ãå´ã§ã¨ã©ã¼çºç
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ãã®æ»ãå¤ãè¦ã¦ä»¥éã®ã¯ã©ã¤ã¢ã³ãã§ãªãã ãã®å¦çããã¦ããããã°ã¨æãã¾ãã
å®éã«ãããéãè¾¼ãJavaã§ã®ã¯ã©ã¤ã¢ã³ãå®è£
ã®ãµã³ãã«ã¯ãªãªã¼ã¹ç©ã®
test/ServerClientSampleãã£ã¬ã¯ããªã®SetsunaServerModeClientSample.javaã«ãªãã¾ãã
ã³ã¼ãã¯ãããªæãã§ãã
ãã®ãµã³ãã«ã¯ã©ã¤ã¢ã³ãã§ãã¤ã³ãã¯ã¾ãã27è¡ç®ã34è¡ç®ã®ãªã¢ã¼ãã¡ã½ããã®å®ç¾©ã§
1
2 import org.msgpack.rpc.Client;
3 import org.msgpack.rpc.loop.EventLoop;
4
5 /**
6 * Setsunaã"-server true"ã«ã¦ç«ã¡ä¸ããå ´åã«ãã¼ã¿ãæå ¥ãã
7 * Clientã®ãµã³ãã«.
8 * Setsunaã®Serverã¢ã¼ãã¯MessagePack-RPCã§åºæ¥ã¦ããããã
9 * ClientãMessagePack-RPCã§ä½æããå¿ è¦ãããã
10 * Setsunaå´ã«ã¯ä»¥ä¸ã®ã¡ã½ãããå®ç¾©ããã¦ããã®ã§
11 * ãããã«å®è£ ãã.
12 * -- å®ç¾©ã¡ã½ãã ----------
13 * int next (String[] data)
14 * --------------------------
15 * å¼æ°ã¯1ã¬ã³ã¼ãå½ããã®ãã¼ã¿ã表ãé å
16 * æ»ãå¤ã¯å¼ã³åºãã®æå¦(0=æ£å¸¸çµäº, -9=ã«ã©ã å®ç¾©ã¨åããªã , -1=å é¨ã¨ã©ã¼)
17 *
18 * @author T.Okuyama
19 */
20 public class SetsunaServerModeClientSample {
21
22 /**
23 * SetsunaãRPCè¶ãã«å¼ã³åºã
24 * 渡ãå¤ã¯ã«ã©ã æ°åã®Stringå¤ã®é å.ä¸è²«ãã¦åãé·ãåãéããã¨
25 * æ»ãå¤:æ£å¸¸çµäº 0, ã«ã©ã å®ç¾©ã¨åããªã -9, å é¨ã¨ã©ã¼ -1
26 */
27 public static interface RPCInterface {
28 /**
29 *
30 * @param data ã«ã©ã ãã¼ã¿ã®é åãå¿ ãã«ã©ã æ°åå¿ è¦
31 * @return int çµæ:æ£å¸¸çµäº=0, ã«ã©ã å®ç¾©ã¨åããªã=-9, å é¨ã¨ã©ã¼=-1
32 */
33 int next(String[] data);
34 }
35
36 public static void main(String[] args) throws Exception {
37 EventLoop loop = EventLoop.defaultEventLoop();
38
39 Client cli = new Client("localhost", 10028, loop);
40 RPCInterface iface = cli.proxy(RPCInterface.class);
41
42 String[] list = new String[3];
43 list[0] = "aa";
44 list[1] = "bb";
45 list[2] = "cc";
46 for (int i = 0; i < 1000; i++) {
47 // ãã¼ã¿ãç»é²ãã
48 System.out.println(iface.next(list));
49 }
50 cli.close();
51 loop.shutdown();
52 }
53 }
ä¸ã«ç¤ºãããµã¼ãå´ã®å®ç¾©ãã¤ã³ããªãã¦ã¾ããããã¦37è¡ç®ã§EventLoopã¯ã©ã¹ãä½æã39è¡ç®ã§ã¯ã©ã¤ã¢ã³ãã
Setsunaã®ã¢ãã¬ã¹ã¨ãã¼ãã¨å ç¨ã®EventLoopãæå®ãã¦ä½æã
ããã¦æ¬¡ã®40è¡ç®ã§ããªã¢ã¼ãã¡ã½ãããè¨å®ã
42è¡ç®ã45è¡ç®ã§Setsunaã«æ¸¡ããããã¼ã¿ãä½æãã¦ã48è¡ç®ã§ãªã¢ã¼ãã¡ã½ãããå¼ã³åºãã¦ãã¾ãã
è¦ã¦ãããéãMessagePack-RPCã®ãããã§é常ã«ç°¡æ½ã«ããã¾ãã
ä»è¨èªã®ãã¤ã³ãã£ã³ã°ãæ¬å®¶ãµã¤ãã«åºã¦ããã®ã§ãåºæ¬åãè¦é ã ã¨æãã¾ãã
ããã§ä»ã®ãµã¼ããããã¼ã¿ãæµããã®ã§ãã¤ãã³ãå¦çãéç´åºæ¥ãã¨æãã¾ãã
ãã 1å°ã«éç´ããã¨ãã®ãµã¼ããããããã©ããããªã©ã¯ä»å¾ã®èª²é¡ã§ãã
ãã®ä»ã®è¿½å æ©è½ã§ããã主ã«ãããã°ç³»ã®æ©è½ã¨åãè¾¼ã¿ãã¼ã¿ã
ãã¼ã¿ãã¼ã¹ã«ãããã³ã°ãã辺ããå¼·åãã¾ããã
ãããã°ï¼Setsunaèªèº«ã®ãã°æ©è½
"-debug"ãªãã·ã§ã³
åã®ãã¼ã¸ã§ã³ã§ã¯Setsunaã«ã©ã®ãããªãã¼ã¿ãAdapterã§éãè¾¼ã¾ããã©ã®ãããªTriggerãåããã©ã®ãããªSQLã
æ¤è¨¼ç¨ã«æµãã©ã®ãããªUserEventãå®è¡ããããåããã¾ããã§ããããããã«Setsunaãå©ç¨ãã¦éçºããããã§
ããã§ã¯å³ããã®ã§ããããã°ãã°ãåºããããã«ãã¾ããã
"-debug"ã¨ãããªãã·ã§ã³è¨å®ã§åºåããã¾ããå®éã«æå®ããã¨ä»¥ä¸ã®ããã«ãªãã¾ãã
æå®ãã¦ãã¯æå¾ã®"-debug on"ã¨ããé¨åã§ããããã§ã³ã³ã½ã¼ã«ã«æ¨æºå ¥åããéãè¾¼ã¾ãããã¼ã¿ããããã°ããã¾ãã
ping -i 1 -c 1000 192.168.1.1 | grep --line-buffered ttl | java -jar setsuna.jar -debug on
以ä¸ã®ãããªæãã«ãªãã¾ãã
ãããã°ã§åºåãããæååã¯å é ã"Debug"ã¨ããæåå§ã¾ãè¡ãå®éã«éãè¾¼ã¾ãããã¼ã¿æååã§ãã
Debug : Sat Mar 24 18:02:50 JST 2012 - - Pipe Input=[64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.237 ms]
{"COLUMN0":"64","COLUMN1":"bytes","COLUMN2":"from","COLUMN3":"192.168.1.1:","COLUMN4":"icmp_seq=1","COLUMN5":"ttl=64","COLUMN6":"time=0.237","COLUMN7":"ms"}
Debug : Sat Mar 24 18:02:50 JST 2012 - - Pipe Input=[64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.297 ms]
{"COLUMN0":"64","COLUMN1":"bytes","COLUMN2":"from","COLUMN3":"192.168.1.1:","COLUMN4":"icmp_seq=2","COLUMN5":"ttl=64","COLUMN6":"time=0.297","COLUMN7":"ms"}
Debug : Sat Mar 24 18:02:51 JST 2012 - - Pipe Input=[64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.245 ms]
ãã®ä»ã®"-trigger"ã"-query"ã"-event"ã"-eventquery"ã§æå®ããå 容ãå®è¡ããå 容ãåãããã«
"Debug"ãå é ã«ã¤ãã¦åºåããã¾ãã
ãã ãè¦ã¦ãåããããã«ãããã°ä»¥å¤ã®åºåãæ··ãã£ã¦ããã®ã§é常ã«è¦è¾ãã§ãã
ãããæ¹åããã®ãã以ä¸ã®æå®ã§ãã
"-debug only"ã¨ãªã£ã¦ããã®ããã®æå®ã§ããããã»ã©ã¯"on"ã ã£ãé¨åã"only"ã¨ãããã¨ã§ã以ä¸ã®ããã«ãªãã¾ãã
ping -i 1 -c 1000 192.168.1.1 | grep --line-buffered ttl | java -jar setsuna.jar -debug only
ãããã°ã®ã¿ã®åºåã«ãªã£ã¦ããã®ãããã£ã¦ããããã¨æãã¾ãã
Debug : Sat Mar 24 18:29:20 JST 2012 - - Pipe Input=[64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.263 ms]
Debug : Sat Mar 24 18:29:20 JST 2012 - - Pipe Input=[64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.243 ms]
Debug : Sat Mar 24 18:29:21 JST 2012 - - Pipe Input=[64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.229 ms]
"-errorlog"ãªãã·ã§ã³
ãã®ãªãã·ã§ã³ã¯Setsunaãåãåºãã¨ã©ã¼å 容ããã¡ã¤ã«ã«åºåããããã®ãã®ã§ãã
å¾æ¥ã¯ã³ã³ã½ã¼ã«ã«ããåºãªãã£ãã®ã§ãããããã¡ã¤ã«ã«åºååºæ¥ãããã«ãã¾ããã
以ä¸ã®ããã«æå®ãã¾ãã
ããã§"/var/log/setsuna_error"ã«ã¨ã©ã¼åºåãåºãããã«ãªãã¾ãã
ping -i 1 -c 1000 192.168.1.1 | grep --line-buffered ttl | java -jar setsuna.jar -errorlog /var/log/setsuna_error
ã¤ã³ããããã¼ã¿ã®èªã¿è¾¼ã¿éå§ã¬ã³ã¼ãæå®ï¼ã«ã©ã å®ç¾©éãã®ãã¼ã¿ãéãè¾¼ãã éã«ç¡è¦ããæå®
"-offsetãªãã·ã§ã³"
Setsunaã«ã¤ã³ãããããããã¼ã¿ãå é¨DBã«åãè¾¼ã¿ãéå§ããä½ç½®ãã¬ã³ã¼ãæ°ã§è¨å®ã§ãã¾ãã
è¨å®ã¯ä»¥ä¸ã®ããã«ãªãã¾ãããã®ãªãã·ã§ã³ã¯å¿ ã"-column"ãªãã·ã§ã³ãæå®ããå¿ è¦ãããã¾ãã
"-offset 2"ã®é¨åã®æå®ã§ããããã§ãã¤ã³ãããããããã¼ã¿ã®2ã¬ã³ã¼ãç®ããåãè¾¼ã¾ãã¾ãã
ping -i 1 -c 1000 192.168.1.1 | java -jar setsuna.jar -column "col1 col2 col3 col4 col5 col6 col7 col8" -offset 2
1è¡ç®ã¯ã¨ããã¾ããç¡è¦ããã¾ãã
å©ç¨ãããæ³å®ã¯ä»¥ä¸ã®ããã«pingã®ãã¼ã¿ãSetsunaã«éãè¾¼ã¿ããå ´å
1è¡ç®ã®ãã¼ã¿ã®ãã©ã¼ãããã¨2è¡ç®ãç°ãªããããã®ã¾ã¾åãè¾¼ãã¨Exceptionãçºè¡ããã¾ãã
[setsuna]$ ping -i 1 -c 1000 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.277 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.278 ms
ããã¯"-column"æå®ã§å®ç¾©ããã«ã©ã å®ç¾©ã8ã«ã©ã ããã®ã«å¯¾ã1è¡ç®ã®
"PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data."ãããã©ã«ãã®åè§ã¹ãã¼ã¹ã§å解ããã¨
以ä¸ã®ããã«7ã«ã©ã ãããªãããã§ãã
ãã®ãããªå ´åã«å¾æ¥ã¯grepãªã©ã§Setsunaã«ãã¼ã¿ãéãè¾¼ãåã«ãä¸è¦ãªãã¼ã¿ã¯çãã¦ããã£ã¦ããã§ããã
col1="PING"
col2="192.168.1.1"
col3="(192.168.1.1)"
col4="56(84)"
col5="bytes"
col6="of"
col7="data."
col8=ãã¼ã¿ããªãï¼ï¼
ãã®ãªãã·ã§ã³ã使ããã¨ã§åãè¾¼ã¿éå§ä½ç½®ã調æ´ãããã¨ã§ãå ¥åãã¼ã¿ã®ãããã¼ãã¨ã°ãããåºæ¥ã¾ãã
"-skiperror"ãªãã·ã§ã³
"-offset"ã¯åãè¾¼ã¿éå§ä½ç½®ã調æ´ã§ãã¾ãããåãè¾¼ã¿ãéå§ããåºãã¦ããå®ç¾©éãã®ãã¼ã¿ãããå ´åã«ã¯
ãã¯ãExceptionãçºçãã¾ããããã§"-skiperror"ãªãã·ã§ã³ãæå®ããã¨ãéä¸ã«å®ç¾©éãã®ãã¼ã¿ãæ¥ã
å ´åã«ãã®ãã¼ã¿ãåãè¾¼ã¾ãã«ç¡è¦ãã¾ãã以ä¸ã®ããã«æå®ãã¾ãã
æå¾ã®"-skiperror true"ã§ãããã®æå®ã¯-columnã®æå®ã¯å¿ é ã§ã¯ããã¾ããã"-column"ãæå®ããªãå ´åã¯ã
ping -i 1 -c 1000 192.168.1.1 | java -jar setsuna.jar -column "col1 col2 col3 col4 col5 col6 col7 col8" -skiperror true
æåã®ã¬ã³ã¼ãããèªåçã«ã«ã©ã å®ç¾©ãä½æããã¾ãã
以ä¸ãä»åã®è¿½å æ©è½ã§ãããã以å¤ã«ã¯ããã¤ãã®å¹çåã¨ãã°Fixããã¦ãã¾ãã
追å æ©è½ãå«ãã¦å ¨ã¦ã®æ©è½ã¯"-help"ãªãã·ã§ã³ã§ç¢ºèªãã¦ãããã¾ãã
ã¾ã ã¾ã ãçºå±éä¸ã®ããã¸ã§ã¯ããªã®ã§ãæ°è»½ã«ãæè¦ããã ããã¨ãããããã§ãï¼ï¼
ããã次ã¯åæ£åã§ãèãå§ããããªãã
ComplexEventProcessingã¨ã³ã¸ã³ Setsuna ããªãªã¼ã¹ãã¾ããï¼ï¼
ãã£ã¨ãªãªã¼ã¹ã§ãã¾ããï¼
Sourceforge.jpダウンロードページ
ååã¯Setsuna(ã»ãã)ã¨ãã¾ããã
æéã®åä½ã表ãè¨èã§ããå¹é£ãããã¦ãã¾ãã
å¹é£ã®çãã§ãã¼ã¿ãå¦çåºæ¥ãã°ãããªã¨ãããã¨ã§ãã®ååã«ãã¾ããã
ãã®Setsunaã§ãããCEPã¨ããããã«ãã´ãªã«å±ãããã®ã§ãã
ã§ã¯CEPã¨ã¯ï¼ï¼ãªãã§ãããããã¯èªæºãã®ã¾ã¾ã§ãã
ComplexãEvent Processing
è¤æ°ã®ã¤ãã³ãã¤ã¾ããã¼ã¿ãå¦çããã¨ã³ã¸ã³ã§ãã
ã¤ã¡ã¼ã¸ã¨ãã¦ã¯ãã¼ã¿ã®æµãã«ç´æ¥å¦çãè¡ããã¤ã¡ã¼ã¸ã§ãã
ãã¾ãæç« ã°ããã§ãã¤ã¾ããªãã®ã§ãå®éSetsunaã使ããªãã説æãã¦ããããã¨æãã¾ãã
ã§ã¯é¡æã¯ãããªã®ã«ãããã¨æãã¾ãã
ãApacheãéãï¼ï¼ãã²ãã£ã¨ãã¦æ»æããã¦ãï¼ï¼ã
ããã¾ãããããããããã¿ã¤ãã«ã§ãããã
ãããããã¨ã¯ãWebãµã¼ãã®è² è·ãä¸å®å¤ãè¶
ããå ´åã«ãApacheã®ã¢ã¯ã»ã¹ãã°ã®ç´è¿1ä¸ä»¶ä»¥å
ããã®
IPã¢ãã¬ã¹å¥ã§ã¢ã¯ã»ã¹åæ°ãåè¨ããã®åè¨å¤ããè¦å®åæ°ãè¶
ãã¦ããå ´åã«ãã¢ã©ã¼ãå
容ãSystemãã°ã«
åºåããã¨ãããã®ã§ãã
ã§ã¯ãã®å¦çãã©ã®ããã«ãããé ã追ã£ã¦è¦ã¦ããããã¨æãã¾ãã
â»ç°å¢ã¯CentOS5.5(64bit)åæã¨ãã¦é²ãã¾ãã
Step1.ãµã¼ãã®è² è·ãç£è¦ãã
Step1:ã¾ãã¯ãµã¼ãã®è² è·ãç£è¦ããªãã¨ãã¡ã§ãã
ããã§ã¯topã³ãã³ãã®ãã¼ãã¢ãã¬ã¼ã¸ãè² è·ã®ææ¨ã«å©ç¨ãããã¨æãã¾ãã
çµæã¯ä»¥ä¸ã®ãããªæãã§ãã
$top -d 1
ã§ã¯æ©éãããSetsunaã«æµãè¾¼ã¿ããã¨æãã¾ãã
top - 16:47:19 up 8 min, 2 users, load average: 0.06, 0.11, 0.08
Tasks: 78 total, 1 running, 77 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.5%us, 3.0%sy, 0.0%ni, 93.9%id, 0.2%wa, 0.1%hi, 0.3%si, 0.0%st
Mem: 793284k total, 180116k used, 613168k free, 12272k buffers
Swap: 1048568k total, 0k used, 1048568k free, 130704k cachedPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 15 0 2072 636 544 S 0.0 0.1 0:00.72 init
2 root RT -5 0 0 0 S 0.0 0.0 0:00.00 migration/0
ãããããããããããããããã»
ãããããããããããããããã»
ãããããããããããããããã»
Setsunaã¯æ¨æºã§ãã¤ãã§ç¹ããã¨ã§ãã¼ã¿ãæµãè¾¼ããã¨ãå¯è½ã§ãã
Setsunaããã¦ã³ãã¦ã³ãã¼ããã¦ããã£ã¦é©å½ãªå ´æã«è§£åãã¦ãããã¨
ä¸ã«setsuna.jarã¨ãããã¡ã¤ã«ãããã¨æãã¾ãããããæ¬ä½ã§ãã
å®è¡å¯è½jarãªã®ã§ãjavaãåãç°å¢ã§ããã°ãã®ãã¡ã¤ã«ä»¥å¤ã¯ä½ãå¿ è¦ããã¾ããã
ä¸è¨ãå®è¡ããã¨ä»¥ä¸ã®ãããªã¨ã©ã¼ãåºãã¨æãã¾ãã
$top -b -d 1 | java -jar setsuna.jar
ããã¯ãSetsunaã®èªåãã¼ãã«ãããã³ã°ã®æ©è½ãããã¦ãã¾ããã¤ã¾ãSetsunaã¾ã§ã¯
setsuna.core.util.SetsunaException: The read data differs from definition information. Adapter name is PIPE
at setsuna.core.adapter.SetsunaCoreAdapterEngine.doEvent(SetsunaCoreAdapterEngine.java:67)
at setsuna.core.AbstractCoreEngine.run(AbstractCoreEngine.java:54)
topã®çµæã¯å±ãã¦ãã¾ããã§ã¯ã©ããã£ãã¨ã©ã¼ãï¼ï¼
ãããã¯ã1è¡ç®ã®ãã¼ã¿ã¨2è¡ç®ã®ãã¼ã¿ã®å½¢å¼ãéãã¾ããã¨ãããã¨ãè¨ã£ã¦ãã¾ãã
Setsunaã¯ãã¤ãã©ã¤ã³å ¥åã§æ¸¡ããããã¼ã¿ãå èµããH2Databseã«èªåçã«æ ¼ç´ãã¾ãã
ãã®ãããæ ¼ç´ããããã«ãã¼ã¿ãã¬ã³ã¼ãã¨ãã¦èªèããã¤ãã«ã©ã ã«å解ãããã¨ãã¾ãã
Setsunaã¯ããã©ã«ãã§ã¯ãã¼ã¿(ã¬ã³ã¼ã)ã®åºåããæ¹è¡ã¨ããã«ã©ã ã¬ãã«ã¸ã®å解ã«
åè§ã¹ãã¼ã¹ãå©ç¨ãã¾ãã(2ã¤ä»¥ä¸ç¶ãã¹ãã¼ã¹ã¯èªåçã«1ã¤ã«ããªã ããã¾ã)
topã®çµæãããä¸åº¦ã¿ã¦ã¿ãã¨ã
è¡çªå·1ã¨2ã§ã¯å ¨ããã©ã¼ããããç°ãªãã¾ãããã©ã¼ãããã¨ã¯ã¹ãã¼ã¹ã§å解ããéã®å解ã§ããæ°ã§ãã
1: top - 16:47:19 up 8 min, 2 users, load average: 0.06, 0.11, 0.08
2: Tasks: 78 total, 1 running, 77 sleeping, 0 stopped, 0 zombie
ããã§ãã¼ãã¢ãã¬ã¼ã¸ãå«ã1è¡ç®ã ããSetsunaã«éãè¾¼ãã§ã¿ã¾ããããããã«ã¯grepãå©ç¨ãã¾ãã
ããã¦ãã®ãã¼ã¿ã®æµãã«ååãä»ãããã¨æãã¾ãã-streamãªãã·ã§ã³ãå©ç¨ããã¨ååãä»ããã¾ãã
$top -b -d 1 | grep --line-buffered "top -" | java -jar setsuna.jar -stream top
Exceptionãåºãªããªãå¤ããã«ä»¥ä¸ã®ãããªçµæã«ãªã£ã¦ããªãã§ããããï¼
ããã¯Setsunaãåãè¾¼ãã ãã¼ã¿ãJSONãã©ã¼ãããã§
{"COLUMN0":"top","COLUMN1":"-","COLUMN2":"17:01:58","COLUMN3":"up","COLUMN4":"23","COLUMN5":"min,","COLUMN6":"2","COLUMN7":"users,","COLUMN8":"load","COLUMN9":"average:","COLUMN10":"0.20,","COLUMN11":"0.12,","COLUMN12":"0.09"}
{"COLUMN0":"top","COLUMN1":"-","COLUMN2":"17:01:59","COLUMN3":"up","COLUMN4":"23","COLUMN5":"min,","COLUMN6":"2","COLUMN7":"users,","COLUMN8":"load","COLUMN9":"average:","COLUMN10":"0.20,","COLUMN11":"0.12,","COLUMN12":"0.09"}
{"COLUMN0":"top","COLUMN1":"-","COLUMN2":"17:02:00","COLUMN3":"up","COLUMN4":"23","COLUMN5":"min,","COLUMN6":"2","COLUMN7":"users,","COLUMN8":"load","COLUMN9":"average:","COLUMN10":"0.20,","COLUMN11":"0.12,","COLUMN12":"0.09"}
{"COLUMN0":"top","COLUMN1":"-","COLUMN2":"17:02:01","COLUMN3":"up","COLUMN4":"23","COLUMN5":"min,","COLUMN6":"2","COLUMN7":"users,","COLUMN8":"load","COLUMN9":"average:","COLUMN10":"0.20,","COLUMN11":"0.12,","COLUMN12":"0.09"}
ã«ã©ã æ å ±ã¨ã»ããã§åºåãã¦ãã¾ãã
Setsunaã¯ãã¤ãã©ã¤ã³ã§ãã¼ã¿ãä¸ããã ãã®å ´åãã®ãããªåãã«ãªãã¾ãã
ã§ã¯ããããè¦ã¦ããã¾ãããã
topã®ãã¼ãã¢ãã¬ã¼ã¸ã®è¡
Setsunaã®çµæ
top - 16:47:19 up 8 min, 2 users, load average: 0.06, 0.11, 0.08
ãããã³ã°åºæ¥ã¦ãã¾ããã
{
"COLUMN0":"top",
"COLUMN1":"-",
"COLUMN2":"17:01:58",
"COLUMN3":"up",
"COLUMN4":"23",
"COLUMN5":"min,",
"COLUMN6":"2",
"COLUMN7":"users,",
"COLUMN8":"load",
"COLUMN9":"average:",
"COLUMN10":"0.20,",
"COLUMN11":"0.12,",
"COLUMN12":"0.09"
}
ç®å½ã¦ã®ãã¼ãã¢ãã¬ã¼ã¸ã®å¤ã¯"COLUMN10"ã®å¤ã§ãã
ããã§Setsunaã¸ã®ãã¼ã¿ã®æµãè¾¼ã¿ã¯å®äºã§ãã
ãã®æµãè¾¼ãå¦çã®é¨åã¯Adapterã¨å¼ãã§ãã¾ãã
Step2
ã§ã¯æ¬¡ã«ãããä¸ã¤ã®ãã¼ã¿ã§ããApacheã®ã¢ã¯ã»ã¹ãã°ãæµãè¾¼ã¿ããã¨æãã¾ãã
ãã®ãã¼ã¿ã¯ã¢ã¯ã»ã¹IPã®æ½åºã«å©ç¨ãããã¨æãã¾ãã
å ã»ã©ã¨åãæé ã§Setsunaã«ãã¼ã¿ãæµãè¾¼ã¿ã¾ãã
ãã®ãã¼ã¿ã®æµãã«ã¯logã¨ããååãä»ãã¾ãã
ä»åã¯å ã»ã©ã¨éãã-sepã¨ããé ç®ãã¤ãã¦ãã¾ãã
$tail -f /etc/httpd/logs/access_log | java -jar setsuna.jar -sep " - -" -stream log
ããã¯ãã¬ã³ã¼ããã¼ã¿ãã«ã©ã ã«å解ããéã®ã»ãã¬ã¼ã¿ãæå®ãã¦ãã¾ãã
åã®ç°å¢ã®ã¢ã¯ã»ã¹ãã°ã¯ä»¥ä¸ã®ãããªãã©ã¼ãããã§ããã
ããããIPã ããåãåºãããã®ã§ããã¼ã¿ãå解ããã»ãã¬ã¼ã¿ã«" - -"ã¨ããæååã
192.168.1.100 - - [15/Mar/2012:17:29:52 +0900] "GET /index.php HTTP/1.1" 200 130 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11"
å©ç¨ãã¾ãããããã§å é ã®IPé¨åã®ç´å¾ã§å解ã§ãã¾ãã
ããã¦å®éã«Setsunaã«æµãããã çµæãä¸ã§ãã
"COLUMN0"ã«IPæ å ±ããããã³ã°ããã¦ããã®ããããã¾ãã
{"COLUMN0":"192.168.1.100","COLUMN1":" [15/Mar/2012:17:46:45 +0900] "GET /index.php HTTP/1.1" 200 130 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11""}
Step3
ããã¾ã§ã¯ãã¼ã¿ãSetsunaã«æµãè¾¼ãã ãã§ãããããããã¯å®éã«ãã¼ã¿ãå¦çãã¦è² è·ãæ¤ç¥ãã¦ã¿ã¾ãã
è² è·ã®æ¤ç¥ã«ã¯å ã»ã©ã®topã®ãã¼ã¿ã®æµãã®ãã¼ãã¢ãã¬ã¼ã¸ã®å¤ã使ãããã¨æãã¾ãã
ããã¦ãè² è·ãå¤å®ããããã®æ¡ä»¶ãè¨å®ãããã¨æãã¾ããããã«ã¯-triggerãªãã·ã§ã³ãå©ç¨ãã¾ãã
ããã¦ãããè¤éãªæ¡ä»¶ã§ããã¢ã¯ã»ã¹é »åº¦ã®é«ãIPãå²ãåºãããã«ã-queryãªãã·ã§ã³ã使ãã
SQLã«ã¦ãã¢ã¯ã»ã¹ãã°ã®ãã¼ã¿å ããåºåºåæ°ãè¶ ããã¢ã¯ã»ã¹ãè¡ã£ã¦ããIPããã£ãå ´åã«ã
Systemãã°ã«ã¢ã©ã¼ãæ¸ãã ããã¨æãã¾ãã
ã¾ããå ã»ã©ã®ãã¼ã¿ãã¯ãªã¢ããããã«ã2ã¤ã®Setsunaããã»ã¹ãæ¢ãã¦ãã ãããCrtl+Cãªã©ã§å¼·å¶çµäºã§OKã§ãã
ããã¦ã¾ãã¢ã¯ã»ã¹ãã°ãæµãè¾¼ã¿ã¾ãã
ããã¦ãtopã®çµæãæµãè¾¼ããã§ããããã®åã«ã-triggerãä½ãããã¨æãã¾ãã
$tail -f /etc/httpd/logs/access_log | java -jar setsuna.jar -sep " - -" -stream log
triggerã§ã¯ãã¼ãã¢ãã¬ã¼ã¸ãè¦å®å¤ãè¶ ãã¦ããªããããã§ãã¯ããã¾ãã
- trigger "COLUMN10 > 1"
ããã§å©ç¨ããã®ã¯å
ã»ã©ã®æµããã¨ãã ãã¼ã¿ãåèã«COLUMN10ãæå®ãã¦ãã¾ãã
ããã¯ç´è¿ã®ãã¼ãã¢ãã¬ã¼ã¸ã®å¤ã§ããããã¦ã'>'ã¨ããæ¡ä»¶è¨å·ã使ã£ã¦ã
'1'ã¨ãæ°å¤ä»¥ä¸ãæå®ãã¦ãã¾ãã
ããã§æ³¨ç®ãã¦ãããããã®ã¯ãä¸ã®å解ããtopã®COLUMN10ã®å¤ã§ãã
COLUMN10ã®å¤ã¯æ°å¤ã®å¾ãã«','ãå ¥ã£ã¦ãã¾ãããã®æåã§ãã"0.20,"ãæ°å¤å¤æããã¨
"COLUMN10":"0.20,"
å½ç¶æå¾ã®','ã®ããã§å¤æã¨ã©ã¼ã«ãªã£ã¦ãã¾ãã¾ãã
ããããSetsunaã®æã¤'>'ã'<'æ¡ä»¶è¨å·ã¯ãããã£ãå¤ãå¯è½ãªéãæ°å¤åãã¾ãã
ã¤ã¾ãæå¾ã®','ã¯å¤ãã¦æ°å¤ã«å¤æãã¦ããæ¯ã¹ã¾ãã
ããã¯ã対象ãã¼ã¿ã®ä¸ããæ°å¤ãæåã«è¦ã¤ããã¨ããããæ°å¤ã§ã¯ãªããªãã¾ã§ã®éã®
å¤ãæ°å¤ã¨ãã¦èªèããããã«åºæ¥ã¦ããããã§ãããªã®ã§ã"Count=10"ã¿ãããªå¤ã§
ãã£ã¦ã10ã¨èªèãããã¨ãã§ãã¾ãã
ãã®ã»ãã«æ¡ä»¶è¨å·ã¯å®å ¨ä¸è´ãæå®ãã'='ããé¨åä¸è´ãæå®ãã'like'ãåå¨ãã¾ãã
ã§ã¯ããã§triggerã¯å®æã§ãã
次ã«ã¢ã¯ã»ã¹é »åº¦ã®é«ãIPãè¦ã¤ãã-queryã§ããããã¯å®å ¨ã«SQLã§è¨è¿°ãã¾ãã
æ¢ã«å®è¡ä¸ã®ã¢ã¯ã»ã¹ãã°ã®ã¹ããªã¼ã ãå©ç¨ãããã¨æãã¾ãã
ã¢ã¯ã»ã¹é »åº¦ã®é«ãIPãæ½åºããã¯ã¨ãªã ãè¨è¿°ãã¾ãã
ããã§ç´è¿ã®60ç§ã®ãã°ããã¢ã¯ã»ã¹ãã¦ããIPã¢ã¯ã»ã¹åæ°ã®å¹³åã
select
count(*)
from
(select count(column0) as gcnt,
column0
from
log \ // 20120321:ä¿®æ£
group by column0)
where (gcnt*3) < (select
avg(cnt)
from (select
count(column0) as cnt,
column0
from
log
where
C_TIME > DATEADD(SECOND, -60, current_timestamp)
group by column0)
);
大ããè¶ ãã(3å)IPãåå¨ãã¦ããããã«ã¦ã³ããã¦ã¾ãã
ããã§æ³¨ç®ãã¦ããã ãããããã®ã¯ãä¸ãã3è¡ç®ã®C_TIMEã¨ããé ç®ã§ãã
ããã¯Setsunaããã¼ã¿ããã¼ãã«ã«æ ¼ç´ããéã«èªåçã«ä½æãã¦ããã«ã©ã ã§ãã
ãã®ã«ã©ã ã«ã¯ããã¼ã¿ãæå ¥ããæ¥æãTimestampåã§ç»é²ããã¾ãã
ãªã®ã§ããã®ããã«ç¾å¨æå»ãã60ç§åã®ãããªæå®ãå¯è½ã«ãªã£ã¦ãã¾ãã
"C_TIME > DATEADD(SECOND, -60, current_timestamp)"ã®é¨åã
ãã®ã»ãã«longåã®ã·ã¼ã±ã³ã¹å¤ããã£ã¦ãã¾ããããã¯0å§ã¾ãã®ã·ã¼ã±ã³ã¹å¤
ãªã®ã§ãåç´ã«ãã¼ã¿ãã½ã¼ãããéã¯ãã¡ãã便å©ã§ãã
ãã®æ¡ä»¶æå®ã®é¨åãQueryã¨å¼ãã§ãã¾ãã
ãã¦-tirggerã¨-queryã§ãã¼ã¿ããã³ããªã³ã°åºæ¥ãã°å¾ã¯ãUserEventã¨è¨ãæå¾ã®é¨åã§ãã
ããã¯ãã¦ã¼ã¶ãèªç±ã«å®ç¾©ããå¦çãæå®ããé¨åã§ãã
ä»åã®ä¾ã§ã¯loggerã¨è¨ãããsyslogã«ãã°ãåºåããæ¨æºã®ã©ã¤ãã©ãªã使ãããã¨æãã¾ãã
UserEventãå©ç¨ããå ´åã¯-eventã¨è¨è¿°ãããã以éã«å®è¡ããã³ãã³ããè¨è¿°ãã¾ãã
以ä¸ã®ããã«ãªãã¾ãã
ããã¦ä»ã¾ã§ã®å ¨ã¦ãç¹ãã¨ä»¥ä¸ã®ããã«ãªãã¾ãã
-event "logger Warning!! System busy"
ããã§topã®ãã¼ãã¢ãã¬ã¼ã¸å¤ã1以ä¸ã®å ´åã«ãç´è¿60ç§éã®ã¢ã¯ã»ã¹ã®éã«ç°å¸¸ã«
$top -b -d 1 | grep --line-buffered "top -" | java -jar setsuna.jar -stream top\
-trigger "COLUMN10 > 1" \
-query "select \
* \
from \
(select count(column0) as gcnt,\
column0 \
from \
log \ // 20120321:ä¿®æ£
group by column0) \
where (gcnt*3) < (select \
avg(cnt) \
from (select \
count(column0) as cnt,\
column0\
from \
log\
where\
C_TIME > DATEADD(SECOND, -60, current_timestamp)\
group by column0)"\
-event "logger Warning!! System busy"
ã¢ã¯ã»ã¹æ°ãå¤ãIPã¢ãã¬ã¹ãè¦ã¤ãã¦syslogã«ã¯ã¼ãã³ã°ãåºåã§ãã¾ãã
â»2012/03/20 追è¨
- eventã§æå®ããã³ãã³ãã«ã¯å¼æ°ã¨ãã¦ãã®UserEventãå®è¡ããå¼ãéã¨ãªã
Adapterããã®ãã¼ã¿ã1ã¬ã³ã¼ãã渡ãããã®ã§ç¬¬ä¸å¼æ°ã§åå¾ãã¦ä½¿ãã¾ãã
ãããªæãã§ãã
å®éã«ã¯ä¸ã®ããã«ãªãã¾ãã
-event "logger "
logger "{"COLUMN0":"top","COLUMN1":"-","COLUMN2":"17:01:58","COLUMN3":"up","COLUMN4":"23","COLUMN5":"min,","COLUMN6":"2","COLUMN7":"users,","COLUMN8":"load","COLUMN9":"average:","COLUMN10":"0.20,","COLUMN11":"0.12,","COLUMN12":"0.09"}"
1ã¬ã³ã¼ãã§ã¯ãªããSQLãªã©ã§ãã¼ã¿ãåå¾ãã¦ããããå©ç¨ãããå ´åã¯
- eventqueryã使ãã¾ãã
ããã¯UserEventã§SQLãå®è¡ãããã®ã§æ¸ãæ¹ã¯-queryã¨å
¨ãåãã§ãã
ãã çµæãæ¨æºåºåã«åºåãããã®ã§ãSetsunaãã®ãã®ãããã«å¥ã®ã³ãã³ãã«ãã¤ãã§ç¹ãã§ã-eventqueryã®çµæãå©ç¨åºæ¥ã¾ãã
ãã¼ã¸ã§ã³0.0.1ã§ã¯-eventãã-eventqueryã®ã©ã¡ããããæå®åºæ¥ã¾ããã
次ã®ãã¼ã¸ã§ã³ã§ããã®ã¯ã¨ãªã®çµæã-eventã§æå®ããã³ãã³ãã«ã渡ããæ§ã«ããäºå®ã§ãã
ãã®ããã«ãè¤æ°ã®ãã¼ã¿ãSetsunaã«æµãã¦ããã°ããããè¤åãã¦ãã¼ã¿ã®å¤åãæ´ããã¨ã
åºæ¥ã¾ããã¦ã¼ã¶ã¤ãã³ããæå®ã¯èªç±ãªã®ã§ãã¡ã¼ã«ãåºããããä»åã®ä¾ã§è¨ãã¨iptablesãªã©ã§
IPãé®æãããã¨ãã§ãã¾ãã
ãã ãããã¼ã¿ãã¼ã¹ã§ã¯ãªããããã¼ã¿ãèç©ãããã¨ã¯ã§ãã¾ãããSQLã§ãã¼ã¿ãå¼ãããã
ãã¼ã¿ã¯èç©ãããããã«è¦ãã¾ãããèªåçã«å¤ããã¼ã¿ããæ¶ãã¦ããã¾ãã(ããã©ã«ã10åå)
ããã¯å¤§éã®ã¤ã³ããããã¼ã¿ã«é«éã«å¦çãè¡ãããã«å
èDBãã¤ã³ã¡ã¢ãªã§ããããã§ãã
ããã¾ã§å¦çãè¡ãã¨ã³ã¸ã³ã¨ããã¨ããã§ããã
ç¾å¨ã¯ãã¤ãã®ã¤ã³ããããããªãã®ã§ä»å¾ã¯ãµã¼ãåã®éçºãè¡ããå¤é¨ããNWè¶ãã«ãã¼ã¿ã
æµããããã«ããäºå®ã§ãããã°ã³ã¬ã¯ã¿ãæè¿ã¯ç±ãã®ã§ããããã¨ãã¤ãªãããã§ã(fluentdã¨ãè¯ãã§ããï¼ï¼)ã
Complex Event Processing Engineãã¤ããã¯ããã
ä¹
ãã¶ãã®æ稿ã ãã
ä»ã¾ã§ã¯okuyamaã¡ã¤ã³ã§OSSæ´»åããã¦ãããã©ããæ°ãã«ãããã¯ããå§ãã¾ããã
æ°ãããããã¯ãã¯CEPã¨è¨ããã種é¡ã®ã½ããã¦ã§ã¢ã§ãã
ãããããCEPã£ã¦ãªãã ï¼ï¼
Complex Event Processingã®ç¥ã«ãªãã¾ãã
訳ãã¨ãè¤åã¤ãã³ãå¦çã§ãã
ã§ã£ãä½ãåºæ¥ãããªãã§ãã
ãªã¢ã«ã¿ã¤ã å¦çãå¾æãªã¨ã³ã¸ã³ã§ãã
ããã ãã§ã¯ãã³ã¨ããªãã®ã§ãå°ãä¾ãèãã¦ã¿ã¾ãã
ä¾1)
ãããµã¼ãã®ç£è¦ããããã¨ãã¾ãã
ç£è¦ã«ã¯é¦´æã¿ã®sarããtopã使ãã¨ä¾¿å©ã§ãããã
ä¾ãã°topã-bãªã©ã®æ¨æºåºåã«çµæãæ¸ãåºãã¢ã¼ãã§åããã¦ã
ããããã¤ãã§grepã«ã¤ãªãã§ãã¼ãã¢ãã¬ã¼ã¸ã®
é¨åãåãåºãã¦ã1ãè¶
ãã¦ããã¡ã¼ã«ãæãããããããªå ´åã©ãä½ãã¾ãããï¼
ãã¼ãã¢ãã¬ã¼ã¸ãåãåºãã¾ã§ã¯ãã®ã¾ã¾ã§è¯ãããã§ãã
ãããããããã¡ã¤ã«ã«ãªãã¤ã¬ã¯ããã¦ããããç£è¦ãããã¹ã¯ãªãããæ¸ãã¾ããããã
çµæ§é¢åã§ããããã«çºè¦ã¾ã§ã«ã¿ã¤ã ã©ã°ãããããã§ãã
ãããæ´çããã¨ã
ãã¼ãã¢ãã¬ã¼ã¸ã¨ãããã¼ã¿ã®æµãã«
æ¡ä»¶æ¤ç´¢ãè¡ã£ã¦ã
çµæ次第ã§å¦çããã¦ãã¾ãã
ã§ã¯ã次ã¯ä¾2)
ä¾1ã«å¥ã®è¦ç´ ãå ãããã©ãã§ãããï¼
ãã¼ãã¢ãã¬ã¼ã¸ãè¦å®å¤ãè¶ããã ãã§ã¡ã¼ã«ãçããå¤å¯ããªãã®ã§ã
ããå°ãç£è¦ãè³¢ããããã§ãã
ãã¨ãã°ãã¼ãã¢ãã¬ã¼ã¸ãè¦å®å¤ãè¶
ãã¦ãå ´åã«ããã¡ã¼ã«ãéãã®ã§ã¯ãªãã
ãµã¤ãã®å¿çé度ã3ç§ãè¶ãã¦ãå ´åã«ã ããããããã
ã¾ãã¯ãI/O-Waitã30% ãè¶ãã¦ãå ´åã«ã¡ã¼ã«ãéãããã
èãåºãã¨ããªãããã¾ããã
ããããã¼ãã¢ãã¬ã¼ã¸ãã¤ãããªã£ã¦ãããµã¤ãã®å¿çé度ãè¨æ¸¬ãã¦ãã®ã§ã¯é
ããã§ãã
ãã®å¦çã¯å
ã»ã©ã®ãã¼ãã¢ãã¬ã¼ã¸ã ãã§ã¯ãªããµã¤ãã®å¿çæéããI/O-Waitãªã©ã
ãã¼ãã¢ãã¬ã¼ã¸ããããªã£ã¦ãå¿çæéããããªã£ãå ´åã¨ããè¤æ°ã®æ¡ä»¶æ¤ç´¢ããããªã£ã¦
æºãããå ´åã«å¦çããããªã£ã¦ãã¾ãã
ãããã£ãè¤æ°ã®æ¡ä»¶ãæºãããå ´åãæ¤ç¥ããã«ã¯çµæ§ãªä»çµã¿ãå¿
è¦ã ã¨æãã¾ã
ãããæ¡ä»¶ãã¿ãããã¨åæã«å¦çãããã«è¡ããªããã°ãªããªãã
ããã§CEPã§ãã
CEPã¯ãªã¢ã«ã¿ã¤ã ã«è¤æ°ã®ãã¼ã¿ã«æ¨ªæçã«æ¡ä»¶ãããã³ã°ãè¡ã£ã¦ããã«
ãã®çµæ次第ã§ã¤ãã³ããçºçããããã¨ã«ç¹åãã¦ãã¾ãã
okuyamaã®ããã«ãã¼ã¿ãããããã¯ã§ãã¾ãããã§ããä¸å®æéã®ãã¼ã¿ã
èãããã¨ã¯åºæ¥ã¾ãããªã®ã§ããã®ä¸å®æéã«å¯¾ãã¦å¦çããããã¨ã
å¾æã§ãããã£ãã®ä¾ã§ããã¨ãä»ã®ãã¼ãã¢ãã¬ã¼ã¸ã§ã¯ãªãç´è¿5åã®ãã¼ã
ã¢ãã¬ã¼ã¸ã®å¹³åãããã ã£ããã¨ãããµã¤ãã®å¿çã3ç§ä»¥ä¸ããã£ã¦ãããã¨ã
ï¼å以å
ã«100å以ä¸ãã£ãããªã©ãè¦ã¤ãããã¨ãåºæ¥ã¾ãã
ããã¦ã¦ã¼ã¶ãä½æããã¤ãã³ããåæã«å¼ã³åºãã¦ããã¾ãã
ããã¦ãªã«ãããã®ä¸é£ã®å¦çãç¸å½é«éã«ãããªãã¾ãã
ãªã®ã§ã¢ã¯ã»ã¹ãã°ã®ãããªåãå¢ãã§ã¤ããã ããããã¼ã¿ã
ãªã¢ã«ã¿ã¤ã ã«å¦çãããã¨ã«ãåãã¦ãã¾ãã
ãã®ãããã®ã話ã¨ä»ä½ã£ã¦ããã¨ã³ã¸ã³ã®ã話ãä»åº¦
ç¥æ¸ã§ããåå¼·ä¼ã§ã話ããäºå®ã§ãã
http://atnd.org/events/25695
ã¾ã ãªãªã¼ã¹ã¯ãã¦ã¾ããããä¸å¿ä»¥ä¸ã«å®è£
ä¸ã®ã³ã¼ããããã¾ãã
http://sourceforge.jp/projects/setsuna/
Java7éæ»ãã¹ã
ã¨ããããã§ãJava7ããªãªã¼ã¹ããã¾ããã
è²ã
ã¨é¢ç½ãããªæ©è½ãããã¾ããã
åã¯SCTPãªã©ãçµæ§æ³¨ç®ãªãã§ãããåãåããJava7ä¸ã§ç¾è¡ã®okuyamaãåããã¦ã
ã©ãããåç´æ¯è¼ã§æ§è½ãéãã®ãæ¤è¨¼ãã¦ã¿ã¾ããã
okuyamaå´ã¯ç¹ã«Java7ã«åããã¦å¤æ´ãªã©ã¯ãã¦ããªãã®ã§ããªãªã¼ã¹Version-0.8.8ã®ã¾ã¾ã§ãã
ã¡ãªã¿ã«ãokuyamaã¯Threadãjava.langç³»ãjava.utilç³»ãjava.ioç³»ãjava.util.concurrentç³»ãªã©ã
ãããã¨ããã§ä½¿ã£ã¦ãã¾ãã
ã³ã³ãã¤ã«ã®ã¿Jdk6ã¨Jdk7ã§ããããå®è¡åã«è¡ãã¾ããã
okuyamaã®ã¢ã¼ãã¯æ°¸ç¶åç¨ã®WALãã¡ã¤ã«ã¯å¸¸ã«åãåºãã¦ãããå¾ãã¼ã¿ãã¡ã¢ãªã«æã¤ã¢ã¼ãã¨ã
ãã¡ã¤ã«ã«æã¤ã¢ã¼ãã§è¨æ¸¬ãã¾ããããã¡ã¤ã«ã«æã¤å ´åã¯ãã¡ã¤ã«ã¸ã®I/Oã¯ã©ã³ãã ãªã¼ãã§ãã
ã¡ã¢ãªå±éã¯SeriarizeMapããããã¾ããããã®å ´åã¯Objectã®ã·ãªã¢ã©ã¤ãºããã·ãªã¢ã©ã¤ãºä¸ã¤ãzipå§ç¸®ãè¡ããã¾ãã
以ä¸ã¯å®è¡ããPCã®ã¹ããã¯ã§ãã1å°ã§è¡ãã¾ããã
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
CPUï¼Intel Corei5 650 3.20GHz
Memoryï¼4GB
HDDï¼SATA 7200rpm 500GBÃ1
OSï¼CentOS5.5 (64bit)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
okuyamaã®GCãªãã·ã§ã³ã¯ä»¥ä¸ã§ãã
"-Xmx1024m -Xms1024m -server -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseParNewGC"
ãã¹ãã¯åæã«8ã¯ã©ã¤ã¢ã³ããã¹ã¬ããã§çæãã1åã¢ã¯ã»ã¹ãSetãGetå
±ã«ãç¶ãã¾ãã
å®éã«ã¢ã¯ã»ã¹ãè¡ãã¯ã©ã¹ã¯ä»¥ä¸ã§ãã
http://sourceforge.jp/projects/okuyama/svn/view/trunk/test/ResponseTestThread.java?view=markup&revision=637&root=okuyama
ãã®ã¯ã©ã¹ãä¸è¨ã®ã¯ã©ã¹ã§8åã¤ã³ã¹ã¿ã³ã¹åãã¦Threadã¨ãã¦å®è¡ãã¾ãã
http://sourceforge.jp/projects/okuyama/svn/view/trunk/test/ResponseTest.java?view=markup&revision=442&root=okuyama
ããã§ã¯ããããã®çµæã§ãã
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ã¢ã¼ãï¼WALãã¡ã¤ã«ï¼Keyï¼Valueå ±ã«ã¡ã¢ãª
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
âSet
â Java6
60ç§ = 1045091
17418 QPS
â Java7
60ç§ = 1201714
20028 QPS
âGet
â Java6
60ç§ = 1359632
22660 QPS
â Java7
60ç§ = 1553264
25887 QPS
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ã¢ã¼ãï¼WALãã¡ã¤ã«ï¼Keyï¼Valueå ±ã«ã¡ã¢ãªï¼SerializeMap
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
âSet
â Java6
60ç§ = 383142
6385 QPS
â Java7
60ç§ = 418954
6982 QPS
âGet
â Java6
60ç§ = 708405
11806 QPS
â Java7
60ç§ = 799126
13318 QPS
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ã¢ã¼ãï¼WALãã¡ã¤ã«ï¼Key=ã¡ã¢ãªï¼Value=ãã¡ã¤ã«
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
âSet
â Java6
60ç§ = 837324
13955 QPS
â Java7
60ç§ = 939385
15656 QPS
âGet
â Java6
60ç§ = 1273324
21222 QPS
â Java7
60ç§ = 1423650
23737 QPS
ãããªçµæã«ãªãã¾ããã
ç·ãã¦æ§è½ãåä¸ãã¦ããã®ãåããã¾ãã
ã ããã10%ã15%ã¨ãã£ãã¨ããã§ãããã
ã¾ã ã©ããã©ããªã£ã¦ããããçµæãåºã¦ããã®ã
調æ»ã§ãã¦ããªãã®ã§ããã®ã¸ããããããã§ããã
ã¨ããããéæ»ãã¹ãã§ããã
ã第1ååæ£å¦çã¯ã¼ã¯ã·ã§ãã in Tokyoããéå¬ãã¾ãã
7/8ã«ã第ï¼ååæ£å¦çã¯ã¼ã¯ã·ã§ãããã@doryokujinさんã¨å
±åã§éå¬ãã¾ããã
â»ATNDリンク
åå ããã ãã¾ããçæ§ãããã¨ããããã¾ããm(_ _)m
å½æ¥ã®è³æããã®ä»ã®æ
å ±ãå¯è½ãªéãã¾ã¨ãã¦ã¿ã¾ãã
@understeerããã®ããToggetter
http://togetter.com/li/159266
å½æ¥ã®UStream(2å
ä¸ç¶ã§ãããªãã¾ãã)
ãã®1
http://www.ustream.tv/channel/dist-study-1#utm_campaign=togetter.com&utm_source=8743151&utm_medium=social
ãã®2
http://www.ustream.tv/channel/dist-study-2#utm_campaign=unknown&utm_source=8743162&utm_medium=social
å½æ¥ã®ã¹ãã¼ã«ã®æ¹ã
ã®è³æã¨UStreamé²ç»(å½æ¥çºè¡¨é )(â»ç¾æç¹ã§ç§ãèªèãã¦ããç¯å²ã§ã)
ã»okuyama - @okuyamaoo
è³æï¼http://www.slideshare.net/okuyamaoo/20110708-dist-studyokuyama
Ustï¼http://www.ustream.tv/recorded/15864685#dist_study
ã»MongoDB - @doryokujinさん
è³æï¼http://www.slideshare.net/doryokujin/mongodb-replicationshardingmapreduce
Ustï¼http://www.ustream.tv/recorded/15864876
ã»Hibari - @tatsuya6502さん
è³æï¼http://www.slideshare.net/tatsuya6502/hibari-nosql-at-diststudy-20110708
Ustï¼http://www.ustream.tv/recorded/15865171
ã»Cassandra - @yukimさん
è³æï¼http://m7a.me/s/diststudy1/#1
Ustï¼http://www.ustream.tv/recorded/15865706
ã»HBase - @ueshinさん
è³æï¼http://www.slideshare.net/ueshin/20110708-h-base1-in-tokyo
Ustï¼http://www.ustream.tv/recorded/15866025
ã»Mesgpackã¨Fluentã¨Kumofsã«ã¤ã㦠- @frsyuki
Ustï¼http://www.ustream.tv/recorded/15866352
å½æ¥ã¯@ueshinããã¨@frsyukiããã®ãäºäººããé£ã³è¾¼ã¿ã§çºè¡¨é ãã¾ããããããã¨ããããã¾ããã
ã¾ããä¼å ´ããæä¾é ãããã¦ãéå¶ãå¼·åã«ããã¯ã¢ããããã ãã¾ããããããã£æ§
UStreamãtogetterã§ã®æ
å ±ã¾ã¨ãããåä»ã質åã¿ã¤ã ã®éå¶ãªã©ãå¼·åã«ããã¯ã¢ããããã ããã
@understeerãããã¯ããã¦ããçæ§ãæ¬å½ã«ãããã¨ããããã¾ããã
ããã¦@doryokujinããé ¼ãã£ã±ãªãã«ãªã£ã¦ããã¾ããã§ããã
ä»åã¯ã©ã¡ããã¨ããã¨NOSQLã®ã¤ã³ãããã¯ã·ã§ã³ã¨ãªãã¾ããããä¸é¨ã§æ·±ã話ãåºæãã£ã¦ãã¾ããã®ã§
次åã¯NOSQLã使ã£ããããã£ãéçºãã¼ã¯ãããããã£ãéç¨ãã¼ã¯ãªã©ãåºæ¥ãã°é¢ç½ãããªã¨ãæã£ã¦ãã¾ãã
åèªèº«okuyamaãå®è£
ãã¦ã¯ãã¾ãããããã使ã£ããããã¯ãã®éçºããéç¨ã§ã¯ã¾ã ã¾ã è¿·ããã¨ãå¤ãã®ã§
NOSQLã®å®ã·ã¹ãã é©å¿ãéç¨ã¯ã¾ã ã¾ã 試è¡é¯èª¤ã®ãã§ã¼ãºãªã®ããªã¨ãèãã¦ãã¾ãã
ãã®ãããããã¼ãå¥ã§åº§è«ä¼åºæ¥ã¦ãé¢ç½ãããªã¨æã£ã¦ãã¾ãã
ãã®ã¸ãã¯@doryokujinããã¨åçä¼ããã¦èããäºå®ã§ãã
é¢æ±ã§ã¯ãã®ã¾ã¾ã®å¢ãã§è¿ããã¡ã«ç¬¬2åãåºæ¥ãã°è¯ãããªã¼ã¨èãã¦ãã¾ãã
å¾ã¯ãåã®å°å
ã§ãããé¢è¥¿ã§ãæ¯éããããªã¼ã¨æã£ã¦ãã¾ãã
é¢æ±ãé¢è¥¿ä¸¡æ¹ã«è¨ãããã¨ãªãã§ãããããããªãã¨è°è«ããããããªã©ããã°@okuyamaooã«
ã¡ã³ã·ã§ã³é ããã°ã¨æãã¾ãã
okuyama-0.8.8ãªãªã¼ã¹ã¾ã¨ã
okuyamaã®ãã¼ã¸ã§ã³0.8.8ããªãªã¼ã¹ããã®ã§ã
ä»åã®å¤æ´ç¹ãã¾ã¨ãã¦ãããã¨æãã¾ãã
ä»åã®ä¸»è¦ãªè¿½å ã¯SerializeMapãªãã§ãããæ©è½ã¯åã
åã¨ã
ååã®æ¥è¨ã«ã¾ã¨ããã¨ããã§ãã
ãã®æç¹ã§ã¯(ã)ã·ãªã¢ã©ã¤ã¶ã¯ãã¿å®è£
ã ã£ããã§ããã
ãã£ãããªãã§ã¤ã³ã¿ã¼ãã§ã¼ã¹è¦å®ãã¦ãè¨å®ãã¡ã¤ã«ãã
ã¤ã³ã¸ã§ã¯ã·ã§ã³åºæ¥ãããã«ãã¾ããã
åãåããã¯ObjectOutputStreamé¢ä¿ã使ã£ãå®è£
ãå梱ãã¦ã¾ãã
å¾ã»ã©ãåã®è¨äºã§èª¿æ»ãã¦åãç¸æ§ãè¯ãã£ãMessagePackã使ã£ãå®è£
ããªãªã¼ã¹ãã¾ãã
ã¤ã³ã¿ã¼ãã§ã¼ã¹ã¯ã©ã¹ã¯ä»¥ä¸ã§ãã
http://sourceforge.jp/projects/okuyama/svn/view/trunk/src/okuyama/imdst/util/serializemap/ISerializer.java?view=markup&revision=706&root=okuyama
ã·ãªã¢ã©ã¤ãºã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ä¸ã®éãã§ãã·ãªã¢ã©ã¤ãºå¯¾è±¡ã®Mapã¨ããã®Mapã«æ ¼ç´ããã¦ãã
Keyã¨Valueããããã®Classã渡ã£ã¦ãã¾ãã®ã§åèç¨åº¦ã«å©ç¨ã§ãã¾ãã
è¿å´å¤ã¯ã·ãªã¢ã©ã¤ãºå¦çå¾ã®byteé
åã§ãã
public byte serialize(Map serializeTarget, Class mapKeyClazz, Class mapValueClazz);
ãã·ãªã¢ã©ã¤ãºã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ä¸ã®éãã§ãå
ã»ã©ã®ã·ãªã¢ã©ã¤ãºã§å¦çããbyteé
åãå¼æ°ã§æ¸¡ã£ã¦ãã¾ãã
ãããMap復å
ãã¦è¿ãã¾ãã
public Map deSerialize(byte deserializeTarget);
åãåããä»ã®okuyamaã§å®è£
ãã¦ããã½ã¼ã¹ã¯ä»¥ä¸ã§ãã
http://sourceforge.jp/projects/okuyama/svn/view/trunk/src/okuyama/imdst/util/serializemap/ObjectStreamSerializer.java?view=markup&revision=706&root=okuyama
ãã®å®è£
ã¯ã·ãªã¢ã©ã¤ãºã¯ObjectOutputStreamãå©ç¨ãã¦ã·ãªã¢ã©ã¤ãºãããã®ãZipã§å§ç¸®ãã¦ã
ãã·ãªã¢ã©ã¤ãºã¯ãããZip復å
å¾ãObjectInputStreamã§Mapåãã¦ãã¾ãã
è¨å®æ¹æ³ã¯ãDataNode.propertiesã®"DataSaveMapType"ã¨ã"SerializerClassName"ã®è¨å®ã使ãã¾ãã
DataSaveMapType=serializeã<=ããã§SerializeMapã使ã宣è¨ã«ãªãã¾ã
SerializerClassName=okuyama.imdst.util.serializemap.ObjectStreamSerializerã<=å®è£
ããã·ãªã¢ã©ã¤ãºã¯ã©ã¹ãæå®ãã¾ãã
æ®ãã®è¿½å æ©è½ã¯ããã®éãã§ãã
1.OkuyamaClientããããã¼ã¿ã®æå¹æéãè¨å®å¯è½ã«ãã¾ããã
ä»ã¾ã§ã§ããmemcachedãããã³ã«ã§ããã°ãæå¹æéã¯è¨å®å¯è½ã ã£ãã®ã§ããOkuyamaClientã§ã
使ããããã«ãã¾ãããå©ç¨æ¹æ³ã¯setValueã¨setNewValueã®æçµå¼æ°ã«Integeråã§æå¹ãªç§æ°ã
渡ãã ãã§ããIntegerã®æ大æ¡æ°ã¾ã§è¨å®å¯è½ã§ãã
2.ãã¼ã¿åå¾æã«æå¹æéãèªåçã«å»¶é·ããgetValueAndUpdateExpireTimeã¨ããã¡ã½ãããOkuyamaClientã«è¿½å ãã¾ããã
é常ã®getValueã¨åæ§ã®åããããã®ã§ããããã®ã¡ã½ããã¯å®è¡æç¹ã§ãã®ãã¼ã¿ã®æå¹æéå
ã§
ããã°ãæåã«è¨å®ããæå¹æéåæå¹ãªæéã延é·ããã¾ãã
å©ç¨æ³å®ã¨ãã¦ã¯Webç³»ã®ã»ãã·ã§ã³æ
å ±ãªã©ã§ãã»ãã·ã§ã³æ
å ±ã«ã¢ã¯ã»ã¹ããã°ã»ãã·ã§ã³ã
ç ´æ£ããæéã延ã°ããããªå ´åã§ãã
3.è¤æ°Tagãæå®ãã¦ç´ä»ãKeyã¨Valueãåå¾ããgetMultiTagValuesã¡ã½ãããOkuyamaClientã«è¿½å ãã¾ããã
ä»ã¾ã§Tagã¸ã®åå¾ç³»å¦çã¯KeyãKeyã¨Valueã®ã»ããã©ã¡ãã®å ´åã§ãæå®ã§ããTagã¯1ã¤ã ã£ããã§ããã
ããããè¤æ°ã®Tagãæå®åºæ¥ãããã«ãã¾ããã
åå¾ãããå¤ã¯Keyã¨Valueãã»ãããããMapã§ãã
ãã¨ãè¤æ°æå®ãªã®ã§æåã¨ãã¦ANDã¨ORãæå®ã§ããããã«ãã¾ããã
ANDãªãæå®ããTagå
¨ã¦ã«ç´ä»ãKey-Valueã»ããã ããORãªãã©ããã®Tagã«ç´ä»ãã¦ããã°åå¾ããã¾ãã
ãã ãã¾ã å®è£
ããã¾ãã¤ã±ã¦ãªãã®ã§ãOkuyamaClientã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ã¯å¤ãã¾ããããå
é¨å®è£
ã¯å¾ã
å¤ããããããã¾ããã
4.ãã¼ã¿ä¸æ¬åé¤æ©è½ãUtilClientã«è¿½å ãã¾ããã
okuyama.imdst.client.UtilClientã«okuyamaã®å
¨ã¦ã®ãã¼ã¿ãããã¯ãæå®ãããã¼ãã£ã·ã§ã³ã®ãã¼ã¿ã
ä¸æ¬åé¤ããæ©è½ã追å ãã¾ãããtruncateã®ãããªå¦çã§ãã
å©ç¨æ¹æ³ã¯ããã®éãã§ã
java -classpath ./:./classes okuyama.imdst.client.UtilClient truncatedata 192.168.1.1 8888 all
1ã¤ç®ã®å¼æ°ã¯ã'truncatedata'åºå®ã§ãã
2ã¤ç®ã®å¼æ°ã¯ãMasterNodeã®ä¸ã§ãMainMasterNodeã¨ãã管çãè¡ã£ã¦ããMasterNodeã®æ¥ç¶IPæ
å ±ã§ãã
3ã¤ç®ã®å¼æ°ã¯ãMasterNodeã®èµ·åãã¼ãçªå·ã§ãã
4ã¤ç®ã®å¼æ°ã¯åé¤ããé åæå®ã§ãã'all'ãªãå
¨ã¦ã®ãã¼ã¿ãåé¤ããã¼ãã£ã·ã§ã³ç¨ã®Prefixå¤ãªããã®é åã ãåé¤ããã¾ãã
åé¤ã¯ãã¼ã¿éã«ä¾åãã¦å¦çæéããããã¾ãã
5.MasterNodeã®è¨å®æ
å ±ãåå¾ããæ©è½ãUtilClientã«è¿½å ãã¾ããã
MasterNodeã®æã£ã¦ããè¨å®æ
å ±ã¯èµ·åå¾ãDataNodeã®è¿½å ããMasterNodeã®è¿½å ãªã©ã§å¤åãç¶ãã¾ãã
ããã§ç¾æç¹ã§ã®MasterNodeãå©ç¨ãã¦ããè¨å®æ
å ±ãåå¾ããæ©è½ã追å ãã¾ããã
MasterNodeã®æåãããããå ´åãªã©ãã®æ©è½ã§MasterNodeãèµ·åãããã¾ã¾ç¶æ
診æãã§ãã¾ãã
å©ç¨æ¹æ³ã¯ããã®éãã§ãã
java -classpath ./:./classes okuyama.imdst.client.UtilClient masterconfig 192.168.1.1 8888
1ã¤ç®ã®å¼æ°ã¯ã'masterconfig'åºå®ã§ãã
2ã¤ç®ã®å¼æ°ã¯ãè¨å®æ
å ±ã確èªãããMasterNodeã®æ¥ç¶IPæ
å ±ã§ãã
3ã¤ç®ã®å¼æ°ã¯ãMasterNodeã®èµ·åãã¼ãçªå·ã§ãã
åºåãããæ
å ±ã¯ããã®éãã§ã
"998,true,MainMasterNode=[true]- MyInfo=[127.0.0.1:8888]- MainMasterNodeInfo=[127.0.0.1:8888]- AllMasterNodeInfo=[127.0.0.1:8888 127.0.0.1:8889 127.0.0.1:11211]-
CheckMasterNodeTargetInfo=- Algorithm [0]:mod [1]:consistenthash=[1]- AllDataNodeInfo=[{third=[localhost:7553 localhost:7554] sub=[localhost:6553 localhost:6554]
main=[localhost:5553 localhost:5554]}"
ããããã®æå³ã¯
"MainMasterNode=[true]"ï¼ãã®MasterNodeãMainMasterNodeã¨ãã¦ç¨¼åãã¦ãããã®æ
å ±
"MyInfo=[127.0.0.1:8888]]"ï¼ãã®MasterNodeã®ã¦ãã¼ã¯å
"MainMasterNodeInfo=[127.0.0.1:8888]"ï¼ç¾å¨ã®MainMasterNodeã®æ
å ±
"AllMasterNodeInfo=[127.0.0.1:8888 127.0.0.1:8889 127.0.0.1:11211]"ï¼ç¾å¨ã®okuyamaã¯ã©ã¹ã¿ã®å
¨MasterNodeæ
å ±
"CheckMasterNodeTargetInfo="ï¼ãã®MasterNodeãçå確èªãè¡ãå¿
è¦ãããMasterNodeã®æ
å ±
"Algorithmã[0]:mod [1]:consistenthash=[1]"ï¼ç¾å¨ã®æ¯ãåãã¢ã«ã´ãªãºã (æå¾ã®[1]ããã®å¤)
"main=[localhost:5553 localhost:5554]"ï¼å
¨ã¦ã®DataNodeã®æ
å ±
"sub=[localhost:6553 localhost:6554]"ï¼å
¨ã¦ã®SubDataNodeã®æ
å ±
"third=[localhost:7553 localhost:7554]"ï¼å
¨ã¦ã®ThirdDataNodeã®æ
å ±
6.ãã°Fixã¨æ§è½åä¸ããã¾ããã
ããã¤ããã°ãFixãã¾ãããã¾ã¨ãã«åããªããã°ã§ã¯ãªããæé©åç³»ã§ãã
ãªãªã¼ã¹å
容ã¯ä»¥ä¸ã§ãã
ä»åã¯SerializeMapãç®çãªã®ã§ãããä»okuyamaãå©ç¨ããã ãã¦ããã°ãæ¯éå©ç¨ãæ¤è¨ãã¦ã¿ã¦ãã ããã
KeyãValueããã¡ã¤ã«ã使ã£ã¦ããå ´åã¯æ©æµã¯ããã¾ããããKey-Value両æ¹ãããã¯Keyã ãã§ãã¡ã¢ãªã«
è¼ã£ã¦ããããã®ã§ããã°ãã¬ã¹ãã³ã¹ã¨ã®ãã¬ã¼ããªãã«ã¯ãªãã¾ããé£èºçã«æ ¼ç´ã§ãã件æ°ãåä¸ãã¾ãã
æ¤è¨¼ãè¡ã£ãã¨ãã以ä¸ã®è¨å®ã§Keyï¼40byteãValueï¼1000byteç¨åº¦ã®ãã¼ã¿ã1DataNodeã§1å件以ä¸æ ¼ç´ã§ãã¾ããã
OS:CentOS(64bit)
ã¡ã¢ãª:4GB
CPU:Core i5
HDD:500GBÃ2(ã½ããã¦ã§ã¢RAID0)
KeyManagerJob1.memoryMode=false
KeyManagerJob1.dataMemory=false
KeyManagerJob1.keyMemory=true
KeyManagerJob1.keySize=20000000
KeyManagerJob1.memoryLimitSize=98
KeyManagerJob1.virtualStoreDirs=./keymapfile/virtualdata1/
KeyManagerJob1.keyStoreDirs=./keymapfile/data1/,./keymapfile/data2/
- Xmx:2880m
- Xms:2880m
okuyamaã®SerializeMapãæ¤è¨¼ãã¦ã¿ãï¼Getç·¨)(çªå¤ç·¨MessagePack for Javaã試ãã¦ã¿ã)
前回の記事ã§okuyamaã«è¿½å äºå®ã®æ©è½ã§ããã
SerializeMapã¨ããã¡ã¢ãªã®å¹çåãèãã¦å®è£
ãã¦ã¿ãMapå®è£
ã®
Setæ§è½ãå³ã£ã¦ã¿ã¾ããããMapãªã®ã§å½ç¶Getãããã®ã§ä»åã¯ãã®æ§è½ãè¨æ¸¬ãã¦ã¿ã¾ãã
ã¾ãããã®åã«ãã®SerializeMapã®æ§é ãä¸æã§ããçµµã«ãã¦ã¿ã¾ããã
ä¸è¨ã®ãããªæ§é ã§ããå
é¨ã§ConcurrentHashMapã1ã¤ã ãä¿æãã¦ãã¦ã
ãã®Mapã®Valueã«ããã«HashMapããã£ã¦ãã¾ãããã®HashMapã«å®éã«Keyã¨Valueã®
ã»ãããæ ¼ç´ããã¾ããããã¦ãã®HashMapã¯Serializeããå¾ã«
å§ç¸®ãã¦byteåã®é
åã§ãã£ã¦ããã®ã§ãå®éã«Mapãæ ¼ç´ããã¦ããããã§ã¯ããã¾ããã
SetãGetãªã©ã®å¦çãèµ°ã£ãå ´åã¯ãå¦çä¾é ¼ã®Keyå¤ãããã·ã¥é¢æ°ã使ã£ã¦æ°å¤ã«ãã¦ã
ãããConcurrentHashMapã®è¦ç´ æ°ã§å²ã£ã¦åºãä½ãã®å ´æã®HashMapã®byteé
åãDserializeãã¦
å¦çãè¡ãã¾ããConcurrentHashMapã®è¦ç´ æ°ã¯åæåæã«åºå®åããã®ã§ãåºå®æ°ãè¶
ãããã¨ã¯ãªãã
ã¡ã¢ãªä¸ã®Mapãªãã¸ã§ã¯ãã¯ConcurrentHashMap1ã¤ã«ãªãã¾ãã
å©ç¨ããPCã¯ååã¨å
¨ãåããJVMãªãã·ã§ã³ãåãã§ãã¡ã¢ãªå²ãå½ã¦ã ã1024MBã«ãã¾ããã
ãã¹ãç¨ã®PGMã¯ä»¥ä¸ã§ãã
http://sourceforge.jp/projects/okuyama/svn/view/trunk/test/SerializeMapGetTest.java?view=markup&revision=684&root=okuyama
ãã®PGMã¯äºåã«æå®ãã件æ°ã ããè¦ç´ ãç»é²ãã¦ããã«å¯¾ãã¦ä¸¦åã«æå®ã¹ã¬ããæ°ã§ãGetå¦çãã©ã³ãã ã«è¡ãã¾ãã
ä»åã®ãã¹ãã¯ãäºåã«300ä¸ä»¶ç»é²ããã¨ããã«ã8ã¹ã¬ãã並åGetãè¡ããã¿ã¼ã³ã¨ã16ã¹ã¬ãã並åGetãè¡ããã¿ã¼ã³ã
ããã¨ãäºåç»é²ä»¶æ°ã500ä¸ä»¶ã«å¢ããããã¿ã¼ã³ã®4ãã¿ã¼ã³ã試ãã¾ããã
ã¾ããConcurrentHashMapããã®ã¾ã¾å©ç¨ããå ´åã®åèå¤ã§ãã
â»ã¡ã¢ãªå²ãå½ã¦ã512MBã§ã¯åæã®300ä¸ä»¶ãæ ¼ç´ããããªãã®ã§ãã¡ã¢ãªã ã2048MBã«ãã¾ããã
ConcurrentHashMapã®ãã¹ãçµæ
ã»300ä¸ä»¶ - 8ã¹ã¬ãã
ã4208588 QPS
ã»300ä¸ä»¶ - 16ã¹ã¬ãã
ã4263423 QPS
ã»500ä¸ä»¶ - 8ã¹ã¬ãã
ã3333208 QPS
ã»500ä¸ä»¶ - 16ã¹ã¬ãã
ã3360552 QPS
éããªã¼ï¼ï¼
300ä¸ä»¶ã®æã«400ä¸QPSè¶
ãã¦ããã
次ã«SerializeMapã®ãã¹ãçµæã§ãã
ã»300ä¸ä»¶ - 8ã¹ã¬ãã
ã189167 QPS
ã»300ä¸ä»¶ - 16ã¹ã¬ãã
ã191084 QPS
ã»500ä¸ä»¶ - 8ã¹ã¬ãã
ã145988 QPS
ã»500ä¸ä»¶ - 16ã¹ã¬ãã
ã144266 QPS
ä¸è¨ã®ãããªçµæã«ãªãã¾ããã
ConcurrentHashMapã¨æ¯ã¹ã¦ãã¾ãã¨ãå
¨ç¶ã§ããã
ä¸å¿20ä¸QPSãããåºã¦ããã®ã§ãããããã®ã¹ãã¼ãã¯åºãããã§ãã
並åæ°ã§ã®ã¹ãã¼ãä½ä¸ã¯ãã¾ããªãããã§ãã
å½ç¶åãå¤ã«ã¢ã¯ã»ã¹ãç¹°ãè¿ãã°é
ããªãã¾ãããããç¨åº¦ã©ã³ãã ã«ã¢ã¯ã»ã¹ãããå ´åã¯å¤§ä¸å¤«ãªããã§ãã
ããããããã¼ã¿æ°ã®å¢å ã«å½±é¿ãåããããã§ããããã¯å§ç¸®è§£é¤ãDserializeã®é¨åã§å¤§ããªãã¼ã¿ãæ±ãããã§ããã
ãã¦ããããã¯çªå¤ç·¨ã§ãã
ã·ãªã¢ã©ã¤ãºãã¦ãã¼ã¿ãæã¤ã¨ãããã¨ã§ãããã¾ã§ã¯(ã)ã·ãªã¢ã©ã¤ã¶ã«Javaã®ObjectOutputStreamãå©ç¨ãã¦ããã®ã§ããã
ãã®ä»ã®ãã®ã試ãã¦ã¿ããã¨æãã¾ããMessagePack for Javaãããããã¦ããã ãã¾ããã
ãã¼ã¸ã§ã³ã¯0.5.2ãå©ç¨ã
ããã°ã©ã ã¨ãã¦ã¯SerializeMapã®ã·ãªã¢ã©ã¤ãºå¦çã¨ãã·ãªã¢ã©ã¤ãºå¦çã®é¨åãmsgpackç¨ã«å¤æ´ãã¦ãå§ç¸®ã¯æ¢ã«
ã©ã¤ãã©ãªå´ã§è¡ã£ã¦ããã¨ããæ
å ±ãããã¾ããã®ã§é¤å¤ã
ã·ãªã¢ã©ã¤ãºã¯ä»¥ä¸ã®ãããªæ§æ
public static byte dataSerialize(Map data) {
return MessagePack.pack(data);
}
ãã·ãªã¢ã©ã¤ãºã¯ä»¥ä¸ã®ãããªæ§æ
public static Map dataDeserialize(byte data) {
return (Map)MessagePack.unpack(data, tMap(TString, TString));
}
ãã®ãããåãããããã§ãã!!
ã§ã¯æ©éSetãããã¹ãã
æ¡ä»¶ã¯[http://d.hatena.ne.jp/okuyamaoo/20110616:title=åå]ã¨ã¾ã£ããåãç¶æ
ã§ãã
ã»1ç§å½ããã®ã»ããæ°
TotalExecCount = 2981566
QPS = 298156
åãã§ããç§é30ä¸Setãªã®ã§ãæ¨æºã®Objectã·ãªã¢ã©ã¤ãºã6ä¸QPSç¨åº¦ã ã£ãã®ã§ã
大ä½5åç¨åº¦ã®ã¹ãã¼ãã§ããåç´ã«ConcurrentHashMapã¨æ¯ã¹ã¦ã2åã®1ç¨åº¦ã®ã¹ãã¼ããåºã¦ãã¾ãã
ã¤ãã«ãéçæ ¼ç´æ°
éå§ç´å¾
1124725
2112027
2788948
3377631
3938942
大ä½ã3ç§ã§100ä¸ãã70ä¸ä»¶ã®ãã¼ã¹ã§sizeãå¢ãã¦ããã®ã§ã
30ã25ä¸QPSã§ã¦ããã®ãåããã¾ãã
é常ã«é«éã§ããã
ããã¦ã1000ä¸ãè¶
ããå½ããã§ã¯ã
10337128
10462071
10597972
10760863
10907505
大ä½ã3ç§ã§13ä¸ä»¶ãã15ä¸ä»¶ç¨åº¦å¢ãã¦ããã®ã§ã5ä¸QPSããã§ããããã
å¼ãç¶ãããªãé«éã§ãã
ããã¦ã1400ä¸ä»¶ç¨åº¦ã®ãã¼ã¿ãæ ¼ç´ããç¶æ
ã§ãç§éã®Setæ°ã700QPSç¨åº¦ã«ãªãã¾ããã
14685807
14688025
14690492
14692575
14694516
ãã®å¾ã1480ä¸ç¨åº¦ã§OutOfMemoryã¨ãªãã¾ããã
ConcurrentHashMapããã å©ç¨ããå ´åã¯200ä¸ä»¶ç¨åº¦ã§OutOfMemoryã§ããã®ã§ã
大ä½7åç¨åº¦ã®ãã¼ã¿ãä¿æã§ãã¦ä¸ã¤ã1000ä¸ä»¶ä¿ææç¹ã§ãããªãé«éã§ãã
ç¶ãã¦ãGetã®ãã¹ãã§ãã
ãã¡ããæåã®ã»ãã«æ¸ãã¦ããã®ã¨åãæ¡ä»¶ã§è©¦ãã¾ããã
ãã¹ãçµæã§ãã
ã»300ä¸ä»¶ - 8ã¹ã¬ãã
ã972738 QPS
ã»300ä¸ä»¶ - 16ã¹ã¬ãã
ã963889 QPS
ã»500ä¸ä»¶ - 8ã¹ã¬ãã
ã683249 QPS
ã»500ä¸ä»¶ - 16ã¹ã¬ãã
ã684657 QPS
åãéãï¼ï¼
ãã¼ã¿ã®å¢å ã§é
ããªããã¨ã¯ã©ããããããªãã¨ã¯æãã¾ããã
300ä¸ä»¶ã¸ã®ã¢ã¯ã»ã¹ã«ããã£ã¦ã¯ã100ä¸QPSã«å±ããããªå¢ããªã®ã§ã
å®ã«ObjectOutputStreamã®5åã§ãã500ä¸ä»¶ã§ãé常ã«é«éã§ãããã¨ãåããã¾ããã
ã·ãªã¢ã©ã¤ãºã«ãããã¼ã¿ãµã¤ãºãããªãå°ãããªããããã¦é«éãªã·ãªã¢ã©ã¤ãºããã·ãªã¢ã©ã¤ãºã¯é常ã«æå¹ã§ããã
okuyamaã§ãå©ç¨ããã¦é ãããã¨èãã¦ããã¾ãã