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. ISAPI_Rewrite不起作用的N种原因

    现在经常用到ISAPI_Rewrite,遇到的问题就是在本地测试的时候,一切没有问题,到服务器上,竟然不起作用.郁闷~经过我的一些探索,发现了比起作用的原因如下:1.IIS_WPG对ISAPI_Rew ...

  2. Windows 8实例教程系列 - 理解应用框架

    原文:Windows 8实例教程系列 - 理解应用框架 Windows 操作系统之所以风靡世界,是因为其“易学易用”,从用户的角度出发,让数以万计的非IT人员使用计算机实现娱乐,工作等目的.Windo ...

  3. 最小二乘法 (转)good

    最小二乘法也称为最小平方法,是一种数据优化技术,它通过最小化误差的平方和寻找数据的最佳函数匹配. 最小二乘法最初由高尔顿在创立回归分析的时候提出,现在已经成为探索变量间关系最重要的方法,最小二乘法根据 ...

  4. JCombox

    A component that combines a button or editable field and a drop-down list. The user can select a val ...

  5. jQuery 完成ajax传jsonObject数据,并在后台处理

    效果图: 1.js文件封装的几个js工具 <span style="font-family:KaiTi_GB2312;font-size:18px;">//兼容ie i ...

  6. openSUSE 国内镜像摘要

    1. 北交(BJTU): http://mirror.bjtu.edu.cn/opensuse http://mirror.bjtu.edu.cn/packman/suse 2. 华中科大(HUST) ...

  7. 读书时间《JavaScript高级程序设计》三:函数,闭包,作用域

    上一次看了第6章,面向对象.这里接着看第7章. 第7章:函数表达式 定义函数有两种方式:函数声明.函数表达式 //函数声明 function functionName(arg0,arg1,arg2){ ...

  8. 【原创】构建高性能ASP.NET站点 第七章 如何解决内存的问题(前中篇)—托管资源优化—监测CLR性能

    原文:[原创]构建高性能ASP.NET站点 第七章 如何解决内存的问题(前中篇)-托管资源优化-监测CLR性能 构建高性能ASP.NET站点 第七章 如何解决内存的问题(前中篇)—托管资源优化—监测C ...

  9. object-c计划tips-添加到类对象属性

    这个问题从网络包的内容,由于保密问题,我刚才所描述我的业余的想法. 基本的想法: 网络请求,我们应该能够使用基类BaseNetWork, 然后由派生类继承BaseNetWork,并实现一些特殊的方法. ...

  10. IOS 多于UIImageView 当加载较大的高清闪存管理

    当我们是一家人View  多于UIImageView,和UIImageView表明一个更大的HD,可能存在的存储器的警告的问题.假设第一次走进这个view,无记忆出现预警.当重新进入view,在那曾经 ...