zhangjinkun 5 vuotta sitten
vanhempi
commit
4c4d39908d

+ 8 - 3
fullproject/src_dev5/config.json

@@ -1,14 +1,19 @@
 {
-    "loadData":true,
     "mongodbServers": "192.168.3.207:27082",
     "mongodbPoolSize": 10,
     "mongodbName": "cesuo",
     "extractColl": "key1_biddingall",
-    "projectColl": "projectset_0809",
+    "projectColl": "projectset_zjk",
     "jkmail": {
         "to": "zhangjinkun@topnet.net.cn",
         "api": "http://10.171.112.160:19281/_send/_mail"
     },
     "udpport": ":1482",
-    "nextNode": []
+    "nextNode": [
+        {
+            "addr": "172.17.145.163",
+            "port": 1483,
+            "memo": "创建项目索引new"
+        }
+    ]
 }

+ 2 - 1
fullproject/src_dev5/init.go

@@ -22,6 +22,7 @@ var (
 	Sysconfig                map[string]interface{} //读取配置文件
 	MongoTool                mongodb.MongodbSim     //mongodb连接
 	ExtractColl, ProjectColl string                 //抽取表、项目表
+	NextNode                 []interface{}
 )
 
 var (
@@ -61,7 +62,7 @@ func init() {
 	MongoTool.InitPool()
 	ExtractColl = Sysconfig["extractColl"].(string)
 	ProjectColl = Sysconfig["projectColl"].(string)
-
+	NextNode = Sysconfig["nextNode"].([]interface{})
 	udpport, _ := Sysconfig["udpport"].(string)
 	udpclient = mu.UdpClient{Local: udpport, BufSize: 1024}
 	udpclient.Listen(processUdpMsg)

+ 23 - 4
fullproject/src_dev5/task.go

@@ -3,11 +3,12 @@ package main
 import (
 	"encoding/json"
 	"log"
+	mu "mfw/util"
+	"net"
 	"qfw/util"
 	"regexp"
 	"strings"
 	"sync"
-	//"strings"
 	"time"
 
 	"github.com/robfig/cron"
@@ -203,7 +204,6 @@ func (p *ProjectTask) taskQl(udpInfo map[string]interface{}) {
 	if bcon {
 		//生成查询语句执行
 		p.enter(db, coll, map[string]interface{}{})
-
 	}
 }
 
@@ -225,11 +225,13 @@ func (p *ProjectTask) taskZl(udpInfo map[string]interface{}) {
 	}
 	//开始id和结束id
 	q, _ := udpInfo["query"].(map[string]interface{})
+	gtid := udpInfo["gtid"].(string)
+	lteid := udpInfo["lteid"].(string)
 	if q == nil {
 		q = map[string]interface{}{
 			"_id": map[string]interface{}{
-				"$gt":  util.StringTOBsonId(udpInfo["gtid"].(string)),
-				"$lte": util.StringTOBsonId(udpInfo["lteid"].(string)),
+				"$gt":  util.StringTOBsonId(gtid),  //util.StringTOBsonId(udpInfo["gtid"].(string)),
+				"$lte": util.StringTOBsonId(lteid), //util.StringTOBsonId(udpInfo["lteid"].(string)),
 			},
 		}
 	}
@@ -237,7 +239,24 @@ func (p *ProjectTask) taskZl(udpInfo map[string]interface{}) {
 		//生成查询语句执行
 		p.enter(db, coll, q)
 	}
+	nextNode(gtid, lteid, "project")
+}
 
+//通知下个节点nextNode
+func nextNode(gtid, lteid, stype string) {
+	by, _ := json.Marshal(map[string]interface{}{
+		"gtid":  gtid,
+		"lteid": lteid,
+		"stype": stype,
+	})
+	for _, v := range NextNode {
+		if node, ok := v.(map[string]interface{}); ok {
+			udpclient.WriteUdp(by, mu.OP_TYPE_DATA, &net.UDPAddr{
+				IP:   net.ParseIP(node["addr"].(string)),
+				Port: util.IntAll(node["port"]),
+			})
+		}
+	}
 }
 
 func (p *ProjectTask) enter(db, coll string, q map[string]interface{}) {

+ 0 - 5
fullproject/src_dev5/test/t.go

@@ -1,5 +0,0 @@
-package main
-
-func main() {
-
-}