alma::acs::nc::Helper Class Reference

Inheritance diagram for alma::acs::nc::Helper:
Inheritance graph
[legend]
Collaboration diagram for alma::acs::nc::Helper:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Helper (ContainerServicesBase services) throws AcsJException
ContainerServicesBase getContainerServices ()
NamingContext getNamingService ()
EventChannel getNotificationChannel (EventChannelFactory ecf)
EventChannel getNotificationChannel (String channelName, String channelKind, String notifyFactoryName) throws AcsJException
ChannelProperties getChannelProperties ()
String getNotificationFactoryNameForChannel (String channelName)
String getNotificationFactoryNameForChannel (String channelName, String domainName)
HashMap< String, Double > getEventHandlerTimeoutMap (String channelName)
EventChannelFactory getNotifyFactory ()

Protected Member Functions

NamingContext getNamingServiceInitial () throws AcsJException
void initializeNotifyFactory (String notifyFactoryName) throws AcsJException
EventChannel createNotificationChannel (String channelName, String channelKind, String notifyFactoryName) throws AcsJException, NameAlreadyUsed, NameMapError
EventChannel createNotifyChannel_internal (EventChannelFactory notifyFactory, Property[] initial_qos, Property[] initial_admin, String channelName, IntHolder channelIdHolder) throws UnsupportedAdmin, NameAlreadyUsed, UnsupportedQoS, NameMapError
void destroyNotificationChannel (String channelName, String channelKind, EventChannel channelRef) throws AcsJException

Protected Attributes

final Logger m_logger

Private Attributes

final NamingContext m_nContext
final ContainerServicesBase m_services
final ChannelProperties m_channelProperties
final CDBAccess m_cdbAccess
DAOProxy channelsDAO
int channelId
EventChannelFactory notifyFactory
final Map< String, Long > channelConfigProblems = new HashMap<String, Long>()
String channelName

Static Private Attributes

static final String m_nameJavaProp = "ORBInitRef.NameService"

Detailed Description

This class provides methods useful to both supplier and consumer objects.


Constructor & Destructor Documentation

alma::acs::nc::Helper::Helper ( ContainerServicesBase  services  )  throws AcsJException [inline]

Creates a new instance of Helper, which includes resolving the naming service.

Parameters:
services A reference to the ContainerServices
Exceptions:
AcsJException Generic ACS exception will be thrown if anything in this class is broken.

References getContainerServices(), alma::acs::container::ContainerServicesBase::getLogger(), getNamingServiceInitial(), m_cdbAccess, m_channelProperties, m_logger, m_nContext, m_services, com::cosylab::cdb::client::CDBAccess::setDAL(), and alma::ACSErrTypeCommon::wrappers::AcsJBadParameterEx::setReason().


Member Function Documentation

EventChannel alma::acs::nc::Helper::createNotificationChannel ( String  channelName,
String  channelKind,
String  notifyFactoryName 
) throws AcsJException, NameAlreadyUsed, NameMapError [inline, protected]

Tries to create a notification channel (using quality of service and administrative properties specified by configQofS() and configAdminProps() respectively). If this succeeds, then registers this channel with the naming service.

Should only be invoked when the channel that this supplier or consumer is attempting to connect to does not exist. However even with prior check for the existence of this channel, a race condition with other suppliers or consumers can lead to multiple attempts to create the same channel, which will result in NameAlreadyUsed exception.

Design note: Currently the TAO notification extensions are used to synch channel creation with other clients by supplying the channel name to the factory. If we want to use only standard NC factories then we'd have to implement our own locking mechanisms in all ACS consumer and supplier classes, see http://jira.alma.cl/browse/COMP-2808

Returns:
Reference to the newly created channel.
Parameters:
channelName Name of the channel to create.
channelKind Kind of the channel as registered with the CORBA naming service.
notifyFactoryName Name of the notification service as registered with the CORBA naming service.
Exceptions:
AcsJException Standard ACS Java exception.
NameMapError ( check in TAO code what this means!)
NameAlreadyUsed thrown if the channel of this name already exists.

References alma::ACSErrTypeCommon::wrappers::AcsJCORBAProblemEx::AcsJCORBAProblemEx(), channelId, channelName, alma::acs::nc::ChannelProperties::configAdminProps(), alma::acs::nc::ChannelProperties::configQofS(), createNotifyChannel_internal(), getNamingService(), initializeNotifyFactory(), m_channelProperties, m_logger, notifyFactory, and alma::ACSErrTypeCommon::wrappers::AcsJCORBAProblemEx::setInfo().

Referenced by getNotificationChannel().

EventChannel alma::acs::nc::Helper::createNotifyChannel_internal ( EventChannelFactory  notifyFactory,
Property[]  initial_qos,
Property[]  initial_admin,
String  channelName,
IntHolder  channelIdHolder 
) throws UnsupportedAdmin, NameAlreadyUsed, UnsupportedQoS, NameMapError [inline, protected]

Broken out from createNotificationChannel(String, String, String) to give tests better control about the timing when this call to the event factory is made.

Reimplemented in alma::acs::nc::HelperTest::HelperWithChannelCreationSynch.

References channelName, gov::sandia::NotifyMonitoringExt::EventChannelFactoryOperations::create_named_channel(), and notifyFactory.

Referenced by createNotificationChannel().

void alma::acs::nc::Helper::destroyNotificationChannel ( String  channelName,
String  channelKind,
EventChannel  channelRef 
) throws AcsJException [inline, protected]

Destroys the channel and unregisters it from the naming service. ONLY USE THIS METHOD IF YOU KNOW FOR CERTAIN THERE IS ONLY ONE SUPPLIER FOR THE CHANNEL!!! Use this method with extreme caution as it's likely to become deprecated in future versions of ACS!

Parameters:
channelName name of the channel as registered int the CORBA notification service
channelKind Kind of the channel as registered with the CORBA naming service.
channelRef reference to the channel being destroyed
Exceptions:
AcsJException Thrown when the channel isn't registered with the Naming Service.
Warning:
this method assumes

References channelName, getNamingService(), and m_logger.

Referenced by alma::acs::nc::ConsumerWithComponentClientTestCaseTest::channelDown(), alma::acs::nc::SimpleSupplier::destroyNotificationChannel(), alma::acs::nc::HelperTest::testConcurrentChannelCreation(), alma::acs::nc::HelperTest::testConcurrentChannelRetrieval(), and alma::acs::nc::HelperTest::testCreateChannel().

ChannelProperties alma::acs::nc::Helper::getChannelProperties (  )  [inline]
ContainerServicesBase alma::acs::nc::Helper::getContainerServices (  )  [inline]

Returns a reference to the Container Services which are provided by a container or client.

Returns:
A valid reference to the ContainerServices instance.

References m_services.

Referenced by alma::acs::nc::Consumer::disconnect(), getNamingServiceInitial(), and Helper().

HashMap<String, Double> alma::acs::nc::Helper::getEventHandlerTimeoutMap ( String  channelName  )  [inline]

The following returns a map where each key is the name of an event and the value is the maximum amount of time (in floating point seconds) an event receiver has to process the event before a warning message is logged.

Parameters:
channelName name of the channel
Returns:
HashMap described above

References alma::acs::container::ContainerServicesBase::getCDB(), m_logger, and m_services.

NamingContext alma::acs::nc::Helper::getNamingService (  )  [inline]
NamingContext alma::acs::nc::Helper::getNamingServiceInitial (  )  throws AcsJException [inline, protected]

Retrieves and returns a reference to the Naming Service. This code belongs to the constructor and should only be called from there.

This method is protected to support unit tests, otherwise it would be private.

: The dependence of NC libs on the NamingService should be expressed in a less hidden form than using a property, which leads to dangerous runtime-only failures if missing. It would already be an improvement if we would obtain the NamingService reference from AdvancedContainerServices#getORB(). A more radical change would be to integrate the NC classes into the ContainerServices.

Returns:
Valid reference to the Naming Service.
Exceptions:
AcsJException Thrown when there's a bad corbaloc given for the Naming Service or the reference cannot be narrowed.
See also:
getNamingService()

References alma::acs::container::AdvancedContainerServices::corbaObjectFromString(), alma::acs::container::ContainerServicesBase::getAdvancedContainerServices(), getContainerServices(), m_nameJavaProp, and alma::ACSErrTypeCommon::wrappers::AcsJBadParameterEx::setReason().

Referenced by Helper().

EventChannel alma::acs::nc::Helper::getNotificationChannel ( String  channelName,
String  channelKind,
String  notifyFactoryName 
) throws AcsJException [inline]

This method gets a reference to the event channel. If it is not already registered with the naming service, it is created.

Make "protected" again once we no longer have NC classes in separate subpackge "refactored".

Returns:
Reference to the event channel specified by channelName.
Parameters:
channelName Name of the event channel registered with the CORBA Naming Service
channelKind Kind of the channel as registered with the CORBA naming service ("channels").
notifyFactoryName Name of the notification service as registered with the CORBA naming service.
Exceptions:
AcsJException Standard ACS Java exception.

References channelName, createNotificationChannel(), getNamingService(), initializeNotifyFactory(), m_logger, and alma::ACSErrTypeCommon::wrappers::AcsJGenericErrorEx::setErrorDesc().

EventChannel alma::acs::nc::Helper::getNotificationChannel ( EventChannelFactory  ecf  )  [inline]
String alma::acs::nc::Helper::getNotificationFactoryNameForChannel ( String  channelName,
String  domainName 
) [inline]

Gets the notification channel factory name for the given channel/domain.

Tries to use the optional mapping from the CDB, otherwise uses "NotifyEventChannelFactory".

Parameters:
channelName name of the channel.
domainName name of the domain, null if undefined.
Returns:
notification channel factory name.

References channelConfigProblems, channelsDAO, com::cosylab::cdb::client::CDBAccess::createDAO(), com::cosylab::cdb::client::DAOProxy::get_string(), com::cosylab::cdb::client::DAOProxy::get_string_seq(), m_cdbAccess, and m_logger.

String alma::acs::nc::Helper::getNotificationFactoryNameForChannel ( String  channelName  )  [inline]
EventChannelFactory alma::acs::nc::Helper::getNotifyFactory (  )  [inline]
void alma::acs::nc::Helper::initializeNotifyFactory ( String  notifyFactoryName  )  throws AcsJException [inline, protected]

Member Data Documentation

final Map<String, Long> alma::acs::nc::Helper::channelConfigProblems = new HashMap<String, Long>() [private]

Map that's used similar to a log repeat guard, because the OMC was flooded with NC config problem logs (as of 2008-03-06).

key = channel name; value = timestamp in ms when config error was found for the given channel.

Referenced by getNotificationFactoryNameForChannel().

final Logger alma::acs::nc::Helper::m_logger [protected]
final String alma::acs::nc::Helper::m_nameJavaProp = "ORBInitRef.NameService" [static, private]

Java property name for the CORBA Naming Service corbaloc. This property is set in the acsstartup :: acsStartJava.

: Check if we can eliminate this property if we use something similar as in jmanager's com.cosylab.acs.maci.plug.NamingServiceRemoteDirectory.

Referenced by getNamingServiceInitial().

final NamingContext alma::acs::nc::Helper::m_nContext [private]

In a running system, there can be only one reference to the Naming Service.

Referenced by getNamingService(), and Helper().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2