Gaea是支持跨平台具有高并发、高性能、高可靠性,并提供异步、多协议、事件驱动的中间层服务框架

Gaea:58同城开源的中间层服务框架 https://github.com/58code/Gaea

中间件

Gaea是支持跨平台具有高并发、高性能、高可靠性,并提供异步、多协议、事件驱动的中间层服务框架。相对于其它重量级的中间件,比如淘宝的dubbo,Gaea只做一件事,因此没有过多的项目依赖。

在学校的时候学过CORBA,因此对中间件有所了解。在CORBA中,接口通过IDL描述,然后分别生成本地存根(stub)和服务器端骨架(skeleton)。服务器端对这些接口进行实现,当客户端调用时,本地将调用的相关信息(方法、参数)通过消息发送到服务器端,服务器端执行完后返回结果。

Gaea也提供了同样的服务。在公司内部,各个系统之间可能需要相互调用,通过Gaea对外提供服务实现跨平台,跨语言调用。

部署服务器端

Gaea提供了一个demo(Gaea/demo目录下),客户端虽然提供了一个gaeaDemo.jar,但实际上只需要里面的INewsService.java以及News.java。

部署服务端时使用的目录结构参照gaea.tar.gz,服务是放在service目录下,service/deploy/{serviceName} 放配置文件,serveice/lib放依赖的jar包。

[root@localhost gaea]# pwd
/opt/test/gaea
[root@localhost gaea]# ls -l
总计 36
drwxr-xr-x 2 root root 4096 2012-09-10 bin
drwxr-xr-x 2 root root 4096 2012-09-10 conf
-rw-r--r-- 1 root root   52 2012-09-10 COPYRIGHT
drwxr-xr-x 2 root root 4096 2012-09-10 docs
drwxr-xr-x 2 root root 4096 2012-09-10 lib
drwxr-xr-x 2 root root 4096 2012-09-10 log
-rw-r--r-- 1 root root  247 2012-09-10 README
drwxr-xr-x 4 root root 4096 2012-09-10 service
drwxr-xr-x 3 root root 4096 2012-09-10 tmp

如果需要修改服务器的监听端口,修改service/deploy/{serviceName}/gaea_config.xml

<!-- socket server listent port -->
<property>
<name>gaea.server.tcp.listenPort</name>
<value>9090</value>
</property>

启动时执行startup.sh,参数参考demo_run.sh

[root@localhost bin]# pwd
/opt/test/gaea/bin
[root@localhost bin]# ls -l
总计 20
-rw-r--r-- 1 root root  164 2012-08-16 demo_run.sh
-rw-r--r-- 1 root root 2065 2012-09-04 restart.sh
-rw-r--r-- 1 root root    0 2010-12-28 shutdown.bat
-rw-r--r-- 1 root root  809 2012-08-16 shutdown.sh
-rw-r--r-- 1 root root 2115 2012-09-07 startup.bat
-rwxr-xr-x 1 root root 2967 2012-08-16 startup.sh
[root@localhost bin]# chmod +x demo_run.sh 
[root@localhost bin]# ./demo_run.sh

no GAEA_HOME path
pid:6118
[root@localhost bin]# [06-21 16:03:41,073 INFO ] [main] bootstrap.Main - +++++++++++++++++++++ staring +++++++++++++++++++++

[06-21 16:03:41,074 INFO ] [main] bootstrap.Main - user.dir: /opt/test/gaea/bin
[06-21 16:03:41,074 INFO ] [main] bootstrap.Main - rootPath: /opt/test/gaea/bin/../
[06-21 16:03:41,074 INFO ] [main] bootstrap.Main - service gaea_config.xml: /opt/test/gaea/bin/../service/deploy/demo/gaea_config.xml
[06-21 16:03:41,074 INFO ] [main] bootstrap.Main - default gaea_config.xml: /opt/test/gaea/bin/../conf/gaea_config.xml
[06-21 16:03:41,075 INFO ] [main] bootstrap.Main - service gaea_log4j.xml: /opt/test/gaea/bin/../service/deploy/demo/gaea_log4j.xml
[06-21 16:03:41,075 INFO ] [main] bootstrap.Main - default gaea_log4j.xml: /opt/test/gaea/bin/../conf/gaea_log4j.xml
[06-21 16:03:41,075 INFO ] [main] bootstrap.Main - load service config...
[06-21 16:03:41,328 INFO ] [main] bootstrap.Main - gaea.service.name: demo
[06-21 16:03:41,329 INFO ] [main] bootstrap.Main - -----------------loading global jars------------------
[06-21 16:03:41,337 INFO ] [main] hotdeploy.GlobalClassLoader - append jar to classpath:file:/opt/test/gaea/service/deploy/demo/demo.jar
[06-21 16:03:41,337 INFO ] [main] hotdeploy.GlobalClassLoader - append jar to classpath:file:/opt/test/gaea/service/lib/antlr-runtime-3.3.jar

[06-21 16:03:41,344 INFO ] [main] bootstrap.Main - -------------------------end-------------------------

[06-21 16:03:41,345 INFO ] [main] bootstrap.Main - --------------------loading proxys-------------------
[06-21 16:03:41,348 INFO ] [main] bytecode.ScanClass - begin scan jar from path:/opt/test/gaea/bin/../service/deploy/demo/
[06-21 16:03:41,435 INFO ] [main] bytecode.ScanClass - finish scan jar
[06-21 16:03:41,437 INFO ] [main] bytecode.ProxyClassCreater - loading dynamic proxy v1...
[06-21 16:03:41,437 INFO ] [main] bytecode.ProxyClassCreater - loading => NewsServiceProxyStub1371801821435
[06-21 16:03:41,437 INFO ] [main] bytecode.ProxyClassCreater - class name:components.NewsService
[06-21 16:03:41,491 DEBUG] [main] bytecode.ProxyClassCreater - create method:getNewsByID
[06-21 16:03:41,545 DEBUG] [main] bytecode.ProxyClassCreater - create method:getNewsByCateID
[06-21 16:03:41,572 INFO ] [main] bytecode.ProxyClassCreater - load dynamic proxy success!!!
[06-21 16:03:41,572 INFO ] [main] bytecode.CreateManager - proxy class buffer creater finish!!!
[06-21 16:03:41,573 INFO ] [main] bytecode.ProxyFactoryCreater - begin create ProxyFactory:ProxyFactory1371801821435
[06-21 16:03:41,578 DEBUG] [main] bytecode.ProxyFactoryCreater - ProxyFactory source code:public com.bj58.spat.gaea.server.contract.context.IProxyStub getProxy(String lookup) {if(lookup.equalsIgnoreCase("NewsService")){return proxyNewsServicedemo;}return null;}}
[06-21 16:03:41,579 INFO ] [main] bytecode.ProxyFactoryCreater - create ProxyFactory success!!!
[06-21 16:03:41,580 INFO ] [main] bytecode.CreateManager - proxy factory buffer creater finish!!!
[06-21 16:03:41,581 INFO ] [main] bytecode.CreateManager - dynamic load class:NewsServiceProxyStub1371801821435
[06-21 16:03:41,582 INFO ] [main] bytecode.CreateManager - crate ProxyFactory instance!!!
[06-21 16:03:41,582 INFO ] [main] bootstrap.Main - -------------------------end-------------------------

[06-21 16:03:41,582 INFO ] [main] bootstrap.Main - -----------------loading init beans------------------
[06-21 16:03:41,582 INFO ] [main] bootstrap.Main - load: com.bj58.spat.gaea.server.contract.context.SerializerClassInit
[06-21 16:03:41,588 INFO ] [main] log.SystemPrintStream - Scan jar files begin!
[06-21 16:03:41,589 ERROR] [main] log.SystemPrintStream - 开始扫描全部引用jar包,如果扫描过程过长请在启动vm参数中设置gaea.serializer.basepakage或者设置gaea.serializer.scantype=asyn使用异步模式扫描。
[06-21 16:03:41,590 INFO ] [main] log.SystemPrintStream - scanByURLClassLoader:/opt/test/gaea/bin/
[06-21 16:03:41,591 INFO ] [main] log.SystemPrintStream - scanByURLClassLoader:/opt/jdk1.6.0_16/lib/tools.jar
[06-21 16:03:42,964 INFO ] [main] log.SystemPrintStream - scanByURLClassLoader:/opt/test/gaea/lib/antlrall-2.7.2.jar
[06-21 16:03:43,100 INFO ] [main] log.SystemPrintStream - scanByURLClassLoader:/opt/test/gaea/lib/com.bj58.spat.gaea.protocol-1.0.0.jar
[06-21 16:03:43,111 INFO ] [main] log.SystemPrintStream - scanByURLClassLoader:/opt/test/gaea/lib/com.bj58.spat.gaea.serializer-1.0.0.jar
[06-21 16:03:43,131 INFO ] [main] log.SystemPrintStream - scanByURLClassLoader:/opt/test/gaea/lib/com.bj58.spat.gaea.server-1.0.0.jar

[06-21 16:03:46,197 INFO ] [main] log.SystemPrintStream - scaning com.bj58.enterprise.entity.com.bj58.enterprise.entity.Enterprise
[06-21 16:03:46,197 INFO ] [main] log.SystemPrintStream - scaning com.bj58.enterprise.entity.com.bj58.enterprise.entity.SESUser
[06-21 16:03:46,198 INFO ] [main] log.SystemPrintStream - scaning com.bj58.enterprise.entity.com.bj58.enterprise.entity.User
[06-21 16:03:46,198 INFO ] [main] log.SystemPrintStream - scaning com.bj58.spat.gaea.server.core.communication.http.com.bj58.spat.gaea.server.core.communication.http.News
[06-21 16:03:46,199 INFO ] [main] log.SystemPrintStream - scaning com.bj58.spat.gaea.server.util.com.bj58.spat.gaea.server.util.News
[06-21 16:03:46,199 INFO ] [main] log.SystemPrintStream - scaning entity.entity.News
[06-21 16:03:46,199 INFO ] [main] log.SystemPrintStream - Scan jar files completed!
[06-21 16:03:46,200 INFO ] [main] bootstrap.Main - -------------------------end-------------------------

[06-21 16:03:46,200 INFO ] [main] bootstrap.Main - -----------loading global request filters------------
[06-21 16:03:46,200 INFO ] [main] bootstrap.Main - load: com.bj58.spat.gaea.server.filter.ProtocolParseFilter
[06-21 16:03:46,201 INFO ] [main] bootstrap.Main - load: com.bj58.spat.gaea.server.filter.HandclaspFilter
[06-21 16:03:46,202 INFO ] [main] bootstrap.Main - load: com.bj58.spat.gaea.server.filter.ExecuteMethodFilter
[06-21 16:03:46,203 INFO ] [main] bootstrap.Main - -------------------------end-------------------------

[06-21 16:03:46,203 INFO ] [main] bootstrap.Main - -----------loading global response filters-----------
[06-21 16:03:46,203 INFO ] [main] bootstrap.Main - load: com.bj58.spat.gaea.server.filter.ProtocolCreateFilter
[06-21 16:03:46,219 INFO ] [main] bootstrap.Main - load: com.bj58.spat.gaea.server.filter.ExecuteTimeFilter
[06-21 16:03:46,224 INFO ] [main] bootstrap.Main - -------------------------end-------------------------

[06-21 16:03:46,224 INFO ] [main] bootstrap.Main - -----------loading connection filters-----------
[06-21 16:03:46,224 INFO ] [main] bootstrap.Main - load: com.bj58.spat.gaea.server.filter.IPFilter
[06-21 16:03:46,225 INFO ] [main] bootstrap.Main - -------------------------end-------------------------

