- 浏览: 330280 次
- 性别:
- 来自: 北京
最新评论
-
hoey168:
请问楼主,ICE 客户端连接多个服务端,tcp -h 172. ...
ZeroC ICE之旅------负载均衡及容错 -
iOracleSun:
makeC++SharedLib 增加 -G参数即可链接成功 ...
AIX apache module问题 -
fanyonglu:
不错,讲的很细,学习中
ZeroC ICE之旅------java -
click_guobin:
...
我在深圳,每月收入850元,怎么也花不完,晒一晒我是怎么开销和投资的(zz) -
hanyu332:
引用修改%apache%/conf/httpd.conf修改为 ...
awstats日志分析小结(1)
Ice的服务端可以采用C++/Java/Python/C#等实现,客户端可以采用C++/Java/Python/C#/VB/PHP/Ruby来实现,就是说我的一个服务端采用C++实现,客户端可以采用java/php/vb/c# 等其他语言实现。
这个特性也是Ice的很重要的优势之一.
Ice的多语言之间如何确保对象的正确传输,每种语言都有各自的特点,数据类型,Ice是如何达到各种语言之间的互通互联的呢?
那么就一定提到Slice语言.Slice是保证各种语言的互通互联的关键,它是独立于其它任何语言,Ice可以通过把Slice代码片断转化为各自的
语言描述.
赫赫够多!
Slice的全称:Specification Language for Ice,是Ice自己的特殊语言,一种用于使对象接口与其实现相分离的基础性抽象机制。Slice 建立在客户与服务器之间的合约,用以描述应用所使用的类型和对象接口。Slice描述独立于实现语言,所以客户实现语言是否与编写服务器所用的语言相同没有任何关系。
slice语言片段可以被编译为任何所支持语言的实现。目前Ice Slice可以支持映射到到C++, Java, C#, Python,Ruby, and PHP。
因为Slice主要对接口和类型的定义和描述,没有实现部分。
到底如何实现不同语言的互通互联的呢?我们已Java,C++作为Ice例子原形,实际上我们仅仅做少量修改,就可以实现
C++的服务端,Java的客户端。Server和Client还是保持在同一台机器上运行。注意我们基于同一个demo.ice的事例。
首先运行./Server,再运行Client,看到结果了么?赫赫,是不是出现了正常结果。
到目前没有我们所有实例都是基于同一台机器的,实际情况Server,Client会分布在不同机器上。这种情况下,我们需要如何处理呢?
这个很简单,在Server少量修改
"default -p 10000" 采用 "tcp -h server1 -p port" 替代
Server所在主机IP:172.17.12.101 ,端口:10000
所以就修改为:tcp -h 172.17.12.101 -p 10000,再重新编译Server
编译方式参见:
http://masterkey.iteye.com/blog/183307
下面我们需要对Client连接部分进行修改,同理:
看到了么,就是这么简单,其他部分不用修改。
好了,我们进行验证,首先启动./Server,再执行Client ,看到了
"My first Ice 事例" 看到了么,祝贺你,跨语言的分布式调用例子你已经实现了。
其实Ice的通讯机制极其强大,支持集群和容错技术。关于集群的事例会在日后的文章中介绍。
BTW:
注意,Server运行之后监听于10000端口,需要修改iptables,允许其他机器可以连接。
编辑 iptables
vi /etc/sysconfig/iptables
追加:
ICE之轻量级分布式通讯中间件
http://masterkey.iteye.com/blog/182954
ZeroC ICE之旅------C++
http://masterkey.iteye.com/blog/183307
ZeroC ICE之旅------java
http://masterkey.iteye.com/blog/182975
ZeroC ICE之旅------Slice
http://masterkey.iteye.com/blog/184064
ZeroC ICE之旅------集群和容错
http://masterkey.iteye.com/blog/185081
更多ICE文章,请关注:
Titan的天空
http://masterkey.iteye.com
这个特性也是Ice的很重要的优势之一.
Ice的多语言之间如何确保对象的正确传输,每种语言都有各自的特点,数据类型,Ice是如何达到各种语言之间的互通互联的呢?
那么就一定提到Slice语言.Slice是保证各种语言的互通互联的关键,它是独立于其它任何语言,Ice可以通过把Slice代码片断转化为各自的
语言描述.
-rwxr-xr-x 1 system users 447888 2007-03-09 slice2java -rwxr-xr-x 1 system users 67753 2007-03-09 slice2py -rwxr-xr-x 1 system users 38679 2007-03-09 slice2rb -rwxr-xr-x 1 system users 505441 2007-03-09 slice2vb -rwxr-xr-x 1 system users 507119 2007-03-09 slice2cpp -rwxr-xr-x 1 system users 454347 2007-03-09 slice2cs
赫赫够多!
Slice的全称:Specification Language for Ice,是Ice自己的特殊语言,一种用于使对象接口与其实现相分离的基础性抽象机制。Slice 建立在客户与服务器之间的合约,用以描述应用所使用的类型和对象接口。Slice描述独立于实现语言,所以客户实现语言是否与编写服务器所用的语言相同没有任何关系。
slice语言片段可以被编译为任何所支持语言的实现。目前Ice Slice可以支持映射到到C++, Java, C#, Python,Ruby, and PHP。
因为Slice主要对接口和类型的定义和描述,没有实现部分。
到底如何实现不同语言的互通互联的呢?我们已Java,C++作为Ice例子原形,实际上我们仅仅做少量修改,就可以实现
C++的服务端,Java的客户端。Server和Client还是保持在同一台机器上运行。注意我们基于同一个demo.ice的事例。
首先运行./Server,再运行Client,看到结果了么?赫赫,是不是出现了正常结果。
到目前没有我们所有实例都是基于同一台机器的,实际情况Server,Client会分布在不同机器上。这种情况下,我们需要如何处理呢?
这个很简单,在Server少量修改
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints ("TestAdapter", "default -p 10000");
"default -p 10000" 采用 "tcp -h server1 -p port" 替代
Server所在主机IP:172.17.12.101 ,端口:10000
所以就修改为:tcp -h 172.17.12.101 -p 10000,再重新编译Server
#include <Ice/Ice.h> #include <demo.h> using namespace std; using namespace Demo; class Server:public test { public: ::std::string execute (const string & mth, const string & str, const Ice::Current &); public: Server (); }; Server::Server () { }; std::string Server::execute (const string & mth, const string & str, const Ice::Current &) { cout << mth + str << endl; return mth + str; } int main (int argc, char *argv[]) { int status = 0; Ice::CommunicatorPtr ic; try { ic = Ice::initialize (argc, argv); Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints ("TestAdapter", "tcp -h 172.17.12.101 -p 10000"); Ice::ObjectPtr object = new Server; adapter->add (object, ic->stringToIdentity ("TestAdapter")); adapter->activate (); ic->waitForShutdown (); } catch (const Ice::Exception & e) { cerr << e << endl; status = 1; } catch (const char *msg) { cerr << msg << endl; status = 1; } if (ic) { try { ic->destroy (); } catch (const Ice::Exception & e) { cerr << e << endl; status = 1; } } return status; }
编译方式参见:
http://masterkey.iteye.com/blog/183307
下面我们需要对Client连接部分进行修改,同理:
Ice.ObjectPrx base = ic.stringToProxy("TestAdapter:tcp -h 172.17.12.101 -p 10000");
package Demo; public class Client { public static void main(String[] args) { int status = 0; Ice.Communicator ic = null; try { ic = Ice.Util.initialize(args); // Ice.ObjectPrx base = ic // .stringToProxy("SimplePrinter:tcp -h 172.17.12.101 -p 10000"); Ice.ObjectPrx base = ic .stringToProxy("TestAdapter:tcp -h 172.17.12.101 -p 10000"); testPrx test = testPrxHelper.checkedCast(base); if (test == null) throw new Error("Invalid proxy"); System.out.println(test.execute("My first Ice ", "事例")); //System.out.println("ok"); } catch (Ice.LocalException e) { e.printStackTrace(); status = 1; } catch (Exception e) { System.err.println(e.getMessage()); status = 1; } if (ic != null) { // Clean up // try { ic.destroy(); } catch (Exception e) { System.err.println(e.getMessage()); status = 1; } } System.exit(status); } }
看到了么,就是这么简单,其他部分不用修改。
好了,我们进行验证,首先启动./Server,再执行Client ,看到了
"My first Ice 事例" 看到了么,祝贺你,跨语言的分布式调用例子你已经实现了。
其实Ice的通讯机制极其强大,支持集群和容错技术。关于集群的事例会在日后的文章中介绍。
BTW:
注意,Server运行之后监听于10000端口,需要修改iptables,允许其他机器可以连接。
编辑 iptables
vi /etc/sysconfig/iptables
追加:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 10000 -j ACCEPT
ICE之轻量级分布式通讯中间件
http://masterkey.iteye.com/blog/182954
ZeroC ICE之旅------C++
http://masterkey.iteye.com/blog/183307
ZeroC ICE之旅------java
http://masterkey.iteye.com/blog/182975
ZeroC ICE之旅------Slice
http://masterkey.iteye.com/blog/184064
ZeroC ICE之旅------集群和容错
http://masterkey.iteye.com/blog/185081
更多ICE文章,请关注:
Titan的天空
http://masterkey.iteye.com
发表评论
-
Redis 2.2.0 RC1 is out
2010-12-17 10:15 1176Redis 2.2.0 RC1 新特性:很多都是我所期待的; ... -
iBATIS 3 for Java Released (BETA 1)
2009-08-09 13:52 1346A month ago iBATIS turned 7 yea ... -
Memcached 1.4.0 Release
2009-07-10 17:10 1863New Features Binary Protocol ... -
nginx-0.7.60
2009-06-16 09:01 1436Changes with nginx 0.7.60 ... -
nginx-0.7.55
2009-05-06 18:47 1092Changes with nginx 0.7.55 ... -
Open Source SSL Acceleration
2009-04-17 11:15 1683SSL acceleration is a techniq ... -
March 2009 Web Server Survey
2009-04-02 12:49 982In the March 2009 survey, we re ... -
nginx 缓存功能
2009-03-26 16:02 4381随着 nginx-0.7.44的发布,nginx的c ... -
Memcached Beta 1.3.2 Released
2009-03-12 16:21 1175We've just released memcached ... -
nginx 0.7.40
2009-03-09 17:09 983Changes with nginx 0.7.40 ... -
February 2009 Web Server Survey
2009-03-02 09:19 1029In the February 2009 survey we ... -
Handle 1 Billion Events Per Day Using a Memory Gri
2009-02-17 10:41 1002Moshe Kaplan of RockeTier shows ... -
Scaling Digg and Other Web Applications
2009-02-16 11:36 1052Joe Stump, Lead Architect at D ... -
MySpace Architecture
2009-02-13 10:39 1185Information Sources Presenta ... -
Cloud Relationship Model
2009-01-20 09:53 1108Hiya All, welcome to my first g ... -
January 2009 Web Server Survey
2009-01-19 15:33 1054In the January 2009 survey we ... -
December 2008 Web Server Survey
2008-12-25 17:47 971In the December 2008 survey, ... -
Apache 2.2.11
2008-12-15 13:24 1376Changes with Apache 2.2.11 * ... -
nginx 0.7.26
2008-12-09 12:05 1028Changes with nginx 0.7.26 ... -
Python 3.0 final released
2008-12-04 10:47 1327We are pleased to announce the ...
相关推荐
python库,解压后可用。 资源全名:zeroc_ice-3.7.0-cp36-cp36m-win_amd64.whl
zeroc_ice-3.7.6-cp38-cp38-win_amd64
zeroc_ice-3.7.6-cp37-cp37m-win_amd64
zeroc_ice-3.7.4-cp36-cp36m-win_amd64
zeroc_ice-3.7.6-cp39-cp39-win_amd64
zeroc_ice-3.7.6-cp38-cp38-win32
资源来自pypi官网。 资源全名:zeroc_ice-3.7.2-cp27-cp27m-macosx_10_14_x86_64.whl
zeroc_ice-3.7.6-cp39-cp39-win32
zeroc_ice-3.7.6-cp37-cp37m-win32
zeroc_ice-3.7.4-cp36-cp36m-win32
Zeroc Ice原理介绍-附件资源
ZeroC ICE 是指ZeroC公司的ICE(Internet Communications Engine)中间件平台。对于客户端和服务端程序的开发提供了很大的便利。 目前ICE平台中包括Ice,Ice-E,Ice Touch。 Ice为主流平台设计,包括Windows和...
Ice是RPC通讯领域里最稳定、强大、高性能、跨平台、多语言支持的老牌开源中间件,特别适合于当前互联网领域中一个平台存在多种开发语言编程,以及网站和app应用并存的复杂大型项目。 RPC(Remote Procedure Call ...
python安装ice: pip install zeroc-ice
《ZeroC Ice权威指南》是业界第一本关于Ice这个知名开源分布式RPC中间件的纸质书籍,全书内容涵盖了分布式系统架构概述、RPC原理、Ice基础源码研读、高级进阶、多语言调用、性能调优、SSL安全调用、IceGrid运维与...