提交 afb33efc 编写于 作者: H hjxilinx

configure the connection option through taos_options #671

上级 5d1b1735
......@@ -54,8 +54,9 @@
# interval of system monitor
# monitorInterval 60
# set socket type(UDP by default). if udpsocket is 0, TCP is applied for all connections
# udpsocket 1
# set socket type("udp" and "tcp").
# The server and client should have the same socket type. Otherwise, connect will fail.
# sockettype udp
# RPC re-try timer, millisecond
# rpcTimer 300
......
......@@ -174,6 +174,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
SGlobalConfig *cfg_locale = tsGetConfigOption("locale");
SGlobalConfig *cfg_charset = tsGetConfigOption("charset");
SGlobalConfig *cfg_timezone = tsGetConfigOption("timezone");
SGlobalConfig *cfg_socket = tsGetConfigOption("sockettype");
switch (option) {
case TSDB_OPTION_CONFIGDIR:
......@@ -304,6 +305,20 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
tsCfgStatusStr[cfg_timezone->cfgStatus], (char *)cfg_timezone->ptr);
}
break;
case TSDB_OPTION_SOCKET_TYPE:
if (cfg_socket && cfg_socket->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
if (strcasecmp(arg, TAOS_SOCKET_TYPE_NAME_UDP) != 0 && strcasecmp(arg, TAOS_SOCKET_TYPE_NAME_TCP) != 0) {
tscError("only 'tcp' or 'udp' allowed for configuring the socket type");
return -1;
}
strncpy(tsSocketType, arg, tListLen(tsSocketType));
cfg_socket->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
tscPrint("socket type is set:%s", tsSocketType);
}
break;
default:
tscError("Invalid option %d", option);
return -1;
......
......@@ -46,6 +46,7 @@ typedef enum {
TSDB_OPTION_TIMEZONE,
TSDB_OPTION_CONFIGDIR,
TSDB_OPTION_SHELL_ACTIVITY_TIMER,
TSDB_OPTION_SOCKET_TYPE,
TSDB_MAX_OPTIONS
} TSDB_OPTION;
......
......@@ -132,7 +132,7 @@ extern int tsStreamCompRetryDelay;
extern int tsProjectExecInterval;
extern int64_t tsMaxRetentWindow;
extern int tsUDPSocket;
extern char tsSocketType[4];
extern char tsHttpIp[];
extern short tsHttpPort;
......
......@@ -30,12 +30,15 @@ extern "C" {
#define TAOS_CONN_HTTPS 4
#define TAOS_CONN_HTTPC 5
#define TAOS_SOCKET_TYPE_NAME_TCP "tcp"
#define TAOS_SOCKET_TYPE_NAME_UDP "udp"
#define TAOS_ID_ASSIGNED 0
#define TAOS_ID_FREE 1
#define TAOS_ID_REALLOCATE 2
#define TAOS_CONN_SOCKET_TYPE_S() ((tsUDPSocket == 1)? TAOS_CONN_UDPS:TAOS_CONN_TCPS)
#define TAOS_CONN_SOCKET_TYPE_C() ((tsUDPSocket == 1)? TAOS_CONN_UDP:TAOS_CONN_TCPC)
#define TAOS_CONN_SOCKET_TYPE_S() ((strcasecmp(tsSocketType, TAOS_SOCKET_TYPE_NAME_UDP) == 0)? TAOS_CONN_UDPS:TAOS_CONN_TCPS)
#define TAOS_CONN_SOCKET_TYPE_C() ((strcasecmp(tsSocketType, TAOS_SOCKET_TYPE_NAME_UDP) == 0)? TAOS_CONN_UDP:TAOS_CONN_TCPC)
#define taosSendMsgToPeer(x, y, z) taosSendMsgToPeerH(x, y, z, NULL)
#define taosOpenRpcChann(x, y, z) taosOpenRpcChannWithQ(x, y, z, NULL)
......
......@@ -122,8 +122,7 @@ int tsStreamCompRetryDelay = 10; // the stream computing delay
int tsProjectExecInterval = 10000; // every 10sec, the projection will be executed once
int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance
int tsUDPSocket = 1; // use UDP by default, if tsUDPSocket equals to 0, all connection use TCP socket
char tsSocketType[4] = "udp"; // use UDP by default[option: udp, tcp]
char tsHttpIp[TSDB_IPv4ADDR_LEN] = "0.0.0.0";
short tsHttpPort = 6020; // only tcp, range tcp[6020]
// short tsNginxPort = 6060; //only tcp, range tcp[6060]
......@@ -500,8 +499,8 @@ void tsInitGlobalConfig() {
TSDB_PASSWORD_LEN, TSDB_CFG_UTYPE_NONE);
// socket type, udp by default
tsInitConfigOption(cfg++, "udpsocket", &tsUDPSocket, TSDB_CFG_VTYPE_INT,
TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW, 0, 1, 1, TSDB_CFG_UTYPE_NONE);
tsInitConfigOption(cfg++, "sockettype", tsSocketType, TSDB_CFG_VTYPE_STRING,
TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW, 0, 0, 3, TSDB_CFG_UTYPE_NONE);
// locale & charset
tsInitConfigOption(cfg++, "timezone", tsTimezone, TSDB_CFG_VTYPE_STRING,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册