ICE简单介绍(InternetCommunicationEngine)

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

ICE简单介绍(InternetCommunicationEngine)
1. ICE的⼀些背景
ICE 是ZeroC的主要产品, 是⼀个object-oriented toolkit,⽤来帮助我们构建分布式应⽤程序,使我们专注于程序的逻辑⽽不是底程⽹络交互的细节
ZeroC provides a fast and highly-scalable communications infrastructure for demanding technical applications, such as telecom, defense, finance, on-line entertainment, manufacturing, and process control. ZeroC's core product is Ice, the . Ice is one of the most versatile and powerful distributed computing platforms ever.
With an aggressive, no-nonsense licensing model for the Open Source community (GPL, the ), in addition to traditional for commercial customers, ZeroC aims to establish Ice as the leading technical middleware product.
ice提供了强⼤的 RPC(remote procedure call)功能,(同步异步Invocation,dispatch), one-way (对tcp,ssl),datagram(udp) ,也就是客户端调⽤了就不管了(fire and forget) 以及提供了除rpc之外的⼏个强⼤的服务,iceGrid, iceStorm....
ICE提供的编程模型:4步,定义slice⽂件, slice⽂件⽣成相应语⾔的代码(根据client,server所使⽤的语⾔),编写client-side代码并链接ICE,编写server-side代码并链接ICE
ICE⼴泛⽀持了各主流语⾔和 platform(OS & compiler)
2. ice manual的基本内容
这个⽂档是ice主要的⽂档了,编程什么的都参考它,主要分了4个部份;
2.1,概述,ice主要的⼏个部份介绍,在2.2.2(terminology)作为术语解释,包括ice object, ice proxy, ice object简单说是⼀个可以响应client request的实体,它有⾄少⼀个interface,interface则有⼀个或多个operation,每个ice object都有⼀个object identity(object在35章详讲); ice proxy: client要想contact⼀个ice object,就必须hold⼀个ice proxy,它就是ice object的本地代理,所以proxy必须有object的address信息,以及object的identity来定位object,(proxy在32章详讲), 以及⼀个hello world例⼦,告诉我们最简单的ice client,server怎么写
2.2 slice(specification language for ice) , slice在client和server之间做了⼀个约定, slice会被c++的预处理器作预处理,所以我们在⽂件中都应该⽤到#ifndef, #define,#endif,另外 #include应该⽤<>,这样slice compiler会在编译选项的-I路径中去查找头⽂件,slice中所有的定义都必须放到module中,不能在全局定义
特别的要提到Ice module, 基本上所有的Ice run time时的API, 都是在以slice的形式定义和表达的,在module Ice { }中,⽐如我们下⾯提到的communicator是⼀个slice的interface
slice中的类型有basic types , user-defined types(enum, structure, sequence, dictionary), sequence<type>, dictionary<type,type>在c++中被映射为vector和map
interface是slice中最中⼼最关注的东西了,通过proxy调⽤⼀个operation则就由Ice run time向⽬标object发送了⼀个message, 4.10.4讲了ice所定义的exception的层次结构,根处是Ice::Exception,应该是Ice⾃⼰⽤Slice定义的吧,不知道映射到C++中是不是std::Exception,
interface可以⽤extends来派⽣, interface Thing extends BaseThing {}
class的内容很丰富,后⾯看,有和interface,struct的⽐较。

2.3 slice到具体语⾔的映射,主要去看看到C++的映射
2.4 ice的configuration, thread, ice run-time的深⼊理解(其中有proxy),上⾯提到,run-time的api基本都是由slice定义的,以及ice object的深⼊理解
2.5 ice提供的其它服务,如ice storm
3. ICE manual 中的⼀张图
这是在ice manual中概述部份的⼀张图,2.2.5, client和server端的结构,其中proxy code和Skeleton都是slice⽣成的具体语⾔的代
码,Object Adapter是专属server端的 Ice run-time的⼀部份,它把client的request映射到object具体的⽅法上
4, communicator的⼀点理解
以下内容差不多都看⾃于 Ice manual中Ice run-time in detail那⼀章
Communicator代表了Ice run time的主要进⼊点, Ice::Communicator的⼀个 instance(实例)关联了⼀系列 run-time resources(运⾏时的资源) ,包括Client-side Thread Pool, Server-side Thread Pool , Configuration Properties ...... Communicator 是⼀个slice定义的 local interface, Communicator提供了⼀系列的operation, stringToProxy , createObjectAdapterWithEndpoints...; talk中的IceChannel这个类就是对 Ice
Communicator的包装, 且IceChannel中定义的⽅法⼤都是对createObjectAdapterWithEndpoints的包装,在talk的main函数中, 要⽤communicator的地⽅⽤的IceChannel
(32.3)Communicator的在创建的过程中, ICE run time为其初始化了⼀系列的特性, 并且初使化后不能修改, 也就是只能在创建⼀个communicator时设定这些特性; ⾸先初始化⼀个data structure, 对C++来说是 struct InitializationData {PropertiesPtr properties; ...}, 然后使⽤函数 Ice::initialize来初使化⽣成⼀个communicator CommunicatorPtr initialize(const InitializationData& = InitializationData())
1 Ice::InitializationData id;
2 id.PropertiesPtr = properties;(properites先赋好值)
3 Ice::CommunicatorPtr ic = Ice::initialize(id);
在talk的 IceChannel::init()中先设置PropertiesPtr 再⽣成 CommunicatorPtr_ ;
Object Adapters(32.4)
⼀个communicator有⼀个或多个object adapters, ⼀个object adapter处在Ice run time和server application(服务端应⽤程序)之间, Object Adapter本⾝是⼀个local interface, 
endpoint的概念也是adapter的, 且⼀个adapter维护两组endpoints, physical endpoints 和 published endpoints,
servant activation and deactivation(32.4.4) : adapter提供了 add , remove, find 等操作 , 在talk中main函数⾥⾯⽤到了add, 注意创建的是Ice::objectPtr ....,⽽add带的第⼆参数是 Identity(32.5), 也就是client要使⽤这个servant必须知晓的名字
object Identity (32.5) 每⼀个ICE object都有⼀个object Identity, 这是⼀个slice定义的struct(module Ice中), Object Identity可以以string的形式表式, Fatory/File 表⽰ category是 Factory, name是File Communicator提供了 stringToIdentity 和 identityToString 来进⾏string和Identity的互转 除⾮使⽤Locator, category常常是空的
module Ice{
struct Identity {
string name;
string category;
};
};
5.ICE wiki 介绍。

相关文档
最新文档