add code for write response
This commit is contained in:
parent
ff41901d5e
commit
cc2dfbf5ef
|
@ -20,6 +20,11 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int len;
|
||||
void *rsp;
|
||||
} SRspRet;
|
||||
|
||||
int32_t vnodeInitWrite();
|
||||
int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg);
|
||||
int32_t vnodeDrop(int32_t vgId);
|
||||
|
|
|
@ -289,7 +289,7 @@ static void dnodeProcessRetrieveMsg(void *pVnode, SReadMsg *pMsg) {
|
|||
dnodeContinueExecuteQuery(pVnode, pQInfo, pMsg);
|
||||
} else { // no further execution invoked, release the ref to vnode
|
||||
dnodeProcessReadResult(pVnode, pMsg);
|
||||
dnodeReleaseVnode(pVnode);
|
||||
vnodeRelease(pVnode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef struct {
|
|||
} SWriteWorker;
|
||||
|
||||
typedef struct {
|
||||
SRspRet rspRet;
|
||||
void *pCont;
|
||||
int32_t contLen;
|
||||
SRpcMsg rpcMsg;
|
||||
|
@ -148,8 +149,8 @@ void dnodeSendRpcWriteRsp(void *pVnode, void *param, int32_t code) {
|
|||
|
||||
SRpcMsg rpcRsp = {
|
||||
.handle = pWrite->rpcMsg.handle,
|
||||
.pCont = NULL,
|
||||
.contLen = 0,
|
||||
.pCont = pWrite->rspRet.rsp,
|
||||
.contLen = pWrite->rspRet.len,
|
||||
.code = code,
|
||||
};
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
#include "vnodeInt.h"
|
||||
|
||||
static int32_t (*vnodeProcessWriteMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *, void*);
|
||||
static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pMsg, void *);
|
||||
static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pMsg, void *);
|
||||
static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pMsg, void *);
|
||||
static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pMsg, void *);
|
||||
static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pMsg, void *);
|
||||
static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pMsg, SRspRet *);
|
||||
static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pMsg, SRspRet *);
|
||||
static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pMsg, SRspRet *);
|
||||
static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pMsg, SRspRet *);
|
||||
static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pMsg, SRspRet *);
|
||||
|
||||
int32_t vnodeInitWrite() {
|
||||
vnodeProcessWriteMsgFp[TSDB_MSG_TYPE_SUBMIT] = vnodeProcessSubmitMsg;
|
||||
|
@ -49,6 +49,9 @@ int32_t vnodeProcessWrite(void *param, int qtype, SWalHead *pHead, void *item) {
|
|||
int32_t code = 0;
|
||||
SVnodeObj *pVnode = (SVnodeObj *)param;
|
||||
|
||||
if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL)
|
||||
return TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
|
||||
if (pVnode->status == VN_STATUS_DELETING || pVnode->status == VN_STATUS_CLOSING)
|
||||
return TSDB_CODE_NOT_ACTIVE_VNODE;
|
||||
|
||||
|
@ -86,7 +89,7 @@ int32_t vnodeProcessWrite(void *param, int qtype, SWalHead *pHead, void *item) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, void *item) {
|
||||
static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pRet) {
|
||||
int32_t code = 0;
|
||||
|
||||
// save insert result into item
|
||||
|
@ -94,10 +97,19 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, void *item)
|
|||
dTrace("pVnode:%p vgId:%d, submit msg is processed", pVnode, pVnode->vgId);
|
||||
code = tsdbInsertData(pVnode->tsdb, pCont);
|
||||
|
||||
pRet->len = sizeof(SShellSubmitRspMsg);
|
||||
pRet->rsp = rpcMallocCont(pRet->len);
|
||||
SShellSubmitRspMsg *pRsp = pRet->rsp;
|
||||
|
||||
pRsp->code = 0;
|
||||
pRsp->numOfRows = htonl(1);
|
||||
pRsp->affectedRows = htonl(1);
|
||||
pRsp->numOfFailedBlocks = 0;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, void *item) {
|
||||
static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pRet) {
|
||||
SMDCreateTableMsg *pTable = pCont;
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -153,7 +165,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, void *
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pCont, void *item) {
|
||||
static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pRet) {
|
||||
SMDDropTableMsg *pTable = pCont;
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -168,7 +180,7 @@ static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pCont, void *it
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, void *item) {
|
||||
static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pRet) {
|
||||
SMDCreateTableMsg *pTable = pCont;
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -223,7 +235,7 @@ static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, void *i
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, void *item) {
|
||||
static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pRet) {
|
||||
SMDDropSTableMsg *pTable = pCont;
|
||||
int32_t code = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue