configure the socket type(TCP/UDP) in config file.#671

This commit is contained in:
hjxilinx 2019-11-04 13:16:31 +08:00
parent ba197c2d39
commit 654a5061ff
7 changed files with 26 additions and 11 deletions

View File

@ -54,6 +54,9 @@
# interval of system monitor # interval of system monitor
# monitorInterval 60 # 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 # RPC re-try timer, millisecond
# rpcTimer 300 # rpcTimer 300

View File

@ -118,7 +118,7 @@ void taos_init_imp() {
rpcInit.sessionsPerChann = tsMaxVnodeConnections / tscNumOfThreads; rpcInit.sessionsPerChann = tsMaxVnodeConnections / tscNumOfThreads;
rpcInit.idMgmt = TAOS_ID_FREE; rpcInit.idMgmt = TAOS_ID_FREE;
rpcInit.noFree = 0; rpcInit.noFree = 0;
rpcInit.connType = TAOS_CONN_UDP; rpcInit.connType = TAOS_CONN_SOCKET_TYPE_C();
rpcInit.qhandle = tscQhandle; rpcInit.qhandle = tscQhandle;
pVnodeConn = taosOpenRpc(&rpcInit); pVnodeConn = taosOpenRpc(&rpcInit);
if (pVnodeConn == NULL) { if (pVnodeConn == NULL) {
@ -139,7 +139,7 @@ void taos_init_imp() {
rpcInit.sessionsPerChann = tsMaxMgmtConnections; rpcInit.sessionsPerChann = tsMaxMgmtConnections;
rpcInit.idMgmt = TAOS_ID_FREE; rpcInit.idMgmt = TAOS_ID_FREE;
rpcInit.noFree = 0; rpcInit.noFree = 0;
rpcInit.connType = TAOS_CONN_UDP; rpcInit.connType = TAOS_CONN_SOCKET_TYPE_C();
rpcInit.qhandle = tscQhandle; rpcInit.qhandle = tscQhandle;
pTscMgmtConn = taosOpenRpc(&rpcInit); pTscMgmtConn = taosOpenRpc(&rpcInit);
if (pTscMgmtConn == NULL) { if (pTscMgmtConn == NULL) {

View File

@ -132,6 +132,8 @@ extern int tsStreamCompRetryDelay;
extern int tsProjectExecInterval; extern int tsProjectExecInterval;
extern int64_t tsMaxRetentWindow; extern int64_t tsMaxRetentWindow;
extern int tsUDPSocket;
extern char tsHttpIp[]; extern char tsHttpIp[];
extern short tsHttpPort; extern short tsHttpPort;
extern int tsHttpCacheSessions; extern int tsHttpCacheSessions;
@ -182,12 +184,12 @@ void tsSetTimeZone();
void tsSetLocale(); void tsSetLocale();
void tsInitGlobalConfig(); void tsInitGlobalConfig();
#define TSDB_CFG_CTYPE_B_CONFIG 1 // can be configured from file #define TSDB_CFG_CTYPE_B_CONFIG 1U // can be configured from file
#define TSDB_CFG_CTYPE_B_SHOW 2 // can displayed by "show configs" commands #define TSDB_CFG_CTYPE_B_SHOW 2U // can displayed by "show configs" commands
#define TSDB_CFG_CTYPE_B_LOG 4 // is a log type configuration #define TSDB_CFG_CTYPE_B_LOG 4U // is a log type configuration
#define TSDB_CFG_CTYPE_B_CLIENT 8 // can be displayed in the client log #define TSDB_CFG_CTYPE_B_CLIENT 8U // 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_OPTION 16U // can be configured by taos_options function
#define TSDB_CFG_CTYPE_B_NOT_PRINT 32 #define TSDB_CFG_CTYPE_B_NOT_PRINT 32U
#define TSDB_CFG_CSTATUS_NONE 0 // not configured #define TSDB_CFG_CSTATUS_NONE 0 // not configured
#define TSDB_CFG_CSTATUS_DEFAULT 1 // use system default value #define TSDB_CFG_CSTATUS_DEFAULT 1 // use system default value

View File

@ -34,6 +34,9 @@ extern "C" {
#define TAOS_ID_FREE 1 #define TAOS_ID_FREE 1
#define TAOS_ID_REALLOCATE 2 #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 taosSendMsgToPeer(x, y, z) taosSendMsgToPeerH(x, y, z, NULL)
#define taosOpenRpcChann(x, y, z) taosOpenRpcChannWithQ(x, y, z, NULL) #define taosOpenRpcChann(x, y, z) taosOpenRpcChannWithQ(x, y, z, NULL)
#define taosBuildReqMsg(x, y) taosBuildReqMsgWithSize(x, y, 512) #define taosBuildReqMsg(x, y) taosBuildReqMsgWithSize(x, y, 512)

View File

@ -64,7 +64,7 @@ int mgmtInitShell() {
rpcInit.numOfChanns = 1; rpcInit.numOfChanns = 1;
rpcInit.sessionsPerChann = tsMaxShellConns; rpcInit.sessionsPerChann = tsMaxShellConns;
rpcInit.idMgmt = TAOS_ID_FREE; rpcInit.idMgmt = TAOS_ID_FREE;
rpcInit.connType = TAOS_CONN_UDPS; rpcInit.connType = TAOS_CONN_SOCKET_TYPE_S();
rpcInit.idleTime = tsShellActivityTimer * 2000; rpcInit.idleTime = tsShellActivityTimer * 2000;
rpcInit.qhandle = mgmtQhandle; rpcInit.qhandle = mgmtQhandle;
rpcInit.afp = mgmtRetriveUserAuthInfo; rpcInit.afp = mgmtRetriveUserAuthInfo;

View File

@ -127,7 +127,7 @@ int vnodeInitShell() {
rpcInit.numOfChanns = TSDB_MAX_VNODES; rpcInit.numOfChanns = TSDB_MAX_VNODES;
rpcInit.sessionsPerChann = 16; rpcInit.sessionsPerChann = 16;
rpcInit.idMgmt = TAOS_ID_FREE; rpcInit.idMgmt = TAOS_ID_FREE;
rpcInit.connType = TAOS_CONN_UDPS; rpcInit.connType = TAOS_CONN_SOCKET_TYPE_S();
rpcInit.idleTime = tsShellActivityTimer * 2000; rpcInit.idleTime = tsShellActivityTimer * 2000;
rpcInit.qhandle = rpcQhandle[0]; rpcInit.qhandle = rpcQhandle[0];
rpcInit.efp = vnodeSendVpeerCfgMsg; rpcInit.efp = vnodeSendVpeerCfgMsg;

View File

@ -122,6 +122,8 @@ int tsStreamCompRetryDelay = 10; // the stream computing delay
int tsProjectExecInterval = 10000; // every 10sec, the projection will be executed once int tsProjectExecInterval = 10000; // every 10sec, the projection will be executed once
int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance 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"; char tsHttpIp[TSDB_IPv4ADDR_LEN] = "0.0.0.0";
short tsHttpPort = 6020; // only tcp, range tcp[6020] short tsHttpPort = 6020; // only tcp, range tcp[6020]
// short tsNginxPort = 6060; //only tcp, range tcp[6060] // short tsNginxPort = 6060; //only tcp, range tcp[6060]
@ -494,7 +496,12 @@ void tsInitGlobalConfig() {
tsInitConfigOption(cfg++, "defaultUser", tsDefaultUser, TSDB_CFG_VTYPE_STRING, 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); 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, 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 // locale & charset
tsInitConfigOption(cfg++, "timezone", tsTimezone, TSDB_CFG_VTYPE_STRING, tsInitConfigOption(cfg++, "timezone", tsTimezone, TSDB_CFG_VTYPE_STRING,