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 0c284c7237b add_nodes
0c284c7237b is described below
commit 0c284c7237bea0fef23785df0b08cd74162e090e
Author: Caideyipi <[email protected]>
AuthorDate: Thu Dec 4 14:51:35 2025 +0800
add_nodes
---
.../main/java/org/apache/iotdb/opcua/ClientTest.java | 17 +++--------------
.../db/pipe/sink/protocol/opcua/OpcUaNameSpace.java | 20 +++-----------------
2 files changed, 6 insertions(+), 31 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 b31a1a298c8..eaf7c733275 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
@@ -24,7 +24,6 @@ import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
import org.eclipse.milo.opcua.sdk.core.AccessLevel;
import org.eclipse.milo.opcua.sdk.core.ValueRanks;
import org.eclipse.milo.opcua.stack.core.Identifiers;
-import
org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamEncoder;
import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString;
import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject;
@@ -40,7 +39,6 @@ import
org.eclipse.milo.opcua.stack.core.types.structured.AddNodesItem;
import org.eclipse.milo.opcua.stack.core.types.structured.AddNodesResponse;
import org.eclipse.milo.opcua.stack.core.types.structured.DeleteNodesItem;
import org.eclipse.milo.opcua.stack.core.types.structured.VariableAttributes;
-import org.eclipse.milo.opcua.stack.core.util.BufferUtil;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;
@@ -78,14 +76,6 @@ public class ClientTest implements ClientExample {
client.deleteNodes(Collections.singletonList(new DeleteNodesItem(nodeId,
true)));
- final OpcUaBinaryStreamEncoder encoder =
- new OpcUaBinaryStreamEncoder(client.getStaticSerializationContext());
- final ByteBuf byteBuf = BufferUtil.pooledBuffer();
- new VariableAttributes.Codec()
- .encode(
- client.getStaticSerializationContext(),
- encoder.setBuffer(byteBuf),
- createPressureSensorAttributes());
AddNodesResponse addStatus =
client
.addNodes(
@@ -96,13 +86,12 @@ public class ClientTest implements ClientExample {
new NodeId(2, "root/sg/d1/s2").expanded(),
new QualifiedName(2, "s2"),
NodeClass.Variable,
- new ExtensionObject(
- convertByteBufToByteString(byteBuf),
- Identifiers.OPCBinarySchema_TypeSystem),
+ ExtensionObject.encode(
+ client.getStaticSerializationContext(),
+ createPressureSensorAttributes()),
Identifiers.BaseDataVariableType.expanded())))
.get();
System.out.println("新增节点状态: " + addStatus);
- byteBuf.clear();
client.disconnect().get();
}
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 560e188a60d..7c4ff906da8 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
@@ -28,7 +28,6 @@ import org.apache.iotdb.db.utils.DateTimeUtils;
import org.apache.iotdb.db.utils.TimestampPrecisionUtils;
import org.apache.iotdb.pipe.api.event.Event;
-import io.netty.buffer.ByteBuf;
import org.apache.tsfile.common.constant.TsFileConstant;
import org.apache.tsfile.enums.ColumnCategory;
import org.apache.tsfile.enums.TSDataType;
@@ -51,7 +50,6 @@ import
org.eclipse.milo.opcua.sdk.server.util.SubscriptionModel;
import org.eclipse.milo.opcua.stack.core.Identifiers;
import org.eclipse.milo.opcua.stack.core.StatusCodes;
import org.eclipse.milo.opcua.stack.core.UaException;
-import
org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamDecoder;
import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
import org.eclipse.milo.opcua.stack.core.types.builtin.DateTime;
import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject;
@@ -63,7 +61,6 @@ import
org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass;
import org.eclipse.milo.opcua.stack.core.types.structured.AddNodesItem;
import org.eclipse.milo.opcua.stack.core.types.structured.AddNodesResult;
import org.eclipse.milo.opcua.stack.core.types.structured.VariableAttributes;
-import org.eclipse.milo.opcua.stack.core.util.BufferUtil;
import java.nio.file.Paths;
import java.sql.Date;
@@ -512,20 +509,9 @@ public class OpcUaNameSpace extends
ManagedNamespaceWithLifecycle {
new StatusCode(StatusCodes.Bad_ParentNodeIdInvalid),
NodeId.NULL_VALUE));
continue;
}
- final VariableAttributes variableAttributes;
- if
(attributes.getBodyType().equals(ExtensionObject.BodyType.ByteString)) {
- final OpcUaBinaryStreamDecoder decoder =
- new
OpcUaBinaryStreamDecoder(getServer().getSerializationContext());
- final ByteBuf byteBuf = BufferUtil.pooledBuffer();
- variableAttributes =
- new VariableAttributes.Codec()
- .decode(getServer().getSerializationContext(),
decoder.setBuffer(byteBuf));
- } else {
- results.add(
- new AddNodesResult(
- new StatusCode(StatusCodes.Bad_NodeAttributesInvalid),
NodeId.NULL_VALUE));
- continue;
- }
+ final VariableAttributes variableAttributes =
+ (VariableAttributes)
+
item.getNodeAttributes().decode(getServer().getSerializationContext());
measurementNode =
new UaVariableNode.UaVariableNodeBuilder(getNodeContext())
.setNodeId(nodeId.get())