|
@@ -29,15 +29,14 @@ var (
|
|
DM *datamap //
|
|
DM *datamap //
|
|
HM *historymap //判重数据
|
|
HM *historymap //判重数据
|
|
lastid = ""
|
|
lastid = ""
|
|
- /*
|
|
|
|
- 5da3f31aa5cb26b9b798d3aa
|
|
|
|
- */
|
|
|
|
|
|
+
|
|
//正则筛选相关
|
|
//正则筛选相关
|
|
FilterRegTitle = regexp.MustCompile("^_$")
|
|
FilterRegTitle = regexp.MustCompile("^_$")
|
|
FilterRegTitle_1 = regexp.MustCompile("^_$")
|
|
FilterRegTitle_1 = regexp.MustCompile("^_$")
|
|
FilterRegTitle_2 = regexp.MustCompile("^_$")
|
|
FilterRegTitle_2 = regexp.MustCompile("^_$")
|
|
|
|
|
|
isMerger bool //是否合并
|
|
isMerger bool //是否合并
|
|
|
|
+ Is_Sort bool //是否排序
|
|
threadNum int //线程数量
|
|
threadNum int //线程数量
|
|
SiteMap map[string]map[string]interface{} //站点map
|
|
SiteMap map[string]map[string]interface{} //站点map
|
|
idtype, sid, eid string //测试人员判重使用
|
|
idtype, sid, eid string //测试人员判重使用
|
|
@@ -60,7 +59,6 @@ func init() {
|
|
}
|
|
}
|
|
mgo.InitPool()
|
|
mgo.InitPool()
|
|
extract = mconf["extract"].(string)
|
|
extract = mconf["extract"].(string)
|
|
-
|
|
|
|
dupdays = util.IntAllDef(Sysconfig["dupdays"], 3)
|
|
dupdays = util.IntAllDef(Sysconfig["dupdays"], 3)
|
|
//加载数据
|
|
//加载数据
|
|
DM = NewDatamap(dupdays, lastid)
|
|
DM = NewDatamap(dupdays, lastid)
|
|
@@ -68,6 +66,7 @@ func init() {
|
|
FilterRegTitle_1 = regexp.MustCompile(util.ObjToString(Sysconfig["specialtitle_1"]))
|
|
FilterRegTitle_1 = regexp.MustCompile(util.ObjToString(Sysconfig["specialtitle_1"]))
|
|
FilterRegTitle_2 = regexp.MustCompile(util.ObjToString(Sysconfig["specialtitle_2"]))
|
|
FilterRegTitle_2 = regexp.MustCompile(util.ObjToString(Sysconfig["specialtitle_2"]))
|
|
isMerger = Sysconfig["isMerger"].(bool)
|
|
isMerger = Sysconfig["isMerger"].(bool)
|
|
|
|
+ Is_Sort = Sysconfig["isSort"].(bool)
|
|
threadNum = util.IntAllDef(Sysconfig["threads"], 1)
|
|
threadNum = util.IntAllDef(Sysconfig["threads"], 1)
|
|
|
|
|
|
//站点配置
|
|
//站点配置
|
|
@@ -107,9 +106,9 @@ func mainT() {
|
|
ObjectId("5df5071ce9d1f601e495fa54")
|
|
ObjectId("5df5071ce9d1f601e495fa54")
|
|
ObjectId("5e09c05f0cf41612e0626abc")
|
|
ObjectId("5e09c05f0cf41612e0626abc")
|
|
*/
|
|
*/
|
|
- sid = "5df5071ce9d1f601e495fa54"
|
|
|
|
- eid = "5e09c05f0cf41612e0626abc"
|
|
|
|
-
|
|
|
|
|
|
+ log.Println("测试开始")
|
|
|
|
+ sid = "5da3f31aa5cb26b9b798d3aa"
|
|
|
|
+ eid = "5da418c4a5cb26b9b7e3e9a6"
|
|
mapinfo := map[string]interface{}{}
|
|
mapinfo := map[string]interface{}{}
|
|
if sid == "" || eid == "" {
|
|
if sid == "" || eid == "" {
|
|
log.Println("sid,eid参数不能为空")
|
|
log.Println("sid,eid参数不能为空")
|
|
@@ -118,7 +117,7 @@ func mainT() {
|
|
mapinfo["gtid"] = sid
|
|
mapinfo["gtid"] = sid
|
|
mapinfo["lteid"] = eid
|
|
mapinfo["lteid"] = eid
|
|
mapinfo["stop"] = "true"
|
|
mapinfo["stop"] = "true"
|
|
- task([]byte{}, mapinfo)
|
|
|
|
|
|
+ historyTask([]byte{}, mapinfo)
|
|
time.Sleep(10 * time.Second)
|
|
time.Sleep(10 * time.Second)
|
|
}
|
|
}
|
|
func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
|
|
func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
|
|
@@ -183,12 +182,16 @@ func task(data []byte, mapInfo map[string]interface{}) {
|
|
log.Println(mgo.DbName, extract, q)
|
|
log.Println(mgo.DbName, extract, q)
|
|
sess := mgo.GetMgoConn()
|
|
sess := mgo.GetMgoConn()
|
|
defer mgo.DestoryMongoConn(sess)
|
|
defer mgo.DestoryMongoConn(sess)
|
|
- //it := sess.DB(mgo.DbName).C(extract).Find(&q).Sort("publishtime").Iter()
|
|
|
|
|
|
+
|
|
|
|
+ //是否排序
|
|
it := sess.DB(mgo.DbName).C(extract).Find(&q).Iter()
|
|
it := sess.DB(mgo.DbName).C(extract).Find(&q).Iter()
|
|
|
|
+ if Is_Sort {
|
|
|
|
+ it = sess.DB(mgo.DbName).C(extract).Find(&q).Sort("publishtime").Iter()
|
|
|
|
+ }
|
|
|
|
+ //it = sess.DB(mgo.DbName).C(extract).Find(&q).Iter()
|
|
updateExtract := [][]map[string]interface{}{}
|
|
updateExtract := [][]map[string]interface{}{}
|
|
log.Println("线程数:", threadNum)
|
|
log.Println("线程数:", threadNum)
|
|
pool := make(chan bool, threadNum)
|
|
pool := make(chan bool, threadNum)
|
|
-
|
|
|
|
wg := &sync.WaitGroup{}
|
|
wg := &sync.WaitGroup{}
|
|
//mapLock := &sync.Mutex{}
|
|
//mapLock := &sync.Mutex{}
|
|
n, repeateN := 0, 0
|
|
n, repeateN := 0, 0
|
|
@@ -397,11 +400,15 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
minTime, maxTime := int64(0), int64(0)
|
|
minTime, maxTime := int64(0), int64(0)
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); {
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); {
|
|
//取出最大最小时间
|
|
//取出最大最小时间
|
|
- if minTime == 0 || maxTime == 0 && util.Int64All(tmp["publishtime"]) != 0 {
|
|
|
|
- minTime = util.Int64All(tmp["publishtime"])
|
|
|
|
- maxTime = util.Int64All(tmp["publishtime"])
|
|
|
|
|
|
+ info_time:=tmp["comeintime"]
|
|
|
|
+ if Is_Sort {
|
|
|
|
+ info_time = tmp["publishtime"]
|
|
|
|
+ }
|
|
|
|
+ if minTime == 0 || maxTime == 0 && util.Int64All(info_time) != 0 {
|
|
|
|
+ minTime = util.Int64All(info_time)
|
|
|
|
+ maxTime = util.Int64All(info_time)
|
|
} else {
|
|
} else {
|
|
- t := util.Int64All(tmp["publishtime"])
|
|
|
|
|
|
+ t := util.Int64All(info_time)
|
|
if t < minTime && t != 0 {
|
|
if t < minTime && t != 0 {
|
|
minTime = t
|
|
minTime = t
|
|
}
|
|
}
|
|
@@ -412,7 +419,7 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
}
|
|
}
|
|
//时间不正确时
|
|
//时间不正确时
|
|
if minTime == 0 && maxTime == 0 {
|
|
if minTime == 0 && maxTime == 0 {
|
|
- log.Println("段数据区间 publishtime不符合")
|
|
|
|
|
|
+ log.Println("段数据区间 不符合")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
fmt.Println("最小时间==", minTime, "最大时间==", maxTime)
|
|
fmt.Println("最小时间==", minTime, "最大时间==", maxTime)
|
|
@@ -442,7 +449,12 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
log.Println(mgo.DbName, extract, q_history)
|
|
log.Println(mgo.DbName, extract, q_history)
|
|
- it_history := sess_history.DB(mgo.DbName).C(extract).Find(&q_history).Sort("publishtime").Iter()
|
|
|
|
|
|
+
|
|
|
|
+ //是否排序
|
|
|
|
+ it_history := sess_history.DB(mgo.DbName).C(extract).Find(&q_history).Iter()
|
|
|
|
+ if Is_Sort {
|
|
|
|
+ it_history = sess_history.DB(mgo.DbName).C(extract).Find(&q_history).Sort("publishtime").Iter()
|
|
|
|
+ }
|
|
updateExtract := [][]map[string]interface{}{}
|
|
updateExtract := [][]map[string]interface{}{}
|
|
log.Println("线程数:", threadNum)
|
|
log.Println("线程数:", threadNum)
|
|
pool := make(chan bool, threadNum)
|
|
pool := make(chan bool, threadNum)
|