|
@@ -141,36 +141,41 @@ func getTopicsOfNode(faultLabel string) (masterTopics []string, slaveTopics []st
|
|
|
return faultCodeTopics, nil
|
|
|
}
|
|
|
|
|
|
-// 判断采集包数量是否超过限额
|
|
|
+// 判断是否可采集数据
|
|
|
func canCollect() bool {
|
|
|
- responseString, err := commonUtil.HttpPostJsonWithHeaders(
|
|
|
- commonConfig.CloudConfig.CollectLimit.Url,
|
|
|
- map[string]string{"Authorization": "U9yKpD6kZZDDe4LFKK6myAxBUT1XRrDM"},
|
|
|
- map[string]string{
|
|
|
- "snCode": commonConfig.LocalConfig.SecretKey,
|
|
|
- "collectLimitDay": util.ToString(commonConfig.CloudConfig.CollectLimit.Day),
|
|
|
- "collectLimitWeek": util.ToString(commonConfig.CloudConfig.CollectLimit.Week),
|
|
|
- "collectLimitMonth": util.ToString(commonConfig.CloudConfig.CollectLimit.Month),
|
|
|
- "collectLimitYear": util.ToString(commonConfig.CloudConfig.CollectLimit.Year),
|
|
|
- },
|
|
|
- )
|
|
|
- if err != nil {
|
|
|
- c_log.GlobalLogger.Error("发送http请求获取是否允许采集失败:", err)
|
|
|
- return false
|
|
|
- }
|
|
|
- // 解析JSON字符串到Response结构体
|
|
|
- var resp entity.Response
|
|
|
- err = json.Unmarshal([]byte(responseString), &resp)
|
|
|
- if err != nil {
|
|
|
- c_log.GlobalLogger.Error("解析是否允许采集接口返回结果失败:", err)
|
|
|
- return false
|
|
|
- }
|
|
|
- if resp.Code != 200 { // 不是200 代表不允许采集
|
|
|
- c_log.GlobalLogger.Info("采集数量已超过限额,当前周期内不再采集。", resp.Code)
|
|
|
- return false
|
|
|
+ // 如果开启了采集频率限制,则云端判断采集数量是否超过限额
|
|
|
+ if commonConfig.LocalConfig.CollectLimitFlag == 1 {
|
|
|
+ responseString, err := commonUtil.HttpPostJsonWithHeaders(
|
|
|
+ commonConfig.CloudConfig.CollectLimit.Url,
|
|
|
+ map[string]string{"Authorization": "U9yKpD6kZZDDe4LFKK6myAxBUT1XRrDM"},
|
|
|
+ map[string]string{
|
|
|
+ "snCode": commonConfig.LocalConfig.SecretKey,
|
|
|
+ "collectLimitDay": util.ToString(commonConfig.CloudConfig.CollectLimit.Day),
|
|
|
+ "collectLimitWeek": util.ToString(commonConfig.CloudConfig.CollectLimit.Week),
|
|
|
+ "collectLimitMonth": util.ToString(commonConfig.CloudConfig.CollectLimit.Month),
|
|
|
+ "collectLimitYear": util.ToString(commonConfig.CloudConfig.CollectLimit.Year),
|
|
|
+ },
|
|
|
+ )
|
|
|
+ if err != nil {
|
|
|
+ c_log.GlobalLogger.Error("发送http请求获取是否允许采集失败:", err)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 解析JSON字符串到Response结构体
|
|
|
+ var resp entity.Response
|
|
|
+ err = json.Unmarshal([]byte(responseString), &resp)
|
|
|
+ if err != nil {
|
|
|
+ c_log.GlobalLogger.Error("解析是否允许采集接口返回结果失败:", err)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if resp.Code != 200 { // 不是200 代表不允许采集
|
|
|
+ c_log.GlobalLogger.Info("采集数量已超过限额,当前周期内不再采集。", resp.Code)
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ // 本地判断是否存在正在处理的数据
|
|
|
if len(entity.TimeWindowConsumerQueue) != 0 {
|
|
|
- c_log.GlobalLogger.Info("存在正在处理的数据,此次不再采集。", resp.Code)
|
|
|
+ c_log.GlobalLogger.Info("存在正在处理的数据,此次不再采集。")
|
|
|
return false
|
|
|
}
|
|
|
|