Merge pull request #10223 from taosdata/feature/privilege
refact user msg decoder
This commit is contained in:
commit
2c0f1e7793
|
@ -349,15 +349,15 @@ typedef struct {
|
||||||
int64_t maxStorage; // In unit of GB
|
int64_t maxStorage; // In unit of GB
|
||||||
} SCreateAcctReq, SAlterAcctReq;
|
} SCreateAcctReq, SAlterAcctReq;
|
||||||
|
|
||||||
int32_t tSerializeSCreateAcctReq(void** buf, SCreateAcctReq* pReq);
|
int32_t tSerializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pReq);
|
||||||
void* tDeserializeSCreateAcctReq(void* buf, SCreateAcctReq* pReq);
|
int32_t tDeserializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
} SDropUserReq, SDropAcctReq;
|
} SDropUserReq, SDropAcctReq;
|
||||||
|
|
||||||
int32_t tSerializeSDropUserReq(void** buf, SDropUserReq* pReq);
|
int32_t tSerializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
|
||||||
void* tDeserializeSDropUserReq(void* buf, SDropUserReq* pReq);
|
int32_t tDeserializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t createType;
|
int8_t createType;
|
||||||
|
@ -366,8 +366,8 @@ typedef struct {
|
||||||
char pass[TSDB_PASSWORD_LEN];
|
char pass[TSDB_PASSWORD_LEN];
|
||||||
} SCreateUserReq;
|
} SCreateUserReq;
|
||||||
|
|
||||||
int32_t tSerializeSCreateUserReq(void** buf, SCreateUserReq* pReq);
|
int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
|
||||||
void* tDeserializeSCreateUserReq(void* buf, SCreateUserReq* pReq);
|
int32_t tDeserializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t alterType;
|
int8_t alterType;
|
||||||
|
@ -377,15 +377,15 @@ typedef struct {
|
||||||
char dbname[TSDB_DB_FNAME_LEN];
|
char dbname[TSDB_DB_FNAME_LEN];
|
||||||
} SAlterUserReq;
|
} SAlterUserReq;
|
||||||
|
|
||||||
int32_t tSerializeSAlterUserReq(void** buf, SAlterUserReq* pReq);
|
int32_t tSerializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
|
||||||
void* tDeserializeSAlterUserReq(void* buf, SAlterUserReq* pReq);
|
int32_t tDeserializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
} SGetUserAuthReq;
|
} SGetUserAuthReq;
|
||||||
|
|
||||||
int32_t tSerializeSGetUserAuthReq(void** buf, SGetUserAuthReq* pReq);
|
int32_t tSerializeSGetUserAuthReq(void* buf, int32_t bufLen, SGetUserAuthReq* pReq);
|
||||||
void* tDeserializeSGetUserAuthReq(void* buf, SGetUserAuthReq* pReq);
|
int32_t tDeserializeSGetUserAuthReq(void* buf, int32_t bufLen, SGetUserAuthReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
|
@ -394,8 +394,8 @@ typedef struct {
|
||||||
SHashObj* writeDbs;
|
SHashObj* writeDbs;
|
||||||
} SGetUserAuthRsp;
|
} SGetUserAuthRsp;
|
||||||
|
|
||||||
int32_t tSerializeSGetUserAuthRsp(void** buf, SGetUserAuthRsp* pReq);
|
int32_t tSerializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pReq);
|
||||||
void* tDeserializeSGetUserAuthRsp(void* buf, SGetUserAuthRsp* pReq);
|
int32_t tDeserializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int16_t colId; // column id
|
int16_t colId; // column id
|
||||||
|
@ -851,19 +851,32 @@ typedef struct {
|
||||||
int32_t port;
|
int32_t port;
|
||||||
} SCreateDnodeReq;
|
} SCreateDnodeReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSCreateDnodeReq(void* buf, int32_t bufLen, SCreateDnodeReq* pReq);
|
||||||
|
int32_t tDeserializeSCreateDnodeReq(void* buf, int32_t bufLen, SCreateDnodeReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
} SDropDnodeReq;
|
} SDropDnodeReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSDropDnodeReq(void* buf, int32_t bufLen, SDropDnodeReq* pReq);
|
||||||
|
int32_t tDeserializeSDropDnodeReq(void* buf, int32_t bufLen, SDropDnodeReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
char config[TSDB_DNODE_CONFIG_LEN];
|
char config[TSDB_DNODE_CONFIG_LEN];
|
||||||
|
char value[TSDB_DNODE_VALUE_LEN];
|
||||||
} SMCfgDnodeReq, SDCfgDnodeReq;
|
} SMCfgDnodeReq, SDCfgDnodeReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq);
|
||||||
|
int32_t tDeserializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
} SMCreateMnodeReq, SMDropMnodeReq, SDDropMnodeReq;
|
} SMCreateMnodeReq, SMDropMnodeReq, SDDropMnodeReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSMCreateDropMnodeReq(void* buf, int32_t bufLen, SMCreateMnodeReq* pReq);
|
||||||
|
int32_t tDeserializeSMCreateDropMnodeReq(void* buf, int32_t bufLen, SMCreateMnodeReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int8_t replica;
|
int8_t replica;
|
||||||
|
@ -872,15 +885,11 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
} SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq;
|
} SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq, SMCreateSnodeReq, SMDropSnodeReq,
|
||||||
|
SDCreateSnodeReq, SDDropSnodeReq, SMCreateBnodeReq, SMDropBnodeReq, SDCreateBnodeReq, SDDropBnodeReq;
|
||||||
|
|
||||||
typedef struct {
|
int32_t tSerializeSMCreateDropQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
|
||||||
int32_t dnodeId;
|
int32_t tDeserializeSMCreateDropQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
|
||||||
} SMCreateSnodeReq, SMDropSnodeReq, SDCreateSnodeReq, SDDropSnodeReq;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t dnodeId;
|
|
||||||
} SMCreateBnodeReq, SMDropBnodeReq, SDCreateBnodeReq, SDDropBnodeReq;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char sql[TSDB_SHOW_SQL_LEN];
|
char sql[TSDB_SHOW_SQL_LEN];
|
||||||
|
|
|
@ -219,6 +219,7 @@ do { \
|
||||||
|
|
||||||
#define TSDB_ERROR_MSG_LEN 1024
|
#define TSDB_ERROR_MSG_LEN 1024
|
||||||
#define TSDB_DNODE_CONFIG_LEN 128
|
#define TSDB_DNODE_CONFIG_LEN 128
|
||||||
|
#define TSDB_DNODE_VALUE_LEN 256
|
||||||
|
|
||||||
#define TSDB_MQTT_HOSTNAME_LEN 64
|
#define TSDB_MQTT_HOSTNAME_LEN 64
|
||||||
#define TSDB_MQTT_PORT_LEN 8
|
#define TSDB_MQTT_PORT_LEN 8
|
||||||
|
|
|
@ -600,142 +600,323 @@ void *tDeserializeSStatusRsp(void *buf, SStatusRsp *pRsp) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSCreateAcctReq(void **buf, SCreateAcctReq *pReq) {
|
int32_t tSerializeSCreateAcctReq(void *buf, int32_t bufLen, SCreateAcctReq *pReq) {
|
||||||
int32_t tlen = 0;
|
SCoder encoder = {0};
|
||||||
tlen += taosEncodeString(buf, pReq->user);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
tlen += taosEncodeString(buf, pReq->pass);
|
|
||||||
tlen += taosEncodeFixedI32(buf, pReq->maxUsers);
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI32(buf, pReq->maxDbs);
|
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI32(buf, pReq->maxTimeSeries);
|
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI32(buf, pReq->maxStreams);
|
if (tEncodeI32(&encoder, pReq->maxUsers) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI32(buf, pReq->accessState);
|
if (tEncodeI32(&encoder, pReq->maxDbs) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->maxStorage);
|
if (tEncodeI32(&encoder, pReq->maxTimeSeries) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->maxStreams) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->accessState) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->maxStorage) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *tDeserializeSCreateAcctReq(void *buf, SCreateAcctReq *pReq) {
|
int32_t tDeserializeSCreateAcctReq(void *buf, int32_t bufLen, SCreateAcctReq *pReq) {
|
||||||
buf = taosDecodeStringTo(buf, pReq->user);
|
SCoder decoder = {0};
|
||||||
buf = taosDecodeStringTo(buf, pReq->pass);
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->maxUsers);
|
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->maxDbs);
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->maxTimeSeries);
|
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->maxStreams);
|
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->accessState);
|
if (tDecodeI32(&decoder, &pReq->maxUsers) < 0) return -1;
|
||||||
buf = taosDecodeFixedI64(buf, &pReq->maxStorage);
|
if (tDecodeI32(&decoder, &pReq->maxDbs) < 0) return -1;
|
||||||
return buf;
|
if (tDecodeI32(&decoder, &pReq->maxTimeSeries) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->maxStreams) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->accessState) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->maxStorage) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSDropUserReq(void **buf, SDropUserReq *pReq) {
|
int32_t tSerializeSDropUserReq(void *buf, int32_t bufLen, SDropUserReq *pReq) {
|
||||||
int32_t tlen = 0;
|
SCoder encoder = {0};
|
||||||
tlen += taosEncodeString(buf, pReq->user);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *tDeserializeSDropUserReq(void *buf, SDropUserReq *pReq) {
|
int32_t tDeserializeSDropUserReq(void *buf, int32_t bufLen, SDropUserReq *pReq) {
|
||||||
buf = taosDecodeStringTo(buf, pReq->user);
|
SCoder decoder = {0};
|
||||||
return buf;
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSCreateUserReq(void **buf, SCreateUserReq *pReq) {
|
int32_t tSerializeSCreateUserReq(void *buf, int32_t bufLen, SCreateUserReq *pReq) {
|
||||||
int32_t tlen = 0;
|
SCoder encoder = {0};
|
||||||
tlen += taosEncodeFixedI8(buf, pReq->createType);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
tlen += taosEncodeFixedI8(buf, pReq->superUser);
|
|
||||||
tlen += taosEncodeString(buf, pReq->user);
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
tlen += taosEncodeString(buf, pReq->pass);
|
if (tEncodeI8(&encoder, pReq->createType) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *tDeserializeSCreateUserReq(void *buf, SCreateUserReq *pReq) {
|
int32_t tDeserializeSCreateUserReq(void *buf, int32_t bufLen, SCreateUserReq *pReq) {
|
||||||
buf = taosDecodeFixedI8(buf, &pReq->createType);
|
SCoder decoder = {0};
|
||||||
buf = taosDecodeFixedI8(buf, &pReq->superUser);
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
buf = taosDecodeStringTo(buf, pReq->user);
|
|
||||||
buf = taosDecodeStringTo(buf, pReq->pass);
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
return buf;
|
if (tDecodeI8(&decoder, &pReq->createType) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSAlterUserReq(void **buf, SAlterUserReq *pReq) {
|
int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq) {
|
||||||
int32_t tlen = 0;
|
SCoder encoder = {0};
|
||||||
tlen += taosEncodeFixedI8(buf, pReq->alterType);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
tlen += taosEncodeString(buf, pReq->user);
|
|
||||||
tlen += taosEncodeString(buf, pReq->pass);
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
tlen += taosEncodeString(buf, pReq->dbname);
|
if (tEncodeI8(&encoder, pReq->alterType) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI8(buf, pReq->superUser);
|
if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->dbname) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *tDeserializeSAlterUserReq(void *buf, SAlterUserReq *pReq) {
|
int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq) {
|
||||||
buf = taosDecodeFixedI8(buf, &pReq->alterType);
|
SCoder decoder = {0};
|
||||||
buf = taosDecodeStringTo(buf, pReq->user);
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
buf = taosDecodeStringTo(buf, pReq->pass);
|
|
||||||
buf = taosDecodeStringTo(buf, pReq->dbname);
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
buf = taosDecodeFixedI8(buf, &pReq->superUser);
|
if (tDecodeI8(&decoder, &pReq->alterType) < 0) return -1;
|
||||||
return buf;
|
if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->dbname) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSGetUserAuthReq(void **buf, SGetUserAuthReq *pReq) {
|
int32_t tSerializeSGetUserAuthReq(void *buf, int32_t bufLen, SGetUserAuthReq *pReq) {
|
||||||
int32_t tlen = 0;
|
SCoder encoder = {0};
|
||||||
tlen += taosEncodeString(buf, pReq->user);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *tDeserializeSGetUserAuthReq(void *buf, SGetUserAuthReq *pReq) {
|
int32_t tDeserializeSGetUserAuthReq(void *buf, int32_t bufLen, SGetUserAuthReq *pReq) {
|
||||||
buf = taosDecodeStringTo(buf, pReq->user);
|
SCoder decoder = {0};
|
||||||
return buf;
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSGetUserAuthRsp(void **buf, SGetUserAuthRsp *pReq) {
|
int32_t tSerializeSGetUserAuthRsp(void *buf, int32_t bufLen, SGetUserAuthRsp *pReq) {
|
||||||
int32_t tlen = 0;
|
SCoder encoder = {0};
|
||||||
tlen += taosEncodeString(buf, pReq->user);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
tlen += taosEncodeFixedI8(buf, pReq->superAuth);
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->superAuth) < 0) return -1;
|
||||||
|
|
||||||
int32_t numOfReadDbs = taosHashGetSize(pReq->readDbs);
|
int32_t numOfReadDbs = taosHashGetSize(pReq->readDbs);
|
||||||
int32_t numOfWriteDbs = taosHashGetSize(pReq->writeDbs);
|
int32_t numOfWriteDbs = taosHashGetSize(pReq->writeDbs);
|
||||||
tlen += taosEncodeFixedI32(buf, numOfReadDbs);
|
if (tEncodeI32(&encoder, numOfReadDbs) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI32(buf, numOfWriteDbs);
|
if (tEncodeI32(&encoder, numOfWriteDbs) < 0) return -1;
|
||||||
|
|
||||||
char *db = taosHashIterate(pReq->readDbs, NULL);
|
char *db = taosHashIterate(pReq->readDbs, NULL);
|
||||||
while (db != NULL) {
|
while (db != NULL) {
|
||||||
tlen += taosEncodeString(buf, db);
|
if (tEncodeCStr(&encoder, db) < 0) return -1;
|
||||||
db = taosHashIterate(pReq->readDbs, db);
|
db = taosHashIterate(pReq->readDbs, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
db = taosHashIterate(pReq->writeDbs, NULL);
|
db = taosHashIterate(pReq->writeDbs, NULL);
|
||||||
while (db != NULL) {
|
while (db != NULL) {
|
||||||
tlen += taosEncodeString(buf, db);
|
if (tEncodeCStr(&encoder, db) < 0) return -1;
|
||||||
db = taosHashIterate(pReq->writeDbs, db);
|
db = taosHashIterate(pReq->writeDbs, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *tDeserializeSGetUserAuthRsp(void *buf, SGetUserAuthRsp *pReq) {
|
int32_t tDeserializeSGetUserAuthRsp(void *buf, int32_t bufLen, SGetUserAuthRsp *pReq) {
|
||||||
buf = taosDecodeStringTo(buf, pReq->user);
|
|
||||||
buf = taosDecodeFixedI8(buf, &pReq->superAuth);
|
|
||||||
|
|
||||||
pReq->readDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
|
pReq->readDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
|
||||||
pReq->writeDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
|
pReq->writeDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
|
||||||
if (pReq->readDbs == NULL || pReq->writeDbs == NULL) {
|
if (pReq->readDbs == NULL || pReq->writeDbs == NULL) {
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCoder decoder = {0};
|
||||||
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->superAuth) < 0) return -1;
|
||||||
|
|
||||||
int32_t numOfReadDbs = 0;
|
int32_t numOfReadDbs = 0;
|
||||||
int32_t numOfWriteDbs = 0;
|
int32_t numOfWriteDbs = 0;
|
||||||
buf = taosDecodeFixedI32(buf, &numOfReadDbs);
|
if (tDecodeI32(&decoder, &numOfReadDbs) < 0) return -1;
|
||||||
buf = taosDecodeFixedI32(buf, &numOfWriteDbs);
|
if (tDecodeI32(&decoder, &numOfWriteDbs) < 0) return -1;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfReadDbs; ++i) {
|
for (int32_t i = 0; i < numOfReadDbs; ++i) {
|
||||||
char db[TSDB_DB_FNAME_LEN] = {0};
|
char db[TSDB_DB_FNAME_LEN] = {0};
|
||||||
buf = taosDecodeStringTo(buf, db);
|
if (tDecodeCStrTo(&decoder, db) < 0) return -1;
|
||||||
int32_t len = strlen(db) + 1;
|
int32_t len = strlen(db) + 1;
|
||||||
taosHashPut(pReq->readDbs, db, len, db, len);
|
taosHashPut(pReq->readDbs, db, len, db, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfWriteDbs; ++i) {
|
for (int32_t i = 0; i < numOfWriteDbs; ++i) {
|
||||||
char db[TSDB_DB_FNAME_LEN] = {0};
|
char db[TSDB_DB_FNAME_LEN] = {0};
|
||||||
buf = taosDecodeStringTo(buf, db);
|
if (tDecodeCStrTo(&decoder, db) < 0) return -1;
|
||||||
int32_t len = strlen(db) + 1;
|
int32_t len = strlen(db) + 1;
|
||||||
taosHashPut(pReq->writeDbs, db, len, db, len);
|
taosHashPut(pReq->writeDbs, db, len, db, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMCreateDropQSBNodeReq(void *buf, int32_t bufLen, SMCreateQnodeReq *pReq) {
|
||||||
|
SCoder encoder = {0};
|
||||||
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMCreateDropQSBNodeReq(void *buf, int32_t bufLen, SMCreateQnodeReq *pReq) {
|
||||||
|
SCoder decoder = {0};
|
||||||
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSDropDnodeReq(void *buf, int32_t bufLen, SDropDnodeReq *pReq) {
|
||||||
|
return tSerializeSMCreateDropQSBNodeReq(buf, bufLen, (SMCreateQnodeReq *)pReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSDropDnodeReq(void *buf, int32_t bufLen, SDropDnodeReq *pReq) {
|
||||||
|
return tDeserializeSMCreateDropQSBNodeReq(buf, bufLen, (SMCreateQnodeReq *)pReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMCreateDropMnodeReq(void *buf, int32_t bufLen, SMCreateMnodeReq *pReq) {
|
||||||
|
return tSerializeSMCreateDropQSBNodeReq(buf, bufLen, (SMCreateQnodeReq *)pReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMCreateDropMnodeReq(void *buf, int32_t bufLen, SMCreateMnodeReq *pReq) {
|
||||||
|
return tDeserializeSMCreateDropQSBNodeReq(buf, bufLen, (SMCreateQnodeReq *)pReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMCfgDnodeReq(void *buf, int32_t bufLen, SMCfgDnodeReq *pReq) {
|
||||||
|
SCoder encoder = {0};
|
||||||
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->config) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->value) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMCfgDnodeReq(void *buf, int32_t bufLen, SMCfgDnodeReq *pReq) {
|
||||||
|
SCoder decoder = {0};
|
||||||
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->config) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->value) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSCreateDnodeReq(void *buf, int32_t bufLen, SCreateDnodeReq *pReq) {
|
||||||
|
SCoder encoder = {0};
|
||||||
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->fqdn) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->port) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSCreateDnodeReq(void *buf, int32_t bufLen, SCreateDnodeReq *pReq) {
|
||||||
|
SCoder decoder = {0};
|
||||||
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->fqdn) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->port) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,10 @@ int32_t mndCheckCreateUserAuth(SUserObj *pOperUser);
|
||||||
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SDbObj *pDb, SAlterUserReq *pAlter);
|
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SDbObj *pDb, SAlterUserReq *pAlter);
|
||||||
int32_t mndCheckDropUserAuth(SUserObj *pOperUser);
|
int32_t mndCheckDropUserAuth(SUserObj *pOperUser);
|
||||||
|
|
||||||
|
int32_t mndCheckCreateNodeAuth(SUserObj *pOperUser);
|
||||||
|
int32_t mndCheckDropNodeAuth(SUserObj *pOperUser);
|
||||||
|
int32_t mndCheckAlterNodeAuth(SUserObj *pOperUser);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -109,4 +109,17 @@ int32_t mndCheckDropUserAuth(SUserObj *pOperUser) {
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t mndCheckCreateNodeAuth(SUserObj *pOperUser) {
|
||||||
|
if (pOperUser->superUser) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndCheckDropNodeAuth(SUserObj *pOperUser) { return mndCheckCreateNodeAuth(pOperUser); }
|
||||||
|
|
||||||
|
int32_t mndCheckAlterNodeAuth(SUserObj *pOperUser) { return mndCheckCreateNodeAuth(pOperUser); }
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndBnode.h"
|
#include "mndBnode.h"
|
||||||
|
#include "mndAuth.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
|
#include "mndUser.h"
|
||||||
|
|
||||||
#define TSDB_BNODE_VER_NUMBER 1
|
#define TSDB_BNODE_VER_NUMBER 1
|
||||||
#define TSDB_BNODE_RESERVE_SIZE 64
|
#define TSDB_BNODE_RESERVE_SIZE 64
|
||||||
|
@ -257,40 +259,57 @@ CREATE_BNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMCreateBnodeReq *pCreate = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
|
SBnodeObj *pObj = NULL;
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
SUserObj *pUser = NULL;
|
||||||
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
|
||||||
pCreate->dnodeId = htonl(pCreate->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto CREATE_BNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
mDebug("bnode:%d, start to create", pCreate->dnodeId);
|
mDebug("bnode:%d, start to create", createReq.dnodeId);
|
||||||
|
|
||||||
SBnodeObj *pObj = mndAcquireBnode(pMnode, pCreate->dnodeId);
|
pObj = mndAcquireBnode(pMnode, createReq.dnodeId);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
mError("bnode:%d, bnode already exist", pObj->id);
|
|
||||||
terrno = TSDB_CODE_MND_BNODE_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_BNODE_ALREADY_EXIST;
|
||||||
mndReleaseBnode(pMnode, pObj);
|
goto CREATE_BNODE_OVER;
|
||||||
return -1;
|
|
||||||
} else if (terrno != TSDB_CODE_MND_BNODE_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_BNODE_NOT_EXIST) {
|
||||||
mError("bnode:%d, failed to create bnode since %s", pCreate->dnodeId, terrstr());
|
goto CREATE_BNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pCreate->dnodeId);
|
pDnode = mndAcquireDnode(pMnode, createReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
mError("bnode:%d, dnode not exist", pCreate->dnodeId);
|
|
||||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||||
return -1;
|
goto CREATE_BNODE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndCreateBnode(pMnode, pReq, pDnode, pCreate);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto CREATE_BNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckDropNodeAuth(pUser)) {
|
||||||
|
goto CREATE_BNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndCreateBnode(pMnode, pReq, pDnode, &createReq);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
CREATE_BNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
|
mError("bnode:%d, failed to create since %s", createReq.dnodeId, terrstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
mndReleaseBnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
if (code != 0) {
|
return code;
|
||||||
mError("bnode:%d, failed to create since %s", pCreate->dnodeId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetDropBnodeRedoLogs(STrans *pTrans, SBnodeObj *pObj) {
|
static int32_t mndSetDropBnodeRedoLogs(STrans *pTrans, SBnodeObj *pObj) {
|
||||||
|
@ -352,33 +371,51 @@ DROP_BNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropBnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessDropBnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMDropBnodeReq *pDrop = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
SUserObj *pUser = NULL;
|
||||||
|
SBnodeObj *pObj = NULL;
|
||||||
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
|
||||||
mDebug("bnode:%d, start to drop", pDrop->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto DROP_BNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDrop->dnodeId <= 0) {
|
mDebug("bnode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
|
||||||
|
if (dropReq.dnodeId <= 0) {
|
||||||
terrno = TSDB_CODE_SDB_APP_ERROR;
|
terrno = TSDB_CODE_SDB_APP_ERROR;
|
||||||
mError("bnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_BNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SBnodeObj *pObj = mndAcquireBnode(pMnode, pDrop->dnodeId);
|
pObj = mndAcquireBnode(pMnode, dropReq.dnodeId);
|
||||||
if (pObj == NULL) {
|
if (pObj == NULL) {
|
||||||
mError("bnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_BNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndDropBnode(pMnode, pReq, pObj);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
if (code != 0) {
|
if (pUser == NULL) {
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
mError("bnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
goto DROP_BNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
if (mndCheckCreateNodeAuth(pUser)) {
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
goto DROP_BNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndDropBnode(pMnode, pReq, pObj);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
DROP_BNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
|
mError("bnode:%d, failed to drop since %s", dropReq.dnodeId, terrstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
mndReleaseBnode(pMnode, pObj);
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pRsp) {
|
static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pRsp) {
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
|
#include "mndAuth.h"
|
||||||
#include "mndMnode.h"
|
#include "mndMnode.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
|
#include "mndUser.h"
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
|
|
||||||
#define TSDB_DNODE_VER_NUMBER 1
|
#define TSDB_DNODE_VER_NUMBER 1
|
||||||
|
@ -354,7 +356,8 @@ static int32_t mndProcessStatusReq(SMnodeMsg *pReq) {
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
pDnode->offlineReason = DND_REASON_VERSION_NOT_MATCH;
|
pDnode->offlineReason = DND_REASON_VERSION_NOT_MATCH;
|
||||||
}
|
}
|
||||||
mError("dnode:%d, status msg version:%d not match cluster:%d", statusReq.dnodeId, statusReq.sver, pMnode->cfg.sver);
|
mError("dnode:%d, status msg version:%d not match cluster:%d", statusReq.dnodeId, statusReq.sver,
|
||||||
|
pMnode->cfg.sver);
|
||||||
terrno = TSDB_CODE_MND_INVALID_MSG_VERSION;
|
terrno = TSDB_CODE_MND_INVALID_MSG_VERSION;
|
||||||
goto PROCESS_STATUS_MSG_OVER;
|
goto PROCESS_STATUS_MSG_OVER;
|
||||||
}
|
}
|
||||||
|
@ -461,35 +464,54 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pReq, SCreateDnodeReq *
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateDnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessCreateDnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SCreateDnodeReq *pCreate = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
pCreate->port = htonl(pCreate->port);
|
SUserObj *pUser = NULL;
|
||||||
mDebug("dnode:%s:%d, start to create", pCreate->fqdn, pCreate->port);
|
SDnodeObj *pDnode = NULL;
|
||||||
|
SCreateDnodeReq createReq = {0};
|
||||||
|
|
||||||
if (pCreate->fqdn[0] == 0 || pCreate->port <= 0 || pCreate->port > UINT16_MAX) {
|
if (tDeserializeSCreateDnodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto CREATE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDebug("dnode:%s:%d, start to create", createReq.fqdn, createReq.port);
|
||||||
|
|
||||||
|
if (createReq.fqdn[0] == 0 || createReq.port <= 0 || createReq.port > UINT16_MAX) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_DNODE_EP;
|
terrno = TSDB_CODE_MND_INVALID_DNODE_EP;
|
||||||
mError("dnode:%s:%d, failed to create since %s", pCreate->fqdn, pCreate->port, terrstr());
|
goto CREATE_DNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char ep[TSDB_EP_LEN];
|
char ep[TSDB_EP_LEN];
|
||||||
snprintf(ep, TSDB_EP_LEN, "%s:%d", pCreate->fqdn, pCreate->port);
|
snprintf(ep, TSDB_EP_LEN, "%s:%d", createReq.fqdn, createReq.port);
|
||||||
SDnodeObj *pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
mError("dnode:%d, already exist, %s:%u", pDnode->id, pCreate->fqdn, pCreate->port);
|
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
|
||||||
terrno = TSDB_CODE_MND_DNODE_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_DNODE_ALREADY_EXIST;
|
||||||
|
goto CREATE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto CREATE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckDropNodeAuth(pUser)) {
|
||||||
|
goto CREATE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndCreateDnode(pMnode, pReq, &createReq);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
CREATE_DNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
|
mError("dnode:%s:%d, failed to create since %s", createReq.fqdn, createReq.port, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndCreateDnode(pMnode, pReq, pCreate);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
if (code != 0) {
|
return code;
|
||||||
mError("dnode:%s:%d, failed to create since %s", pCreate->fqdn, pCreate->port, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndDropDnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode) {
|
static int32_t mndDropDnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode) {
|
||||||
|
@ -519,34 +541,53 @@ static int32_t mndDropDnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropDnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessDropDnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SDropDnodeReq *pDrop = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
SUserObj *pUser = NULL;
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
SDropDnodeReq dropReq = {0};
|
||||||
|
|
||||||
mDebug("dnode:%d, start to drop", pDrop->dnodeId);
|
if (tDeserializeSDropDnodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
if (pDrop->dnodeId <= 0) {
|
goto DROP_DNODE_OVER;
|
||||||
terrno = TSDB_CODE_MND_INVALID_DNODE_ID;
|
|
||||||
mError("dnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pDrop->dnodeId);
|
mDebug("dnode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
|
||||||
|
if (dropReq.dnodeId <= 0) {
|
||||||
|
terrno = TSDB_CODE_MND_INVALID_DNODE_ID;
|
||||||
|
goto DROP_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDnode = mndAcquireDnode(pMnode, dropReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||||
mError("dnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_DNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndDropDnode(pMnode, pReq, pDnode);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
if (code != 0) {
|
if (pUser == NULL) {
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
mError("dnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckCreateNodeAuth(pUser)) {
|
||||||
|
goto DROP_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndDropDnode(pMnode, pReq, pDnode);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
DROP_DNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
|
mError("dnode:%d, failed to drop since %s", dropReq.dnodeId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessConfigDnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessConfigDnodeReq(SMnodeMsg *pReq) {
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndQnode.h"
|
#include "mndQnode.h"
|
||||||
|
#include "mndAuth.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
|
#include "mndUser.h"
|
||||||
|
|
||||||
#define TSDB_QNODE_VER_NUMBER 1
|
#define TSDB_QNODE_VER_NUMBER 1
|
||||||
#define TSDB_QNODE_RESERVE_SIZE 64
|
#define TSDB_QNODE_RESERVE_SIZE 64
|
||||||
|
@ -257,40 +259,58 @@ CREATE_QNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMCreateQnodeReq *pCreate = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
|
SQnodeObj *pObj = NULL;
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
SUserObj *pUser = NULL;
|
||||||
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
|
||||||
pCreate->dnodeId = htonl(pCreate->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto CREATE_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
mDebug("qnode:%d, start to create", pCreate->dnodeId);
|
mDebug("qnode:%d, start to create", createReq.dnodeId);
|
||||||
|
|
||||||
SQnodeObj *pObj = mndAcquireQnode(pMnode, pCreate->dnodeId);
|
pObj = mndAcquireQnode(pMnode, createReq.dnodeId);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
mError("qnode:%d, qnode already exist", pObj->id);
|
|
||||||
terrno = TSDB_CODE_MND_QNODE_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_QNODE_ALREADY_EXIST;
|
||||||
mndReleaseQnode(pMnode, pObj);
|
goto CREATE_QNODE_OVER;
|
||||||
return -1;
|
|
||||||
} else if (terrno != TSDB_CODE_MND_QNODE_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_QNODE_NOT_EXIST) {
|
||||||
mError("qnode:%d, failed to create qnode since %s", pCreate->dnodeId, terrstr());
|
goto CREATE_QNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pCreate->dnodeId);
|
pDnode = mndAcquireDnode(pMnode, createReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
mError("qnode:%d, dnode not exist", pCreate->dnodeId);
|
|
||||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||||
|
goto CREATE_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto CREATE_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckDropNodeAuth(pUser)) {
|
||||||
|
goto CREATE_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndCreateQnode(pMnode, pReq, pDnode, &createReq);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
CREATE_QNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
|
mError("qnode:%d, failed to create since %s", createReq.dnodeId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndCreateQnode(pMnode, pReq, pDnode, pCreate);
|
mndReleaseQnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
if (code != 0) {
|
return code;
|
||||||
mError("qnode:%d, failed to create since %s", pCreate->dnodeId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetDropQnodeRedoLogs(STrans *pTrans, SQnodeObj *pObj) {
|
static int32_t mndSetDropQnodeRedoLogs(STrans *pTrans, SQnodeObj *pObj) {
|
||||||
|
@ -352,33 +372,52 @@ DROP_QNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropQnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessDropQnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMDropQnodeReq *pDrop = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
SUserObj *pUser = NULL;
|
||||||
|
SQnodeObj *pObj = NULL;
|
||||||
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
|
||||||
mDebug("qnode:%d, start to drop", pDrop->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto DROP_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDrop->dnodeId <= 0) {
|
mDebug("qnode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
|
||||||
|
if (dropReq.dnodeId <= 0) {
|
||||||
terrno = TSDB_CODE_SDB_APP_ERROR;
|
terrno = TSDB_CODE_SDB_APP_ERROR;
|
||||||
mError("qnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_QNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SQnodeObj *pObj = mndAcquireQnode(pMnode, pDrop->dnodeId);
|
pObj = mndAcquireQnode(pMnode, dropReq.dnodeId);
|
||||||
if (pObj == NULL) {
|
if (pObj == NULL) {
|
||||||
mError("qnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_QNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndDropQnode(pMnode, pReq, pObj);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
if (code != 0) {
|
if (pUser == NULL) {
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto DROP_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckCreateNodeAuth(pUser)) {
|
||||||
|
goto DROP_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndDropQnode(pMnode, pReq, pObj);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
DROP_QNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mError("qnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
mError("qnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
mndReleaseQnode(pMnode, pObj);
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pRsp) {
|
static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pRsp) {
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndSnode.h"
|
#include "mndSnode.h"
|
||||||
|
#include "mndAuth.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
|
#include "mndUser.h"
|
||||||
|
|
||||||
#define TSDB_SNODE_VER_NUMBER 1
|
#define TSDB_SNODE_VER_NUMBER 1
|
||||||
#define TSDB_SNODE_RESERVE_SIZE 64
|
#define TSDB_SNODE_RESERVE_SIZE 64
|
||||||
|
@ -258,40 +260,58 @@ CREATE_SNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMCreateSnodeReq *pCreate = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
|
SSnodeObj *pObj = NULL;
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
SUserObj *pUser = NULL;
|
||||||
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
|
||||||
pCreate->dnodeId = htonl(pCreate->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto CREATE_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
mDebug("snode:%d, start to create", pCreate->dnodeId);
|
mDebug("snode:%d, start to create", createReq.dnodeId);
|
||||||
|
|
||||||
SSnodeObj *pObj = mndAcquireSnode(pMnode, pCreate->dnodeId);
|
pObj = mndAcquireSnode(pMnode, createReq.dnodeId);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
mError("snode:%d, snode already exist", pObj->id);
|
|
||||||
terrno = TSDB_CODE_MND_SNODE_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_SNODE_ALREADY_EXIST;
|
||||||
mndReleaseSnode(pMnode, pObj);
|
goto CREATE_SNODE_OVER;
|
||||||
return -1;
|
|
||||||
} else if (terrno != TSDB_CODE_MND_SNODE_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_SNODE_NOT_EXIST) {
|
||||||
mError("snode:%d, failed to create snode since %s", pCreate->dnodeId, terrstr());
|
goto CREATE_SNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pCreate->dnodeId);
|
pDnode = mndAcquireDnode(pMnode, createReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
mError("snode:%d, dnode not exist", pCreate->dnodeId);
|
|
||||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||||
|
goto CREATE_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto CREATE_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckDropNodeAuth(pUser)) {
|
||||||
|
goto CREATE_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndCreateSnode(pMnode, pReq, pDnode, &createReq);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
CREATE_SNODE_OVER:
|
||||||
|
if(code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
|
mError("snode:%d, failed to create since %s", createReq.dnodeId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndCreateSnode(pMnode, pReq, pDnode, pCreate);
|
mndReleaseSnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
if (code != 0) {
|
return code;
|
||||||
mError("snode:%d, failed to create since %s", pCreate->dnodeId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetDropSnodeRedoLogs(STrans *pTrans, SSnodeObj *pObj) {
|
static int32_t mndSetDropSnodeRedoLogs(STrans *pTrans, SSnodeObj *pObj) {
|
||||||
|
@ -354,33 +374,52 @@ DROP_SNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropSnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessDropSnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMDropSnodeReq *pDrop = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
SUserObj *pUser = NULL;
|
||||||
|
SSnodeObj *pObj = NULL;
|
||||||
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
|
||||||
mDebug("snode:%d, start to drop", pDrop->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto DROP_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDrop->dnodeId <= 0) {
|
mDebug("snode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
|
||||||
|
if (dropReq.dnodeId <= 0) {
|
||||||
terrno = TSDB_CODE_SDB_APP_ERROR;
|
terrno = TSDB_CODE_SDB_APP_ERROR;
|
||||||
mError("snode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_SNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SSnodeObj *pObj = mndAcquireSnode(pMnode, pDrop->dnodeId);
|
pObj = mndAcquireSnode(pMnode, dropReq.dnodeId);
|
||||||
if (pObj == NULL) {
|
if (pObj == NULL) {
|
||||||
mError("snode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_SNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndDropSnode(pMnode, pReq, pObj);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
if (code != 0) {
|
if (pUser == NULL) {
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto DROP_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckCreateNodeAuth(pUser)) {
|
||||||
|
goto DROP_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndDropSnode(pMnode, pReq, pObj);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
DROP_SNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mError("snode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
mError("snode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
mndReleaseSnode(pMnode, pObj);
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pRsp) {
|
static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pRsp) {
|
||||||
|
|
|
@ -302,7 +302,7 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pReq) {
|
||||||
SUserObj *pOperUser = NULL;
|
SUserObj *pOperUser = NULL;
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCreateUserReq(pReq->rpcMsg.pCont, &createReq) == NULL) goto CREATE_USER_OVER;
|
if (tDeserializeSCreateUserReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) goto CREATE_USER_OVER;
|
||||||
|
|
||||||
mDebug("user:%s, start to create", createReq.user);
|
mDebug("user:%s, start to create", createReq.user);
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pReq) {
|
||||||
SUserObj newUser = {0};
|
SUserObj newUser = {0};
|
||||||
SAlterUserReq alterReq = {0};
|
SAlterUserReq alterReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSAlterUserReq(pReq->rpcMsg.pCont, &alterReq) == NULL) goto ALTER_USER_OVER;
|
if (tDeserializeSAlterUserReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &alterReq) != 0) goto ALTER_USER_OVER;
|
||||||
|
|
||||||
mDebug("user:%s, start to alter", alterReq.user);
|
mDebug("user:%s, start to alter", alterReq.user);
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pReq) {
|
||||||
SUserObj *pOperUser = NULL;
|
SUserObj *pOperUser = NULL;
|
||||||
SDropUserReq dropReq = {0};
|
SDropUserReq dropReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSDropUserReq(pReq->rpcMsg.pCont, &dropReq) == NULL) goto DROP_USER_OVER;
|
if (tDeserializeSDropUserReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) goto DROP_USER_OVER;
|
||||||
|
|
||||||
mDebug("user:%s, start to drop", dropReq.user);
|
mDebug("user:%s, start to drop", dropReq.user);
|
||||||
|
|
||||||
|
@ -583,7 +583,7 @@ static int32_t mndProcessGetUserAuthReq(SMnodeMsg *pReq) {
|
||||||
SGetUserAuthReq authReq = {0};
|
SGetUserAuthReq authReq = {0};
|
||||||
SGetUserAuthRsp authRsp = {0};
|
SGetUserAuthRsp authRsp = {0};
|
||||||
|
|
||||||
if (tDeserializeSGetUserAuthReq(pReq->rpcMsg.pCont, &authReq) == NULL) goto GET_AUTH_OVER;
|
if (tDeserializeSGetUserAuthReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &authReq) != 0) goto GET_AUTH_OVER;
|
||||||
|
|
||||||
mTrace("user:%s, start to get auth", authReq.user);
|
mTrace("user:%s, start to get auth", authReq.user);
|
||||||
|
|
||||||
|
@ -614,15 +614,14 @@ static int32_t mndProcessGetUserAuthReq(SMnodeMsg *pReq) {
|
||||||
sdbRelease(pSdb, pDb);
|
sdbRelease(pSdb, pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t contLen = tSerializeSGetUserAuthRsp(NULL, &authRsp);
|
int32_t contLen = tSerializeSGetUserAuthRsp(NULL, 0, &authRsp);
|
||||||
void *pRsp = rpcMallocCont(contLen);
|
void *pRsp = rpcMallocCont(contLen);
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto GET_AUTH_OVER;
|
goto GET_AUTH_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pBuf = pRsp;
|
tSerializeSGetUserAuthRsp(pRsp, contLen, &authRsp);
|
||||||
tSerializeSGetUserAuthRsp(&pBuf, &authRsp);
|
|
||||||
|
|
||||||
pReq->pCont = pRsp;
|
pReq->pCont = pRsp;
|
||||||
pReq->contLen = contLen;
|
pReq->contLen = contLen;
|
||||||
|
|
|
@ -52,10 +52,12 @@ TEST_F(MndTestBnode, 01_Show_Bnode) {
|
||||||
|
|
||||||
TEST_F(MndTestBnode, 02_Create_Bnode) {
|
TEST_F(MndTestBnode, 02_Create_Bnode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -63,10 +65,12 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -83,10 +87,12 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -96,11 +102,13 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
|
||||||
|
|
||||||
TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 9019;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9019);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -113,10 +121,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -135,10 +145,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropBnodeReq);
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -154,10 +166,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropBnodeReq);
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -168,10 +182,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
||||||
TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
|
@ -181,10 +197,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, bnode is creating
|
// continue send message, bnode is creating
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -193,10 +211,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, bnode is creating
|
// continue send message, bnode is creating
|
||||||
int32_t contLen = sizeof(SMDropBnodeReq);
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -212,10 +232,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -230,10 +252,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
||||||
TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMDropBnodeReq);
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||||
|
@ -243,10 +267,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, bnode is dropping
|
// continue send message, bnode is dropping
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -255,10 +281,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, bnode is dropping
|
// continue send message, bnode is dropping
|
||||||
int32_t contLen = sizeof(SMDropBnodeReq);
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -274,10 +302,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
|
|
@ -88,11 +88,13 @@ TEST_F(MndTestDnode, 02_ConfigDnode) {
|
||||||
|
|
||||||
TEST_F(MndTestDnode, 03_Create_Dnode) {
|
TEST_F(MndTestDnode, 03_Create_Dnode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "");
|
||||||
|
createReq.port = 9024;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9024);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -100,11 +102,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = -1;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(-1);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -112,11 +116,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 123456;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(123456);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -124,11 +130,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 9024;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9024);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -136,11 +144,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 9024;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9024);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -172,10 +182,12 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
|
||||||
|
|
||||||
TEST_F(MndTestDnode, 04_Drop_Dnode) {
|
TEST_F(MndTestDnode, 04_Drop_Dnode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SDropDnodeReq);
|
SDropDnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = -3;
|
||||||
|
|
||||||
SDropDnodeReq* pReq = (SDropDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSDropDnodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(-3);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSDropDnodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -183,10 +195,12 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SDropDnodeReq);
|
SDropDnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 5;
|
||||||
|
|
||||||
SDropDnodeReq* pReq = (SDropDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSDropDnodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(5);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSDropDnodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -194,10 +208,12 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SDropDnodeReq);
|
SDropDnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SDropDnodeReq* pReq = (SDropDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSDropDnodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSDropDnodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -205,10 +221,12 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SDropDnodeReq);
|
SDropDnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SDropDnodeReq* pReq = (SDropDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSDropDnodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSDropDnodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -235,11 +253,13 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
|
||||||
|
|
||||||
TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
|
TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 9025;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9025);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -247,11 +267,13 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 9026;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9026);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -259,11 +281,13 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 9027;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9027);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
|
|
@ -87,11 +87,13 @@ TEST_F(MndTestMnode, 03_Create_Mnode_Invalid_Id) {
|
||||||
TEST_F(MndTestMnode, 04_Create_Mnode) {
|
TEST_F(MndTestMnode, 04_Create_Mnode) {
|
||||||
{
|
{
|
||||||
// create dnode
|
// create dnode
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 9029;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9029);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
|
|
@ -52,10 +52,12 @@ TEST_F(MndTestQnode, 01_Show_Qnode) {
|
||||||
|
|
||||||
TEST_F(MndTestQnode, 02_Create_Qnode) {
|
TEST_F(MndTestQnode, 02_Create_Qnode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -63,10 +65,12 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -83,10 +87,12 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -96,11 +102,13 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
|
||||||
|
|
||||||
TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 9015;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9015);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -113,10 +121,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -135,10 +145,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropQnodeReq);
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -154,10 +166,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropQnodeReq);
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -168,10 +182,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
||||||
TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
|
@ -181,10 +197,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, qnode is creating
|
// continue send message, qnode is creating
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -193,10 +211,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, qnode is creating
|
// continue send message, qnode is creating
|
||||||
int32_t contLen = sizeof(SMDropQnodeReq);
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -212,10 +232,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -230,10 +252,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
||||||
TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMDropQnodeReq);
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||||
|
@ -243,11 +267,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, qnode is dropping
|
// continue send message, qnode is dropping
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
|
||||||
pReq->dnodeId = htonl(2);
|
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||||
|
@ -255,10 +280,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, qnode is dropping
|
// continue send message, qnode is dropping
|
||||||
int32_t contLen = sizeof(SMDropQnodeReq);
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -274,11 +301,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
|
||||||
pReq->dnodeId = htonl(2);
|
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
if (pRsp->code == 0) break;
|
if (pRsp->code == 0) break;
|
||||||
|
|
|
@ -52,10 +52,12 @@ TEST_F(MndTestSnode, 01_Show_Snode) {
|
||||||
|
|
||||||
TEST_F(MndTestSnode, 02_Create_Snode) {
|
TEST_F(MndTestSnode, 02_Create_Snode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -63,10 +65,12 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -83,10 +87,12 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -96,11 +102,13 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
|
||||||
|
|
||||||
TEST_F(MndTestSnode, 03_Drop_Snode) {
|
TEST_F(MndTestSnode, 03_Drop_Snode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 9017;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9017);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -113,10 +121,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -135,10 +145,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropSnodeReq);
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -154,10 +166,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropSnodeReq);
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -168,10 +182,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
||||||
TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
|
@ -181,10 +197,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, snode is creating
|
// continue send message, snode is creating
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -193,10 +211,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, snode is creating
|
// continue send message, snode is creating
|
||||||
int32_t contLen = sizeof(SMDropSnodeReq);
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -212,10 +232,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -230,10 +252,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
||||||
TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMDropSnodeReq);
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||||
|
@ -243,10 +267,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, snode is dropping
|
// continue send message, snode is dropping
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -255,10 +281,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, snode is dropping
|
// continue send message, snode is dropping
|
||||||
int32_t contLen = sizeof(SMDropSnodeReq);
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -274,10 +302,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
|
|
@ -67,10 +67,9 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
|
||||||
strcpy(createReq.user, "u1");
|
strcpy(createReq.user, "u1");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, contLen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -101,10 +100,12 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
|
||||||
|
|
||||||
TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
|
TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -118,10 +119,12 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
|
||||||
|
|
||||||
KillThenRestartServer();
|
KillThenRestartServer();
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -136,11 +139,13 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
|
||||||
|
|
||||||
TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
|
TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SCreateDnodeReq);
|
SCreateDnodeReq createReq = {0};
|
||||||
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
createReq.port = 9020;
|
||||||
|
|
||||||
SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
strcpy(pReq->fqdn, "localhost");
|
void* pReq = rpcMallocCont(contLen);
|
||||||
pReq->port = htonl(9020);
|
tSerializeSCreateDnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -153,10 +158,12 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
|
@ -173,10 +180,12 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
|
|
@ -49,10 +49,9 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
strcpy(createReq.user, "");
|
strcpy(createReq.user, "");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, contLen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -64,10 +63,9 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
strcpy(createReq.user, "u1");
|
strcpy(createReq.user, "u1");
|
||||||
strcpy(createReq.pass, "");
|
strcpy(createReq.pass, "");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, contLen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -79,10 +77,9 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
strcpy(createReq.user, "root");
|
strcpy(createReq.user, "root");
|
||||||
strcpy(createReq.pass, "1");
|
strcpy(createReq.pass, "1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, contLen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -94,10 +91,9 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
strcpy(createReq.user, "u1");
|
strcpy(createReq.user, "u1");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, contLen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -121,10 +117,9 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
SDropUserReq dropReq = {0};
|
SDropUserReq dropReq = {0};
|
||||||
strcpy(dropReq.user, "u1");
|
strcpy(dropReq.user, "u1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSDropUserReq(NULL, &dropReq);
|
int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSDropUserReq(pReq, contLen, &dropReq);
|
||||||
tSerializeSDropUserReq(&pBuf, &dropReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -141,10 +136,9 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
createReq.superUser = 1;
|
createReq.superUser = 1;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, contLen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -168,10 +162,9 @@ TEST_F(MndTestUser, 02_Create_User) {
|
||||||
SDropUserReq dropReq = {0};
|
SDropUserReq dropReq = {0};
|
||||||
strcpy(dropReq.user, "u2");
|
strcpy(dropReq.user, "u2");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSDropUserReq(NULL, &dropReq);
|
int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSDropUserReq(pReq, contLen, &dropReq);
|
||||||
tSerializeSDropUserReq(&pBuf, &dropReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -190,10 +183,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
createReq.superUser = 1;
|
createReq.superUser = 1;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, contLen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -210,10 +202,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.user, "");
|
strcpy(alterReq.user, "");
|
||||||
strcpy(alterReq.pass, "p1");
|
strcpy(alterReq.pass, "p1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -226,10 +217,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.user, "u3");
|
strcpy(alterReq.user, "u3");
|
||||||
strcpy(alterReq.pass, "");
|
strcpy(alterReq.pass, "");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -242,10 +232,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.user, "u4");
|
strcpy(alterReq.user, "u4");
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -258,10 +247,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.user, "u3");
|
strcpy(alterReq.user, "u3");
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -275,10 +263,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
alterReq.superUser = 1;
|
alterReq.superUser = 1;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -291,10 +278,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.user, "u3");
|
strcpy(alterReq.user, "u3");
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -307,10 +293,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.user, "u3");
|
strcpy(alterReq.user, "u3");
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -324,10 +309,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
strcpy(alterReq.dbname, "d1");
|
strcpy(alterReq.dbname, "d1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -371,10 +355,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
strcpy(alterReq.dbname, "1.d2");
|
strcpy(alterReq.dbname, "1.d2");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -388,10 +371,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
strcpy(alterReq.dbname, "1.d2");
|
strcpy(alterReq.dbname, "1.d2");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -401,17 +383,16 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
{
|
{
|
||||||
SGetUserAuthReq authReq = {0};
|
SGetUserAuthReq authReq = {0};
|
||||||
strcpy(authReq.user, "u3");
|
strcpy(authReq.user, "u3");
|
||||||
int32_t contLen = tSerializeSGetUserAuthReq(NULL, &authReq);
|
int32_t contLen = tSerializeSGetUserAuthReq(NULL, 0, &authReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSGetUserAuthReq(pReq, contLen, &authReq);
|
||||||
tSerializeSGetUserAuthReq(&pBuf, &authReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_GET_USER_AUTH, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_GET_USER_AUTH, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
||||||
SGetUserAuthRsp authRsp = {0};
|
SGetUserAuthRsp authRsp = {0};
|
||||||
tDeserializeSGetUserAuthRsp(pRsp->pCont, &authRsp);
|
tDeserializeSGetUserAuthRsp(pRsp->pCont, pRsp->contLen, &authRsp);
|
||||||
EXPECT_STREQ(authRsp.user, "u3");
|
EXPECT_STREQ(authRsp.user, "u3");
|
||||||
EXPECT_EQ(authRsp.superAuth, 1);
|
EXPECT_EQ(authRsp.superAuth, 1);
|
||||||
int32_t numOfReadDbs = taosHashGetSize(authRsp.readDbs);
|
int32_t numOfReadDbs = taosHashGetSize(authRsp.readDbs);
|
||||||
|
@ -433,10 +414,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
strcpy(alterReq.dbname, "1.d2");
|
strcpy(alterReq.dbname, "1.d2");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -447,10 +427,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
SDropUserReq dropReq = {0};
|
SDropUserReq dropReq = {0};
|
||||||
strcpy(dropReq.user, "u3");
|
strcpy(dropReq.user, "u3");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSDropUserReq(NULL, &dropReq);
|
int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSDropUserReq(pReq, contLen, &dropReq);
|
||||||
tSerializeSDropUserReq(&pBuf, &dropReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -467,10 +446,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
|
||||||
SDropUserReq dropReq = {0};
|
SDropUserReq dropReq = {0};
|
||||||
strcpy(dropReq.user, "");
|
strcpy(dropReq.user, "");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSDropUserReq(NULL, &dropReq);
|
int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSDropUserReq(pReq, contLen, &dropReq);
|
||||||
tSerializeSDropUserReq(&pBuf, &dropReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -481,10 +459,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
|
||||||
SDropUserReq dropReq = {0};
|
SDropUserReq dropReq = {0};
|
||||||
strcpy(dropReq.user, "u4");
|
strcpy(dropReq.user, "u4");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSDropUserReq(NULL, &dropReq);
|
int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSDropUserReq(pReq, contLen, &dropReq);
|
||||||
tSerializeSDropUserReq(&pBuf, &dropReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -496,10 +473,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
|
||||||
strcpy(createReq.user, "u1");
|
strcpy(createReq.user, "u1");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, contLen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -510,10 +486,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
|
||||||
SDropUserReq dropReq = {0};
|
SDropUserReq dropReq = {0};
|
||||||
strcpy(dropReq.user, "u1");
|
strcpy(dropReq.user, "u1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSDropUserReq(NULL, &dropReq);
|
int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSDropUserReq(pReq, contLen, &dropReq);
|
||||||
tSerializeSDropUserReq(&pBuf, &dropReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -533,10 +508,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
|
||||||
strcpy(createReq.user, "u1");
|
strcpy(createReq.user, "u1");
|
||||||
strcpy(createReq.pass, "p1");
|
strcpy(createReq.pass, "p1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, contLen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -548,10 +522,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
|
||||||
strcpy(createReq.user, "u2");
|
strcpy(createReq.user, "u2");
|
||||||
strcpy(createReq.pass, "p2");
|
strcpy(createReq.pass, "p2");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, contLen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -583,10 +556,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
|
||||||
strcpy(alterReq.user, "u1");
|
strcpy(alterReq.user, "u1");
|
||||||
strcpy(alterReq.pass, "p2");
|
strcpy(alterReq.pass, "p2");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSAlterUserReq(pReq, contLen, &alterReq);
|
||||||
tSerializeSAlterUserReq(&pBuf, &alterReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -616,10 +588,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
|
||||||
SDropUserReq dropReq = {0};
|
SDropUserReq dropReq = {0};
|
||||||
strcpy(dropReq.user, "u1");
|
strcpy(dropReq.user, "u1");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSDropUserReq(NULL, &dropReq);
|
int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
void* pBuf = pReq;
|
tSerializeSDropUserReq(pReq, contLen, &dropReq);
|
||||||
tSerializeSDropUserReq(&pBuf, &dropReq);
|
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
|
|
@ -12,7 +12,7 @@ SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseContext* pParseCtx, SMsgBuf*
|
||||||
SCreateDbReq* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseContext *pCtx, SMsgBuf* pMsgBuf);
|
SCreateDbReq* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseContext *pCtx, SMsgBuf* pMsgBuf);
|
||||||
char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* len, SParseContext* pParseCtx, SMsgBuf* pMsgBuf);
|
char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* len, SParseContext* pParseCtx, SMsgBuf* pMsgBuf);
|
||||||
char* buildDropStableReq(SSqlInfo* pInfo, int32_t* len, SParseContext* pParseCtx, SMsgBuf* pMsgBuf);
|
char* buildDropStableReq(SSqlInfo* pInfo, int32_t* len, SParseContext* pParseCtx, SMsgBuf* pMsgBuf);
|
||||||
SCreateDnodeReq *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf);
|
char* buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf);
|
||||||
SDropDnodeReq *buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf);
|
char* buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf);
|
||||||
|
|
||||||
#endif // TDENGINE_ASTTOMSG_H
|
#endif // TDENGINE_ASTTOMSG_H
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "parserInt.h"
|
|
||||||
#include "astGenerator.h"
|
#include "astGenerator.h"
|
||||||
|
#include "parserInt.h"
|
||||||
#include "parserUtil.h"
|
#include "parserUtil.h"
|
||||||
|
|
||||||
char* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen) {
|
char* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen) {
|
||||||
|
@ -16,15 +16,14 @@ char* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id,
|
||||||
strncpy(createReq.pass, pUser->passwd.z, pUser->passwd.n);
|
strncpy(createReq.pass, pUser->passwd.z, pUser->passwd.n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tlen = tSerializeSCreateUserReq(NULL, &createReq);
|
int32_t tlen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||||
void* pReq = malloc(tlen);
|
void* pReq = malloc(tlen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateUserReq(pReq, tlen, &createReq);
|
||||||
tSerializeSCreateUserReq(&pBuf, &createReq);
|
|
||||||
*outputLen = tlen;
|
*outputLen = tlen;
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
@ -63,15 +62,14 @@ char* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tlen = tSerializeSCreateAcctReq(NULL, &createReq);
|
int32_t tlen = tSerializeSCreateAcctReq(NULL, 0, &createReq);
|
||||||
void* pReq = malloc(tlen);
|
void* pReq = malloc(tlen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* pBuf = pReq;
|
tSerializeSCreateAcctReq(pReq, tlen, &createReq);
|
||||||
tSerializeSCreateAcctReq(&pBuf, &createReq);
|
|
||||||
*outputLen = tlen;
|
*outputLen = tlen;
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
@ -86,20 +84,19 @@ char* buildDropUserMsg(SSqlInfo* pInfo, int32_t* msgLen, int64_t id, char* msgBu
|
||||||
|
|
||||||
strncpy(dropReq.user, pName->z, pName->n);
|
strncpy(dropReq.user, pName->z, pName->n);
|
||||||
|
|
||||||
int32_t tlen = tSerializeSDropUserReq(NULL, &dropReq);
|
int32_t tlen = tSerializeSDropUserReq(NULL, 0, &dropReq);
|
||||||
void* pReq = malloc(tlen);
|
void* pReq = malloc(tlen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* pBuf = pReq;
|
tSerializeSDropUserReq(pReq, tlen, &dropReq);
|
||||||
tSerializeSDropUserReq(&pBuf, &dropReq);
|
|
||||||
*msgLen = tlen;
|
*msgLen = tlen;
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseContext *pCtx, SMsgBuf* pMsgBuf) {
|
SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseContext* pCtx, SMsgBuf* pMsgBuf) {
|
||||||
SShowReq* pShowMsg = calloc(1, sizeof(SShowReq));
|
SShowReq* pShowMsg = calloc(1, sizeof(SShowReq));
|
||||||
if (pShowMsg == NULL) {
|
if (pShowMsg == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -158,27 +155,27 @@ static int32_t setKeepOption(SCreateDbReq* pMsg, const SCreateDbInfo* pCreateDb,
|
||||||
if (pKeep != NULL) {
|
if (pKeep != NULL) {
|
||||||
size_t s = taosArrayGetSize(pKeep);
|
size_t s = taosArrayGetSize(pKeep);
|
||||||
#ifdef _STORAGE
|
#ifdef _STORAGE
|
||||||
if (s >= 4 ||s <= 0) {
|
if (s >= 4 || s <= 0) {
|
||||||
#else
|
#else
|
||||||
if (s != 1) {
|
if (s != 1) {
|
||||||
#endif
|
#endif
|
||||||
return buildInvalidOperationMsg(pMsgBuf, msg1);
|
return buildInvalidOperationMsg(pMsgBuf, msg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// tListI* p0 = taosArrayGet(pKeep, 0);
|
// tListI* p0 = taosArrayGet(pKeep, 0);
|
||||||
// tVariantListItem* p1 = (s > 1) ? taosArrayGet(pKeep, 1) : p0;
|
// tVariantListItem* p1 = (s > 1) ? taosArrayGet(pKeep, 1) : p0;
|
||||||
// tVariantListItem* p2 = (s > 2) ? taosArrayGet(pKeep, 2) : p1;
|
// tVariantListItem* p2 = (s > 2) ? taosArrayGet(pKeep, 2) : p1;
|
||||||
//
|
//
|
||||||
// if ((int32_t)p0->pVar.i64 <= 0 || (int32_t)p1->pVar.i64 <= 0 || (int32_t)p2->pVar.i64 <= 0) {
|
// if ((int32_t)p0->pVar.i64 <= 0 || (int32_t)p1->pVar.i64 <= 0 || (int32_t)p2->pVar.i64 <= 0) {
|
||||||
// return buildInvalidOperationMsg(pMsgBuf, msg2);
|
// return buildInvalidOperationMsg(pMsgBuf, msg2);
|
||||||
// }
|
// }
|
||||||
// if (!(((int32_t)p0->pVar.i64 <= (int32_t)p1->pVar.i64) && ((int32_t)p1->pVar.i64 <= (int32_t)p2->pVar.i64))) {
|
// if (!(((int32_t)p0->pVar.i64 <= (int32_t)p1->pVar.i64) && ((int32_t)p1->pVar.i64 <= (int32_t)p2->pVar.i64))) {
|
||||||
// return buildInvalidOperationMsg(pMsgBuf, msg3);
|
// return buildInvalidOperationMsg(pMsgBuf, msg3);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// pMsg->daysToKeep0 = htonl((int32_t)p0->pVar.i64);
|
// pMsg->daysToKeep0 = htonl((int32_t)p0->pVar.i64);
|
||||||
// pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64);
|
// pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64);
|
||||||
// pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64);
|
// pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -189,7 +186,7 @@ static int32_t setTimePrecision(SCreateDbReq* pMsg, const SCreateDbInfo* pCreate
|
||||||
|
|
||||||
pMsg->precision = TSDB_TIME_PRECISION_MILLI; // millisecond by default
|
pMsg->precision = TSDB_TIME_PRECISION_MILLI; // millisecond by default
|
||||||
|
|
||||||
SToken* pToken = (SToken*) &pCreateDbInfo->precision;
|
SToken* pToken = (SToken*)&pCreateDbInfo->precision;
|
||||||
if (pToken->n > 0) {
|
if (pToken->n > 0) {
|
||||||
pToken->n = strdequote(pToken->z);
|
pToken->n = strdequote(pToken->z);
|
||||||
|
|
||||||
|
@ -213,20 +210,20 @@ static int32_t setTimePrecision(SCreateDbReq* pMsg, const SCreateDbInfo* pCreate
|
||||||
|
|
||||||
static void doSetDbOptions(SCreateDbReq* pMsg, const SCreateDbInfo* pCreateDb) {
|
static void doSetDbOptions(SCreateDbReq* pMsg, const SCreateDbInfo* pCreateDb) {
|
||||||
pMsg->cacheBlockSize = htonl(pCreateDb->cacheBlockSize);
|
pMsg->cacheBlockSize = htonl(pCreateDb->cacheBlockSize);
|
||||||
pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks);
|
pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks);
|
||||||
pMsg->daysPerFile = htonl(pCreateDb->daysPerFile);
|
pMsg->daysPerFile = htonl(pCreateDb->daysPerFile);
|
||||||
pMsg->commitTime = htonl((int32_t)pCreateDb->commitTime);
|
pMsg->commitTime = htonl((int32_t)pCreateDb->commitTime);
|
||||||
pMsg->minRows = htonl(pCreateDb->minRowsPerBlock);
|
pMsg->minRows = htonl(pCreateDb->minRowsPerBlock);
|
||||||
pMsg->maxRows = htonl(pCreateDb->maxRowsPerBlock);
|
pMsg->maxRows = htonl(pCreateDb->maxRowsPerBlock);
|
||||||
pMsg->fsyncPeriod = htonl(pCreateDb->fsyncPeriod);
|
pMsg->fsyncPeriod = htonl(pCreateDb->fsyncPeriod);
|
||||||
pMsg->compression = (int8_t) pCreateDb->compressionLevel;
|
pMsg->compression = (int8_t)pCreateDb->compressionLevel;
|
||||||
pMsg->walLevel = (char)pCreateDb->walLevel;
|
pMsg->walLevel = (char)pCreateDb->walLevel;
|
||||||
pMsg->replications = pCreateDb->replica;
|
pMsg->replications = pCreateDb->replica;
|
||||||
pMsg->quorum = pCreateDb->quorum;
|
pMsg->quorum = pCreateDb->quorum;
|
||||||
pMsg->ignoreExist = pCreateDb->ignoreExists;
|
pMsg->ignoreExist = pCreateDb->ignoreExists;
|
||||||
pMsg->update = pCreateDb->update;
|
pMsg->update = pCreateDb->update;
|
||||||
pMsg->cacheLastRow = pCreateDb->cachelast;
|
pMsg->cacheLastRow = pCreateDb->cachelast;
|
||||||
pMsg->numOfVgroups = htonl(pCreateDb->numOfVgroups);
|
pMsg->numOfVgroups = htonl(pCreateDb->numOfVgroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t setDbOptions(SCreateDbReq* pCreateDbMsg, const SCreateDbInfo* pCreateDbSql, SMsgBuf* pMsgBuf) {
|
int32_t setDbOptions(SCreateDbReq* pCreateDbMsg, const SCreateDbInfo* pCreateDbSql, SMsgBuf* pMsgBuf) {
|
||||||
|
@ -243,7 +240,7 @@ int32_t setDbOptions(SCreateDbReq* pCreateDbMsg, const SCreateDbInfo* pCreateDbS
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCreateDbReq* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseContext *pCtx, SMsgBuf* pMsgBuf) {
|
SCreateDbReq* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseContext* pCtx, SMsgBuf* pMsgBuf) {
|
||||||
SCreateDbReq* pCreateMsg = calloc(1, sizeof(SCreateDbReq));
|
SCreateDbReq* pCreateMsg = calloc(1, sizeof(SCreateDbReq));
|
||||||
if (setDbOptions(pCreateMsg, pCreateDbInfo, pMsgBuf) != TSDB_CODE_SUCCESS) {
|
if (setDbOptions(pCreateMsg, pCreateDbInfo, pMsgBuf) != TSDB_CODE_SUCCESS) {
|
||||||
tfree(pCreateMsg);
|
tfree(pCreateMsg);
|
||||||
|
@ -323,7 +320,7 @@ char* buildDropStableReq(SSqlInfo* pInfo, int32_t* len, SParseContext* pParseCtx
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCreateDnodeReq *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf) {
|
char* buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf) {
|
||||||
const char* msg1 = "invalid host name (name too long, maximum length 128)";
|
const char* msg1 = "invalid host name (name too long, maximum length 128)";
|
||||||
const char* msg2 = "dnode name can not be string";
|
const char* msg2 = "dnode name can not be string";
|
||||||
const char* msg3 = "port should be an integer that is less than 65535 and greater than 0";
|
const char* msg3 = "port should be an integer that is less than 65535 and greater than 0";
|
||||||
|
@ -355,33 +352,44 @@ SCreateDnodeReq *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCreateDnodeReq *pCreate = (SCreateDnodeReq *) calloc(1, sizeof(SCreateDnodeReq));
|
SCreateDnodeReq createReq = {0};
|
||||||
if (pCreate == NULL) {
|
|
||||||
buildInvalidOperationMsg(pMsgBuf, msg4);
|
strncpy(createReq.fqdn, id->z, id->n);
|
||||||
|
createReq.port = val;
|
||||||
|
|
||||||
|
int32_t tlen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||||
|
void* pReq = malloc(tlen);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pCreate->fqdn, id->z, id->n);
|
tSerializeSCreateDnodeReq(pReq, tlen, &createReq);
|
||||||
pCreate->port = htonl(val);
|
*len = tlen;
|
||||||
|
return pReq;
|
||||||
*len = sizeof(SCreateDnodeReq);
|
|
||||||
return pCreate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDropDnodeReq *buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf) {
|
char* buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf) {
|
||||||
|
SDropDnodeReq dropReq = {0};
|
||||||
|
|
||||||
SToken* pzName = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
SToken* pzName = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||||
|
|
||||||
char* end = NULL;
|
char* end = NULL;
|
||||||
SDropDnodeReq * pDrop = (SDropDnodeReq *)calloc(1, sizeof(SDropDnodeReq));
|
dropReq.dnodeId = strtoll(pzName->z, &end, 10);
|
||||||
pDrop->dnodeId = strtoll(pzName->z, &end, 10);
|
|
||||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
|
||||||
*len = sizeof(SDropDnodeReq);
|
|
||||||
|
|
||||||
if (end - pzName->z != pzName->n) {
|
if (end - pzName->z != pzName->n) {
|
||||||
buildInvalidOperationMsg(pMsgBuf, "invalid dnode id");
|
buildInvalidOperationMsg(pMsgBuf, "invalid dnode id");
|
||||||
tfree(pDrop);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pDrop;
|
int32_t tlen = tSerializeSDropDnodeReq(NULL, 0, &dropReq);
|
||||||
|
void* pReq = malloc(tlen);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tSerializeSDropDnodeReq(pReq, tlen, &dropReq);
|
||||||
|
*len = tlen;
|
||||||
|
return pReq;
|
||||||
}
|
}
|
Loading…
Reference in New Issue