com.prosysopc.ua.client
Class NodeCache

java.lang.Object
  extended by com.prosysopc.ua.NodeMap
      extended by com.prosysopc.ua.client.NodeCache

public class NodeCache
extends NodeMap

A client side cache of UaNode objects retrieved from the server.

See Also:
AddressSpace.getCache()

Nested Class Summary
 class NodeCache.NodeCacheWrapper
          A wrapper which keeps track of time when a node was added to the cache.
 
Field Summary
protected  boolean dataTypesInitialized
           
 
Fields inherited from class com.prosysopc.ua.NodeMap
defaultLocale, nodeFactory
 
Constructor Summary
NodeCache(UaNodeFactory nodeFactory, int maxQueueLength, long nodeMaxAgeInMillis)
           
 
Method Summary
 UaNode addNode(UaNode node)
           
protected  UaNode addNode(UaNode node, org.opcfoundation.ua.builtintypes.DateTime timestamp)
           
 UaNode addPermanently(UaNode node)
          Add a node permanently to the cache.
 void clear()
          Clear the node map of all entries.
protected  UaNode createNode(org.opcfoundation.ua.core.NodeClass nodeClass, org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.QualifiedName browseName, org.opcfoundation.ua.builtintypes.LocalizedText displayName, org.opcfoundation.ua.builtintypes.ExpandedNodeId typeDefinition)
          Create a new node and add it to the cache.
 int getMaxQueueLength()
          The maximum number of nodes to keep in the cache queue.
 UaNode getNode(org.opcfoundation.ua.builtintypes.NodeId nodeId)
           
 long getNodeMaxAgeInMillis()
          Maximum age of a node in the cache.
 boolean hasNode(org.opcfoundation.ua.builtintypes.NodeId nodeId)
          Check if the map contains a node with the specified NodeId.
 void initDataTypes()
          Initialize built-in types into the NodeMap.
protected  boolean isPermanentTimestamp(org.opcfoundation.ua.builtintypes.DateTime timestamp)
           
 UaNode remove(org.opcfoundation.ua.builtintypes.NodeId nodeId)
          Remove a node from the node map.
 UaNode remove(UaNode node)
          Remove a node from the node map.
 void setMaxQueueLength(int maxQueueLength)
          Set the maximum queue length.
 void setNodeMaxAgeInMillis(long nodeMaxAgeInMillis)
          Set the maximum time to keep nodes in the cache.
 int size()
           
 
Methods inherited from class com.prosysopc.ua.NodeMap
addType, addType, getNodeFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataTypesInitialized

protected volatile boolean dataTypesInitialized
Constructor Detail

NodeCache

public NodeCache(UaNodeFactory nodeFactory,
                 int maxQueueLength,
                 long nodeMaxAgeInMillis)
Method Detail

addNode

public UaNode addNode(UaNode node)
Specified by:
addNode in class NodeMap

addPermanently

public UaNode addPermanently(UaNode node)
Add a node permanently to the cache. It is not included in the queue, which limits the size of the cache. If there was already a node with the same NodeId, the method returns that.

Parameters:
node - the node to add
Returns:
the previous node with the same NodeId in the cache - or null, if there was not such a node

clear

public void clear()
Description copied from class: NodeMap
Clear the node map of all entries.

Specified by:
clear in class NodeMap

getMaxQueueLength

public int getMaxQueueLength()
The maximum number of nodes to keep in the cache queue. When the queue gets full, oldest nodes are removed from the cache.

Returns:
the current max of the queue length

getNode

public UaNode getNode(org.opcfoundation.ua.builtintypes.NodeId nodeId)
Specified by:
getNode in class NodeMap

getNodeMaxAgeInMillis

public long getNodeMaxAgeInMillis()
Maximum age of a node in the cache. If a node gets older, i.e. it was added to the cache too long time ago, it will get removed from the cache and needs to be re-added.

Returns:
the maximum time to keep nodes in the cache, in milliseconds

hasNode

public boolean hasNode(org.opcfoundation.ua.builtintypes.NodeId nodeId)
Description copied from class: NodeMap
Check if the map contains a node with the specified NodeId.

Specified by:
hasNode in class NodeMap
Parameters:
nodeId - the ID to check
Returns:
true, if the map contains a node with ID

initDataTypes

public void initDataTypes()
                   throws UaNodeFactoryException
Initialize built-in types into the NodeMap.
NOTE! Until clear() is called calling this method again has no effect.

Throws:
UaNodeFactoryException

remove

public UaNode remove(org.opcfoundation.ua.builtintypes.NodeId nodeId)
Description copied from class: NodeMap
Remove a node from the node map.

Specified by:
remove in class NodeMap
Parameters:
nodeId - the node to remove.
Returns:
the node that was removed or null, if it was not in the map.

remove

public UaNode remove(UaNode node)
Description copied from class: NodeMap
Remove a node from the node map.

Overrides:
remove in class NodeMap
Parameters:
node - the node to remove.
Returns:
the node that was removed or null, if it was not in the map.

setMaxQueueLength

public void setMaxQueueLength(int maxQueueLength)
Set the maximum queue length.

Parameters:
maxQueueLength - the max length
See Also:
getMaxQueueLength()

setNodeMaxAgeInMillis

public void setNodeMaxAgeInMillis(long nodeMaxAgeInMillis)
Set the maximum time to keep nodes in the cache.

Parameters:
nodeMaxAgeInMillis - max time in milliseconds
See Also:
getNodeMaxAgeInMillis()

size

public int size()
Returns:

addNode

protected UaNode addNode(UaNode node,
                         org.opcfoundation.ua.builtintypes.DateTime timestamp)

createNode

protected UaNode createNode(org.opcfoundation.ua.core.NodeClass nodeClass,
                            org.opcfoundation.ua.builtintypes.NodeId nodeId,
                            org.opcfoundation.ua.builtintypes.QualifiedName browseName,
                            org.opcfoundation.ua.builtintypes.LocalizedText displayName,
                            org.opcfoundation.ua.builtintypes.ExpandedNodeId typeDefinition)
                     throws UaNodeFactoryException
Create a new node and add it to the cache. The created type of the node depends on the parameters, namely nodeClass and typeDefinition.

Parameters:
nodeClass -
nodeId -
browseName -
displayName -
typeDefinition -
Returns:
the new node that was created
Throws:
UaNodeFactoryException

isPermanentTimestamp

protected boolean isPermanentTimestamp(org.opcfoundation.ua.builtintypes.DateTime timestamp)
Parameters:
timestamp -
Returns:


Copyright © 2018. All rights reserved.