Use of the TAO implementation library IMR (Implementation repository) of the CORBA Application
Use of the TAO implementation library IMR (Implementation repository) of the CORBA Application
By wulanshi@163.com
0. Preface
This article is written only when you encounter problems when learning ace_wrappers/TAO/docs/tutorials/quoter/simple/impl-repo/examples, the steps following the example are not feasible (Implementation repository). Later I studied the README document to find the problem, so in order to make it easier for later colleagues, and translate the relevant reading materials into the following articles. Due to your limited knowledge, the original text may be vague. Therefore, some may be inaccurate in translation or inaccurate in understanding. I hope you can understand it and correct it.
I. terms in this article:
Implementation Library: it is also a service provided by the system (provided by the system)
Service: refers to the entity to be called by the application. It is also a CORBA service (a program, a non-system service) and is registered in the Implementation library.
Application: generally refers to the client application, and the client agrees that the application may be on a machine or different from the service, and used to call the service.
Ii. Overview of the implementation Library:
When an application calls a service, the related requests are first sent to the implementation library. if the service is not started, the service is started first and then the call is forwarded to the service. When a service is activated, the implementation library is used to track a service and record relevant information so that the service can be re-activated next time.
Iii. Usage of libraries:
If an application wants to use a service in the implementation library, the Service must use the IMR File Communication Mode to track and synchronize the latest running status of the service. This function is already included in POA, so a service uses persistent POA and does not specify the-orbuseimr parameter, so it will be able to communicate with the Implementation library.
The IMR feature is used to improve the throughput and balance of the TAO system. It enables the implementation library to break down tasks into two layers: implrepo_service and imr_activator.
1. implrepo_service
The main program implemented by implrepo_service "implementation library" is visible to applications using IMR. It accepts a request from tao_imr and distributes the request to the registered imr_activator. Implrepo_service is stateless, except for the imr_activato information registered on it, other information is not maintained. Its task is used as an intermediate medium for the application and the imr_activator that actually executes the request.
Up to now, only one implrepo_service can be run at any time. implrepo_service can be called through common methods, such as-orbinitref,-orbdefaultinitref, or broadcast (Multicast.
Parameters for running implrepo_service:
-D Indicates whether to enable debugging. The default value is enable, and the default value is 0.
-M supports broadcast discovery
-O to generate the IOR file, this parameter is followed by a file name
Of course, there are other orb-related parameters. You can add the parameter-h to view the specific command format, as shown in the following example.
2. imr_activator
Imr_activator is the entity actually executed. It can activate, shut down services, or maintain information about various service programs related to it. Only one imr_activator instance can be run on a host. imr_activator is transparent to applications. Only implrepo_service can be directly connected to it, and only implrepo_service needs it.
An imr_activato instance must first use implrepo_service for registration to accept the request. When registering, it passes the current host name and its own ior file to implrepo_service. The same information will be used when implrepo_service accesses it in the future.
Parameters for running imr_activator:
-C-run service commands
-D: Print debugging information
-L lock the database
-O generates the IOR file, which may be used by other users.
-R allows Win32 registration implementation
-T sets a delay time.
-H: Print help information
When a persistent imr_activator is requested, you may need to save some information, such as startup parameters, positioning information, and working directory actions. You can set the parameters to be saved in a file in the following format:
-P transfers an implrepo_service file name and stores it in ace_configuration_heap mode.
-X is stored in an XML file.
The stored information can be passed as a parameter in tao_imr related to a specific service.
3. Working Process
1) run an implrepo_service.
Only implrepo_service running can instantiate one or more imr_activato required by the application.
2) Select imr_activator
When a service needs to be added to the implementation library or an existing service needs to be updated, a request is sent to implrepo_service through the tao_imr program. As mentioned above, the startup command, working directory, current host of the service, and other information must be passed to implrepo_service through tao_imr. Implrepo_service select imr_activator in the host passed in to activate the corresponding service. If the corresponding imr_activator cannot be selected, it is selected through a certain algorithm. Once an imr_activator is selected, it is also responsible for the lifecycle of the activated service.
3) Execution Service
When imr_activator is selected, implrepo_service sends the relevant request to imr_activator. This imr_activator calls the service to execute the relevant request and updates its database to reflect the latest status of the service.
4. Run and use IMR
Combined with the Implementation repository document of Tao 1.4 (see ace_wrappers/TAO/docs/tutorials/quoter/simple/impl-repo/index.html, in the Linux9.0 environment, I cannot register services according to the steps provided in this document (return the cocould not Register Server . Activator not found !), This is mainly because the intermediate imr_activator process is missing, so this sample cannot run normally. The following processes run in the current directory of the server.
1) first run implrepo_service
$ Tao_root/orbsvcs/implrepo_service-O implrepo. ior-D 0-orbobjrefstyle URL &
2) then run imr_activator.
$ Tao_root/orbsvcs/implrepo_service/imr_activator-orbinitref implreposervice = file: // implrepo. ior &
3) $ tao_root/orbsvcs/implrepo_service/tao_imr-orbinitref implreposervice = file: // implrepo. ior add childpoa-c ". /Server-orbuseimr 1-orbobjrefstyle URL-orbinitref implreposervice = file: // implrepo. ior"
System return:
IMR Activator: Register Server childpoa.
Successfully registered Server
This indicates that the service has been registered successfully.
4) start the service to generate the IOR file and write the stock_factory.ior file.
$ Tao_imr-orbinitref implreposervice = file: // implrepo. ior childpoa-F stock_factory.ior
5) when the application starts, the stock_factory.ior file will be passed out as a parameter and automatically enters the IMR service of the implementation library. if the service is not started, the IMR service of the implementation library will be started.
If a service is no longer used by the application, run the following command to disable it:
$ Tao_imr-orbinitref implreposervice = file: // implrepo. ior
Shutdown childpoa
If a service is no longer used at any time, you can remove it from the IMR database:
$ Tao_imr-orbinitref implreposervice = file: // implrepo. ior
Remove childpoa
6) Client Applications
./Client file: // stock_factory.ior MSFT rhat
Return Value:
The price of a stock in "Microsoft, Inc." is $91
The price of a stock in "RedHat, Inc." is $210
Test the running status of persistent POA and stop the current service:
$ Tao_imr-orbinitref implreposervice = file: // implrepo. ior
Shutdown childpoa
Then run./client file: // stock_factory.ior MSFT rhat.
Return Value:
The price of a stock in "Microsoft, Inc." is $91
The price of a stock in "RedHat, Inc." is $210
The result indicates that the service is stopped, but the client application can call the service through the IMR mechanism.
4. What should I do to implement the Service server in implementing the IMR mechanism?
1. in earlier versions, the implementation library must explicitly use the ir_help class. Now you only need to use the-orbuseimr 1 parameter description.
2. server implementation requires some restrictions. In server, only persistent POA can be supported by IMR, And the PoA name in server can be used as the key of IMR as the entry index. In other words, A server can have only one persistent PoA.
V. Use of the IMR-orbdefaultinitref Parameter
1. A basic (or default) ior is passed as the default parameter by orb. When the resolve_initial_reference method is called, this orb attaches the sevice name to the basic ior to form a complete ior. When such IMR is used, there is a very useful feature, that is, when the IMR's endpoint is used as the basic ior, this IMR can provide many services by calling the resolve_initial_reference method. For example, if an IMR service runs on a host with a Doriath port of 5555, it can be considered that the name service has also been registered on this IMR service.
The application can use the default parameter-orbdefaultinitref to use the name service:
Client-orbdefaultinitref corbaloc: IIOP: Doriath: 5555
When the application calls resolve_initial_reference ("nameservice"), orb will resolve it to "corbaloc: IIOP: Doriath: 5555/nameservice ", in this case, IMR can identify the IOR and locate the actual nameservice as a pointer. Then, start the nameservice service as needed, and connect the application to the name service.
2. Using a service as a default parameter must meet two conditions.
1) The service must be registered with the name called by resolve_initial_reference. For example, the name service must be registered as "nameservice" and contain a POA. The name of this PoA must also be "nameservice"
2) this service must be able to process the name "corbaloc: IIOP: Machine: Port/poa_name"
6. activation mode of the Service Server
1) normal
The default method. The application sends a request and then automatically activates it in tao_imr mode.
2) Manual
Manual mode. Activate by manually using the tao_imr command line
3) per_client
Each application request activates a new service process to start.
Because each client caches the previous reference, a client corresponds to a service. This also has some exceptions. For example, the original ior is used in different threads (each thread obtains different services ). In this mode, the implementation library does not store the information of each started service, so it cannot close the service. Therefore, this service must be disabled.
4) auto_start
The service is automatically started when the database is started. Tao_imr also has an automatic startup command to automatically start all services marked as automatic.
VII. database development in the future:
In the future, the implementation library uses the ORT (Object reference template) technology. This technology allows the implementation library to save the intermediate process of imr_activator. I/O only needs to point to implrepo_service.