提交 0ac592fb 编写于 作者: dengyihao's avatar dengyihao

add inuse to vgroupinfo

上级 65b32c38
...@@ -64,7 +64,7 @@ static void tscIpSetHtons(SRpcIpSet *s) { ...@@ -64,7 +64,7 @@ static void tscIpSetHtons(SRpcIpSet *s) {
} }
} }
bool tscIpSetIsEqual(SRpcIpSet *s1, SRpcIpSet *s2) { bool tscIpSetIsEqual(SRpcIpSet *s1, SRpcIpSet *s2) {
if (s1->numOfIps != s2->numOfIps /*|| s1->inUse != s1->inUse*/) { if (s1->numOfIps != s2->numOfIps || s1->inUse != s2->inUse) {
return false; return false;
} }
for (int32_t i = 0; i < s1->numOfIps; i++) { for (int32_t i = 0; i < s1->numOfIps; i++) {
...@@ -88,7 +88,8 @@ static void tscDumpIpSetFromVgroupInfo(SCMVgroupInfo *pVgroupInfo, SRpcIpSet *pI ...@@ -88,7 +88,8 @@ static void tscDumpIpSetFromVgroupInfo(SCMVgroupInfo *pVgroupInfo, SRpcIpSet *pI
if (vgId) { if (vgId) {
*vgId = pVgroupInfo->vgId; *vgId = pVgroupInfo->vgId;
} }
pIpSet->inUse = 0; int8_t inUse = pVgroupInfo->inUse;
pIpSet->inUse = (inUse >= 0 && inUse < TSDB_MAX_REPLICA) ? inUse: 0;
pIpSet->numOfIps = pVgroupInfo->numOfIps; pIpSet->numOfIps = pVgroupInfo->numOfIps;
for (int32_t i = 0; i < pVgroupInfo->numOfIps; ++i) { for (int32_t i = 0; i < pVgroupInfo->numOfIps; ++i) {
strncpy(pIpSet->fqdn[i], pVgroupInfo->ipAddr[i].fqdn, TSDB_FQDN_LEN); strncpy(pIpSet->fqdn[i], pVgroupInfo->ipAddr[i].fqdn, TSDB_FQDN_LEN);
...@@ -104,7 +105,8 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcIpSet *pIpSet) { ...@@ -104,7 +105,8 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcIpSet *pIpSet) {
SCMVgroupInfo *pVgroupInfo = &pTableMetaInfo->pTableMeta->vgroupInfo; SCMVgroupInfo *pVgroupInfo = &pTableMetaInfo->pTableMeta->vgroupInfo;
taosCorBeginWrite(&pVgroupInfo->version); taosCorBeginWrite(&pVgroupInfo->version);
//TODO(dengyihao), dont care vgid //TODO(dengyihao), dont care vgid
pVgroupInfo->inUse = pIpSet->inUse;
pVgroupInfo->numOfIps = pIpSet->numOfIps; pVgroupInfo->numOfIps = pIpSet->numOfIps;
for (int32_t i = 0; pVgroupInfo->numOfIps; i++) { for (int32_t i = 0; pVgroupInfo->numOfIps; i++) {
strncpy(pVgroupInfo->ipAddr[i].fqdn, pIpSet->fqdn[i], TSDB_FQDN_LEN); strncpy(pVgroupInfo->ipAddr[i].fqdn, pIpSet->fqdn[i], TSDB_FQDN_LEN);
...@@ -1897,6 +1899,7 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) { ...@@ -1897,6 +1899,7 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) {
//just init, no need to lock //just init, no need to lock
SCMVgroupInfo *pVgroups = &pInfo->vgroupList->vgroups[j]; SCMVgroupInfo *pVgroups = &pInfo->vgroupList->vgroups[j];
pVgroups->version = 0; pVgroups->version = 0;
pVgroups->inUse = 0;
pVgroups->vgId = htonl(pVgroups->vgId); pVgroups->vgId = htonl(pVgroups->vgId);
assert(pVgroups->numOfIps >= 1); assert(pVgroups->numOfIps >= 1);
for (int32_t k = 0; k < pVgroups->numOfIps; ++k) { for (int32_t k = 0; k < pVgroups->numOfIps; ++k) {
......
...@@ -649,6 +649,7 @@ typedef struct SCMSTableVgroupMsg { ...@@ -649,6 +649,7 @@ typedef struct SCMSTableVgroupMsg {
typedef struct { typedef struct {
int32_t version; int32_t version;
int32_t vgId; int32_t vgId;
int8_t inUse;
int8_t numOfIps; int8_t numOfIps;
SIpAddr ipAddr[TSDB_MAX_REPLICA]; SIpAddr ipAddr[TSDB_MAX_REPLICA];
} SCMVgroupInfo; } SCMVgroupInfo;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册