当前位置: 代码迷 >> 人工智能 >> CshBBrainPP 装配、配置、运行和测试文档
  详细解决方案

CshBBrainPP 装配、配置、运行和测试文档

热度:6780   发布时间:2013-02-26 00:00:00.0
CshBBrainPP 安装、配置、运行和测试文档

CshBBrainPP 安装配置运行和测试

1.项目的安装

从http://code.google.com/p/cshbbrainpp/downloads/list下载源代码包,解压。从Eclipse 导入项目。 在Eclipse编译项目没有错误提示即成功(项目编译要求jdk1.6及以上版本)。

?

2.项目的配置

2.1项目系统参数配置

项目参数文件位置:src/com/jason/config.properties

项目系统参数列表:

#the port of the server

#服务器所使用的端口

port=8080

?

#the priority of the thread in pool

#服务器工作线程的优先级,使用默认优先级即可

maxPriority=5

?

#the tmp folder

#图片服务器存放图片的根目录

serverRoot=e:/tmp/

?

#the factor of the work process thread per CPU kernel

#业务处理线程CPU内核因子,例如设置为5则表示每个CPU核将创建5个处理线程,如果你的服务器有4个内核,那么将创建5*4=20个处理线程

requestWorker=5

?

#the factor of the read writer monitor thread per CPU kernel

#网络数据读写监听线程CPU内核因子,例如设置为1则表示系统将为每个内核创建1个数据读写监听线程,你可以根据自己服务器的性能和需要配置2,4,8个读写监听线程每内核;设置将更加灵活

monitorWorker=1

?

#the buffer size of the read buffer,unit is KB

#网络数据读取缓存大小,单位是KB

readBuffer=5

?

#the buffer size of the write buffer,unit is KB

#网络数据发送缓存大小,单位是KB

writeBuffer=64

?

#the send buffer size of the system sockect

#系统相关的Sockect数据发送缓冲区大小,单位KB

sockectSendBufferSize=64

?

#the receive buffer of the system socket

#系统相关的Sockect数据接收缓冲区大小,单位KB

sockectReceiveBufferSize=5

?

#wheather the connection keep alive,1:keep alive,0:not keep alive

#设置服务器处理的连接是长连接,还是端连接,websocket服务器默认为长连接,不可更改

keepConnect=1

?

#the count of blank read

#设置服务器端空读多少次之后放弃读取客户端的数据

zoreFetchCount = 10

?

#the min size and the max size of the buffer pool?

#设置缓冲区池的最大值和最小值

minBufferPoolSize=1000

maxBufferPoolSize=1000

?

#whether open the broadcast thread

#设置系统是否开启广播线程

broadSwitch=0

?

?

2.2系统日志配置

系统日志文件位置:src/log4j.properties

日志的配置请按照标准的log4j日志进行配置即可

?

3.项目运行

找到src/com/jason/server/ws/Server.java文件,作为application运行即可启动程序。

服务器启动成功后,默认会输出如下日志:

2013-2-5 11:23:46 com.jason.server.MasterServer$ReadWriteMonitor <init>

信息: 数据读取回写监听线程创建成功:请求数据传输监听线程0

2013-2-5 11:23:46 com.jason.server.MasterServer$ReadWriteMonitor createProcessDistributer

信息: 请求处理调度线程创建完毕

2013-2-5 11:23:46 com.jason.server.MasterServer$ReadWriteMonitor <init>

信息: 数据读取回写监听线程创建成功:请求数据传输监听线程1

2013-2-5 11:23:46 com.jason.server.MasterServer$ReadWriteMonitor createProcessDistributer

信息: 请求处理调度线程创建完毕

2013-2-5 11:23:46 com.jason.server.MasterServer createConnectDistributeThread

信息: 连接监听线程创建成功

2013-2-5 11:23:46 com.jason.server.MasterServer startMonitor

信息: 服务器准备就绪,等待请求到来

?

4.项目测试

找到项目下的图片目录下的图片文件,在浏览器中输入访问地址,比如服务器ip为192.168.1.220,端口为8080,图片目录下有一张图片名为/20130124102202.jpg.在浏览器输入:http://192.168.1.220:8080/20130124102202.jpg回车,即可看到浏览器中显示图片了。在服务器的后台输出你看到如下信息表示请求处理成功:

访问URL2013-02-05 11:25:08:GET /20130124102202.jpg HTTP/1.1

Host: 192.168.1.220:8080

Connection: keep-alive

Cache-Control: no-cache

Pragma: no-cache

User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Encoding: gzip,deflate,sdch

Accept-Language: zh-CN,zh;q=0.8

Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3

?

?

2013-2-5 11:25:09 com.jason.server.Response write

信息: the postion of the data in write: 0

2013-2-5 11:25:09 com.jason.server.Response write

信息: translate size:448127

2013-2-5 11:25:09 com.jason.server.Response write

信息: 向客户端传输数据的长度 : 448127

?

好了,你现在就可以通过CshBBrainPP来访问你的图片了。