Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dgraph
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
dgraph
Commits
8a0a2a9a
Commit
8a0a2a9a
authored
9 years ago
by
Manish R Jain
Browse files
Options
Downloads
Patches
Plain Diff
Add a Mutate RPC call in the worker. This would be used to propagate mutations across the cluster.
parent
799450d6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/main.go
+4
-3
4 additions, 3 deletions
server/main.go
worker/worker.go
+35
-1
35 additions, 1 deletion
worker/worker.go
with
39 additions
and
4 deletions
server/main.go
+
4
−
3
View file @
8a0a2a9a
...
...
@@ -50,6 +50,7 @@ var instanceIdx = flag.Uint64("instanceIdx", 0,
"serves only entities whose Fingerprint % numInstance == instanceIdx."
)
var
workers
=
flag
.
String
(
"workers"
,
""
,
"Comma separated list of IP addresses of workers"
)
var
numInstances
uint64
func
addCorsHeaders
(
w
http
.
ResponseWriter
)
{
w
.
Header
()
.
Set
(
"Access-Control-Allow-Origin"
,
"*"
)
...
...
@@ -166,17 +167,17 @@ func main() {
defer
clog
.
Close
()
addrs
:=
strings
.
Split
(
*
workers
,
","
)
numInstances
=
len
(
addrs
)
posting
.
Init
(
clog
)
if
*
instanceIdx
!=
0
{
worker
.
Init
(
ps
,
nil
,
addrs
)
worker
.
Init
(
ps
,
nil
,
addrs
,
*
instanceIdx
)
uid
.
Init
(
nil
)
}
else
{
uidStore
:=
new
(
store
.
Store
)
uidStore
.
Init
(
*
uidDir
)
defer
uidStore
.
Close
()
// Only server instance 0 will have uidStore
worker
.
Init
(
ps
,
uidStore
,
addrs
)
worker
.
Init
(
ps
,
uidStore
,
addrs
,
*
instanceIdx
)
uid
.
Init
(
uidStore
)
}
...
...
This diff is collapsed.
Click to expand it.
worker/worker.go
+
35
−
1
View file @
8a0a2a9a
...
...
@@ -2,6 +2,7 @@ package worker
import
(
"flag"
"fmt"
"io"
"net"
"net/rpc"
...
...
@@ -11,6 +12,7 @@ import (
"github.com/dgraph-io/dgraph/store"
"github.com/dgraph-io/dgraph/task"
"github.com/dgraph-io/dgraph/x"
"github.com/dgryski/go-farm"
"github.com/google/flatbuffers/go"
)
...
...
@@ -21,11 +23,13 @@ var glog = x.Log("worker")
var
dataStore
,
xiduidStore
*
store
.
Store
var
pools
[]
*
conn
.
Pool
var
addrs
[]
string
var
instanceIdx
uint64
func
Init
(
ps
,
xuStore
*
store
.
Store
,
workerList
[]
string
)
{
func
Init
(
ps
,
xuStore
*
store
.
Store
,
workerList
[]
string
,
idx
uint64
)
{
dataStore
=
ps
xiduidStore
=
xuStore
addrs
=
workerList
instanceIdx
=
idx
}
func
Connect
()
{
...
...
@@ -133,6 +137,36 @@ func (w *Worker) Hello(query *conn.Query, reply *conn.Reply) error {
return
nil
}
func
(
w
*
Worker
)
Mutate
(
query
*
conn
.
Query
,
reply
*
conn
.
Reply
)
(
rerr
error
)
{
m
:=
new
(
Mutations
)
if
err
:=
m
.
Decode
(
query
.
Data
);
err
!=
nil
{
return
err
}
left
:=
new
(
Mutations
)
// For now, assume it's all only Set instructions.
for
_
,
edge
:=
range
m
.
Set
{
if
farm
.
Fingerprint64
(
[]
byte
(
edge
.
Attribute
))
%
uint64
(
len
(
addrs
))
!=
instanceIdx
{
glog
.
WithField
(
"instanceIdx"
,
instanceIdx
)
.
WithField
(
"attr"
,
edge
.
Attribute
)
.
Info
(
"Predicate fingerprint doesn't match instanceIdx"
)
return
fmt
.
Errorf
(
"predicate fingerprint doesn't match this instance."
)
}
key
:=
posting
.
Key
(
edge
.
Entity
,
edge
.
Attribute
)
plist
:=
posting
.
GetOrCreate
(
key
,
dataStore
)
if
err
:=
plist
.
AddMutation
(
edge
,
posting
.
Set
);
err
!=
nil
{
left
.
Set
=
append
(
left
.
Set
,
edge
)
glog
.
WithError
(
err
)
.
WithField
(
"edge"
,
edge
)
.
Error
(
"While adding mutation."
)
continue
}
}
reply
.
Data
,
rerr
=
left
.
Encode
()
return
}
func
serveRequests
(
irwc
io
.
ReadWriteCloser
)
{
for
{
sc
:=
&
conn
.
ServerCodec
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment