From c724aab16d664261bd2d94e7de38d6aa7ffa755c Mon Sep 17 00:00:00 2001 From: lyf <1548150065@qq.com> Date: Wed, 3 Jan 2024 17:25:12 +0800 Subject: [PATCH] function.xml is perceivable --- configuration/bin/startup.sh | 7 ++++--- .../edu/tsinghua/iot/benchmark/conf/Config.java | 15 ++++++++++++++- .../tsinghua/iot/benchmark/conf/Constants.java | 2 ++ iginx/src/assembly/assembly.xml | 4 ++++ influxdb-2.0/src/assembly/assembly.xml | 4 ++++ influxdb/src/assembly/assembly.xml | 4 ++++ iotdb-0.12/src/assembly/assembly.xml | 4 ++++ iotdb-0.13/src/assembly/assembly.xml | 4 ++++ iotdb-1.0/src/assembly/assembly.xml | 4 ++++ iotdb-1.1/src/assembly/assembly.xml | 4 ++++ kairosdb/src/assembly/assembly.xml | 4 ++++ mssqlserver/src/assembly/assembly.xml | 4 ++++ opentsdb/src/assembly/assembly.xml | 4 ++++ pi/src/assembly/assembly.xml | 4 ++++ questdb/src/assembly/assembly.xml | 4 ++++ sqlite/src/assembly/assembly.xml | 4 ++++ tdengine-3.0/src/assembly/assembly.xml | 4 ++++ tdengine/src/assembly/assembly.xml | 4 ++++ timescaledb-cluster/src/assembly/assembly.xml | 4 ++++ timescaledb/src/assembly/assembly.xml | 4 ++++ verification/src/assembly/assembly.xml | 4 ++++ victoriametrics/src/assembly/assembly.xml | 4 ++++ 22 files changed, 96 insertions(+), 4 deletions(-) diff --git a/configuration/bin/startup.sh b/configuration/bin/startup.sh index cbe0c34b8..26f620b55 100755 --- a/configuration/bin/startup.sh +++ b/configuration/bin/startup.sh @@ -80,11 +80,11 @@ fi # check BENCHMARK_HOME if [ -z "${BENCHMARK_HOME}" ]; then - export BENCHMARK_HOME="$(cd "`dirname "$0"`"/.. && pwd)" + export BENCHMARK_HOME="$(cd "$(dirname "$0")" && pwd)" fi # check $benchmark_conf -if [ -z $benchmark_conf ] ; then +if [ -z "${benchmark_conf}" ] ; then benchmark_conf=${BENCHMARK_HOME}/conf/config.properties else benchmark_conf="$(cd "$(dirname "$benchmark_conf")" && pwd)/$(basename "$benchmark_conf")" @@ -93,7 +93,7 @@ else exit 1 fi fi -echo Using configuration file: $benchmark_conf +echo Using configuration file: "${benchmark_conf}" # set MAIN_CLASS MAIN_CLASS=cn.edu.tsinghua.iot.benchmark.App @@ -106,6 +106,7 @@ done # set benchmark_parms benchmark_parms="$benchmark_parms -Duser.timezone=GMT+8" benchmark_parms="$benchmark_parms -Dlogback.configurationFile=${BENCHMARK_HOME}/conf/logback.xml" +benchmark_parms="$benchmark_parms -DBENCHMARK_HOME=${BENCHMARK_HOME}" if [ -n "$MAX_HEAP_SIZE" ]; then echo Set MAX_HEAP_SIZE=$MAX_HEAP_SIZE benchmark_parms="$benchmark_parms -Xmx${MAX_HEAP_SIZE}" 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 c9b4832b4..86ee9db62 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 @@ -35,6 +35,8 @@ import javax.xml.bind.Unmarshaller; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.*; import java.util.concurrent.atomic.AtomicLong; @@ -402,11 +404,22 @@ public class Config { /** Sensor function */ private Map SENSOR_FUNCTION = new HashMap<>(); + public String getHomeDir() { + // When start benchmark with the script, the environment variables will be set. + // But in developer mode it will return another dir to find resources. + return System.getProperty(Constants.BENCHMARK_HOME, null); + } + /** init inner functions */ public void initInnerFunction() { FunctionXml xml = null; try { - InputStream input = Function.class.getResourceAsStream("/function.xml"); + InputStream input; + if (getHomeDir() == null) { + input = Function.class.getResourceAsStream("/function.xml"); + } else { + input = Files.newInputStream(Paths.get(getHomeDir() + "/resources/function.xml")); + } JAXBContext context = JAXBContext.newInstance(FunctionXml.class, FunctionParam.class); Unmarshaller unmarshaller = context.createUnmarshaller(); xml = (FunctionXml) unmarshaller.unmarshal(input); 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 1aaa700dd..70908305f 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 @@ -27,6 +27,8 @@ public class Constants { public static final long START_TIMESTAMP = TimeUtils.convertDateStrToTimestamp(config.getSTART_TIME()); public static final String CONSOLE_PREFIX = "iot-benchmark>"; + + public static final String BENCHMARK_HOME = "BENCHMARK_HOME"; public static final String BENCHMARK_CONF = "benchmark-conf"; public static final String MYSQL_DRIVENAME = "com.mysql.jdbc.Driver"; diff --git a/iginx/src/assembly/assembly.xml b/iginx/src/assembly/assembly.xml index 93ff1c548..0aa1d7115 100644 --- a/iginx/src/assembly/assembly.xml +++ b/iginx/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/influxdb-2.0/src/assembly/assembly.xml b/influxdb-2.0/src/assembly/assembly.xml index 45d37eb85..e6f0bb1d1 100644 --- a/influxdb-2.0/src/assembly/assembly.xml +++ b/influxdb-2.0/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/influxdb/src/assembly/assembly.xml b/influxdb/src/assembly/assembly.xml index 7d01be532..60a2408cf 100644 --- a/influxdb/src/assembly/assembly.xml +++ b/influxdb/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/iotdb-0.12/src/assembly/assembly.xml b/iotdb-0.12/src/assembly/assembly.xml index 29c523070..1a5addfc6 100644 --- a/iotdb-0.12/src/assembly/assembly.xml +++ b/iotdb-0.12/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/iotdb-0.13/src/assembly/assembly.xml b/iotdb-0.13/src/assembly/assembly.xml index b7b529671..320d4dea8 100644 --- a/iotdb-0.13/src/assembly/assembly.xml +++ b/iotdb-0.13/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/iotdb-1.0/src/assembly/assembly.xml b/iotdb-1.0/src/assembly/assembly.xml index ca77f5943..835e0d43a 100644 --- a/iotdb-1.0/src/assembly/assembly.xml +++ b/iotdb-1.0/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/iotdb-1.1/src/assembly/assembly.xml b/iotdb-1.1/src/assembly/assembly.xml index b54670893..543ed397e 100644 --- a/iotdb-1.1/src/assembly/assembly.xml +++ b/iotdb-1.1/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/kairosdb/src/assembly/assembly.xml b/kairosdb/src/assembly/assembly.xml index f81677b31..2afbff08d 100644 --- a/kairosdb/src/assembly/assembly.xml +++ b/kairosdb/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/mssqlserver/src/assembly/assembly.xml b/mssqlserver/src/assembly/assembly.xml index 789856b2a..d46e6384e 100644 --- a/mssqlserver/src/assembly/assembly.xml +++ b/mssqlserver/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/opentsdb/src/assembly/assembly.xml b/opentsdb/src/assembly/assembly.xml index f76aee75f..88e10223e 100644 --- a/opentsdb/src/assembly/assembly.xml +++ b/opentsdb/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/pi/src/assembly/assembly.xml b/pi/src/assembly/assembly.xml index 6b734583e..6a8986a60 100644 --- a/pi/src/assembly/assembly.xml +++ b/pi/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/questdb/src/assembly/assembly.xml b/questdb/src/assembly/assembly.xml index d105854a9..1777a84cb 100644 --- a/questdb/src/assembly/assembly.xml +++ b/questdb/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/sqlite/src/assembly/assembly.xml b/sqlite/src/assembly/assembly.xml index 0ddc9572a..ddff591ce 100644 --- a/sqlite/src/assembly/assembly.xml +++ b/sqlite/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/tdengine-3.0/src/assembly/assembly.xml b/tdengine-3.0/src/assembly/assembly.xml index c394a47c1..214a5de45 100644 --- a/tdengine-3.0/src/assembly/assembly.xml +++ b/tdengine-3.0/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/tdengine/src/assembly/assembly.xml b/tdengine/src/assembly/assembly.xml index 1b584465b..951f87baf 100644 --- a/tdengine/src/assembly/assembly.xml +++ b/tdengine/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/timescaledb-cluster/src/assembly/assembly.xml b/timescaledb-cluster/src/assembly/assembly.xml index 7e7325afa..20378f2ba 100644 --- a/timescaledb-cluster/src/assembly/assembly.xml +++ b/timescaledb-cluster/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/timescaledb/src/assembly/assembly.xml b/timescaledb/src/assembly/assembly.xml index 52a5cd813..d414eadfa 100644 --- a/timescaledb/src/assembly/assembly.xml +++ b/timescaledb/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/verification/src/assembly/assembly.xml b/verification/src/assembly/assembly.xml index 579856572..8392566d7 100644 --- a/verification/src/assembly/assembly.xml +++ b/verification/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources + diff --git a/victoriametrics/src/assembly/assembly.xml b/victoriametrics/src/assembly/assembly.xml index b9c88a2fd..e91df1994 100644 --- a/victoriametrics/src/assembly/assembly.xml +++ b/victoriametrics/src/assembly/assembly.xml @@ -40,6 +40,10 @@ ${maven.multiModuleProjectDirectory}/configuration/conf/ conf + + ${maven.multiModuleProjectDirectory}/core/src/main/resources + resources +