TDengine/source/dnode/bnode/src/bnode.c

59 lines
1.6 KiB
C
Raw Normal View History

feat(mqtt): mqtt subscription (#30127) * feat(mqtt): Initial commit for mqtt * chore(xnode/mnd): xnode message handlers for mnode * chore(mnd/xnode): mnode part for xnode * chore(xnode/translater): fix show commands * fix(ast/creater): fix xnode create option * fix(xnode/ci): fix ci & doc's error codes * chore(xnode/sql): make create/drop/show work properly * fix(xnode/sql): commit new files * fix(xnode/sql): commit cmake files * fix: fix testing cases * fix(xnode/tsc): fix tokens * fix(ast/anode): fix anode update decl. * fix(xnode/error): fix xnode error codes * fix: xnode make/destroy * chore: xnode with option & dnode id * chore: use taosmqtt for xnode * chore: new error code for xnode launching * chore(xnode): new error code * chore: header for _xnode_mgmt_mqtt * chore: source for _xnode_mgmt_mqtt * chore: remove test directory from cmake * chore: remove taosmqtt for ci to compile * chore: remove taosudf header from xnode * chore: new window macro * chore: remove xnode mgmt mqtt for windows compilation * Revert "chore: remove xnode mgmt mqtt for windows compilation" This reverts commit 197e1640c79e40343e683f42236b3f0824392944. * chore: cleanup code * chore: xnode mgmt comment windows part out * chore: mgmt/mqtt, move uv head toppest * xnode/mnode: create xnode once per dnode * fix(xnode/systable/test): fix column count * xnode/sdb: renumber sdb type for xnode to make start/stop order correct * xnode/mqtt: new param mqttPort * fix SXnode's struct type * transfer dnode id to mqtt subscription * tmqtt: remove uv_a linking * tmqtt/tools: sources for tools * tools: fix windows compilation * tools/producer: fix windows sleep param * tools/producer: fix uninited var rc * make tools only for linux * test/mnodes: wail 1 or 2 seconds for offline to be leader * update topic producer tool for geometry data type testing * format tool sql statements * show xnodes' ep * make shell auto complete xnodes * use usleep instead of sleep * mqtt/proto: first version mqtt protocol * remove assert styles * build with linux only * fix libuv for taosmqtt building * fix log printing * mem: use ttq_ prefix instead of tmqtt * xnode/parser/proto: protocol option for xnode * xnode/translater/option: translate xnode option proto * xnode/translator: translate proto param * xnode/tmsg: encode/decode proto param * xnode/mnode: proto parma for mndXnode * xnode/proto: protocol param for xnode * xnode/mqtt: save/load proto from xnode json * rename tmqtt proto header * rename head directories * rename header name styles * restyle func names * update * update * use camel db * use camel for cxt * update count of information_schema * fix exceptional cases * fix w.r.t reviews * fixes w.r.t reviews * use ttq_free * append xnode msgs * update information schema count * support tmq meta data sub * success typo fix Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix error line var w.r.t. suggestions from copilot * denote mqtt node with bnode instead of xnode * smoke testing for mqtt * soak testing * new package for test framework: paho 2.1.0 * import mqtt into util * fix soak testing * test/soak: user 5 topics per client * test/soak: cover qos * update docker image references to tdengine-ci:0.1 in CI scripts and common.py * refactor: rename bnode msg to backup node * refactor: rename xnode to bnode 1 * refactor: rename xnode to bnode 2 * refactor: rename xnode to bnode 3 * refactor: rename xnode to bnode 4 * refactor: rename xnode to bnode 4 * refactor: rename xnode to bnode 5 * refactor: rename xnode to bnode 6 * refactor: rename some files 1 * refactor: rename some files 2 * refactor: rename some files 3 * refactor: rename some files 4 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: chenhaoran <haoran920c@163.com> Co-authored-by: Simon Guan <guanshengliang@qq.com>
2025-06-25 06:58:51 +00:00
/*
* 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/>.
*/
#include "libs/tmqtt/tmqtt.h"
#include "bndInt.h"
int32_t bndOpen(const SBnodeOpt *pOption, SBnode **pBnode) {
int32_t code = 0;
*pBnode = taosMemoryCalloc(1, sizeof(SBnode));
if (NULL == *pBnode) {
bndError("calloc SBnode failed");
code = terrno;
TAOS_RETURN(code);
}
(*pBnode)->msgCb = pOption->msgCb;
(*pBnode)->dnodeId = pOption->dnodeId;
(*pBnode)->protocol = (int8_t)pOption->proto;
if (TSDB_BNODE_OPT_PROTO_MQTT == (*pBnode)->protocol) {
if ((code = mqttMgmtStartMqttd((*pBnode)->dnodeId)) != 0) {
bndError("failed to start taosudf since %s", tstrerror(code));
taosMemoryFree(*pBnode);
*pBnode = NULL;
feat(mqtt): mqtt subscription (#30127) * feat(mqtt): Initial commit for mqtt * chore(xnode/mnd): xnode message handlers for mnode * chore(mnd/xnode): mnode part for xnode * chore(xnode/translater): fix show commands * fix(ast/creater): fix xnode create option * fix(xnode/ci): fix ci & doc's error codes * chore(xnode/sql): make create/drop/show work properly * fix(xnode/sql): commit new files * fix(xnode/sql): commit cmake files * fix: fix testing cases * fix(xnode/tsc): fix tokens * fix(ast/anode): fix anode update decl. * fix(xnode/error): fix xnode error codes * fix: xnode make/destroy * chore: xnode with option & dnode id * chore: use taosmqtt for xnode * chore: new error code for xnode launching * chore(xnode): new error code * chore: header for _xnode_mgmt_mqtt * chore: source for _xnode_mgmt_mqtt * chore: remove test directory from cmake * chore: remove taosmqtt for ci to compile * chore: remove taosudf header from xnode * chore: new window macro * chore: remove xnode mgmt mqtt for windows compilation * Revert "chore: remove xnode mgmt mqtt for windows compilation" This reverts commit 197e1640c79e40343e683f42236b3f0824392944. * chore: cleanup code * chore: xnode mgmt comment windows part out * chore: mgmt/mqtt, move uv head toppest * xnode/mnode: create xnode once per dnode * fix(xnode/systable/test): fix column count * xnode/sdb: renumber sdb type for xnode to make start/stop order correct * xnode/mqtt: new param mqttPort * fix SXnode's struct type * transfer dnode id to mqtt subscription * tmqtt: remove uv_a linking * tmqtt/tools: sources for tools * tools: fix windows compilation * tools/producer: fix windows sleep param * tools/producer: fix uninited var rc * make tools only for linux * test/mnodes: wail 1 or 2 seconds for offline to be leader * update topic producer tool for geometry data type testing * format tool sql statements * show xnodes' ep * make shell auto complete xnodes * use usleep instead of sleep * mqtt/proto: first version mqtt protocol * remove assert styles * build with linux only * fix libuv for taosmqtt building * fix log printing * mem: use ttq_ prefix instead of tmqtt * xnode/parser/proto: protocol option for xnode * xnode/translater/option: translate xnode option proto * xnode/translator: translate proto param * xnode/tmsg: encode/decode proto param * xnode/mnode: proto parma for mndXnode * xnode/proto: protocol param for xnode * xnode/mqtt: save/load proto from xnode json * rename tmqtt proto header * rename head directories * rename header name styles * restyle func names * update * update * use camel db * use camel for cxt * update count of information_schema * fix exceptional cases * fix w.r.t reviews * fixes w.r.t reviews * use ttq_free * append xnode msgs * update information schema count * support tmq meta data sub * success typo fix Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix error line var w.r.t. suggestions from copilot * denote mqtt node with bnode instead of xnode * smoke testing for mqtt * soak testing * new package for test framework: paho 2.1.0 * import mqtt into util * fix soak testing * test/soak: user 5 topics per client * test/soak: cover qos * update docker image references to tdengine-ci:0.1 in CI scripts and common.py * refactor: rename bnode msg to backup node * refactor: rename xnode to bnode 1 * refactor: rename xnode to bnode 2 * refactor: rename xnode to bnode 3 * refactor: rename xnode to bnode 4 * refactor: rename xnode to bnode 4 * refactor: rename xnode to bnode 5 * refactor: rename xnode to bnode 6 * refactor: rename some files 1 * refactor: rename some files 2 * refactor: rename some files 3 * refactor: rename some files 4 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: chenhaoran <haoran920c@163.com> Co-authored-by: Simon Guan <guanshengliang@qq.com>
2025-06-25 06:58:51 +00:00
TAOS_RETURN(code);
}
} else {
bndError("Unknown bnode proto: %hhd.", (*pBnode)->protocol);
taosMemoryFree(*pBnode);
*pBnode = NULL;
feat(mqtt): mqtt subscription (#30127) * feat(mqtt): Initial commit for mqtt * chore(xnode/mnd): xnode message handlers for mnode * chore(mnd/xnode): mnode part for xnode * chore(xnode/translater): fix show commands * fix(ast/creater): fix xnode create option * fix(xnode/ci): fix ci & doc's error codes * chore(xnode/sql): make create/drop/show work properly * fix(xnode/sql): commit new files * fix(xnode/sql): commit cmake files * fix: fix testing cases * fix(xnode/tsc): fix tokens * fix(ast/anode): fix anode update decl. * fix(xnode/error): fix xnode error codes * fix: xnode make/destroy * chore: xnode with option & dnode id * chore: use taosmqtt for xnode * chore: new error code for xnode launching * chore(xnode): new error code * chore: header for _xnode_mgmt_mqtt * chore: source for _xnode_mgmt_mqtt * chore: remove test directory from cmake * chore: remove taosmqtt for ci to compile * chore: remove taosudf header from xnode * chore: new window macro * chore: remove xnode mgmt mqtt for windows compilation * Revert "chore: remove xnode mgmt mqtt for windows compilation" This reverts commit 197e1640c79e40343e683f42236b3f0824392944. * chore: cleanup code * chore: xnode mgmt comment windows part out * chore: mgmt/mqtt, move uv head toppest * xnode/mnode: create xnode once per dnode * fix(xnode/systable/test): fix column count * xnode/sdb: renumber sdb type for xnode to make start/stop order correct * xnode/mqtt: new param mqttPort * fix SXnode's struct type * transfer dnode id to mqtt subscription * tmqtt: remove uv_a linking * tmqtt/tools: sources for tools * tools: fix windows compilation * tools/producer: fix windows sleep param * tools/producer: fix uninited var rc * make tools only for linux * test/mnodes: wail 1 or 2 seconds for offline to be leader * update topic producer tool for geometry data type testing * format tool sql statements * show xnodes' ep * make shell auto complete xnodes * use usleep instead of sleep * mqtt/proto: first version mqtt protocol * remove assert styles * build with linux only * fix libuv for taosmqtt building * fix log printing * mem: use ttq_ prefix instead of tmqtt * xnode/parser/proto: protocol option for xnode * xnode/translater/option: translate xnode option proto * xnode/translator: translate proto param * xnode/tmsg: encode/decode proto param * xnode/mnode: proto parma for mndXnode * xnode/proto: protocol param for xnode * xnode/mqtt: save/load proto from xnode json * rename tmqtt proto header * rename head directories * rename header name styles * restyle func names * update * update * use camel db * use camel for cxt * update count of information_schema * fix exceptional cases * fix w.r.t reviews * fixes w.r.t reviews * use ttq_free * append xnode msgs * update information schema count * support tmq meta data sub * success typo fix Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix error line var w.r.t. suggestions from copilot * denote mqtt node with bnode instead of xnode * smoke testing for mqtt * soak testing * new package for test framework: paho 2.1.0 * import mqtt into util * fix soak testing * test/soak: user 5 topics per client * test/soak: cover qos * update docker image references to tdengine-ci:0.1 in CI scripts and common.py * refactor: rename bnode msg to backup node * refactor: rename xnode to bnode 1 * refactor: rename xnode to bnode 2 * refactor: rename xnode to bnode 3 * refactor: rename xnode to bnode 4 * refactor: rename xnode to bnode 4 * refactor: rename xnode to bnode 5 * refactor: rename xnode to bnode 6 * refactor: rename some files 1 * refactor: rename some files 2 * refactor: rename some files 3 * refactor: rename some files 4 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: chenhaoran <haoran920c@163.com> Co-authored-by: Simon Guan <guanshengliang@qq.com>
2025-06-25 06:58:51 +00:00
TAOS_RETURN(code);
}
bndInfo("Bnode opened.");
return TSDB_CODE_SUCCESS;
}
void bndClose(SBnode *pBnode) {
mqttMgmtStopMqttd();
taosMemoryFree(pBnode);
bndInfo("Bnode closed.");
}