diff --git a/.github/actions/dbRunner/action.yml b/.github/actions/dbRunner/action.yml index b9993ace68..6c6b7d2fc1 100644 --- a/.github/actions/dbRunner/action.yml +++ b/.github/actions/dbRunner/action.yml @@ -24,14 +24,14 @@ runs: shell: bash run: | if [ "$RUNNER_OS" == "Linux" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/influxdb.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/influxdb.sh" 8088 8087 + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/influxdb.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/influxdb.sh" 8088 8087 elif [ "$RUNNER_OS" == "Windows" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/influxdb_windows.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/influxdb_windows.sh" 8088 8087 + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/influxdb_windows.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/influxdb_windows.sh" 8088 8087 elif [ "$RUNNER_OS" == "macOS" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/influxdb_macos.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/influxdb_macos.sh" 8088 8087 + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/influxdb_macos.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/influxdb_macos.sh" 8088 8087 else echo "$RUNNER_OS is not supported" exit 1 @@ -46,14 +46,14 @@ runs: shell: bash run: | if [ "$RUNNER_OS" == "Linux" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/iotdb12.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/iotdb12.sh" 6667 6668 6669 + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/iotdb12.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/iotdb12.sh" 6667 6668 6669 elif [ "$RUNNER_OS" == "Windows" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/iotdb12_windows.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/iotdb12_windows.sh" 6667 6668 6669 + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/iotdb12_windows.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/iotdb12_windows.sh" 6667 6668 6669 elif [ "$RUNNER_OS" == "macOS" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/iotdb12_macos.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/iotdb12_macos.sh" 6667 6668 6669 + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/iotdb12_macos.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/iotdb12_macos.sh" 6667 6668 6669 else echo "$RUNNER_OS is not supported" exit 1 @@ -64,14 +64,14 @@ runs: shell: bash run: | if [ "$RUNNER_OS" == "Linux" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/mix_iotdb12_influxdb.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/mix_iotdb12_influxdb.sh" + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/mix_iotdb12_influxdb.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/mix_iotdb12_influxdb.sh" elif [ "$RUNNER_OS" == "Windows" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/mix_iotdb12_influxdb_windows.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/mix_iotdb12_influxdb_windows.sh" + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/mix_iotdb12_influxdb_windows.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/mix_iotdb12_influxdb_windows.sh" elif [ "$RUNNER_OS" == "macOS" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/mix_iotdb12_influxdb_macos.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/mix_iotdb12_influxdb_macos.sh" + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/mix_iotdb12_influxdb_macos.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/mix_iotdb12_influxdb_macos.sh" else echo "$RUNNER_OS is not supported" exit 1 @@ -83,14 +83,14 @@ runs: run: | cp -f "${GITHUB_WORKSPACE}/conf/config.properties" "${GITHUB_WORKSPACE}/conf/config.properties.bak" if [[ "$RUNNER_OS" == "Linux" ]]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/parquet_linux_windows.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/parquet_linux_windows.sh" 6667 6888 test/mn ${GITHUB_WORKSPACE}/test/iginx_mn false false conf/config.properties + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/parquet_linux_windows.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/parquet_linux_windows.sh" 6667 6888 test/mn ${GITHUB_WORKSPACE}/test/iginx_mn false false conf/config.properties elif [[ "$RUNNER_OS" == "Windows" ]]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/parquet_linux_windows.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/parquet_linux_windows.sh" 6667 6888 test/mn test/iginx_mn false false conf/config.properties + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/parquet_linux_windows.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/parquet_linux_windows.sh" 6667 6888 test/mn test/iginx_mn false false conf/config.properties elif [ "$RUNNER_OS" == "macOS" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/parquet_macos.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/parquet_macos.sh" 6667 6888 test/mn test/iginx_mn false false conf/config.properties + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/parquet_macos.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/parquet_macos.sh" 6667 6888 test/mn test/iginx_mn false false conf/config.properties else echo "$RUNNER_OS is not supported" exit 1 @@ -122,14 +122,14 @@ runs: run: | cp -f "${GITHUB_WORKSPACE}/conf/config.properties" "${GITHUB_WORKSPACE}/conf/config.properties.bak" if [[ "$RUNNER_OS" == "Linux" ]]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/filesystem_linux_windows.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/filesystem_linux_windows.sh" 6667 6888 test/mn ${GITHUB_WORKSPACE}/test/iginx_mn false false conf/config.properties + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/filesystem_linux_windows.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/filesystem_linux_windows.sh" 6667 6888 test/mn ${GITHUB_WORKSPACE}/test/iginx_mn false false conf/config.properties elif [[ "$RUNNER_OS" == "Windows" ]]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/filesystem_linux_windows.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/filesystem_linux_windows.sh" 6667 6888 test/mn test/iginx_mn false false conf/config.properties + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/filesystem_linux_windows.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/filesystem_linux_windows.sh" 6667 6888 test/mn test/iginx_mn false false conf/config.properties elif [ "$RUNNER_OS" == "macOS" ]; then - chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/filesystem_macos.sh" - "${GITHUB_WORKSPACE}/.github/scripts/dataSources/filesystem_macos.sh" 6667 6888 test/mn test/iginx_mn false false conf/config.properties + chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/filesystem_macos.sh" + "${GITHUB_WORKSPACE}/.github/scripts/dataSources/startup/filesystem_macos.sh" 6667 6888 test/mn test/iginx_mn false false conf/config.properties else echo "$RUNNER_OS is not supported" exit 1 diff --git a/.github/scripts/dataSources/filesystem_linux_windows.sh b/.github/scripts/dataSources/startup/filesystem_linux_windows.sh similarity index 100% rename from .github/scripts/dataSources/filesystem_linux_windows.sh rename to .github/scripts/dataSources/startup/filesystem_linux_windows.sh diff --git a/.github/scripts/dataSources/filesystem_macos.sh b/.github/scripts/dataSources/startup/filesystem_macos.sh similarity index 100% rename from .github/scripts/dataSources/filesystem_macos.sh rename to .github/scripts/dataSources/startup/filesystem_macos.sh diff --git a/.github/scripts/dataSources/influxdb.sh b/.github/scripts/dataSources/startup/influxdb.sh similarity index 97% rename from .github/scripts/dataSources/influxdb.sh rename to .github/scripts/dataSources/startup/influxdb.sh index 879629574d..3d051b8259 100644 --- a/.github/scripts/dataSources/influxdb.sh +++ b/.github/scripts/dataSources/startup/influxdb.sh @@ -40,6 +40,7 @@ sed -i "s/#storageEngineList=127.0.0.1#8086/storageEngineList=127.0.0.1#8086/g" for port in "$@" do + # target path is also used in update/ script sh -c "sudo cp -r influxdb2-2.0.7-linux-amd64/ influxdb2-2.0.7-linux-amd64-$port/" sudo sh -c "cd influxdb2-2.0.7-linux-amd64-$port/; nohup ./influxd run --bolt-path=~/.influxdbv2/influxd.bolt --engine-path=~/.influxdbv2/engine --http-bind-address=:$port --query-memory-bytes=20971520 &" diff --git a/.github/scripts/dataSources/influxdb_macos.sh b/.github/scripts/dataSources/startup/influxdb_macos.sh similarity index 97% rename from .github/scripts/dataSources/influxdb_macos.sh rename to .github/scripts/dataSources/startup/influxdb_macos.sh index 513562c313..a4774b06f4 100644 --- a/.github/scripts/dataSources/influxdb_macos.sh +++ b/.github/scripts/dataSources/startup/influxdb_macos.sh @@ -40,6 +40,7 @@ sed -i "" "s/#storageEngineList=127.0.0.1#8086/storageEngineList=127.0.0.1#8086/ for port in "$@" do + # target path is also used in update/ script sh -c "sudo cp -r influxdb2-2.0.7-darwin-amd64/ influxdb2-2.0.7-darwin-amd64-$port/" sudo sh -c "cd influxdb2-2.0.7-darwin-amd64-$port/; nohup ./influxd run --bolt-path=~/.influxdbv2/influxd.bolt --engine-path=~/.influxdbv2/engine --http-bind-address=:$port --query-memory-bytes=20971520 &" diff --git a/.github/scripts/dataSources/influxdb_windows.sh b/.github/scripts/dataSources/startup/influxdb_windows.sh similarity index 92% rename from .github/scripts/dataSources/influxdb_windows.sh rename to .github/scripts/dataSources/startup/influxdb_windows.sh index ac5669b550..7346abbe3a 100644 --- a/.github/scripts/dataSources/influxdb_windows.sh +++ b/.github/scripts/dataSources/startup/influxdb_windows.sh @@ -48,6 +48,7 @@ sed -i "s/#storageEngineList=127.0.0.1#8086/storageEngineList=127.0.0.1#8086/g" for port in "$@" do + # target path is also used in update/ script sh -c "cp -r influxdb2-2.0.7-windows-amd64/ influxdb2-2.0.7-windows-amd64-$port/" pathPrefix="influxdb2-2.0.7-windows-amd64-$port" @@ -57,15 +58,4 @@ do redirect="-RedirectStandardOutput '$pathPrefix/logs/db.log' -RedirectStandardError '$pathPrefix/logs/db-error.log'" powershell -command "Start-Process -FilePath 'influxdb2-2.0.7-windows-amd64-$port/influxd' $arguments -NoNewWindow $redirect" - - sh -c "sleep 10" - - sh -c "cat $pathPrefix/logs/db.log" - - echo "===========================================" - - sh -c "cat $pathPrefix/logs/db-error.log" - - echo "===========================================" - done diff --git a/.github/scripts/dataSources/iotdb12.sh b/.github/scripts/dataSources/startup/iotdb12.sh similarity index 96% rename from .github/scripts/dataSources/iotdb12.sh rename to .github/scripts/dataSources/startup/iotdb12.sh index 28d806af7f..00bad8eedb 100644 --- a/.github/scripts/dataSources/iotdb12.sh +++ b/.github/scripts/dataSources/startup/iotdb12.sh @@ -32,6 +32,7 @@ sh -c "sudo sed -i 's/^# compaction_strategy=.*$/compaction_strategy=NO_COMPACTI for port in "$@" do + # target path is also used in update/ script sh -c "sudo cp -r apache-iotdb-0.12.6-server-bin/ apache-iotdb-0.12.6-server-bin-$port" sh -c "sudo sed -i 's/# wal_buffer_size=16777216/wal_buffer_size=167772160/g' apache-iotdb-0.12.6-server-bin-$port/conf/iotdb-engine.properties" diff --git a/.github/scripts/dataSources/iotdb12_macos.sh b/.github/scripts/dataSources/startup/iotdb12_macos.sh similarity index 96% rename from .github/scripts/dataSources/iotdb12_macos.sh rename to .github/scripts/dataSources/startup/iotdb12_macos.sh index 021ae8cf35..05a4f5383f 100644 --- a/.github/scripts/dataSources/iotdb12_macos.sh +++ b/.github/scripts/dataSources/startup/iotdb12_macos.sh @@ -32,6 +32,7 @@ sh -c "sudo sed -i '' 's/#storageEngineList=127.0.0.1#6667#iotdb12/storageEngine for port in "$@" do + # target path is also used in update/ script sh -c "sudo cp -r apache-iotdb-0.12.6-server-bin/ apache-iotdb-0.12.6-server-bin-$port" sh -c "sudo sed -i '' 's/# wal_buffer_size=16777216/wal_buffer_size=167772160/' apache-iotdb-0.12.6-server-bin-$port/conf/iotdb-engine.properties" diff --git a/.github/scripts/dataSources/iotdb12_windows.sh b/.github/scripts/dataSources/startup/iotdb12_windows.sh similarity index 97% rename from .github/scripts/dataSources/iotdb12_windows.sh rename to .github/scripts/dataSources/startup/iotdb12_windows.sh index 82bddb7ffd..c6f35b16f9 100644 --- a/.github/scripts/dataSources/iotdb12_windows.sh +++ b/.github/scripts/dataSources/startup/iotdb12_windows.sh @@ -34,6 +34,7 @@ sh -c "sed -i 's/#storageEngineList=127.0.0.1#6667#iotdb12/storageEngineList=127 for port in "$@" do + # target path is also used in update/ script sh -c "cp -r apache-iotdb-0.12.6-server-bin/ apache-iotdb-0.12.6-server-bin-$port" sh -c "sed -i 's/6667/$port/g' apache-iotdb-0.12.6-server-bin-$port/conf/iotdb-engine.properties" diff --git a/.github/scripts/dataSources/mix_iotdb12_influxdb.sh b/.github/scripts/dataSources/startup/mix_iotdb12_influxdb.sh similarity index 81% rename from .github/scripts/dataSources/mix_iotdb12_influxdb.sh rename to .github/scripts/dataSources/startup/mix_iotdb12_influxdb.sh index 9a608a8589..38eb4c17dd 100644 --- a/.github/scripts/dataSources/mix_iotdb12_influxdb.sh +++ b/.github/scripts/dataSources/startup/mix_iotdb12_influxdb.sh @@ -20,13 +20,13 @@ set -e -sh -c "chmod +x .github/scripts/dataSources/iotdb12.sh" +sh -c "chmod +x .github/scripts/dataSources/startup/iotdb12.sh" -sh -c "chmod +x .github/scripts/dataSources/influxdb.sh" +sh -c "chmod +x .github/scripts/dataSources/startup/influxdb.sh" -sh -c ".github/scripts/dataSources/iotdb12.sh 6667" +sh -c ".github/scripts/dataSources/startup/iotdb12.sh 6667" -sh -c ".github/scripts/dataSources/influxdb.sh" +sh -c ".github/scripts/dataSources/startup/influxdb.sh" set -i "s/storageEngineList/#storageEngineList/g" conf/config.properties diff --git a/.github/scripts/dataSources/mix_iotdb12_influxdb_macos.sh b/.github/scripts/dataSources/startup/mix_iotdb12_influxdb_macos.sh similarity index 80% rename from .github/scripts/dataSources/mix_iotdb12_influxdb_macos.sh rename to .github/scripts/dataSources/startup/mix_iotdb12_influxdb_macos.sh index 936b956be4..e06e0c46d5 100644 --- a/.github/scripts/dataSources/mix_iotdb12_influxdb_macos.sh +++ b/.github/scripts/dataSources/startup/mix_iotdb12_influxdb_macos.sh @@ -20,13 +20,13 @@ set -e -sh -c "chmod +x .github/scripts/dataSources/iotdb12_macos.sh" +sh -c "chmod +x .github/scripts/dataSources/startup/iotdb12_macos.sh" -sh -c "chmod +x .github/scripts/dataSources/influxdb_macos.sh" +sh -c "chmod +x .github/scripts/dataSources/startup/influxdb_macos.sh" -sh -c ".github/scripts/dataSources/iotdb12_macos.sh 6667" +sh -c ".github/scripts/dataSources/startup/iotdb12_macos.sh 6667" -sh -c ".github/scripts/dataSources/influxdb_macos.sh" +sh -c ".github/scripts/dataSources/startup/influxdb_macos.sh" set -i "s/storageEngineList/#storageEngineList/g" conf/config.properties diff --git a/.github/scripts/dataSources/mix_iotdb12_influxdb_windows.sh b/.github/scripts/dataSources/startup/mix_iotdb12_influxdb_windows.sh similarity index 79% rename from .github/scripts/dataSources/mix_iotdb12_influxdb_windows.sh rename to .github/scripts/dataSources/startup/mix_iotdb12_influxdb_windows.sh index 857e3907bd..f1fd1c6e6c 100644 --- a/.github/scripts/dataSources/mix_iotdb12_influxdb_windows.sh +++ b/.github/scripts/dataSources/startup/mix_iotdb12_influxdb_windows.sh @@ -20,13 +20,13 @@ set -e -sh -c "chmod +x .github/scripts/dataSources/iotdb12_windows.sh" +sh -c "chmod +x .github/scripts/dataSources/startup/iotdb12_windows.sh" -sh -c "chmod +x .github/scripts/dataSources/influxdb_windows.sh" +sh -c "chmod +x .github/scripts/dataSources/startup/influxdb_windows.sh" -sh -c ".github/scripts/dataSources/iotdb12_windows.sh 6667" +sh -c ".github/scripts/dataSources/startup/iotdb12_windows.sh 6667" -sh -c ".github/scripts/dataSources/influxdb_windows.sh" +sh -c ".github/scripts/dataSources/startup/influxdb_windows.sh" sed -i "s/storageEngineList/#storageEngineList/g" conf/config.properties diff --git a/.github/scripts/dataSources/parquet_linux_windows.sh b/.github/scripts/dataSources/startup/parquet_linux_windows.sh similarity index 100% rename from .github/scripts/dataSources/parquet_linux_windows.sh rename to .github/scripts/dataSources/startup/parquet_linux_windows.sh diff --git a/.github/scripts/dataSources/parquet_macos.sh b/.github/scripts/dataSources/startup/parquet_macos.sh similarity index 100% rename from .github/scripts/dataSources/parquet_macos.sh rename to .github/scripts/dataSources/startup/parquet_macos.sh diff --git a/.github/scripts/dataSources/update/influxdb.sh b/.github/scripts/dataSources/update/influxdb.sh new file mode 100644 index 0000000000..df5737b298 --- /dev/null +++ b/.github/scripts/dataSources/update/influxdb.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# usage:.sh + +set -e + +cd influxdb2-2.0.7-linux-amd64/ + +# 所有org的信息 +output=$(influx org list) + +echo $output + +# 只有一个组织,所以直接匹配 +id=$(echo "$output" | grep -Eo '^[a-z0-9]{16}') + +# 验证 +echo "Extracted ID: $id" + +sh -c "./influx org update --host http://localhost:$1 -t testToken -i $id -n $2" diff --git a/.github/scripts/dataSources/update/influxdb_macos.sh b/.github/scripts/dataSources/update/influxdb_macos.sh new file mode 100644 index 0000000000..8daa987745 --- /dev/null +++ b/.github/scripts/dataSources/update/influxdb_macos.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# usage:.sh + +set -e + +cd influxdb2-2.0.7-darwin-amd64/ + +# 所有org的信息 +output=$(influx org list) + +echo $output + +# 只有一个组织,所以直接匹配 +id=$(echo "$output" | grep -Eo '^[a-z0-9]{16}') + +# 验证 +echo "Extracted ID: $id" + +sh -c "./influx org update --host http://localhost:$1 -t testToken -i $id -n $2" diff --git a/.github/scripts/dataSources/update/influxdb_windows.sh b/.github/scripts/dataSources/update/influxdb_windows.sh new file mode 100644 index 0000000000..160a36c4f2 --- /dev/null +++ b/.github/scripts/dataSources/update/influxdb_windows.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# usage:.sh + +set -e + +cd influxdb2-2.0.7-windows-amd64/ + +# 所有org的信息 +output=$(influx org list) + +echo $output + +# 只有一个组织,所以直接匹配 +id=$(echo "$output" | grep -Eo '^[a-z0-9]{16}') + +# 验证 +echo "Extracted ID: $id" + +sh -c "./influx org --host http://localhost:$1 -t testToken update -i $id -n $2" diff --git a/.github/scripts/dataSources/update/iotdb.sh b/.github/scripts/dataSources/update/iotdb.sh new file mode 100644 index 0000000000..d4ccd6d608 --- /dev/null +++ b/.github/scripts/dataSources/update/iotdb.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# usage:.sh + +set -e + +cd apache-iotdb-0.12.6-server-bin-$1/ +sh -c "sbin/start-cli.sh -h 127.0.0.1 -p $1 -u root -pw $2 -e 'ALTER USER root SET PASSWORD \"$3\";'" \ No newline at end of file diff --git a/.github/scripts/dataSources/update/iotdb_macos.sh b/.github/scripts/dataSources/update/iotdb_macos.sh new file mode 100644 index 0000000000..d4ccd6d608 --- /dev/null +++ b/.github/scripts/dataSources/update/iotdb_macos.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# usage:.sh + +set -e + +cd apache-iotdb-0.12.6-server-bin-$1/ +sh -c "sbin/start-cli.sh -h 127.0.0.1 -p $1 -u root -pw $2 -e 'ALTER USER root SET PASSWORD \"$3\";'" \ No newline at end of file diff --git a/.github/scripts/dataSources/update/iotdb_windows.sh b/.github/scripts/dataSources/update/iotdb_windows.sh new file mode 100644 index 0000000000..a60e18c78a --- /dev/null +++ b/.github/scripts/dataSources/update/iotdb_windows.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# usage:.sh + +set -e + +cd apache-iotdb-0.12.6-server-bin-$1/ +sh -c "sbin/start-cli.bat -h 127.0.0.1 -p $1 -u root -pw $2 -e 'ALTER USER root SET PASSWORD \"$3\";'" \ No newline at end of file diff --git a/.github/scripts/dataSources/update/mysql.sh b/.github/scripts/dataSources/update/mysql.sh new file mode 100644 index 0000000000..e5fb32035a --- /dev/null +++ b/.github/scripts/dataSources/update/mysql.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# usage:.sh :set/unset + +set -e + +if [ $2 = "set" ]; then + # set password when there was none + mysql -h 127.0.0.1 --port=$1 -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$3'; flush privileges;" +else + # remove password + mysql -h 127.0.0.1 --port=$1 -u root -p$3 -e "ALTER USER 'root'@'localhost' IDENTIFIED BY ''; flush privileges;" +fi diff --git a/.github/scripts/dataSources/update/mysql_macos.sh b/.github/scripts/dataSources/update/mysql_macos.sh new file mode 100644 index 0000000000..e5fb32035a --- /dev/null +++ b/.github/scripts/dataSources/update/mysql_macos.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# usage:.sh :set/unset + +set -e + +if [ $2 = "set" ]; then + # set password when there was none + mysql -h 127.0.0.1 --port=$1 -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$3'; flush privileges;" +else + # remove password + mysql -h 127.0.0.1 --port=$1 -u root -p$3 -e "ALTER USER 'root'@'localhost' IDENTIFIED BY ''; flush privileges;" +fi diff --git a/.github/scripts/dataSources/update/mysql_windows.sh b/.github/scripts/dataSources/update/mysql_windows.sh new file mode 100644 index 0000000000..e5fb32035a --- /dev/null +++ b/.github/scripts/dataSources/update/mysql_windows.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# usage:.sh :set/unset + +set -e + +if [ $2 = "set" ]; then + # set password when there was none + mysql -h 127.0.0.1 --port=$1 -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$3'; flush privileges;" +else + # remove password + mysql -h 127.0.0.1 --port=$1 -u root -p$3 -e "ALTER USER 'root'@'localhost' IDENTIFIED BY ''; flush privileges;" +fi diff --git a/.github/scripts/dataSources/update/postgresql.sh b/.github/scripts/dataSources/update/postgresql.sh new file mode 100644 index 0000000000..d32940c16c --- /dev/null +++ b/.github/scripts/dataSources/update/postgresql.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# usage:.sh + +set -e + +export PGPASSWORD=$2 + +psql -h 127.0.0.1 -U postgres -p $1 -c"ALTER USER postgres WITH PASSWORD '$3';" \ No newline at end of file diff --git a/.github/scripts/dataSources/update/postgresql_macos.sh b/.github/scripts/dataSources/update/postgresql_macos.sh new file mode 100644 index 0000000000..d32940c16c --- /dev/null +++ b/.github/scripts/dataSources/update/postgresql_macos.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# usage:.sh + +set -e + +export PGPASSWORD=$2 + +psql -h 127.0.0.1 -U postgres -p $1 -c"ALTER USER postgres WITH PASSWORD '$3';" \ No newline at end of file diff --git a/.github/scripts/dataSources/update/postgresql_windows.sh b/.github/scripts/dataSources/update/postgresql_windows.sh new file mode 100644 index 0000000000..9525bcc34d --- /dev/null +++ b/.github/scripts/dataSources/update/postgresql_windows.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# IGinX - the polystore system with high performance +# Copyright (C) Tsinghua University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# usage:.sh + +set -e + +export PGPASSWORD=$2 + +psql -h 127.0.0.1 -Upostgres -p$1 -c"ALTER USER postgres WITH PASSWORD '$3';" \ No newline at end of file diff --git a/antlr/src/main/antlr4/cn/edu/tsinghua/iginx/sql/Sql.g4 b/antlr/src/main/antlr4/cn/edu/tsinghua/iginx/sql/Sql.g4 index 59fde95dc1..23b146c76f 100644 --- a/antlr/src/main/antlr4/cn/edu/tsinghua/iginx/sql/Sql.g4 +++ b/antlr/src/main/antlr4/cn/edu/tsinghua/iginx/sql/Sql.g4 @@ -32,6 +32,7 @@ statement | SHOW COLUMNS showColumnsOptions # showColumnsStatement | SHOW REPLICA NUMBER # showReplicationStatement | ADD STORAGEENGINE storageEngineSpec # addStorageEngineStatement + | ALTER STORAGEENGINE engineId = INT WITH PARAMS params = stringLiteral # alterEngineStatement | SHOW CLUSTER INFO # showClusterInfoStatement | SHOW FUNCTIONS # showRegisterTaskStatement | CREATE FUNCTION udfType udfClassRef (COMMA (udfType)? udfClassRef)* IN filePath = stringLiteral # registerTaskStatement @@ -452,6 +453,8 @@ keyWords | AS | udfType | jobStatus + | ALTER + | PARAMS | WITH | WITHOUT | TAG @@ -543,6 +546,14 @@ removedStorageEngine //============================ +ALTER + : A L T E R + ; + +PARAMS + : P A R A M S + ; + INSERT : I N S E R T ; diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/IginxWorker.java b/core/src/main/java/cn/edu/tsinghua/iginx/IginxWorker.java index d6a5d8ded6..017b3df355 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/IginxWorker.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/IginxWorker.java @@ -107,7 +107,7 @@ private boolean addLocalStorageEngineMetas() { metaFromConf.setExtraParams(extraParams); boolean hasAdded = false; for (StorageEngineMeta meta : metaManager.getStorageEngineList()) { - if (isDuplicated(metaFromConf, meta)) { + if (metaFromConf.equals(meta)) { hasAdded = true; break; } @@ -325,13 +325,15 @@ public Status addStorageEngines(AddStorageEnginesReq req) { int port = storageEngine.getPort(); StorageEngineType type = storageEngine.getType(); Map extraParams = storageEngine.getExtraParams(); - boolean hasData = Boolean.parseBoolean(extraParams.getOrDefault(Constants.HAS_DATA, "false")); + // 仅add时,默认为true + boolean hasData = Boolean.parseBoolean(extraParams.getOrDefault(Constants.HAS_DATA, "true")); String dataPrefix = null; if (hasData && extraParams.containsKey(Constants.DATA_PREFIX)) { dataPrefix = extraParams.get(Constants.DATA_PREFIX); } + // 仅add时,默认为true boolean readOnly = - Boolean.parseBoolean(extraParams.getOrDefault(Constants.IS_READ_ONLY, "false")); + Boolean.parseBoolean(extraParams.getOrDefault(Constants.IS_READ_ONLY, "true")); if (!isValidHost(ip)) { // IP 不合法 LOGGER.error("ip {} is invalid.", ip); @@ -400,7 +402,7 @@ private void addStorageEngineMetas( List duplicatedStorageEngines = new ArrayList<>(); for (StorageEngineMeta storageEngine : storageEngineMetas) { for (StorageEngineMeta currentStorageEngine : currentStorageEngines) { - if (isDuplicated(storageEngine, currentStorageEngine)) { + if (storageEngine.equals(currentStorageEngine)) { duplicatedStorageEngines.add(storageEngine); LOGGER.error("repeatedly add storage engine {}.", storageEngine); status.addToSubStatus(RpcUtils.FAILURE); @@ -514,23 +516,52 @@ private void addStorageEngineMetas( } } - private boolean isDuplicated(StorageEngineMeta engine1, StorageEngineMeta engine2) { - if (!engine1.getStorageEngine().equals(engine2.getStorageEngine())) { - return false; - } - if (engine1.getPort() != engine2.getPort()) { - return false; + /** This function is only for read-only dummy, temporarily */ + @Override + public Status alterStorageEngine(AlterStorageEngineReq req) { + if (!sessionManager.checkSession(req.getSessionId(), AuthType.Cluster)) { + return RpcUtils.ACCESS_DENY; } - if (!Objects.equals(engine1.getDataPrefix(), engine2.getDataPrefix())) { - return false; + Status status = new Status(RpcUtils.SUCCESS.code); + long targetId = req.getEngineId(); + Map newParams = req.getNewParams(); + StorageEngineMeta targetMeta = metaManager.getStorageEngine(targetId); + if (targetMeta == null) { + status.setCode(RpcUtils.FAILURE.code); + status.setMessage("No engine found with id:" + targetId); + return status; } - if (!Objects.equals(engine1.getSchemaPrefix(), engine2.getSchemaPrefix())) { - return false; + if (!targetMeta.isHasData() || !targetMeta.isReadOnly()) { + status.setCode(RpcUtils.FAILURE.code); + status.setMessage( + "Only read-only & dummy engines' params can be altered. Engine with id(" + + targetId + + ") cannot be altered."); + return status; + } + + // update meta info + if (newParams.remove(Constants.IP) != null + || newParams.remove(Constants.PORT) != null + || newParams.remove(Constants.DATA_PREFIX) != null + || newParams.remove(Constants.SCHEMA_PREFIX) != null) { + status.setCode(RpcUtils.FAILURE.code); + status.setMessage( + "IP, port, type, data_prefix, schema_prefix cannot be altered. Removing and adding new engine is recommended."); + return status; } - if (isLocalHost(engine1.getIp()) && isLocalHost(engine2.getIp())) { // 都是本机IP - return true; + targetMeta.updateExtraParams(newParams); + + // remove, then add + if (!metaManager.removeDummyStorageEngine(targetId)) { + LOGGER.error("unexpected error during removing dummy storage engine {}.", targetMeta); + status.setCode(RpcUtils.FAILURE.code); + status.setMessage("unexpected error occurred. Please check server log."); + return status; } - return engine1.getIp().equals(engine2.getIp()); + + addStorageEngineMetas(Collections.singletonList(targetMeta), status, true); + return status; } @Override diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/conf/Constants.java b/core/src/main/java/cn/edu/tsinghua/iginx/conf/Constants.java index 2a9dd9e1ef..82d1c61da1 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/conf/Constants.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/conf/Constants.java @@ -45,8 +45,15 @@ public class Constants { public static final String LEVEL_PLACEHOLDER = "*"; + // engine params in sql + public static final String IP = "ip"; + public static final String PORT = "port"; + public static final String HAS_DATA = "has_data"; + // dummy dir path for embedded storage engines + public static final String DUMMY_DIR = "dummy_dir"; + public static final String IS_READ_ONLY = "is_read_only"; public static final String DATA_PREFIX = "data_prefix"; diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/engine/StatementBuilder.java b/core/src/main/java/cn/edu/tsinghua/iginx/engine/StatementBuilder.java index a1e9189bdf..f76d16097a 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/engine/StatementBuilder.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/engine/StatementBuilder.java @@ -45,6 +45,7 @@ public class StatementBuilder { typeMap.put(StatementType.EXPORT_CSV_FROM_SELECT, SqlType.ExportCsv); typeMap.put(StatementType.EXPORT_STREAM_FROM_SELECT, SqlType.ExportStream); typeMap.put(StatementType.ADD_STORAGE_ENGINE, SqlType.AddStorageEngines); + typeMap.put(StatementType.ALTER_STORAGE_ENGINE, SqlType.AlterStorageEngine); typeMap.put(StatementType.REMOVE_HISTORY_DATA_SOURCE, SqlType.RemoveHistoryDataSource); typeMap.put(StatementType.SHOW_REPLICATION, SqlType.GetReplicaNum); typeMap.put(StatementType.COUNT_POINTS, SqlType.CountPoints); diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/storage/StorageManager.java b/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/storage/StorageManager.java index 4823983360..3f88625a89 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/storage/StorageManager.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/storage/StorageManager.java @@ -18,6 +18,7 @@ package cn.edu.tsinghua.iginx.engine.physical.storage; import cn.edu.tsinghua.iginx.conf.ConfigDescriptor; +import cn.edu.tsinghua.iginx.engine.physical.exception.PhysicalException; import cn.edu.tsinghua.iginx.metadata.entity.ColumnsInterval; import cn.edu.tsinghua.iginx.metadata.entity.KeyInterval; import cn.edu.tsinghua.iginx.metadata.entity.StorageEngineMeta; @@ -212,4 +213,32 @@ public static IStorage initStorageInstance(StorageEngineMeta meta) { return null; } } + + public boolean releaseStorage(StorageEngineMeta meta) throws PhysicalException { + long id = meta.getId(); + Pair pair = storageMap.get(id); + if (pair == null) { + LOGGER.warn("Storage id {} not found", id); + return false; + } + + ThreadPoolExecutor dispatcher = pair.getV(); + dispatcher.shutdown(); // 停止接收新任务 + try { + if (!dispatcher.awaitTermination(60, TimeUnit.SECONDS)) { // 等待任务完成 + dispatcher.shutdownNow(); // 如果时间内未完成任务,强制关闭 + if (!dispatcher.awaitTermination(60, TimeUnit.SECONDS)) { + LOGGER.error("Executor did not terminate"); + } + } + } catch (InterruptedException ie) { + dispatcher.shutdownNow(); + LOGGER.error("unexpected exception occurred in releasing storage engine: ", ie); + return false; + } + + pair.getK().release(); + storageMap.remove(id); + return true; + } } diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/storage/execute/StoragePhysicalTaskExecutor.java b/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/storage/execute/StoragePhysicalTaskExecutor.java index 599cc05033..514983ac08 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/storage/execute/StoragePhysicalTaskExecutor.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/storage/execute/StoragePhysicalTaskExecutor.java @@ -298,6 +298,18 @@ private StoragePhysicalTaskExecutor() { if (after.getCreatedBy() != metaManager.getIginxId()) { storageManager.addStorage(after); } + } else if (before != null && after == null) { // 删除引擎时,需要release(目前仅支持dummy & read only) + try { + if (!storageManager.releaseStorage(before)) { + LOGGER.error( + "Fail to release deleted storage engine. Please look into server log."); + } + LOGGER.info("Release storage with id={} succeeded.", before.getId()); + } catch (PhysicalException e) { + LOGGER.error( + "unexpected exception during in releasing storage engine, please contact developer to check: ", + e); + } } }; metaManager.registerStorageEngineChangeHook(storageEngineChangeHook); diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/DefaultMetaManager.java b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/DefaultMetaManager.java index baf2a41d5b..59e95b1234 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/DefaultMetaManager.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/DefaultMetaManager.java @@ -438,8 +438,11 @@ private void addStorageEngine(long storageEngineId, StorageEngineMeta storageEng public boolean removeDummyStorageEngine(long storageEngineId) { try { storage.removeDummyStorageEngine(storageEngineId); + // release 对接层 + for (StorageEngineChangeHook hook : storageEngineChangeHooks) { + hook.onChange(getStorageEngine(storageEngineId), null); + } return cache.removeDummyStorageEngine(storageEngineId); - // TODO 由于当前 StorageEngineChangeHook 和 StorageUnitHook 只会处理新增事件,因此不必调用相关 onChange 函数 } catch (MetaStorageException e) { LOGGER.error("remove dummy storage engine {} error: ", storageEngineId, e); } diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/StorageEngineMeta.java b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/StorageEngineMeta.java index 2be914f2d3..991329ba1c 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/StorageEngineMeta.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/StorageEngineMeta.java @@ -17,10 +17,14 @@ */ package cn.edu.tsinghua.iginx.metadata.entity; +import static cn.edu.tsinghua.iginx.utils.HostUtils.isLocalHost; + import cn.edu.tsinghua.iginx.thrift.StorageEngineType; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.validation.constraints.NotNull; public final class StorageEngineMeta { @@ -212,6 +216,10 @@ public void setExtraParams(Map extraParams) { this.extraParams = extraParams; } + public void updateExtraParams(Map newParams) { + this.extraParams.putAll(newParams); + } + public StorageEngineType getStorageEngine() { return storageEngine; } @@ -277,6 +285,29 @@ public void setNeedReAllocate(boolean needReAllocate) { this.needReAllocate = needReAllocate; } + public static String extractEmbeddedPrefix(@NotNull String dummyDirPath) { + if (dummyDirPath.isEmpty()) { + return null; + } + String separator = System.getProperty("file.separator"); + // dummyDirPath是规范路径,一定不会以separator结尾 + String prefix = dummyDirPath.substring(dummyDirPath.lastIndexOf(separator) + 1); + // "/" also can be used on windows, just in case + return prefix.substring(prefix.lastIndexOf("/") + 1); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StorageEngineMeta that = (StorageEngineMeta) o; + return (ip.equals(that.ip) || (isLocalHost(ip) && isLocalHost(that.ip))) + && port == that.port + && storageEngine == that.storageEngine + && Objects.equals(schemaPrefix, that.getSchemaPrefix()) + && Objects.equals(dataPrefix, that.getDataPrefix()); + } + @Override public String toString() { return "StorageEngineMeta {" diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/storage/etcd/ETCDMetaStorage.java b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/storage/etcd/ETCDMetaStorage.java index 30e582acad..c60eb0457a 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/storage/etcd/ETCDMetaStorage.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/storage/etcd/ETCDMetaStorage.java @@ -121,7 +121,7 @@ public class ETCDMetaStorage implements IMetaStorage { private final int STORAGE_ENGINE_NODE_LENGTH = 10; private String generateID(String prefix, long idLength, long val) { - return String.format(prefix + "%0" + idLength + "d", (int) val); + return String.format(prefix + "%0" + idLength + "d", val); } public ETCDMetaStorage() { diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/utils/StorageEngineUtils.java b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/utils/StorageEngineUtils.java index b2e35b8abc..090a350d68 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/utils/StorageEngineUtils.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/utils/StorageEngineUtils.java @@ -60,7 +60,7 @@ public static boolean checkEmbeddedStorageExtraParams( if (iginxPort == null || iginxPort.isEmpty()) { return false; } - boolean hasData = Boolean.parseBoolean(extraParams.getOrDefault(HAS_DATA, "false")); + boolean hasData = Boolean.parseBoolean(extraParams.getOrDefault(Constants.HAS_DATA, "false")); boolean readOnly = Boolean.parseBoolean(extraParams.getOrDefault(Constants.IS_READ_ONLY, "false")); if (hasData) { @@ -81,10 +81,7 @@ public static boolean checkEmbeddedStorageExtraParams( return false; } } - String separator = System.getProperty("file.separator"); - // dummyDirPath是规范路径,一定不会以separator结尾 - String dirPrefix = dummyDirPath.substring(dummyDirPath.lastIndexOf(separator) + 1); - extraParams.put(EMBEDDED_PREFIX, dirPrefix); + extraParams.put(EMBEDDED_PREFIX, StorageEngineMeta.extractEmbeddedPrefix(dummyDirPath)); } else { // hasData=false readOnly=true 无意义的引擎 if (readOnly) { diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/sql/IginXSqlVisitor.java b/core/src/main/java/cn/edu/tsinghua/iginx/sql/IginXSqlVisitor.java index 30f916b73a..80fb8b8d4b 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/sql/IginXSqlVisitor.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/sql/IginXSqlVisitor.java @@ -547,6 +547,13 @@ public Statement visitAddStorageEngineStatement(AddStorageEngineStatementContext return addStorageEngineStatement; } + @Override + public Statement visitAlterEngineStatement(SqlParser.AlterEngineStatementContext ctx) { + long engineId = Long.parseLong(ctx.engineId.getText()); + Map newParams = parseExtra(ctx.params); + return new AlterEngineStatement(engineId, newParams); + } + @Override public Statement visitShowColumnsStatement(ShowColumnsStatementContext ctx) { return parseShowColumnsOptions(ctx.showColumnsOptions()); diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/sql/statement/AlterEngineStatement.java b/core/src/main/java/cn/edu/tsinghua/iginx/sql/statement/AlterEngineStatement.java new file mode 100644 index 0000000000..a8af8b1270 --- /dev/null +++ b/core/src/main/java/cn/edu/tsinghua/iginx/sql/statement/AlterEngineStatement.java @@ -0,0 +1,50 @@ +/* + * IGinX - the polystore system with high performance + * Copyright (C) Tsinghua University + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package cn.edu.tsinghua.iginx.sql.statement; + +import cn.edu.tsinghua.iginx.IginxWorker; +import cn.edu.tsinghua.iginx.engine.shared.RequestContext; +import cn.edu.tsinghua.iginx.engine.shared.Result; +import cn.edu.tsinghua.iginx.engine.shared.exception.StatementExecutionException; +import cn.edu.tsinghua.iginx.thrift.AlterStorageEngineReq; +import cn.edu.tsinghua.iginx.thrift.Status; +import java.util.Map; + +public class AlterEngineStatement extends SystemStatement { + + private final long engineId; + + private final IginxWorker worker = IginxWorker.getInstance(); + + private final Map newParams; + + public AlterEngineStatement(long engineId, Map newParams) { + this.statementType = StatementType.ALTER_STORAGE_ENGINE; + this.engineId = engineId; + this.newParams = newParams; + } + + @Override + public void execute(RequestContext ctx) throws StatementExecutionException { + AlterStorageEngineReq req = new AlterStorageEngineReq(ctx.getSessionId(), engineId, newParams); + Status status = worker.alterStorageEngine(req); + + Result result = new Result(status); + ctx.setResult(result); + } +} diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/sql/statement/StatementType.java b/core/src/main/java/cn/edu/tsinghua/iginx/sql/statement/StatementType.java index 7130308932..236820ea2a 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/sql/statement/StatementType.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/sql/statement/StatementType.java @@ -28,6 +28,7 @@ public enum StatementType { EXPORT_CSV_FROM_SELECT, EXPORT_STREAM_FROM_SELECT, ADD_STORAGE_ENGINE, + ALTER_STORAGE_ENGINE, SHOW_REPLICATION, COUNT_POINTS, CLEAR_DATA, diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/BaseCapacityExpansionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/BaseCapacityExpansionIT.java index 2d280f2384..30ce5d5896 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/BaseCapacityExpansionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/BaseCapacityExpansionIT.java @@ -21,8 +21,7 @@ import static cn.edu.tsinghua.iginx.integration.controller.Controller.SUPPORT_KEY; import static cn.edu.tsinghua.iginx.integration.expansion.constant.Constant.*; import static cn.edu.tsinghua.iginx.integration.expansion.utils.SQLTestTools.executeShellScript; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import cn.edu.tsinghua.iginx.exception.SessionException; import cn.edu.tsinghua.iginx.integration.controller.Controller; @@ -35,11 +34,10 @@ import cn.edu.tsinghua.iginx.session.QueryDataSet; import cn.edu.tsinghua.iginx.session.Session; import cn.edu.tsinghua.iginx.thrift.RemovedStorageEngineInfo; +import cn.edu.tsinghua.iginx.thrift.StorageEngineInfo; import cn.edu.tsinghua.iginx.thrift.StorageEngineType; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; import org.junit.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,6 +49,8 @@ public abstract class BaseCapacityExpansionIT { protected static Session session; + protected static final String ALTER_ENGINE_STRING = "alter storageengine %d with params \"%s\";"; + private static final ConfLoader testConf = new ConfLoader(Controller.CONFIG_FILE); protected StorageEngineType type; @@ -59,6 +59,8 @@ public abstract class BaseCapacityExpansionIT { protected List wrongExtraParams = new ArrayList<>(); + protected Map updatedParams = new HashMap<>(); + private final boolean IS_PARQUET_OR_FILE_SYSTEM = this instanceof FileSystemCapacityExpansionIT || this instanceof ParquetCapacityExpansionIT; @@ -68,6 +70,8 @@ public abstract class BaseCapacityExpansionIT { public static final String DBCE_PARQUET_FS_TEST_DIR = "test"; + protected static final String updateParamsScriptDir = ".github/scripts/dataSources/update/"; + protected static BaseHistoryDataGenerator generator; public BaseCapacityExpansionIT( @@ -244,11 +248,13 @@ public void oriNoDataExpNoData() throws InterruptedException { } @Test - public void testReadOnly() throws InterruptedException { + public void testReadOnly() throws InterruptedException, SessionException { // 查询原始只读节点的历史数据,结果不为空 testQueryHistoryDataOriHasData(); + // 测试只读节点的参数修改 + testUpdateEngineParams(); // 测试参数错误的只读节点扩容 - testInvalidDummyParams(readOnlyPort, true, false, null, EXP_SCHEMA_PREFIX); + testInvalidDummyParams(readOnlyPort, true, true, null, READ_ONLY_SCHEMA_PREFIX); // 扩容只读节点 addStorageEngineInProgress(readOnlyPort, true, true, null, READ_ONLY_SCHEMA_PREFIX); // 查询扩容只读节点的历史数据,结果不为空 @@ -320,6 +326,69 @@ protected void testInvalidDummyParams( } } + /** 测试引擎修改参数(目前仅支持dummy & read-only) */ + protected void testUpdateEngineParams() throws SessionException { + // 修改前后通过相同schema_prefix查询判断引擎成功更新 + LOGGER.info("Testing updating engine params..."); + if (updatedParams.isEmpty()) { + LOGGER.info("Engine {} skipped this test.", type); + return; + } + + String prefix = "prefix"; + // 添加只读节点 + addStorageEngine(readOnlyPort, true, true, null, prefix, extraParams); + // 查询 + String statement = "select wt01.status, wt01.temperature from " + prefix + ".tm.wf05;"; + List pathList = + READ_ONLY_PATH_LIST.stream().map(s -> prefix + "." + s).collect(Collectors.toList()); + List> valuesList = READ_ONLY_VALUES_LIST; + SQLTestTools.executeAndCompare(session, statement, pathList, valuesList); + + // 修改数据库参数 + updateParams(readOnlyPort); + + // 修改 + List engineInfoList = session.getClusterInfo().getStorageEngineInfos(); + long id = -1; + for (StorageEngineInfo info : engineInfoList) { + if (info.getIp().equals("127.0.0.1") + && info.getPort() == readOnlyPort + && info.getDataPrefix().equals("null") + && info.getSchemaPrefix().equals(prefix) + && info.getType().equals(type)) { + id = info.getId(); + } + } + assertTrue(id != -1); + + String newParams = + updatedParams.entrySet().stream() + .map(entry -> entry.getKey() + ":" + entry.getValue()) + .collect(Collectors.joining(", ")); + session.executeSql(String.format(ALTER_ENGINE_STRING, id, newParams)); + + // 重新查询 + statement = "select wt01.status, wt01.temperature from " + prefix + ".tm.wf05;"; + pathList = READ_ONLY_PATH_LIST.stream().map(s -> prefix + "." + s).collect(Collectors.toList()); + valuesList = READ_ONLY_VALUES_LIST; + SQLTestTools.executeAndCompare(session, statement, pathList, valuesList); + + // 删除,不影响后续测试 + session.removeHistoryDataSource( + Collections.singletonList( + new RemovedStorageEngineInfo("127.0.0.1", readOnlyPort, prefix, ""))); + + // 改回数据库参数 + restoreParams(readOnlyPort); + } + + /** 这个方法需要实现:通过脚本修改port对应数据源的可变参数,如密码等 */ + protected abstract void updateParams(int port); + + /** 这个方法需要实现:通过脚本恢复updateParams中修改的可变参数 */ + protected abstract void restoreParams(int port); + protected void queryExtendedKeyDummy() { // ori // extended key queryable @@ -731,15 +800,15 @@ protected void startStorageEngineWithIginx(int port, boolean hasData, boolean is if (this instanceof FileSystemCapacityExpansionIT) { if (isOnMac) { - scriptPath = ".github/scripts/dataSources/filesystem_macos.sh"; + scriptPath = ".github/scripts/dataSources/startup/filesystem_macos.sh"; } else { - scriptPath = ".github/scripts/dataSources/filesystem_linux_windows.sh"; + scriptPath = ".github/scripts/dataSources/startup/filesystem_linux_windows.sh"; } } else if (this instanceof ParquetCapacityExpansionIT) { if (isOnMac) { - scriptPath = ".github/scripts/dataSources/parquet_macos.sh"; + scriptPath = ".github/scripts/dataSources/startup/parquet_macos.sh"; } else { - scriptPath = ".github/scripts/dataSources/parquet_linux_windows.sh"; + scriptPath = ".github/scripts/dataSources/startup/parquet_linux_windows.sh"; } } else { throw new IllegalStateException("Only support file system and parquet"); diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/filesystem/FileSystemCapacityExpansionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/filesystem/FileSystemCapacityExpansionIT.java index 449a1d2a52..461ed202e1 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/filesystem/FileSystemCapacityExpansionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/filesystem/FileSystemCapacityExpansionIT.java @@ -112,4 +112,11 @@ public void testShowColumns() { + "Total line number = 3\n"; SQLTestTools.executeAndCompare(session, statement, expected); } + + // no param is allowed to be updated + @Override + protected void updateParams(int port) {} + + @Override + protected void restoreParams(int port) {} } diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/influxdb/InfluxDBCapacityExpansionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/influxdb/InfluxDBCapacityExpansionIT.java index eda0e0b9e1..3a089246c7 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/influxdb/InfluxDBCapacityExpansionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/influxdb/InfluxDBCapacityExpansionIT.java @@ -18,7 +18,9 @@ package cn.edu.tsinghua.iginx.integration.expansion.influxdb; +import static cn.edu.tsinghua.iginx.integration.expansion.utils.SQLTestTools.executeShellScript; import static cn.edu.tsinghua.iginx.thrift.StorageEngineType.influxdb; +import static org.junit.Assert.fail; import cn.edu.tsinghua.iginx.integration.controller.Controller; import cn.edu.tsinghua.iginx.integration.expansion.BaseCapacityExpansionIT; @@ -44,9 +46,35 @@ public InfluxDBCapacityExpansionIT() { Constant.readOnlyPort = dbConf.getDBCEPortMap().get(Constant.READ_ONLY_PORT_NAME); wrongExtraParams.add( "username:user, password:12345678, token:testToken, organization:wrongOrg"); + updatedParams.put("organization", "newOrg"); } // dummy key range cannot be extended yet @Override protected void queryExtendedKeyDummy() {} + + @Override + protected void updateParams(int port) { + changeParams(port, "newOrg"); + } + + @Override + protected void restoreParams(int port) { + changeParams(port, "testOrg"); + } + + private void changeParams(int port, String newOrgName) { + String scriptPath = updateParamsScriptDir + "influxdb.sh"; + String os = System.getProperty("os.name").toLowerCase(); + if (os.contains("mac")) { + scriptPath = updateParamsScriptDir + "influxdb_macos.sh"; + } else if (os.contains("win")) { + scriptPath = updateParamsScriptDir + "influxdb_windows.sh"; + } + // 脚本参数:对应端口,新参数 + int res = executeShellScript(scriptPath, String.valueOf(port), newOrgName); + if (res != 0) { + fail("Fail to update influxdb params."); + } + } } diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/iotdb/IoTDB12CapacityExpansionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/iotdb/IoTDB12CapacityExpansionIT.java index aad4f8d6d9..1242fbcbb0 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/iotdb/IoTDB12CapacityExpansionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/iotdb/IoTDB12CapacityExpansionIT.java @@ -18,7 +18,9 @@ package cn.edu.tsinghua.iginx.integration.expansion.iotdb; +import static cn.edu.tsinghua.iginx.integration.expansion.utils.SQLTestTools.executeShellScript; import static cn.edu.tsinghua.iginx.thrift.StorageEngineType.iotdb12; +import static org.junit.Assert.fail; import cn.edu.tsinghua.iginx.integration.expansion.BaseCapacityExpansionIT; import org.slf4j.Logger; @@ -35,5 +37,31 @@ public IoTDB12CapacityExpansionIT() { new IoTDB12HistoryDataGenerator()); wrongExtraParams.add("username:root, password:wrong, sessionPoolSize:20"); wrongExtraParams.add("username:wrong, password:root, sessionPoolSize:20"); + updatedParams.put("password", "newPassword"); + } + + @Override + protected void updateParams(int port) { + changeParams(port, "root", "newPassword"); + } + + @Override + protected void restoreParams(int port) { + changeParams(port, "newPassword", "root"); + } + + private void changeParams(int port, String oldPw, String newPw) { + String scriptPath = updateParamsScriptDir + "iotdb.sh"; + String os = System.getProperty("os.name").toLowerCase(); + if (os.contains("mac")) { + scriptPath = updateParamsScriptDir + "iotdb_macos.sh"; + } else if (os.contains("win")) { + scriptPath = updateParamsScriptDir + "iotdb_windows.sh"; + } + // 脚本参数:对应端口,旧密码,新密码 + int res = executeShellScript(scriptPath, String.valueOf(port), oldPw, newPw); + if (res != 0) { + fail("Fail to update iotdb params."); + } } } diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/mongodb/MongoDBCapacityExpansionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/mongodb/MongoDBCapacityExpansionIT.java index a7b840345e..5806db1b79 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/mongodb/MongoDBCapacityExpansionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/mongodb/MongoDBCapacityExpansionIT.java @@ -353,4 +353,11 @@ public void testShowColumns() { + "Total line number = 3\n"; SQLTestTools.executeAndCompare(session, statement, expected); } + + // no param is allowed to be updated + @Override + protected void updateParams(int port) {} + + @Override + protected void restoreParams(int port) {} } diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/mysql/MySQLCapacityExpansionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/mysql/MySQLCapacityExpansionIT.java index 4e04b6f86f..a0d8944aeb 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/mysql/MySQLCapacityExpansionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/mysql/MySQLCapacityExpansionIT.java @@ -18,6 +18,9 @@ package cn.edu.tsinghua.iginx.integration.expansion.mysql; +import static cn.edu.tsinghua.iginx.integration.expansion.utils.SQLTestTools.executeShellScript; +import static org.junit.Assert.fail; + import cn.edu.tsinghua.iginx.integration.controller.Controller; import cn.edu.tsinghua.iginx.integration.expansion.BaseCapacityExpansionIT; import cn.edu.tsinghua.iginx.integration.expansion.constant.Constant; @@ -42,5 +45,33 @@ public MySQLCapacityExpansionIT() { Constant.oriPort = dbConf.getDBCEPortMap().get(Constant.ORI_PORT_NAME); Constant.expPort = dbConf.getDBCEPortMap().get(Constant.EXP_PORT_NAME); Constant.readOnlyPort = dbConf.getDBCEPortMap().get(Constant.READ_ONLY_PORT_NAME); + updatedParams.put("password", "newPassword"); + } + + @Override + protected void updateParams(int port) { + changeParams(port, null, "newPassword"); + } + + @Override + protected void restoreParams(int port) { + changeParams(port, "newPassword", null); + } + + private void changeParams(int port, String oldPw, String newPw) { + String scriptPath = updateParamsScriptDir + "mysql.sh"; + String mode = oldPw == null ? "set" : "unset"; + String os = System.getProperty("os.name").toLowerCase(); + if (os.contains("mac")) { + scriptPath = updateParamsScriptDir + "mysql_macos.sh"; + } else if (os.contains("win")) { + scriptPath = updateParamsScriptDir + "mysql_windows.sh"; + } + // 脚本参数:对应端口,模式(是在无密码条件下设置密码,还是在有密码条件下去掉密码),需要设置的密码/需要被去掉的密码 + int res = + executeShellScript(scriptPath, String.valueOf(port), mode, oldPw == null ? newPw : oldPw); + if (res != 0) { + fail("Fail to update mysql params."); + } } } diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/parquet/ParquetCapacityExpansionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/parquet/ParquetCapacityExpansionIT.java index 60f3aa60ee..589628dc1e 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/parquet/ParquetCapacityExpansionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/parquet/ParquetCapacityExpansionIT.java @@ -38,4 +38,11 @@ protected void testInvalidDummyParams( int port, boolean hasData, boolean isReadOnly, String dataPrefix, String schemaPrefix) { LOGGER.info("parquet skips test for wrong dummy engine params."); } + + // no param is allowed to be updated + @Override + protected void updateParams(int port) {} + + @Override + protected void restoreParams(int port) {} } diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/postgresql/PostgreSQLCapacityExpansionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/postgresql/PostgreSQLCapacityExpansionIT.java index c3e7bf6895..03d62aaeca 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/postgresql/PostgreSQLCapacityExpansionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/postgresql/PostgreSQLCapacityExpansionIT.java @@ -18,6 +18,9 @@ package cn.edu.tsinghua.iginx.integration.expansion.postgresql; +import static cn.edu.tsinghua.iginx.integration.expansion.utils.SQLTestTools.executeShellScript; +import static org.junit.Assert.fail; + import cn.edu.tsinghua.iginx.integration.controller.Controller; import cn.edu.tsinghua.iginx.integration.expansion.BaseCapacityExpansionIT; import cn.edu.tsinghua.iginx.integration.expansion.constant.Constant; @@ -46,6 +49,8 @@ public PostgreSQLCapacityExpansionIT() { Constant.readOnlyPort = dbConf.getDBCEPortMap().get(Constant.READ_ONLY_PORT_NAME); wrongExtraParams.add("username:wrong, password:postgres"); // wrong password situation cannot be tested because trust mode is used + + updatedParams.put("password", "newPassword"); } @Override @@ -138,4 +143,29 @@ protected void testConcatFunction() { assert false; } } + + @Override + protected void updateParams(int port) { + changeParams(port, "postgres", "newPassword"); + } + + @Override + protected void restoreParams(int port) { + changeParams(port, "newPassword", "postgres"); + } + + private void changeParams(int port, String oldPw, String newPw) { + String scriptPath = updateParamsScriptDir + "postgresql.sh"; + String os = System.getProperty("os.name").toLowerCase(); + if (os.contains("mac")) { + scriptPath = updateParamsScriptDir + "postgresql_macos.sh"; + } else if (os.contains("win")) { + scriptPath = updateParamsScriptDir + "postgresql_windows.sh"; + } + // 脚本参数:对应端口,旧密码,新密码 + int res = executeShellScript(scriptPath, String.valueOf(port), oldPw, newPw); + if (res != 0) { + fail("Fail to update postgresql params."); + } + } } diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/redis/RedisCapacityExpansionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/redis/RedisCapacityExpansionIT.java index 8a9502c46f..cf1e038de4 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/redis/RedisCapacityExpansionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/expansion/redis/RedisCapacityExpansionIT.java @@ -96,4 +96,11 @@ public void testShowColumns() { + "Total line number = 2\n"; SQLTestTools.executeAndCompare(session, statement, expected); } + + // no param is allowed to be updated + @Override + protected void updateParams(int port) {} + + @Override + protected void restoreParams(int port) {} } diff --git a/thrift/src/main/proto/rpc.thrift b/thrift/src/main/proto/rpc.thrift index b0429d071b..5d64ad21c7 100644 --- a/thrift/src/main/proto/rpc.thrift +++ b/thrift/src/main/proto/rpc.thrift @@ -59,6 +59,7 @@ enum SqlType { Query, GetReplicaNum, AddStorageEngines, + AlterStorageEngine, CountPoints, ClearData, DeleteColumns, @@ -267,6 +268,12 @@ struct AddStorageEnginesReq { 2: required list storageEngines } +struct AlterStorageEngineReq { + 1: required i64 sessionId + 2: required i64 engineId + 3: required map newParams +} + struct StorageEngine { 1: required string ip 2: required i32 port @@ -730,6 +737,8 @@ service IService { Status addStorageEngines(1: AddStorageEnginesReq req); + Status alterStorageEngine(1: AlterStorageEngineReq req); + Status removeHistoryDataSource(1: RemoveHistoryDataSourceReq req); AggregateQueryResp aggregateQuery(1: AggregateQueryReq req);