From b9dc381ba92999050f57790668b00166f7f376a7 Mon Sep 17 00:00:00 2001 From: Ashwin <ashwin2007ray@gmail.com> Date: Fri, 26 Feb 2016 17:54:54 +1100 Subject: [PATCH] handled uidStore querying which is on instance 0 --- worker/worker.go | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/worker/worker.go b/worker/worker.go index 86992cb1..560b1e32 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -68,21 +68,41 @@ func ProcessTaskOverNetwork(qu []byte) (result []byte, rerr error) { attr := string(q.Attr()) idx := farm.Fingerprint64([]byte(attr)) % numInstances - if idx == instanceIdx { - return ProcessTask(qu) - } else { - pool := pools[idx] - addr := addrs[idx] - query := new(conn.Query) - query.Data = qu - reply := new(conn.Reply) - if err := pool.Call("Worker.ServeTask", query, reply); err != nil { - glog.WithField("call", "Worker.ServeTask").Fatal(err) + + if attr == "_xid_" || attr == "_uid_" { + if instanceIdx == 0 { + return ProcessTask(qu) + } else { // Send the request to instance 0 which has uidstore + pool := pools[0] + addr := addrs[0] + query := new(conn.Query) + query.Data = qu + reply := new(conn.Reply) + if err := pool.Call("Worker.ServeTask", query, reply); err != nil { + glog.WithField("call", "Worker.ServeTask").Fatal(err) + } + glog.WithField("reply", string(reply.Data)).WithField("addr", addr). + Info("Got reply from server") + + return reply.Data, nil } - glog.WithField("reply", string(reply.Data)).WithField("addr", addr). - Info("Got reply from server") + } else { + if idx == instanceIdx { + return ProcessTask(qu) + } else { + pool := pools[idx] + addr := addrs[idx] + query := new(conn.Query) + query.Data = qu + reply := new(conn.Reply) + if err := pool.Call("Worker.ServeTask", query, reply); err != nil { + glog.WithField("call", "Worker.ServeTask").Fatal(err) + } + glog.WithField("reply", string(reply.Data)).WithField("addr", addr). + Info("Got reply from server") - return reply.Data, nil + return reply.Data, nil + } } } -- GitLab