未验证 提交 ebb98e4e 编写于 作者: Y Yang Zhao 提交者: GitHub

fix: do not show any ws info in websocket in not defined (#15293)

上级 5a1412f4
......@@ -51,7 +51,6 @@ typedef struct SShellArguments {
char* auth;
char* database;
char* timezone;
bool restful;
TAOS* con;
bool is_raw_time;
bool is_use_passwd;
......@@ -69,10 +68,11 @@ typedef struct SShellArguments {
char* netTestRole;
char* dsn;
#ifdef WEBSOCKET
bool restful;
WS_TAOS* ws_conn;
#endif
bool cloud;
uint32_t timeout;
#endif
} SShellArguments;
/**************** Function declarations ****************/
......
......@@ -60,12 +60,14 @@ void printHelp() {
printf("%s%s%s\n", indent, indent, "Use multi-thread to import all SQL files in the directory separately.");
printf("%s%s\n", indent, "-T");
printf("%s%s%s\n", indent, indent, "Number of threads when using multi-thread to import data.");
#ifdef WEBSOCKET
printf("%s%s\n", indent, "-R");
printf("%s%s%s\n", indent, indent, "Connect and interact with TDengine use restful.");
printf("%s%s\n", indent, "-E");
printf("%s%s%s\n", indent, indent, "The DSN to use when connecting TDengine's cloud services.");
printf("%s%s\n", indent, "-t");
printf("%s%s%s\n", indent, indent, "The timeout in seconds for websocket interact.");
#endif
exit(EXIT_SUCCESS);
}
......@@ -79,7 +81,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
// for host
if (strcmp(argv[i], "-h") == 0) {
if (i < argc - 1) {
#ifdef WEBSOCKET
arguments->cloud = false;
#endif
arguments->host = argv[++i];
} else {
fprintf(stderr, "option -h requires an argument\n");
......@@ -111,7 +115,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
// for management port
else if (strcmp(argv[i], "-P") == 0) {
if (i < argc - 1) {
#ifdef WEBSOCKET
arguments->cloud = false;
#endif
arguments->port = atoi(argv[++i]);
} else {
fprintf(stderr, "option -P requires an argument\n");
......@@ -128,7 +134,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
}
} else if (strcmp(argv[i], "-c") == 0) {
if (i < argc - 1) {
#ifdef WEBSOCKET
arguments->cloud = false;
#endif
if (strlen(argv[++i]) >= TSDB_FILENAME_LEN) {
fprintf(stderr, "config file path: %s overflow max len %d\n", argv[i], TSDB_FILENAME_LEN - 1);
exit(EXIT_FAILURE);
......@@ -198,7 +206,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit(EXIT_FAILURE);
}
}
#ifdef WEBSOCKET
else if (strcmp(argv[i], "-R") == 0) {
arguments->cloud = false;
arguments->restful = true;
......@@ -221,6 +229,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit(EXIT_FAILURE);
}
}
#endif
// For temperory command TODO
else if (strcmp(argv[i], "--help") == 0) {
......@@ -232,6 +241,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit(EXIT_FAILURE);
}
}
#ifdef WEBSOCKET
if (args.dsn == NULL) {
if (args.cloud) {
args.dsn = getenv("TDENGINE_CLOUD_DSN");
......@@ -242,6 +252,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
} else {
args.cloud = true;
}
#endif
}
int32_t shellReadCommand(TAOS *con, char *command) {
......
......@@ -52,9 +52,11 @@ static struct argp_option options[] = {
{"pktlen", 'l', "PKTLEN", 0, "Packet length used for net test, default is 1000 bytes."},
{"pktnum", 'N', "PKTNUM", 0, "Packet numbers used for net test, default is 100."},
{"pkttype", 'S', "PKTTYPE", 0, "Choose packet type used for net test, default is TCP. Only speed test could be either TCP or UDP."},
#ifdef WEBSOCKET
{"restful", 'R', 0, 0, "Connect and interact with TDengine use restful."},
{"cloudDsn", 'E', "DSN", 0, "The DSN to use when connecting TDengine's cloud services."},
{"timeout", 't', "SECONDS", 0, "The timeout seconds for websocket to interact."},
#endif
{0}};
static error_t parse_opt(int key, char *arg, struct argp_state *state) {
......@@ -66,7 +68,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
switch (key) {
case 'h':
if (arg) {
#ifdef WEBSOCKET
args.cloud = false;
#endif
args.host = arg;
} else {
fprintf(stderr, "Invalid host\n");
......@@ -77,7 +81,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
break;
case 'P':
if (arg) {
#ifdef WEBSOCKET
args.cloud = false;
#endif
tsDnodeShellPort = atoi(arg);
args.port = atoi(arg);
} else {
......@@ -105,7 +111,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
wordfree(&full_path);
return -1;
}
#ifdef WEBSOCKET
args.cloud = false;
#endif
tstrncpy(configDir, full_path.we_wordv[0], TSDB_FILENAME_LEN);
wordfree(&full_path);
break;
......@@ -173,6 +181,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case OPT_ABORT:
arguments->abort = 1;
break;
#ifdef WEBSOCKET
case 'R':
arguments->restful = true;
arguments->cloud = false;
......@@ -192,6 +201,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
fprintf(stderr, "Invalid -t option\n");
}
break;
#endif
default:
return ARGP_ERR_UNKNOWN;
}
......@@ -245,6 +255,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
argp_parse(&argp, argc, argv, 0, 0, arguments);
#ifdef WEBSOCKET
if (args.dsn == NULL) {
if (args.cloud) {
args.dsn = getenv("TDENGINE_CLOUD_DSN");
......@@ -255,6 +266,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
} else {
args.cloud = true;
}
#endif
if (arguments->abort) {
#ifndef _ALPINE
......
......@@ -37,9 +37,11 @@ void *cancelHandler(void *arg) {
taosMsleep(10);
continue;
}
#ifdef WEBSOCKET
if (args.restful || args.cloud) {
stop_fetch = true;
}
#endif
#ifdef LINUX
int64_t rid = atomic_val_compare_exchange_64(&result, result, 0);
SSqlObj* pSql = taosAcquireRef(tscObjRef, rid);
......@@ -81,7 +83,6 @@ SShellArguments args = {.host = NULL,
.user = NULL,
.database = NULL,
.timezone = NULL,
.restful = false,
.is_raw_time = false,
.is_use_passwd = false,
.dump_config = false,
......@@ -93,9 +94,12 @@ SShellArguments args = {.host = NULL,
.pktNum = 100,
.pktType = "TCP",
.netTestRole = NULL,
#ifdef WEBSOCKET
.restful = false,
.cloud = true,
.dsn = NULL,
.timeout = 10,
#endif
};
/*
......@@ -135,6 +139,7 @@ int main(int argc, char* argv[]) {
exit(0);
}
#ifdef WEBSOCKET
if (args.restful) {
args.dsn = calloc(1, 1024);
......@@ -148,6 +153,7 @@ int main(int argc, char* argv[]) {
snprintf(args.dsn, 1024, "ws://%s:%d/rest/ws",args.host, args.port);
}
#endif
/* Initialize the shell */
shellInit(&args);
......
......@@ -62,12 +62,14 @@ void printHelp() {
printf("%s%s%s\n", indent, indent, "Packet length used for net test, default is 1000 bytes.");
printf("%s%s\n", indent, "-N");
printf("%s%s%s\n", indent, indent, "Packet numbers used for net test, default is 100.");
#ifdef WEBSOCKET
printf("%s%s\n", indent, "-R");
printf("%s%s%s\n", indent, indent, "Connect and interact with TDengine use restful.");
printf("%s%s\n", indent, "-E");
printf("%s%s%s\n", indent, indent, "The DSN to use when connecting TDengine's cloud services.");
printf("%s%s\n", indent, "-t");
printf("%s%s%s\n", indent, indent, "The timeout seconds for websocekt to interact.");
#endif
printf("%s%s\n", indent, "-S");
printf("%s%s%s\n", indent, indent, "Packet type used for net test, default is TCP.");
printf("%s%s\n", indent, "-V");
......@@ -82,7 +84,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
// for host
if (strcmp(argv[i], "-h") == 0) {
if (i < argc - 1) {
#ifdef WEBSOCKET
arguments->cloud = false;
#endif
arguments->host = argv[++i];
} else {
fprintf(stderr, "option -h requires an argument\n");
......@@ -114,7 +118,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
// for management port
else if (strcmp(argv[i], "-P") == 0) {
if (i < argc - 1) {
#ifdef WEBSOCKET
arguments->cloud = false;
#endif
arguments->port = atoi(argv[++i]);
} else {
fprintf(stderr, "option -P requires an argument\n");
......@@ -138,7 +144,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
}
} else if (strcmp(argv[i], "-c") == 0) {
if (i < argc - 1) {
#ifdef WEBSOCKET
arguments->cloud = false;
#endif
char *tmp = argv[++i];
if (strlen(tmp) >= TSDB_FILENAME_LEN) {
fprintf(stderr, "config file path: %s overflow max len %d\n", tmp, TSDB_FILENAME_LEN - 1);
......@@ -220,6 +228,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit(EXIT_FAILURE);
}
}
#ifdef WEBSOCKET
else if (strcmp(argv[i], "-R") == 0) {
arguments->cloud = false;
......@@ -243,6 +252,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit(EXIT_FAILURE);
}
}
#endif
else if (strcmp(argv[i], "-V") == 0) {
printVersion();
......@@ -258,6 +268,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit(EXIT_FAILURE);
}
}
#ifdef WEBSOCKET
if (args.dsn == NULL) {
if (args.cloud) {
args.dsn = getenv("TDENGINE_CLOUD_DSN");
......@@ -274,6 +285,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
} else {
args.cloud = true;
}
#endif
}
void shellPrintContinuePrompt() { printf("%s", CONTINUE_PROMPT); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册