更新时间:2024-06-05 GMT+08:00
分享

在本地Windows环境中调测IoTDB应用

操作场景

在程序代码完成开发后,您可以在Windows开发环境中运行应用。本地和集群业务平面网络互通时,您可以直接在本地进行调测。

  • 如果Windows开发环境中使用IBM JDK,不支持在Windows环境中直接运行应用程序。
  • 需要在运行样例代码的本机hosts文件中设置访问节点的主机名和IP地址映射,主机名和IP地址请保持一一对应。

操作步骤

  1. 单击IDEA右边Maven窗口的“Reimport All Maven Projects”,进行maven项目依赖import。

    图1 reimport projects

  2. 编译运行程序。

    修改代码匹配的IoTDBServer节点IP、端口、登录用户名和密码。

    1. 编译方式有以下两种。
      • 方法一

        选择“Maven > 样例工程名称 > Lifecycle > clean”,双击“clean”运行maven的clean命令。

        选择“Maven > 样例工程名称 > Lifecycle > compile”,双击“compile”运行maven的compile命令。

        图2 maven工具 clean和compile
      • 方法二

        在IDEA的下方Terminal窗口进入“pom.xml”所在目录,手动输入mvn clean compile命令进行编译。

        图3 idea terminal输入“mvn clean compile”

        编译完成,打印“BUILD SUCCESS”。

        图4 编译完成
    2. 运行程序,案例以JDBC程序为例,其他程序运行操作相同。

      右键单击“JDBCExample.java”文件,选择“Run 'JDBCExample.main() ”

      图5 运行程序

查看调测结果