[06-21 16:03:46,225 INFO ] [main] bootstrap.Main - ------------------load secureKey start---------------------
[06-21 16:03:46,225 INFO ] [main] bootstrap.Main - ------------------load secureKey end----------------------

[06-21 16:03:46,226 INFO ] [main] bootstrap.Main - ------------------signal registr start---------------------
[06-21 16:03:46,226 INFO ] [main] bootstrap.Main - ------------------signal registr success----------------------

[06-21 16:03:46,226 INFO ] [main] bootstrap.Main - ------------------ starting servers -----------------
[06-21 16:03:46,227 INFO ] [main] bootstrap.Main - gaea.server.tcp is starting...
[06-21 16:03:46,263 INFO ] [main] tcp.SocketServer - loading invoker...
[06-21 16:03:46,300 INFO ] [main] proxy.AsyncInvokerHandle - async worker count:100
[06-21 16:03:46,300 INFO ] [main] tcp.SocketServer - initing server...
[06-21 16:03:46,300 INFO ] [main] tcp.SocketServer - -- socket server config --
[06-21 16:03:46,301 INFO ] [main] tcp.SocketServer - -- listen ip: 0.0.0.0
[06-21 16:03:46,301 INFO ] [main] tcp.SocketServer - -- port: 9090
[06-21 16:03:46,301 INFO ] [main] tcp.SocketServer - -- tcpNoDelay: true
[06-21 16:03:46,301 INFO ] [main] tcp.SocketServer - -- receiveBufferSize: 65536
[06-21 16:03:46,301 INFO ] [main] tcp.SocketServer - -- sendBufferSize: 65536
[06-21 16:03:46,302 INFO ] [main] tcp.SocketServer - -- frameMaxLength: 524288
[06-21 16:03:46,302 INFO ] [main] tcp.SocketServer - -- worker thread count: 32
[06-21 16:03:46,302 INFO ] [main] tcp.SocketServer - --------------------------
[06-21 16:03:46,302 INFO ] [main] tcp.SocketServer - demo SocketServer starting...
[06-21 16:03:46,345 INFO ] [main] bootstrap.Main - gaea.server.tcpstarted success!!!

[06-21 16:03:46,345 INFO ] [main] bootstrap.Main - gaea.server.telnet is starting...
[06-21 16:03:46,346 INFO ] [main] telnet.TelnetServer - ----------------telnet server config------------------
[06-21 16:03:46,346 INFO ] [main] telnet.TelnetServer - -- telnet server listen ip: 0.0.0.0
[06-21 16:03:46,346 INFO ] [main] telnet.TelnetServer - -- telnet server port: 7070
[06-21 16:03:46,346 INFO ] [main] telnet.TelnetServer - ------------------------------------------------------
[06-21 16:03:46,352 INFO ] [main] bootstrap.Main - gaea.server.telnetstarted success!!!

[06-21 16:03:46,352 INFO ] [main] bootstrap.Main - -------------------------end-------------------------

[06-21 16:03:46,352 INFO ] [main] bootstrap.Main - +++++++++++++++++++++ server start success!!! +++++++++++++++++++++

服务器启动完毕

客户端

启动客户端,我自己打包成了可执行文件

[root@localhost test]# java -jar client.jar 
Scan jar files begin!
开始扫描全部引用jar包,如果扫描过程过长请在启动vm参数中设置gaea.serializer.basepakage或者设置gaea.serializer.scantype=asyn使用异步模式扫描。
scanByURLClassLoader:/opt/test/client.jar
scaning com.bj58.spat.gaea.serializer.component.com.bj58.spat.gaea.serializer.component.TypeMap
scaning com.bj58.spat.gaea.serializer.component.com.bj58.spat.gaea.serializer.component.ClassScaner
scaning com.bj58.spat.gaea.serializer.component.annotation.com.bj58.spat.gaea.serializer.component.annotation.GaeaSerializable
scaning com.bj58.spat.gaea.serializer.component.exception.com.bj58.spat.gaea.serializer.component.exception.DisallowedSerializeException
scaning com.bj58.spat.gaea.serializer.serializer.com.bj58.spat.gaea.serializer.serializer.ObjectSerializer
scaning com.bj58.spat.gaea.protocol.sdp.com.bj58.spat.gaea.protocol.sdp.RequestProtocol
scaning com.bj58.spat.gaea.protocol.sdp.com.bj58.spat.gaea.protocol.sdp.ResetProtocol
scaning com.bj58.spat.gaea.protocol.sdp.com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol
scaning com.bj58.spat.gaea.protocol.sdp.com.bj58.spat.gaea.protocol.sdp.ResponseProtocol
scaning com.bj58.spat.gaea.protocol.sdp.com.bj58.spat.gaea.protocol.sdp.HandclaspProtocol
scaning com.bj58.spat.gaea.protocol.utility.com.bj58.spat.gaea.protocol.utility.KeyValuePair
scaning com.github.hailinzeng.gaea.com.github.hailinzeng.gaea.News
Scan jar files completed!
2013-6-21 17:13:04 com.bj58.spat.gaea.client.utility.logger.FileLog info
信息: Gaea Client v1.0.0:starting init servers
2013-6-21 17:13:04 com.bj58.spat.gaea.client.utility.logger.FileLog info
信息: Gaea Client v1.0.0:init servers end
2013-6-21 17:13:04 com.bj58.spat.gaea.client.utility.logger.FileLog info
信息: Gaea Client v1.0.0:MaxPakageSize:102400
2013-6-21 17:13:04 com.bj58.spat.gaea.client.utility.logger.FileLog info
信息: Gaea Client v1.0.0:SendBufferSize:8388608
2013-6-21 17:13:04 com.bj58.spat.gaea.client.utility.logger.FileLog info
信息: Gaea Client v1.0.0:RecvBufferSize:8388608
2013-6-21 17:13:04 com.bj58.spat.gaea.client.utility.logger.FileLog info
信息: Gaea Client v1.0.0:create a new connection :Socket[addr=/127.0.0.1,port=9090,localport=35459]
2013-6-21 17:13:04 com.bj58.spat.gaea.client.utility.logger.FileLog warn
警告: Gaea Client v1.0.0:method:getNewsByCateID invoke time :1010
ID is 58 title is 58同城一个神奇的网站

Gaea是支持跨平台具有高并发、高性能、高可靠性,并提供异步、多协议、事件驱动的中间层服务框架的更多相关文章

  1. PHP秒杀系统-高并发高性能的极致挑战

    慕课网实战教程后端:1.java c++算法与数据结构2.java Spring Boot带前后端 渐进式开发企业级博客系统3.java Spring Boot企业微信点餐系统4.java Sprin ...

  2. 优秀开源项目之三:高性能、高并发、高扩展性和可读性的网络服务器架构State Threads

    译文在后面. State Threads for Internet Applications Introduction State Threads is an application library ...

  3. PHP秒杀系统 高并发 高性能的极致挑战 下载

    第1章 课程介绍 秒杀系统在各种网站和应用中经常会用到.本课程从基本的系统设计和基础功能开始教导大家用PHP来设计和实现秒杀系统,并且为海量并发提供更高级的技术方案和实现手段. 第2章 系统技术选型分 ...

  4. java亿级流量电商详情页系统的大型高并发与高可用缓存架构实战视频教程

    亿级流量电商详情页系统的大型高并发与高可用缓存架构实战 完整高清含源码,需要课程的联系QQ:2608609000 1[免费观看]课程介绍以及高并发高可用复杂系统中的缓存架构有哪些东西2[免费观看]基于 ...

  5. 在高并发、高负载的情况下,如何给表添加字段并设置DEFAULT值?

    在高并发.高负载的情况下,如何给表添加字段并设置DEFAULT值? 在Oracle 12c之前,当Oracle表数据量上亿时,对表执行“ALTER TABLE XXX ADD COLUMN_XX VA ...

  6. [ 高并发]Java高并发编程系列第二篇--线程同步

    高并发,听起来高大上的一个词汇,在身处于互联网潮的社会大趋势下,高并发赋予了更多的传奇色彩.首先,我们可以看到很多招聘中,会提到有高并发项目者优先.高并发,意味着,你的前雇主,有很大的业务层面的需求, ...

  7. tcp/udp高并发和高吐吞性能测试工具

    在编写一个网络服务的时候都比较关心这个服务能达到多少并发连接,而在这连接的基础上又能达到一个怎样的交互能力.编写服务已经是一件很花力气的事情,而还要去编写一个能够体现结果的测试工具就更加消耗工作时间. ...

  8. 5.如何保证 redis 的高并发和高可用?redis 的主从复制原理能介绍一下么?redis 的哨兵原理能介绍一下么?

    作者:中华石杉 面试题 如何保证 redis 的高并发和高可用?redis 的主从复制原理能介绍一下么?redis 的哨兵原理能介绍一下么? 面试官心理分析 其实问这个问题,主要是考考你,redis ...

  9. 【Distributed】大型网站高并发和高可用

    一.DNS域名解析 二.大型网站系统应有的特点 三.网站架构演变过程 3.1 传统架构 3.2 分布式架构 3.3 SOA架构 3.4 微服务架构 四.高并发设计原则 4.1 拆分系统 4.2 服务化 ...

