diff --git a/cluster/.predicates.go.swp b/cluster/.predicates.go.swp new file mode 100644 index 0000000000000000000000000000000000000000..77a879eba4ebea7a80ae37bf9f581cc7c262d141 Binary files /dev/null and b/cluster/.predicates.go.swp differ diff --git a/cluster/cluster.go b/cluster/cluster.go deleted file mode 100644 index 26e45ace703ac7d8d93562ccca9d80a8041e1d50..0000000000000000000000000000000000000000 --- a/cluster/cluster.go +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2016 DGraph Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package cluster - -func Init() { - //TODO::Code to start a RAFT group -} - -func Join() { - // TODO::Code when a new node joins the cluster -} diff --git a/cluster/doc.go b/cluster/doc.go index 916b1b53b9f0d4dcc23f2acdd15d61f9a243674f..450e81e6b25122d2d3a77660cd73dd0de2ed8d5d 100644 --- a/cluster/doc.go +++ b/cluster/doc.go @@ -1 +1,26 @@ +/* + * Copyright 201666666 DGraph Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + +This package includes getting the list of predicates that a node serves +and sharing it with other nodes in the cluster. + +A RAFT backed key-value store will maintain a globally consistent +mapping from a given predicate to the information of the node +that serves that predicate +*/ package cluster diff --git a/cluster/ipList.go b/cluster/ipList.go new file mode 100644 index 0000000000000000000000000000000000000000..2eae35a3e46989112f843747cccc5e460a11f5d1 --- /dev/null +++ b/cluster/ipList.go @@ -0,0 +1,5 @@ +package cluster + +type ipList struct { + ip string +} diff --git a/cluster/predicateList.go b/cluster/predicates.go similarity index 86% rename from cluster/predicateList.go rename to cluster/predicates.go index fa57677895389b7ee4b9a78982fa7b2f3efd22a5..f7ff4c529ef1b1e7ba479c4cfc696ef20864bd26 100644 --- a/cluster/predicateList.go +++ b/cluster/predicates.go @@ -21,11 +21,17 @@ import ( "bytes" "github.com/dgraph-io/dgraph/store" + "github.com/dgraph-io/dgraph/x" ) +var glog = x.Log("cluster") + func getPredicate(b []byte) string { buf := bytes.NewBuffer(b) - a, _ := buf.ReadString('|') + a, err := buf.ReadString('|') + if err != nil { + glog.WithField("byte", b).Fatal("error retreiving predicate") + } str := string(a[:len(a)-1]) // omit the trailing '|' return str } diff --git a/cluster/predicateList_test.go b/cluster/predicates_test.go similarity index 98% rename from cluster/predicateList_test.go rename to cluster/predicates_test.go index d7f74e569aa883b8ce78087a690a10fa9dcd11cb..43263a821105b487920c9c8cacb4191bd0747a2f 100644 --- a/cluster/predicateList_test.go +++ b/cluster/predicates_test.go @@ -1,5 +1,5 @@ /* - * Copyright 2015 DGraph Labs, Inc. + * Copyright 2016 DGraph Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/posting/list.go b/posting/list.go index 07a0887638e6286004fd8908743cbaaa545e83cc..6f7ae0088b2b0fdcc7d99f282f6205fcdb6e799c 100644 --- a/posting/list.go +++ b/posting/list.go @@ -105,7 +105,8 @@ func samePosting(a *types.Posting, b *types.Posting) bool { // key = (entity uid, attribute) func Key(uid uint64, attr string) []byte { - buf := bytes.NewBufferString(attr + "|") + buf := bytes.NewBufferString(attr) + buf.WriteRune('|') if err := binary.Write(buf, binary.LittleEndian, uid); err != nil { glog.Fatalf("Error while creating key with attr: %v uid: %v\n", attr, uid) }