IoTDB应用程序运行完成后,可通过IntelliJ IDEA运行结果查看应用程序运行情况。

  • JDBCExample样例程序运行结果如下所示:
    ...
    --------------------------
    Time root.sg.d1.s1 root.company.line2.device1.temperature root.company.line2.device1.speed root.company.line2.device2.speed root.company.line2.device2.status root.company.line1.device1.spin root.company.line1.device1.status root.company.line1.device2.temperature root.company.line1.device2.power root.sg1.d1.s3 root.sg1.d1.s1 root.sg1.d1.s2 
    0, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    1, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    2, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    3, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    4, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    5, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    6, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    7, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    8, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    9, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    10, null, null, null, null, null, null, null, null, null, 1.0, 1.0, 1.0
    --------------------------
    
    --------------------------
    count(root.sg.d1.s1) count(root.company.line2.device1.temperature) count(root.company.line2.device1.speed) count(root.company.line2.device2.speed) count(root.company.line2.device2.status) count(root.company.line1.device1.spin) count(root.company.line1.device1.status) count(root.company.line1.device2.temperature) count(root.company.line1.device2.power) count(root.sg1.d1.s3) count(root.sg1.d1.s1) count(root.sg1.d1.s2) 
    8237, 1, 1, 1, 1, 1, 1, 1, 1, 101, 101, 101
    --------------------------
    
    --------------------------
    Time count(root.sg.d1.s1) count(root.company.line2.device1.temperature) count(root.company.line2.device1.speed) count(root.company.line2.device2.speed) count(root.company.line2.device2.status) count(root.company.line1.device1.spin) count(root.company.line1.device1.status) count(root.company.line1.device2.temperature) count(root.company.line1.device2.power) count(root.sg1.d1.s3) count(root.sg1.d1.s1) count(root.sg1.d1.s2) 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 19, 19
    20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20
    40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20
    60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20
    80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20
    --------------------------
  • FlinkIoTDBSink样例程序运行结果如下所示:
    ...
    19:53:41.532 [flink-akka.actor.default-dispatcher-9] DEBUG org.apache.flink.runtime.resourcemanager.StandaloneResourceManager - Received heartbeat from 5153e4ff24b25b13225f1bf67a4312d8.
    19:53:41.800 [flink-akka.actor.default-dispatcher-9] DEBUG org.apache.flink.runtime.jobmaster.JobMaster - Trigger heartbeat request.
    19:53:41.800 [flink-akka.actor.default-dispatcher-10] DEBUG org.apache.flink.runtime.taskexecutor.TaskExecutor - Received heartbeat request from 5153e4ff24b25b13225f1bf67a4312d8.
    19:53:41.802 [flink-akka.actor.default-dispatcher-9] DEBUG org.apache.flink.runtime.jobmaster.JobMaster - Received heartbeat from 7d6ef313-3f78-4cee-bbb1-e234dcac6d30.
    19:53:42.988 [pool-3-thread-1] DEBUG org.apache.iotdb.flink.IoTDBSink - send event successfully
    19:53:42.988 [pool-6-thread-1] DEBUG org.apache.iotdb.flink.IoTDBSink - send event successfully
    19:53:42.990 [pool-4-thread-1] DEBUG org.apache.iotdb.flink.IoTDBSink - send event successfully
    19:53:45.990 [pool-7-thread-1] DEBUG org.apache.iotdb.flink.IoTDBSink - send event successfully
    19:53:45.992 [pool-9-thread-1] DEBUG org.apache.iotdb.flink.IoTDBSink - send event successfully
    19:53:45.994 [pool-5-thread-1] DEBUG org.apache.iotdb.flink.IoTDBSink - send event successfully
  • IoTDB Kafka样例程序运行结果如下所示:
    • Producer.java
      ...
      [2022-01-15 15:12:34,221] INFO New Producer: start. (com.huawei.bigdata.iotdb.Producer)
      [2022-01-15 15:12:39,369] INFO [Producer clientId=DemoProducer] Cluster ID: uDtuaWS_QUK02EtuZQ4Xew (org.apache.kafka.clients.Metadata)
      [2022-01-15 15:12:57,077] INFO The Producer have send 100 messages. (com.huawei.bigdata.iotdb.Producer)
      [2022-01-15 15:13:04,691] INFO The Producer have send 200 messages. (com.huawei.bigdata.iotdb.Producer)
      [2022-01-15 15:13:11,355] INFO The Producer have send 300 messages. (com.huawei.bigdata.iotdb.Producer)
      [2022-01-15 15:13:17,758] INFO The Producer have send 400 messages. (com.huawei.bigdata.iotdb.Producer)
      [2022-01-15 15:13:24,335] INFO The Producer have send 500 messages. (com.huawei.bigdata.iotdb.Producer)
      [2022-01-15 15:13:30,739] INFO The Producer have send 600 messages. (com.huawei.bigdata.iotdb.Producer)
      [2022-01-15 15:13:37,267] INFO The Producer have send 700 messages. (com.huawei.bigdata.iotdb.Producer)
    • KafkaConsumerMultThread.java
      ...
      [2022-01-15 15:19:27,563] INFO Consumer Thread-1 partitions:1 record: sensor_29,1642231023769,1.000000 offsets: 828 (com.huawei.bigdata.iotdb.KafkaConsumerMultThread)
      [2022-01-15 15:19:27,612] INFO Consumer Thread-1 partitions:1 record: sensor_31,1642231023769,1.000000 offsets: 829 (com.huawei.bigdata.iotdb.KafkaConsumerMultThread)
      [2022-01-15 15:19:27,612] INFO Consumer Thread-0 partitions:0 record: sensor_8,1642231023769,1.000000 offsets: 842 (com.huawei.bigdata.iotdb.KafkaConsumerMultThread)
      [2022-01-15 15:19:27,665] INFO Consumer Thread-1 partitions:1 record: sensor_32,1642231023769,1.000000 offsets: 830 (com.huawei.bigdata.iotdb.KafkaConsumerMultThread)
      [2022-01-15 15:19:27,665] INFO Consumer Thread-0 partitions:0 record: sensor_9,1642231023769,1.000000 offsets: 843 (com.huawei.bigdata.iotdb.KafkaConsumerMultThread)
      [2022-01-15 15:19:27,732] INFO Consumer Thread-1 partitions:1 record: sensor_33,1642231023769,1.000000 offsets: 831 (com.huawei.bigdata.iotdb.KafkaConsumerMultThread)
      [2022-01-15 15:19:27,732] INFO Consumer Thread-0 partitions:0 record: sensor_11,1642231023769,1.000000 offsets: 844 (com.huawei.bigdata.iotdb.KafkaConsumerMultThread)
      [2022-01-15 15:19:27,786] INFO Consumer Thread-0 partitions:0 record: sensor_12,1642231023769,1.000000 offsets: 845 (com.huawei.bigdata.iotdb.KafkaConsumerMultThread)
      [2022-01-15 15:19:27,786] INFO Consumer Thread-1 partitions:1 record: sensor_35,1642231023769,1.000000 offsets: 832 (com.huawei.bigdata.iotdb.KafkaConsumerMultThread)

相关文档