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. grep在一个特定的文件搜索文件夹keyword

    grep -R --include="*.*"(文件名匹配)  key(keyword) dir(夹) eg.在当前文件夹搜索xml关键文件172.19.32.22 grep -R ...

  2. poj 2762 Going from u to v or from v to u? (推断它是否是一个薄弱环节图)

    意甲冠军:给定一个有向图有m单向边缘.免费推断是否两点起来(a可以b要么b可以a或最多彼此),该请求 弱联通重量. 算法: 缩点求强连通分量.然后又一次建图.推断新图是否是一条单链,即不能分叉,假设分 ...

  3. POJ 3356 AGTC(最长公共子)

    AGTC Description Let x and y be two strings over some finite alphabet A. We would like to transform  ...

  4. 我学cocos2d-x (两) 采用Delegate(信托)

    Delegate(信托)什么 Delegate是ios开发中的一个概念,主要是为了让类A中的功能,放到类B中来实现,这样能够合理的把功能划分到不同的文件里进行实现,从而更好的实现模块的分离.如UIAp ...

  5. tomcatport占用,如何识别和kill

    开始-执行-cmd,进netstat -ano你可以看到整个port入住. 增加要想知道谁占用了我们的port8080,输入下面命令 C:\Documents and Settings\Adminis ...

  6. php中国的垃圾问题

    header这条线加,这是解决中国乱码的问题. 版权声明:本文博主原创文章,博客,未经同意不得转载.

  7. Android 应用程序启动过程源代码分析

    本文转自:http://blog.csdn.net/luoshengyang/article/details/6689748 前文简要介绍了Android应用程序的Activity的启动过程.在And ...

  8. Webpact打包React后端Node+Express

    Webpact打包React后端Node+Express 前言 React官方推荐用Browserify或者Webpack 来开发React组件. Webpack 是什么?是德国开发者 Tobias ...

  9. 第一次QQ群视频教育有感

    标题:第一次QQ群视频教育有感 作者:丁又专, 时间:2014.08.16     教育的目的:启示学生心智,发现个人优势,激发探索欲望.     今天早上看到 中国大学MOOC<文献管理与信息 ...

  10. Android应用程序的组成部分和Manifest文件(转)

    Android应用程序由松散耦合的组件组成,并使用应用程序Manifest绑定到一起:应用程序Manifest描述了每一组件和它们之间的交互方式,还用于指定应用程序元数据.其硬件和平台要求.外部库以及 ...