payloadFormatters =
+ ServiceLoader.load(PayloadFormatter.class, PayloadFormatManager.class.getClassLoader());
for (PayloadFormatter formatter : payloadFormatters) {
if (formatter == null) {
logger.error("PayloadFormatManager(), formatter is null.");
@@ -90,6 +92,7 @@ private static void buildMqttPluginMap() throws IOException {
logger.info("PayloadFormatManager(), find MQTT Payload Plugin {}.", pluginName);
}
+ // Add all PayloadFormatters defined in the mqtt plugin directory.
URL[] jarURLs = getPluginJarURLs(mqttDir);
logger.debug("MQTT Plugin jarURLs: {}", jarURLs);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/mqtt/PayloadFormatterV2.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/mqtt/PayloadFormatterV2.java
new file mode 100644
index 0000000000000..fe5b14692bc11
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/mqtt/PayloadFormatterV2.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.iotdb.db.protocol.mqtt;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
+/**
+ * PayloadFormatterV2 enhanced interface for PayloadFormatters
+ *
+ * This is a SPI interface.
+ *
+ * @see PayloadFormatterV2
+ */
+public interface PayloadFormatterV2 extends PayloadFormatter {
+ /**
+ * format a payload to a list of messages
+ *
+ * @param topic
+ * @param payload
+ * @return
+ */
+ List format(String topic, ByteBuf payload);
+}
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/mqtt/JSONPayloadFormatterTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/mqtt/JSONPayloadFormatterTest.java
index 082225984cae8..0eb169cc640f1 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/mqtt/JSONPayloadFormatterTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/mqtt/JSONPayloadFormatterTest.java
@@ -24,6 +24,7 @@
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public class JSONPayloadFormatterTest {
@@ -45,7 +46,8 @@ public void formatJson() {
assertEquals("root.sg.d1", message.getDevice());
assertEquals(Long.valueOf(1586076045524L), message.getTimestamp());
assertEquals("s1", message.getMeasurements().get(0));
- assertEquals(0.530635D, Double.parseDouble(message.getValues().get(0)), 0);
+ assertTrue(message.getValues().get(0) instanceof String);
+ assertEquals(0.530635D, Double.parseDouble((String) message.getValues().get(0)), 0);
}
@Test
@@ -66,7 +68,8 @@ public void formatBatchJson() {
assertEquals("root.sg.d1", message.getDevice());
assertEquals(Long.valueOf(1586076065526L), message.getTimestamp());
assertEquals("s2", message.getMeasurements().get(1));
- assertEquals(0.530695D, Double.parseDouble(message.getValues().get(1)), 0);
+ assertTrue(message.getValues().get(0) instanceof String);
+ assertEquals(0.530695D, Double.parseDouble((String) message.getValues().get(1)), 0);
}
@Test
@@ -95,7 +98,8 @@ public void formatJsonArray() {
assertEquals("root.sg.d2", message.getDevice());
assertEquals(Long.valueOf(1586076065526L), message.getTimestamp());
assertEquals("s3", message.getMeasurements().get(0));
- assertEquals(0.530655D, Double.parseDouble(message.getValues().get(0)), 0);
+ assertTrue(message.getValues().get(0) instanceof String);
+ assertEquals(0.530655D, Double.parseDouble((String) message.getValues().get(0)), 0);
}
@Test
@@ -124,6 +128,7 @@ public void formatBatchJsonArray() {
assertEquals("root.sg.d2", message.getDevice());
assertEquals(Long.valueOf(1586076065526L), message.getTimestamp());
assertEquals("s4", message.getMeasurements().get(1));
- assertEquals(0.530695D, Double.parseDouble(message.getValues().get(1)), 0);
+ assertTrue(message.getValues().get(0) instanceof String);
+ assertEquals(0.530695D, Double.parseDouble((String) message.getValues().get(1)), 0);
}
}
diff --git a/pom.xml b/pom.xml
index 7479cc7ade419..0260a3b96e475 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1123,6 +1123,7 @@
linux-x86_64
+ linux-x64_64
Unix Makefiles
thrift
@@ -1138,6 +1139,7 @@
linux-aarch64
+ linux-aarch_64
Unix Makefiles
thrift
@@ -1152,6 +1154,7 @@
mac-x86_64
+ osx-x86_64
Unix Makefiles
thrift
/usr/local/include
@@ -1167,6 +1170,7 @@
mac-aarch64
+ osx-aarch_64
Unix Makefiles
thrift
/opt/homebrew/opt/boost/include
@@ -1182,6 +1186,7 @@
windows-x86_64
+ windows-x86_64
Visual Studio 17 2022
Release/thrift.exe
@@ -1196,6 +1201,7 @@
windows-aarch64
+ windows-aarch_64
Visual Studio 17 2022
Release/thrift.exe