ice 连接

Once a proxy has been associated with a connection, the proxy’s default behavior is to continue using that connection for all subsequent requests. In effect, the proxy caches the connection and attempts to use it for as long as possible in order to minimize the overhead of creating new connections. If the connection is later closed and the proxy is used again, the proxy repeats the connection-establishment procedure described in Section 37.3.1.

37.3.1 Endpoint Selection
A proxy performs a number of operations on its endpoints before it asks the Ice run time to supply a connection. These operations produce a list of zero or more endpoints that satisfy the proxy’s configuration. If the resulting list is empty, the application receives NoEndpointException to indicate that no suitable endpoints could be found. For example, this situation can arise when a twoway proxy contains only a UDP endpoint; the UDP endpoint is eliminated from consideration because it cannot be used for twoway invocations.
The proxy performs the following steps to derive its endpoint list:
1. Remove the endpoints of unknown transports. For instance, SSL endpoints are removed if the SSL plug‑in is not installed.
2. Remove endpoints that are not suitable for the proxy’s invocation mode. For example, datagram endpoints are removed for twoway, oneway and batch oneway proxies. Similarly, non-datagram endpoints are removed for datagram and batch datagram proxies.
3. Perform DNS queries to convert host names into IP addresses, if necessary. For a multi-homed host name, the proxy adds a new endpoint for each address returned by the DNS query.
4. Sort the endpoints according to the configured selection type, which is established using the ice_endpointSelection factory method. The default value is Random, meaning the endpoints are randomly shuffled. Alternatively, the value Ordered maintains the existing order of the endpoints.
5. Satisfy the proxy’s security requirements:
1. If Ice.Override.Secure is defined, remove all non-secure endpoints.
2. Otherwise, if the proxy is configured to prefer secure endpoints (e.g., by calling the ice_preferSecure factory method), move all secure endpoints to the beginning of the list. Note that this setting still allows non-secure endpoints to be included.
3. Otherwise, move all non-secure endpoints to the beginning of the list.
If connection caching is enabled (see Section 37.3.4) and the Ice run already has a compatible connection (see Section 37.3.3), it reuses the cached connection. Otherwise, the run time attempts to connect to each endpoint in the list until it succeeds or exhausts the list; the order in which endpoints are selected for connection attempts depends on the endpoint selection policy (see page 1775).


There are situations in which this default caching behavior is undesirable, such as when a client has a proxy with multiple endpoints and wishes to balance the load among the servers at those endpoints.

猜你喜欢

转载自yidianfengfan.iteye.com/blog/1025111
ice