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, EET
Avatar
Christv
Member
Members
Forum Posts: 7
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, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 417
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, EET
Avatar
Christv
Member
Members
Forum Posts: 7
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, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 417
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: 81

Currently Online:
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 91

pramanj: 86

ibrahim: 68

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 36

Rainer Versteeg: 32

peterrob45: 25

Member Stats:

Guest Posters: 0

Members: 894

Moderators: 12

Admins: 1

Forum Stats:

Groups: 3

Forums: 14

Topics: 897

Posts: 3779

Newest Members:

dpto.informatica, nolazky8119, peter.jakubik, amaralesbeltateresa@yahoo.com, amaralesbeltateresa@gmail.com, esbeltateresaamaral@yahoo.com.br, doanphan111, Jeremy Morgan, stefan.bck, ypidig

Moderators: Jouni Aro: 833, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 417, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 16, Markus Johansson: 1

Administrators: admin: 0