赞
踩
本系列以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方法的第一段代码(用于判断并处理启动或停止命令)。代码中加入少量注释,便于理解:
- String level = System.getProperty("benchmark.level", "warn");
- System.setProperty("benchmark.level", level);
- if(args.length>=1){
- ShutdownClient client = new ShutdownClient(MonitorConstant.APPLICATION_NAME);
- MonitorCommandPacket packet = new MonitorCommandPacket(); //监控命令报文对象
- //通过第一个命令行参数进行处理判断
- if("start".equalsIgnoreCase(args[0])){
- //处理启动amoeba命令
- packet.funType = MonitorCommandPacket.FUN_TYPE_PING;
- if(client.run(packet)){
- //如果已经启动,则提示amoeba server启动信息,并异常退出
- System.out.println("amoeba server is running with port="+client.getPort());
- System.exit(-1);
- }
- }else{
- //处理停止amoeba命令
- packet.funType = Mo
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。