diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index d9a9ce32a2da534f973022fc2133e7fa97fe9b00..3f7ece8826c7dd90f47d6557e89acaeb93d23982 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -54,6 +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 + # RPC re-try timer, millisecond # rpcTimer 300 diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 7428399210c4be1740ba07ee6332fae2da040b3f..ff0c1555ffc7e17ca36c7ea5aadb0a8d7090540c 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -118,7 +118,7 @@ void taos_init_imp() { rpcInit.sessionsPerChann = tsMaxVnodeConnections / tscNumOfThreads; rpcInit.idMgmt = TAOS_ID_FREE; rpcInit.noFree = 0; - rpcInit.connType = TAOS_CONN_UDP; + rpcInit.connType = TAOS_CONN_SOCKET_TYPE_C(); rpcInit.qhandle = tscQhandle; pVnodeConn = taosOpenRpc(&rpcInit); if (pVnodeConn == NULL) { @@ -139,7 +139,7 @@ void taos_init_imp() { rpcInit.sessionsPerChann = tsMaxMgmtConnections; rpcInit.idMgmt = TAOS_ID_FREE; rpcInit.noFree = 0; - rpcInit.connType = TAOS_CONN_UDP; + rpcInit.connType = TAOS_CONN_SOCKET_TYPE_C(); rpcInit.qhandle = tscQhandle; pTscMgmtConn = taosOpenRpc(&rpcInit); if (pTscMgmtConn == NULL) { diff --git a/src/inc/tglobalcfg.h b/src/inc/tglobalcfg.h index cfc89997d3f171841761c98248a6e2c90bbb7f86..054317fcaeabe94a80d3ac2b730f1e27b5ccbf4d 100644 --- a/src/inc/tglobalcfg.h +++ b/src/inc/tglobalcfg.h @@ -132,6 +132,8 @@ extern int tsStreamCompRetryDelay; extern int tsProjectExecInterval; extern int64_t tsMaxRetentWindow; +extern int tsUDPSocket; + extern char tsHttpIp[]; extern short tsHttpPort; extern int tsHttpCacheSessions; @@ -182,12 +184,12 @@ void tsSetTimeZone(); void tsSetLocale(); void tsInitGlobalConfig(); -#define TSDB_CFG_CTYPE_B_CONFIG 1 // can be configured from file -#define TSDB_CFG_CTYPE_B_SHOW 2 // can displayed by "show configs" commands -#define TSDB_CFG_CTYPE_B_LOG 4 // is a log type configuration -#define TSDB_CFG_CTYPE_B_CLIENT 8 // can be displayed in the client log -#define TSDB_CFG_CTYPE_B_OPTION 16 // can be configured by taos_options function -#define TSDB_CFG_CTYPE_B_NOT_PRINT 32 +#define TSDB_CFG_CTYPE_B_CONFIG 1U // can be configured from file +#define TSDB_CFG_CTYPE_B_SHOW 2U // can displayed by "show configs" commands +#define TSDB_CFG_CTYPE_B_LOG 4U // is a log type configuration +#define TSDB_CFG_CTYPE_B_CLIENT 8U // can be displayed in the client log +#define TSDB_CFG_CTYPE_B_OPTION 16U // can be configured by taos_options function +#define TSDB_CFG_CTYPE_B_NOT_PRINT 32U #define TSDB_CFG_CSTATUS_NONE 0 // not configured #define TSDB_CFG_CSTATUS_DEFAULT 1 // use system default value diff --git a/src/inc/trpc.h b/src/inc/trpc.h index 70804903e32b369e49926db5451e1532765fa98f..0532f1c12990779962e154cb91f868f1e7e0c91a 100644 --- a/src/inc/trpc.h +++ b/src/inc/trpc.h @@ -34,6 +34,9 @@ extern "C" { #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 taosSendMsgToPeer(x, y, z) taosSendMsgToPeerH(x, y, z, NULL) #define taosOpenRpcChann(x, y, z) taosOpenRpcChannWithQ(x, y, z, NULL) #define taosBuildReqMsg(x, y) taosBuildReqMsgWithSize(x, y, 512) diff --git a/src/system/src/mgmtShell.c b/src/system/src/mgmtShell.c index 19f706f4a85eb62075035d223366144f97e3ec9f..9621af763b5feb527b9eee0fb4f88b077421e789 100644 --- a/src/system/src/mgmtShell.c +++ b/src/system/src/mgmtShell.c @@ -64,7 +64,7 @@ int mgmtInitShell() { rpcInit.numOfChanns = 1; rpcInit.sessionsPerChann = tsMaxShellConns; rpcInit.idMgmt = TAOS_ID_FREE; - rpcInit.connType = TAOS_CONN_UDPS; + rpcInit.connType = TAOS_CONN_SOCKET_TYPE_S(); rpcInit.idleTime = tsShellActivityTimer * 2000; rpcInit.qhandle = mgmtQhandle; rpcInit.afp = mgmtRetriveUserAuthInfo; diff --git a/src/system/src/vnodeShell.c b/src/system/src/vnodeShell.c index c87c504dcba7abe414755dda371007f5f82faccb..66818766d97186bd62951f5f6635772a74da3ff0 100644 --- a/src/system/src/vnodeShell.c +++ b/src/system/src/vnodeShell.c @@ -127,7 +127,7 @@ int vnodeInitShell() { rpcInit.numOfChanns = TSDB_MAX_VNODES; rpcInit.sessionsPerChann = 16; rpcInit.idMgmt = TAOS_ID_FREE; - rpcInit.connType = TAOS_CONN_UDPS; + rpcInit.connType = TAOS_CONN_SOCKET_TYPE_S(); rpcInit.idleTime = tsShellActivityTimer * 2000; rpcInit.qhandle = rpcQhandle[0]; rpcInit.efp = vnodeSendVpeerCfgMsg; diff --git a/src/util/src/tglobalcfg.c b/src/util/src/tglobalcfg.c index 7bdd4df7e508c3786de39bae29f73bfbc2a3ca8b..f26732e68835197ec4411a5f18bf54ebc79eb078 100644 --- a/src/util/src/tglobalcfg.c +++ b/src/util/src/tglobalcfg.c @@ -122,6 +122,8 @@ 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 tsHttpIp[TSDB_IPv4ADDR_LEN] = "0.0.0.0"; short tsHttpPort = 6020; // only tcp, range tcp[6020] // short tsNginxPort = 6060; //only tcp, range tcp[6060] @@ -494,7 +496,12 @@ void tsInitGlobalConfig() { tsInitConfigOption(cfg++, "defaultUser", tsDefaultUser, TSDB_CFG_VTYPE_STRING, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT, 0, 0, TSDB_USER_LEN, TSDB_CFG_UTYPE_NONE); tsInitConfigOption(cfg++, "defaultPass", tsDefaultPass, TSDB_CFG_VTYPE_STRING, - TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_NOT_PRINT, 0, 0, TSDB_PASSWORD_LEN, TSDB_CFG_UTYPE_NONE); + TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_NOT_PRINT, 0, 0, + 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); // locale & charset tsInitConfigOption(cfg++, "timezone", tsTimezone, TSDB_CFG_VTYPE_STRING,