diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f0108e530..74119f2c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -75,7 +75,7 @@ jobs: id: compile-benchmark run: | cd ${{ github.workspace }}/iot-benchmark - mvn clean package -am -pl core,influxdb,influxdb-2.0,tdengine,timescaledb,iotdb-1.0,iotdb-1.1,iotdb-0.13,iotdb-1.3 -DskipTests + mvn clean package -am -pl core,influxdb,influxdb-2.0,tdengine,timescaledb,iotdb-1.0,iotdb-1.1,iotdb-1.3 -DskipTests # get time - name: collect common info shell: bash @@ -98,16 +98,6 @@ jobs: Java Version: java${{ matrix.java_version }} draft: false prerelease: false - #---0.13 - - name: Upload benchmark-iotdb-0.13 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create-release.outputs.upload_url }} - asset_path: ${{ github.workspace }}/iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13.zip - asset_name: benchmark-iotdb-0.13-java${{ matrix.java_version }}.zip - asset_content_type: application/zip #---1.0 - name: Upload benchmark-iotdb-1.0 uses: actions/upload-release-asset@v1 diff --git a/.github/workflows/release_history_commit.yml b/.github/workflows/release_history_commit.yml index 8700c230f..d496f81ac 100644 --- a/.github/workflows/release_history_commit.yml +++ b/.github/workflows/release_history_commit.yml @@ -46,7 +46,7 @@ jobs: id: compile-benchmark run: | cd ${{ github.workspace }}/iot-benchmark - mvn clean package -am -pl core,influxdb,influxdb-2.0,tdengine,tdengine-3.0,timescaledb,iotdb-1.0,iotdb-1.1,iotdb-0.13 -DskipTests + mvn clean package -am -pl core,influxdb,influxdb-2.0,tdengine,tdengine-3.0,timescaledb,iotdb-1.0,iotdb-1.1,iotdb-1.3 -DskipTests # get time - name: collect common info shell: bash @@ -69,16 +69,6 @@ jobs: Java Version: java${{ matrix.java_version }} draft: false prerelease: false - #---0.13 - - name: Upload benchmark-iotdb-0.13 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create-release.outputs.upload_url }} - asset_path: ${{ github.workspace }}/iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13.zip - asset_name: benchmark-iotdb-0.13-java${{ matrix.java_version }}.zip - asset_content_type: application/zip #---1.0 - name: Upload benchmark-iotdb-1.0 uses: actions/upload-release-asset@v1 diff --git a/README-cn.md b/README-cn.md index f2b50f7e1..3ab4d0486 100644 --- a/README-cn.md +++ b/README-cn.md @@ -127,7 +127,7 @@ iot-benchmark的特点如下: 1. Java 8 2. Maven:不建议使用镜像源,国内可以使用阿里云镜像源。 3. 合适版本的数据库 - 1. Apache IoTDB >= v0.13([获取方式](https://github.com/apache/iotdb)) + 1. Apache IoTDB >= v1.0([获取方式](https://github.com/apache/iotdb)) 2. 其他的对应版本的数据库 4. CSV的记录模式只能在Linux系统中使用,记录测试过程中的相关系统信息。 5. 我们建议使用MacOs或Linux系统,本文以MacOS和Linux系统为例,如果使用Windows系统,请使用`conf`文件夹下的`benchmark.bat`脚本启动benchmark。 @@ -137,8 +137,8 @@ iot-benchmark的特点如下: | :------------: | :-------------------: | :------------------------------------------------------------------------------- | | 常规测试模式 | testWithDefaultPath | 支持多种读和写操作的混合负载 | | 生成数据模式 | generateDataMode | Benchmark生成数据集到FILE_PATH路径中 | -| 正确性写入模式 | verificationWriteMode | 从FILE_PATH路径中加载数据集进行写入,目前支持 IoTDB v0.13 及更新的版本 | -| 正确性查询模式 | verificationQueryMode | 从FILE_PATH路径中加载数据集和数据库中进行比对,目前支持 IoTDB v0.13 及更新的版本 | +| 正确性写入模式 | verificationWriteMode | 从FILE_PATH路径中加载数据集进行写入,目前支持 IoTDB v1.0 及更新的版本 | +| 正确性查询模式 | verificationQueryMode | 从FILE_PATH路径中加载数据集和数据库中进行比对,目前支持 IoTDB v1.0 及更新的版本 | ## 5.3. iot-benchmark的编译构建 @@ -150,16 +150,15 @@ mvn clean package -Dmaven.test.skip=true 该命令会编译iot-benchmark的core模块,和所有其他相关的数据库。 -在完成编译后,以IoTDB v0.13为例,你可以进入到`iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`文件夹下,使用`./benchmark.sh`来启动对IoTDB v0.13的测试。 +在完成编译后,以IoTDB v1.0为例,你可以进入到`iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`文件夹下,使用`./benchmark.sh`来启动对IoTDB v1.0的测试。 -默认的配置文件存放在`iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13/conf`下,您可以编辑`config.properties`来完成配置,请**注意的是,您需要将配置文件中的DB_SWITCH参数调整为您需要被测数据库**,其对应关系和可能取值如下所示: +默认的配置文件存放在`iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0/conf`下,您可以编辑`config.properties`来完成配置,请**注意的是,您需要将配置文件中的DB_SWITCH参数调整为您需要被测数据库**,其对应关系和可能取值如下所示: | 数据库 | 版本 | 对应子项目 | DB_SWITCH | | :------------------: | :------: | :-----------------: | :----------------------------------------------------------------------------------------------------------: | | IoTDB | 1.3 | iotdb-1.3 | IoTDB-130-JDBC
IoTDB-130-SESSION_BY_TABLET
IoTDB-130-SESSION_BY_RECORD
IoTDB-130-SESSION_BY_RECORDS | | IoTDB | 1.1 | iotdb-1.1 | IoTDB-110-JDBC
IoTDB-110-SESSION_BY_TABLET
IoTDB-110-SESSION_BY_RECORD
IoTDB-110-SESSION_BY_RECORDS | | IoTDB | 1.0 | iotdb-1.0 | IoTDB-100-JDBC
IoTDB-100-SESSION_BY_TABLET
IoTDB-100-SESSION_BY_RECORD
IoTDB-100-SESSION_BY_RECORDS | -| IoTDB | 0.13 | iotdb-0.13 | IoTDB-013-JDBC
IoTDB-013-SESSION_BY_TABLET
IoTDB-013-SESSION_BY_RECORD
IoTDB-013-SESSION_BY_RECORDS | | InfluxDB | v1.x | influxdb | InfluxDB | | InfluxDB | v2.0 | influxdb-2.0 | InfluxDB-2.0 | | QuestDB | v6.0.7 | questdb | QuestDB | @@ -210,7 +209,7 @@ CPU:I7-11700 ```properties HOST=127.0.0.1 PORT=6667 -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET BENCHMARK_WORK_MODE=testWithDefaultPath OPERATION_PROPORTION=1:0:0:0:0:0:0:0:0:0:0 GROUP_NUMBER=10 @@ -228,7 +227,7 @@ LOOP=10000 在启动测试之前,您需要在本机的6667端口启动IoTDB服务。 -之后您进入到`iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): +之后您进入到`iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): ```sh > ./benchmark.sh @@ -258,7 +257,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -368,7 +367,7 @@ MAX_K=170000 HOST=127.0.0.1 PORT=6667 IS_DELETE_DATA=false -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET BENCHMARK_WORK_MODE=testWithDefaultPath OPERATION_PROPORTION=0:1:1:1:1:1:1:1:1:1:1 GROUP_NUMBER=10 @@ -400,7 +399,7 @@ GROUP_BY_TIME_UNIT=20000 在启动测试之前,您需要在本机的6667端口启动IoTDB服务。 -之后您进入到`iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): +之后您进入到`iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): ```sh > ./benchmark.sh @@ -429,7 +428,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -511,7 +510,7 @@ VALUE_RANGE_QUERY_DESC 5.44 0.52 2.05 2.68 3.62 HOST=127.0.0.1 PORT=6667 IS_DELETE_DATA=false -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET BENCHMARK_WORK_MODE=testWithDefaultPath OPERATION_PROPORTION=1:1:1:1:1:1:1:1:1:1:1 GROUP_NUMBER=10 @@ -542,7 +541,7 @@ GROUP_BY_TIME_UNIT=20000 在启动测试之前,您需要在本机的6667端口启动IoTDB服务。 -之后您进入到`iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): +之后您进入到`iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): ```sh > ./benchmark.sh @@ -571,7 +570,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -650,7 +649,7 @@ VALUE_RANGE_QUERY_DESC 13.19 0.37 0.65 0.86 1.46 HOST=127.0.0.1 PORT=6667 IS_DELETE_DATA=false -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET BENCHMARK_WORK_MODE=testWithDefaultPath OPERATION_PROPORTION=1:1:1:1:1:1:1:1:1:1:1 GROUP_NUMBER=10 @@ -681,7 +680,7 @@ GROUP_BY_TIME_UNIT=20000 在启动测试之前,您需要在本机的6667端口启动IoTDB服务。 -之后您进入到`iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): +之后您进入到`iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): ```sh > ./benchmark.sh @@ -700,7 +699,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -791,7 +790,7 @@ MONITOR_INTERVAL=0 在启动测试之前,您需要在本机的6667端口启动IoTDB服务。 -之后您进入到`iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): +之后您进入到`iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): ```sh > ./benchmark.sh @@ -855,7 +854,7 @@ BIG_BATCH_SIZE=100 ### 6.7.2. Benchmark的启动 -您进入到`iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): +您进入到`iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): ```sh > ./benchmark.sh @@ -921,7 +920,7 @@ SENSORS=[s_0, s_1, s_2, s_3, s_4, s_5, s_6, s_7, s_8, s_9] ## 6.8. 正确性写入模式(单数据库,外部数据集) -为了验证数据集写入的正确性,您可以使用该模式写入生成数据模式中生成的数据集,目前该模式仅支持IoTDB v0.13 及更新的版本和InfluxDB v1.x +为了验证数据集写入的正确性,您可以使用该模式写入生成数据模式中生成的数据集,目前该模式仅支持IoTDB v1.0 及更新的版本和InfluxDB v1.x ### 6.8.1. Benchmark的配置 @@ -962,7 +961,7 @@ IS_COPY_MODE=true 在启动测试之前,您需要在本机的6667端口启动IoTDB服务。 -之后您进入到`iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): +之后您进入到`iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): ```sh > ./benchmark.sh @@ -991,7 +990,7 @@ BENCHMARK_WORK_MODE=verificationWriteMode ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -1035,7 +1034,7 @@ INGESTION 0.52 0.02 0.02 0.03 0.03 在运行这个模式之前需要先使用正确性写入模式写入数据到数据库。 -为了验证数据集写入的正确性,您可以使用该模式查询写入到数据库中的数据集,目前该模式仅支持IoTDB v0.13 和 InfluxDB v1.x +为了验证数据集写入的正确性,您可以使用该模式查询写入到数据库中的数据集,目前该模式仅支持IoTDB v1.0 和 InfluxDB v1.x ### 6.9.1. Benchmark的配置 @@ -1057,7 +1056,7 @@ BIG_BATCH_SIZE=100 在启动测试之前,您需要在本机的6667端口启动IoTDB服务。 -之后您进入到`iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): +之后您进入到`iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`中运行如下命令来启动Benchmark(目前仅Unix/OS X系统中执行如下脚本): ```sh > ./benchmark.sh @@ -1085,7 +1084,7 @@ BENCHMARK_WORK_MODE=verificationQueryMode ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -1130,7 +1129,7 @@ VERIFICATION_QUERY 14.48 0.96 11.40 12.67 14.43 为了更方便、快速完成正确性验证,iot-benchmark也支持双数据库模式。 1. 对于上文中提到的所有测试场景,除特别说明,均支持双数据库进行。请在`verification`项目中**启动测试**。 -2. 对于下文中的正确性验证的相关测试场景,均必须在双数据库模式下运行,并且目前仅支持IoTDB v0.13 及更新的版本和timescaledb。 +2. 对于下文中的正确性验证的相关测试场景,均必须在双数据库模式下运行,并且目前仅支持IoTDB v1.0 及更新的版本和timescaledb。 为了完成双数据库配置,您需要对`config.properties`完成如下修改: @@ -1170,7 +1169,7 @@ IS_POINT_COMPARISON=false ``` BENCHMARK_WORK_MODE=testWithDefaultPath -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=127.0.0.1 PORT=6667 OPERATION_PROPORTION=1:0:0:0:0:0:0:0:0:0:0 @@ -1216,7 +1215,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=true DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ANOTHER DBConfig= DB_SWITCH=TimescaleDB @@ -1300,7 +1299,7 @@ IS_POINT_COMPARISON=true ``` BENCHMARK_WORK_MODE=testWithDefaultPath -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=127.0.0.1 PORT=6667 OPERATION_PROPORTION=1:0:0:0:0:0:0:0:0:0:0 @@ -1346,7 +1345,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=true DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ANOTHER DBConfig= DB_SWITCH=TimescaleDB @@ -1414,7 +1413,7 @@ IS_COMPARISON=true ``` BENCHMARK_WORK_MODE=testWithDefaultPath -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=127.0.0.1 PORT=6667 OPERATION_PROPORTION=0:1:1:1:1:1:1:1:1:1:1 @@ -1459,7 +1458,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=true DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ANOTHER DBConfig= DB_SWITCH=TimescaleDB @@ -1561,7 +1560,7 @@ VALUE_RANGE_QUERY_DESC 1.61 0.14 0.30 0.43 0.72 [快速指引](./tdengine/README.md) # 8. 正确性验证的进一步说明 -1. 目前正确性验证部分仅支持IoTDB v0.13 及更新的版本和TimeScaleDB +1. 目前正确性验证部分仅支持IoTDB v1.0 及更新的版本和TimeScaleDB 2. [快速指引](verification/README.md) # 9. 自动化脚本 @@ -1629,7 +1628,7 @@ LOOP=50 DEVICE_NUMBER=20 TEST 2. iot-benchmark的所有的数据库测试的实现均在各个maven子项目中。 3. 如果你想要使用IDEA等编辑器运行Benchmark: 1. 可以在每一个maven子项目下找到test文件目录下的TestEntrance,运行对应测试。 - 2. 以IoTDB 0.13为例,你可以运行`iotdb-0.13/src/main/test/cn/edu/tsinghua/iotdb/benchmark/TestEntrance` + 2. 以IoTDB 1.0为例,你可以运行`iotdb-1.0/src/main/test/cn/edu/tsinghua/iotdb/benchmark/TestEntrance` # 11. 相关文章 Benchmark Time Series Database with iot-benchmark for IoT Scenarios diff --git a/README.md b/README.md index 8440d6672..d8f022c5a 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ To use iot-benchmark, you need to have: 1. Java 8 2. Maven: It is not recommended to use the mirror. 3. The appropriate version of the database - - Apache IoTDB >= v0.13 ([Get it!](https://github.com/apache/iotdb)) + - Apache IoTDB >= v1.0 ([Get it!](https://github.com/apache/iotdb)) - His corresponding version of the database 4. CSV recording modes can only be used in Linux systems to record relevant system information during the test. @@ -134,8 +134,8 @@ To use iot-benchmark, you need to have: | :------------------------: | :-------------------: | :-------------------------------------------------------------------------------------------------------------------------------- | | Conventional test mode | testWithDefaultPath | Supports mixed loads of multiple read and write operations | | Generate data mode | generateDataMode | Benchmark generates the data set to the FILE_PATH path | -| Write mode of verification | verificationWriteMode | Load the data set from the FILE_PATH path for writing, currently supports IoTDB v0.13 and newer version is supported | -| Query mode of verification | verificationQueryMode | Load the data set from the FILE_PATH path and compare it with the database. Currently, IoTDB v0.13 and newer version is supported | +| Write mode of verification | verificationWriteMode | Load the data set from the FILE_PATH path for writing, currently supports IoTDB v1.0 and newer version is supported | +| Query mode of verification | verificationQueryMode | Load the data set from the FILE_PATH path and compare it with the database. Currently, IoTDB v1.0 and newer version is supported | ## 5.3. Build of iot-benchmark @@ -147,16 +147,15 @@ mvn clean package -Dmaven.test.skip=true This will compile all versions of IoTDB and other database benchmarks. if you want to compile a specific database, go to the package and run the above command. -After, for example, you can go to `/iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`, and run `./benchmark.sh` to start iot-benchmark. +After, for example, you can go to `/iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`, and run `./benchmark.sh` to start iot-benchmark. -The default configuration file is stored under `iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13/conf`, you can edit `config.properties` to complete the configuration, please **note that you need to Adjust the DB_SWITCH parameter in the configuration file to the database you need to be tested**. The corresponding relationship and possible values are as follows: +The default configuration file is stored under `iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0/conf`, you can edit `config.properties` to complete the configuration, please **note that you need to Adjust the DB_SWITCH parameter in the configuration file to the database you need to be tested**. The corresponding relationship and possible values are as follows: | Database | Version | Corresponding Sub-project | DB_SWITCH | | :------------------: | :------: | :-----------------------: | :----------------------------------------------------------------------------------------------------------: | | IoTDB | 1.3 | iotdb-1.3 | IoTDB-130-JDBC
IoTDB-130-SESSION_BY_TABLET
IoTDB-130-SESSION_BY_RECORD
IoTDB-130-SESSION_BY_RECORDS | | IoTDB | 1.1 | iotdb-1.1 | IoTDB-110-JDBC
IoTDB-110-SESSION_BY_TABLET
IoTDB-110-SESSION_BY_RECORD
IoTDB-110-SESSION_BY_RECORDS | | IoTDB | 1.0 | iotdb-1.0 | IoTDB-100-JDBC
IoTDB-100-SESSION_BY_TABLET
IoTDB-100-SESSION_BY_RECORD
IoTDB-100-SESSION_BY_RECORDS | -| IoTDB | 0.13 | iotdb-0.13 | IoTDB-013-JDBC
IoTDB-013-SESSION_BY_TABLET
IoTDB-013-SESSION_BY_RECORD
IoTDB-013-SESSION_BY_RECORDS | | InfluxDB | v1.x | influxdb | InfluxDB | | InfluxDB | v2.0 | influxdb-2.0 | InfluxDB-2.0 | | QuestDB | v6.0.7 | questdb | QuestDB | @@ -209,7 +208,7 @@ edit the corresponding parameters in the ```config.properties``` file as followi ```properties HOST=127.0.0.1 PORT=6667 -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET BENCHMARK_WORK_MODE=testWithDefaultPath OPERATION_PROPORTION=1:0:0:0:0:0:0:0:0:0:0 GROUP_NUMBER=10 @@ -227,7 +226,7 @@ Currently, you can edit other configs, more config in [config.properties](config Before running the test, you need to open the IoTDB service on port 6667. -Then, you can go to `/iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`, and run the startup script, currently we only support Unix/OS X system: +Then, you can go to `/iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`, and run the startup script, currently we only support Unix/OS X system: ```sh > ./benchmark.sh @@ -257,7 +256,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -366,7 +365,7 @@ Edit the corresponding parameters in the ```config.properties``` file as followi HOST=127.0.0.1 PORT=6667 IS_DELETE_DATA=false -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET BENCHMARK_WORK_MODE=testWithDefaultPath OPERATION_PROPORTION=0:1:1:1:1:1:1:1:1:1:1 GROUP_NUMBER=10 @@ -399,7 +398,7 @@ GROUP_BY_TIME_UNIT=20000 Before running the test, you need to open the IoTDB service on port 6667. -Then, you can go to `/iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`, and run the startup script, currently we only support Unix/OS X system: +Then, you can go to `/iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`, and run the startup script, currently we only support Unix/OS X system: ```sh > ./benchmark.sh @@ -428,7 +427,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -511,7 +510,7 @@ Modify the relevant parameters in the ```config.properties``` file as follows (p HOST=127.0.0.1 PORT=6667 IS_DELETE_DATA=false -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET BENCHMARK_WORK_MODE=testWithDefaultPath OPERATION_PROPORTION=1:1:1:1:1:1:1:1:1:1:1 GROUP_NUMBER=10 @@ -542,7 +541,7 @@ GROUP_BY_TIME_UNIT=20000 Before starting the test, you need to start the IoTDB service on port 6667 of the machine. -Then you enter `iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13` and run the following command to start Benchmark (currently only execute the following script in Unix/OS X system): +Then you enter `iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0` and run the following command to start Benchmark (currently only execute the following script in Unix/OS X system): ```sh > ./benchmark.sh @@ -571,7 +570,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -650,7 +649,7 @@ Modify the relevant parameters in the ```config.properties``` file as follows (p HOST=127.0.0.1 PORT=6667 IS_DELETE_DATA=false -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET BENCHMARK_WORK_MODE=testWithDefaultPath OPERATION_PROPORTION=1:1:1:1:1:1:1:1:1:1:1 GROUP_NUMBER=10 @@ -681,7 +680,7 @@ GROUP_BY_TIME_UNIT=20000 Before starting the test, you need to start the IoTDB service on port 6667 of the machine. -Then you enter `iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13` and run the following command to start Benchmark (currently only execute the following script in Unix/OS X system): +Then you enter `iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0` and run the following command to start Benchmark (currently only execute the following script in Unix/OS X system): ```sh > ./benchmark.sh @@ -710,7 +709,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -800,7 +799,7 @@ MONITOR_INTERVAL=0 Before running the test, you need to open the IoTDB service on port 6667. -Then, you can go to `/iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`, and run the startup script, currently we only support Unix/OS X system: +Then, you can go to `/iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`, and run the startup script, currently we only support Unix/OS X system: ```sh > ./benchmark.sh @@ -861,7 +860,7 @@ BIG_BATCH_SIZE=100 ### 6.7.2. Start -Then, you can go to `/iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`, and run the startup script, currently we only support Unix/OS X system: +Then, you can go to `/iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`, and run the startup script, currently we only support Unix/OS X system: ```sh > ./benchmark.sh @@ -928,7 +927,7 @@ SENSORS=[s_0, s_1, s_2, s_3, s_4, s_5, s_6, s_7, s_8, s_9] ## 6.8. Write mode for Verificaiton (single database, external data set) -In order to verify the correctness of the data set writing, you can use this mode to write the data set generated in the generated data mode. Currently this mode only supports IoTDB v0.13 and newer version, influxdb v1.x +In order to verify the correctness of the data set writing, you can use this mode to write the data set generated in the generated data mode. Currently this mode only supports IoTDB v1.0 and newer version, influxdb v1.x ### 6.8.1. Configure @@ -973,7 +972,7 @@ After that, you can start it. Before running the test, you need to open the IoTDB service on port 6667. -Then, you can go to `/iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`, and run the startup script, currently we only support Unix/OS X system: +Then, you can go to `/iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`, and run the startup script, currently we only support Unix/OS X system: ```sh > ./benchmark.sh @@ -1002,7 +1001,7 @@ BENCHMARK_WORK_MODE=verificationWriteMode ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -1046,7 +1045,7 @@ INGESTION 0.52 0.02 0.02 0.03 0.03 Before running this mode, you need to use the correctness write mode to write data to the database. -In order to verify the correctness of the data set writing, you can use this mode to query the data set written to the database. Currently this mode only supports IoTDB v0.13 and newer version, influxdb v1.x +In order to verify the correctness of the data set writing, you can use this mode to query the data set written to the database. Currently this mode only supports IoTDB v1.0 and newer version, influxdb v1.x ### 6.9.1. Configure @@ -1069,7 +1068,7 @@ BIG_BATCH_SIZE=100 Before running the test, you need to open the IoTDB service on port 6667. -Then, you can go to `/iot-benchmark/iotdb-0.13/target/iot-benchmark-iotdb-0.13`, and run the startup script, currently we only support Unix/OS X system: +Then, you can go to `/iot-benchmark/iotdb-1.0/target/iot-benchmark-iotdb-1.0`, and run the startup script, currently we only support Unix/OS X system: ```sh > ./benchmark.sh @@ -1098,7 +1097,7 @@ BENCHMARK_WORK_MODE=verificationQueryMode ########### Database Connection Information ########### DOUBLE_WRITE=false DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ########### Data Mode ########### GROUP_NUMBER=10 @@ -1143,7 +1142,7 @@ VERIFICATION_QUERY 14.48 0.96 11.40 12.67 14.43 In order to more conveniently and quickly complete the correctness verification, iot-benchmark also supports dual database mode. 1. For all the test scenarios mentioned above, unless otherwise specified, dual databases are supported. Please **start the test** in the `verification` project. -2. For the relevant test scenarios for correctness verification below, all must be run in dual database mode, and currently **only supports** iotdb-0.13 and newer version, and timescaledb. +2. For the relevant test scenarios for correctness verification below, all must be run in dual database mode, and currently **only supports** iotdb-1.0 and newer version, and timescaledb. In order to complete the dual database configuration, you need to make the following modifications to `config.properties`: @@ -1182,7 +1181,7 @@ In addition, please modify the following configuration in `config.properties`: ``` BENCHMARK_WORK_MODE=testWithDefaultPath -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=127.0.0.1 PORT=6667 OPERATION_PROPORTION=1:0:0:0:0:0:0:0:0:0:0 @@ -1228,7 +1227,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=true DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ANOTHER DBConfig= DB_SWITCH=TimescaleDB @@ -1312,7 +1311,7 @@ In addition, please modify the following configuration in `config.properties`: ``` BENCHMARK_WORK_MODE=testWithDefaultPath -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=127.0.0.1 PORT=6667 OPERATION_PROPORTION=1:0:0:0:0:0:0:0:0:0:0 @@ -1358,7 +1357,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=true DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ANOTHER DBConfig= DB_SWITCH=TimescaleDB @@ -1426,7 +1425,7 @@ In addition, please modify the following configuration in `config.properties` (N ``` BENCHMARK_WORK_MODE=testWithDefaultPath -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=127.0.0.1 PORT=6667 OPERATION_PROPORTION=0:1:1:1:1:1:1:1:1:1:1 @@ -1472,7 +1471,7 @@ BENCHMARK_WORK_MODE=testWithDefaultPath ########### Database Connection Information ########### DOUBLE_WRITE=true DBConfig= - DB_SWITCH=IoTDB-013-SESSION_BY_TABLET + DB_SWITCH=IoTDB-100-SESSION_BY_TABLET HOST=[127.0.0.1] ANOTHER DBConfig= DB_SWITCH=TimescaleDB @@ -1583,7 +1582,7 @@ VALUE_RANGE_QUERY_DESC 1.61 0.14 0.30 0.43 0.72 # 8. Further explanation of correctness verification -1. Now verification **only support** IoTDB v0.13 and newer version, TimescaleDB +1. Now verification **only support** IoTDB v1.0 and newer version, TimescaleDB 2. [Quick Start](verification/README.md) # 9. Perform Multiple Tests Automatically @@ -1637,7 +1636,7 @@ In this case, if you want to know what is going on, you can check the log inform 2. The realization of all database tests of iot-benchmark are in each maven sub-project. 3. If you want to use an editor such as IDEA to run Benchmark: 1. You can find TestEntrance in the test file directory under each maven subproject, and run the corresponding test. - 2. Taking IoTDB 0.13 as an example, you can run `iotdb-0.13/src/main/test/cn/edu/tsinghua/iotdb/benchmark/TestEntrance` + 2. Taking IoTDB 1.0 as an example, you can run `iotdb-1.0/src/main/test/cn/edu/tsinghua/iotdb/benchmark/TestEntrance` # 11. Related Article diff --git a/configuration/conf/README-cn.md b/configuration/conf/README-cn.md index 65a94dac3..51e24dd4d 100644 --- a/configuration/conf/README-cn.md +++ b/configuration/conf/README-cn.md @@ -13,7 +13,7 @@ DNW=1时,搭配效果应与加入跨设备Batch之前完全一致,**此处分析DNW>1的情况** - 与DB_SWITCH: - - 数据库版本:目前支持IoTDB-013、IoTDB-110 + - 数据库版本:IoTDB-110及更新版本 - insert方式:SESSION_BY_RECORDS模式允许DNW>1,SESSION_BY_RECORD、SESSION_BY_TABLET模式只允许DNW=1,参数不匹配则报错"The combination of DEVICE_NUM_PER_WRITE and insert-mode is not supported" - 与BATCH_SIZE_PER_WRITE:BATCH_SIZE_PER_WRITE含义为单次向单个设备写入的行数,单次写入的总行数为DNW×BATCH_SIZE_PER_WRITE - 与IS_CLIENT_BIND:支持true与false diff --git a/configuration/conf/README.md b/configuration/conf/README.md index ac55784fa..8bdece818 100644 --- a/configuration/conf/README.md +++ b/configuration/conf/README.md @@ -15,7 +15,7 @@ When `DNW`=1, the combination effect should be exactly the same as before adding So we only analyze the case where `DNW`>1. - With `DB_SWITCH`: - - Database version: Currently only supports `IoTDB-013`. + - Database version: Currently only supports `IoTDB-110` and newer. - Insert mode: `SESSION_BY_RECORDS` mode allows `DNW`>1, `SESSION_BY_RECORD` and `SESSION_BY_TABLET` modes only allow `DNW`=1, and an error will be reported if the parameters do not match("The combination of DEVICE_NUM_PER_WRITE and insert-mode is not supported"). - With `BATCH_SIZE_PER_WRITE`: `BATCH_SIZE_PER_WRITE` refers to the number of rows written to a single device in a single write operation. The total number of rows written in a single operation is `DNW` × `BATCH_SIZE_PER_WRITE`. - With `IS_CLIENT_BIND`: True and false are both supported. diff --git a/configuration/conf/config.properties b/configuration/conf/config.properties index 55f8f02d6..8e08611fc 100644 --- a/configuration/conf/config.properties +++ b/configuration/conf/config.properties @@ -76,7 +76,7 @@ # IS_DOUBLE_WRITE=false # 另一个写入的数据库,目前的格式为{name}{-version}{-insert mode}(注意-号)其全部参考值参见README文件 -# ANOTHER_DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +# ANOTHER_DB_SWITCH=IoTDB-100-SESSION_BY_TABLET # 另一个写入的数据库的主机 # ANOTHER_HOST=127.0.0.1 @@ -177,7 +177,7 @@ # 是否使用vector # VECTOR=true -# 是否使用Debug模式,仅支持iotdb-0.13 +# 是否使用Debug模式,仅支持iotdb # IOTDB_USE_DEBUG=false # 使用DEBUG查询的比率 [0, 1] diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/Config.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/Config.java index 42f92e7a6..fc8400faf 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/Config.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/Config.java @@ -218,7 +218,7 @@ public class Config { private String TEMPLATE_NAME = "BenchmarkTemplate"; /** Whether to use vector */ private boolean VECTOR = true; - /** whether to use debug in iotdb-0.13 */ + /** whether to use debug in iotdb */ private boolean IOTDB_USE_DEBUG = false; /** the ratio of use debug */ private double IOTDB_USE_DEBUG_RATIO = 0.01; diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/ConfigDescriptor.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/ConfigDescriptor.java index 1d8d041c5..cd1a7c4b7 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/ConfigDescriptor.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/ConfigDescriptor.java @@ -715,11 +715,10 @@ private void checkQuery() { private boolean checkDatabaseVerification(DBConfig dbConfig) { boolean result = false; if (dbConfig.getDB_SWITCH().getType() == DBType.IoTDB) { - // support after iotdb 0.13 + // support after iotdb 1.0 if (dbConfig.getDB_SWITCH().getVersion() == DBVersion.IOTDB_130 || dbConfig.getDB_SWITCH().getVersion() == DBVersion.IOTDB_110 - || dbConfig.getDB_SWITCH().getVersion() == DBVersion.IOTDB_100 - || dbConfig.getDB_SWITCH().getVersion() == DBVersion.IOTDB_013) { + || dbConfig.getDB_SWITCH().getVersion() == DBVersion.IOTDB_100) { result = true; } } else if (dbConfig.getDB_SWITCH().getType() == DBType.InfluxDB) { @@ -735,7 +734,7 @@ private boolean checkDatabaseVerification(DBConfig dbConfig) { } if (!result) { LOGGER.error( - "Verification only support between iotdb v0.13 and newer version, timescaledb and influxdb 1.x"); + "Verification only support between iotdb v1.0 and newer version, timescaledb and influxdb 1.x"); } return result; } diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/Constants.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/Constants.java index d660a55f7..09373b5b0 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/Constants.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/conf/Constants.java @@ -69,12 +69,6 @@ public class Constants { public static final String IOTDB100_ROUNDROBIN_SESSION_CLASS = "cn.edu.tsinghua.iot.benchmark.iotdb100.IoTDBClusterSession"; - public static final String IOTDB013_JDBC_CLASS = "cn.edu.tsinghua.iot.benchmark.iotdb013.IoTDB"; - public static final String IOTDB013_SESSION_CLASS = - "cn.edu.tsinghua.iot.benchmark.iotdb013.IoTDBSession"; - public static final String IOTDB013_ROUNDROBIN_SESSION_CLASS = - "cn.edu.tsinghua.iot.benchmark.iotdb013.IoTDBClusterSession"; - public static final String INFLUXDB_CLASS = "cn.edu.tsinghua.iot.benchmark.influxdb.InfluxDB"; public static final String INFLUXDB2_CLASS = "cn.edu.tsinghua.iot.benchmark.influxdb2.InfluxDB"; public static final String CNOSDB_CLASS = "cn.edu.tsinghua.iot.benchmark.cnosdb.CnosDB"; diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/DBFactory.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/DBFactory.java index 83b80824c..5b3740d6c 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/DBFactory.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/DBFactory.java @@ -77,19 +77,6 @@ public IDatabase getDatabase(DBConfig dbConfig) throws SQLException { dbClass = Constants.IOTDB100_SESSION_CLASS; } break; - // IoTDB 0.13 - case DB_IOT_013_JDBC: - dbClass = Constants.IOTDB013_JDBC_CLASS; - break; - case DB_IOT_013_SESSION_BY_TABLET: - case DB_IOT_013_SESSION_BY_RECORD: - case DB_IOT_013_SESSION_BY_RECORDS: - if (config.isIS_ALL_NODES_VISIBLE()) { - dbClass = Constants.IOTDB013_ROUNDROBIN_SESSION_CLASS; - } else { - dbClass = Constants.IOTDB013_SESSION_CLASS; - } - break; case DB_INFLUX: dbClass = Constants.INFLUXDB_CLASS; break; diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/enums/DBSwitch.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/enums/DBSwitch.java index a33a1349e..9d01a7d03 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/enums/DBSwitch.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/enums/DBSwitch.java @@ -44,13 +44,6 @@ public enum DBSwitch { DBType.IoTDB, DBVersion.IOTDB_100, DBInsertMode.INSERT_USE_SESSION_RECORD), DB_IOT_100_SESSION_BY_RECORDS( DBType.IoTDB, DBVersion.IOTDB_100, DBInsertMode.INSERT_USE_SESSION_RECORDS), - DB_IOT_013_JDBC(DBType.IoTDB, DBVersion.IOTDB_013, DBInsertMode.INSERT_USE_JDBC), - DB_IOT_013_SESSION_BY_TABLET( - DBType.IoTDB, DBVersion.IOTDB_013, DBInsertMode.INSERT_USE_SESSION_TABLET), - DB_IOT_013_SESSION_BY_RECORD( - DBType.IoTDB, DBVersion.IOTDB_013, DBInsertMode.INSERT_USE_SESSION_RECORD), - DB_IOT_013_SESSION_BY_RECORDS( - DBType.IoTDB, DBVersion.IOTDB_013, DBInsertMode.INSERT_USE_SESSION_RECORDS), DB_DOUBLE_IOT(DBType.DoubleIoTDB, null, null), DB_INFLUX(DBType.InfluxDB, null, null), diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/enums/DBVersion.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/enums/DBVersion.java index 192c63d63..669bd0584 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/enums/DBVersion.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/enums/DBVersion.java @@ -23,7 +23,6 @@ public enum DBVersion { IOTDB_130("130"), IOTDB_110("110"), IOTDB_100("100"), - IOTDB_013("013"), InfluxDB_2("2.x"), TimescaleDB_Cluster("cluster"), TDengine_3("3"); diff --git a/iotdb-0.13/pom.xml b/iotdb-0.13/pom.xml deleted file mode 100644 index 0ef6194cf..000000000 --- a/iotdb-0.13/pom.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - 4.0.0 - - cn.edu.tsinghua - iot-benchmark - 1.0.0 - ../pom.xml - - iotdb-0.13 - Benchmark IoTDB 0.13 - - - - cn.edu.tsinghua - core - ${project.version} - - - org.apache.iotdb - iotdb-jdbc - 0.13.4 - - - org.apache.iotdb - iotdb-session - 0.13.4 - - - - - iot-benchmark-iotdb-0.13 - - - org.apache.maven.plugins - maven-assembly-plugin - 3.1.0 - - - - server-assembly - package - - single - - - - src/assembly/assembly.xml - - false - - - true - true - - - - - - - - - diff --git a/iotdb-0.13/src/assembly/assembly.xml b/iotdb-0.13/src/assembly/assembly.xml deleted file mode 100644 index b7b529671..000000000 --- a/iotdb-0.13/src/assembly/assembly.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - IoTDB-0.13 - - dir - zip - - true - - - lib - - - - - ${maven.multiModuleProjectDirectory}/configuration/bin/ - bin - 0755 - - - ${maven.multiModuleProjectDirectory}/configuration/conf/ - conf - - - - - ${maven.multiModuleProjectDirectory}/configuration/benchmark.bat - - - ${maven.multiModuleProjectDirectory}/configuration/benchmark.sh - 0755 - - - ${maven.multiModuleProjectDirectory}/configuration/rep-benchmark.sh - 0755 - - - - ${maven.multiModuleProjectDirectory}/configuration/cli-benchmark.sh - 0755 - - - ${maven.multiModuleProjectDirectory}/configuration/routine - - - ${maven.multiModuleProjectDirectory}/LICENSE - - - diff --git a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDB.java b/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDB.java deleted file mode 100644 index 2e43fe13b..000000000 --- a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDB.java +++ /dev/null @@ -1,932 +0,0 @@ -/* - * 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 cn.edu.tsinghua.iot.benchmark.iotdb013; - -import org.apache.iotdb.isession.template.Template; -import org.apache.iotdb.isession.util.Version; -import org.apache.iotdb.rpc.IoTDBConnectionException; -import org.apache.iotdb.rpc.StatementExecutionException; -import org.apache.iotdb.session.Session; -import org.apache.iotdb.session.template.MeasurementNode; -import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType; -import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; -import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding; - -import cn.edu.tsinghua.iot.benchmark.client.operation.Operation; -import cn.edu.tsinghua.iot.benchmark.conf.Config; -import cn.edu.tsinghua.iot.benchmark.conf.ConfigDescriptor; -import cn.edu.tsinghua.iot.benchmark.entity.Batch.IBatch; -import cn.edu.tsinghua.iot.benchmark.entity.DeviceSummary; -import cn.edu.tsinghua.iot.benchmark.entity.Record; -import cn.edu.tsinghua.iot.benchmark.entity.Sensor; -import cn.edu.tsinghua.iot.benchmark.entity.enums.SensorType; -import cn.edu.tsinghua.iot.benchmark.exception.DBConnectException; -import cn.edu.tsinghua.iot.benchmark.measurement.Status; -import cn.edu.tsinghua.iot.benchmark.schema.schemaImpl.DeviceSchema; -import cn.edu.tsinghua.iot.benchmark.tsdb.DBConfig; -import cn.edu.tsinghua.iot.benchmark.tsdb.IDatabase; -import cn.edu.tsinghua.iot.benchmark.tsdb.TsdbException; -import cn.edu.tsinghua.iot.benchmark.utils.TimeUtils; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.AggRangeQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.AggRangeValueQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.AggValueQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.DeviceQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.GroupByQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.LatestPointQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.PreciseQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.RangeQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.ValueRangeQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.VerificationQuery; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.CyclicBarrier; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; - -/** this class will create more than one connection. */ -public class IoTDB implements IDatabase { - - private static final Logger LOGGER = LoggerFactory.getLogger(IoTDB.class); - private static final String ALREADY_KEYWORD = "already"; - private static final String TEMPLATE_NAME = "BenchmarkTemplate"; - private static final AtomicBoolean templateInit = new AtomicBoolean(false); - protected final String DELETE_SERIES_SQL; - protected SingleNodeJDBCConnection ioTDBConnection; - - protected static final Config config = ConfigDescriptor.getInstance().getConfig(); - protected static final CyclicBarrier templateBarrier = - new CyclicBarrier(config.getCLIENT_NUMBER()); - protected static final CyclicBarrier schemaBarrier = new CyclicBarrier(config.getCLIENT_NUMBER()); - protected static Set storageGroups = Collections.synchronizedSet(new HashSet<>()); - protected final String ROOT_SERIES_NAME; - protected ExecutorService service; - protected Future future; - protected DBConfig dbConfig; - protected Random random = new Random(config.getDATA_SEED()); - - public IoTDB(DBConfig dbConfig) { - this.dbConfig = dbConfig; - ROOT_SERIES_NAME = "root." + dbConfig.getDB_NAME(); - DELETE_SERIES_SQL = "delete storage group root." + dbConfig.getDB_NAME() + ".*"; - } - - @Override - public void init() throws TsdbException { - if (ioTDBConnection == null) { - try { - ioTDBConnection = new SingleNodeJDBCConnection(dbConfig); - ioTDBConnection.init(); - this.service = Executors.newSingleThreadExecutor(); - } catch (Exception e) { - throw new TsdbException(e); - } - } - } - - @Override - public void cleanup() { - try (Statement statement = ioTDBConnection.getConnection().createStatement()) { - statement.execute(DELETE_SERIES_SQL); - LOGGER.info("Finish clean data!"); - } catch (Exception e) { - LOGGER.warn("No Data to Clean!"); - } - } - - @Override - public void close() throws TsdbException { - if (ioTDBConnection != null) { - ioTDBConnection.close(); - } - if (service != null) { - service.shutdownNow(); - } - if (future != null) { - future.cancel(true); - } - } - - @Override - public Double registerSchema(List schemaList) throws TsdbException { - // create timeseries one by one is too slow in current cluster server. - // therefore, we use session to create time series in batch. - long start = System.nanoTime(); - long end; - if (config.hasWrite()) { - Map> sessionListMap = new HashMap<>(); - try { - // open meta session - if (!config.isIS_ALL_NODES_VISIBLE()) { - Session metaSession = - new Session.Builder() - .host(dbConfig.getHOST().get(0)) - .port(Integer.parseInt(dbConfig.getPORT().get(0))) - .username(dbConfig.getUSERNAME()) - .password(dbConfig.getPASSWORD()) - .version(Version.V_0_13) - .build(); - metaSession.open(config.isENABLE_THRIFT_COMPRESSION()); - sessionListMap.put(metaSession, createTimeseries(schemaList)); - } else { - int sessionNumber = dbConfig.getHOST().size(); - List keys = new ArrayList<>(); - for (int i = 0; i < sessionNumber; i++) { - Session metaSession = - new Session.Builder() - .host(dbConfig.getHOST().get(i)) - .port(Integer.parseInt(dbConfig.getPORT().get(i))) - .username(dbConfig.getUSERNAME()) - .password(dbConfig.getPASSWORD()) - .version(Version.V_0_13) - .build(); - metaSession.open(config.isENABLE_THRIFT_COMPRESSION()); - keys.add(metaSession); - sessionListMap.put(metaSession, new ArrayList<>()); - } - for (int i = 0; i < schemaList.size(); i++) { - sessionListMap - .get(keys.get(i % sessionNumber)) - .add(createTimeseries(schemaList.get(i))); - } - } - - if (config.isTEMPLATE() && templateInit.compareAndSet(false, true)) { - Template template = null; - if (config.isTEMPLATE() && schemaList.size() > 0) { - template = createTemplate(schemaList.get(0)); - } - start = System.nanoTime(); - int sessionIndex = random.nextInt(sessionListMap.size()); - Session templateSession = new ArrayList<>(sessionListMap.keySet()).get(sessionIndex); - registerTemplate(templateSession, template); - } else { - start = System.nanoTime(); - } - templateBarrier.await(); - for (Map.Entry> pair : sessionListMap.entrySet()) { - registerStorageGroups(pair.getKey(), pair.getValue()); - } - schemaBarrier.await(); - if (!config.isTEMPLATE()) { - for (Map.Entry> pair : sessionListMap.entrySet()) { - registerTimeseries(pair.getKey(), pair.getValue()); - } - } - } catch (Exception e) { - throw new TsdbException(e); - } finally { - if (sessionListMap.size() != 0) { - Set sessions = sessionListMap.keySet(); - for (Session session : sessions) { - try { - session.close(); - } catch (IoTDBConnectionException e) { - LOGGER.error("Schema-register session cannot be closed: {}", e.getMessage()); - } - } - } - } - } - end = System.nanoTime(); - return TimeUtils.convertToSeconds(end - start, "ns"); - } - - /** create template */ - private Template createTemplate(DeviceSchema deviceSchema) { - Template template = null; - if (config.isTEMPLATE()) { - if (config.isVECTOR()) { - template = new Template(TEMPLATE_NAME, true); - } else { - template = new Template(TEMPLATE_NAME, false); - } - try { - for (Sensor sensor : deviceSchema.getSensors()) { - MeasurementNode measurementNode = - new MeasurementNode( - sensor.getName(), - Enum.valueOf(TSDataType.class, sensor.getSensorType().name), - Enum.valueOf(TSEncoding.class, getEncodingType(sensor.getSensorType())), - Enum.valueOf(CompressionType.class, config.getCOMPRESSOR())); - template.addToTemplate(measurementNode); - } - } catch (StatementExecutionException e) { - LOGGER.error(e.getMessage()); - return null; - } - } - return template; - } - - /** register template */ - private void registerTemplate(Session metaSession, Template template) - throws IoTDBConnectionException, IOException { - try { - metaSession.createSchemaTemplate(template); - } catch (StatementExecutionException ignore) { - // do nothing - } - } - - private void registerStorageGroups(Session metaSession, List schemaList) - throws TsdbException { - // get all storage groups - Set groups = new HashSet<>(); - for (TimeseriesSchema timeseriesSchema : schemaList) { - DeviceSchema schema = timeseriesSchema.getDeviceSchema(); - synchronized (IoTDB.class) { - if (!storageGroups.contains(schema.getGroup())) { - groups.add(schema.getGroup()); - storageGroups.add(schema.getGroup()); - } - } - } - // register storage groups - for (String group : groups) { - try { - metaSession.setStorageGroup(ROOT_SERIES_NAME + "." + group); - if (config.isTEMPLATE()) { - metaSession.setSchemaTemplate(TEMPLATE_NAME, ROOT_SERIES_NAME + "." + group); - } - } catch (Exception e) { - handleRegisterException(e); - } - } - } - - private TimeseriesSchema createTimeseries(DeviceSchema deviceSchema) { - List paths = new ArrayList<>(); - List tsDataTypes = new ArrayList<>(); - List tsEncodings = new ArrayList<>(); - List compressionTypes = new ArrayList<>(); - for (Sensor sensor : deviceSchema.getSensors()) { - if (config.isVECTOR()) { - paths.add(sensor.getName()); - } else { - paths.add(getSensorPath(deviceSchema, sensor.getName())); - } - SensorType datatype = sensor.getSensorType(); - tsDataTypes.add(Enum.valueOf(TSDataType.class, datatype.name)); - tsEncodings.add(Enum.valueOf(TSEncoding.class, getEncodingType(datatype))); - compressionTypes.add(Enum.valueOf(CompressionType.class, config.getCOMPRESSOR())); - } - TimeseriesSchema timeseriesSchema = - new TimeseriesSchema(deviceSchema, paths, tsDataTypes, tsEncodings, compressionTypes); - if (config.isVECTOR()) { - timeseriesSchema.setDeviceId(getDevicePath(deviceSchema)); - } - return timeseriesSchema; - } - - private List createTimeseries(List schemaList) { - List timeseriesSchemas = new ArrayList<>(); - for (DeviceSchema deviceSchema : schemaList) { - TimeseriesSchema timeseriesSchema = createTimeseries(deviceSchema); - timeseriesSchemas.add(timeseriesSchema); - } - return timeseriesSchemas; - } - - private void registerTimeseries(Session metaSession, List timeseriesSchemas) - throws TsdbException { - // create time series - for (TimeseriesSchema timeseriesSchema : timeseriesSchemas) { - try { - if (config.isVECTOR()) { - metaSession.createAlignedTimeseries( - timeseriesSchema.getDeviceId(), - timeseriesSchema.getPaths(), - timeseriesSchema.getTsDataTypes(), - timeseriesSchema.getTsEncodings(), - timeseriesSchema.getCompressionTypes(), - null); - } else { - metaSession.createMultiTimeseries( - timeseriesSchema.getPaths(), - timeseriesSchema.getTsDataTypes(), - timeseriesSchema.getTsEncodings(), - timeseriesSchema.getCompressionTypes(), - null, - null, - null, - null); - } - } catch (Exception e) { - handleRegisterException(e); - } - } - } - - private void handleRegisterException(Exception e) throws TsdbException { - // ignore if already has the time series - if (!e.getMessage().contains(ALREADY_KEYWORD) && !e.getMessage().contains("300")) { - LOGGER.error("Register IoTDB schema failed because ", e); - throw new TsdbException(e); - } - } - - @Override - public Status insertOneBatch(IBatch batch) throws DBConnectException { - try (Statement statement = ioTDBConnection.getConnection().createStatement()) { - for (Record record : batch.getRecords()) { - String sql = - getInsertOneBatchSql( - batch.getDeviceSchema(), record.getTimestamp(), record.getRecordDataValue()); - statement.addBatch(sql); - } - statement.executeBatch(); - return new Status(true); - } catch (Exception e) { - return new Status(false, 0, e, e.toString()); - } - } - - /** - * Q1: PreciseQuery SQL: select {sensors} from {devices} where time = {time} - * - * @param preciseQuery universal precise query condition parameters - * @return - */ - @Override - public Status preciseQuery(PreciseQuery preciseQuery) { - String strTime = preciseQuery.getTimestamp() + ""; - String sql = getSimpleQuerySqlHead(preciseQuery.getDeviceSchema()) + " WHERE time = " + strTime; - return executeQueryAndGetStatus(sql, Operation.PRECISE_QUERY); - } - - /** - * Q2: RangeQuery SQL: select {sensors} from {devices} where time >= {startTime} and time <= - * {endTime} - * - * @param rangeQuery universal range query condition parameters - * @return - */ - @Override - public Status rangeQuery(RangeQuery rangeQuery) { - String sql = - getRangeQuerySql( - rangeQuery.getDeviceSchema(), - rangeQuery.getStartTimestamp(), - rangeQuery.getEndTimestamp()); - return executeQueryAndGetStatus(sql, Operation.RANGE_QUERY); - } - - /** - * Q3: ValueRangeQuery SQL: select {sensors} from {devices} where time >= {startTime} and time <= - * {endTime} and {sensors} > {value} - * - * @param valueRangeQuery contains universal range query with value filter parameters - * @return - */ - @Override - public Status valueRangeQuery(ValueRangeQuery valueRangeQuery) { - String sql = getValueRangeQuerySql(valueRangeQuery); - return executeQueryAndGetStatus(sql, Operation.VALUE_RANGE_QUERY); - } - - /** - * Q4: AggRangeQuery SQL: select {AggFun}({sensors}) from {devices} where time >= {startTime} and - * time <= {endTime} - * - * @param aggRangeQuery contains universal aggregation query with time filter parameters - * @return - */ - @Override - public Status aggRangeQuery(AggRangeQuery aggRangeQuery) { - String aggQuerySqlHead = - getAggQuerySqlHead(aggRangeQuery.getDeviceSchema(), aggRangeQuery.getAggFun()); - String sql = - addWhereTimeClause( - aggQuerySqlHead, aggRangeQuery.getStartTimestamp(), aggRangeQuery.getEndTimestamp()); - return executeQueryAndGetStatus(sql, Operation.AGG_RANGE_QUERY); - } - - /** - * Q5: AggValueQuery SQL: select {AggFun}({sensors}) from {devices} where {sensors} > {value} - * - * @param aggValueQuery contains universal aggregation query with value filter parameters - * @return - */ - @Override - public Status aggValueQuery(AggValueQuery aggValueQuery) { - String aggQuerySqlHead = - getAggQuerySqlHead(aggValueQuery.getDeviceSchema(), aggValueQuery.getAggFun()); - String sql = - aggQuerySqlHead - + " WHERE " - + getValueFilterClause( - aggValueQuery.getDeviceSchema(), (int) aggValueQuery.getValueThreshold()) - .substring(4); - return executeQueryAndGetStatus(sql, Operation.AGG_VALUE_QUERY); - } - - /** - * Q6: AggRangeValueQuery SQL: select {AggFun}({sensors}) from {devices} where time >= {startTime} - * and time <= {endTime} and {sensors} > {value} - * - * @param aggRangeValueQuery contains universal aggregation query with time and value filters - * parameters - * @return - */ - @Override - public Status aggRangeValueQuery(AggRangeValueQuery aggRangeValueQuery) { - String aggQuerySqlHead = - getAggQuerySqlHead(aggRangeValueQuery.getDeviceSchema(), aggRangeValueQuery.getAggFun()); - String sql = - addWhereTimeClause( - aggQuerySqlHead, - aggRangeValueQuery.getStartTimestamp(), - aggRangeValueQuery.getEndTimestamp()); - sql += - getValueFilterClause( - aggRangeValueQuery.getDeviceSchema(), (int) aggRangeValueQuery.getValueThreshold()); - return executeQueryAndGetStatus(sql, Operation.AGG_RANGE_VALUE_QUERY); - } - - /** - * Q7: GroupByQuery SQL: select {AggFun}({sensors}) from {devices} group by ([{start}, {end}], - * {Granularity}ms) - * - * @param groupByQuery contains universal group by query condition parameters - * @return - */ - @Override - public Status groupByQuery(GroupByQuery groupByQuery) { - String aggQuerySqlHead = - getAggQuerySqlHead(groupByQuery.getDeviceSchema(), groupByQuery.getAggFun()); - String sql = - addGroupByClause( - aggQuerySqlHead, - groupByQuery.getStartTimestamp(), - groupByQuery.getEndTimestamp(), - groupByQuery.getGranularity()); - return executeQueryAndGetStatus(sql, Operation.GROUP_BY_QUERY); - } - - /** - * Q8: LatestPointQuery SQL: select last {sensors} from {devices} - * - * @param latestPointQuery contains universal latest point query condition parameters - * @return - */ - @Override - public Status latestPointQuery(LatestPointQuery latestPointQuery) { - String aggQuerySqlHead = getLatestPointQuerySql(latestPointQuery.getDeviceSchema()); - return executeQueryAndGetStatus(aggQuerySqlHead, Operation.LATEST_POINT_QUERY); - } - - /** - * Q9: RangeQuery SQL: select {sensors} from {devices} where time >= {startTime} and time <= - * {endTime} order by time desc - * - * @param rangeQuery universal range query condition parameters - * @return - */ - @Override - public Status rangeQueryOrderByDesc(RangeQuery rangeQuery) { - String sql = - getRangeQuerySql( - rangeQuery.getDeviceSchema(), - rangeQuery.getStartTimestamp(), - rangeQuery.getEndTimestamp()) - + " order by time desc"; - return executeQueryAndGetStatus(sql, Operation.RANGE_QUERY_ORDER_BY_TIME_DESC); - } - - /** - * Q10: ValueRangeQuery SQL: select {sensors} from {devices} where time >= {startTime} and time <= - * {endTime} and {sensors} > {value} order by time desc - * - * @param valueRangeQuery contains universal range query with value filter parameters - * @return - */ - @Override - public Status valueRangeQueryOrderByDesc(ValueRangeQuery valueRangeQuery) { - String sql = getValueRangeQuerySql(valueRangeQuery) + " order by time desc"; - return executeQueryAndGetStatus(sql, Operation.VALUE_RANGE_QUERY_ORDER_BY_TIME_DESC); - } - - /** - * Generate simple query header. - * - * @param devices schema list of query devices - * @return Simple Query header. e.g. Select sensors from devices - */ - protected String getSimpleQuerySqlHead(List devices) { - StringBuilder builder = new StringBuilder(); - builder.append("SELECT "); - List querySensors = devices.get(0).getSensors(); - builder.append(querySensors.get(0).getName()); - for (int i = 1; i < querySensors.size(); i++) { - builder.append(", ").append(querySensors.get(i).getName()); - } - return addFromClause(devices, builder); - } - - private String getAggQuerySqlHead(List devices, String aggFun) { - StringBuilder builder = new StringBuilder(); - builder.append("SELECT "); - List querySensors = devices.get(0).getSensors(); - builder.append(aggFun).append("(").append(querySensors.get(0).getName()).append(")"); - for (int i = 1; i < querySensors.size(); i++) { - builder - .append(", ") - .append(aggFun) - .append("(") - .append(querySensors.get(i).getName()) - .append(")"); - } - return addFromClause(devices, builder); - } - - /** - * Add from Clause - * - * @param devices - * @param builder - * @return From clause, e.g. FROM devices - */ - private String addFromClause(List devices, StringBuilder builder) { - builder.append(" FROM ").append(getDevicePath(devices.get(0))); - for (int i = 1; i < devices.size(); i++) { - builder.append(", ").append(getDevicePath(devices.get(i))); - } - return builder.toString(); - } - - private String getValueRangeQuerySql(ValueRangeQuery valueRangeQuery) { - String rangeQuerySql = - getRangeQuerySql( - valueRangeQuery.getDeviceSchema(), - valueRangeQuery.getStartTimestamp(), - valueRangeQuery.getEndTimestamp()); - String valueFilterClause = - getValueFilterClause( - valueRangeQuery.getDeviceSchema(), (int) valueRangeQuery.getValueThreshold()); - return rangeQuerySql + valueFilterClause; - } - - private String getValueFilterClause(List deviceSchemas, int valueThreshold) { - StringBuilder builder = new StringBuilder(); - for (DeviceSchema deviceSchema : deviceSchemas) { - for (Sensor sensor : deviceSchema.getSensors()) { - builder - .append(" AND ") - .append(getDevicePath(deviceSchema)) - .append(".") - .append(sensor.getName()) - .append(" > ") - .append(valueThreshold); - } - } - return builder.toString(); - } - - private String getLatestPointQuerySql(List devices) { - StringBuilder builder = new StringBuilder(); - builder.append("SELECT last "); - List querySensors = devices.get(0).getSensors(); - builder.append(querySensors.get(0).getName()); - for (int i = 1; i < querySensors.size(); i++) { - builder.append(", ").append(querySensors.get(i).getName()); - } - return addFromClause(devices, builder); - } - - private String getRangeQuerySql(List deviceSchemas, long start, long end) { - return addWhereTimeClause(getSimpleQuerySqlHead(deviceSchemas), start, end); - } - - private String addWhereTimeClause(String prefix, long start, long end) { - String startTime = start + ""; - String endTime = end + ""; - return prefix + " WHERE time >= " + startTime + " AND time <= " + endTime; - } - - private String addGroupByClause(String prefix, long start, long end, long granularity) { - return prefix + " group by ([" + start + "," + end + ")," + granularity + "ms) "; - } - - /** - * convert deviceSchema to the format - * - * @param deviceSchema - * @return format, e.g. root.group_1.d_1 - */ - protected String getDevicePath(DeviceSchema deviceSchema) { - StringBuilder name = new StringBuilder(ROOT_SERIES_NAME); - name.append(".").append(deviceSchema.getGroup()); - for (Map.Entry pair : deviceSchema.getTags().entrySet()) { - name.append(".").append(pair.getValue()); - } - name.append(".").append(deviceSchema.getDevice()); - return name.toString(); - } - - protected Status executeQueryAndGetStatus(String sql, Operation operation) { - String executeSQL; - if (config.isIOTDB_USE_DEBUG() && random.nextDouble() < config.getIOTDB_USE_DEBUG_RATIO()) { - executeSQL = "debug " + sql; - } else { - executeSQL = sql; - } - if (!config.isIS_QUIET_MODE()) { - LOGGER.info("{} query SQL: {}", Thread.currentThread().getName(), executeSQL); - } - AtomicLong queryResultPointNum = new AtomicLong(); - AtomicBoolean isOk = new AtomicBoolean(true); - try (Statement statement = ioTDBConnection.getConnection().createStatement()) { - List> records = new ArrayList<>(); - future = - service.submit( - () -> { - long resultNum = 0; - try (ResultSet resultSet = statement.executeQuery(executeSQL)) { - while (resultSet.next()) { - switch (operation) { - case LATEST_POINT_QUERY: - resultNum++; - break; - default: - resultNum += resultSet.getMetaData().getColumnCount() - 1; - break; - } - if (config.isIS_COMPARISON()) { - List record = new ArrayList<>(); - for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) { - switch (operation) { - case LATEST_POINT_QUERY: - if (i == 2 || i >= 4) { - continue; - } - break; - default: - break; - } - record.add(resultSet.getObject(i)); - } - records.add(record); - } - } - } catch (SQLException e) { - LOGGER.error("exception occurred when execute query={}", executeSQL, e); - isOk.set(false); - } - queryResultPointNum.set(resultNum); - }); - try { - future.get(config.getREAD_OPERATION_TIMEOUT_MS(), TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - future.cancel(true); - return new Status(false, queryResultPointNum.get(), e, executeSQL); - } - if (isOk.get()) { - if (config.isIS_COMPARISON()) { - return new Status(true, queryResultPointNum.get(), executeSQL, records); - } else { - return new Status(true, queryResultPointNum.get()); - } - } else { - return new Status( - false, queryResultPointNum.get(), new Exception("Failed to execute."), executeSQL); - } - } catch (Exception e) { - return new Status(false, queryResultPointNum.get(), e, executeSQL); - } catch (Throwable t) { - return new Status(false, queryResultPointNum.get(), new Exception(t), executeSQL); - } - } - - public String getInsertOneBatchSql( - DeviceSchema deviceSchema, long timestamp, List values) { - StringBuilder builder = new StringBuilder("insert into "); - builder.append(getDevicePath(deviceSchema)).append("(timestamp"); - for (Sensor sensor : deviceSchema.getSensors()) { - builder.append(",").append(sensor.getName()); - } - if (config.isVECTOR() == true) { - builder.append(") aligned values("); - } else { - builder.append(") values("); - } - builder.append(timestamp); - int sensorIndex = 0; - List sensors = deviceSchema.getSensors(); - for (Object value : values) { - switch (sensors.get(sensorIndex).getSensorType()) { - case BOOLEAN: - case INT32: - case INT64: - case FLOAT: - case DOUBLE: - builder.append(",").append(value); - break; - case TEXT: - builder.append(",").append("'").append(value).append("'"); - break; - } - sensorIndex++; - } - builder.append(")"); - LOGGER.debug("getInsertOneBatchSql: {}", builder); - return builder.toString(); - } - - /** - * Using in verification - * - * @param verificationQuery - */ - @Override - public Status verificationQuery(VerificationQuery verificationQuery) { - DeviceSchema deviceSchema = verificationQuery.getDeviceSchema(); - List deviceSchemas = new ArrayList<>(); - deviceSchemas.add(deviceSchema); - - List records = verificationQuery.getRecords(); - if (records == null || records.size() == 0) { - return new Status( - false, - new TsdbException("There are no records in verficationQuery."), - "There are no records in verficationQuery."); - } - - StringBuffer sql = new StringBuffer(); - sql.append(getSimpleQuerySqlHead(deviceSchemas)); - Map> recordMap = new HashMap<>(); - sql.append(" WHERE time = ").append(records.get(0).getTimestamp()); - recordMap.put(records.get(0).getTimestamp(), records.get(0).getRecordDataValue()); - for (int i = 1; i < records.size(); i++) { - Record record = records.get(i); - sql.append(" or time = ").append(record.getTimestamp()); - recordMap.put(record.getTimestamp(), record.getRecordDataValue()); - } - long point = 0; - int line = 0; - try (Statement statement = ioTDBConnection.getConnection().createStatement()) { - ResultSet resultSet = statement.executeQuery(sql.toString()); - while (resultSet.next()) { - long timeStamp = resultSet.getLong(1); - List values = recordMap.get(timeStamp); - for (int i = 0; i < values.size(); i++) { - String value = resultSet.getString(i + 2); - String target = String.valueOf(values.get(i)); - if (!value.equals(target)) { - LOGGER.error("Using SQL: " + sql + ",Expected:" + value + " but was: " + target); - } else { - point++; - } - } - line++; - } - } catch (Exception e) { - LOGGER.error("Query Error: " + sql); - return new Status(false, new TsdbException("Failed to query"), "Failed to query."); - } - if (recordMap.size() != line) { - LOGGER.error( - "Using SQL: " + sql + ",Expected line:" + recordMap.size() + " but was: " + line); - } - return new Status(true, point); - } - - @Override - public Status deviceQuery(DeviceQuery deviceQuery) throws SQLException, TsdbException { - DeviceSchema deviceSchema = deviceQuery.getDeviceSchema(); - String sql = - getDeviceQuerySql( - deviceSchema, deviceQuery.getStartTimestamp(), deviceQuery.getEndTimestamp()); - if (!config.isIS_QUIET_MODE()) { - LOGGER.info("IoTDB:" + sql); - } - List> result = new ArrayList<>(); - try (Statement statement = ioTDBConnection.getConnection().createStatement()) { - ResultSet resultSet = statement.executeQuery(sql); - int colNumber = resultSet.getMetaData().getColumnCount(); - while (resultSet.next()) { - List line = new ArrayList<>(); - for (int i = 1; i <= colNumber; i++) { - line.add(resultSet.getObject(i)); - } - result.add(line); - } - } catch (Exception e) { - LOGGER.error("Query Error: " + sql + " exception:" + e.getMessage()); - return new Status(false, new TsdbException("Failed to query"), "Failed to query."); - } - - return new Status(true, 0, sql.toString(), result); - } - - protected String getDeviceQuerySql( - DeviceSchema deviceSchema, long startTimeStamp, long endTimeStamp) { - StringBuffer sql = new StringBuffer(); - List deviceSchemas = new ArrayList<>(); - deviceSchemas.add(deviceSchema); - sql.append(getSimpleQuerySqlHead(deviceSchemas)); - sql.append(" where time >= ").append(startTimeStamp); - sql.append(" and time <").append(endTimeStamp); - sql.append(" order by time desc"); - return sql.toString(); - } - - @Override - public DeviceSummary deviceSummary(DeviceQuery deviceQuery) throws SQLException, TsdbException { - DeviceSchema deviceSchema = deviceQuery.getDeviceSchema(); - int totalLineNumber = 0; - long minTimeStamp = 0, maxTimeStamp = 0; - try (Statement statement = ioTDBConnection.getConnection().createStatement()) { - ResultSet resultSet = statement.executeQuery(getTotalLineNumberSql(deviceSchema)); - resultSet.next(); - totalLineNumber = Integer.parseInt(resultSet.getString(1)); - - resultSet = statement.executeQuery(getMaxTimeStampSql(deviceSchema)); - resultSet.next(); - maxTimeStamp = Long.parseLong(resultSet.getObject(1).toString()); - - resultSet = statement.executeQuery(getMinTimeStampSql(deviceSchema)); - resultSet.next(); - minTimeStamp = Long.parseLong(resultSet.getObject(1).toString()); - } - return new DeviceSummary(deviceSchema.getDevice(), totalLineNumber, minTimeStamp, maxTimeStamp); - } - - protected String getTotalLineNumberSql(DeviceSchema deviceSchema) { - return "select count(*) from " + getDevicePath(deviceSchema); - } - - protected String getMinTimeStampSql(DeviceSchema deviceSchema) { - return "select * from " + getDevicePath(deviceSchema) + " order by time limit 1"; - } - - protected String getMaxTimeStampSql(DeviceSchema deviceSchema) { - return "select * from " + getDevicePath(deviceSchema) + " order by time desc limit 1"; - } - - String getEncodingType(SensorType dataSensorType) { - switch (dataSensorType) { - case BOOLEAN: - return config.getENCODING_BOOLEAN(); - case INT32: - return config.getENCODING_INT32(); - case INT64: - return config.getENCODING_INT64(); - case FLOAT: - return config.getENCODING_FLOAT(); - case DOUBLE: - return config.getENCODING_DOUBLE(); - case TEXT: - return config.getENCODING_TEXT(); - default: - LOGGER.error("Unsupported data sensorType {}.", dataSensorType); - return null; - } - } - - /** - * convert deviceSchema and sensor to the format: root.group_1.d_1.s_1 - * - * @param deviceSchema - * @param sensor - * @return - */ - private String getSensorPath(DeviceSchema deviceSchema, String sensor) { - return getDevicePath(deviceSchema) + "." + sensor; - } -} diff --git a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDBClusterSession.java b/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDBClusterSession.java deleted file mode 100644 index 691dd3283..000000000 --- a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDBClusterSession.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * 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 cn.edu.tsinghua.iot.benchmark.iotdb013; - -import org.apache.iotdb.rpc.IoTDBConnectionException; -import org.apache.iotdb.rpc.StatementExecutionException; -import org.apache.iotdb.session.pool.SessionDataSetWrapper; -import org.apache.iotdb.session.pool.SessionPool; -import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; -import org.apache.iotdb.tsfile.read.common.Field; -import org.apache.iotdb.tsfile.read.common.RowRecord; -import org.apache.iotdb.tsfile.write.record.Tablet; - -import cn.edu.tsinghua.iot.benchmark.client.operation.Operation; -import cn.edu.tsinghua.iot.benchmark.conf.Config; -import cn.edu.tsinghua.iot.benchmark.conf.ConfigDescriptor; -import cn.edu.tsinghua.iot.benchmark.entity.Batch.IBatch; -import cn.edu.tsinghua.iot.benchmark.entity.DeviceSummary; -import cn.edu.tsinghua.iot.benchmark.entity.Record; -import cn.edu.tsinghua.iot.benchmark.entity.Sensor; -import cn.edu.tsinghua.iot.benchmark.measurement.Status; -import cn.edu.tsinghua.iot.benchmark.schema.schemaImpl.DeviceSchema; -import cn.edu.tsinghua.iot.benchmark.tsdb.DBConfig; -import cn.edu.tsinghua.iot.benchmark.tsdb.TsdbException; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.DeviceQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.VerificationQuery; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; - -public class IoTDBClusterSession extends IoTDBSessionBase { - - private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBClusterSession.class); - private static Config config = ConfigDescriptor.getInstance().getConfig(); - private SessionPool sessionPool; - private static final int MAX_SESSION_CONNECTION_PER_CLIENT = 3; - - public IoTDBClusterSession(DBConfig dbConfig) { - super(dbConfig); - createSessions(); - } - - private void createSessions() { - List hostUrls = new ArrayList<>(dbConfig.getHOST().size()); - for (int i = 0; i < dbConfig.getHOST().size(); i++) { - hostUrls.add(dbConfig.getHOST().get(i) + ":" + dbConfig.getPORT().get(i)); - } - sessionPool = - new SessionPool( - hostUrls, - dbConfig.getUSERNAME(), - dbConfig.getPASSWORD(), - MAX_SESSION_CONNECTION_PER_CLIENT, - config.isENABLE_THRIFT_COMPRESSION(), - true); - } - - @Override - public void init() throws TsdbException { - // do nothing - this.service = Executors.newSingleThreadExecutor(); - } - - @Override - public Status insertOneBatchByRecord(IBatch batch) { - String deviceId = getDevicePath(batch.getDeviceSchema()); - int failRecord = 0; - List sensors = - batch.getDeviceSchema().getSensors().stream() - .map(Sensor::getName) - .collect(Collectors.toList()); - for (Record record : batch.getRecords()) { - long timestamp = record.getTimestamp(); - List dataTypes = - constructDataTypes( - batch.getDeviceSchema().getSensors(), record.getRecordDataValue().size()); - try { - if (config.isVECTOR()) { - sessionPool.insertAlignedRecord( - deviceId, timestamp, sensors, dataTypes, record.getRecordDataValue()); - } else { - sessionPool.insertRecord( - deviceId, timestamp, sensors, dataTypes, record.getRecordDataValue()); - } - } catch (IoTDBConnectionException | StatementExecutionException e) { - LOGGER.error("insert record failed", e); - failRecord++; - } - } - - if (failRecord == 0) { - return new Status(true); - } else { - Exception e = new Exception("failRecord number is " + failRecord); - return new Status(false, 0, e, e.toString()); - } - } - - @Override - public Status insertOneBatchByRecords(IBatch batch) { - List deviceIds = new ArrayList<>(); - String deviceId = getDevicePath(batch.getDeviceSchema()); - List times = new ArrayList<>(); - List> measurementsList = new ArrayList<>(); - List> typesList = new ArrayList<>(); - List> valuesList = new ArrayList<>(); - List sensors = - batch.getDeviceSchema().getSensors().stream() - .map(Sensor::getName) - .collect(Collectors.toList()); - for (Record record : batch.getRecords()) { - deviceIds.add(deviceId); - times.add(record.getTimestamp()); - measurementsList.add(sensors); - valuesList.add(record.getRecordDataValue()); - typesList.add( - constructDataTypes( - batch.getDeviceSchema().getSensors(), record.getRecordDataValue().size())); - } - - future = - service.submit( - () -> { - try { - if (config.isVECTOR()) { - sessionPool.insertAlignedRecords( - deviceIds, times, measurementsList, typesList, valuesList); - } else { - sessionPool.insertRecords( - deviceIds, times, measurementsList, typesList, valuesList); - } - } catch (IoTDBConnectionException | StatementExecutionException e) { - LOGGER.error("insert records failed", e); - } - }); - - return waitFuture(); - } - - @Override - public Status insertOneBatchByTablet(IBatch batch) { - Tablet tablet = genTablet(batch); - - future = - service.submit( - () -> { - try { - if (config.isVECTOR()) { - sessionPool.insertAlignedTablet(tablet); - } else { - sessionPool.insertTablet(tablet); - } - } catch (IoTDBConnectionException | StatementExecutionException e) { - LOGGER.error("insert tablet failed", e); - } - }); - - return waitFuture(); - } - - @Override - protected Status executeQueryAndGetStatus(String sql, Operation operation) { - String executeSQL; - if (config.isIOTDB_USE_DEBUG() && random.nextDouble() < config.getIOTDB_USE_DEBUG_RATIO()) { - executeSQL = "debug " + sql; - } else { - executeSQL = sql; - } - if (!config.isIS_QUIET_MODE()) { - LOGGER.info("{} query SQL: {}", Thread.currentThread().getName(), executeSQL); - } - AtomicLong queryResultPointNum = new AtomicLong(); - AtomicBoolean isOk = new AtomicBoolean(true); - - try { - List> records = new ArrayList<>(); - future = - service.submit( - () -> { - long resultNum = 0; - try { - SessionDataSetWrapper sessionDataSet = - sessionPool.executeQueryStatement(executeSQL); - while (sessionDataSet.hasNext()) { - RowRecord rowRecord = sessionDataSet.next(); - switch (operation) { - case LATEST_POINT_QUERY: - resultNum++; - break; - default: - resultNum += rowRecord.getFields().size(); - break; - } - if (config.isIS_COMPARISON()) { - List record = new ArrayList<>(); - switch (operation) { - case AGG_RANGE_QUERY: - case AGG_VALUE_QUERY: - case AGG_RANGE_VALUE_QUERY: - break; - default: - record.add(rowRecord.getTimestamp()); - break; - } - List fields = rowRecord.getFields(); - for (int i = 0; i < fields.size(); i++) { - switch (operation) { - case LATEST_POINT_QUERY: - if (i == 0 || i == 2) { - continue; - } - default: - break; - } - record.add(fields.get(i).toString()); - } - records.add(record); - } - } - sessionDataSet.close(); - } catch (StatementExecutionException | IoTDBConnectionException e) { - LOGGER.error("exception occurred when execute query={}", executeSQL, e); - isOk.set(false); - } - queryResultPointNum.set(resultNum); - }); - try { - future.get(config.getREAD_OPERATION_TIMEOUT_MS(), TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - future.cancel(true); - return new Status(false, queryResultPointNum.get(), e, executeSQL); - } - if (isOk.get()) { - if (config.isIS_COMPARISON()) { - return new Status(true, queryResultPointNum.get(), executeSQL, records); - } else { - return new Status(true, queryResultPointNum.get()); - } - } else { - return new Status( - false, queryResultPointNum.get(), new Exception("Failed to execute."), executeSQL); - } - } catch (Exception e) { - return new Status(false, queryResultPointNum.get(), e, executeSQL); - } catch (Throwable t) { - return new Status(false, queryResultPointNum.get(), new Exception(t), executeSQL); - } - } - - /** - * Using in verification - * - * @param verificationQuery - */ - @Override - public Status verificationQuery(VerificationQuery verificationQuery) { - DeviceSchema deviceSchema = verificationQuery.getDeviceSchema(); - List deviceSchemas = new ArrayList<>(); - deviceSchemas.add(deviceSchema); - - List records = verificationQuery.getRecords(); - if (records == null || records.size() == 0) { - return new Status( - false, - new TsdbException("There are no records in verficationQuery."), - "There are no records in verficationQuery."); - } - - StringBuffer sql = new StringBuffer(); - sql.append(getSimpleQuerySqlHead(deviceSchemas)); - Map> recordMap = new HashMap<>(); - sql.append(" WHERE time = ").append(records.get(0).getTimestamp()); - recordMap.put(records.get(0).getTimestamp(), records.get(0).getRecordDataValue()); - for (int i = 1; i < records.size(); i++) { - Record record = records.get(i); - sql.append(" or time = ").append(record.getTimestamp()); - recordMap.put(record.getTimestamp(), record.getRecordDataValue()); - } - long point = 0; - int line = 0; - try { - SessionDataSetWrapper sessionDataSet = sessionPool.executeQueryStatement(sql.toString()); - while (sessionDataSet.hasNext()) { - RowRecord rowRecord = sessionDataSet.next(); - long timeStamp = rowRecord.getTimestamp(); - List values = recordMap.get(timeStamp); - for (int i = 0; i < values.size(); i++) { - String value = rowRecord.getFields().get(i).toString(); - String target = String.valueOf(values.get(i)); - if (!value.equals(target)) { - LOGGER.error("Using SQL: " + sql + ",Expected:" + value + " but was: " + target); - } else { - point++; - } - } - line++; - } - sessionDataSet.close(); - } catch (Exception e) { - LOGGER.error("Query Error: " + sql); - return new Status(false, new TsdbException("Failed to query"), "Failed to query."); - } - if (recordMap.size() != line) { - LOGGER.error( - "Using SQL: " + sql + ",Expected line:" + recordMap.size() + " but was: " + line); - } - return new Status(true, point); - } - - @Override - public Status deviceQuery(DeviceQuery deviceQuery) throws SQLException, TsdbException { - DeviceSchema deviceSchema = deviceQuery.getDeviceSchema(); - String sql = - getDeviceQuerySql( - deviceSchema, deviceQuery.getStartTimestamp(), deviceQuery.getEndTimestamp()); - if (!config.isIS_QUIET_MODE()) { - LOGGER.info("IoTDB:" + sql); - } - List> result = new ArrayList<>(); - try { - SessionDataSetWrapper sessionDataSet = sessionPool.executeQueryStatement(sql); - while (sessionDataSet.hasNext()) { - List line = new ArrayList<>(); - RowRecord rowRecord = sessionDataSet.next(); - line.add(rowRecord.getTimestamp()); - List fields = rowRecord.getFields(); - for (int i = 0; i < fields.size(); i++) { - line.add(fields.get(i).getStringValue()); - } - result.add(line); - } - sessionDataSet.close(); - } catch (Exception e) { - LOGGER.error("Query Error: " + sql + " exception:" + e.getMessage()); - return new Status(false, new TsdbException("Failed to query"), "Failed to query."); - } - - return new Status(true, 0, sql, result); - } - - @Override - public DeviceSummary deviceSummary(DeviceQuery deviceQuery) throws SQLException, TsdbException { - DeviceSchema deviceSchema = deviceQuery.getDeviceSchema(); - int totalLineNumber = 0; - long minTimeStamp = 0, maxTimeStamp = 0; - try { - SessionDataSetWrapper sessionDataSet = - sessionPool.executeQueryStatement(getTotalLineNumberSql(deviceSchema)); - RowRecord rowRecord = sessionDataSet.next(); - totalLineNumber = Integer.parseInt(rowRecord.getFields().get(0).toString()); - sessionDataSet.close(); - - sessionDataSet = sessionPool.executeQueryStatement(getMaxTimeStampSql(deviceSchema)); - rowRecord = sessionDataSet.next(); - maxTimeStamp = rowRecord.getTimestamp(); - sessionDataSet.close(); - - sessionDataSet = sessionPool.executeQueryStatement(getMinTimeStampSql(deviceSchema)); - rowRecord = sessionDataSet.next(); - minTimeStamp = rowRecord.getTimestamp(); - sessionDataSet.close(); - } catch (IoTDBConnectionException e) { - throw new TsdbException("Failed to connect to IoTDB:" + e.getMessage()); - } catch (StatementExecutionException e) { - throw new TsdbException("Failed to execute statement:" + e.getMessage()); - } - return new DeviceSummary(deviceSchema.getDevice(), totalLineNumber, minTimeStamp, maxTimeStamp); - } - - private Status waitFuture() { - try { - future.get(config.getWRITE_OPERATION_TIMEOUT_MS(), TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - future.cancel(true); - return new Status(false, 0, e, e.toString()); - } - - return new Status(true); - } - - @Override - public void close() throws TsdbException { - if (sessionPool != null) { - sessionPool.close(); - } - if (ioTDBConnection != null) { - ioTDBConnection.close(); - } - this.service.shutdown(); - } -} diff --git a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDBSession.java b/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDBSession.java deleted file mode 100644 index 82545dec6..000000000 --- a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDBSession.java +++ /dev/null @@ -1,416 +0,0 @@ -/* - * 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 cn.edu.tsinghua.iot.benchmark.iotdb013; - -import org.apache.iotdb.isession.util.Version; -import org.apache.iotdb.rpc.IoTDBConnectionException; -import org.apache.iotdb.rpc.StatementExecutionException; -import org.apache.iotdb.session.Session; -import org.apache.iotdb.session.SessionDataSet; -import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; -import org.apache.iotdb.tsfile.read.common.Field; -import org.apache.iotdb.tsfile.read.common.RowRecord; -import org.apache.iotdb.tsfile.write.record.Tablet; - -import cn.edu.tsinghua.iot.benchmark.client.operation.Operation; -import cn.edu.tsinghua.iot.benchmark.conf.Config; -import cn.edu.tsinghua.iot.benchmark.conf.ConfigDescriptor; -import cn.edu.tsinghua.iot.benchmark.entity.Batch.IBatch; -import cn.edu.tsinghua.iot.benchmark.entity.DeviceSummary; -import cn.edu.tsinghua.iot.benchmark.entity.Record; -import cn.edu.tsinghua.iot.benchmark.entity.Sensor; -import cn.edu.tsinghua.iot.benchmark.measurement.Status; -import cn.edu.tsinghua.iot.benchmark.schema.schemaImpl.DeviceSchema; -import cn.edu.tsinghua.iot.benchmark.tsdb.DBConfig; -import cn.edu.tsinghua.iot.benchmark.tsdb.TsdbException; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.DeviceQuery; -import cn.edu.tsinghua.iot.benchmark.workload.query.impl.VerificationQuery; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; - -public class IoTDBSession extends IoTDBSessionBase { - - private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBSession.class); - private static final Config config = ConfigDescriptor.getInstance().getConfig(); - private final Session session; - - public IoTDBSession(DBConfig dbConfig) { - super(dbConfig); - session = - new Session.Builder() - .host(dbConfig.getHOST().get(0)) - .port(Integer.parseInt(dbConfig.getPORT().get(0))) - .username(dbConfig.getUSERNAME()) - .password(dbConfig.getPASSWORD()) - .enableCacheLeader(true) - .version(Version.V_0_13) - .build(); - } - - @Override - public void init() throws TsdbException { - try { - if (config.isENABLE_THRIFT_COMPRESSION()) { - session.open(true); - } else { - session.open(); - } - this.service = Executors.newSingleThreadExecutor(); - } catch (IoTDBConnectionException e) { - LOGGER.error("Failed to add session", e); - } - } - - @Override - public Status insertOneBatchByRecord(IBatch batch) { - String deviceId = getDevicePath(batch.getDeviceSchema()); - int failRecord = 0; - List sensors = - batch.getDeviceSchema().getSensors().stream() - .map(Sensor::getName) - .collect(Collectors.toList()); - - for (Record record : batch.getRecords()) { - long timestamp = record.getTimestamp(); - List dataTypes = - constructDataTypes( - batch.getDeviceSchema().getSensors(), record.getRecordDataValue().size()); - try { - if (config.isTEMPLATE()) { - session.insertAlignedRecord( - deviceId, timestamp, sensors, dataTypes, record.getRecordDataValue()); - } else { - session.insertRecord( - deviceId, timestamp, sensors, dataTypes, record.getRecordDataValue()); - } - } catch (IoTDBConnectionException | StatementExecutionException e) { - failRecord++; - } - } - if (failRecord == 0) { - return new Status(true); - } else { - Exception e = new Exception("failRecord number is " + failRecord); - return new Status(false, 0, e, e.toString()); - } - } - - @Override - public Status insertOneBatchByRecords(IBatch batch) { - // String deviceId = getDevicePath(batch.getDeviceSchema()); - List deviceIds = new ArrayList<>(); - List times = new ArrayList<>(); - List> measurementsList = new ArrayList<>(); - List> typesList = new ArrayList<>(); - List> valuesList = new ArrayList<>(); - List sensors = - batch.getDeviceSchema().getSensors().stream() - .map(Sensor::getName) - .collect(Collectors.toList()); - while (true) { - for (Record record : batch.getRecords()) { - deviceIds.add(getDevicePath(batch.getDeviceSchema())); - times.add(record.getTimestamp()); - measurementsList.add(sensors); - valuesList.add(record.getRecordDataValue()); - typesList.add( - constructDataTypes( - batch.getDeviceSchema().getSensors(), record.getRecordDataValue().size())); - } - if (!batch.hasNext()) { - break; - } - batch.next(); - } - try { - if (config.isVECTOR()) { - session.insertAlignedRecords(deviceIds, times, measurementsList, typesList, valuesList); - } else { - session.insertRecords(deviceIds, times, measurementsList, typesList, valuesList); - } - } catch (IoTDBConnectionException | StatementExecutionException e) { - return new Status(false, 0, e, e.toString()); - } - return new Status(true); - } - - @Override - public Status insertOneBatchByTablet(IBatch batch) { - Tablet tablet = genTablet(batch); - try { - if (config.isVECTOR()) { - session.insertAlignedTablet(tablet); - } else { - session.insertTablet(tablet); - } - return new Status(true); - } catch (IoTDBConnectionException | StatementExecutionException e) { - return new Status(false, 0, e, e.toString()); - } - } - - @Override - protected Status executeQueryAndGetStatus(String sql, Operation operation) { - String executeSQL; - if (config.isIOTDB_USE_DEBUG() && random.nextDouble() < config.getIOTDB_USE_DEBUG_RATIO()) { - executeSQL = "debug " + sql; - } else { - executeSQL = sql; - } - if (!config.isIS_QUIET_MODE()) { - LOGGER.info("{} query SQL: {}", Thread.currentThread().getName(), executeSQL); - } - AtomicLong queryResultPointNum = new AtomicLong(); - AtomicBoolean isOk = new AtomicBoolean(true); - - try { - List> records = new ArrayList<>(); - future = - service.submit( - () -> { - long resultNum = 0; - try { - SessionDataSet sessionDataSet = session.executeQueryStatement(executeSQL); - while (sessionDataSet.hasNext()) { - RowRecord rowRecord = sessionDataSet.next(); - switch (operation) { - case LATEST_POINT_QUERY: - resultNum++; - break; - default: - resultNum += rowRecord.getFields().size(); - break; - } - if (config.isIS_COMPARISON()) { - List record = new ArrayList<>(); - switch (operation) { - case AGG_RANGE_QUERY: - case AGG_VALUE_QUERY: - case AGG_RANGE_VALUE_QUERY: - break; - default: - record.add(rowRecord.getTimestamp()); - break; - } - List fields = rowRecord.getFields(); - for (int i = 0; i < fields.size(); i++) { - switch (operation) { - case LATEST_POINT_QUERY: - if (i == 0 || i == 2) { - continue; - } - default: - break; - } - record.add(fields.get(i).toString()); - } - records.add(record); - } - } - sessionDataSet.closeOperationHandle(); - } catch (StatementExecutionException | IoTDBConnectionException e) { - LOGGER.error("exception occurred when execute query={}", executeSQL, e); - isOk.set(false); - } - queryResultPointNum.set(resultNum); - }); - try { - future.get(config.getREAD_OPERATION_TIMEOUT_MS(), TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - future.cancel(true); - return new Status(false, queryResultPointNum.get(), e, executeSQL); - } - if (isOk.get()) { - if (config.isIS_COMPARISON()) { - return new Status(true, queryResultPointNum.get(), executeSQL, records); - } else { - return new Status(true, queryResultPointNum.get()); - } - } else { - return new Status( - false, queryResultPointNum.get(), new Exception("Failed to execute."), executeSQL); - } - } catch (Exception e) { - return new Status(false, queryResultPointNum.get(), e, executeSQL); - } catch (Throwable t) { - return new Status(false, queryResultPointNum.get(), new Exception(t), executeSQL); - } - } - - /** - * Using in verification - * - * @param verificationQuery - */ - @Override - public Status verificationQuery(VerificationQuery verificationQuery) { - DeviceSchema deviceSchema = verificationQuery.getDeviceSchema(); - List deviceSchemas = new ArrayList<>(); - deviceSchemas.add(deviceSchema); - - List records = verificationQuery.getRecords(); - if (records == null || records.size() == 0) { - return new Status( - false, - new TsdbException("There are no records in verficationQuery."), - "There are no records in verficationQuery."); - } - - StringBuffer sql = new StringBuffer(); - sql.append(getSimpleQuerySqlHead(deviceSchemas)); - Map> recordMap = new HashMap<>(); - sql.append(" WHERE time = ").append(records.get(0).getTimestamp()); - recordMap.put(records.get(0).getTimestamp(), records.get(0).getRecordDataValue()); - for (int i = 1; i < records.size(); i++) { - Record record = records.get(i); - sql.append(" or time = ").append(record.getTimestamp()); - recordMap.put(record.getTimestamp(), record.getRecordDataValue()); - } - long point = 0; - int line = 0; - try { - SessionDataSet sessionDataSet = session.executeQueryStatement(sql.toString()); - while (sessionDataSet.hasNext()) { - RowRecord rowRecord = sessionDataSet.next(); - long timeStamp = rowRecord.getTimestamp(); - List values = recordMap.get(timeStamp); - for (int i = 0; i < values.size(); i++) { - String value = rowRecord.getFields().get(i).toString(); - String target = String.valueOf(values.get(i)); - if (!value.equals(target)) { - LOGGER.error("Using SQL: " + sql + ",Expected:" + value + " but was: " + target); - } else { - point++; - } - } - line++; - } - sessionDataSet.close(); - } catch (Exception e) { - LOGGER.error("Query Error: " + sql); - return new Status(false, new TsdbException("Failed to query"), "Failed to query."); - } - if (recordMap.size() != line) { - LOGGER.error( - "Using SQL: " + sql + ",Expected line:" + recordMap.size() + " but was: " + line); - } - return new Status(true, point); - } - - @Override - public Status deviceQuery(DeviceQuery deviceQuery) throws SQLException, TsdbException { - DeviceSchema deviceSchema = deviceQuery.getDeviceSchema(); - String sql = - getDeviceQuerySql( - deviceSchema, deviceQuery.getStartTimestamp(), deviceQuery.getEndTimestamp()); - if (!config.isIS_QUIET_MODE()) { - LOGGER.info("IoTDB:" + sql); - } - List> result = new ArrayList<>(); - try { - SessionDataSet sessionDataSet = session.executeQueryStatement(sql); - while (sessionDataSet.hasNext()) { - List line = new ArrayList<>(); - RowRecord rowRecord = sessionDataSet.next(); - List fields = rowRecord.getFields(); - line.add(rowRecord.getTimestamp()); - for (int i = 0; i < fields.size(); i++) { - line.add(fields.get(i).getStringValue()); - } - result.add(line); - } - sessionDataSet.closeOperationHandle(); - } catch (Exception e) { - LOGGER.error("Query Error: " + sql + " exception:" + e.getMessage()); - return new Status(false, new TsdbException("Failed to query"), "Failed to query."); - } - - return new Status(true, 0, sql, result); - } - - @Override - public DeviceSummary deviceSummary(DeviceQuery deviceQuery) throws SQLException, TsdbException { - DeviceSchema deviceSchema = deviceQuery.getDeviceSchema(); - int totalLineNumber = 0; - long minTimeStamp = 0, maxTimeStamp = 0; - try { - SessionDataSet sessionDataSet = - session.executeQueryStatement(getTotalLineNumberSql(deviceSchema)); - RowRecord rowRecord = sessionDataSet.next(); - totalLineNumber = Integer.parseInt(rowRecord.getFields().get(0).toString()); - sessionDataSet.closeOperationHandle(); - - sessionDataSet = session.executeQueryStatement(getMaxTimeStampSql(deviceSchema)); - rowRecord = sessionDataSet.next(); - maxTimeStamp = rowRecord.getTimestamp(); - sessionDataSet.closeOperationHandle(); - - sessionDataSet = session.executeQueryStatement(getMinTimeStampSql(deviceSchema)); - rowRecord = sessionDataSet.next(); - minTimeStamp = rowRecord.getTimestamp(); - sessionDataSet.closeOperationHandle(); - } catch (IoTDBConnectionException e) { - throw new TsdbException("Failed to connect to IoTDB:" + e.getMessage()); - } catch (StatementExecutionException e) { - throw new TsdbException("Failed to execute statement:" + e.getMessage()); - } - return new DeviceSummary(deviceSchema.getDevice(), totalLineNumber, minTimeStamp, maxTimeStamp); - } - - @Override - public void cleanup() { - try { - session.executeNonQueryStatement(DELETE_SERIES_SQL); - } catch (IoTDBConnectionException e) { - LOGGER.error("Failed to connect to IoTDB:" + e.getMessage()); - } catch (StatementExecutionException e) { - LOGGER.error("Failed to execute statement:" + e.getMessage()); - } - } - - @Override - public void close() throws TsdbException { - try { - if (session != null) { - session.close(); - } - if (ioTDBConnection != null) { - ioTDBConnection.close(); - } - this.service.shutdown(); - } catch (IoTDBConnectionException ioTDBConnectionException) { - LOGGER.error("Failed to close session."); - throw new TsdbException(ioTDBConnectionException); - } - } -} diff --git a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDBSessionBase.java b/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDBSessionBase.java deleted file mode 100644 index 3ffadf1d3..000000000 --- a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/IoTDBSessionBase.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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 cn.edu.tsinghua.iot.benchmark.iotdb013; - -import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; -import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding; -import org.apache.iotdb.tsfile.utils.Binary; -import org.apache.iotdb.tsfile.write.record.Tablet; -import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; - -import cn.edu.tsinghua.iot.benchmark.entity.Batch.IBatch; -import cn.edu.tsinghua.iot.benchmark.entity.Record; -import cn.edu.tsinghua.iot.benchmark.entity.Sensor; -import cn.edu.tsinghua.iot.benchmark.entity.enums.SensorType; -import cn.edu.tsinghua.iot.benchmark.measurement.Status; -import cn.edu.tsinghua.iot.benchmark.tsdb.DBConfig; -import cn.edu.tsinghua.iot.benchmark.tsdb.enums.DBInsertMode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; - -public class IoTDBSessionBase extends IoTDB { - private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBSessionBase.class); - - public IoTDBSessionBase(DBConfig dbConfig) { - super(dbConfig); - } - - public Status insertOneBatchByTablet(IBatch batch) { - return new Status(true); - } - - public Status insertOneBatchByRecord(IBatch batch) { - return new Status(true); - } - - public Status insertOneBatchByRecords(IBatch batch) { - return new Status(true); - } - - protected Tablet genTablet(IBatch batch) { - List schemaList = new ArrayList<>(); - int sensorIndex = 0; - for (Sensor sensor : batch.getDeviceSchema().getSensors()) { - SensorType dataSensorType = sensor.getSensorType(); - schemaList.add( - new MeasurementSchema( - sensor.getName(), - Enum.valueOf(TSDataType.class, dataSensorType.name), - Enum.valueOf(TSEncoding.class, getEncodingType(dataSensorType)))); - sensorIndex++; - } - String deviceId = getDevicePath(batch.getDeviceSchema()); - Tablet tablet = new Tablet(deviceId, schemaList, batch.getRecords().size()); - long[] timestamps = tablet.timestamps; - Object[] values = tablet.values; - - List sensors = batch.getDeviceSchema().getSensors(); - for (int recordIndex = 0; recordIndex < batch.getRecords().size(); recordIndex++) { - tablet.rowSize++; - Record record = batch.getRecords().get(recordIndex); - sensorIndex = 0; - long currentTime = record.getTimestamp(); - timestamps[recordIndex] = currentTime; - for (int recordValueIndex = 0; - recordValueIndex < record.getRecordDataValue().size(); - recordValueIndex++) { - switch (sensors.get(sensorIndex).getSensorType()) { - case BOOLEAN: - boolean[] sensorsBool = (boolean[]) values[recordValueIndex]; - sensorsBool[recordIndex] = - (boolean) (record.getRecordDataValue().get(recordValueIndex)); - break; - case INT32: - int[] sensorsInt = (int[]) values[recordValueIndex]; - sensorsInt[recordIndex] = (int) (record.getRecordDataValue().get(recordValueIndex)); - break; - case INT64: - long[] sensorsLong = (long[]) values[recordValueIndex]; - sensorsLong[recordIndex] = (long) (record.getRecordDataValue().get(recordValueIndex)); - break; - case FLOAT: - float[] sensorsFloat = (float[]) values[recordValueIndex]; - sensorsFloat[recordIndex] = (float) (record.getRecordDataValue().get(recordValueIndex)); - break; - case DOUBLE: - double[] sensorsDouble = (double[]) values[recordValueIndex]; - sensorsDouble[recordIndex] = - (double) (record.getRecordDataValue().get(recordValueIndex)); - break; - case TEXT: - Binary[] sensorsText = (Binary[]) values[recordValueIndex]; - sensorsText[recordIndex] = - Binary.valueOf((String) record.getRecordDataValue().get(recordValueIndex)); - break; - default: - LOGGER.error("Unsupported Type:" + sensors.get(sensorIndex).getSensorType()); - } - sensorIndex++; - } - } - return tablet; - } - - public List constructDataTypes(List sensors, int recordValueSize) { - List dataTypes = new ArrayList<>(); - for (int sensorIndex = 0; sensorIndex < recordValueSize; sensorIndex++) { - switch (sensors.get(sensorIndex).getSensorType()) { - case BOOLEAN: - dataTypes.add(TSDataType.BOOLEAN); - break; - case INT32: - dataTypes.add(TSDataType.INT32); - break; - case INT64: - dataTypes.add(TSDataType.INT64); - break; - case FLOAT: - dataTypes.add(TSDataType.FLOAT); - break; - case DOUBLE: - dataTypes.add(TSDataType.DOUBLE); - break; - case TEXT: - dataTypes.add(TSDataType.TEXT); - break; - } - } - return dataTypes; - } - - @Override - public Status insertOneBatch(IBatch batch) { - DBInsertMode insertMode = dbConfig.getDB_SWITCH().getInsertMode(); - switch (insertMode) { - case INSERT_USE_SESSION_TABLET: - return insertOneBatchByTablet(batch); - case INSERT_USE_SESSION_RECORD: - return insertOneBatchByRecord(batch); - case INSERT_USE_SESSION_RECORDS: - return insertOneBatchByRecords(batch); - default: - throw new IllegalStateException("Unexpected INSERT_MODE value: " + insertMode); - } - } -} diff --git a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/SingleNodeJDBCConnection.java b/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/SingleNodeJDBCConnection.java deleted file mode 100644 index 31ce533c7..000000000 --- a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/SingleNodeJDBCConnection.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 cn.edu.tsinghua.iot.benchmark.iotdb013; - -import cn.edu.tsinghua.iot.benchmark.conf.Config; -import cn.edu.tsinghua.iot.benchmark.conf.ConfigDescriptor; -import cn.edu.tsinghua.iot.benchmark.tsdb.DBConfig; -import cn.edu.tsinghua.iot.benchmark.tsdb.TsdbException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -public class SingleNodeJDBCConnection { - - private static final Logger LOGGER = LoggerFactory.getLogger(SingleNodeJDBCConnection.class); - private static Config config = ConfigDescriptor.getInstance().getConfig(); - - protected static final String JDBC_URL = "jdbc:iotdb://%s:%s/"; - protected DBConfig dbConfig; - - private Connection[] connections; - private AtomicInteger currConnectionIndex = new AtomicInteger(0); - - public SingleNodeJDBCConnection(DBConfig dbConfig) { - this.dbConfig = dbConfig; - } - - public void init() throws TsdbException { - int nodeSize = 1; - String[] urls; - if (config.isIS_ALL_NODES_VISIBLE()) { - nodeSize = dbConfig.getHOST().size(); - urls = new String[nodeSize]; - List clusterHosts = dbConfig.getHOST(); - for (int i = 0; i < nodeSize; i++) { - String jdbcUrl = - String.format(JDBC_URL, dbConfig.getHOST().get(i), dbConfig.getPORT().get(i)); - urls[i] = jdbcUrl; - } - } else { - urls = new String[nodeSize]; - urls[0] = String.format(JDBC_URL, dbConfig.getHOST().get(0), dbConfig.getPORT().get(0)); - } - connections = new Connection[nodeSize]; - - for (int i = 0; i < connections.length; i++) { - try { - Class.forName("org.apache.iotdb.jdbc.IoTDBDriver"); - org.apache.iotdb.jdbc.Config.rpcThriftCompressionEnable = - config.isENABLE_THRIFT_COMPRESSION(); - connections[i] = - DriverManager.getConnection(urls[i], dbConfig.getUSERNAME(), dbConfig.getPASSWORD()); - } catch (Exception e) { - LOGGER.error("Initialize IoTDB failed because ", e); - throw new TsdbException(e); - } - } - } - - public void close() throws TsdbException { - for (Connection connection : connections) { - if (connection != null) { - try { - connection.close(); - } catch (SQLException e) { - LOGGER.error("Failed to close IoTDB connection because ", e); - throw new TsdbException(e); - } - } - } - } - - public Connection getConnection() { - return connections[currConnectionIndex.incrementAndGet() % connections.length]; - } -} diff --git a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/TimeseriesSchema.java b/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/TimeseriesSchema.java deleted file mode 100644 index feff636e7..000000000 --- a/iotdb-0.13/src/main/java/cn/edu/tsinghua/iot/benchmark/iotdb013/TimeseriesSchema.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 cn.edu.tsinghua.iot.benchmark.iotdb013; - -import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType; -import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; -import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding; - -import cn.edu.tsinghua.iot.benchmark.schema.schemaImpl.DeviceSchema; - -import java.util.List; - -public class TimeseriesSchema { - private DeviceSchema deviceSchema; - private List paths; - private List tsDataTypes; - private List tsEncodings; - private List compressionTypes; - private String deviceId; - - public TimeseriesSchema( - DeviceSchema deviceSchema, - List paths, - List tsDataTypes, - List tsEncodings, - List compressionTypes) { - this.deviceSchema = deviceSchema; - this.paths = paths; - this.tsDataTypes = tsDataTypes; - this.tsEncodings = tsEncodings; - this.compressionTypes = compressionTypes; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public DeviceSchema getDeviceSchema() { - return deviceSchema; - } - - public List getPaths() { - return paths; - } - - public List getTsDataTypes() { - return tsDataTypes; - } - - public List getTsEncodings() { - return tsEncodings; - } - - public List getCompressionTypes() { - return compressionTypes; - } - - public String getDeviceId() { - return deviceId; - } -} diff --git a/iotdb-0.13/src/main/test/cn/edu/tsinghua/iot/benchmark/IoTDB013TestEntrance.java b/iotdb-0.13/src/main/test/cn/edu/tsinghua/iot/benchmark/IoTDB013TestEntrance.java deleted file mode 100644 index 8585763c2..000000000 --- a/iotdb-0.13/src/main/test/cn/edu/tsinghua/iot/benchmark/IoTDB013TestEntrance.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 cn.edu.tsinghua.iot.benchmark; - -import java.sql.SQLException; - -public class IoTDB013TestEntrance { - public static void main(String[] args) throws SQLException { - App.main(args); - } -} diff --git a/pom.xml b/pom.xml index 3d3d3320b..aa36f92eb 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,6 @@ iotdb-1.3 iotdb-1.1 iotdb-1.0 - iotdb-0.13 mssqlserver sqlite verification diff --git a/verification/README.md b/verification/README.md index 349e6ad6d..aa271acb6 100644 --- a/verification/README.md +++ b/verification/README.md @@ -4,7 +4,7 @@ Benchmark for Verification and Double-Write # 1. 正确性验证 ## 1.1. environment -目前仅仅支持IoTDB v0.13及以上版本和TimescaleDB进行正确性验证 +目前仅仅支持IoTDB v1.0及以上版本和TimescaleDB进行正确性验证 ## 1.2. 相关模式 1. testWithDefaultPath 使用benchmark生成数据集后正确性验证。 diff --git a/verification/conf/generate-query.properties b/verification/conf/generate-query.properties index 6d04c9e99..9f0b5e86b 100644 --- a/verification/conf/generate-query.properties +++ b/verification/conf/generate-query.properties @@ -4,7 +4,7 @@ ################### 被测数据库配置 ####################### # 被测试的数据库,目前的格式为{name}{-version}{-insert mode}(注意-号)其全部参考值参见README文件 -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET # 主机列表,如果有多个主机则使用英文逗号进行分割 HOST=127.0.0.1 # 端口列表,需要和HOST数量一致,保持一一对应。如果有多个端口则使用英文逗号进行分割。 diff --git a/verification/conf/generate-write.properties b/verification/conf/generate-write.properties index af6803baf..a76ecad3a 100644 --- a/verification/conf/generate-write.properties +++ b/verification/conf/generate-write.properties @@ -4,7 +4,7 @@ ################### 被测数据库配置 ####################### # 被测试的数据库,目前的格式为{name}{-version}{-insert mode}(注意-号)其全部参考值参见README文件 -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET # 主机列表,如果有多个主机则使用英文逗号进行分割 HOST=127.0.0.1 # 端口列表,需要和HOST数量一致,保持一一对应。如果有多个端口则使用英文逗号进行分割。 diff --git a/verification/conf/generate.properties b/verification/conf/generate.properties index f18ea7fc0..49a166058 100644 --- a/verification/conf/generate.properties +++ b/verification/conf/generate.properties @@ -4,7 +4,7 @@ ################### 被测数据库配置 ####################### # 被测试的数据库,目前的格式为{name}{-version}{-insert mode}(注意-号)其全部参考值参见README文件 -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET # 主机列表,如果有多个主机则使用英文逗号进行分割 HOST=127.0.0.1 # 端口列表,需要和HOST数量一致,保持一一对应。如果有多个端口则使用英文逗号进行分割。 diff --git a/verification/conf/query.properties b/verification/conf/query.properties index e9ec39d21..c088a24d0 100644 --- a/verification/conf/query.properties +++ b/verification/conf/query.properties @@ -4,7 +4,7 @@ ################### 被测数据库配置 ####################### # 被测试的数据库,目前的格式为{name}{-version}{-insert mode}(注意-号)其全部参考值参见README文件 -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET # 主机列表,如果有多个主机则使用英文逗号进行分割 HOST=127.0.0.1 # 端口列表,需要和HOST数量一致,保持一一对应。如果有多个端口则使用英文逗号进行分割。 diff --git a/verification/conf/write.properties b/verification/conf/write.properties index 6581a7ab1..e31426599 100644 --- a/verification/conf/write.properties +++ b/verification/conf/write.properties @@ -4,7 +4,7 @@ ################### 被测数据库配置 ####################### # 被测试的数据库,目前的格式为{name}{-version}{-insert mode}(注意-号)其全部参考值参见README文件 -DB_SWITCH=IoTDB-013-SESSION_BY_TABLET +DB_SWITCH=IoTDB-100-SESSION_BY_TABLET # 主机列表,如果有多个主机则使用英文逗号进行分割 HOST=127.0.0.1 # 端口列表,需要和HOST数量一致,保持一一对应。如果有多个端口则使用英文逗号进行分割。 diff --git a/verification/pom.xml b/verification/pom.xml index c17058b7e..1011d3344 100644 --- a/verification/pom.xml +++ b/verification/pom.xml @@ -264,18 +264,6 @@ - - cn.edu.tsinghua - iotdb-0.13 - ${project.version} - - - cn.edu.tsinghua - core - - - - cn.edu.tsinghua mssqlserver