Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
52cc0098
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
52cc0098
编写于
4月 23, 2022
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
udfd pipe name generating with dnode id through environment passing
上级
400436ff
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
24 addition
and
18 deletion
+24
-18
source/dnode/mgmt/implement/src/dmHandle.c
source/dnode/mgmt/implement/src/dmHandle.c
+3
-0
source/libs/function/inc/tudf.h
source/libs/function/inc/tudf.h
+2
-1
source/libs/function/inc/tudfInt.h
source/libs/function/inc/tudfInt.h
+1
-0
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+15
-6
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+2
-10
source/libs/function/test/runUdf.c
source/libs/function/test/runUdf.c
+1
-1
未找到文件。
source/dnode/mgmt/implement/src/dmHandle.c
浏览文件 @
52cc0098
...
...
@@ -310,6 +310,9 @@ static void dmWatchUdfd(void *args) {
}
static
int32_t
dmStartUdfd
(
SDnode
*
pDnode
)
{
char
dnodeId
[
8
]
=
{
0
};
snprintf
(
dnodeId
,
sizeof
(
dnodeId
),
"%d"
,
pDnode
->
data
.
dnodeId
);
uv_os_setenv
(
"DNODE_ID"
,
dnodeId
);
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
if
(
pData
->
startCalled
)
{
dInfo
(
"dnode-mgmt start udfd already called"
);
...
...
source/libs/function/inc/tudf.h
浏览文件 @
52cc0098
...
...
@@ -29,6 +29,7 @@ extern "C" {
#define UDF_LISTEN_PIPE_NAME_LEN 32
#define UDF_LISTEN_PIPE_NAME_PREFIX "udfd.sock."
#define UDF_DNODE_ID_ENV_NAME "DNODE_ID"
//======================================================================================
//begin API to taosd and qworker
...
...
@@ -45,7 +46,7 @@ typedef void *UdfcFuncHandle;
* create udfd proxy, called once in process that call setupUdf/callUdfxxx/teardownUdf
* @return error code
*/
int32_t
udfcOpen
(
int32_t
dnodeId
,
UdfcHandle
*
proxyHandle
);
int32_t
udfcOpen
(
UdfcHandle
*
proxyHandle
);
/**
* destroy udfd proxy
...
...
source/libs/function/inc/tudfInt.h
浏览文件 @
52cc0098
...
...
@@ -112,6 +112,7 @@ void freeUdfDataDataBlock(SUdfDataBlock *block);
int32_t
convertDataBlockToUdfDataBlock
(
SSDataBlock
*
block
,
SUdfDataBlock
*
udfBlock
);
int32_t
convertUdfColumnToDataBlock
(
SUdfColumn
*
udfCol
,
SSDataBlock
*
block
);
int32_t
getUdfdPipeName
(
char
*
pipeName
,
int32_t
size
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/function/src/tudf.c
浏览文件 @
52cc0098
...
...
@@ -124,7 +124,7 @@ enum {
int64_t
gUdfTaskSeqNum
=
0
;
typedef
struct
SUdfdProxy
{
int32_t
dnodeId
;
char
udfdPipeName
[
UDF_LISTEN_PIPE_NAME_LEN
]
;
uv_barrier_t
gUdfInitBarrier
;
uv_loop_t
gUdfdLoop
;
...
...
@@ -212,6 +212,17 @@ enum {
UDFC_STATUS_FINAL
,
// stopped
};
int32_t
getUdfdPipeName
(
char
*
pipeName
,
int32_t
size
)
{
char
dnodeId
[
8
]
=
{
0
};
size_t
dnodeIdSize
;
int32_t
err
=
uv_os_getenv
(
UDF_DNODE_ID_ENV_NAME
,
dnodeId
,
&
dnodeIdSize
);
if
(
err
!=
0
)
{
dnodeId
[
0
]
=
'1'
;
}
snprintf
(
pipeName
,
size
,
"%s%s"
,
UDF_LISTEN_PIPE_NAME_PREFIX
,
dnodeId
);
return
0
;
}
int32_t
encodeUdfSetupRequest
(
void
**
buf
,
const
SUdfSetupRequest
*
setup
)
{
int32_t
len
=
0
;
len
+=
taosEncodeBinary
(
buf
,
setup
->
udfName
,
TSDB_FUNC_NAME_LEN
);
...
...
@@ -874,9 +885,7 @@ int32_t startUvUdfTask(SClientUvTaskNode *uvTask) {
uv_connect_t
*
connReq
=
taosMemoryMalloc
(
sizeof
(
uv_connect_t
));
connReq
->
data
=
uvTask
;
char
listeningPipeName
[
32
]
=
{
0
};
sprintf
(
listeningPipeName
,
"%s%d"
,
UDF_LISTEN_PIPE_NAME_PREFIX
,
uvTask
->
udfc
->
dnodeId
);
uv_pipe_connect
(
connReq
,
pipe
,
listeningPipeName
,
onUdfClientConnect
);
uv_pipe_connect
(
connReq
,
pipe
,
uvTask
->
udfc
->
udfdPipeName
,
onUdfClientConnect
);
break
;
}
case
UV_TASK_REQ_RSP
:
{
...
...
@@ -972,9 +981,9 @@ void constructUdfService(void *argsThread) {
uv_loop_close
(
&
udfc
->
gUdfdLoop
);
}
int32_t
udfcOpen
(
int32_t
dnodeId
,
UdfcHandle
*
udfc
)
{
int32_t
udfcOpen
(
UdfcHandle
*
udfc
)
{
SUdfdProxy
*
proxy
=
taosMemoryCalloc
(
1
,
sizeof
(
SUdfdProxy
));
proxy
->
dnodeId
=
dnodeId
;
getUdfdPipeName
(
proxy
->
udfdPipeName
,
UDF_LISTEN_PIPE_NAME_LEN
)
;
proxy
->
gUdfcState
=
UDFC_STATE_STARTNG
;
uv_barrier_init
(
&
proxy
->
gUdfInitBarrier
,
2
);
uv_thread_create
(
&
proxy
->
gUdfLoopThread
,
constructUdfService
,
proxy
);
...
...
source/libs/function/src/udfd.c
浏览文件 @
52cc0098
...
...
@@ -531,15 +531,7 @@ static int32_t udfdUvInit() {
uv_pipe_open
(
&
global
.
ctrlPipe
,
0
);
uv_read_start
((
uv_stream_t
*
)
&
global
.
ctrlPipe
,
udfdCtrlAllocBufCb
,
udfdCtrlReadCb
);
char
dnodeId
[
8
]
=
{
0
};
size_t
dnodeIdSize
;
int32_t
err
=
uv_os_getenv
(
"DNODE_ID"
,
dnodeId
,
&
dnodeIdSize
);
if
(
err
!=
0
)
{
dnodeId
[
0
]
=
'1'
;
}
char
listenPipeName
[
32
]
=
{
0
};
snprintf
(
listenPipeName
,
sizeof
(
listenPipeName
),
"%s%s"
,
UDF_LISTEN_PIPE_NAME_PREFIX
,
dnodeId
);
strcpy
(
global
.
listenPipeName
,
listenPipeName
);
getUdfdPipeName
(
global
.
listenPipeName
,
UDF_LISTEN_PIPE_NAME_LEN
);
removeListeningPipe
();
...
...
@@ -550,7 +542,7 @@ static int32_t udfdUvInit() {
int
r
;
fnInfo
(
"bind to pipe %s"
,
global
.
listenPipeName
);
if
((
r
=
uv_pipe_bind
(
&
global
.
listeningPipe
,
listenPipeName
)))
{
if
((
r
=
uv_pipe_bind
(
&
global
.
listeningPipe
,
global
.
listenPipeName
)))
{
fnError
(
"Bind error %s"
,
uv_err_name
(
r
));
removeListeningPipe
();
return
-
1
;
...
...
source/libs/function/test/runUdf.c
浏览文件 @
52cc0098
...
...
@@ -9,7 +9,7 @@
int
main
(
int
argc
,
char
*
argv
[])
{
UdfcHandle
udfc
;
udfcOpen
(
1
,
&
udfc
);
udfcOpen
(
&
udfc
);
uv_sleep
(
1000
);
char
path
[
256
]
=
{
0
};
size_t
cwdSize
=
256
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录