| |
- maci__POA.Client(omniORB.PortableServer.Servant)
-
- BaseClient
- threading.Thread(threading._Verbose)
-
- ManagerAsyncConnector
class BaseClient(maci__POA.Client) |
|
BaseClient class is an implementation of the MACI Client IDL interface in
Python. |
|
- Method resolution order:
- BaseClient
- maci__POA.Client
- omniORB.PortableServer.Servant
- __builtin__.object
Methods defined here:
- __init__(self, name='Python Client')
- Initialize the client.
Parameters:
- name is what manager will refer to this client instance as
Returns: Nothing
Raises: CORBAProblemExImpl
- authenticate(self, execution_id, question)
- Authentication method. Method authenticate is the challenge issued to
the client after it tries to login. The login will be successful if the
clients authenticate() produces the expected result. Only in this case
will the Managers login method return a valid handle, which the client
will later use as the id parameter with all calls to the Manager.
Parameters: question this string does not currently matter
Return Answer - first character of the answer identifies the type of
the client, and can be one of:
- C = a regular client (implements just the Client interface).
- A = a container (implements the Container interface).
- AR = a container with recovery capability (implements the Container interface).
- S = Supervisor (implements the Administrator interface).
Raises: Nothing
string authenticate (in string question);
- components_available(self, components)
- Notify client about the change (availability) of the components currently
in use by this client. For administrative clients, notification is issued
for the change of availability of any component in the domain.
Parameters:
- components is a sequence of ComponentInfo structures
Returns: None
Raises: Nothing
oneway void components_available(in ComponentInfoSeq components)
- components_unavailable(self, component_names)
- Notify client that some of the Components currently in use by client
have become unavailable.
Parameters:
- component_names names of various unavailable components
Returns: None
Raises: Nothing
oneway void Components_unavailable (in stringSeq component_names)
- disconnect(self)
- Disconnect notification. The disconnect method is called by the Manager
to notify the client that it will be unavailable and that the client
should log off.
Also, the client developer is required to disconnect all connected clients
before exiting the Python interpreter.
Parameters: None
Returns: None
Raises: Nothing
oneway void disconnect ();
- getCode(self)
- Returns the code to be used when manager tries to authenticate this
object
Parameters: None
Returns: the code to be returned to manager.
Raises: Nothing
- getMyCorbaRef(self)
- Helper method which returns this Python objects underlying CORBA servant
reference.
This implementation implicityly activates the client using the default
POA if it has not been activated before.
Parameters: None
Returns: a CORBA reference to this object
Raises: CORBAProblemExImpl
- isLoggedIn(self)
- Returns True is the client is logged into the manager
and False otherwise
Parameters: None
Raises: Nothing
- managerLogin(self)
- Login into the manager
Parameters: None
Returns: The token received from the manager
Raises: CORBAProblemExImpl If the login failed
- managerLogout(self)
- Logout from manager
Parameters: None
Returns: None
Raises: Nothing
- message(self, message_type, message)
- The Manager and administrators use this method for sending textual messages
to the client.
This implementation first attempts to use the ACS logging mechanism to
display the message and if that fails for any reason, it is only sent
to standard out.
Parameters:
- message_type is an integer defined as a constant in the Client interface
- message is a string
Returns: Nothing
Raises: Nothing
oneway void message (in short message_type, in string message)
- ping(self)
- Manager pings its clients to verify they still exist.
Parameters: None
Returns: CORBA.TRUE (i.e., 1)
Raises: Nothing
boolean ping ();
- setToken(self, newToken)
- This method is called by the thread when it tries to
reconnect to the manager.
This method does not do anything if the connection failed:
it must be overridden to customize (the Container wants to terminate
in that case for example).
Parameters: newToken The newToken returned by the manager
A value of None means that the thread failed to reconnect
Returns None
Raises: Nothing
Data descriptors inherited from omniORB.PortableServer.Servant:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class ManagerAsyncConnector(threading.Thread) |
|
Objects of this class asynchronously login the client passed in the constructor
into the manager.
The ManagerAsyncConnector should be used to log in into the manager in the following way:
1. instantiate the object passing the number of attempts to connect (0 means try forever)
2. start the thread
Before terminating, the thread invokes setToken to the BaseClien: if the token is None, it means
that the it was unable to connect and it is up to the client to decide how to handle
the failure.
terminateThread() force the thread to terminate. It is safer to
start the thread as daemon. |
|
- Method resolution order:
- ManagerAsyncConnector
- threading.Thread
- threading._Verbose
- __builtin__.object
Methods defined here:
- __init__(self, client, logger, attempts=0)
- Initialize the class
Parameters: attempts The number of attempts to get the manager reference
If it is 0 then it keep trying forever
It must be a positive number
client The BaseClient to login into the manager
logger: The logger
Returns: None
Raises: Nothing
- getToken(self)
- Returns the token assigned by the manager after logging in
or None if the object failed to log in into the manager
- run(self)
- The thread that wait until it gets the manager reference
- sleepCheckingTermination(self, nSecs)
- Helper method that returns after nSecs but checking
the termination every 0.5 seconds
- terminateThread(self)
- Tell the thread to terminate at the next iteration
Methods inherited from threading.Thread:
- __repr__(self)
- getName(self)
- isAlive(self)
- Return whether the thread is alive.
This method returns True just before the run() method starts until just
after the run() method terminates. The module function enumerate()
returns a list of all alive threads.
- isDaemon(self)
- is_alive = isAlive(self)
- Return whether the thread is alive.
This method returns True just before the run() method starts until just
after the run() method terminates. The module function enumerate()
returns a list of all alive threads.
- join(self, timeout=None)
- Wait until the thread terminates.
This blocks the calling thread until the thread whose join() method is
called terminates -- either normally or through an unhandled exception
or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a
floating point number specifying a timeout for the operation in seconds
(or fractions thereof). As join() always returns None, you must call
isAlive() after join() to decide whether a timeout happened -- if the
thread is still alive, the join() call timed out.
When the timeout argument is not present or None, the operation will
block until the thread terminates.
A thread can be join()ed many times.
join() raises a RuntimeError if an attempt is made to join the current
thread as that would cause a deadlock. It is also an error to join() a
thread before it has been started and attempts to do so raises the same
exception.
- setDaemon(self, daemonic)
- setName(self, name)
- start(self)
- Start the thread's activity.
It must be called at most once per thread object. It arranges for the
object's run() method to be invoked in a separate thread of control.
This method will raise a RuntimeError if called more than once on the
same thread object.
Data descriptors inherited from threading.Thread:
- daemon
- A boolean value indicating whether this thread is a daemon thread (True) or not (False).
This must be set before start() is called, otherwise RuntimeError is
raised. Its initial value is inherited from the creating thread; the
main thread is not a daemon thread and therefore all threads created in
the main thread default to daemon = False.
The entire Python program exits when no alive non-daemon threads are
left.
- ident
- Thread identifier of this thread or None if it has not been started.
This is a nonzero integer. See the thread.get_ident() function. Thread
identifiers may be recycled when a thread exits and another thread is
created. The identifier is available even after the thread has exited.
- name
- A string used for identification purposes only.
It has no semantics. Multiple threads may be given the same name. The
initial name is set by the constructor.
Data descriptors inherited from threading._Verbose:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |