T - The event (base) type. If all events published by an instance of this class are of the same type,
e.g., MyEventStructFromIDL, then that type should be used;
otherwise the common base type IDLEntity should be used. T extends IDLEntity
because of ArchiveSupplier which extends NCPublisher<Object>.public class NCPublisher<T> extends OSPushSupplierPOA implements AcsEventPublisher<T>, ReconnectableParticipant
SimpleSupplier class,
to integrate its functionality into the ContainerServices and and to allow
using transport mechanisms other than Corba NC under the hood.
Design note on CORBA usage (generally not relevant to ACS NC users): The IDL-struct-data is wrapped by a corba Any, but then pushed on the notification channel inside a "Structured Event" (with the Any object in StructuredEvent#filterable_data[0]). Don't confuse this with Corba's option of sending events directly as Anys. As of 2006-12, HSO is not sure why this complex design was chosen, instead of using structured events without the Any wrapping inside. Possibly it offers some flexibility for generic consumer tools written in languages that have no introspection.
Note about refactoring: NCPublisher gets instantiated in module jcont using java reflection.
Thus if you change the package, name, or constructor of this class,
make sure to fix ContainerServicesImpl.CLASSNAME_NC_PUBLISHER
or its use to get the constructor.
AcsEventPublisher.EventProcessingHandler<U>| Modifier and Type | Field and Description |
|---|---|
protected alma.acs.nc.AnyAide |
anyAide
Helper class used to manipulate CORBA anys
|
protected EventChannel |
channel
Channel we'll be sending events to.
|
protected java.lang.String |
channelName
The event channel has exactly one name registered in the naming service.
|
protected java.lang.String |
channelNotifyServiceDomainName
The channel notification service domain name, can be
null. |
protected java.util.concurrent.atomic.AtomicLong |
count
The total number of successful events published by this particular
supplier.
|
protected AcsEventPublisher.EventProcessingHandler<T> |
eventProcessingHandler
Optional event processing handler.
|
protected CircularQueue<T> |
eventQueue
If the user registers
eventProcessingHandler, then we also create this queue;
otherwise it remains null. |
protected java.lang.Object |
eventQueueSync
Monitor for access to
eventQueue and eventProcessingHandler. |
protected Helper |
helper
Provides code shared among suppliers and consumers.
|
protected java.util.logging.Logger |
logger
Provides access to the ACS logging system.
|
protected StructuredProxyPushConsumer |
proxyConsumer
The server-side proxy consumer object used by this supplier to push events onto the channel.
|
protected AcsNcReconnectionCallback |
reconnectCallback |
protected ContainerServicesBase |
services
To access the ORB among other things
|
protected SupplierAdmin |
supplierAdmin
Supplier Admin object is responsible for creating & managing proxy consumers.
|
| Constructor and Description |
|---|
NCPublisher(java.lang.String channelName,
ContainerServicesBase services,
org.omg.CosNaming.NamingContext namingService)
Creates a new instance of NCPublisher.
|
NCPublisher(java.lang.String channelName,
java.lang.String channelNotifyServiceDomainName,
ContainerServicesBase services,
org.omg.CosNaming.NamingContext namingService)
Creates a new instance of NCPublisher.
|
| Modifier and Type | Method and Description |
|---|---|
void |
disconnect_structured_push_supplier()
The CORBA NC spec (3.3.10.1) says:
"The disconnect_structured_push_supplier operation is invoked to
terminate a connection between the target StructuredPushSupplier
and its associated consumer.
|
void |
disconnect()
User code must call this method when the Supplier is no longer useful.
|
void |
enableEventQueue(int queueSize,
AcsEventPublisher.EventProcessingHandler<T> handler)
Enables using a queue for published events.
|
protected StructuredEvent |
getCORBAEvent(java.lang.String typeName,
java.lang.String eventName)
Method used to create a pre-filled CORBA event.
|
int |
getEventBufferSize() |
protected java.lang.String |
getNotificationFactoryName()
This method returns the notify service name as registered with the
CORBA Naming Service.
|
boolean |
increaseEventBufferSize(int bufferSize)
Increase the event buffer size
|
protected void |
init(org.omg.CosNaming.NamingContext namingService)
Initializes NCPublisher
|
protected void |
publishCORBAEvent(StructuredEvent se,
T customData)
Method which publishes an entire CORBA StructuredEvent without making any
modifications to it.
|
void |
publishEvent(T customStruct)
Takes the given Java object and tries to pack it into a CORBA Any and
publish it to the notification channel.
|
protected void |
queueUnpublishedEvent(StructuredEvent se,
T customData)
Method which queue an event that couldn't be published
|
void |
reconnect(EventChannelFactory ecf) |
void |
setAutoreconnect(boolean autoreconnect)
This method sets the attribute autoreconnect which is used to determine if
a reconnection to the channel must be done when the exception OBJECT_NOT_EXIST
is thrown during the publication of an event.
|
void |
setEventProcessingHandler(AcsEventPublisher.EventProcessingHandler<T> handler)
Sets the event processing handler
|
void |
subscription_change(EventType[] added,
EventType[] removed)
This method gets called by the CORBA framework to notify us that the subscriber
situation has changed.
|
protected Helper helper
protected final java.lang.String channelName
protected final java.lang.String channelNotifyServiceDomainName
null.protected SupplierAdmin supplierAdmin
protected StructuredProxyPushConsumer proxyConsumer
protected final java.util.concurrent.atomic.AtomicLong count
protected EventChannel channel
protected final java.util.logging.Logger logger
protected final ContainerServicesBase services
protected final alma.acs.nc.AnyAide anyAide
protected AcsNcReconnectionCallback reconnectCallback
protected AcsEventPublisher.EventProcessingHandler<T> eventProcessingHandler
null.#registerEventProcessingCallback(alma.acs.nc.AcsEventPublisher.EventProcessingHandler)protected CircularQueue<T> eventQueue
eventProcessingHandler, then we also create this queue;
otherwise it remains null.
The queue stores events during Notify Service failures, to allow re-sending them later. The re-sending is implemented in a rather simple way, without using a separate timer and thread; future attempts to publish other events simply check if the queue contains older events, which then get sent first.
protected final java.lang.Object eventQueueSync
eventQueue and eventProcessingHandler.
We assume that compared to the Corba transport of events the overhead to synchronize threads using this object is negligible, so that we don't bother with fancier synchronization techniques.
public NCPublisher(java.lang.String channelName,
ContainerServicesBase services,
org.omg.CosNaming.NamingContext namingService)
throws AcsJException
disconnect() when you no longer need this event supplier object.channelName - Name of the notification channel events will be published to.services - This is used to get the name of the component and to access
the ACS logging system.AcsJException - There are literally dozens of CORBA exceptions that could be
thrown by the NCPublisher class. Instead, these are converted
into an ACS Error System exception for the developer's
convenience.public NCPublisher(java.lang.String channelName,
java.lang.String channelNotifyServiceDomainName,
ContainerServicesBase services,
org.omg.CosNaming.NamingContext namingService)
throws AcsJException
disconnect() when you no longer need this event supplier object.channelName - name of the notification channel events will be published to.channelNotifyServiceDomainName - Channel domain name, which is being used to determine
notification service.services - This is used to get the name of the component and to access
the ACS logging system.AcsJException - There are literally dozens of CORBA exceptions that could be
thrown by the NCPublisher class. Instead, these are
converted into an ACS Error System exception for the
developer's convenience.protected void init(org.omg.CosNaming.NamingContext namingService)
throws AcsJException
namingService - Naming serviceAcsJException - There are literally dozens of CORBA exceptions that could be
thrown by the NCPublisher class. Instead, these are
converted into an ACS Error System exception for the
developer's convenience.public void disconnect()
throws AcsJIllegalStateEventEx
disconnect in interface AcsEventPublisher<T>AcsJIllegalStateEventEx - if called when already disconnected.protected java.lang.String getNotificationFactoryName()
public void setAutoreconnect(boolean autoreconnect)
autoreconnect - Whether autoreconneting to the channel should be donepublic void subscription_change(EventType[] added,
EventType[] removed)
throws InvalidEventType
ACS does not provide an implementation of this method. Probably because of not fully understanding the possibilities of the obtain_subscription_types call (see c'tor above) in the past, we assumed that a supplier could not know whether there is more than one subscriber listening for a given event type on our NC, so that the subscription_change information coming from a single subscriber would not be good enough to make us drop certain event types on the supplier side.
InvalidEventTypeorg.omg.CosNotifyComm.NotifySubscribeOperations#subscription_change(org.omg.CosNotification.EventType[],
org.omg.CosNotification.EventType[])public void disconnect_structured_push_supplier()
protected void queueUnpublishedEvent(StructuredEvent se,
T customData)
se - A complete structured eventcustomData - The user-supplied event data, needed for eventProcessingHandler notification.protected void publishCORBAEvent(StructuredEvent se,
T customData)
throws AcsJException
se - A complete structured eventcustomData - The user-supplied event data, needed for eventProcessingHandler notification.AcsJException - if the event cannot be published for some reason or another.protected StructuredEvent getCORBAEvent(java.lang.String typeName,
java.lang.String eventName)
typeName - The structured event's type_name.eventName - Name of the event.public void publishEvent(T customStruct) throws AcsJException
publishEvent in interface AcsEventPublisher<T>customStruct - An instance of the IDL struct (Java class) to be published.AcsJPublishEventFailureEx - If customStruct is not an IDL struct,
for which it must be a subclass of IDLEntity.AcsJException - There are an enormous amount of possibilities pertaining to
why an AcsJException would be thrown by publishEvent.public void reconnect(EventChannelFactory ecf)
reconnect in interface ReconnectableParticipantecf - The new EventChannelFactory reference as delivered by the NotifyService's callback.public void enableEventQueue(int queueSize,
AcsEventPublisher.EventProcessingHandler<T> handler)
AcsEventPublisher
As of ACS 10.1, only a missing NotifyService as diagnosed through
a org.omg.CORBA.TRANSIENT exception will cause the publisher
to store an event in this queue for later re-sending.
enableEventQueue in interface AcsEventPublisher<T>queueSize - Number of events that this queue should store.
The choice is a tradeoff between memory use and data loss.handler - The handler that should be notified by the publisher.public boolean increaseEventBufferSize(int bufferSize)
AcsEventPublisherincreaseEventBufferSize in interface AcsEventPublisher<T>bufferSize - new event buffer sizepublic int getEventBufferSize()
getEventBufferSize in interface AcsEventPublisher<T>public void setEventProcessingHandler(AcsEventPublisher.EventProcessingHandler<T> handler)
AcsEventPublishersetEventProcessingHandler in interface AcsEventPublisher<T>handler - event processing handler