com.prosysopc.ua.server
Class SubscriptionManager

java.lang.Object
  extended by com.prosysopc.ua.server.SubscriptionManager

public class SubscriptionManager
extends Object

A standard implementation of the subscription manager of an OPC UA client. The subscription manager requires a NodeManager which it uses to locate the nodes.


Field Summary
protected  List<SubscriptionManagerListener> listeners
           
protected  NodeManagerTable nodeManagerTable
           
protected  SessionManager sessionManager
           
 
Constructor Summary
SubscriptionManager(SessionManager sessionManager, NodeManagerTable nodeManagerTable)
           
 
Method Summary
protected  void acknowledge(ServiceContext serviceContext, org.opcfoundation.ua.core.PublishRequest request, org.opcfoundation.ua.core.PublishResponse response)
           
protected  void acknowledgeSubscriptions(ServiceContext serviceContext, org.opcfoundation.ua.core.SubscriptionAcknowledgement[] acks, org.opcfoundation.ua.builtintypes.StatusCode[] results, org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnostics)
           
 void addListener(SubscriptionManagerListener listener)
          Add a new SubscriptionManagerListener.
protected  SubscriptionBase addSubscription(ServiceContext serviceContext, org.opcfoundation.ua.core.CreateSubscriptionRequest request)
          Add a new subscription.
protected  void addTriggeringLink(Subscription s, MonitoredItemBase triggeringItem, org.opcfoundation.ua.builtintypes.UnsignedInteger linkToAdd)
           
