ããŒãã«ã¯ããŸããŸãªã©ã€ãã©ãªãåããJavaããããŸãã ãã¹ãŠã¯ãMavenãã©ã°ã€ã³ãä»ããŠãã³ã³ãããŒã®å€éšã§èµ·åãããŸãã ããŒãããŒã®ãã©ãããã©ãŒã ã«åºã¥ããŠãããããããŒã¿ããŒã¹ããããŒã®æäœãã¯ã©ã€ã¢ã³ããšãµãŒããŒã®ããåãã®ç®¡çãªã©ãå¯èœã§ãã DB-RedisãšPostgreSQLïŒååããããããŒã¿ããŒã¹ããå¥ã®ããŒã¿ããŒã¹ã«ç§»è¡ããæ¹æ³ã«ã€ããŠæžããŠããŸã ïŒã
ããžãã¹ããžãã¯ã®èŠ³ç¹ãããã¢ããªã±ãŒã·ã§ã³ã«ã¯ä»¥äžãå«ãŸããŸãã
- ã«ã¹ã¿ã ããŒããšãã®ã³ã³ãã³ããæäœããŸãã
- ããŒãã®ãŠãŒã¶ãŒç»é²ãäœæã管çã®æ©èœã
- ã«ã¹ã¿ã ãªãœãŒã¹ãžã§ãã¬ãŒã¿ãŒã ããšãã°ãã¢ããªã±ãŒã·ã§ã³ã«ã¢ããããŒãããã倧ããªç»åãæé©åããŠãã¯ã©ã€ã¢ã³ãã®é床ãäœäžããªãããã«ããŸãã
- ãµãŒãããŒãã£ã®ãµãŒãã¹ãšã®å€ãã®çµ±åã
2011幎ãç§ãã¡ãå§ããã°ããã®ãšããMiroå šäœãåããµãŒããŒäžã«ãããŸããã ãã¹ãŠãããã«ãããŸããïŒãµã€ãã®phpãå€æŽãããNginxãJavaã¢ããªã±ãŒã·ã§ã³ãããã³ããŒã¿ããŒã¹ã
補åãéçºããããŠãŒã¶ãŒã®æ°ãšããŒãã«è¿œå ãããã³ã³ãã³ããå¢å ããããããµãŒããŒã®è² è·ãå¢å ããŸããã ãµãŒããŒäžã®ã¢ããªã±ãŒã·ã§ã³ã®æ°ãå€ãããããã®æç¹ã§ã¯äœãæ£ç¢ºã«è² è·ãäžããŠããã®ãç解ã§ããããããã£ãŠæé©åã§ããŸããã§ããããããä¿®æ£ããããã«ããã¹ãŠãç°ãªããµãŒããŒã«åå²ããWebãµãŒããŒãã¢ããªã±ãŒã·ã§ã³ãšããŒã¿ããŒã¹ãµãŒããŒã§ã
æ®å¿µãªããããã°ãããããšãã¢ããªã±ãŒã·ã§ã³ã®è² è·ãå¢å€§ãç¶ãããããåé¡ãåã³çºçããŸããã 次ã«ãã€ã³ãã©ã¹ãã©ã¯ãã£ãæ¡åŒµããæ¹æ³ã«ã€ããŠèããŸããã
次ã«ãã¯ã©ã¹ã¿ãŒã®éçºãšJavaã¢ããªã±ãŒã·ã§ã³ãšã€ã³ãã©ã¹ãã©ã¯ãã£ã®ã¹ã±ãŒãªã³ã°ã§çºçããåé¡ã«ã€ããŠèª¬æããŸãã
ã€ã³ãã©ã¹ãã©ã¯ãã£ãæ°Žå¹³ã«æ¡åŒµ
ã¡ã¢ãªãšCPUã®äœ¿çšããŠãŒã¶ãŒã¯ãšãªã®å®è¡ã«ãããæéãã·ã¹ãã ãªãœãŒã¹ã®äœ¿çšãããŒã¿ããŒã¹ã®æäœãªã©ã®ã¡ããªãã¯ãåéããããšããå§ããŸããã ã¡ããªãã¯ããããŠãŒã¶ãŒãªãœãŒã¹ã®çæã¯äºæž¬äžå¯èœãªããã»ã¹ã§ããããšãæããã§ããã ããã»ããµã100ïŒ èªã¿èŸŒã¿ããã¹ãŠãå®äºãããŸã§æ°åç§åŸ ã€ããšãã§ããŸãã ããŒãã«å¯ŸãããŠãŒã¶ãŒã®ãªã¯ãšã¹ãã«ãããäºæããªãè² è·ãçºçããããšããããŸããã ããšãã°ããŠãŒã¶ãŒã1000åã®ãŠã£ãžã§ãããéžæããããããèªçºçã«ç§»åãå§ããå Žåã
ã·ã¹ãã ã®ãããã®éšåãã©ã®ããã«æ¡åŒµãããã«ã€ããŠèãå§ããæãããªè§£æ±ºçãèŠã€ããŸããã
ããŒããšã³ã³ãã³ãã䜿çšããŠäœæ¥ãæ¡åŒµããŸã ã ãŠãŒã¶ãŒã¯æ¬¡ã®ããã«ããŒããéããŸãïŒãŠãŒã¶ãŒã¯ã¯ã©ã€ã¢ã³ããéããŸãâéãããããŒãã瀺ããŸãâãµãŒããŒã«æ¥ç¶ããŸãâãµãŒããŒã§ã¹ããªãŒã ãäœæãããŸãâãã®ããŒãã®ãã¹ãŠã®ãŠãŒã¶ãŒã1ã€ã®ã¹ããªãŒã ã«æ¥ç¶ããŸãâãŠã£ãžã§ããã®å€æŽãŸãã¯äœæã¯ãã®ã¹ããªãŒã å ã§è¡ãããŸã ããŒãã§ã®ãã¹ãŠã®äœæ¥ã¯ãããŒã«ãã£ãŠå³å¯ã«å¶éãããŠããããšãããããŸããã€ãŸãããããã®ãããŒããµãŒããŒéã§åæ£ã§ããŸãã
ãŠãŒã¶ãŒãªãœãŒã¹ã®çæãã¹ã±ãŒãªã³ã°ããŸã ã ãµãŒããŒãåãåºããŠãªãœãŒã¹ãåå¥ã«çæãããšãçæã®ããã®ã¡ãã»ãŒãžãåä¿¡ãããã¹ãŠãçæãããããšã«å¿çããŸãã
ãã¹ãŠãã·ã³ãã«ãªããã§ãã ãããããã®ãããã¯ãããæ·±ãç 究ãå§ãããšããã«ãéæ¥çãªåé¡ãããã«è§£æ±ºããå¿ èŠãããããšãããããŸããã ããšãã°ããŠãŒã¶ãŒã®ææãµãã¹ã¯ãªãã·ã§ã³ã®æå¹æéãåããå ŽåããŠãŒã¶ãŒãã©ã®ããŒãã§ãããã«é¢ä¿ãªããããããŠãŒã¶ãŒã«éç¥ããå¿ èŠããããŸãã ãŸãã¯ããŠãŒã¶ãŒããªãœãŒã¹ã®ããŒãžã§ã³ãæŽæ°ããå Žåããã¹ãŠã®ãµãŒããŒã§ãã£ãã·ã¥ãæ£ãããã©ãã·ã¥ãããŠããããšã確èªããå¿ èŠããããé©åãªããŒãžã§ã³ãæäŸããŸãã
ã·ã¹ãã èŠä»¶ãç¹å®ããŸããã 次ã®ã¹ãããã¯ããããå®è¡ããæ¹æ³ãç解ããããšã§ãã å®éãã¯ã©ã¹ã¿ãŒå ã®ãµãŒããŒãçžäºã«éä¿¡ããããã«åºã¥ããŠãã¹ãŠã®ã¢ã€ãã¢ãå®çŸã§ããã·ã¹ãã ãå¿ èŠã§ããã
ç®±ããåºããŠæåã®ã¯ã©ã¹ã¿ãŒ
ã·ã¹ãã ã®æåã®ããŒãžã§ã³ã¯ã䜿çšããããŒãããŒãã©ãããã©ãŒã ã«æ¢ã«éšåçã«å®è£ ãããŠãããããéžæããŸããã§ããã ãã®äžã§ããã¹ãŠã®ãµãŒããŒã¯TCPãä»ããŠçžäºã«æ¥ç¶ããããã®æ¥ç¶ã䜿çšããŠRPCã¡ãã»ãŒãžã1ã€ãŸãã¯ãã¹ãŠã®ãµãŒããŒã«äžåºŠã«éä¿¡ã§ããŸããã
ããšãã°ã3ã€ã®ãµãŒããŒãããããããã¯TCPãä»ããŠçžäºã«æ¥ç¶ãããŠãããRedisã«ã¯ãããã®ãµãŒããŒã®ãªã¹ãããããŸãã ã¯ã©ã¹ã¿ãŒã§æ°ãããµãŒããŒãèµ·åããŸãâRedisã®ãªã¹ãã«èªåèªèº«ãè¿œå ããŸãâãªã¹ããèªã¿åã£ãŠã¯ã©ã¹ã¿ãŒå ã®ãã¹ãŠã®ãµãŒããŒã確èªããŸãâãã¹ãŠã«æ¥ç¶ããŸãã
RPCã«åºã¥ããŠããã£ãã·ã¥ããã©ãã·ã¥ãããŠãŒã¶ãŒãç®çã®ãµãŒããŒã«ãªãã€ã¬ã¯ããããµããŒããæ¢ã«å®è£ ãããŠããŸãã ãŠãŒã¶ãŒãªãœãŒã¹ãçæããäœããçºçããããšããŠãŒã¶ãŒã«éç¥ããå¿ èŠããããŸããïŒããšãã°ãã¢ã«ãŠã³ãã®æå¹æéãåããïŒã ãªãœãŒã¹ãçæããããã«ãä»»æã®ãµãŒããŒãéžæããŠçæèŠæ±ãéä¿¡ãããµãã¹ã¯ãªãã·ã§ã³ã®æéåãã«é¢ããéç¥ã®ããã«ãã¡ãã»ãŒãžãç®æšã«å°éããããšãæåŸ ããŠã³ãã³ãããã¹ãŠã®ãµãŒããŒã«éä¿¡ããŸããã
ãµãŒããŒèªäœãã¡ãã»ãŒãžã®éä¿¡å ã決å®ããŸãã
åé¡ã§ã¯ãªãæ©èœã®ããã«èãããŸãã ãã ãããµãŒããŒã¯å¥ã®ãµãŒããŒãžã®æ¥ç¶ã®ã¿ã«çŠç¹ãåãããŸãã æ¥ç¶ãããå Žåãã¡ãã»ãŒãžãéä¿¡ããåè£ããããŸãã
åé¡ã¯ããµãŒããŒçªå·1ãããµãŒããŒçªå·4ãçŸåšé«è² è·ã«ãªã£ãŠããããšãèªèããŠããªããããååã«è¿ éã«å¿çã§ããªãããšã§ãã ãã®çµæããµãŒããŒïŒ1ã®ãªã¯ãšã¹ãã¯ãåŠçé床ãé ããªããŸãã
ãµãŒããŒã¯ã2çªç®ã®ãµãŒããŒãããªãŒãºããŠããããšãç¥ããŸãã
ãããããµãŒããŒã®è² è·ãé«ãã ãã§ãªããäžè¬çã«ããªãŒãºããå Žåã¯ã©ããªããŸããïŒ ããã«ãããã¯ãã¯ãçãè¿ããªãããã«ãã³ã°ããŸãã ããšãã°ã䜿çšå¯èœãªã¡ã¢ãªããã¹ãŠäœ¿ãæãããŸããã
ãã®å ŽåããµãŒããŒïŒ1ã¯åé¡ãäœã§ããããç¥ããªããããå¿çãåŸ ã¡ç¶ããŸãã ã¯ã©ã¹ã¿ãŒå ã®æ®ãã®ãµãŒããŒãããµãŒããŒ4ã®ç¶æ³ãèªèããŠããªãããããµãŒããŒ4ã«å€ãã®ã¡ãã»ãŒãžãéä¿¡ããå¿çãåŸ ã¡ãŸãã ãµãŒããŒçªå·4ãæ»ã¬ãŸã§ã§ãã
ã©ããã ãµãŒããŒã¹ããŒã¿ã¹ãã§ãã¯ãã·ã¹ãã ã«åå¥ã«è¿œå ã§ããŸãã ãŸãã¯ããç æ°ã®ããµãŒããŒãããå¥åº·ãªããµãŒããŒã«ã¡ãã»ãŒãžããªãã€ã¬ã¯ãã§ããŸãã ããã«ã¯ãã¹ãŠãéçºè ã®æéãããããããŸãã 2012幎ã«ã¯ããã®åéã§ã®çµéšãã»ãšãã©ãªãã£ãããããã¹ãŠã®åé¡ã«å¯Ÿããæ¢è£œã®è§£æ±ºçãããã«æ¢ãå§ããŸããã
ã¡ãã»ãŒãžãããŒã«ãŒã Activemq
ãµãŒããŒéã®éä¿¡ãæ£ããæ§æããããã«ãã¡ãã»ãŒãžãããŒã«ãŒã«ç§»è¡ããããšã«ããŸããã ActiveMQãéžæããã®ã¯ãç¹å®ã®æéã«ã³ã³ã·ã¥ãŒãã§åä¿¡ã¡ãã»ãŒãžãæ§æã§ããããã§ãã 確ãã«ããã®æ©äŒãå©çšããããšããªããããããšãã°RabbitMQãéžæã§ããŸãã
ãã®çµæãã¯ã©ã¹ã¿ãŒã·ã¹ãã å šäœãActiveMQã«ç§»è¡ããŸããã ãããäžãããã®ïŒ
- ãã¹ãŠã®ã¡ãã»ãŒãžããã¥ãŒãééããããããµãŒããŒã¯ã¡ãã»ãŒãžã®éä¿¡å ãèªåã§æ±ºå®ããªããªããŸããã
- ãã©ãŒã«ããã¬ã©ã³ã¹ãæ§æãããŸããã ãã¥ãŒãèªã¿åãã«ã¯ã1ã€ã§ã¯ãªãè€æ°ã®ãµãŒããŒãå®è¡ã§ããŸãã ãããã®1ã€ãèœã¡ãŠããã·ã¹ãã ã¯åäœãç¶ããŸãã
- ãµãŒããŒã¯åœ¹å²ã®ããã«èŠããè² è·ã®çš®é¡ã«ãã£ãŠãµãŒããŒãåå²ã§ããŸããã ããšãã°ããªãœãŒã¹ãžã§ãã¬ãŒã¿ãŒã¯ã¡ãã»ãŒãžãèªã¿åã£ãŠãªãœãŒã¹ãçæããããã®ãã¥ãŒã«ã®ã¿æ¥ç¶ã§ããããŒããæã€ãµãŒããŒã¯ããŒããéãããã®ãã¥ãŒã«æ¥ç¶ã§ããŸãã
- RPCéä¿¡ãã€ãŸã åãµãŒããŒã«ã¯ãä»ã®ãµãŒããŒãã€ãã³ããéä¿¡ããç¬èªââã®ãã©ã€ããŒããã¥ãŒããããŸãã
- ãµãã¹ã¯ãªãã·ã§ã³ããªã»ããããããã«äœ¿çšãããããã¯ãä»ããŠããã¹ãŠã®ãµãŒããŒã«ã¡ãã»ãŒãžãéä¿¡ã§ããŸãã
ã¹ããŒã ã¯åçŽã«èŠããŸãããã¹ãŠã®ãµãŒããŒããããŒã«ãŒã«æ¥ç¶ããããµãŒããŒéã®éä¿¡ãå¶åŸ¡ããŸãã ãã¹ãŠãæ©èœããã¡ãã»ãŒãžãéåä¿¡ããããªãœãŒã¹ãäœæãããŸãã ããããæ°ããåé¡ããããŸãã
å¿ èŠãªãµãŒããŒããã¹ãŠæšªããã£ããã©ãããŸããïŒ
ãµãŒããŒïŒ3ãã¡ãã»ãŒãžãéä¿¡ããŠããã¥ãŒå ã®ãªãœãŒã¹ãçæããããšããŸãã 圌ã¯ã¡ãã»ãŒãžãåŠçãããããšãæåŸ ããŠããŸãã ããããäœããã®çç±ã§ã¡ãã»ãŒãžã®åä¿¡è ã1人ãããªãããšã圌ã¯ç¥ããŸããã ããšãã°ããšã©ãŒã«ããåä¿¡è ãã¯ã©ãã·ã¥ããŸããã
ãã¹ãŠã®åŸ æ©æéã®éããµãŒããŒã¯ãªã¯ãšã¹ããšãšãã«å€ãã®ã¡ãã»ãŒãžãéä¿¡ããŸãããããã¡ãã»ãŒãžã®ãã¥ãŒã衚瀺ãããçç±ã§ãã ãããã£ãŠã皌åäžã®ãµãŒããŒã衚瀺ããããšãèç©ããããã¥ãŒãæåã«åŠçããå¿ èŠããããæéãããããŸãã ãŠãŒã¶ãŒåŽã§ã¯ãããã¯ãŠãŒã¶ãŒãã¢ããããŒãããç»åãããã«ã¯è¡šç€ºãããªããšããäºå®ã«ã€ãªãããŸãã 圌ã¯åŸ ã€æºåãã§ããŠããªãã®ã§ã圌ã¯ããŒããå»ããŸãã
ãã®çµæããªãœãŒã¹ã®çæã«ãµãŒããŒã®åŠçèœåãè²»ãããçµæãå¿ èŠãšãã人ã¯ããŸããã
ã©ãããã°åé¡ã解決ã§ããŸããïŒ ç£èŠãèšå®ã§ããŸããããã«ãããäœãèµ·ããŠããããéç¥ãããŸãã ããããç£èŠãäœããå ±åããç¬éããããµãŒããŒãæªãããšãç解ããç¬éãŸã§ãæéãçµã¡ãŸãã ããã¯ç§ãã¡ã«ã¯åããŸããã
ãã1ã€ã®ãªãã·ã§ã³ã¯ããµãŒãã¹æ€åºããŸãã¯ã©ã®ãµãŒããŒãã©ã®ããŒã«ã§å®è¡ãããŠããããç¥ããµãŒãã¹ã®ã¬ãžã¹ããªãå®è¡ããããšã§ãã ãã®å Žåã空ããµãŒããŒããªãå Žåã¯ãããã«ãšã©ãŒã¡ãã»ãŒãžã衚瀺ãããŸãã
äžéšã®ãµãŒãã¹ã¯æ°Žå¹³æ¹åã«ã¹ã±ãŒãªã³ã°ã§ããŸãã
ããã¯ãActiveMQã§ã¯ãªããåæã®ã³ãŒãã®åé¡ã§ãã äŸã瀺ããŸãããïŒ
Permission ownerPermission = service.getOwnerPermission(board); Permission permission = service.getPermission(board,user); ownerPermission.setRole(EDITOR); permission.setRole(OWNER);
ããŒãäžã®ãŠãŒã¶ãŒæš©éãæäœãããµãŒãã¹ããããŸãããŠãŒã¶ãŒã¯ããŒãã®ææè ãŸãã¯ãã®ç·šéè ã«ãªããŸãã åç· åœ¹äŒã«ããããšãã§ããææè ã¯1人ã ãã§ãã ãããŠãŒã¶ãŒããå¥ã®ãŠãŒã¶ãŒã«ããŒãã®æææš©ãè²æž¡ãããã·ããªãªããããšããŸãã æåã®è¡ã§ã¯ãããŒãã®çŸåšã®ææè ãååŸãã2è¡ç®ã§ã¯ãç·šéè ã§ãã£ããŠãŒã¶ãŒãååŸããçŸåšã¯ææè ã«ãªããŸãã ããã«ãçŸåšã®ææè ã¯EDITORã®åœ¹å²ããå ã®ç·šéè ã¯OWNERã®åœ¹å²ã眮ããŸãã
ããããã«ãã¹ã¬ããç°å¢ã§ã©ã®ããã«æ©èœããããèŠãŠã¿ãŸãããã æåã®ã¹ã¬ãããEDITORããŒã«ã確ç«ãã2çªç®ã®ã¹ã¬ãããçŸåšã®OWNERãååŸããããšãããšã次ã®ããã«ãªããŸã-OWNERã¯ååšããŸãããã2ã€ã®EDITORããããŸãã
ãã®çç±ã¯ãåæã®æ¬ åŠã§ãã ããŒãã«åæãããã¯ãè¿œå ããããšã§åé¡ã解決ã§ããŸãã
synchronized (board) { Permission ownerPermission = service.getOwnerPermission(board); Permission permission = service.getPermission(board,user); ownerPermission.setRole(EDITOR); permission.setRole(OWNER); }
ãã®ãœãªã¥ãŒã·ã§ã³ã¯ã¯ã©ã¹ã¿ãŒã§ã¯æ©èœããŸããã SQLããŒã¿ããŒã¹ã¯ããã©ã³ã¶ã¯ã·ã§ã³ãå©çšããŠãããæ¯æŽããããšãã§ããŸãã ããããRedisããããŸãã
å¥ã®è§£æ±ºçã¯ãã¯ã©ã¹ã¿ãŒã«åæ£ããã¯ãè¿œå ããŠãåæã1ã€ã®ãµãŒããŒã ãã§ãªãã¯ã©ã¹ã¿ãŒå šäœã®å éšã«ãªãããã«ããããšã§ãã
ããŒãã«å ¥ãéã®åäžé害ç¹
ã¯ã©ã€ã¢ã³ããšãµãŒããŒéã®çžäºäœçšã®ã¢ãã«ã¯ã¹ããŒããã«ã§ãã ãã®ãããããŒãã®ç¶æ ããµãŒããŒã«ä¿åããå¿ èŠããããŸãã ãã®ããããµãŒããŒã«å¥ã®ããŒã«ãäœæããŸãã-BoardServerã¯ãããŒãã«é¢é£ãããŠãŒã¶ãŒãªã¯ãšã¹ããåŠçããŸãã
BoardServerã3ã€ããããã®ãã¡ã®1ã€ãã¡ã€ã³ã®ãã®ã§ãããšæ³åããŠãã ããã ãŠãŒã¶ãŒã¯ãid = 123ã§ããŒããéãããšãããªã¯ãšã¹ããéä¿¡ããŸãããµãŒããŒã¯ãããŒããéããŠãããã©ãããã©ã®ãµãŒããŒäžã«ããããããŒã¿ããŒã¹ã§èª¿ã¹ãŸãã ãã®äŸã§ã¯ãããŒãã¯éããŠããŸãã
ã¡ã€ã³ãµãŒããŒã¯ããµãŒããŒ1ã«æ¥ç¶ããå¿ èŠããããšå¿çããŸãããŠãŒã¶ãŒã¯æ¥ç¶ããŠããŸãã æããã«ãã¡ã€ã³ãµãŒããŒãåæ¢ãããšããŠãŒã¶ãŒã¯æ°ããããŒãã«ã¢ã¯ã»ã¹ã§ããªããªããŸãã
ããã§ã¯ããªãããŒããéããŠããããç¥ã£ãŠãããµãŒããŒãå¿ èŠãªã®ã§ããããïŒ åäžã®æ±ºå®ãã€ã³ããããããã«ã ãµãŒããŒã«äœããã®åé¡ãçºçããå Žåãã¬ãžã¹ããªããããŒããåé€ããããå¥ã®å Žæã§å床éãããã«ãããŒããå®éã«äœ¿çšå¯èœãã©ãããç解ããå¿ èŠããããŸãã è€æ°ã®ãµãŒããŒãåæ§ã®åé¡ã解決ããå Žåãã¯ã©ãŒã©ã ã®å©ããåããŠãããç·šæããããšã¯å¯èœã§ããããã®æç¹ã§ã¯ã¯ã©ãŒã©ã ãç¬ç«ããŠå®è£ ããç¥èããããŸããã§ããã
Hazelcastã«åãæ¿ãã
äœããã®æ¹æ³ã§ãçºçããåé¡ã«å¯ŸåŠããŸããããããã¯æãçŸããæ¹æ³ã§ã¯ãªããããããŸããã 次ã«ãããããæ£ãã解決ããæ¹æ³ãç解ããå¿ èŠããã£ããããæ°ããã¯ã©ã¹ã¿ãŒãœãªã¥ãŒã·ã§ã³ã®èŠä»¶ã®ãªã¹ããäœæããŸããã
- ãã¹ãŠã®ãµãŒããŒãšãã®åœ¹å²ã®ã¹ããŒã¿ã¹ãç£èŠãããã®ãå¿ èŠã§ãã ããããµãŒãã¹ãã£ã¹ã«ããªãŒãšåŒã³ãŸãã
- å±éºãªã¯ãšãªãå®è¡ãããšãã«äžè²«æ§ã確ä¿ããã®ã«åœ¹ç«ã€ã¯ã©ã¹ã¿ãŒããã¯ãå¿ èŠã§ãã
- ããŒããç¹å®ã®ãµãŒããŒäžã«ããããšã確èªããäœãåé¡ãçºçããå Žåã«éç¥ããåæ£ããŒã¿æ§é ãå¿ èŠã§ãã
2015幎ã§ããã Hazelcast-RAMã«æ å ±ãä¿åããããã®ã¯ã©ã¹ã¿ãŒã·ã¹ãã ã§ããIn-Memory Data GridãéžæããŸããã 次ã«ãå¥è·¡çãªãœãªã¥ãŒã·ã§ã³ãã¯ã©ã¹ã¿ãŒã€ã³ã¿ã©ã¯ã·ã§ã³ã®äžçã®èæ¯ããã¹ãŠãå®è¡ã§ããåæ£ããŒã¿æ§é ãããã¯ãRPCã¡ãã»ãŒãžãããã³ãã¥ãŒãçµåããå¥è·¡ã®ãã¬ãŒã ã¯ãŒã¯ãèŠã€ãããšèããŸããã
ActiveMQãšåæ§ã«ãã»ãŒãã¹ãŠãHazelcastã«è»¢éããŸããã
- ExecutorServiceãä»ãããŠãŒã¶ãŒãªãœãŒã¹ã®çæã
- æš©å©ãå€æŽããããšãã®åæ£ããã¯ã
- ãµãŒããŒã®åœ¹å²ãšå±æ§ïŒãµãŒãã¹æ€åºïŒ;
- ãªãŒãã³ããŒããªã©ã®åäžã®ã¬ãžã¹ããª
Hazelcastã®ããããžãŒ
Hazelcastã¯2ã€ã®ããããžã§æ§æã§ããŸãã æåã®ãªãã·ã§ã³ã¯ãã¯ã©ã€ã¢ã³ããµãŒããŒã§ããã¡ã³ããŒãã¡ã€ã³ã¢ããªã±ãŒã·ã§ã³ãšã¯å¥ã«é 眮ãããã¡ã³ããŒèªäœãã¯ã©ã¹ã¿ãŒã圢æãããã¹ãŠã®ã¢ããªã±ãŒã·ã§ã³ãããŒã¿ããŒã¹ãšããŠãããã«æ¥ç¶ããŸãã
Hazelcastã¡ã³ããŒãã¢ããªã±ãŒã·ã§ã³èªäœã«åã蟌ãŸããŠããå Žåã2çªç®ã®ããããžã¯Embeddedã§ãã ãã®å ŽåãããŒã¿ãšããžãã¹ããžãã¯èªäœãåãå Žæã«ããããã䜿çšã§ããã€ã³ã¹ã¿ã³ã¹ãå°ãªããªããããŒã¿ã¢ã¯ã»ã¹ãé«éã«ãªããŸãã
2çªç®ã®ãœãªã¥ãŒã·ã§ã³ãéžæããã®ã¯ãããå¹æçã§çµæžçã«å®è£ ã§ãããšèããããã§ãã HazelcastããŒã¿ãžã®ã¢ã¯ã»ã¹é床ãé ããªããããå¹æçã§ãã ããããããã®ããŒã¿ã¯çŸåšã®ãµãŒããŒäžã«ãããŸãã çµæžçãè¿œå ã®ã€ã³ã¹ã¿ã³ã¹ã«ãéãè²»ããå¿ èŠããªãããã
ã¡ã³ããŒããã³ã°ãããšã¯ã©ã¹ã¿ãŒããã³ã°ãã
Hazelcastããªã³ã«ããŠæ°é±éåŸãåé¡ã補åã«çŸããŸããã
æåã«ããµãŒããŒã®1ã€ãã¡ã¢ãªãåŸã ã«éè² è·ã«ãå§ããããšãç£èŠã瀺ããŸããã ãã®ãµãŒããŒãç£èŠããŠããéã«ãæ®ãã®ãµãŒããŒãããŒããéå§ããŸãããCPUãRAMããããŠ5ååŸã«ãã¹ãŠã®ãµãŒããŒã䜿çšå¯èœãªã¡ã¢ãªããã¹ãŠäœ¿çšããŸããã
ã³ã³ãœãŒã«ã®ãã®æç¹ã§ã次ã®ã¡ãã»ãŒãžã衚瀺ãããŸããã
2015-07-15 15:35:51,466 [WARN] (cached18) com.hazelcast.spi.impl.operationservice.impl.Invocation: [my.host.address.com]:5701 [dev] [3.5] Asking ifoperation execution has been started: com.hazelcast.spi.impl.operationservice.impl.IsStillRunningService$InvokeIsStillRunningOperationRunnable@6d4274d7 2015-07-15 15:35:51,467 [WARN] (hz._hzInstance_1_dev.async.thread-3) com.hazelcast.spi.impl.operationservice.impl.Invocation:[my.host.address.com]:5701 [dev] [3.5] 'is-executing': true -> Invocation{ serviceName='hz:impl:executorService', op=com.hazelcast.executor.impl.operations.MemberCallableTaskOperation{serviceName='null', partitionId=-1, callId=18062, invocationTime=1436974430783, waitTimeout=-1,callTimeout=60000}, partitionId=-1, replicaIndex=0, tryCount=250, tryPauseMillis=500, invokeCount=1, callTimeout=60000,target=Address[my.host2.address.com]:5701, backupsExpected=0, backupsCompleted=0}
ããã§ãHazelcastã¯ãæåã®ãæ»ã«ãããŠããããµãŒããŒã«éä¿¡ãããæäœãé²è¡äžãã©ããã確èªããŸãã Hazelcastã¯ææ°ã®ç¶æ ãç¶æããããšãã1ç§éã«æ°åæäœã®ã¹ããŒã¿ã¹ã確èªããŸããã ãã®çµæã圌ã¯ãã®æäœã§ä»ã®ãã¹ãŠã®ãµãŒããŒãã¹ãã ããæ°ååŸã«ããããã¡ã¢ãªããé£ã³åºããåãµãŒããŒããæ°GBã®ãã°ãåéããŸããã
ãã®ç¶æ³ã¯æ°åç¹°ãè¿ãããŸããã ããã¯ããªã¯ãšã¹ãã®ã¹ããŒã¿ã¹ããã§ãã¯ããããŒãããŒãã¡ã«ããºã ãå®è£ ãããHazelcastããŒãžã§ã³3.5ã®ãã°ã§ããããšãå€æããŸããã ééããå¢çã±ãŒã¹ã®äžéšã¯ãã§ãã¯ããŸããã§ããã ãããã®ã±ãŒã¹ã«é¥ããªãããã«ã¢ããªã±ãŒã·ã§ã³ãæé©åããå¿ èŠããããæ°é±éåŸã«Hazelcastã¯èªå® ã§ãšã©ãŒãä¿®æ£ããŸããã
Hazelcastã«é »ç¹ã«ã¡ã³ããŒãè¿œå ããã³åé€ãã
次ã«çºèŠããåé¡ã¯ãHazelcastã®ã¡ã³ããŒã®è¿œå ãšåé€ã§ãã
æåã«ãHazelcastãããŒãã£ã·ã§ã³ã§ã©ã®ããã«æ©èœããããç°¡åã«èª¬æããŸãã ããšãã°ã4ã€ã®ãµãŒããŒããããåãµãŒããŒã«ã¯ããŒã¿ã®äžéšãæ ŒçŽãããŠããŸãïŒå³ã§ã¯ãè²ãç°ãªã£ãŠããŸãïŒã ãŠãããã¯ãã©ã€ããªããŒãã£ã·ã§ã³ããã¥ãŒã¹ã¯ã»ã«ã³ããªããŒãã£ã·ã§ã³ãã€ãŸã ã¡ã€ã³ããŒãã£ã·ã§ã³ã®ããã¯ã¢ããã
ãµãŒããŒã®é»æºããªãã«ãªããšãããŒãã£ã·ã§ã³ã¯ä»ã®ãµãŒããŒã«éä¿¡ãããŸãã ãµãŒããŒãåæ¢ããå ŽåãããŒãã£ã·ã§ã³ã¯ããããã§ã¯ãªãããŸã çããŠããããããã®ããŒãã£ã·ã§ã³ã®ããã¯ã¢ãããä¿æããŠãããµãŒããŒãã転éãããŸãã
ããã¯ä¿¡é Œã§ããã¡ã«ããºã ã§ãã åé¡ã¯ãè² è·ã®ãã©ã³ã¹ããšãããã«ãµãŒããŒã®é»æºãå ¥ãããåã£ããããããšãå€ããããŒãã£ã·ã§ã³ã®å調æŽã«ãæéããããããšã§ãã ãããŠãããå€ãã®ãµãŒããŒãå®è¡ãããHazelcastã«ä¿åãããããŒã¿ãå¢ããã»ã©ãããŒãã£ã·ã§ã³ã®åãã©ã³ã¹ã«æéãããããŸãã
ãã¡ãããããã¯ã¢ããã®æ°ãæžããããšãã§ããŸãã äºæ¬¡ããŒãã£ã·ã§ã³ã ããããããã¯å®å šã§ã¯ãããŸãããäœããééããªã倱æããããã§ãã
å¥ã®è§£æ±ºçã¯ããµãŒããŒã®ãªã³ãšãªããã³ã¢Hazelcastã¯ã©ã¹ã¿ãŒã«åœ±é¿ããªãããã«ãã¯ã©ã€ã¢ã³ããµãŒããŒããããžã«åãæ¿ããããšã§ãã ãããè©Šã¿ãŸããããRPCèŠæ±ãã¯ã©ã€ã¢ã³ãã§å®è¡ã§ããªãããšãå€æããŸããã çç±ãèŠãŠã¿ãŸãããã
ãããè¡ãã«ã¯ã1ã€ã®RPCèŠæ±ãå¥ã®ãµãŒããŒã«éä¿¡ããäŸãèããŠãã ããã ExecutorServiceã䜿çšãããšãRPCã¡ãã»ãŒãžãéä¿¡ããæ°ããã¿ã¹ã¯ã§éä¿¡ã§ããŸãã
hazelcastInstance .getExecutorService(...) .submit(new Task(), ...);
ã¿ã¹ã¯èªäœã¯ãCallableãå®è£ ããéåžžã®Javaã¯ã©ã¹ã®ããã«èŠããŸãã
public class Task implements Callable<Long> { @Override public Long call() { return 42; } }
åé¡ã¯ãHazelcastã¯ã©ã€ã¢ã³ããJavaã¢ããªã±ãŒã·ã§ã³ã ãã§ãªããC ++ã¢ããªã±ãŒã·ã§ã³ã.NETãªã©ã«ããªãåŸãããšã§ãã åœç¶ãJavaã¯ã©ã¹ãçæããŠå¥ã®ãã©ãããã©ãŒã ã«å€æããããšã¯ã§ããŸããã
1ã€ã®ãªãã·ã§ã³ã¯ããããµãŒããŒããå¥ã®ãµãŒããŒã«äœããéä¿¡ããŠåçãåŸããå Žåã«ãhttp-requestsã®äœ¿çšã«åãæ¿ããããšã§ãã ãããããã®åŸãHazelcastãéšåçã«æŸæ£ããå¿ èŠããããŸãã
ãããã£ãŠã解決çãšããŠãExecutorServiceã®ä»£ããã«ãã¥ãŒã䜿çšããããšãéžæããŸããã ãããè¡ãããã«ããã¥ãŒå ã®èŠçŽ ãåŠçãããã®ãåŸ æ©ããã¡ã«ããºã ãç¬èªã«å®è£ ããŸãããã®ã¡ã«ããºã ã¯ãå¢çã±ãŒã¹ãåŠçããçµæãèŠæ±å ãµãŒããŒã«è¿ããŸãã
ç§ãã¡ãåŠãã ããš
ã·ã¹ãã ã«æè»æ§ã眮ããŸãã æªæ¥ã¯åžžã«å€åããŠãããããå®ç§ãªãœãªã¥ãŒã·ã§ã³ã¯ãããŸããã æ£ãããæ£ãããæ©èœããããã§ã¯ãããŸããããæè»ã«ã·ã¹ãã ã«çµã¿èŸŒãããšã¯ã§ããŸãã ããã«ãããéèŠãªã¢ãŒããã¯ãã£äžã®æ±ºå®ãåãå ¥ããããšãäžå¯èœã«ãªããŸã§å»¶æããããšãã§ããŸããã
Clean Architectureã®Robert Martinã¯ããã®ååã«ã€ããŠæ¬¡ã®ããã«æžããŠããŸãã
ãã¢ãŒããã¯ãã®ç®æšã¯ãæ¿æ²»ãæãéèŠãªèŠçŽ ãšããã·ã¹ãã ã®ãã©ãŒã ãšãæ¿æ²»çã§ãªã詳现ãäœæããããšã§ãã ããã«ããã詳现ã«é¢ãã決å®ãé ãããé ãããããŸãã
æ®éçãªããŒã«ãšãœãªã¥ãŒã·ã§ã³ã¯ååšããŸããã äœããã®ãã¬ãŒã ã¯ãŒã¯ããã¹ãŠã®åé¡ã解決ããŠããããã«æããå Žåãããããããã§ã¯ãããŸããã ãããã£ãŠããã¬ãŒã ã¯ãŒã¯ãå®è£ ãããšãã¯ãã©ã®åé¡ã解決ãããã ãã§ãªããã©ã®åé¡ãããããã®ããç解ããããšãéèŠã§ãã
ããã«ãã¹ãŠãæžãæããªãã§ãã ããã ã¢ãŒããã¯ãã£ã®åé¡ã«çŽé¢ããŠããŠããã¹ãŠããŒãããæžãããšãå¯äžã®æ£ãã解決çã§ãããšæãããå Žåã¯ãåŸ ã£ãŠãã ããã åé¡ãæ¬åœã«æ·±å»ãªå Žåã¯ãç°¡åãªä¿®æ£ãèŠã€ããŠãã·ã¹ãã ãå°æ¥ã©ã®ããã«æ©èœãããã確èªããŠãã ããã ã»ãšãã©ã®å Žåããããã¢ãŒããã¯ãã£ã®å¯äžã®åé¡ã§ã¯ãªããæéã®çµéãšãšãã«ããã«èŠã€ããã§ãããã ãããŠãååãªæ°ã®åé¡é åãããã¯ã¢ããããå Žåã«ã®ã¿ããªãã¡ã¯ã¿ãªã³ã°ãéå§ã§ããŸãã ãã®å Žåã«ã®ã¿ããã®å€ãããå€ãã®å©ç¹ããããŸãã