diff --git a/packaging/deb/DEBIAN/preinst b/packaging/deb/DEBIAN/preinst
index 472d853637d8f39f02de2f872555794e3e026d5b..b313f90e90eeb6c4c29e70a6e276aa5e49b3e786 100644
--- a/packaging/deb/DEBIAN/preinst
+++ b/packaging/deb/DEBIAN/preinst
@@ -11,6 +11,8 @@ if pidof taosd &> /dev/null; then
${csudo} systemctl stop taosd || :
elif $(which insserv &> /dev/null); then
${csudo} service taosd stop || :
+ elif $(which update-rc.d &> /dev/null); then
+ ${csudo} service taosd stop || :
else
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || :
diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec
index 7b0a1afd6e75b68719a190848e0c50b2c170ef0d..c858f01d8a46b8096a09cbc533e5ab68043de688 100644
--- a/packaging/rpm/tdengine.spec
+++ b/packaging/rpm/tdengine.spec
@@ -70,14 +70,6 @@ cp -r %{_compiledir}/../tests/examples/* %{buildroot}%{homepath}/exam
#Scripts executed before installation
%pre
-function is_using_systemd() {
- if pidof systemd &> /dev/null; then
- return 0
- else
- return 1
- fi
-}
-
csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
@@ -85,10 +77,15 @@ fi
# Stop the service if running
if pidof taosd &> /dev/null; then
- if is_using_systemd; then
+ if pidof systemd &> /dev/null; then
${csudo} systemctl stop taosd || :
- else
+ elif $(which insserv &> /dev/null); then
${csudo} service taosd stop || :
+ elif $(which update-rc.d &> /dev/null); then
+ ${csudo} service taosd stop || :
+ else
+ pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
+ ${csudo} kill -9 ${pid} || :
fi
echo "Stop taosd service success!"
sleep 1
diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh
index 7dd64306602ee1c4d28a6622f3f96d7ed37377cf..9e1878365737d614369d536932ba0b00918d2a4f 100755
--- a/packaging/tools/post.sh
+++ b/packaging/tools/post.sh
@@ -38,26 +38,26 @@ if command -v sudo > /dev/null; then
csudo="sudo"
fi
+initd_mod=0
service_mod=2
if pidof systemd &> /dev/null; then
service_mod=0
+elif $(which insserv &> /dev/null); then
+ service_mod=1
+ initd_mod=1
+ service_config_dir="/etc/init.d"
elif $(which update-rc.d &> /dev/null); then
service_mod=1
+ initd_mod=2
service_config_dir="/etc/init.d"
else
service_mod=2
fi
function kill_taosd() {
- ${csudo} pkill -f taosd || :
-}
-
-function is_using_systemd() {
- if pidof systemd &> /dev/null; then
- return 0
- else
- return 1
- fi
+# ${csudo} pkill -f taosd || :
+ pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
+ ${csudo} kill -9 ${pid} || :
}
function install_include() {
@@ -103,12 +103,18 @@ function install_config() {
function clean_service_on_sysvinit() {
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
- #if pidof taosd &> /dev/null; then
- # ${csudo} service taosd stop || :
- #fi
+ if pidof taosd &> /dev/null; then
+ ${csudo} service taosd stop || :
+ fi
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
${csudo} rm -f ${service_config_dir}/taosd || :
- ${csudo} update-rc.d -f taosd remove || :
+
+ if ((${initd_mod}==1)); then
+ ${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || :
+ elif ((${initd_mod}==2)); then
+ ${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || :
+ fi
+# ${csudo} update-rc.d -f taosd remove || :
${csudo} init q || :
}
diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh
index edf8072fc31bbf4195c3e165cfdf69e8b97c9b59..4ada19762c55034751d64de0dd063100424b3503 100755
--- a/packaging/tools/remove.sh
+++ b/packaging/tools/remove.sh
@@ -23,18 +23,27 @@ if command -v sudo > /dev/null; then
csudo="sudo"
fi
-function is_using_systemd() {
- if pidof systemd &> /dev/null; then
- return 0
- else
- return 1
- fi
-}
-
-if ! is_using_systemd; then
+initd_mod=0
+service_mod=2
+if pidof systemd &> /dev/null; then
+ service_mod=0
+elif $(which insserv &> /dev/null); then
+ service_mod=1
+ initd_mod=1
service_config_dir="/etc/init.d"
+elif $(which update-rc.d &> /dev/null); then
+ service_mod=1
+ initd_mod=2
+ service_config_dir="/etc/init.d"
+else
+ service_mod=2
fi
+function kill_taosd() {
+ pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
+ ${csudo} kill -9 ${pid} || :
+}
+
function clean_bin() {
# Remove link
${csudo} rm -f ${bin_link_dir}/taos || :
@@ -78,23 +87,29 @@ function clean_service_on_systemd() {
function clean_service_on_sysvinit() {
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
-
if pidof taosd &> /dev/null; then
- echo "TDengine taosd is running, stopping it..."
${csudo} service taosd stop || :
fi
-
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
${csudo} rm -f ${service_config_dir}/taosd || :
- ${csudo} update-rc.d -f taosd remove || :
+
+ if ((${initd_mod}==1)); then
+ ${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || :
+ elif ((${initd_mod}==2)); then
+ ${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || :
+ fi
+# ${csudo} update-rc.d -f taosd remove || :
${csudo} init q || :
}
function clean_service() {
- if is_using_systemd; then
+ if ((${service_mod}==0)); then
clean_service_on_systemd
- else
+ elif ((${service_mod}==1)); then
clean_service_on_sysvinit
+ else
+ # must manual start taosd
+ kill_taosd
fi
}
diff --git a/src/inc/tutil.h b/src/inc/tutil.h
index 901810c44ea7eb43e4f1ef95c8082f692e714366..a9de168fae8a300d3c03c98367b69512276a7071 100644
--- a/src/inc/tutil.h
+++ b/src/inc/tutil.h
@@ -184,7 +184,7 @@ char *strnchr(char *haystack, char needle, int32_t len, bool skipquote);
char **strsplit(char *src, const char *delim, int32_t *num);
-void strtolower(char *dst, const char *src);
+char* strtolower(char *dst, const char *src);
int64_t strnatoi(char *num, int32_t len);
diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c
index f9bd6aace475f8ec290259c9f1b024795a49549d..d2865ec31dfe6e2b5720b6dbb7066c4b013b1ef9 100644
--- a/src/util/src/tutil.c
+++ b/src/util/src/tutil.c
@@ -140,28 +140,31 @@ char *strnchr(char *haystack, char needle, int32_t len, bool skipquote) {
return NULL;
}
-void strtolower(char *dst, const char *z) {
- int quote = 0;
- char *str = z;
- if (dst == NULL) {
- return;
- }
-
- while (*str) {
- if (*str == '\'' || *str == '"') {
- quote = quote ^ 1;
- }
-
- if ((!quote) && (*str >= 'A' && *str <= 'Z')) {
- *dst++ = *str | 0x20;
- } else {
- *dst++ = *str;
+char* strtolower(char *dst, const char *src) {
+ int esc = 0;
+ char quote = 0, *p = dst, c;
+
+ assert(dst != NULL);
+
+ for (c = *src++; c; c = *src++) {
+ if (esc) {
+ esc = 0;
+ } else if (quote) {
+ if (c == '\\') {
+ esc = 1;
+ } else if (c == quote) {
+ quote = 0;
+ }
+ } else if (c >= 'A' && c <= 'Z') {
+ c -= 'A' - 'a';
+ } else if (c == '\'' || c == '"') {
+ quote = c;
}
-
- str++;
+ *p++ = c;
}
- *dst = 0;
+ *p = 0;
+ return dst;
}
char *paGetToken(char *string, char **token, int32_t *tokenLen) {
diff --git a/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml b/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b4f29bea5dff95d2a189fda27aba5cb479a568c9
--- /dev/null
+++ b/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml
@@ -0,0 +1,295 @@
+
+
+
+ 4.0.0
+
+ com.opentsdb.test
+ opentsdbtest
+ 1.0-SNAPSHOT
+ jar
+
+
+
+
+ org.apache.maven.plugins
+ maven-plugins
+ 30
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.0.0
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.1.0
+
+
+
+ OpentsdbTest
+
+
+
+ jar-with-dependencies
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.2
+
+
+ 8
+
+
+
+
+
+
+ opentsdbtest
+
+ http://www.example.com
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+ net.opentsdb
+ opentsdb_gwt_theme
+ 1.0.0
+
+
+
+ net.opentsdb
+ opentsdb
+ 2.4.0
+
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+ com.google.guava
+ guava
+ 18.0
+
+
+
+ com.google.gwt
+ gwt-user
+ 2.6.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ 2.9.5
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ 2.9.5
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.9.5
+
+
+
+ io.netty
+ netty
+ 3.10.6.Final
+
+
+
+ com.stumbleupon
+ async
+ 1.4.0
+
+
+
+ org.apache.commons
+ commons-math3
+ 3.4.1
+
+
+ org.apache.commons
+ commons-jexl
+ 2.1.1
+
+
+ org.apache.commons
+ commons-lang3
+ 3.7
+
+
+ org.apache.commons
+ commons-collections4
+ 4.3
+
+
+
+ org.apache.httpcomponents
+ httpasyncclient
+ 4.1.3
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.4
+
+
+
+ org.jgrapht
+ jgrapht-core
+ 0.9.1
+
+
+
+ com.esotericsoftware.kryo
+ kryo
+ 2.21.1
+
+
+
+ com.datastax.oss
+ java-driver-core
+ 4.1.0
+
+
+
+ com.datastax.oss
+ java-driver-query-builder
+ 4.1.0
+
+
+
+ com.datastax.oss
+ java-driver-mapper-runtime
+ 4.1.0
+
+
+
+ commons-io
+ commons-io
+ 2.4
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.25
+
+
+ org.slf4j
+ slf4j-log4j12
+ 1.7.21
+
+
+ org.slf4j
+ log4j-over-slf4j
+ 1.7.7
+
+
+
+ org.apache.logging.log4j
+ log4j-1.2-api
+ 2.8.2
+
+
+
+ ch.qos.logback
+ logback-core
+ 1.0.13
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.0.13
+
+
+
+ org.projectlombok
+ lombok
+ 1.18.0
+
+
+
+ com.github.eulery
+ opentsdb-java-sdk
+ 1.1.4
+
+
+
+
+
+
+
+ hbase
+
+ true
+
+
+
+
+ org.hbase
+ asynchbase
+ 1.8.2
+
+
+
+ org.apache.zookeeper
+ zookeeper
+ 3.4.6
+
+
+ log4j
+ log4j
+
+
+ org.slf4j
+ slf4j-log4j12
+
+
+ jline
+ jline
+
+
+ junit
+ junit
+
+
+
+
+
+
+
+
+
diff --git a/tests/comparisonTest/opentsdb/opentsdbtest/src/main/java/com/opentsdb/test/OpentsdbTest.java b/tests/comparisonTest/opentsdb/opentsdbtest/src/main/java/com/opentsdb/test/OpentsdbTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..e1a20dfb4908182e3471cac834c57b477b124998
--- /dev/null
+++ b/tests/comparisonTest/opentsdb/opentsdbtest/src/main/java/com/opentsdb/test/OpentsdbTest.java
@@ -0,0 +1,468 @@
+import com.stumbleupon.async.Callback;
+import com.stumbleupon.async.Deferred;
+import lombok.extern.slf4j.Slf4j;
+
+import net.opentsdb.core.TSDB;
+import net.opentsdb.uid.NoSuchUniqueName;
+import net.opentsdb.uid.UniqueId.UniqueIdType;
+import net.opentsdb.utils.Config;
+
+import java.net.URL;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.concurrent.FutureCallback;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
+
+
+import java.io.BufferedWriter;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.FileReader;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.text.DecimalFormat;
+import java.util.Random;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.LinkedHashMap;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.*;
+import java.math.*;
+import java.lang.reflect.Method;
+
+
+public class OpentsdbTest{
+
+ //static { System.setProperty("logback.configurationFile", "/home/ubuntu/fang/opentsdb/opentsdbtest/logback.xml");}
+ static { System.setProperty("logback.configurationFile", "/etc/opentsdb/logback.xml");}
+
+ public static void main(String args[]) {
+ // begin to parse argument
+ String datadir = "/home/ubuntu/testdata";
+ String sqlchoice = "q1";
+ int numOfRows = 1000000;
+ int numOfFiles = 0;
+ int numOfClients = 1;
+ int rowsPerRequest = 1;
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i].equalsIgnoreCase("-dataDir")) {
+ if (i < args.length - 1) {
+ datadir = args[++i];
+ }
+ } else if (args[i].equalsIgnoreCase("-numofFiles")) {
+ if (i < args.length - 1) {
+ numOfFiles = Integer.parseInt(args[++i]);
+ }
+ } else if (args[i].equalsIgnoreCase("-rowsPerRequest")) {
+ if (i < args.length - 1) {
+ rowsPerRequest = Integer.parseInt(args[++i]);
+ }
+ } else if (args[i].equalsIgnoreCase("-writeClients")) {
+ if (i < args.length - 1) {
+ numOfClients = Integer.parseInt(args[++i]);
+ }
+ } else if (args[i].equalsIgnoreCase("-sql")) {
+ sqlchoice = args[++i];
+ }
+ }
+ System.out.println("parameters:\n");
+
+
+ if (numOfFiles >0) {
+ // write data
+ System.out.printf("----dataDir:%s\n", datadir);
+ System.out.printf("----numOfFiles:%d\n", numOfFiles);
+ System.out.printf("----numOfClients:%d\n", numOfClients);
+ System.out.printf("----rowsPerRequest:%d\n", rowsPerRequest);
+ try {
+ // begin to insert data
+ System.out.printf("----begin to insert data\n");
+ long startTime = System.currentTimeMillis();
+ int a = numOfFiles/numOfClients;
+ int b = numOfFiles%numOfClients;
+ int last = 0;
+
+ WriteThread[] writethreads = new WriteThread[numOfClients];
+ int[] wargs = new int[2]; // data file start, end
+ wargs[0] = numOfRows; //rows to be read from each file
+ wargs[1] = rowsPerRequest;
+ int fstart =0;
+ int fend =0;
+ for (int i = 0; i
+
+
+
+
+
+
+
+ %date [%thread] %-5level %logger{80} - %msg%n
+
+
+
+
+ UTF-8
+
+ ${logbase}%d{yyyy-MM-dd}.log.html
+ ${logbase}.%d{yyyy-MM-dd}.log.html.zip
+
+
+
+ 2MB
+
+
+ %date%level%thread%10logger%file%line%msg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+