提交 ce4c2c20 编写于 作者: H Hongze Cheng

Merge branch 'develop' into feature/2.0tsdb

......@@ -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
......
......@@ -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
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*(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
${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg
break
#else
# read -p "Please enter the correct FQDN: " secondFqdn
#fi
else
break
fi
done
break
#else
# read -p "Please enter the correct FQDN: " firstFqdn
# read -p "Please enter the correct FQDN:port: " firstEp
#fi
else
break
......@@ -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
......@@ -701,7 +682,10 @@ function install_TDengine() {
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
......
......@@ -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;
......
......@@ -260,49 +260,65 @@ 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
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()) {
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:
urlProps.setProperty(PROPERTY_KEY_USER, kvPair[1]);
user = kvPair[1];
property.setProperty(PROPERTY_KEY_USER, keyValuePair[1]);
break;
case PROPERTY_KEY_PASSWORD:
urlProps.setProperty(PROPERTY_KEY_PASSWORD, kvPair[1]);
property.setProperty(PROPERTY_KEY_PASSWORD, keyValuePair[1]);
break;
case PROPERTY_KEY_TIME_ZONE:
urlProps.setProperty(PROPERTY_KEY_TIME_ZONE, kvPair[1]);
property.setProperty(PROPERTY_KEY_TIME_ZONE, keyValuePair[1]);
break;
case PROPERTY_KEY_LOCALE:
urlProps.setProperty(PROPERTY_KEY_LOCALE, kvPair[1]);
property.setProperty(PROPERTY_KEY_LOCALE, keyValuePair[1]);
break;
case PROPERTY_KEY_CHARSET:
urlProps.setProperty(PROPERTY_KEY_CHARSET, kvPair[1]);
property.setProperty(PROPERTY_KEY_CHARSET, keyValuePair[1]);
break;
case PROPERTY_KEY_CONFIG_DIR:
urlProps.setProperty(PROPERTY_KEY_CONFIG_DIR, kvPair[1]);
property.setProperty(PROPERTY_KEY_CONFIG_DIR, keyValuePair[1]);
break;
}
}
this.dbMetaData = new TSDBDatabaseMetaData(dbProductName, urlForMeta, user);
return urlProps;
}
public int getMajorVersion() {
return 1;
......
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
......@@ -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;
}
......
......@@ -105,8 +105,8 @@ elif [ $NODE -eq 8 ]; then
fi
echo " " >> $TAOS_CFG
echo "first ${HOSTNAME}:7100" >> $TAOS_CFG
echo "second ${HOSTNAME}:7200" >> $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
......@@ -147,5 +147,5 @@ 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
......@@ -102,12 +102,12 @@ TAOS_FLAG=$PRG_DIR/flag
HOSTNAME=`hostname -f`
echo " " >> $TAOS_CFG
echo "first ${HOSTNAME}:7100" >> $TAOS_CFG
echo "second ${HOSTNAME}:7200" >> $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 "scriptDir ${CODE_DIR}/../script" >> $TAOS_CFG
echo "numOfLogLines 100000000" >> $TAOS_CFG
echo "dDebugFlag 135" >> $TAOS_CFG
echo "mDebugFlag 135" >> $TAOS_CFG
......@@ -122,6 +122,7 @@ 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册