support update enableWhiteList dynamicly
This commit is contained in:
parent
539543b011
commit
8a6d58d339
|
@ -776,7 +776,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
// min free disk space used to check if the disk is full [50MB, 1GB]
|
// min free disk space used to check if the disk is full [50MB, 1GB]
|
||||||
if (cfgAddInt64(pCfg, "minDiskFreeSize", tsMinDiskFreeSize, TFS_MIN_DISK_FREE_SIZE, 1024 * 1024 * 1024, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
if (cfgAddInt64(pCfg, "minDiskFreeSize", tsMinDiskFreeSize, TFS_MIN_DISK_FREE_SIZE, 1024 * 1024 * 1024, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "enableWhiteList", tsEnableWhiteList, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
if (cfgAddBool(pCfg, "enableWhiteList", tsEnableWhiteList, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1;
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -1299,8 +1299,8 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd,
|
int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl,
|
||||||
const char *envFile, char *apolloUrl, SArray *pArgs) {
|
SArray *pArgs) {
|
||||||
if (tsCfg == NULL) osDefaultInit();
|
if (tsCfg == NULL) osDefaultInit();
|
||||||
|
|
||||||
SConfig *pCfg = cfgInit();
|
SConfig *pCfg = cfgInit();
|
||||||
|
|
|
@ -14,9 +14,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include <stdio.h>
|
|
||||||
#include "tjson.h"
|
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
|
#include <stdio.h>
|
||||||
#include "audit.h"
|
#include "audit.h"
|
||||||
#include "mndCluster.h"
|
#include "mndCluster.h"
|
||||||
#include "mndDb.h"
|
#include "mndDb.h"
|
||||||
|
@ -28,9 +27,10 @@
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
#include "mndUser.h"
|
#include "mndUser.h"
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
|
#include "taos_monitor.h"
|
||||||
|
#include "tjson.h"
|
||||||
#include "tmisce.h"
|
#include "tmisce.h"
|
||||||
#include "tunit.h"
|
#include "tunit.h"
|
||||||
#include "taos_monitor.h"
|
|
||||||
|
|
||||||
#define TSDB_DNODE_VER_NUMBER 2
|
#define TSDB_DNODE_VER_NUMBER 2
|
||||||
#define TSDB_DNODE_RESERVE_SIZE 40
|
#define TSDB_DNODE_RESERVE_SIZE 40
|
||||||
|
@ -191,8 +191,8 @@ static SSdbRaw *mndDnodeActionEncode(SDnodeObj *pDnode) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pDnode->fqdn, TSDB_FQDN_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pDnode->fqdn, TSDB_FQDN_LEN, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pDnode->machineId, TSDB_MACHINE_ID_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pDnode->machineId, TSDB_MACHINE_ID_LEN, _OVER)
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_DNODE_RESERVE_SIZE, _OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, TSDB_DNODE_RESERVE_SIZE, _OVER)
|
||||||
SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible
|
SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible
|
||||||
SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible
|
SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible
|
||||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER);
|
SDB_SET_DATALEN(pRaw, dataPos, _OVER);
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
@ -536,49 +536,49 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
||||||
char strClusterId[TSDB_CLUSTER_ID_LEN] = {0};
|
char strClusterId[TSDB_CLUSTER_ID_LEN] = {0};
|
||||||
sprintf(strClusterId, "%"PRId64, pMnode->clusterId);
|
sprintf(strClusterId, "%" PRId64, pMnode->clusterId);
|
||||||
|
|
||||||
if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) {
|
if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tsMonitorLogProtocol){
|
if (tsMonitorLogProtocol) {
|
||||||
mInfo("process statis req,\n %s", statisReq.pCont);
|
mInfo("process statis req,\n %s", statisReq.pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
SJson* pJson = tjsonParse(statisReq.pCont);
|
SJson *pJson = tjsonParse(statisReq.pCont);
|
||||||
|
|
||||||
int32_t ts_size = tjsonGetArraySize(pJson);
|
int32_t ts_size = tjsonGetArraySize(pJson);
|
||||||
|
|
||||||
for(int32_t i = 0; i < ts_size; i++){
|
for (int32_t i = 0; i < ts_size; i++) {
|
||||||
SJson* item = tjsonGetArrayItem(pJson, i);
|
SJson *item = tjsonGetArrayItem(pJson, i);
|
||||||
|
|
||||||
SJson* tables = tjsonGetObjectItem(item, "tables");
|
SJson *tables = tjsonGetObjectItem(item, "tables");
|
||||||
|
|
||||||
int32_t tableSize = tjsonGetArraySize(tables);
|
int32_t tableSize = tjsonGetArraySize(tables);
|
||||||
for(int32_t i = 0; i < tableSize; i++){
|
for (int32_t i = 0; i < tableSize; i++) {
|
||||||
SJson* table = tjsonGetArrayItem(tables, i);
|
SJson *table = tjsonGetArrayItem(tables, i);
|
||||||
|
|
||||||
char tableName[MONITOR_TABLENAME_LEN] = {0};
|
char tableName[MONITOR_TABLENAME_LEN] = {0};
|
||||||
tjsonGetStringValue(table, "name", tableName);
|
tjsonGetStringValue(table, "name", tableName);
|
||||||
|
|
||||||
SJson* metricGroups = tjsonGetObjectItem(table, "metric_groups");
|
SJson *metricGroups = tjsonGetObjectItem(table, "metric_groups");
|
||||||
|
|
||||||
int32_t size = tjsonGetArraySize(metricGroups);
|
int32_t size = tjsonGetArraySize(metricGroups);
|
||||||
for(int32_t i = 0; i < size; i++){
|
for (int32_t i = 0; i < size; i++) {
|
||||||
SJson* item = tjsonGetArrayItem(metricGroups, i);
|
SJson *item = tjsonGetArrayItem(metricGroups, i);
|
||||||
|
|
||||||
SJson* arrayTag = tjsonGetObjectItem(item, "tags");
|
SJson *arrayTag = tjsonGetObjectItem(item, "tags");
|
||||||
|
|
||||||
int32_t tagSize = tjsonGetArraySize(arrayTag);
|
int32_t tagSize = tjsonGetArraySize(arrayTag);
|
||||||
for(int32_t j = 0; j < tagSize; j++){
|
for (int32_t j = 0; j < tagSize; j++) {
|
||||||
SJson* item = tjsonGetArrayItem(arrayTag, j);
|
SJson *item = tjsonGetArrayItem(arrayTag, j);
|
||||||
|
|
||||||
char tagName[MONITOR_TAG_NAME_LEN] = {0};
|
char tagName[MONITOR_TAG_NAME_LEN] = {0};
|
||||||
tjsonGetStringValue(item, "name", tagName);
|
tjsonGetStringValue(item, "name", tagName);
|
||||||
|
|
||||||
if(strncmp(tagName, "cluster_id", MONITOR_TAG_NAME_LEN) == 0) {
|
if (strncmp(tagName, "cluster_id", MONITOR_TAG_NAME_LEN) == 0) {
|
||||||
tjsonDeleteItemFromObject(item, "value");
|
tjsonDeleteItemFromObject(item, "value");
|
||||||
tjsonAddStringToObject(item, "value", strClusterId);
|
tjsonAddStringToObject(item, "value", strClusterId);
|
||||||
}
|
}
|
||||||
|
@ -590,12 +590,12 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
char *pCont = tjsonToString(pJson);
|
char *pCont = tjsonToString(pJson);
|
||||||
monSendContent(pCont);
|
monSendContent(pCont);
|
||||||
|
|
||||||
if(pJson != NULL){
|
if (pJson != NULL) {
|
||||||
tjsonDelete(pJson);
|
tjsonDelete(pJson);
|
||||||
pJson = NULL;
|
pJson = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pCont != NULL){
|
if (pCont != NULL) {
|
||||||
taosMemoryFree(pCont);
|
taosMemoryFree(pCont);
|
||||||
pCont = NULL;
|
pCont = NULL;
|
||||||
}
|
}
|
||||||
|
@ -603,132 +603,132 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
tFreeSStatisReq(&statisReq);
|
tFreeSStatisReq(&statisReq);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SJson* pJson = tjsonParse(statisReq.pCont);
|
SJson* pJson = tjsonParse(statisReq.pCont);
|
||||||
|
|
||||||
int32_t ts_size = tjsonGetArraySize(pJson);
|
int32_t ts_size = tjsonGetArraySize(pJson);
|
||||||
|
|
||||||
for(int32_t i = 0; i < ts_size; i++){
|
for(int32_t i = 0; i < ts_size; i++){
|
||||||
SJson* item = tjsonGetArrayItem(pJson, i);
|
SJson* item = tjsonGetArrayItem(pJson, i);
|
||||||
|
|
||||||
SJson* tables = tjsonGetObjectItem(item, "tables");
|
SJson* tables = tjsonGetObjectItem(item, "tables");
|
||||||
|
|
||||||
int32_t tableSize = tjsonGetArraySize(tables);
|
int32_t tableSize = tjsonGetArraySize(tables);
|
||||||
for(int32_t i = 0; i < tableSize; i++){
|
for(int32_t i = 0; i < tableSize; i++){
|
||||||
SJson* table = tjsonGetArrayItem(tables, i);
|
SJson* table = tjsonGetArrayItem(tables, i);
|
||||||
|
|
||||||
char tableName[MONITOR_TABLENAME_LEN] = {0};
|
char tableName[MONITOR_TABLENAME_LEN] = {0};
|
||||||
tjsonGetStringValue(table, "name", tableName);
|
tjsonGetStringValue(table, "name", tableName);
|
||||||
|
|
||||||
SJson* metricGroups = tjsonGetObjectItem(table, "metric_groups");
|
SJson* metricGroups = tjsonGetObjectItem(table, "metric_groups");
|
||||||
|
|
||||||
int32_t size = tjsonGetArraySize(metricGroups);
|
int32_t size = tjsonGetArraySize(metricGroups);
|
||||||
for(int32_t i = 0; i < size; i++){
|
for(int32_t i = 0; i < size; i++){
|
||||||
SJson* item = tjsonGetArrayItem(metricGroups, i);
|
SJson* item = tjsonGetArrayItem(metricGroups, i);
|
||||||
|
|
||||||
SJson* arrayTag = tjsonGetObjectItem(item, "tags");
|
SJson* arrayTag = tjsonGetObjectItem(item, "tags");
|
||||||
|
|
||||||
int32_t tagSize = tjsonGetArraySize(arrayTag);
|
int32_t tagSize = tjsonGetArraySize(arrayTag);
|
||||||
|
|
||||||
char** labels = taosMemoryMalloc(sizeof(char*) * tagSize);
|
char** labels = taosMemoryMalloc(sizeof(char*) * tagSize);
|
||||||
char** sample_labels = taosMemoryMalloc(sizeof(char*) * tagSize);
|
char** sample_labels = taosMemoryMalloc(sizeof(char*) * tagSize);
|
||||||
|
|
||||||
for(int32_t j = 0; j < tagSize; j++){
|
for(int32_t j = 0; j < tagSize; j++){
|
||||||
SJson* item = tjsonGetArrayItem(arrayTag, j);
|
SJson* item = tjsonGetArrayItem(arrayTag, j);
|
||||||
|
|
||||||
*(labels + j) = taosMemoryMalloc(MONITOR_TAG_NAME_LEN);
|
*(labels + j) = taosMemoryMalloc(MONITOR_TAG_NAME_LEN);
|
||||||
tjsonGetStringValue(item, "name", *(labels + j));
|
tjsonGetStringValue(item, "name", *(labels + j));
|
||||||
|
|
||||||
*(sample_labels + j) = taosMemoryMalloc(MONITOR_TAG_VALUE_LEN);
|
*(sample_labels + j) = taosMemoryMalloc(MONITOR_TAG_VALUE_LEN);
|
||||||
tjsonGetStringValue(item, "value", *(sample_labels + j));
|
tjsonGetStringValue(item, "value", *(sample_labels + j));
|
||||||
if(strncmp(*(labels + j), "cluster_id", MONITOR_TAG_NAME_LEN) == 0) {
|
if(strncmp(*(labels + j), "cluster_id", MONITOR_TAG_NAME_LEN) == 0) {
|
||||||
strncpy(*(sample_labels + j), strClusterId, MONITOR_TAG_VALUE_LEN);
|
strncpy(*(sample_labels + j), strClusterId, MONITOR_TAG_VALUE_LEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SJson* metrics = tjsonGetObjectItem(item, "metrics");
|
SJson* metrics = tjsonGetObjectItem(item, "metrics");
|
||||||
|
|
||||||
int32_t metricLen = tjsonGetArraySize(metrics);
|
int32_t metricLen = tjsonGetArraySize(metrics);
|
||||||
for(int32_t j = 0; j < metricLen; j++){
|
for(int32_t j = 0; j < metricLen; j++){
|
||||||
SJson *item = tjsonGetArrayItem(metrics, j);
|
SJson *item = tjsonGetArrayItem(metrics, j);
|
||||||
|
|
||||||
char name[MONITOR_METRIC_NAME_LEN] = {0};
|
char name[MONITOR_METRIC_NAME_LEN] = {0};
|
||||||
tjsonGetStringValue(item, "name", name);
|
tjsonGetStringValue(item, "name", name);
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
tjsonGetDoubleValue(item, "value", &value);
|
tjsonGetDoubleValue(item, "value", &value);
|
||||||
|
|
||||||
double type = 0;
|
double type = 0;
|
||||||
tjsonGetDoubleValue(item, "type", &type);
|
tjsonGetDoubleValue(item, "type", &type);
|
||||||
|
|
||||||
int32_t metricNameLen = strlen(name) + strlen(tableName) + 2;
|
int32_t metricNameLen = strlen(name) + strlen(tableName) + 2;
|
||||||
char* metricName = taosMemoryMalloc(metricNameLen);
|
char* metricName = taosMemoryMalloc(metricNameLen);
|
||||||
memset(metricName, 0, metricNameLen);
|
memset(metricName, 0, metricNameLen);
|
||||||
sprintf(metricName, "%s:%s", tableName, name);
|
sprintf(metricName, "%s:%s", tableName, name);
|
||||||
|
|
||||||
taos_metric_t* metric = taos_collector_registry_get_metric(metricName);
|
taos_metric_t* metric = taos_collector_registry_get_metric(metricName);
|
||||||
if(metric == NULL){
|
if(metric == NULL){
|
||||||
if(type == 0){
|
|
||||||
metric = taos_counter_new(metricName, "", tagSize, (const char**)labels);
|
|
||||||
}
|
|
||||||
if(type == 1){
|
|
||||||
metric = taos_gauge_new(metricName, "", tagSize, (const char**)labels);
|
|
||||||
}
|
|
||||||
mTrace("fail to get metric from registry, new one metric:%p", metric);
|
|
||||||
|
|
||||||
if(taos_collector_registry_register_metric(metric) == 1){
|
|
||||||
if(type == 0){
|
if(type == 0){
|
||||||
taos_counter_destroy(metric);
|
metric = taos_counter_new(metricName, "", tagSize, (const char**)labels);
|
||||||
}
|
}
|
||||||
if(type == 1){
|
if(type == 1){
|
||||||
taos_gauge_destroy(metric);
|
metric = taos_gauge_new(metricName, "", tagSize, (const char**)labels);
|
||||||
}
|
}
|
||||||
|
mTrace("fail to get metric from registry, new one metric:%p", metric);
|
||||||
|
|
||||||
metric = taos_collector_registry_get_metric(metricName);
|
if(taos_collector_registry_register_metric(metric) == 1){
|
||||||
|
if(type == 0){
|
||||||
|
taos_counter_destroy(metric);
|
||||||
|
}
|
||||||
|
if(type == 1){
|
||||||
|
taos_gauge_destroy(metric);
|
||||||
|
}
|
||||||
|
|
||||||
mTrace("fail to register metric, get metric from registry:%p", metric);
|
metric = taos_collector_registry_get_metric(metricName);
|
||||||
|
|
||||||
|
mTrace("fail to register metric, get metric from registry:%p", metric);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
mTrace("succeed to register metric:%p", metric);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
mTrace("succeed to register metric:%p", metric);
|
mTrace("get metric from registry:%p", metric);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
if(type == 0){
|
||||||
mTrace("get metric from registry:%p", metric);
|
taos_counter_add(metric, value, (const char**)sample_labels);
|
||||||
|
}
|
||||||
|
if(type == 1){
|
||||||
|
taos_gauge_set(metric, value, (const char**)sample_labels);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(metricName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == 0){
|
for(int32_t j = 0; j < tagSize; j++){
|
||||||
taos_counter_add(metric, value, (const char**)sample_labels);
|
taosMemoryFreeClear(*(labels + j));
|
||||||
}
|
taosMemoryFreeClear(*(sample_labels + j));
|
||||||
if(type == 1){
|
|
||||||
taos_gauge_set(metric, value, (const char**)sample_labels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(metricName);
|
taosMemoryFreeClear(sample_labels);
|
||||||
|
taosMemoryFreeClear(labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int32_t j = 0; j < tagSize; j++){
|
|
||||||
taosMemoryFreeClear(*(labels + j));
|
|
||||||
taosMemoryFreeClear(*(sample_labels + j));
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(sample_labels);
|
|
||||||
taosMemoryFreeClear(labels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
code = 0;
|
||||||
|
|
||||||
code = 0;
|
_OVER:
|
||||||
|
if(pJson != NULL){
|
||||||
|
tjsonDelete(pJson);
|
||||||
|
pJson = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
_OVER:
|
tFreeSStatisReq(&statisReq);
|
||||||
if(pJson != NULL){
|
return code;
|
||||||
tjsonDelete(pJson);
|
*/
|
||||||
pJson = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tFreeSStatisReq(&statisReq);
|
|
||||||
return code;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) {
|
static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) {
|
||||||
|
@ -816,8 +816,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||||
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
||||||
bool encryptKeyChanged = pDnode->encryptionKeyChksum != statusReq.clusterCfg.encryptionKeyChksum;
|
bool encryptKeyChanged = pDnode->encryptionKeyChksum != statusReq.clusterCfg.encryptionKeyChksum;
|
||||||
|
bool enableWhiteListChanged = statusReq.clusterCfg.enableWhiteList != (tsEnableWhiteList ? 1 : 0);
|
||||||
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
|
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
|
||||||
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged;
|
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged || enableWhiteListChanged;
|
||||||
|
|
||||||
const STraceId *trace = &pReq->info.traceId;
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||||
|
|
Loading…
Reference in New Issue