Skip to content

Commit 0c556ea

Browse files
committed
fix
1 parent 4a1ad70 commit 0c556ea

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/opcua/OpcUaSink.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public class OpcUaSink implements PipeConnector {
128128

129129
private String serverKey;
130130
boolean isClientServerModel;
131-
String unQualifiedDatabaseName;
131+
String databaseName;
132132
String placeHolder;
133133
@Nullable String valueName;
134134
@Nullable String qualityName;
@@ -159,12 +159,15 @@ public void validate(final PipeParameterValidator validator) throws Exception {
159159

160160
final PipeParameters parameters = validator.getParameters();
161161
if (validator
162-
.getParameters()
163-
.hasAnyAttributes(CONNECTOR_OPC_UA_NODE_URL_KEY, SINK_OPC_UA_NODE_URL_KEY)) {
162+
.getParameters()
163+
.hasAnyAttributes(CONNECTOR_OPC_UA_NODE_URL_KEY, SINK_OPC_UA_NODE_URL_KEY)
164+
|| parameters.getBooleanOrDefault(
165+
Arrays.asList(CONNECTOR_OPC_UA_WITH_QUALITY_KEY, SINK_OPC_UA_WITH_QUALITY_KEY),
166+
CONNECTOR_OPC_UA_WITH_QUALITY_DEFAULT_VALUE)) {
164167
validator.validate(
165168
CONNECTOR_OPC_UA_MODEL_CLIENT_SERVER_VALUE::equals,
166169
String.format(
167-
"When the OPC UA sink points to an outer server or specifies 'with-quality', the %s or %s must be %s.",
170+
"When the OPC UA sink points to an outer server or sets 'with-quality' to true, the %s or %s must be %s.",
168171
CONNECTOR_OPC_UA_MODEL_KEY,
169172
SINK_OPC_UA_MODEL_KEY,
170173
CONNECTOR_OPC_UA_MODEL_CLIENT_SERVER_VALUE),
@@ -207,16 +210,22 @@ public void customize(
207210
final DataRegion region =
208211
StorageEngine.getInstance()
209212
.getDataRegion(new DataRegionId(configuration.getRuntimeEnvironment().getRegionId()));
210-
unQualifiedDatabaseName =
211-
Objects.nonNull(region)
212-
? PathUtils.unQualifyDatabaseName(region.getDatabaseName())
213-
: "__temp_db";
213+
databaseName = Objects.nonNull(region) ? region.getDatabaseName() : "__temp_db";
214+
215+
if (withQuality && PathUtils.isTableModelDatabase(databaseName)) {
216+
throw new PipeException(
217+
"When the OPC UA sink sets 'with-quality' to true, the table model data is not supported.");
218+
}
214219

215220
final String nodeUrl =
216221
parameters.getStringByKeys(CONNECTOR_OPC_UA_NODE_URL_KEY, SINK_OPC_UA_NODE_URL_KEY);
217222
if (Objects.isNull(nodeUrl)) {
218223
customizeServer(parameters);
219224
} else {
225+
if (PathUtils.isTableModelDatabase(databaseName)) {
226+
throw new PipeException(
227+
"When the OPC UA sink points to an outer server, the table model data is not supported.");
228+
}
220229
customizeClient(nodeUrl, parameters);
221230
}
222231
}
@@ -478,8 +487,8 @@ public boolean isClientServerModel() {
478487
return isClientServerModel;
479488
}
480489

481-
public String getUnQualifiedDatabaseName() {
482-
return unQualifiedDatabaseName;
490+
public String getDatabaseName() {
491+
return databaseName;
483492
}
484493

485494
public String getPlaceHolder() {

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/opcua/server/OpcUaNameSpace.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static void transferTabletForClientServerModel(
146146
for (int i = 0; i < tablet.getRowSize(); ++i) {
147147
final Object[] segments = tablet.getDeviceID(i).getSegments();
148148
final String[] folderSegments = new String[segments.length + 1];
149-
folderSegments[0] = sink.getUnQualifiedDatabaseName();
149+
folderSegments[0] = sink.getDatabaseName();
150150

151151
for (int j = 0; j < segments.length; ++j) {
152152
folderSegments[j + 1] =
@@ -382,7 +382,7 @@ private void transferTabletForPubSubModel(
382382
if (isTableModel) {
383383
sourceNameList = new ArrayList<>(tablet.getRowSize());
384384
for (int i = 0; i < tablet.getRowSize(); ++i) {
385-
final StringBuilder idBuilder = new StringBuilder(sink.getUnQualifiedDatabaseName());
385+
final StringBuilder idBuilder = new StringBuilder(sink.getDatabaseName());
386386
for (final Object segment : tablet.getDeviceID(i).getSegments()) {
387387
idBuilder
388388
.append(TsFileConstant.PATH_SEPARATOR)

0 commit comments

Comments
 (0)