This commit is contained in:
Hongze Cheng 2021-09-27 10:49:36 +08:00
parent dfa65623f4
commit 6c3b627e54
13 changed files with 296 additions and 5 deletions

55
include/common/taosMsg.h Normal file
View File

@ -0,0 +1,55 @@
/*
* 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_TAOS_MSG_H_
#define _TD_TAOS_MSG_H_
typedef struct {
/* data */
} SSubmitReq;
typedef struct {
/* data */
} SSubmitRsp;
typedef struct {
/* data */
} SSubmitReqReader;
typedef struct {
/* data */
} SCreateTableReq;
typedef struct {
/* data */
} SCreateTableRsp;
typedef struct {
/* data */
} SDropTableReq;
typedef struct {
/* data */
} SDropTableRsp;
typedef struct {
/* data */
} SAlterTableReq;
typedef struct {
/* data */
} SAlterTableRsp;
#endif /*_TD_TAOS_MSG_H_*/

View File

@ -20,6 +20,10 @@
extern "C" { extern "C" {
#endif #endif
typedef struct SMeta SMeta;
int metaCommit(SMeta *pMeta);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -20,6 +20,11 @@
extern "C" { extern "C" {
#endif #endif
typedef struct STQ STQ;
int tqPushMsg(void *);
int tqCommit(STQ *pTQ);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -17,6 +17,7 @@
#define _TD_TSDB_H_ #define _TD_TSDB_H_
#include "os.h" #include "os.h"
#include "taosMsg.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -47,7 +48,7 @@ int tsdbCloseRepo(STsdb *pTsdb);
int tsdbForceCloseRepo(STsdb *pTsdb); int tsdbForceCloseRepo(STsdb *pTsdb);
// Data commit // Data commit
int tsdbInsert(STsdb *pTsdb, SSubmitMsg *pMsg); int tsdbInsert(STsdb *pTsdb, SSubmitReq *pMsg);
int tsdbCommit(STsdb *pTsdb); int tsdbCommit(STsdb *pTsdb);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -9,9 +9,11 @@ target_include_directories(
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode" PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode"
private "${CMAKE_CURRENT_SOURCE_DIR}/inc" private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
) )
target_include_directories( target_link_libraries(
vnode vnode
PRIVATE meta PUBLIC meta
PRIVATE tq PUBLIC tq
PRIVATE tsdb PUBLIC tsdb
PRIVATE os
PRIVATE common
) )

View File

@ -0,0 +1,29 @@
/*
* 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_VNODE_COMMIT_H_
#define _TD_VNODE_COMMIT_H_
#ifdef __cplusplus
extern "C" {
#endif
int vnodeAsyncCommit(SVnode *pVnode);
#ifdef __cplusplus
}
#endif
#endif /*_TD_VNODE_COMMIT_H_*/

View File

@ -16,10 +16,21 @@
#ifndef _TD_VNODE_INT_H_ #ifndef _TD_VNODE_INT_H_
#define _TD_VNODE_INT_H_ #define _TD_VNODE_INT_H_
#include "tq.h"
#include "tsdb.h"
#include "meta.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct SVnode {
SMeta *pMeta;
STsdb *pTsdb;
STQ * pTQ;
void * allocator; // TODO
} SVnode;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -0,0 +1,27 @@
/*
* 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_VNODE_MEM_ALLOCATOR_H_
#define _TD_VNODE_MEM_ALLOCATOR_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /*_TD_VNODE_MEM_ALLOCATOR_H_*/

View File

@ -0,0 +1,21 @@
/*
* 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_VNODE_WRITE_H_
#define _TD_VNODE_WRITE_H_
int vnodeProcessSubmitReq(SVnode *pVnode, SSubmitReq *pReq, SSubmitRsp *pRsp);
#endif /*_TD_VNODE_WRITE_H_*/

View File

@ -0,0 +1,53 @@
/*
* 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 "vnodeInt.h"
static int vnodeStartCommit(SVnode *pVnode);
static int vnodeEndCommit(SVnode *pVnode);
int vnodeAsyncCommit(SVnode *pVnode) {
if (vnodeStartCommit(pVnode) < 0) {
// TODO
}
if (tqCommit(pVnode->pTQ) < 0) {
// TODO
}
if (metaCommit(pVnode->pMeta) < 0) {
// TODO
}
if (tsdbCommit(pVnode->pTsdb) < 0) {
// TODO
}
if (vnodeEndCommit(pVnode) < 0) {
// TODO
}
return 0;
}
static int vnodeStartCommit(SVnode *pVnode) {
// TODO
return 0;
}
static int vnodeEndCommit(SVnode *pVnode) {
// TODO
return 0;
}

View File

@ -0,0 +1,14 @@
/*
* 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/>.
*/

View File

@ -0,0 +1,68 @@
/*
* 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 "vnodeInt.h"
int vnodeProcessSubmitReq(SVnode *pVnode, SSubmitReq *pReq, SSubmitRsp *pRsp) {
// TODO: Check inputs
#if 1
void *pMem = NULL;
if ((pMem = aMalloc(pVnode->allocator, REQ_SIZE(pReq))) == NULL) {
// No more memory to allocate, schedule an async commit
// and continue
vnodeAsyncCommit(pVnode);
// Reset allocator and allocat more
vnodeResetAllocator(pVnode);
pMem = aMalloc(pVnode->allocator, REQ_SIZE(pReq));
if (pMem == NULL) {
// TODO: handle the error
}
}
// TODO: if SSubmitReq is compressed or encoded, we need to decode the request
memcpy(pMem, pReq, REQ_SIZE(pReq));
if (tqPushMsg((SSubmitReq *)pReq) < 0) {
// TODO: handle error
}
SSubmitReqReader reader;
taosInitSubmitReqReader(&reader, (SSubmitReq *)pMem);
if (tsdbInsertData((SSubmitReq *)pMem) < 0) {
// TODO: handler error
}
#endif
return 0;
}
int vnodeProcessCreateTableReq(SVnode *pVnode, SCreateTableReq *pReq, SCreateTableRsp *pRsp) {
// TODO
return 0;
}
int vnodeProcessDropTableReq(SVnode *pVnode, SDropTableReq *pReq, SDropTableRsp *pRsp) {
// TODO
return 0;
}
int vnodeProcessAlterTableReq(SVnode *pVnode, SDropTableReq *pReq, SDropTableRsp *pRsp) {
// TODO
return 0;
}

View File

@ -8,4 +8,5 @@ target_include_directories(
target_include_directories( target_include_directories(
tsdb tsdb
PRIVATE os PRIVATE os
PRIVATE common
) )