1. Ice run time overview
According to my personal understanding for the time being, icerun time refers to the fact that ice encapsulates most of the APIs to implement various functions of distributed application programs.
First, an important part is the communication tool, which is the main handle of the ice run time and the main entry point of the ice run time. Another important mechanism of ice is the servant positioner, which is used to control the balance between performance and memory consumption. Other equally indispensable components will be introduced later.
2. Communicator
The main entry point of icerun time is represented by the Local interface ice: communicator. Ice: an instance of communicator is associated with some runtime resources:
1) Client thread pool: Make sure that the client has at least one thread that can be used to receive responses to incomplete requests. It can also be used for Asynchronous Method calling (AMI ).
2) server thread pool: receives incoming connections and Processes requests from customers. It can be used for asynchronous distribution (AMD ).
3) Configure attributes: configure all attributes of icerun time. Each communication device has its own property set.
4) object Factory: instantiate the servant class inherited from the known base class.
5) a log recorder object: determines the log message processing method. Implemented the ice: logger interface.
6) A statistical object: prints some communication traffic messages. Implemented the ice: stats interface.
7) a default router implements the ice: router interface. Glacier uses it to implement the ice firewall function.
8) a default locator is used to resolve the object identifier to the proxy object. Icepack is used to build the positioning service.
9) a plug-in manager is an object used to add features to the communicator. Icessl is implemented as a plug-in.
10) Object Adapter: allocates incoming requests and assigns them to the corresponding servant for processing. The next section will be detailed.
The communicator provides some operations:
1) proxytostring, stringtoproxy: These two operations will be serialized, or vice versa.
2) createobjectadapter, createobjectadapterwithenderson points: Create an Object Adapter.
3) shutdown: Shut down the server's icerun time
4) waitforshutdown: suspends the thread that sends the call until the communicator is closed.
5) destroy: destroys the communication device and related resources, such as threads, communication endpoints, and memory resources.
3. Overview of Object Adapter 3.1
A communication device contains one or more object adapters. The Object Adapter is on the line between the ice run time and the server;
1) map the ice object to the requested servant, and allocate the request to the corresponding servant object for processing.
2) assists in lifecycle operations to avoid conflicts between the establishment and destruction of ice objects and Servan.
3) provides one or more transmission endpoints. Each adapter has one or more servant instances.
3.2 active servant ing table
Each Object Adapter maintains an active servant ing table (ASM: Active servant map ). The following figure shows the role of an activity table:
Therefore, its function can be described as binding requests to the correct servant. As shown in the figure, a direct proxy is used to embed the transmission endpoint in the proxy.
3.3) activate and deactivate servant
Activation means to inform the ice run time of the existence of the servant of an ice object. The specific operation is to add the servant object pointer to the ASM table.
The opposite operation is contact activation. These operations are defined in the interface:
Module ice {Local interface objectadapter {//... // Add: Add a signed servant to ASM. The returned value is the proxy object * Add (Object servant, identity ID) of the object embodied in this servant; // addwithuuid: similar to add, but the program automatically adds the ice object identifier. You can use ice_getidentity to obtain the object proxy object * addwithuuid (Object servant ); // remove the corresponding servant entry void remove (identity ID) from ASM );//...};};
3.) Adapter status:
A) Activate: Activity Status. The adapter can dispatch connection requests.
B) hold: hold status. requests arriving at this time will be detained and not distributed to the corresponding servant for processing.
The thread that sends the call will return immediately and will not wait until the operation is completed.
C) waitforhold: suspends the calling thread until the adapter status changes to the hold status.
D) deactivate: requests that arrive later will be rejected, but ongoing requests can be completed.
E) waitfordeactivate: suspends the calling thread until the adapter is migrated to the Deactivate state.
References: ice1.3.0 and ice3.4.2 Manual