TDengine/include/dnode/xnode/xnode.h
guichuan zhang 2c62466aa0
feat(taosx): support distributed taosx (#34126)
* feat: add xnode syntax

* refactor(xnode): reduce function complexity

* chore: add lost xnode.h file

* feat(xnode): create xnode task

* chore: fix double free error

* add xnoded

* start xnoded as subprocess

* complete xnode task feature

* complete show xnode jobs feature

* complete with option feature

* complete alter xnode job feature

* complete alter xnode task feature

* complete user pass feature

* clean code

* modify status type as char

* fix leader ep null

* fix start task req null

* fix pass id for status

* support timeout msg

* drop xnode task relative jobs

* clean code

* wip

* chore: add test cases for xnode

* chore: fix 3.0 merge changes

* fix drain core dump and create task core dump

* add password check

* retrieve xnode status from xnoded

* pass integer as double to cjson

* add some debug log

* add some job log

* fix start task lock

* do not handle http response

* fix coredump drop xnode task by name

* support start/stop/drop task by name

* remove mock xnoded

* support unix socket

* kill pre-xnoded before start

* support dnode close xnoded

* test(xnode): add unit test cases for xnode

* rebalance support where clause

* fix some test issue

* unformat http post content json string

* add xnode zh doc

* modify drain description

* remove job create/stop/drop operation

* support rebalance all without where condition

* support alter task by name

* add NULL param for mndCheckOperPrivilege

* add xnode txnode module for libmnode.a

* code clean

* change parser len to 4096

* clean code

* chore: try to fix gtest/gtest.h not found

* chore: fix markdown files

* chore: fix markdown in zh

* chore: fix enum issue and add ci

* chore: fix test case problem

* chore: fix pKeyVal overflow

* chore: rename to 排空节点

* chore: external cmake remove parallel

* chore: add DEP_ext_gtest for xnode test

* chore: fix gtest errors

* chore: remove gtest pthread lib

* chore: fix data type not match

* chore: fix some lint errors

* chore: fix void unlink

* chore: fix return with null pointer check

* chore: fix pointer double free and xnodeMemoryTest strncpy null

* chore: fix xnode encode action invalid datelen

* chore: remove TD_LINUX condition

* chore: use PRIu64 denote long long

* chore: fix task parser NULL and allow no with clause

* fix(xnode): fix windows build error

* chore: fix windows curl error

* chore: fix test case ins_tables relative error

* chore: fix memory leak

* docs: update taosx docs

* chore: update taosx docs

* chore: add role priviledge table

* chore: fix error code doc

* chore: fix test_xnode.py

* chore: fix doc typo

* fix: ci error while run test_user_privilege_sysinfo.py

---------

Co-authored-by: Linhe Huo <linhehuo@gmail.com>
Co-authored-by: huohong <sallyhuo@taosdata.com>
Co-authored-by: Simon Guan <guanshengliang@qq.com>
2026-01-01 14:51:03 +08:00

100 lines
3 KiB
C

/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_XNODE_H_
#define _TD_XNODE_H_
/** cflags: -L../../common/ */
#include "common/tmsgcb.h"
#include "tglobal.h"
#ifdef __cplusplus
extern "C" {
#endif
// clang-format off
#define xndFatal(...) do { if (xndDebugFlag & DEBUG_FATAL) { taosPrintLog("XND FATAL ", DEBUG_FATAL, xndDebugFlag, __VA_ARGS__);}} while (0)
#define xndError(...) do { if (xndDebugFlag & DEBUG_ERROR) { taosPrintLog("XND ERROR ", DEBUG_ERROR, xndDebugFlag, __VA_ARGS__);}} while (0)
#define xndWarn(...) do { if (xndDebugFlag & DEBUG_WARN) { taosPrintLog("XND WARN ", DEBUG_WARN, xndDebugFlag, __VA_ARGS__);}} while (0)
#define xndInfo(...) do { if (xndDebugFlag & DEBUG_INFO) { taosPrintLog("XND INFO ", DEBUG_INFO, xndDebugFlag, __VA_ARGS__);}} while (0)
#define xndDebug(...) do { if (xndDebugFlag & DEBUG_DEBUG) { taosPrintLog("XND DEBUG ", DEBUG_DEBUG, xndDebugFlag, __VA_ARGS__);}} while (0)
#define xndTrace(...) do { if (xndDebugFlag & DEBUG_TRACE) { taosPrintLog("XND TRACE ", DEBUG_TRACE, xndDebugFlag, __VA_ARGS__);}} while (0)
// clang-format on
/* ------------------------ TYPES EXPOSED ------------------------ */
#ifndef XNODE_USER_PASS_LEN
#define XNODE_USER_PASS_LEN (TSDB_USER_LEN + TSDB_USER_PASSWORD_LONGLEN + 16)
#endif
#define XNODED_MGMT_LISTEN_PIPE_NAME_LEN 32
#ifdef _WIN32
#define XNODED_MGMT_LISTEN_PIPE_NAME_PREFIX "\\\\?\\pipe\\taosxnode.sock"
#else
#define XNODED_MGMT_LISTEN_PIPE_NAME_PREFIX "." CUS_PROMPT "xnoded.sock"
#endif
typedef struct SXnode SXnode;
typedef struct {
SMsgCb msgCb;
int32_t dnodeId;
int64_t clusterId;
int32_t proto;
int32_t upLen;
char userPass[XNODE_USER_PASS_LEN];
SEp ep;
char machineId[TSDB_MACHINE_ID_LEN + 1];
} SXnodeOpt;
struct SXnode {
SMsgCb msgCb;
int8_t protocol;
int32_t dnodeId;
int64_t clusterId;
int32_t proto;
int32_t upLen;
char userPass[XNODE_USER_PASS_LEN];
SEp ep;
};
/* ------------------------ SXnode ------------------------ */
/**
* @brief Start one Xnode in Dnode.
*
* @param pOption Option of the qnode.
* @param pXnode The qnode object.
* @return int32_t The error code.
*/
int32_t xndOpen(const SXnodeOpt *pOption, SXnode **pXnode);
/**
* @brief Stop Xnode in Dnode.
*
* @param pXnode The qnode object to close.
*/
void xndClose(SXnode *pXnode);
#ifdef __cplusplus
}
#endif
int32_t mndOpenXnd(const SXnodeOpt *pOption);
void mndCloseXnd();
void getXnodedPipeName(char *pipeName, int32_t size);
#endif /*_TD_XNODE_H_*/