ICE 簡單介紹(Internet Communication Engine)


1. ICE的一些背景

the Internet Communications Engine   http://www.zeroc.com/ice.html

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 Internet Communications Engine. 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 GNU General Public License), in addition to traditional proprietary licensing models 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 介紹

 http://en.wikipedia.org/wiki/Internet_Communications_Engine   這幅圖不錯  去細看看里面那幅圖

 

ICE 在線文檔(不知道為什么現在沒找到pdf的下載了) http://doc.zeroc.com/display/Ice/Ice+Manual


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM