diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index f2dbc04353f023d3f72a9f4fd27e8bc8746b871b..3a03972e68d662603b4d49a7f640f6aa9e05ff92 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -6,10 +6,10 @@ ######################################################## # first full-qualified domain name (FQDN) for TDengine system -# first hostname1:6030 +# firstEp hostname1:6030 # second full-qualified domain name (FQDN) for TDengine system, for cluster edition only -# second cluster_hostname2:6030 +# secondEp cluster_hostname2:6030 # the full-qualified domain name (FQDN) of dnode # fqdn hostname @@ -23,9 +23,6 @@ # log file's directory # logDir /var/log/taos -# scriptDir file's directory -# scriptDir /var/log/taos - # data file's directory # dataDir /var/lib/taos diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index b2613a7cb62faae489d52d1711c05581b63e8428..47a8febe35c299b2934df75334890cc340eadc34 100644 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -241,36 +241,17 @@ function install_config() { # first full-qualified domain name (FQDN) for TDengine cluster system echo - echo -e -n "${GREEN}Enter the FQDN of an existing TDengine cluster node to join${NC} OR ${GREEN}leave it blank to build one${NC} :" - read firstFqdn + echo -e -n "${GREEN}Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join OR leave it blank to build one${NC} :" + read firstEp while true; do - if [ ! -z "$firstFqdn" ]; then - # check the format of the firstFqdn - #if [[ $firstFqdn == $FQDN_PATTERN ]]; then - # Write the first FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(first\s*).*/\1$firstFqdn/" ${cfg_install_dir}/taos.cfg - - # Get the second FQDN - echo - echo -e -n "${GREEN}Enter the FQDN of another node in cluster${NC} OR ${GREEN}leave it blank to skip${NC}: " - read secondFqdn - while true; do - if [ ! -z "$secondFqdn" ]; then - #if [[ $secondFqdn == $FQDN_PATTERN ]]; then - # Write the second FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(second\s*).*/\1$secondFqdn/" ${cfg_install_dir}/taos.cfg - break - #else - # read -p "Please enter the correct FQDN: " secondFqdn - #fi - else - break - fi - done - + if [ ! -z "$firstEp" ]; then + # check the format of the firstEp + #if [[ $firstEp == $FQDN_PATTERN ]]; then + # Write the first FQDN to configuration file + ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg break #else - # read -p "Please enter the correct FQDN: " firstFqdn + # read -p "Please enter the correct FQDN:port: " firstEp #fi else break @@ -584,7 +565,7 @@ function update_TDengine() { install_service install_config - if [ "$verMode" == "cluster" ]; then + if [ "$verMode" == "cluster" ]; then # Check if openresty is installed openresty_work=false @@ -597,7 +578,7 @@ function update_TDengine() { echo -e "\033[44;31;5mNginx for TDengine does not work! Please try again!\033[0m" fi fi - fi + fi echo echo -e "\033[44;32;1mTDengine is updated successfully!${NC}" @@ -678,8 +659,8 @@ function install_TDengine() { install_config # Ask if to start the service - echo - echo -e "\033[44;32;1mTDengine is installed successfully!${NC}" + #echo + #echo -e "\033[44;32;1mTDengine is installed successfully!${NC}" echo echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" if ((${service_mod}==0)); then @@ -700,8 +681,11 @@ function install_TDengine() { echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}" fi + echo + echo -e "${GREEN_DARK}Please run${NC}: taos -h $firstEp ${GREEN_DARK} to login into cluster, then execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}in TAOS shell to add this new node into the clsuter${NC}" echo echo -e "\033[44;32;1mTDengine is installed successfully!${NC}" + echo else # Only install client install_bin install_config diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 79ea2b2d46be17c41d1dcc06796499ef3d69fc4b..1a510299c1b73af8189775fdc7e5d9af442e7411 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -297,7 +297,7 @@ static void doInitGlobalConfig() { SGlobalCfg cfg = {0}; // ip address - cfg.option = "first"; + cfg.option = "firstEp"; cfg.ptr = tsFirst; cfg.valType = TAOS_CFG_VTYPE_STRING; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; @@ -307,7 +307,7 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - cfg.option = "second"; + cfg.option = "secondEp"; cfg.ptr = tsSecond; cfg.valType = TAOS_CFG_VTYPE_STRING; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java index f4c9ec765aab2f2fe29b958f56fcf38634fa9639..02d642d6430d8c2dccaa9be03258861ff051a374 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java @@ -260,50 +260,66 @@ public class TSDBDriver implements java.sql.Driver { if (url.indexOf("?") != -1) { String dbName = url.substring(0, url.indexOf("?")); urlProps.setProperty(PROPERTY_KEY_DBNAME, dbName); - url = url.trim().substring(1); + url = url.trim().substring(url.indexOf("?") + 1); } else { // without user & password so return - String dbName = url.trim(); - urlProps.setProperty(PROPERTY_KEY_DBNAME, dbName); + if(!url.trim().isEmpty()) { + String dbName = url.trim(); + urlProps.setProperty(PROPERTY_KEY_DBNAME, dbName); + } this.dbMetaData = new TSDBDatabaseMetaData(dbProductName, urlForMeta, urlProps.getProperty("user")); return urlProps; } - String[] queryStrings = url.trim().split("&"); String user = ""; + + if (url.indexOf("&") == -1) { + String[] kvPair = url.trim().split("="); + if (kvPair.length == 2) { + setPropertyValue(urlProps, kvPair); + return urlProps; + } + } + + String[] queryStrings = url.trim().split("&"); for (String queryStr : queryStrings) { String[] kvPair = queryStr.trim().split("="); if (kvPair.length < 2){ continue; } - switch (kvPair[0].toLowerCase()) { - case PROPERTY_KEY_USER: - urlProps.setProperty(PROPERTY_KEY_USER, kvPair[1]); - user = kvPair[1]; - break; - case PROPERTY_KEY_PASSWORD: - urlProps.setProperty(PROPERTY_KEY_PASSWORD, kvPair[1]); - break; - case PROPERTY_KEY_TIME_ZONE: - urlProps.setProperty(PROPERTY_KEY_TIME_ZONE, kvPair[1]); - break; - case PROPERTY_KEY_LOCALE: - urlProps.setProperty(PROPERTY_KEY_LOCALE, kvPair[1]); - break; - case PROPERTY_KEY_CHARSET: - urlProps.setProperty(PROPERTY_KEY_CHARSET, kvPair[1]); - break; - case PROPERTY_KEY_CONFIG_DIR: - urlProps.setProperty(PROPERTY_KEY_CONFIG_DIR, kvPair[1]); - break; - } + setPropertyValue(urlProps, kvPair); } + user = urlProps.getProperty(PROPERTY_KEY_USER).toString(); this.dbMetaData = new TSDBDatabaseMetaData(dbProductName, urlForMeta, user); return urlProps; } + public void setPropertyValue(Properties property, String[] keyValuePair) { + switch (keyValuePair[0].toLowerCase()) { + case PROPERTY_KEY_USER: + property.setProperty(PROPERTY_KEY_USER, keyValuePair[1]); + break; + case PROPERTY_KEY_PASSWORD: + property.setProperty(PROPERTY_KEY_PASSWORD, keyValuePair[1]); + break; + case PROPERTY_KEY_TIME_ZONE: + property.setProperty(PROPERTY_KEY_TIME_ZONE, keyValuePair[1]); + break; + case PROPERTY_KEY_LOCALE: + property.setProperty(PROPERTY_KEY_LOCALE, keyValuePair[1]); + break; + case PROPERTY_KEY_CHARSET: + property.setProperty(PROPERTY_KEY_CHARSET, keyValuePair[1]); + break; + case PROPERTY_KEY_CONFIG_DIR: + property.setProperty(PROPERTY_KEY_CONFIG_DIR, keyValuePair[1]); + break; + } + } + + public int getMajorVersion() { return 1; } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDriverTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDriverTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9ea5a431a5ef6dca232467aa80d430c6ac33dd69 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDriverTest.java @@ -0,0 +1,47 @@ +package com.taosdata.jdbc; + +import org.junit.Test; + +import java.sql.SQLException; +import java.util.Properties; + +import static org.junit.Assert.assertEquals; + +public class TSDBDriverTest { + + @Test + public void urlParserTest() throws SQLException { + TSDBDriver driver = new TSDBDriver(); + String url = "jdbc:TSDB://127.0.0.1:0/db?user=root&password=your_password"; + + Properties properties = new Properties(); + driver.parseURL(url, properties); + assertEquals(properties.get("host"), "127.0.0.1"); + assertEquals(properties.get("port"), "0"); + assertEquals(properties.get("dbname"), "db"); + assertEquals(properties.get("user"), "root"); + assertEquals(properties.get("password"), "your_password"); + + url = "jdbc:TSDB://127.0.0.1:0/log?charset=UTF-8"; + properties = new Properties(); + driver.parseURL(url, properties); + assertEquals(properties.get("host"), "127.0.0.1"); + assertEquals(properties.get("port"), "0"); + assertEquals(properties.get("dbname"), "log"); + assertEquals(properties.get("charset"), "UTF-8"); + + url = "jdbc:TSDB://127.0.0.1:0/"; + properties = new Properties(); + driver.parseURL(url, properties); + assertEquals(properties.get("host"), "127.0.0.1"); + assertEquals(properties.get("port"), "0"); + assertEquals(properties.get("dbname"), null); + + url = "jdbc:TSDB://127.0.0.1:0/db"; + properties = new Properties(); + driver.parseURL(url, properties); + assertEquals(properties.get("host"), "127.0.0.1"); + assertEquals(properties.get("port"), "0"); + assertEquals(properties.get("dbname"), "db"); + } +} \ No newline at end of file diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 01dcc73ef65e4d75ea9f3d7e7a83ab0ee8892950..616a3bfd7f26b55bb2b71aa9bb3f7720bd69e43c 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -73,6 +73,8 @@ TAOS *shellInit(SShellArguments *args) { // Connect to the database. TAOS *con = taos_connect(args->host, args->user, args->password, args->database, args->port); if (con == NULL) { + printf("taos connect failed, reason: %s.\n\n", tstrerror(terrno)); + fflush(stdout); return con; } diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index ac65237319cfb97a9e9100a980f6b840cf7bd20a..90ca14277b42447daa9667628a3e748d0e3cb1ac 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -104,48 +104,48 @@ elif [ $NODE -eq 8 ]; then NODE=7800 fi -echo " " >> $TAOS_CFG -echo "first ${HOSTNAME}:7100" >> $TAOS_CFG -echo "second ${HOSTNAME}:7200" >> $TAOS_CFG -echo "serverPort ${NODE}" >> $TAOS_CFG -echo "dataDir $DATA_DIR" >> $TAOS_CFG -echo "logDir $LOG_DIR" >> $TAOS_CFG -echo "debugFlag 0" >> $TAOS_CFG -echo "mDebugFlag 135" >> $TAOS_CFG -echo "sdbDebugFlag 135" >> $TAOS_CFG -echo "dDebugFlag 135" >> $TAOS_CFG -echo "vDebugFlag 135" >> $TAOS_CFG -echo "tsdbDebugFlag 135" >> $TAOS_CFG -echo "cDebugFlag 135" >> $TAOS_CFG -echo "jnidebugFlag 135" >> $TAOS_CFG -echo "odbcdebugFlag 135" >> $TAOS_CFG -echo "httpDebugFlag 143" >> $TAOS_CFG -echo "monitorDebugFlag 135" >> $TAOS_CFG -echo "mqttDebugFlag 135" >> $TAOS_CFG -echo "qdebugFlag 135" >> $TAOS_CFG -echo "rpcDebugFlag 135" >> $TAOS_CFG -echo "tmrDebugFlag 131" >> $TAOS_CFG -echo "udebugFlag 135" >> $TAOS_CFG -echo "sdebugFlag 135" >> $TAOS_CFG -echo "wdebugFlag 135" >> $TAOS_CFG -echo "monitor 0" >> $TAOS_CFG -echo "monitorInterval 1" >> $TAOS_CFG -echo "http 0" >> $TAOS_CFG -echo "numOfThreadsPerCore 2.0" >> $TAOS_CFG -echo "defaultPass taosdata" >> $TAOS_CFG -echo "numOfLogLines 20000000" >> $TAOS_CFG -echo "mnodeEqualVnodeNum 0" >> $TAOS_CFG -echo "clog 2" >> $TAOS_CFG -#echo "cache 1" >> $TAOS_CFG -#echo "block 2" >> $TAOS_CFG -echo "statusInterval 1" >> $TAOS_CFG -echo "maxVgroupsPerDb 4" >> $TAOS_CFG -echo "minTablesPerVnode 4" >> $TAOS_CFG -echo "maxTablesPerVnode 1000" >> $TAOS_CFG -echo "tableIncStepPerVnode 10000" >> $TAOS_CFG -echo "asyncLog 0" >> $TAOS_CFG -echo "numOfMnodes 1" >> $TAOS_CFG -echo "locale en_US.UTF-8" >> $TAOS_CFG -echo "fsync 0" >> $TAOS_CFG - +echo " " >> $TAOS_CFG +echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG +echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG +echo "serverPort ${NODE}" >> $TAOS_CFG +echo "dataDir $DATA_DIR" >> $TAOS_CFG +echo "logDir $LOG_DIR" >> $TAOS_CFG +echo "debugFlag 0" >> $TAOS_CFG +echo "mDebugFlag 135" >> $TAOS_CFG +echo "sdbDebugFlag 135" >> $TAOS_CFG +echo "dDebugFlag 135" >> $TAOS_CFG +echo "vDebugFlag 135" >> $TAOS_CFG +echo "tsdbDebugFlag 135" >> $TAOS_CFG +echo "cDebugFlag 135" >> $TAOS_CFG +echo "jnidebugFlag 135" >> $TAOS_CFG +echo "odbcdebugFlag 135" >> $TAOS_CFG +echo "httpDebugFlag 143" >> $TAOS_CFG +echo "monitorDebugFlag 135" >> $TAOS_CFG +echo "mqttDebugFlag 135" >> $TAOS_CFG +echo "qdebugFlag 135" >> $TAOS_CFG +echo "rpcDebugFlag 135" >> $TAOS_CFG +echo "tmrDebugFlag 131" >> $TAOS_CFG +echo "udebugFlag 135" >> $TAOS_CFG +echo "sdebugFlag 135" >> $TAOS_CFG +echo "wdebugFlag 135" >> $TAOS_CFG +echo "monitor 0" >> $TAOS_CFG +echo "monitorInterval 1" >> $TAOS_CFG +echo "http 0" >> $TAOS_CFG +echo "numOfThreadsPerCore 2.0" >> $TAOS_CFG +echo "defaultPass taosdata" >> $TAOS_CFG +echo "numOfLogLines 20000000" >> $TAOS_CFG +echo "mnodeEqualVnodeNum 0" >> $TAOS_CFG +echo "clog 2" >> $TAOS_CFG +#echo "cache 1" >> $TAOS_CFG +#echo "block 2" >> $TAOS_CFG +echo "statusInterval 1" >> $TAOS_CFG +echo "maxVgroupsPerDb 4" >> $TAOS_CFG +echo "minTablesPerVnode 4" >> $TAOS_CFG +echo "maxTablesPerVnode 1000" >> $TAOS_CFG +echo "tableIncStepPerVnode 10000" >> $TAOS_CFG +echo "asyncLog 0" >> $TAOS_CFG +echo "numOfMnodes 1" >> $TAOS_CFG +echo "locale en_US.UTF-8" >> $TAOS_CFG +echo "fsync 0" >> $TAOS_CFG +echo " " >> $TAOS_CFG diff --git a/tests/script/test.sh b/tests/script/test.sh index d9a738749f6223bc7f2ec76384bf49fa0c19a98e..96e4ffe689e5098b36ca9993eed66fd7ba9cacef 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -101,28 +101,29 @@ TAOS_FLAG=$PRG_DIR/flag HOSTNAME=`hostname -f` -echo " " >> $TAOS_CFG -echo "first ${HOSTNAME}:7100" >> $TAOS_CFG -echo "second ${HOSTNAME}:7200" >> $TAOS_CFG -echo "serverPort 7100" >> $TAOS_CFG -echo "dataDir $DATA_DIR" >> $TAOS_CFG -echo "logDir $LOG_DIR" >> $TAOS_CFG -echo "scriptDir ${CODE_DIR}/../script">> $TAOS_CFG -echo "numOfLogLines 100000000" >> $TAOS_CFG -echo "dDebugFlag 135" >> $TAOS_CFG -echo "mDebugFlag 135" >> $TAOS_CFG -echo "sdbDebugFlag 135" >> $TAOS_CFG -echo "rpcDebugFlag 135" >> $TAOS_CFG -echo "tmrDebugFlag 131" >> $TAOS_CFG -echo "cDebugFlag 135" >> $TAOS_CFG -echo "httpDebugFlag 135" >> $TAOS_CFG -echo "monitorDebugFlag 135" >> $TAOS_CFG -echo "udebugFlag 135" >> $TAOS_CFG -echo "tablemetakeeptimer 5" >> $TAOS_CFG -echo "wal 0" >> $TAOS_CFG -echo "asyncLog 0" >> $TAOS_CFG -echo "locale en_US.UTF-8" >> $TAOS_CFG -echo " " >> $TAOS_CFG +echo " " >> $TAOS_CFG +echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG +echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG +echo "serverPort 7100" >> $TAOS_CFG +echo "dataDir $DATA_DIR" >> $TAOS_CFG +echo "logDir $LOG_DIR" >> $TAOS_CFG +echo "scriptDir ${CODE_DIR}/../script" >> $TAOS_CFG +echo "numOfLogLines 100000000" >> $TAOS_CFG +echo "dDebugFlag 135" >> $TAOS_CFG +echo "mDebugFlag 135" >> $TAOS_CFG +echo "sdbDebugFlag 135" >> $TAOS_CFG +echo "rpcDebugFlag 135" >> $TAOS_CFG +echo "tmrDebugFlag 131" >> $TAOS_CFG +echo "cDebugFlag 135" >> $TAOS_CFG +echo "httpDebugFlag 135" >> $TAOS_CFG +echo "monitorDebugFlag 135" >> $TAOS_CFG +echo "udebugFlag 135" >> $TAOS_CFG +echo "tablemetakeeptimer 5" >> $TAOS_CFG +echo "wal 0" >> $TAOS_CFG +echo "asyncLog 0" >> $TAOS_CFG +echo "locale en_US.UTF-8" >> $TAOS_CFG +echo "enableCoreFile 1" >> $TAOS_CFG +echo " " >> $TAOS_CFG ulimit -n 600000 ulimit -c unlimited