Merge branch 'develop' of https://github.com/taosdata/TDengine into develop
This commit is contained in:
commit
61254bf30b
|
@ -362,6 +362,26 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
time_t tTime = time(NULL);
|
||||
struct tm tm = *localtime(&tTime);
|
||||
printf("###################################################################\n");
|
||||
printf("# Server IP: %s:%hu\n", ip_addr == NULL ? "localhost" : ip_addr, port);
|
||||
printf("# User: %s\n", user);
|
||||
printf("# Password: %s\n", pass);
|
||||
printf("# Use metric: %s\n", use_metric ? "true" : "false");
|
||||
printf("# Datatype of Columns: %s\n", dataString);
|
||||
printf("# Binary Length(If applicable): %d\n",
|
||||
(strcasestr(dataString, "BINARY") != NULL) ? len_of_binary : -1);
|
||||
printf("# Number of Columns per record: %d\n", ncols_per_record);
|
||||
printf("# Number of Connections: %d\n", nconnections);
|
||||
printf("# Number of Tables: %d\n", ntables);
|
||||
printf("# Number of Data per Table: %d\n", nrecords_per_table);
|
||||
printf("# Records/Request: %d\n", nrecords_per_request);
|
||||
printf("# Database name: %s\n", db_name);
|
||||
printf("# Table prefix: %s\n", tb_prefix);
|
||||
printf("# Test time: %d-%02d-%02d %02d:%02d:%02d\n", tm.tm_year + 1900, tm.tm_mon + 1,
|
||||
tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
printf("###################################################################\n\n");
|
||||
printf("Press enter key to continue");
|
||||
getchar();
|
||||
|
||||
fprintf(fp, "###################################################################\n");
|
||||
fprintf(fp, "# Server IP: %s:%hu\n", ip_addr == NULL ? "localhost" : ip_addr, port);
|
||||
|
@ -858,15 +878,16 @@ void generateData(char *res, char **data_type, int num_of_cols, int64_t timestam
|
|||
pstr += sprintf(pstr, ")");
|
||||
}
|
||||
|
||||
static const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567890";
|
||||
void rand_string(char *str, int size) {
|
||||
memset(str, 0, size);
|
||||
const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567890";
|
||||
char *sptr = str;
|
||||
if (size) {
|
||||
str[0] = 0;
|
||||
if (size > 0) {
|
||||
--size;
|
||||
for (size_t n = 0; n < size; n++) {
|
||||
int n;
|
||||
for (n = 0; n < size; n++) {
|
||||
int key = rand() % (int)(sizeof charset - 1);
|
||||
sptr += sprintf(sptr, "%c", charset[key]);
|
||||
str[n] = charset[key];
|
||||
}
|
||||
str[n] = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -533,7 +533,7 @@ int taosDumpOut(SDumpArguments *arguments) {
|
|||
}
|
||||
}
|
||||
|
||||
taos_free_result(result);
|
||||
// taos_free_result(result);
|
||||
|
||||
if (count == 0) {
|
||||
fprintf(stderr, "No databases valid to dump\n");
|
||||
|
@ -722,6 +722,57 @@ void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, int numOfCols
|
|||
count_temp = counter;
|
||||
|
||||
for (; counter < numOfCols; counter++) {
|
||||
TAOS_ROW row = NULL;
|
||||
|
||||
sprintf(command, "select %s from %s limit 1", tableDes->cols[counter].field, tableDes->name);
|
||||
if (taos_query(taos, command) != 0) {
|
||||
fprintf(stderr, "failed to run command %s\n", command);
|
||||
return;
|
||||
}
|
||||
|
||||
result = taos_use_result(taos);
|
||||
if (result == NULL) {
|
||||
fprintf(stderr, "failed to use result\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TAOS_FIELD *fields = taos_fetch_fields(result);
|
||||
|
||||
row = taos_fetch_row(result);
|
||||
switch (fields[0].type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
sprintf(tableDes->cols[counter].note, "%d", ((((int)(*((char *)row[0]))) == 1) ? 1 : 0));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
sprintf(tableDes->cols[counter].note, "%d", (int)(*((char *)row[0])));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
sprintf(tableDes->cols[counter].note, "%d", (int)(*((short *)row[0])));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
sprintf(tableDes->cols[counter].note, "%d", *((int *)row[0]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
sprintf(tableDes->cols[counter].note, "%" PRId64 "", *((int64_t *)row[0]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
sprintf(tableDes->cols[counter].note, "%f", GET_FLOAT_VAL(row[0]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
sprintf(tableDes->cols[counter].note, "%f", GET_DOUBLE_VAL(row[0]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
sprintf(tableDes->cols[counter].note, "%" PRId64 "", *(int64_t *)row[0]);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
default:
|
||||
strncpy(tableDes->cols[counter].note, (char *)row[0], fields[0].bytes);
|
||||
break;
|
||||
}
|
||||
|
||||
taos_free_result(result);
|
||||
|
||||
if (counter != count_temp) {
|
||||
if (strcasecmp(tableDes->cols[counter].type, "binary") == 0 ||
|
||||
strcasecmp(tableDes->cols[counter].type, "nchar") == 0) {
|
||||
|
|
|
@ -468,7 +468,7 @@ static void taosFreeFdObj(SFdObj *pFdObj) {
|
|||
|
||||
pFdObj->signature = NULL;
|
||||
epoll_ctl(pThreadObj->pollFd, EPOLL_CTL_DEL, pFdObj->fd, NULL);
|
||||
taosCloseTcpSocket(pFdObj->fd);
|
||||
taosCloseSocket(pFdObj->fd);
|
||||
|
||||
pThreadObj->numOfFds--;
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ int taosOpenUdpSocket(uint32_t localIp, uint16_t localPort);
|
|||
int taosOpenTcpClientSocket(uint32_t ip, uint16_t port, uint32_t localIp);
|
||||
int taosOpenTcpServerSocket(uint32_t ip, uint16_t port);
|
||||
int taosKeepTcpAlive(int sockFd);
|
||||
void taosCloseTcpSocket(int sockFd);
|
||||
|
||||
int taosGetFqdn(char *);
|
||||
uint32_t taosGetIpFromFqdn(const char *);
|
||||
|
|
|
@ -305,20 +305,11 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
|
|||
sockFd = -1;
|
||||
}
|
||||
|
||||
taosKeepTcpAlive(sockFd);
|
||||
|
||||
return sockFd;
|
||||
}
|
||||
|
||||
void taosCloseTcpSocket(int sockFd) {
|
||||
struct linger linger;
|
||||
linger.l_onoff = 1;
|
||||
linger.l_linger = 0;
|
||||
if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof(linger)) < 0) {
|
||||
uError("setsockopt SO_LINGER failed: %d (%s)", errno, strerror(errno));
|
||||
}
|
||||
|
||||
taosCloseSocket(sockFd);
|
||||
}
|
||||
|
||||
int taosKeepTcpAlive(int sockFd) {
|
||||
int alive = 1;
|
||||
if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_KEEPALIVE, (void *)&alive, sizeof(alive)) < 0) {
|
||||
|
@ -355,6 +346,15 @@ int taosKeepTcpAlive(int sockFd) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
struct linger linger = {0};
|
||||
linger.l_onoff = 1;
|
||||
//linger.l_linger = 0;
|
||||
if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof(linger)) < 0) {
|
||||
uError("setsockopt SO_LINGER failed: %d (%s)", errno, strerror(errno));
|
||||
close(sockFd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue