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_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_delete(taos_counter_t *self, char *key);
|
||||
#endif // TAOS_COUNTER_H
|
||||
|
|
|
@ -120,25 +120,33 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
|||
taosArrayDestroy(pVloads);
|
||||
}
|
||||
|
||||
int vmCleanExpriedSamples(SVnodeMgmt *pMgmt) {
|
||||
void vmCleanExpriedSamples(SVnodeMgmt *pMgmt) {
|
||||
int list_size = taos_counter_get_keys_size(tsInsertCounter);
|
||||
if (list_size == 0) return 0;
|
||||
if (list_size == 0) return;
|
||||
int32_t *vgroup_ids;
|
||||
char **keys;
|
||||
taos_counter_get_vgroup_ids(tsInsertCounter, &keys, &vgroup_ids);
|
||||
int r = 0;
|
||||
(void)taosThreadRwlockWrlock(&pMgmt->lock);
|
||||
r = taos_counter_get_vgroup_ids(tsInsertCounter, &keys, &vgroup_ids, &list_size);
|
||||
if (r) {
|
||||
dError("failed to get vgroup ids");
|
||||
return;
|
||||
}
|
||||
(void)taosThreadRwlockRdlock(&pMgmt->lock);
|
||||
for (int i = 0; i < list_size; i++) {
|
||||
int32_t vgroup_id = vgroup_ids[i];
|
||||
void *vnode = taosHashGet(pMgmt->hash, &vgroup_id, sizeof(int32_t));
|
||||
if (vnode == NULL) {
|
||||
r = taos_counter_delete(tsInsertCounter, keys[i]);
|
||||
if (r) {
|
||||
dError("failed to delete key:%s", keys[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
||||
taosMemoryFree(vgroup_ids);
|
||||
taosMemoryFree(keys);
|
||||
return r;
|
||||
return;
|
||||
}
|
||||
|
||||
static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||
|
|
|
@ -39,7 +39,7 @@ void vmGetVnodeLoadsLite(void *pMgmt, SMonVloadInfo *pInfo);
|
|||
void mmGetMnodeLoads(void *pMgmt, SMonMloadInfo *pInfo);
|
||||
void qmGetQnodeLoads(void *pMgmt, SQnodeLoad *pInfo);
|
||||
|
||||
int vmCleanExpriedSamples(void *pMgmt);
|
||||
void vmCleanExpriedSamples(void *pMgmt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "audit.h"
|
||||
#include "dmMgmt.h"
|
||||
#include "dmNodes.h"
|
||||
#include "audit.h"
|
||||
|
||||
static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
|
||||
pInfo->protocol = 1;
|
||||
|
@ -52,14 +52,15 @@ static void dmGetDmMonitorInfo(SDnode *pDnode) {
|
|||
monSetDmInfo(&dmInfo);
|
||||
}
|
||||
|
||||
int dmCleanExpriedSamples(SDnode *pDnode) {
|
||||
void dmCleanExpriedSamples(SDnode *pDnode) {
|
||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE];
|
||||
if (dmMarkWrapper(pWrapper) == 0) {
|
||||
if (pWrapper->pMgmt != NULL) {
|
||||
return vmCleanExpriedSamples(pWrapper->pMgmt);
|
||||
vmCleanExpriedSamples(pWrapper->pMgmt);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
dmReleaseWrapper(pWrapper);
|
||||
return;
|
||||
}
|
||||
|
||||
static void dmGetDmMonitorInfoBasic(SDnode *pDnode) {
|
||||
|
@ -134,8 +135,8 @@ void dmSendMonitorReport() {
|
|||
}
|
||||
|
||||
void dmMonitorCleanExpiredSamples() {
|
||||
if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
|
||||
dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort);
|
||||
if (!tsEnableMonitor) return;
|
||||
dTrace("clean monitor expired samples");
|
||||
|
||||
SDnode *pDnode = dmInstance();
|
||||
(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_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);
|
||||
if (self == NULL) return 1;
|
||||
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;
|
||||
taos_linked_list_t *key_list = self->samples->keys;
|
||||
*list_size = key_list->size;
|
||||
int r = 0;
|
||||
*vgroup_ids = (int32_t *)taos_malloc(key_list->size * sizeof(int32_t));
|
||||
*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;
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue