17:57, EEST
August 9, 2016
In thread dump I see a lot blockes on the com.prosysopc.ua.client.AddressSpace.getNode method, I use this method in multithread application in read or write to a tag.
java.lang.Thread.State: BLOCKED
at com.prosysopc.ua.client.AddressSpace.getNode(SourceFile:885)
at com.bekaert.osgi.datakap.opcuaclient.OpcUaServer.tagRead(OpcUaServer.java:1389)
java.lang.Thread.State: BLOCKED
at com.prosysopc.ua.client.AddressSpace.getNode(SourceFile:885)
at com.bekaert.osgi.datakap.opcuaclient.OpcUaServer.tagWrite(OpcUaServer.java:1484)
16:13, EEST
April 3, 2012
Hi,
Yes, it is thread-safe, but it is also synchronized. If the node doesn’t exist in the AddressSpace.getNodeCache() or is old enough there (NodeCache.getNodeMaxAgeInMillis), the getNode will fetch it from the server (Attributes and References), which will take time (3 service calls). If you use it in repeated reads/writes it is quite likely that threads will block on that while service calls happen.
Generally it is better to use UaClient.read and write methods for reading and writing the Value Attribute repeatedly.
17:07, EEST
August 9, 2016
I use this method to get datatype of variant value, as there is no getDatatype method in Variant class
variable = (UaVariable) client.getAddressSpace().getNode(nodeId);
NodeId dataTypeId = variable.getDataTypeId();
UaType dataType = variable.getDataType();
if (dataType == null) dataType = client.getAddressSpace().getType(dataTypeId);
13:17, EEST
April 3, 2012
Most of the time the DataType of a node shouldn’t change. Therefore you should be able to just read that once and cache it in e.g. a Map.
Note that while it is true that the Variant doesn’t contain the specific DataType as a NodeId, in some cases just the java class of the value would be enough. However even if that is not enough, it is still be more performant to Read the DataType Attribute before doing the Write/Read vs. calling getNode(). But note that if you do it faster than 1 second (which is the default cache time of the NodeCache of the AddressSpace), then Reading the DataType will probably start to take more time depending how fast you are writing.
Additionally note that the UaClient.read/write methods you can do bulk operations, i.e. read/write to multiple nodes at once, which probably gives better performance if you can group the operations somehow in your application.
Most Users Ever Online: 1919
Currently Online:
23 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 728
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuartModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1