Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::acs::container::AcsContainer Class Reference

Collaboration diagram for alma::acs::container::AcsContainer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

ComponentInfo activate_component (int componentHandle, long execution_id, String compName, String exe, String type) throws CannotActivateComponentEx
void set_component_shutdown_order (int[] handleSeq)
void deactivate_components (int[] handles) throws CannotDeactivateComponentEx
org.omg.CORBA.Object restart_component (int compHandle) throws CannotRestartComponentEx
void shutdown (int encryptedAction)
ComponentInfo[] get_component_info (int[] handles)
String name ()
void disconnect ()
AuthenticationData authenticate (long execution_id, String question)
void message (short type, String message)
void taggedmessage (short type, short messageID, String message)
boolean ping ()
void components_available (ComponentInfo[] components)
void components_unavailable (String[] component_names)
LogLevels get_default_logLevels ()
void set_default_logLevels (LogLevels levels) throws IllegalArgumentEx
String[] get_logger_names ()
LogLevels get_logLevels (String logger_name) throws LoggerDoesNotExistEx
void set_logLevels (String logger_name, LogLevels levels) throws LoggerDoesNotExistEx, IllegalArgumentEx
void refresh_logging_config ()

Static Public Attributes

final int CONTAINER_RELOAD = 0
final int CONTAINER_REBOOT = 1
final int CONTAINER_EXIT = 2

Protected Member Functions

void loginToManager () throws AcsJContainerEx

Package Functions

 AcsContainer (String containerName, AcsCorba acsCorba, AcsManagerProxy managerProxy, boolean isEmbedded) throws AcsJContainerEx
void initialize () throws AcsJContainerEx
DAL getCDB ()
void setRecoveryMode (boolean recoveryStart)
void shutdown (int encryptedAction, boolean gracefully, boolean isOrbThread)

Private Member Functions

void registerWithCorba () throws AcsJContainerEx
ComponentAdapter getExistingComponent (int componentHandle, String name, String type)
ComponentHelper createComponentHelper (String compName, String exe, ClassLoader compCL) throws AcsJContainerEx
synchronized ComponentAdapter[] markAndFilterForDeactivation (ComponentAdapter[] compAdapters)
synchronized void abortAllComponents (long maxWaitTimeMillis)
void logManagerRequest (String msgBegin, int[] handles)

Private Attributes

final long startTimeUTClong
final String m_containerName
long executionId = -1
final AcsManagerProxy m_managerProxy
final AcsCorba m_acsCorba
final boolean isEmbedded
final AcsLogger m_logger
final ThreadFactory containerThreadFactory
final ComponentMap m_activeComponentMap
LogConfig logConfig
DAL cdb
final AtomicBoolean shuttingDown = new AtomicBoolean(false)
boolean useRecoveryMode = true

Static Private Attributes

AcsContainer s_instance

Detailed Description

The main container class that interfaces with the maci manager. By extending ContainerPOA, an instance of this class is a corba object that implements the maci container interface.

Only one instance of this class can be created per JVM.

Author:
hsommer created 24-Sep-2002 14:24:48


Constructor & Destructor Documentation

alma::acs::container::AcsContainer::AcsContainer String  containerName,
AcsCorba  acsCorba,
AcsManagerProxy  managerProxy,
boolean  isEmbedded
throws AcsJContainerEx [inline, package]
 

Constructor which creates a container that is registered as a CORBA object, but not yet logged in to the manager (for that, call initialize().

Parameters:
containerName 
acsCorba 
managerProxy 
isEmbedded true if this container runs within an application. Affects shutdown behavior.
Exceptions:
AcsJContainerEx if anything goes wrong, or if another instance of this class has already been created.


Member Function Documentation

synchronized void alma::acs::container::AcsContainer::abortAllComponents long  maxWaitTimeMillis  )  [inline, private]
 

Aborts all components that are not already aborting or already defunct.

This method runs the components' aboutToAbort methods concurrently in separate daemon threads. It returns when all components have been aborted, or when the abortion is timed out after maxWaitTimeMillis.

Parameters:
maxWaitTimeMillis maximum time in milliseconds spent in aboutToAbort of all components.
See also:
ComponentLifecycle#aboutToAbort()

ComponentAdapter#getComponentAbortionist(boolean)

ComponentInfo alma::acs::container::AcsContainer::activate_component int  componentHandle,
long  execution_id,
String  compName,
String  exe,
String  type
throws CannotActivateComponentEx [inline]
 

Activates a component so that it's ready to receive functional calls after returning from this method. Called by the ACS Manager.

