|
@@ -1015,14 +1015,18 @@ func GetSpiderDownloadRateDataNew() {
|
|
|
zero := qu.IntAll(tmp["zero"])
|
|
|
oh_percent := qu.IntAll(tmp["oh_percent"])
|
|
|
lock.Lock()
|
|
|
- if spider := CodeInfoMap[code]; spider != nil {
|
|
|
- spider.ListDownloadAllTimes = alltimes
|
|
|
- spider.ListNoDataTimes = zero
|
|
|
- //含有100%采集,及为采集频率异常(由于7410、7500、7510、7700队列模式节点,不建采集频率异常任务)
|
|
|
- //上轮数据下载不成功,下轮采集会被任务是新数据(应该建下载异常任务)
|
|
|
- if oh_percent > 0 && spider.Model != 0 {
|
|
|
- spider.FrequencyErrTimes++
|
|
|
- spider.ListOhPercentTimes = oh_percent
|
|
|
+ if sp := CodeInfoMap[code]; sp != nil {
|
|
|
+ sp.ListDownloadAllTimes = alltimes
|
|
|
+ sp.ListNoDataTimes = zero
|
|
|
+ //含有100%采集,及为采集频率异常(由于7410、7500、7510、7520、7700队列模式节点,不建采集频率异常任务)
|
|
|
+ //上轮数据下载不成功,下轮采集会被任务当做新数据(应该建下载异常任务)
|
|
|
+ //if oh_percent > 0 && spider.Model != 0 {
|
|
|
+ // sp.FrequencyErrTimes++
|
|
|
+ // sp.ListOhPercentTimes = oh_percent
|
|
|
+ //}
|
|
|
+ if oh_percent > 0 {
|
|
|
+ sp.FrequencyErrTimes++
|
|
|
+ sp.ListOhPercentTimes = oh_percent
|
|
|
}
|
|
|
} else {
|
|
|
logger.Debug("-------------", code)
|
|
@@ -1869,7 +1873,7 @@ func CreateTaskProcess() {
|
|
|
if !moreThanLimit { //不在异常范围,不建该类型任务
|
|
|
continue
|
|
|
}
|
|
|
- } else if spider.Model == 0 && spider.Working == 1 { //老模式,队列模式(7500,7510、7520、7700)有下载异常数据直接建任务
|
|
|
+ } else if spider.Model == 0 { //&& spider.Working == 1 { //老模式,队列模式(7500,7510、7520、7700)有下载异常数据直接建任务
|
|
|
if spider.DownloadFailedNum > 0 { //只有7500,7510、7520、7700出现一条下载异常时,任务状态即为待处理
|
|
|
task.State = 1 //待处理
|
|
|
taskStateOk = true
|
|
@@ -1904,6 +1908,24 @@ func CreateTaskProcess() {
|
|
|
}
|
|
|
}
|
|
|
if spider.Platform == "golua平台" { //lua异常(由于采集频率异常比较特殊固放到最后处理)
|
|
|
+ //6、采集频率异常 errtype:8
|
|
|
+ if spider.ListOhPercentTimes > 0 { //采集频率异常
|
|
|
+ tagTime, ok := spider.TaskTags[fmt.Sprint(TASK_RATEERR)].(int64)
|
|
|
+ if !ok || tagTime < util.GetTime(-7) { //无标签或者上次标记时间不在7天内的建任务
|
|
|
+ //UpdateLuaInfo(spider) //出现采集频率异常,便更新爬虫的frequencyerrtimes、最大页自动加1、重新上架
|
|
|
+ //只有当FrequencyErrTimes>3取采集频率异常,相反优先其他异常类型(采集频率异常且待确认时程序自动处理,人工几乎不介入)
|
|
|
+ //if spider.FrequencyErrTimes > 3 { //爬虫采集频率异常次数大于3次,任务为待处理,否则为待确认
|
|
|
+ // task.State = 1 //待处理
|
|
|
+ // task.ErrType = TASK_RATEERR
|
|
|
+ //} else if len(task.DescribeMap) == 0 { //只有采集频率异常且FrequencyErrTimes<=3
|
|
|
+ // task.State = 0 //待确认
|
|
|
+ // task.ErrType = TASK_RATEERR
|
|
|
+ //}
|
|
|
+ task.State = 1 //待处理
|
|
|
+ task.ErrType = TASK_RATEERR
|
|
|
+ task.DescribeMap[TASK_RATEERR] = "采集频率异常:\n 列表页共采集" + fmt.Sprint(spider.ListDownloadAllTimes) + "轮,其中有" + fmt.Sprint(spider.ListOhPercentTimes) + "轮数据全采\n"
|
|
|
+ }
|
|
|
+ }
|
|
|
//5、列表页异常 errtype:7
|
|
|
listTagTime, ok := spider.TaskTags[fmt.Sprint(TASK_LISTERR)].(int64)
|
|
|
if !ok || listTagTime < util.GetTime(-7) { //无标签或者上次标记时间不在7天内的建任务
|
|
@@ -1927,22 +1949,6 @@ func CreateTaskProcess() {
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
- //6、采集频率异常 errtype:8
|
|
|
- if spider.ListOhPercentTimes > 0 { //采集频率异常
|
|
|
- tagTime, ok := spider.TaskTags[fmt.Sprint(TASK_RATEERR)].(int64)
|
|
|
- if !ok || tagTime < util.GetTime(-7) { //无标签或者上次标记时间不在7天内的建任务
|
|
|
- //UpdateLuaInfo(spider) //出现采集频率异常,便更新爬虫的frequencyerrtimes、最大页自动加1、重新上架
|
|
|
- //只有当FrequencyErrTimes>3取采集频率异常,相反优先其他异常类型(采集频率异常且待确认时程序自动处理,人工几乎不介入)
|
|
|
- if spider.FrequencyErrTimes > 3 { //爬虫采集频率异常次数大于3次,任务为待处理,否则为待确认
|
|
|
- task.State = 1 //待处理
|
|
|
- task.ErrType = TASK_RATEERR
|
|
|
- } else if len(task.DescribeMap) == 0 { //只有采集频率异常且FrequencyErrTimes<=3
|
|
|
- task.State = 0 //待确认
|
|
|
- task.ErrType = TASK_RATEERR
|
|
|
- }
|
|
|
- task.DescribeMap[TASK_RATEERR] = "采集频率异常:\n 列表页共采集" + fmt.Sprint(spider.ListDownloadAllTimes) + "轮,其中有" + fmt.Sprint(spider.ListOhPercentTimes) + "轮数据全采\n"
|
|
|
- }
|
|
|
- }
|
|
|
} else if spider.Platform == "python" { //python异常
|
|
|
for stype, info := range PythonErrTypeInfoMap {
|
|
|
if err := spider.Error[stype]; err != nil {
|
|
@@ -2080,11 +2086,11 @@ func CreateTask(t *Task, sp *Spider, upsertBulk *[][]map[string]interface{}, loc
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- task := (*list)[0] //唯一任务
|
|
|
- state_old := qu.IntAll(task["i_state"]) //历史任务状态
|
|
|
- times_old := qu.IntAll(task["i_times"]) //历史任务次数
|
|
|
- type_old := qu.ObjToString(task["s_type"]) //历史任务异常类型
|
|
|
- urgency_old := qu.ObjToString(task["s_urgency"]) //历史任务紧急度
|
|
|
+ task := (*list)[0] //唯一任务
|
|
|
+ state_old := qu.IntAll(task["i_state"]) //历史任务状态
|
|
|
+ times_old := qu.IntAll(task["i_times"]) //历史任务次数
|
|
|
+ type_old := qu.ObjToString(task["s_type"]) //历史任务异常类型
|
|
|
+ //urgency_old := qu.ObjToString(task["s_urgency"]) //历史任务紧急度
|
|
|
descript_old := qu.ObjToString(task["s_descript"]) //历史任务描述
|
|
|
result := map[string]interface{}{
|
|
|
"i_event": sp.Event,
|
|
@@ -2094,33 +2100,23 @@ func CreateTask(t *Task, sp *Spider, upsertBulk *[][]map[string]interface{}, loc
|
|
|
"i_times": times_old + 1,
|
|
|
"s_descript": descript_old + time.Now().Format(qu.Date_Short_Layout) + "追加描述:------------------------------\n" + descript_new,
|
|
|
}
|
|
|
- if state_old == 0 || state_old == 1 { //如果历史任务状态为待确认、待处理,更新任务信息,其它状态只追加任务描述、任务次数、下载量
|
|
|
- //任务状态state、任务类型s_type
|
|
|
- if state_old == 1 || t.State == 1 { //新任务、历史任务有一个任务状态为待处理,更新后任务状态为待处理
|
|
|
- result["i_state"] = 1
|
|
|
- if t.State == 1 && state_old == 1 { //新任务和历史任务均为待处理时,取异常类型等级高者
|
|
|
- if t.ErrType > qu.IntAll(type_old) {
|
|
|
- result["s_type"] = fmt.Sprint(t.ErrType)
|
|
|
- }
|
|
|
- } else if t.State == 1 { //新任务为待处理历史任务为待确认,取新任务的类型
|
|
|
- result["s_type"] = fmt.Sprint(t.ErrType)
|
|
|
- } /*else if state_old == 1 {
|
|
|
- }*/
|
|
|
- } else if state_old == 0 && t.State == 0 && t.ErrType > qu.IntAll(type_old) { //新任务、历史任务均为待确认,取异常类型等级高者
|
|
|
- result["s_type"] = fmt.Sprint(t.ErrType)
|
|
|
- }
|
|
|
- if times_old >= 3 { //某爬虫第四次建任务时,任务状态变为待处理
|
|
|
+ //urgency := qu.IntAll(urgency_old)
|
|
|
+ //if urgency < 4 {
|
|
|
+ // result["s_urgency"] = fmt.Sprint(urgency + 1)
|
|
|
+ //}
|
|
|
+ ////最迟完成时间
|
|
|
+ //if qu.IntAll(result["i_state"]) == 1 && state_old == 0 { //新任务综合处理后任务状态为待处理,历史任务为待确认时,更新最迟完成时间
|
|
|
+ // result["l_complete"] = util.CompleteTime(fmt.Sprint(urgency + 1))
|
|
|
+ //}
|
|
|
+ //任务状态
|
|
|
+ if state_old == 0 {
|
|
|
+ if t.State == 1 || times_old >= 3 { //当前状态为待处理或者某爬虫第四次建任务时,任务状态变为待处理
|
|
|
result["i_state"] = 1
|
|
|
}
|
|
|
- //任务紧急度urgency
|
|
|
- urgency := qu.IntAll(urgency_old)
|
|
|
- if urgency < 4 {
|
|
|
- result["s_urgency"] = fmt.Sprint(urgency + 1)
|
|
|
- }
|
|
|
- //最迟完成时间
|
|
|
- if qu.IntAll(result["i_state"]) == 1 && state_old == 0 { //新任务综合处理后任务状态为待处理,历史任务为待确认时,更新最迟完成时间
|
|
|
- result["l_complete"] = util.CompleteTime(fmt.Sprint(urgency + 1))
|
|
|
- }
|
|
|
+ }
|
|
|
+ //任务类型
|
|
|
+ if t.ErrType > qu.IntAll(type_old) {
|
|
|
+ result["s_type"] = fmt.Sprint(t.ErrType)
|
|
|
}
|
|
|
update = append(update, map[string]interface{}{"_id": task["_id"]})
|
|
|
update = append(update, map[string]interface{}{"$set": result})
|