Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
SKK 4.0.2-808 is com.prosysopc.ua.client.AddressSpace.getNode thread safe?
August 20, 2019
17:57, EEST
Avatar
Christv
Member
Members
Forum Posts: 9
Member Since:
August 9, 2016
sp_UserOfflineSmall Offline

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)

August 21, 2019
16:13, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 982
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

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.

August 21, 2019
17:07, EEST
Avatar
Christv
Member
Members
Forum Posts: 9
Member Since:
August 9, 2016
sp_UserOfflineSmall Offline

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);

August 29, 2019
13:17, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 982
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
15 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

ibrahim: 75

rocket science: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 707

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1465

Posts: 6252

Newest Members:

christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer, shanonhumphreys, KupimotoblokfuB, tamhollander5, paulinafcf, bridgette18l

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 982, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 319, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1