From MACI IDL: Activate a component whose type (class) and name (instance) are given. In the process of activation, component's code-base is loaded into memory if it is not there already. The code-base resides in an executable file (usually a dynamic-link library or a shared library -- DLL). On platforms that do not automatically load dependent executables (e.g., VxWorks), the container identifies the dependencies by querying the executable and loads them automatically. Once the code is loaded, it is asked to construct a servant of a given type. The servant is then initialized with the Configuration Database (CDB) and Persistance Database (PDB) data. The servant is attached to the component, and a reference to it is returned.

Parameters:
componentHandle handle of the component that is being activated. This handle is used by the component when it will present itself to the Manager. The component is expected to remember this handle for its entire life-time.
execution_id 
compName name of the component to instantiate (instance name, comes from CDB)
exe component helper implementation class; must be a subclass of alma.acs.container.ComponentHelper.
type the type of the component to instantiate (Corba IR id).
Returns:
Returns the reference to the object that has just been activated. If the component could not the activated, a nil reference is returned.
See also:
si.ijs.maci.ContainerOperations#activate_component(int, String, String, String)

AuthenticationData alma::acs::container::AcsContainer::authenticate long  execution_id,
String  question
[inline]
 

Authentication method. Below some passages from maci.idl:

Method authenticate is the challenge issued to the client after it tries to login. The login will be successful if the client's authenticate() produces the expected result. Only in this case will the Manager's login method return a valid handle, which the client will later use as the id parameter with all calls to the Manager.

The 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).

Container may support recovery. If the container terminates unexpectedly, and then recovers (after a reboot, for example), it logs in to the Manager and notifies it that it supports recovery by responding with "AR" to the Client::authenticate method. The Manager then uses the activate_component method on the container to bring all the components the container used to have back to life.

Returns:
Answer to the question.
See also:
si.ijs.maci.ClientOperations#authenticate(String)

void alma::acs::container::AcsContainer::components_available ComponentInfo[]  components  )  [inline]
 

Notify client about the change (availability) of the components currently in use by this client.

See also:
si.ijs.maci.ClientOperations::components_available(ComponentInfo[])

void alma::acs::container::AcsContainer::components_unavailable String[]  component_names  )  [inline]
 

Notify client that some of the components currently in use by client have become unavailable.

See also:
si.ijs.maci.ClientOperations::components_unavailable(String[])

ComponentHelper alma::acs::container::AcsContainer::createComponentHelper String  compName,
String  exe,
ClassLoader  compCL
throws AcsJContainerEx [inline, private]
 

void alma::acs::container::AcsContainer::deactivate_components int[]  handles  )  throws CannotDeactivateComponentEx [inline]
 

Deactivates all components whose handles are given.

From maci.idl: Deactivation is the inverse process of activation: component is detached from the POA, and thus made unavailable through CORBA, and its resources are freed. If its code-base is no longer used, it is unloaded from memory.

Parameters:
handles a sequence of handles identifying components that are to be released. If null, then all active components will be deactivated!
See also:
si.ijs.maci.ContainerOperations::deactivate_components(int[])

ComponentAdapter::deactivateComponent()

void alma::acs::container::AcsContainer::disconnect  )  [inline]
 

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.

Since ACS 7.0.2, this method returns quickly and uses a different thread to log back in with the manager. This is cleaner than taking a thread from the ORB's pool for a possibly long time, although the manager does not care because this method is defined as oneway in IDL.

See also:
si.ijs.maci.ClientOperations::disconnect()

ComponentInfo [] alma::acs::container::AcsContainer::get_component_info int[]  handles  )  [inline]
 

Returns information about a subset of components that are currently hosted by the Container. Note: If the list of handles is empty, information about all components hosted by the container is returned!

Parameters:
handles 
Returns:
Information about the selected components.
See also:
si.ijs.maci.ContainerOperations::get_component_info(int[])

LogLevels alma::acs::container::AcsContainer::get_default_logLevels  )  [inline]
 

Gets the log levels of the default logging configuration. These levels are used by all loggers that have not been configured individually.

String [] alma::acs::container::AcsContainer::get_logger_names  )  [inline]
 

Gets the names of all loggers, to allow configuring their levels individually. The names are those that appear in the log records in the field "SourceObject". This includes the container logger, ORB logger, component loggers, and (only C++) GlobalLogger.

The returned logger names are randomly ordered.

LogLevels alma::acs::container::AcsContainer::get_logLevels String  logger_name  )  throws LoggerDoesNotExistEx [inline]
 

Gets log levels for a particular named logger. If the returned field LogLevels.useDefault is true, then the logger uses the default levels, see get_default_logLevels(); otherwise the returned local and remote levels apply.

For possible convenience, the default levels are returned in addition to setting LogLevels#useDefault to true.

DAL alma::acs::container::AcsContainer::getCDB  )  [inline, package]
 

Gets a reference to the CDB. Reuses the previously obtained reference. Implemented as on-demand remote call, so always use this method instead of directly accessing the field cdb.

TODO: reuse this CDB reference in ContainerServicesImpl for method getCDB()

Returns:
the CDB reference, or null if it could not be obtained.

ComponentAdapter alma::acs::container::AcsContainer::getExistingComponent int  componentHandle,
String  name,
String  type
[inline, private]
 

Checks if there is an existing component that matches the spec. This can happen if the Manager went down and back up. Strategy:

  • Same handles:
    • reuses component if name and type match;
    • deactivates existing component if name or type don't match; then returns null.
  • Different handles:
    • reuses component if name and type match, with the existing handle (the manager will have to update its handle table)
    • just returns null if name or type don't match; this is the standard case of activating a genuinly new component.
Parameters:
componentHandle 
name 
type 
Returns:
the adapter for an existing component according to the above rules, or null if none exists.

void alma::acs::container::AcsContainer::initialize  )  throws AcsJContainerEx [inline, package]
 

Container initialization such as logging in to the manager, configuring logging, initializing the alarm system. This is taken out of the ctor just to keep is lean and be able to instantiate a minimum container for testing.

Exceptions:
AcsJContainerServicesEx 

void alma::acs::container::AcsContainer::loginToManager  )  throws AcsJContainerEx [inline, protected]
 

Will attempt to log into the manager. If the manager reference is not available, will enter a loop and keep trying. If login fails on an available manager, will throw a AcsJContainerServicesEx.

Exceptions:
AcsJContainerServicesEx 

void alma::acs::container::AcsContainer::logManagerRequest String  msgBegin,
int[]  handles
[inline, private]
 

Logs a request from the manager which involves an array of component handles. (which is quite different from a LogManager request...)

Checks if the handles are valid. If no component can be found for a given handle, the string (unknown) is appended to that handle.

Used simply to avoid code duplication.

Parameters:
msgBegin begin of the log message
handles handles to components that this container should know of

synchronized ComponentAdapter [] alma::acs::container::AcsContainer::markAndFilterForDeactivation ComponentAdapter[]  compAdapters  )  [inline, private]
 

Filters out those components from compAdapters which can be deactivated (not DESTROYING | ABORTING | DEFUNCT).

Must be synchronized to avoid deactivating the same component more than once.

Parameters:
compAdapters 
Returns:
adapters of components that are ready to be deactivated

void alma::acs::container::AcsContainer::message short  type,
String  message
[inline]
 

See also:
si.ijs.maci.ClientOperations#message(short, String)

String alma::acs::container::AcsContainer::name  )  [inline]
 

See also:
si.ijs.maci.ClientOperations::name()

boolean alma::acs::container::AcsContainer::ping  )  [inline]
 

Replies with true so that Manager sees that this container is alive.

Prints a message to System.out, so that it's visible on the local console that the container is doing ok. Does not log anything, because a failure to reply would show up remotely anyway.

No message is printed if the container log level is above INFO, see http://jira.alma.cl/browse/COMP-1736.

See also:
si.ijs.maci.ClientOperations::ping()

void alma::acs::container::AcsContainer::refresh_logging_config  )  [inline]
 

Commands the container or manager to read in again the logging configuration from the CDB and to reconfigure the loggers accordingly. This allows for persistent changes in the logging configuration to become effective, and also for changes of more advanced parameters.

Note that unlike for the logging initialization in initialize(), now we give precedence to the CDB values over any previous settings.

void alma::acs::container::AcsContainer::registerWithCorba  )  throws AcsJContainerEx [inline, private]
 

To be called only once from the ctor.

Exceptions:
AcsJContainerEx 

org.omg.CORBA.Object alma::acs::container::AcsContainer::restart_component int  compHandle  )  throws CannotRestartComponentEx [inline]
 

Not yet implemented. Left for ACS 3.1 (or later...), see comments at http://almasw.hq.eso.org/almasw/bin/view/ACS/NewMaciIdl, e.g. GianlucaChiozzi - 21 Oct 2003 We do not have really clear ideas yet about this. I think that the most accepted ipothesis is that restart of a component means destroy/create while restart of a container means shutdown/restart. For ACS 3.0 I would forget about this issue and leave it for ACS 3.1.

from maci idl: Restarts a component. Returns a new reference of the restarted component.

Parameters:
compHandle Handle of the component to be restarted.
See also:
si.ijs.maci.ContainerOperations::restart_component(int)

void alma::acs::container::AcsContainer::set_component_shutdown_order int[]  handleSeq  )  [inline]
 

Called by the manager to update the container's knowledge about optimum shutdown order of its components. This information will only be needed for a locally initiated container shutdown, since the manager will call deactivate_components(int[]) in a regular shutdown.

void alma::acs::container::AcsContainer::set_default_logLevels LogLevels  levels  )  throws IllegalArgumentEx [inline]
 

Sets the log levels of the default logging configuration. These levels are used by all loggers that have not been configured individually.

void alma::acs::container::AcsContainer::set_logLevels String  logger_name,
LogLevels  levels
throws LoggerDoesNotExistEx, IllegalArgumentEx [inline]
 

Sets log levels for a particular named logger. If levels.useDefault is true, then the logger will be reset to using default levels; otherwise it will use the supplied local and remote levels.

void alma::acs::container::AcsContainer::setRecoveryMode boolean  recoveryStart  )  [inline, package]
 

void alma::acs::container::AcsContainer::shutdown int  encryptedAction,
boolean  gracefully,
boolean  isOrbThread
[inline, package]
 

Shuts down the container.

Depending on the gracefully parameter, either deactivate_components(int[]) or abortAllComponents(long) is called.

This method may be called from the following threads:

  • one of the ORB invocation threads (shutdown initiated by the manager)
  • shutdown thread (Ctrl-C VM hook)
Parameters:
encryptedAction ignored for the time being (always EXIT)
gracefully if true, this method only returns after cleanUp has been called on all components. if false, it returns faster, running the components' abort methods in separate threads for at most 3 seconds.
See also:
shutdown(int)

ShutdownHook

void alma::acs::container::AcsContainer::shutdown int  encryptedAction  )  [inline]
 

Action to take after shutting down (ignored for the time being). Bits 8 thru 15 of this parameter denote the action, which can be one of:

  • 0 -- reload the container
  • 1 -- reboot the computer
  • 2 -- exit the container

The bits 0 thru 7 (values 0 to 255) are the return value that the Container should pass to the operating system. TODO: get rid of this silly bit-multiplexing

See also:
si.ijs.maci.ContainerOperations::shutdown(int)

void alma::acs::container::AcsContainer::taggedmessage short  type,
short  messageID,
String  message
[inline]
 

See also:
si.ijs.maci.ClientOperations#taggedmessage(short, short, String)


Member Data Documentation

DAL alma::acs::container::AcsContainer::cdb [private]
 

Cache for method getCDB(). Don't use this field directly.

final int alma::acs::container::AcsContainer::CONTAINER_EXIT = 2 [static]
 

final int alma::acs::container::AcsContainer::CONTAINER_REBOOT = 1 [static]
 

final int alma::acs::container::AcsContainer::CONTAINER_RELOAD = 0 [static]
 

actions for shutdown()

final ThreadFactory alma::acs::container::AcsContainer::containerThreadFactory [private]
 

long alma::acs::container::AcsContainer::executionId = -1 [private]
 

An ID assigned by the manager at first login. This ID survives logout/login to the manager. For container shutdown/crashes, a new ID is assigned the following login.

final boolean alma::acs::container::AcsContainer::isEmbedded [private]
 

LogConfig alma::acs::container::AcsContainer::logConfig [private]
 

Singleton logging config object shared with ClientLogManager.

final AcsCorba alma::acs::container::AcsContainer::m_acsCorba [private]
 

final ComponentMap alma::acs::container::AcsContainer::m_activeComponentMap [private]
 

final String alma::acs::container::AcsContainer::m_containerName [private]
 

final AcsLogger alma::acs::container::AcsContainer::m_logger [private]
 

final AcsManagerProxy alma::acs::container::AcsContainer::m_managerProxy [private]
 

AcsContainer alma::acs::container::AcsContainer::s_instance [static, private]
 

It's a singleton, but not with a static getAcsContainer() method to restrict access; s_instance is needed to enforce single instantiation.

final AtomicBoolean alma::acs::container::AcsContainer::shuttingDown = new AtomicBoolean(false) [private]
 

final long alma::acs::container::AcsContainer::startTimeUTClong [private]
 

boolean alma::acs::container::AcsContainer::useRecoveryMode = true [private]
 

see comments in authenticate(String)


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:52:24 2009 for ACS Java API by doxygen 1.3.8