protected  org.opcfoundation.ua.utils.NumericRange checkIndexRangeForMonitoredItem(String indexRange, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
           
protected  void checkSession(ServiceContext serviceContext, Subscription subscription)
           
protected  void close()
           
protected  MonitoredDataItem createMonitoredDataItem(ServiceContext serviceContext, Subscription subscription, org.opcfoundation.ua.core.MonitoredItemCreateRequest itemToCreate, org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn, org.opcfoundation.ua.core.MonitoringFilter filter)
           
protected  MonitoredItem createMonitoredEventItem(ServiceContext serviceContext, Subscription subscription, org.opcfoundation.ua.core.MonitoredItemCreateRequest itemToCreate, org.opcfoundation.ua.core.EventFilter eventFilter)
           
protected  MonitoredItem createMonitoredItem(ServiceContext serviceContext, Subscription subscription, org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn, org.opcfoundation.ua.core.MonitoredItemCreateRequest itemToCreate)
           
protected  MonitoredItemBase deleteMonitoredItem(ServiceContext serviceContext, Subscription subscription, org.opcfoundation.ua.builtintypes.UnsignedInteger itemId)
           
protected  void finalize()
           
 int getMaxNotificationsPerPublish()
          The limit for the maximum number of notifications parameter which is defined per subscription.
 double getMaxPublishingInterval()
           
 int getMaxPublishRequestCount()
           
 int getMaxRetransmissionQueueSize()
          The maximum number of notification messages to keep in the retransmit queue, which is used to enable Republish calls from the client.
 double getMaxSamplingInterval()
           
 int getMaxSubscriptionCount()
          Maximum number of concurrent subscriptions per session.
 double getMinPublishingInterval()
           
 double getMinSamplingInterval()
           
protected  Subscription getNextSubscriptionToPublish(ServiceContext serviceContext, long timeoutHint)
          Find the next subscription from the publish queue
 NodeManagerTable getNodeManagerTable()
           
protected  BlockingQueue<SubscriptionBase> getPublishQueue(Session session)
           
 SessionManager getSessionManager()
           
 Subscription getSubscription(org.opcfoundation.ua.builtintypes.UnsignedInteger subscriptionId)
          Find the subscription by a subscriptionId
 int getSubscriptionCount()
          Number of managed subscriptions.
 boolean hasListener(SubscriptionManagerListener listener)
          Check if the manager already has the specified listener.
 boolean isRunning()
           
protected  MonitoredItem modifyMonitoredItem(ServiceContext serviceContext, Subscription subscription, org.opcfoundation.ua.core.MonitoredItemModifyRequest request, org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn, org.opcfoundation.ua.core.MonitoringParameters params)
           
protected  SubscriptionBase modifySubscription(ServiceContext serviceContext, org.opcfoundation.ua.core.ModifySubscriptionRequest request)
           
protected  org.opcfoundation.ua.builtintypes.UnsignedInteger nextSubscriptionId()
          Find the next Subscription ID.
protected  void publish(ServiceContext serviceContext, org.opcfoundation.ua.core.PublishRequest request, org.opcfoundation.ua.core.PublishResponse response)
           
 void removeListener(SubscriptionManagerListener listener)
          Remove a SubscriptionManagerListener.
protected  void removeSubscription(ServiceContext serviceContext, Subscription subscription, boolean removeFromQueue)
           
protected  void removeTriggeringLink(SubscriptionBase s, MonitoredItemBase triggeringItem, org.opcfoundation.ua.builtintypes.UnsignedInteger linkToRemove)
           
protected  void republish(ServiceContext serviceContext, org.opcfoundation.ua.core.RepublishRequest request, org.opcfoundation.ua.core.RepublishResponse response)
           
 void setMaxNotificationsPerPublish(int maxNotificationsPerPublish)
          Define the limit for MaxNotificationsPerPublish that the clients may define for each subscription.
 void setMaxPublishingInterval(double maxPublishingInterval)
          Define the maximum value for PublishingInterval of any subscription.
 void setMaxPublishRequestCount(int maxPublishRequestCount)
          Define the maximum number of PublishRequests to accept from the client at a time.
 void setMaxRetransmissionQueueSize(int maxRetransmissionQueueSize)
          Define the maximum number of notification messages to keep in the retransmit queue, which is used to enable Republish calls from the client.
 void setMaxSamplingInterval(double maxSamplingInterval)
          Define the maximum value for SamplingInterval of any MonitoredItem.
 void setMaxSubscriptionCount(int maxSubscriptionCount)
          Define the maximum number of Subscriptions to enable per session.
 void setMinPublishingInterval(double minPublishingInterval)
          Define the minimum value for PublishingInterval of any subscription.
 void setMinSamplingInterval(double minSamplingInterval)
          Define the minimum value for SamplingInterval of any MonitoredItem.
protected  void setMonitoringMode(ServiceContext serviceContext, Subscription subscription, org.opcfoundation.ua.builtintypes.UnsignedInteger monitoredItemId, org.opcfoundation.ua.core.MonitoringMode mode)
           
protected  void setPublishingMode(ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.UnsignedInteger subscriptionId, Boolean publishingEnabled)
           
protected  void setTriggering(ServiceContext serviceContext, org.opcfoundation.ua.core.SetTriggeringRequest request, org.opcfoundation.ua.core.SetTriggeringResponse response)
           
protected  void start()
          Starts the manager.
protected  Subscription transferSubscription(ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.UnsignedInteger subscriptionId)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

protected final List<SubscriptionManagerListener> listeners

nodeManagerTable

protected final NodeManagerTable nodeManagerTable

sessionManager

protected final SessionManager sessionManager
Constructor Detail

SubscriptionManager

public SubscriptionManager(SessionManager sessionManager,
                           NodeManagerTable nodeManagerTable)
Parameters:
sessionManager -
nodeManagerTable -
Method Detail

addListener

public void addListener(SubscriptionManagerListener listener)
Add a new SubscriptionManagerListener.

Parameters:
listener - the listener to add. Must not be null

getMaxNotificationsPerPublish

public int getMaxNotificationsPerPublish()
The limit for the maximum number of notifications parameter which is defined per subscription. If the parameter is 0, then no limit is defined and the values defined by clients are used for each subscription.

If this value is defined, the client requested values are modified down to this value, if they would exceed it.

Default: 50000

Returns:
the maximum number of notifications in a single publish message
See Also:
setMaxNotificationsPerPublish(int)

getMaxPublishingInterval

public double getMaxPublishingInterval()
Returns:
the maxPublishingInterval
See Also:
setMaxPublishingInterval(double)

getMaxPublishRequestCount

public int getMaxPublishRequestCount()
Returns:
the maxPublishRequestCount

getMaxRetransmissionQueueSize

public int getMaxRetransmissionQueueSize()
The maximum number of notification messages to keep in the retransmit queue, which is used to enable Republish calls from the client.

Returns:
the maxRetransmissionQueueSize

getMaxSamplingInterval

public double getMaxSamplingInterval()
Returns:
the maxSamplingInterval
See Also:
setMaxSamplingInterval(double)

getMaxSubscriptionCount

public int getMaxSubscriptionCount()
Maximum number of concurrent subscriptions per session. Default: Integer.MAX_VALUE

Returns:
the current value

getMinPublishingInterval

public double getMinPublishingInterval()
Returns:
See Also:
setMinPublishingInterval(double)

getMinSamplingInterval

public double getMinSamplingInterval()
Returns:
the minSamplingInterval
See Also:
setMinSamplingInterval(double)

getNodeManagerTable

public NodeManagerTable getNodeManagerTable()
Returns:
the node manager table

getSessionManager

public SessionManager getSessionManager()
Returns:
the sessionManager

getSubscription

public Subscription getSubscription(org.opcfoundation.ua.builtintypes.UnsignedInteger subscriptionId)
                             throws ServiceException
Find the subscription by a subscriptionId

Parameters:
subscriptionId - the ID
Returns:
the subscription
Throws:
StatusException - if no subscription is found
ServiceException

getSubscriptionCount

public int getSubscriptionCount()
Number of managed subscriptions.


hasListener

public boolean hasListener(SubscriptionManagerListener listener)
Check if the manager already has the specified listener.

Parameters:
listener - the listener to check
listener -
Returns:
true if the listener is already defined for the manager

isRunning

public boolean isRunning()
Returns:
true after the manager is running - when the server is running.

removeListener

public void removeListener(SubscriptionManagerListener listener)
Remove a SubscriptionManagerListener.

Parameters:
listener -

setMaxNotificationsPerPublish

public void setMaxNotificationsPerPublish(int maxNotificationsPerPublish)
Define the limit for MaxNotificationsPerPublish that the clients may define for each subscription.

Default: 50000

Parameters:
maxNotificationsPerPublish -
See Also:
getMaxNotificationsPerPublish()

setMaxPublishingInterval

public void setMaxPublishingInterval(double maxPublishingInterval)
Define the maximum value for PublishingInterval of any subscription. If the requested value exceeds this, it is revised to this value.

Default: 3600000

Parameters:
maxPublishingInterval - the maxPublishingInterval to set (in milliseconds)

setMaxPublishRequestCount

public void setMaxPublishRequestCount(int maxPublishRequestCount)
Define the maximum number of PublishRequests to accept from the client at a time. If the client sends more PublishRequests to the queue, the server will respond with a Bad_TooManyPublishRequests error.

The value defines the maximum per client session.

Parameters:
maxPublishRequestCount - the new limit. Default is 100. Use 0 to set the default value.

setMaxRetransmissionQueueSize

public void setMaxRetransmissionQueueSize(int maxRetransmissionQueueSize)
Define the maximum number of notification messages to keep in the retransmit queue, which is used to enable Republish calls from the client.

Parameters:
maxRetransmissionQueueSize - the new size (default is 10)

setMaxSamplingInterval

public void setMaxSamplingInterval(double maxSamplingInterval)
Define the maximum value for SamplingInterval of any MonitoredItem. If the requested value exceeds this, it is revised to this value.

Default: 3600000

Parameters:
maxSamplingInterval - the maxSamplingInterval to set (in milliseconds)

setMaxSubscriptionCount

public void setMaxSubscriptionCount(int maxSubscriptionCount)
Define the maximum number of Subscriptions to enable per session.

Parameters:
maxSubscriptionCount - the maxSubscriptionCount to set. Default is INTEGER.MAX_VALUE

setMinPublishingInterval

public void setMinPublishingInterval(double minPublishingInterval)
Define the minimum value for PublishingInterval of any subscription. If the requested value exceeds this, it is revised to this value.

Default: 100

Parameters:
minPublishingInterval - the minPublishingInterval to set (in milliseconds). The value must be greater than 0.

setMinSamplingInterval

public void setMinSamplingInterval(double minSamplingInterval)
Define the minimum value for SamplingInterval of any MonitoredItem. If the requested value exceeds this, it is revised to this value.

Default: 1

Parameters:
minSamplingInterval - the minSamplingInterval to set. (in milliseconds)

acknowledge

protected void acknowledge(ServiceContext serviceContext,
                           org.opcfoundation.ua.core.PublishRequest request,
                           org.opcfoundation.ua.core.PublishResponse response)

acknowledgeSubscriptions

protected void acknowledgeSubscriptions(ServiceContext serviceContext,
                                        org.opcfoundation.ua.core.SubscriptionAcknowledgement[] acks,
                                        org.opcfoundation.ua.builtintypes.StatusCode[] results,
                                        org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnostics)

addSubscription

protected SubscriptionBase addSubscription(ServiceContext serviceContext,
                                           org.opcfoundation.ua.core.CreateSubscriptionRequest request)
                                    throws ServiceException
Add a new subscription.

Parameters:
serviceContext -
request -
Returns:
Throws:
ServiceException

addTriggeringLink

protected void addTriggeringLink(Subscription s,
                                 MonitoredItemBase triggeringItem,
                                 org.opcfoundation.ua.builtintypes.UnsignedInteger linkToAdd)
                          throws StatusException
Parameters:
s -
triggeringItem -
unsignedInteger -
Throws:
StatusException

checkIndexRangeForMonitoredItem

protected org.opcfoundation.ua.utils.NumericRange checkIndexRangeForMonitoredItem(String indexRange,
                                                                                  org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
                                                                           throws ServiceException
Parameters:
indexRange -
attributeId -
Returns:
Throws:
org.opcfoundation.ua.common.ServiceResultException
ServiceException

checkSession

protected void checkSession(ServiceContext serviceContext,
                            Subscription subscription)
                     throws ServiceException
Parameters:
serviceContext -
subscription -
Throws:
ServiceException

close

protected void close()

createMonitoredDataItem

protected MonitoredDataItem createMonitoredDataItem(ServiceContext serviceContext,
                                                    Subscription subscription,
                                                    org.opcfoundation.ua.core.MonitoredItemCreateRequest itemToCreate,
                                                    org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
                                                    org.opcfoundation.ua.core.MonitoringFilter filter)
                                             throws ServiceException,
                                                    StatusException
Parameters:
serviceContext -
subscription -
itemToCreate -
timestampsToReturn -
filter -
Throws:
StatusException
ServiceException

createMonitoredEventItem

protected MonitoredItem createMonitoredEventItem(ServiceContext serviceContext,
                                                 Subscription subscription,
                                                 org.opcfoundation.ua.core.MonitoredItemCreateRequest itemToCreate,
                                                 org.opcfoundation.ua.core.EventFilter eventFilter)
                                          throws StatusException
Parameters:
serviceContext -
subscription -
itemToCreate -
eventFilter -
Returns:
Throws:
StatusException

createMonitoredItem

protected MonitoredItem createMonitoredItem(ServiceContext serviceContext,
                                            Subscription subscription,
                                            org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
                                            org.opcfoundation.ua.core.MonitoredItemCreateRequest itemToCreate)
                                     throws StatusException,
                                            ServiceException
Parameters:
serviceContext -
subscription -
timestampsToReturn -
itemToCreate -
Returns:
Throws:
StatusException
ServiceException

deleteMonitoredItem

protected MonitoredItemBase deleteMonitoredItem(ServiceContext serviceContext,
                                                Subscription subscription,
                                                org.opcfoundation.ua.builtintypes.UnsignedInteger itemId)
                                         throws StatusException
Parameters:
serviceContext -
subscription -
itemId -
Throws:
StatusException

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

getNextSubscriptionToPublish

protected Subscription getNextSubscriptionToPublish(ServiceContext serviceContext,
                                                    long timeoutHint)
                                             throws ServiceException
Find the next subscription from the publish queue

Parameters:
serviceContext -
timeoutHint -
Returns:
Throws:
ServiceException

getPublishQueue

protected BlockingQueue<SubscriptionBase> getPublishQueue(Session session)
Parameters:
session -
Returns:

modifyMonitoredItem

protected MonitoredItem modifyMonitoredItem(ServiceContext serviceContext,
                                            Subscription subscription,
                                            org.opcfoundation.ua.core.MonitoredItemModifyRequest request,
                                            org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
                                            org.opcfoundation.ua.core.MonitoringParameters params)
                                     throws StatusException
Parameters:
serviceContext -
subscription -
request -
timestampsToReturn -
params -
Returns:
Throws:
StatusException

modifySubscription

protected SubscriptionBase modifySubscription(ServiceContext serviceContext,
                                              org.opcfoundation.ua.core.ModifySubscriptionRequest request)
                                       throws ServiceException
Parameters:
serviceContext -
request -
Returns:
Throws:
ServiceException
StatusException

nextSubscriptionId

protected org.opcfoundation.ua.builtintypes.UnsignedInteger nextSubscriptionId()
Find the next Subscription ID. The IDs start from 1 and they are reset whenever the application(or SubscriptionManager) is restarted.

Returns:

publish

protected void publish(ServiceContext serviceContext,
                       org.opcfoundation.ua.core.PublishRequest request,
                       org.opcfoundation.ua.core.PublishResponse response)
                throws ServiceException
Throws:
ServiceException

removeSubscription

protected void removeSubscription(ServiceContext serviceContext,
                                  Subscription subscription,
                                  boolean removeFromQueue)
                           throws ServiceException
Parameters:
serviceContext -
subscription -
Throws:
ServiceException

removeTriggeringLink

protected void removeTriggeringLink(SubscriptionBase s,
                                    MonitoredItemBase triggeringItem,
                                    org.opcfoundation.ua.builtintypes.UnsignedInteger linkToRemove)
                             throws StatusException
Parameters:
s -
triggeringItem -
unsignedInteger -
Throws:
StatusException

republish

protected void republish(ServiceContext serviceContext,
                         org.opcfoundation.ua.core.RepublishRequest request,
                         org.opcfoundation.ua.core.RepublishResponse response)
                  throws ServiceException
Throws:
ServiceException

setMonitoringMode

protected void setMonitoringMode(ServiceContext serviceContext,
                                 Subscription subscription,
                                 org.opcfoundation.ua.builtintypes.UnsignedInteger monitoredItemId,
                                 org.opcfoundation.ua.core.MonitoringMode mode)
                          throws ServiceException,
                                 StatusException
Parameters:
serviceContext -
subscription -
monitoredItemId -
Throws:
StatusException
ServiceException

setPublishingMode

protected void setPublishingMode(ServiceContext serviceContext,
                                 org.opcfoundation.ua.builtintypes.UnsignedInteger subscriptionId,
                                 Boolean publishingEnabled)
                          throws ServiceException,
                                 StatusException
Parameters:
serviceContext -
subscriptionId -
publishingEnabled -
Throws:
ServiceException
StatusException

setTriggering

protected void setTriggering(ServiceContext serviceContext,
                             org.opcfoundation.ua.core.SetTriggeringRequest request,
                             org.opcfoundation.ua.core.SetTriggeringResponse response)
                      throws ServiceException
Throws:
ServiceException

start

protected void start()
Starts the manager.


transferSubscription

protected Subscription transferSubscription(ServiceContext serviceContext,
                                            org.opcfoundation.ua.builtintypes.UnsignedInteger subscriptionId)
                                     throws ServiceException
Parameters:
serviceContext -
subscriptionId -
Returns:
Throws:
ServiceException


Copyright © 2018. All rights reserved.