ICE介绍(2) - abetman的专栏 - CSDNBlog

来源:百度文库 编辑:神马文学网 时间:2024/04/25 17:10:32

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 specific type. Parameters are named and have a direction: in-parameters are initialized by the client and passed to the server; out-parameters are initialized by the server and passed to the client. (The return value is simply a special out-parameter.)

 

 

 

 

一个操作有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

 

 

 

 

A 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/IPUDP)

 

 

 

 

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

 

 

 

 

为连接到一个用直接代理表示的对象,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一样)