twitterã§ãå©ç¨ããã¦ããã¡ãã»ã¼ã¸ãã¥ã¼ Kestrelã試ã
ã¤ãã£ãã¼ãããã£ã¦ã¾ãã?
ã¤ãã£ãã¼ããã®ããã¯ã¨ã³ãã¯ãå®ã¯scalaã§æ¸ããã¦ããã£ã¦ãåãã§ãã?
æ¥æé·ããã¤ãã£ãã¼ããã®ããã¯ã¨ã³ããæ¯ãããªãã¦ãããã§ããscala!
ã¤ãã£ãã¼ããã¨scalaã®ã話ã¯ããã¡ããåèã«ã
Twitter on Scala
ã§ãKestrelã¨ããã¡ãã»ã¼ã¸ãã¥ã¼ããã¤ãã£ãã¼ããã®ããã¯ã¨ã³ãã®ä¸é¨ã§å©ç¨*1ããã¦ãã¾ãã
ãã®Kestrelã¯ãªã¼ãã³ã½ã¼ã¹ã§èª°ã§ãå©ç¨ãããã¨ãã§ãã¾ãã
ã¡ãã£ã¨è©¦ãã¦ã¿ã¾ãããã
Kestrelã®ç¹å¾´
READMEã«æ¸ãã¦ãããã®ããã®ã£ããã¦ãã¨ãã«æ訳ãã¾ãã
Kestrel is: fast It runs on the JVM so it can take advantage of the hard work people have put into java performance. small Currently about 1.5K lines of scala (including comments), because it relies on Apache Mina (a rough equivalent of Danger's ziggurat or Ruby's EventMachine) and actors -- and frankly because Scala is extremely expressive. durable Queues are stored in memory for speed, but logged into a journal on disk so that servers can be shutdown or moved without losing any data. reliable A client can ask to "tentatively" fetch an item from a queue, and if that client disconnects from kestrel before confirming ownership of the item, the item is handed to another client. In this way, crashing clients don't cause lost messages.
- é«éãªãã ã?
- JVMã§åãããã ã
- å°ããã?
- 1.5Kè¡
- Apache Minaã¨actorã§æ¸ãã¦ããã
- ä¸å¤«ã ã?
- ãã¥ã¼ã®ä¸èº«ã¯ã¡ã¢ãªã«æ¸ããã©ããã¡ã¤ã«ã«ã¸ã£ã¼ããªã³ã°ãããã
- ä¿¡é ¼ãã¦ãããã ãï¼
- ã¯ã©ã¤ã¢ã³ãããã¥ã¼ããåã£ã¦ãæä¸ã«ã¯ã©ãã·ã¥ãã¦ããã¥ã¼ã®ä¸èº«ã¯æ¶ããªã
- ãã©ã³ã¶ã¯ã·ã§ã³ã£ã½ã
Kestrelã®ãã¦ã³ãã¼ãããã«ã
Kestrelã¯java6(JMXãµãã¼ã)ã¨Ant1.7以ä¸ãå¿ è¦ãªã®ã§ã¤ã³ã¹ãã¼ã«ãã¦ããã¾ãããã
ã¾ãã¯Kestrelã®ã½ã¼ã¹ããã¦ã³ãã¼ããã¦æ¥ã¾ãããã
ã½ã¼ã¹ã¯Githubã«ããã¾ããã
è½ã¨ãã¦ããããã½ã¼ã¹ã®ãã£ã¬ã¯ããªã«ç§»åãã¦ãantã³ãã³ãããã¡ã¾ãã
çµæ§æéããããã¾ã*2ããããã§ãã«ãã§ãã¾ãã
Kestrelãèµ·åãã
ãã«ãåºæ¥ãããdist/kestrel-1.1.2/ã¨ãã£ã¦ãã£ã¬ã¯ããªãã§ãã¦ã¾ãã
kestrel-1.1.2.jarã¨ãç½®ãã¦ããã¾ããã
kestrelã®èµ·åã¯ãdist/kestrel-1.1.2/scriptsã«ããkestrel.shãå©ãã°ãããã§ãããããè¦ãã¨/usr/local/bin/daemonã¨ãæ¸ãã¦ããã¾ãã
èªåã¯mac osxãªã®ã§/usr/local/bin/daemonã¨ãããã¾ããã
ããã©ãããã®ã§java -jarã³ãã³ãã§èµ·åãã¾ããã
kestrelãåããããã«ã¯ãã¸ã£ã¼ãã«æ¸ãè¾¼ã¿ç¨ã®ãã£ã¬ã¯ããª( /var/log/kestrel) ã¨ãspoolç¨ã®ãã£ã¬ã¯ããª(/var/spool/kestrel)ãå¿ è¦ãªã®ã§ãããããä½æãã¦ããã¾ãã
mkdir -p /var/log/kestrel sudo chown -R <ã¦ã¼ã¶ã¼å>:staff /var/log/kestrel mkdir -p /var/spool/kestrel sudo chown -R <ã¦ã¼ã¶ã¼å>:staff /var/spool/kestrel
æºåãçµãã£ãããdist/kestrel-1.1.2/ã«ç§»åãã¦ãjava -jar kestrel-1.1.2.jar ã§èµ·åãã¾ãã
cd dist/kestrel-1.1.2/ java -jar kestrel-1.1.2.jar
Memcache Protocolã§ã®set/get
kestrelã¯ãã¡ãã»ã¼ã¸ã®ãã¥ã¼ã¤ã³ã°ã«Memcache Protocolãå©ç¨ãã¾ãã
ã¯ã©ã¤ã¢ã³ãããkestrelã«ã³ãã¯ã·ã§ã³ãå¼µã£ã¦ãMemcache Protocolã«æºæ ããã³ãã³ããæãããã¨ã§ã¡ãã»ã¼ã¸ããã¥ã¼ã«å
¥ããããåãåºãããåºæ¥ã¾ãã
memcachedã³ãã³ãã«ã¤ãã¦ã¯ããã¡ããåèã«ãã¾ããã
[memcached] memcachedコマンド一覧 - Life with IT
kestrelã¯ããã©ã«ãã§22133portãlistenãã¦ããã®ã§ãtelnetã³ãã³ãã§æ¥ç¶ãã¦ã¿ã¾ãã
$ telnet localhost 22133 Trying ::1... Connected to localhost. Escape character is '^]'. set foo 0 0 3 aaa STORED set foo 0 0 4 bbbb STORED
memcachedã³ãã³ãã§set <ãã¼> <ãã©ã°> <æå¹æé> <ãµã¤ãº>ã§ãã¼ã¿ããã¥ã¼ã«å
¥ãã¾ãã
ä¸ã®ä¾ã§ã¯ããã¼:fooã«"aaa"ã¨"bbbb"ãå
¥ãã¦ãã¾ãã
kestrelã§ã¯ãmemcacheã®ãã¼ãããã¥ã¼åã«ç¸å½ãã¾ãã
次ã¯ããã¥ã¼ã«å
¥ãããã¼ã¿ãåãåºãã¦ã¿ã¾ãã
memcachedã³ãã³ãã§ãget <ãã¼> ã§åãåºãã¾ãã
get foo VALUE foo 0 3 aaa END get foo VALUE foo 0 4 bbbb END
ãã¼:fooã«storeããé çªã«ããã¼ã¿ãåãåºãããã¨ã確èªåºæ¥ã¾ããã
æ¬å½ã¯ãkestrelã使ã£ã¦ã¤ãã£ãã®ã¿ã¤ã ã©ã¤ã³ãkestrelã®ãã¥ã¼ã«å ¥ãã¦ããã¥ã¼ããåãåºãã¦Growlã§éç¥ãããµã³ãã«ã¨ãæ¸ããã¨æã£ããã§ãããåå°½ããã®ã§ããã¾ã§ã«ãã¦ããã¾ããå®æä¸ã®çç±ã§ã
åè:
http://sites.google.com/site/scalatohoku/dai-29kai-benkyou-kai