当前位置:   article > 正文

amoeba源码分析(一)-AmoebaProxyServer入口类分析_amoeba源码包

amoeba源码包

本系列以Amoeba 997版本分支源码(目前最新版本分支)作为分析源,amoeba源码SVN地址:http://amoeba.googlecode.com/svn/trunk。在分析源码前,需要将源码导入到Eclipse工程里面。amoeba共分为amoeba、amoeba-mysql、amoeba-memcached、amoeba-aladdin、amoeba-mongodb、amoeba-manager、amoeba-geteway七个子工程。本系列主要分析amoeba、amoeba-mysql源码,其他子工程会根据需要分析说明

 

AmoebaProxyServer作为Amoeba的入口类存在于amoeba子工程的com.meidusa.amoeba.server包下。AmoebaProxyServer的main方法提供了完整的启动流程和方法。

AmoebaProxyServer提供了两个日志记录对象,一个用于基本的日志记录,一个用于对报告进行日志记录。

1  首先来看main方法的第一段代码(用于判断并处理启动或停止命令)。代码中加入少量注释,便于理解:

  1. String level = System.getProperty("benchmark.level", "warn");
  2. System.setProperty("benchmark.level", level);
  3. if(args.length>=1){
  4. ShutdownClient client = new ShutdownClient(MonitorConstant.APPLICATION_NAME);
  5. MonitorCommandPacket packet = new MonitorCommandPacket(); //监控命令报文对象
  6. //通过第一个命令行参数进行处理判断
  7. if("start".equalsIgnoreCase(args[0])){
  8. //处理启动amoeba命令
  9. packet.funType = MonitorCommandPacket.FUN_TYPE_PING;
  10. if(client.run(packet)){
  11. //如果已经启动,则提示amoeba server启动信息,并异常退出
  12. System.out.println("amoeba server is running with port="+client.getPort());
  13. System.exit(-1);
  14. }
  15. }else{
  16. //处理停止amoeba命令
  17. packet.funType = Mo
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/191971
推荐阅读
相关标签
  

闽ICP备14008679号