随机推荐

  1. SQLSERVER PRINT语句的换行

    原文:SQLSERVER PRINT语句的换行 SQLSERVER  PRINT语句的换行 想在输出的PRINT语句里面换行,可以这样做 /* SQL的换行 制表符 CHAR(9) 换行符 CHAR( ...

  2. 在python正在使用mysql

    缘由 近期在折腾一个小东西须要抓取网上的页面.然后进行解析.将结果放到数据库中. 了解到Python在这方面有优势,便选用之. 由于我有台server上面安装有mysql,自然使用之.在进行数据库的这 ...

  3. 初步STL集装箱Vector

    vector 特点: 1.可变长的动态数组 2.使用时包括头文件 #include <vector> 3.支持随机訪问迭代器 • 依据下标随机訪问某个元素时间为常数 • 在尾部加入速度非常 ...

  4. Base64编码和解码

    Base64这是一个二进制编码方法转换成可打印字符.主要用于邮件传输. Base64将64人物(A-Z,a-z,0-9,+,/)由于基本字符集.把所有的符号转换成字符集. 编码: 编码每次3节转为4字 ...

  5. 【ASP.NET】关于iframe的两个技巧

    原文:[ASP.NET]关于iframe的两个技巧 最近在给朋友写个网站,虽然不大,但是也碰到了一些问题.这篇就为解决ASP.NET中关于IFRAME的两个很现实的问题提供解决方法.PS:呵呵,又做了 ...

  6. 采用curl库

    Windows通过使用curl库: 到http://curl.haxx.se/下了个curl的源代码下来,源代码是用VC6编译的,我在VS2005下又一次进行编译.竟然仅仅有一个警告. cUrl的实现 ...

  7. Java 输出指定编码的字符串

    Java Sting类有个根据byte,字符编码来输出的构造函数.以下为java文档中的解释.public String(byte[] bytes, String charsetName) throw ...

  8. UVA 257 - Palinwords(弦HASH)

    UVA 257 - Palinwords 题目链接 题意:输出一个文本里面的palinword,palinword的定义为.包括两个不同的回文子串,而且要求回文子串不能互相包括 思路:对于每一个单词推 ...

  9. Android - 建设项目的版本号

    建设项目的版本号 本文地址: http://blog.csdn.net/caroline_wendy 依据SVN中的项目, 构建本地版本号, 进行开发, 构建方式是: 1. "svn co& ...

  10. Leetcode 动态规划 Candy

    本文senlie原版的,转载请保留此地址:http://blog.csdn.net/zhengsenlie Candy Total Accepted: 16494 Total Submissions: ...