This is an automated email from the ASF dual-hosted git repository.
justinchen pushed a commit to branch new_opc_server
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/new_opc_server by this push:
new d3b2a799a26 jbs
d3b2a799a26 is described below
commit d3b2a799a26e7fe16dfc9ddf13bafc0f1ea71c5e
Author: Caideyipi <[email protected]>
AuthorDate: Thu Dec 4 16:25:24 2025 +0800
jbs
---
.../java/org/apache/iotdb/opcua/ClientTest.java | 30 ++++++++++++++++++----
.../pipe/sink/protocol/opcua/OpcUaNameSpace.java | 20 ++++++++-------
2 files changed, 36 insertions(+), 14 deletions(-)
diff --git
a/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua/ClientTest.java
b/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua/ClientTest.java
index 19700796106..2699451b745 100644
---
a/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua/ClientTest.java
+++
b/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua/ClientTest.java
@@ -81,11 +81,20 @@ public class ClientTest implements ClientExample {
client
.addNodes(
Arrays.asList(
+ new AddNodesItem(
+ Identifiers.ObjectsFolder.expanded(),
+ Identifiers.Organizes,
+ new NodeId(2, "root").expanded(),
+ new QualifiedName(2, "root"),
+ NodeClass.Object,
+ ExtensionObject.encode(
+ client.getStaticSerializationContext(),
createFolder1Attributes()),
+ Identifiers.FolderType.expanded()),
new AddNodesItem(
new NodeId(2, "root").expanded(),
Identifiers.Organizes,
- new NodeId(2, "root/db").expanded(),
- new QualifiedName(2, "db"),
+ new NodeId(2, "root/sg").expanded(),
+ new QualifiedName(2, "sg"),
NodeClass.Object,
ExtensionObject.encode(
client.getStaticSerializationContext(),
createFolder1Attributes()),
@@ -93,7 +102,7 @@ public class ClientTest implements ClientExample {
new AddNodesItem(
new NodeId(2, "root/sg").expanded(),
Identifiers.Organizes,
- new NodeId(2, "root/sg/d2").expanded(),
+ new NodeId(2, "root/sg/d1").expanded(),
new QualifiedName(2, "d2"),
NodeClass.Object,
ExtensionObject.encode(
@@ -132,10 +141,21 @@ public class ClientTest implements ClientExample {
);
}
+ public static ObjectAttributes createFolder0Attributes() {
+ return new ObjectAttributes(
+ Unsigned.uint(0xFFFF), // specifiedAttributes
+ LocalizedText.english("root"),
+ LocalizedText.english("反应釜压力传感器"),
+ Unsigned.uint(0), // writeMask
+ Unsigned.uint(0), // userWriteMask
+ null // 启用历史记录
+ );
+ }
+
public static ObjectAttributes createFolder1Attributes() {
return new ObjectAttributes(
Unsigned.uint(0xFFFF), // specifiedAttributes
- LocalizedText.english("db"),
+ LocalizedText.english("sg"),
LocalizedText.english("反应釜压力传感器"),
Unsigned.uint(0), // writeMask
Unsigned.uint(0), // userWriteMask
@@ -146,7 +166,7 @@ public class ClientTest implements ClientExample {
public static ObjectAttributes createFolder2Attributes() {
return new ObjectAttributes(
Unsigned.uint(0xFFFF), // specifiedAttributes
- LocalizedText.english("d2"),
+ LocalizedText.english("d1"),
LocalizedText.english("反应釜压力传感器"),
Unsigned.uint(0), // writeMask
Unsigned.uint(0), // userWriteMask
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/opcua/OpcUaNameSpace.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/opcua/OpcUaNameSpace.java
index 698c15dd429..768bd7b043b 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/opcua/OpcUaNameSpace.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/opcua/OpcUaNameSpace.java
@@ -475,7 +475,6 @@ public class OpcUaNameSpace extends
ManagedNamespaceWithLifecycle {
@Override
public void addNodes(final AddNodesContext context, final List<AddNodesItem>
nodesToAdd) {
- UaVariableNode measurementNode;
final List<AddNodesResult> results = new ArrayList<>(nodesToAdd.size());
for (final AddNodesItem item : nodesToAdd) {
// Check attributes
@@ -510,8 +509,9 @@ public class OpcUaNameSpace extends
ManagedNamespaceWithLifecycle {
new StatusCode(StatusCodes.Bad_ParentNodeIdInvalid),
NodeId.NULL_VALUE));
continue;
}
- final UaNode parentNode = getNodeManager().get(parentId.get());
- if (Objects.isNull(parentNode)) {
+ final Optional<UaNode> parentNode =
+ getServer().getAddressSpaceManager().getManagedNode(parentId.get());
+ if (!parentNode.isPresent()) {
results.add(
new AddNodesResult(
new StatusCode(StatusCodes.Bad_ParentNodeIdInvalid),
NodeId.NULL_VALUE));
@@ -589,12 +589,14 @@ public class OpcUaNameSpace extends
ManagedNamespaceWithLifecycle {
// Link reference
getNodeManager().addNode(newNode);
- parentNode.addReference(
- new Reference(
- parentNode.getNodeId(),
- item.getReferenceTypeId(),
- newNode.getNodeId().expanded(),
- true));
+ parentNode
+ .get()
+ .addReference(
+ new Reference(
+ parentNode.get().getNodeId(),
+ item.getReferenceTypeId(),
+ newNode.getNodeId().expanded(),
+ true));
results.add(new AddNodesResult(StatusCode.GOOD, newNode.getNodeId()));
}