resolve comments
This commit is contained in:
parent
81615362c3
commit
97bcdfb86c
|
@ -99,7 +99,7 @@ int taos_counter_inc(taos_counter_t *self, const char **label_values);
|
||||||
*/
|
*/
|
||||||
int taos_counter_add(taos_counter_t *self, double r_value, const char **label_values);
|
int taos_counter_add(taos_counter_t *self, double r_value, const char **label_values);
|
||||||
|
|
||||||
int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vgroup_ids);
|
int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vgroup_ids, int *list_size);
|
||||||
int taos_counter_get_keys_size(taos_counter_t *self);
|
int taos_counter_get_keys_size(taos_counter_t *self);
|
||||||
int taos_counter_delete(taos_counter_t *self, char *key);
|
int taos_counter_delete(taos_counter_t *self, char *key);
|
||||||
#endif // TAOS_COUNTER_H
|
#endif // TAOS_COUNTER_H
|
||||||
|
|
|
@ -120,25 +120,33 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
||||||
taosArrayDestroy(pVloads);
|
taosArrayDestroy(pVloads);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vmCleanExpriedSamples(SVnodeMgmt *pMgmt) {
|
void vmCleanExpriedSamples(SVnodeMgmt *pMgmt) {
|
||||||
int list_size = taos_counter_get_keys_size(tsInsertCounter);
|
int list_size = taos_counter_get_keys_size(tsInsertCounter);
|
||||||
if (list_size == 0) return 0;
|
if (list_size == 0) return;
|
||||||
int32_t *vgroup_ids;
|
int32_t *vgroup_ids;
|
||||||
char **keys;
|
char **keys;
|
||||||
taos_counter_get_vgroup_ids(tsInsertCounter, &keys, &vgroup_ids);
|
int r = 0;
|
||||||
int r = 0;
|
r = taos_counter_get_vgroup_ids(tsInsertCounter, &keys, &vgroup_ids, &list_size);
|
||||||
(void)taosThreadRwlockWrlock(&pMgmt->lock);
|
if (r) {
|
||||||
|
dError("failed to get vgroup ids");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(void)taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
for (int i = 0; i < list_size; i++) {
|
for (int i = 0; i < list_size; i++) {
|
||||||
int32_t vgroup_id = vgroup_ids[i];
|
int32_t vgroup_id = vgroup_ids[i];
|
||||||
void *vnode = taosHashGet(pMgmt->hash, &vgroup_id, sizeof(int32_t));
|
void *vnode = taosHashGet(pMgmt->hash, &vgroup_id, sizeof(int32_t));
|
||||||
if (vnode == NULL) {
|
if (vnode == NULL) {
|
||||||
r = taos_counter_delete(tsInsertCounter, keys[i]);
|
r = taos_counter_delete(tsInsertCounter, keys[i]);
|
||||||
|
if (r) {
|
||||||
|
dError("failed to delete key:%s", keys[i]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
taosMemoryFree(vgroup_ids);
|
taosMemoryFree(vgroup_ids);
|
||||||
taosMemoryFree(keys);
|
taosMemoryFree(keys);
|
||||||
return r;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ void vmGetVnodeLoadsLite(void *pMgmt, SMonVloadInfo *pInfo);
|
||||||
void mmGetMnodeLoads(void *pMgmt, SMonMloadInfo *pInfo);
|
void mmGetMnodeLoads(void *pMgmt, SMonMloadInfo *pInfo);
|
||||||
void qmGetQnodeLoads(void *pMgmt, SQnodeLoad *pInfo);
|
void qmGetQnodeLoads(void *pMgmt, SQnodeLoad *pInfo);
|
||||||
|
|
||||||
int vmCleanExpriedSamples(void *pMgmt);
|
void vmCleanExpriedSamples(void *pMgmt);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "audit.h"
|
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
#include "dmNodes.h"
|
#include "dmNodes.h"
|
||||||
|
#include "audit.h"
|
||||||
|
|
||||||
static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
|
static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
|
||||||
pInfo->protocol = 1;
|
pInfo->protocol = 1;
|
||||||
|
@ -52,14 +52,15 @@ static void dmGetDmMonitorInfo(SDnode *pDnode) {
|
||||||
monSetDmInfo(&dmInfo);
|
monSetDmInfo(&dmInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dmCleanExpriedSamples(SDnode *pDnode) {
|
void dmCleanExpriedSamples(SDnode *pDnode) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE];
|
||||||
if (dmMarkWrapper(pWrapper) == 0) {
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
if (pWrapper->pMgmt != NULL) {
|
if (pWrapper->pMgmt != NULL) {
|
||||||
return vmCleanExpriedSamples(pWrapper->pMgmt);
|
vmCleanExpriedSamples(pWrapper->pMgmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
dmReleaseWrapper(pWrapper);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmGetDmMonitorInfoBasic(SDnode *pDnode) {
|
static void dmGetDmMonitorInfoBasic(SDnode *pDnode) {
|
||||||
|
@ -134,8 +135,8 @@ void dmSendMonitorReport() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmMonitorCleanExpiredSamples() {
|
void dmMonitorCleanExpiredSamples() {
|
||||||
if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
|
if (!tsEnableMonitor) return;
|
||||||
dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort);
|
dTrace("clean monitor expired samples");
|
||||||
|
|
||||||
SDnode *pDnode = dmInstance();
|
SDnode *pDnode = dmInstance();
|
||||||
(void)dmCleanExpriedSamples(pDnode);
|
(void)dmCleanExpriedSamples(pDnode);
|
||||||
|
|
|
@ -68,7 +68,7 @@ int taos_counter_add(taos_counter_t *self, double r_value, const char **label_va
|
||||||
|
|
||||||
int taos_counter_get_keys_size(taos_counter_t *self) { return self->samples->keys->size; }
|
int taos_counter_get_keys_size(taos_counter_t *self) { return self->samples->keys->size; }
|
||||||
|
|
||||||
int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vgroup_ids) {
|
int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vgroup_ids, int *list_size) {
|
||||||
TAOS_TEST_PARA(self != NULL);
|
TAOS_TEST_PARA(self != NULL);
|
||||||
if (self == NULL) return 1;
|
if (self == NULL) return 1;
|
||||||
if (self->type != TAOS_COUNTER) {
|
if (self->type != TAOS_COUNTER) {
|
||||||
|
@ -77,9 +77,12 @@ int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vg
|
||||||
}
|
}
|
||||||
if (self->samples == NULL) return 1;
|
if (self->samples == NULL) return 1;
|
||||||
taos_linked_list_t *key_list = self->samples->keys;
|
taos_linked_list_t *key_list = self->samples->keys;
|
||||||
int r = 0;
|
*list_size = key_list->size;
|
||||||
*vgroup_ids = (int32_t *)taos_malloc(key_list->size * sizeof(int32_t));
|
int r = 0;
|
||||||
*keys = (char **)taos_malloc(key_list->size * sizeof(char *));
|
*vgroup_ids = (int32_t *)taos_malloc(*list_size * sizeof(int32_t));
|
||||||
|
if (vgroup_ids == NULL) return 1;
|
||||||
|
*keys = (char **)taos_malloc(*list_size * sizeof(char *));
|
||||||
|
if (keys == NULL) return 1;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (taos_linked_list_node_t *current_key = key_list->head; current_key != NULL; current_key = current_key->next) {
|
for (taos_linked_list_node_t *current_key = key_list->head; current_key != NULL; current_key = current_key->next) {
|
||||||
char *key = (char *)current_key->item;
|
char *key = (char *)current_key->item;
|
||||||
|
|
Loading…
Reference in New Issue