PIMR" ("Repository)
is the way to raise availability and to make easier
configuration of interfacing CORBA-services.
Also you can use repository instead of namesevice
To get initial object references to certain services.
Repository registers services in its database and when
gets a request redirects it to the proper service.
Also repository controls availability of registered services
and if necessary tries to restart failed service.f
In this realization (version 1.0.0) repository checks
availability of services periodically in certain time interval.
You can set checking frequency in configuration file by
checkfreq {number} command.
If repository detects service unavailability it tries to revive
the service. If service doesn't send the signal about successful
restart after certain timeout, it is considered as failed and is not
being restarted any more.
Repository provides application programmer with API described by idl-interfaces
From static point of view service is characterized by set of interfacing properties and operations. It's possible that some properties don't need to be defined , so they are presented by the set : {flag, property[, property...]}, where flag defines whether a property is defined or not. If flag is set then properties group is defined and you can use these properties. If according flag is not set, then values of the properties group don't have particular sense (though you can read them).
Service Properties:
corbaloc::127.0.0.1:22000/NameService (Is used to redirect
requests and to control services working capacity in addition to
callback-interface).
IDL:omg.org/CosNaming/NamingContext:1.0.
(Is used to bind CORBA-object to 'servant-bait')
restart_flag.
Flag that controls whether such properties
as restart command and host/port are
available or not. If flag is set it means that
service should be restarted if its unavailability
is detected. The other term fro flag is "always available".
127.0.0.1:22000" or \verb"localhost:22000.
myservice -parameter1 parameter2.
You can see main service states diagram on 1 picture. It shows main states and possible transitions from one to another:
At that transition 8 is forbidden for services with "always available" flag. If "always available" flag isn't set , when repository detects that service is unavailable the service is considered as terminated.
The diagram contains two different transitions from TERMINATED state to RUNS state, and it's not an error, for transitions 1,2,5,6 are executed through additional states (2).
Repository API is presented in pimr.idl file:
#pragma prefix "gradsoft.kiev.ua"
module PIMR
{
interface CheckCallback;
interface Repository
{
exception UnknownServiceName {};
/**
* must be call by client, which know about PIMR after
* startup.
**/
void activated(in string service, in Object instance)
raises(UnknownServiceName);
/**
* we can call checker for service
**/
void setCheck(in string service, in CheckCallback callback)
raises(UnknownServiceName);
};
enum ServiceStatus { Unknown, NotRunning, Correct };
//
interface CheckCallback
{
ServiceStatus checkStatus(in string service);
};
};
#endif
Repository interface
(as well as RepositoryAdmin, defined in PIMRAdmin.idl file)
is implemented by repository CORBA-object, which is available by reference:
corbaloc::repository_host:repository_port/Repository
And CheckCallback is to be implemented in the service that supports
repository. This interface should implement particular CORBA-ping ,
that is service availability checking. At that, activated() or
setCheck() operations can be called by object-service at
startup. These operations inform repository about the object-service
activization . The difference between them is that the first operation
informs repository about (probably changed) location of object-service
and the second one informs about location of the object that implements
CheckCallback interface and belongs to the calling service.
Samples that use these interfaces are in the repository package in verb"demosubdirectory.
Though it's not necessary to call those operation,
for the full repository support after service startup
first you should call activated(myIOR) and then
setCheck(callBack). It guaranties that repository
will know about object-service location and will be
able to check its availability.
When using services which implement partial repository support its possible that repository has correct reference to service but incorrect reference to callback-interface (or the other way round). In that case service will be considered as unavailable.
Repository and object-service interaction is possible as follows:
activated(*)
but doesn't implement CheckCallback interface.
CheckCallback interface
(and possibly calls setCallback(*) after startup,
otherwise someone should report service Callback interface reference to repository) but
doesn't use activated(*). In this case someone should report object-service
reference to repository.
CheckCallback interface
(and possibly calls setCallback(*) after startup,
otherwise someone should report service reference to repository)
and calls activated() after startup.
restart_flag (or "always available" flag)
and repository will restart it if detects that service is unavailable.
Be careful when combining several interaction cases of the same service, for the situation is possible, when repository has correct object-service reference and incorrect callback-interface reference. Such service will be unavailable.
Preliminary conditions: repository is running. It's supposed that service is registered at the repository, repository received object reference to service. In such case service will available by the reference:
corbaloc::repository_host:repository_port/required_service_name
Client sends request using this corbaloc. Client orb connects to repository and transmits the request. Client orb receives:
Implementation details:
Client orb connects to repository and transmits request.
Repository uses dynamic servant - bait to associate it with
object available by the references described above.
And so repository orb redirects client request to servant - bait,
but request is caught by interceptor. Interceptor extracts имя_сервиса,
contained in the request, then obtains service information from internal register.
Depending on this information interceptor may execute certain operations with
service, according to repository functioning algorithm, before
redirecttimeout will be exceeded.
Then interceptor returns the result to client.
For better understanding study samples from "demodirectory of repository package.