码迷,mamicode.com
首页 > Web开发 > 详细

什么是ICE (Internet Communications Engine)

时间:2016-04-28 23:50:10      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:

 http://user.qzone.qq.com/77811970

 

直接在google上搜索ICE,出来的结果并不多,所以很多人就认为ICE是个神秘的东西,其实,国内已经有很多大型应用在使用ICE了。前段时间因为工作的关系被逼学习了ICE, 感觉不错的东西。我记录下入门的一些概念,希望对后来的学习者有所帮助。

  •     什么是ICE  (Internet Communications Engine)

          首先,ICE是一个中间件(如果不懂什么是中间件,请先G一下),该中间件的目的是为上层应用提供高效的网络通信。

         其次,ICE是跨平台的( Linux, Solaris, Windows and Mac OS X)、跨语言的( C++Java.NET-languages (such as C# or Visual Basic), Objective-C,PythonPHP, and Ruby[1] )

         最后,ICE不仅仅提供网络通讯的解决方案,还提供一组完整的特性/组件 (比如防火墙、消息订阅、服务器、网格计算等),支持广泛的领域中的分布式应用开发

  •     搭建ICE运行环境

         去ICE的官网上下载for windows的安装文件:(or 猛击这里直接下载http://www.zeroc.com/download.html#win32_msi 

         按照提示安装完毕后,把bin 和 lib的路径添加到classpath和path

         然后打开cmd, 输入slice2java, 如果出现一大堆slice2java的命令参数列表及使用方法,就说明你的ICE运行时安装完毕:)

 

  •     ICE是怎么工作的

         既然ICE是提供网络通讯服务,那么在ICE的使用场景中,必然有一个Client,一个Server。 Ice把能响应客户请求的实体看成一个Ice对象,(ice object),不管这个对象是存在于本地抑或远程。每个ice object都有一个或多个接口,使用者通过调用这些接口来使用ice object提供的服务(有点像java里的interface).

           刚才提到,ICE是跨语言的,那么一个C的客户端如何调用Java写的应用程序呢?这就规定ice object的定义必须统一使用Slice语言来编写,然后通过ice的一系列编译器:slice2java, slice2cpp,slice2cs,slice2py,slice2freezz等,来生成特定语言的接口定义。接着你的应用就可以调用这个接口,来完成相应的操作。

2.1Chapter Overview

In this chapter, we present a high-level overview of the Ice architecture.

Section 2.2 introduces fundamental concepts and terminology, and outlines how

Slice definitions, language mappings, and the Ice run time and protocol work in

concert to create clients and servers. Section 2.3 briefly presents the object

services provided by Ice, and Section 2.4 outlines the benefits that result from the

Ice architecture. Finally, Section 2.5 presents a brief comparison of the Ice and

CORBA architectures.

 

 

 

2.1 章节预览

在这一章里,我们将呈现一个 ICE 架构的高层预览。 2.2 节将介绍一些基础的概念和术语,并概括一下 Slice 是如何定义的,语言是如何映射的,还有 Ice 运行时和协议在创建客户端和服务器时是如何保持一致的。 2.3 节简要的介绍一下 ICE 提供的对象服务。在 2.4 节概括一下由 ICE 架构所带来的好处。最后,在 2.5 节将提供一个 ICE 和 CORBA 架构的一个大概的比较。

2.2The Ice Architecture

2.2.1 Introduction

 

Ice is an object-oriented middleware platform. Fundamentally, this means that Ice provides tools, APIs, and library support for building object-oriented client–server applications. Ice applications are suitable for use in heterogeneous environments: client and server can be written in different programming languages, can run on different operating systems and machine architectures, and can communicate 10 Ice Overview using a variety of networking technologies. The source code for these applications is portable regardless of the deployment environment.

2.2 ICE 的架构

2.2.1 介绍

ICE 是一个面向对象的中间件平台。从根本上讲,这意味着 ICE 提供了一些工具、 API 和库用以开发面向对象的客户端 - 服务器的应用程序。 ICE 应用程序适合于用在各种异构的环境中:客户端和服务器可以用不同的语言编写,能够运行在不同的操作系统、不同体系结构的机器上,可以用不同的网络技术进行通讯 ( 大概 10 种以上 ) 。这些程序的源代码可以在不同的开发环境之间移植。

2.2.2 Terminology

 

Every computing technology creates its own vocabulary as it evolves. Ice is no exception. However, the amount of new jargon used by Ice is minimal. Rather than inventing new terms, we have used existing terminology as much as possible. If you have used another middleware technology, such as CORBA, in the past, you will be familiar with most of what follows. (However, we suggest you at least skim the material because a few terms used by Ice do differ from the corresponding CORBA terminology.)

2.2.2 术语

任何一个计算机技术在它的发展过程中都会创造一些术语。 ICE 也不例外。但是, ICE 所用的新术语是最少的。我们尽可能的用一些已经存在的术语,而不是发明新的。如果你以前用过其他的中间件产品的话,例如 CORBA ,你对下面的很多术语可能已经熟悉了。 ( 但是,我们建议你至少要掌握一些重要的东西,因为有一些术语在 ICE 中与在 CORBA 中的意思不同 )

Clients and Servers

The terms client and server are not firm designations for particular parts of an

application; rather, they denote roles that are taken by parts of an application for

the duration of a request:

• Clients are active entities. They issue requests for service to servers.

• Servers are passive entities. They provide services in response to client

requests.

l         客户端和服务器

客户端和服务器不是指应用程序的固定的某一方。相反,它们是指在应用程序请求期间某一方所扮演的角色。

       客户端是主动的实体。它们向服务器发出服务请求。

       服务器是被动的实体。它们向客户端提供服务。

Frequently, servers are not “pure” servers, in the sense that they never issue

requests and only respond to requests. Instead, servers often act as a server on

behalf of some client but, in turn, act as a client to another server in order to

satisfy their client’s request.

服务器并不总是一个“纯粹的”服务器 ( 所谓“纯粹的”服务器是指它们从来不发送请求,只是回应请求 ) 。通常情况下是这样,服务器相对自己的客户端时是服务器,但是,为了满足其客户端的请求,它们可能会是其他服务器的客户端。

Similarly, clients often are not “pure” clients, in the sense that they only

request service from an object. Instead, clients are frequently client–server

hybrids. For example, a client might start a long-running operation on a server; as

part of starting the operation, the client can provide a callback object to the server

that is used by the server to notify the client when the operation is complete. In

that case, the client acts as a client when it starts the operation, and as a server

when it is notified that the operation is complete.

同样的,客户端也不总是一个“纯粹的”的客户端 ( 所谓“纯粹的”的客户端是指只是从一个对象中请求服务) 。相反,客户端经常是一个客户端 - 服务器的混合体。例如,一个客户端可能会在服务器上启动一个长时间的操作,在启动这个操作时,客户端可能会向服务器提供一个回调对象,服务器可以在完成操作时用这个对象通知客户端。在这种情况下,客户端在启动操作时是一个客户端,在指定的操作完成被通知时是一个服务器。

Such role reversal is common in many systems, so, frequently, client–server

systems could be more accurately described as peer-to-peer systems.

这样的角色互换在很多系统中是很普通的,所以,一个客户端 - 服务器系统常常被精确的描述为一个 PtoP 系统。

Ice Objects An Ice object is a conceptual entity, or abstraction. An Ice object can be character-ized by the following points:

l         ICE 对象

一个 ICE 对象是一个概念上的实体,或者说是一种抽象。一个 ICE 对象可能有下面一些特征:

• An Ice object is an entity in the local or a remote address space that can respond to client requests.

一个 ICE 对象是一个在本地或远程地址空间中的一个实体,它能响应客户端的请求。

  • A single Ice object can be instantiated in a single server or, redundantly, in multiple servers. If an object has multiple simultaneous instantiations, it is still a single Ice object.

单一的一个 ICE 对象可以在一个单一的服务器中,也可以在多个服务器中冗余。如果一个对象有多个相同的实例,它仍然是一个单一的 ICE 对象。

• Each Ice object has one or more interfaces . An interface is a collection of named operations that are supported by an object. Clients issue requests by invoking operations.

每个 ICE 对象有一个或多个接口。一个接口是一个对象所支持的命名操作的集合。客户端通过调用操作来发送请求。

• An operation has zero or more parameters as well as a return value . Parame-ters and return values have a specifictype . Parameters are named and have a direction: in-parameters are initialized by the client and passed to the server;out - param eters are initialized by the server and passed to the client. (The return value is simply a special out -param eter.)

一个操作有 0 个或多个参数,也有返回值。参数和返回值都有一个指定的类型。参数是命名的并且是指定方向的: in 型的参数在客户端初始化后传递到服务器, out 型的参数在服务器初始化后传递到客户端。 ( 返回值被简单的指定为 out 参数 )

• An Ice object has a distinguished interface, known as its main interface . In addition, an Ice object can provide zero or more alternate interfaces, known as facets . Clients can select among the facets of an object to choose the interface they want to work with.

一个 ICE 对象有一个著名的接口,那就是 main 接口。另外,一个 ICE 对象能提供 0 个或多个备用接口,就是facet 。一个客户端可以从对象提供的 facet 中选择一个 facet ,从而选择一个它们想要为其工作的接口。

• Each Ice object has a unique object identity . An object’s identity is an identifying value that distinguishes the object from all other objects. The Ice object model assumes that object identities are globally unique, that is, no two objects within an Ice communication domain can have the same object iden-tity.

每个 ICE 对象都有一个独一无二的对象标识。一个对象标识是区别于其他对象的一个标识值。 ICE 对象模型假设对象是全局唯一的,也就是说,在一个 ICE 的通信域不会有两个对象具有相同的标识。

In practice, you need not use object identities that are globally unique, such as UUIDs [14], only identities that do not clash within any other identity within your domain of interest. However, there are architectural advantages to using globally unique identifiers, which we explore in XREF.

实际上,你并不需要用像 UUID 一样的全局唯一的对象标识,只要在你感兴趣的域中没有碰撞就可以。然而,用全局唯一标识在会有一些架构上的优势,这一个我们将在 XREF 中进一步的探讨。

l         Proxies

For a client to be able to contact an Ice object, the client must hold a proxy for the

Ice object. A proxy is an artifact that is local to the client’s address space; it

represents the (possibly remote) Ice object for the client. A proxy acts as the local

ambassador for an Ice object: when the client invokes an operation on the proxy, the Ice run time: 1. Locates the Ice object 2. Activates the Ice object’s server if it is not running 3. Activates the Ice object within the server 4. Transmits any in-parameters to the Ice object 5. Waits for the operation to complete 6. Returns any out -parameters and the return value to the client (or throws an exception in case of an error)

l         代理

为了使一个客户端能够联系到一个 ICE 对象,这个客户端必须拥有这个 ICE 对象的一个代理。代理是一个位于客户地址空间的一个工具;对于客户端它代表着一个 ICE 对象 ( 可能在远端 ) ,对于 ICE 对象它是一个本地大使。当客户端调用一个在代理上的操作时, ICE 动作如下:

       1 、定位一个 ICE 对象

       2 、如果它没有运行则激活它

       3 、激活服务器的 ICE 对象

       4 、传输 in 参数到 ICE 对象

       5 、等待操作完成

       6 、返回 out 参数和返回值到客户端 ( 如果出错的话会 throw 一个异常 )

A proxy encapsulates all the necessary information for this sequence of steps to take place. In particular, a proxy contains:

• Addressing information that allows the client-side run time to contact the correct server

• An object identity that identifies which particular object in the server is the target of a request

• An optional facet identifier that determines which particular facet of an object the proxy refers to Section 29.8 provides more information about proxies.

一个代理封装了以上一系列动作发生时的必要的信息。特殊情况下,代理包含以下内容:

       允许客户端一边在运行时联系到正确的服务器的寻址信息

       一个对象标识,标识出请求的目标是哪一个特定的对象。

       一个可选的 facet 标识符用来指定代理应该指向哪一个特定的 facet 。

在 29.8 节提供一更详细的关于代理的内容。

Stringified Proxies

The information in a proxy can be expressed as a string. For example, the string

SimplePrinter:default -p 10000

is a human-readable representation of a proxy. The Ice run time provides API calls

that allow you to convert a proxy to its stringified form and vice versa. This is

useful, for example, to store proxies in database tables or text files.

Provided that a client knows the identity of an Ice object and its addressing

information, it can create a proxy “out of thin air” by supplying that information.

In other words, no part of the information inside a proxy is considered opaque; a

client needs to know only an object’s identity, addressing information, and (to be

able to invoke an operation) the object’s type in order to contact the object.

l         字符串化的代理

一个代理的信息可以表示为一个字符串。例如,字符串 SimplePrinter:default –p 10000 是一个可读的代理的表示法。 ICE 运行时提供了 API 允许你将一个代理转换成它的字符化格式,或者相反的转换。这是很有用的,比如,要将代理保存到数据库或文本文件中的时候。假设一个客户端知道一个 ICE 对象的标识和它的地址信息,它就能通过提供的这些信息 “凭空”的创建出一个代理来。换句话说,代理中的信息是透明的;一个客户端仅需要知道一个对象的标识,地址信息和 ( 为了能调用一个操作 ) 为了能连接到对象所需要的类型信息。

Direct Proxies

direct proxy is a proxy that embeds an object’s identity, together with the

address at which its server runs. The address is completely specified by:

• a protocol identifier (such TCP/IP or UDP)

• a protocol-specific address (such as a host name and port number)

To contact the object denoted by a direct proxy, the Ice run time uses the

addressing information in the proxy to contact the server; the identity of the object

is sent to the server with each request made by the client.

l         直接代理

直接代理是这样的一个代理,它嵌入了一个对象的标识和其在上运行的服务器的地址。地址是十分详细的,包括:

       一个协议标识 ( 如 TCP/IP 或 UDP)

       一个特定协议的地址 ( 如一个主机名和一个端口号 )

为连接到一个用直接代理表示的对象, ICE 运行时用代理中的地址信息连接到服务器。对象的标识和客户端的每一次请求被一起发送到服务器。

Indirect Proxies An indirect proxy is a proxy that embeds an object’s identity, together with an object adapter name . Note that an indirect proxy contains no addressing informa-tion. To locate the correct server, the client-side run time uses the object adapter name inside the proxy and passes it to a locator service, such as the IcePack service. In turn, the locator uses the adapter name as the key to a lookup table that contains the address of the server and returns the current server address to the client. The client-side run time now knows how to contact the server and dispatches the client request as usual. The entire process is similar to the mapping from Internet domain names to IP address by the Domain Name Service (DNS): when we use a domain name, such as www.zeroc.com, to look up a web page, the host name is first resolved to an IP address behind the scenes and, once the correct IP address is known, the IP address is used to connect to the server. With Ice, the mapping is from an object adapter name to a protocol–address pair, but otherwise very similar. The client-side run time knows how to contact the IcePack service via configuration (just as web browsers know which DNS to use via configuration).

l         间接代理

间接代理是这样一个代理,它嵌入的是一个的标识以及对象的适配器名。注意一个间接代理没有包含地址信息。要定位到一个正确的服务器,客户端这边在运行时要将代理中的对象的适配器名传给一个定位服务,如IcePack 服务。接着,这个定位器把这个适配器名当作一个 key 在一个包括服务器地址的表中查找,找到后将当前服务器的地址返回给客户端。这时客户端知道了如何连接到服务器,就像通常一样分发请求给服务器了。整个过程就像用 DNS 服务将 Internet 域名映射为 IP 地址一样。当我们用一个域名去访问一个 web 页的时候,如 www.zeroc.com ,主机名在后台先被解析为一个 IP 地址,一旦知道了正确的 IP 地址,就可以通过 IP 地址连接到服务器了。在 ICE 中,这种映射是从一个对象适配器名到一个协议 - 地址对,其他的就相似了。客户端在运行时通过配置就知道如何连接到 IcePack 服务器 ( 正如 web 浏览器可以通过配置知道 DNS 一样 ) 。

什么是ICE (Internet Communications Engine)

标签:

原文地址:http://www.cnblogs.com/endv/p/5444635.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!