|
@@ -2136,18 +2136,36 @@ func ProduceWindow() {
|
|
}
|
|
}
|
|
|
|
|
|
func saveTimeWindow(faultLabel string, faultHappenTime string, lastTimeWindow *commonEntity.TimeWindow) {
|
|
func saveTimeWindow(faultLabel string, faultHappenTime string, lastTimeWindow *commonEntity.TimeWindow) {
|
|
|
|
+ var taskBeforeTime, taskAfterTime, taskMaxTime int
|
|
|
|
+ {
|
|
|
|
+ if commonConfig.PlatformConfig.TaskBeforeTime == 0 {
|
|
|
|
+ taskBeforeTime = 5
|
|
|
|
+ } else {
|
|
|
|
+ taskBeforeTime = commonConfig.PlatformConfig.TaskBeforeTime
|
|
|
|
+ }
|
|
|
|
+ if commonConfig.PlatformConfig.TaskAfterTime == 0 {
|
|
|
|
+ taskAfterTime = 4
|
|
|
|
+ } else {
|
|
|
|
+ taskAfterTime = commonConfig.PlatformConfig.TaskAfterTime
|
|
|
|
+ }
|
|
|
|
+ if commonConfig.PlatformConfig.TaskMaxTime == 0 {
|
|
|
|
+ taskMaxTime = 60
|
|
|
|
+ } else {
|
|
|
|
+ taskMaxTime = commonConfig.PlatformConfig.TaskMaxTime
|
|
|
|
+ }
|
|
|
|
+ }
|
|
saveTimeWindowMutex.Lock()
|
|
saveTimeWindowMutex.Lock()
|
|
defer saveTimeWindowMutex.Unlock()
|
|
defer saveTimeWindowMutex.Unlock()
|
|
masterTopics, slaveTopics := getTopicsOfNode(faultLabel)
|
|
masterTopics, slaveTopics := getTopicsOfNode(faultLabel)
|
|
if lastTimeWindow == nil || util.TimeCustom1GreaterTimeCustom2(faultHappenTime, lastTimeWindow.TimeWindowEnd) { // 如果是不在旧故障窗口内,添加一个新窗口
|
|
if lastTimeWindow == nil || util.TimeCustom1GreaterTimeCustom2(faultHappenTime, lastTimeWindow.TimeWindowEnd) { // 如果是不在旧故障窗口内,添加一个新窗口
|
|
- exceptBegin := util.TimeCustomChange(faultHappenTime, -commonConfig.PlatformConfig.TaskBeforeTime)
|
|
|
|
|
|
+ exceptBegin := util.TimeCustomChange(faultHappenTime, -taskBeforeTime)
|
|
finalTimeWindowBegin := ""
|
|
finalTimeWindowBegin := ""
|
|
if util.TimeCustom1LessEqualThanTimeCustom2(exceptBegin, latestTimeWindowEnd) { // 窗口最早时间不能早于上一个窗口结束时间
|
|
if util.TimeCustom1LessEqualThanTimeCustom2(exceptBegin, latestTimeWindowEnd) { // 窗口最早时间不能早于上一个窗口结束时间
|
|
finalTimeWindowBegin = latestTimeWindowEnd
|
|
finalTimeWindowBegin = latestTimeWindowEnd
|
|
} else {
|
|
} else {
|
|
finalTimeWindowBegin = exceptBegin
|
|
finalTimeWindowBegin = exceptBegin
|
|
}
|
|
}
|
|
- latestTimeWindowEnd = util.TimeCustomChange(faultHappenTime, commonConfig.PlatformConfig.TaskAfterTime)
|
|
|
|
|
|
+ latestTimeWindowEnd = util.TimeCustomChange(faultHappenTime, taskAfterTime)
|
|
newTimeWindow := commonEntity.TimeWindow{
|
|
newTimeWindow := commonEntity.TimeWindow{
|
|
FaultTime: faultHappenTime,
|
|
FaultTime: faultHappenTime,
|
|
TimeWindowBegin: finalTimeWindowBegin,
|
|
TimeWindowBegin: finalTimeWindowBegin,
|
|
@@ -2164,9 +2182,9 @@ func saveTimeWindow(faultLabel string, faultHappenTime string, lastTimeWindow *c
|
|
commonEntity.TimeWindowProducerQueueMutex.RLock()
|
|
commonEntity.TimeWindowProducerQueueMutex.RLock()
|
|
defer commonEntity.TimeWindowProducerQueueMutex.RUnlock()
|
|
defer commonEntity.TimeWindowProducerQueueMutex.RUnlock()
|
|
// 更新故障窗口end时间
|
|
// 更新故障窗口end时间
|
|
- expectEnd := util.TimeCustomChange(faultHappenTime, commonConfig.PlatformConfig.TaskAfterTime) // 窗口期望关闭时间是触发时间加上后置时间
|
|
|
|
|
|
+ expectEnd := util.TimeCustomChange(faultHappenTime, taskAfterTime) // 窗口期望关闭时间是触发时间加上后置时间
|
|
expectLength := util.CalculateDifferenceOfTimeCustom(lastTimeWindow.TimeWindowBegin, expectEnd)
|
|
expectLength := util.CalculateDifferenceOfTimeCustom(lastTimeWindow.TimeWindowBegin, expectEnd)
|
|
- if expectLength < commonConfig.PlatformConfig.TaskMaxTime {
|
|
|
|
|
|
+ if expectLength < taskMaxTime {
|
|
latestTimeWindowEnd = expectEnd
|
|
latestTimeWindowEnd = expectEnd
|
|
lastTimeWindow.TimeWindowEnd = latestTimeWindowEnd
|
|
lastTimeWindow.TimeWindowEnd = latestTimeWindowEnd
|
|
lastTimeWindow.Length = util.CalculateDifferenceOfTimeCustom(lastTimeWindow.TimeWindowBegin, lastTimeWindow.TimeWindowEnd)
|
|
lastTimeWindow.Length = util.CalculateDifferenceOfTimeCustom(lastTimeWindow.TimeWindowBegin, lastTimeWindow.TimeWindowEnd)
|