From 0dbce1e883b16ba25adabd041c4dd5f4b26e9e29 Mon Sep 17 00:00:00 2001 From: Ashwin <ashwin2007ray@gmail.com> Date: Wed, 30 Mar 2016 00:59:34 +1100 Subject: [PATCH] Handled error, copyright change, use WriteRune --- cluster/.predicates.go.swp | Bin 0 -> 12288 bytes cluster/cluster.go | 26 ------------------ cluster/doc.go | 25 +++++++++++++++++ cluster/ipList.go | 5 ++++ cluster/{predicateList.go => predicates.go} | 8 +++++- ...edicateList_test.go => predicates_test.go} | 2 +- posting/list.go | 3 +- 7 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 cluster/.predicates.go.swp delete mode 100644 cluster/cluster.go create mode 100644 cluster/ipList.go rename cluster/{predicateList.go => predicates.go} (86%) rename cluster/{predicateList_test.go => predicates_test.go} (98%) diff --git a/cluster/.predicates.go.swp b/cluster/.predicates.go.swp new file mode 100644 index 0000000000000000000000000000000000000000..77a879eba4ebea7a80ae37bf9f581cc7c262d141 GIT binary patch literal 12288 zcmeI2&2QX97{(_YKwBsv_y^v)huC3bZ_=ujQuVO;YF7!HDw_{QRfT5lS??%b+l*(k z8<meEXE<=-3gV6g2SB2TD_5j~K;puQ8z)q$63;l!$0{P6sm9W?YtOv%&NIK)IV5?z zjh)t;bko1iaJ|adUmrZ#*?WA6O})SvFZv^y&Nmu26+bld|8hmK;(32Il7&{XJJceY zjl{wE;P)mH266V*C{z1Ep~4`Rx<BmtVKxY=Y%;6vf-o5tTBsmbB9bB3qVVJFe0Dox z30MLb6S&N-&CfMV%vI+Kz5d$v#o>0=60ig;0ZYIVummgtOTZGa1fD4ZI-g?i<3!I@ zrz-yrfcvTH`S`nfv|pBhC143y0+xU!U<p_PmVhN-30MM_fF<xhB)}uaeyTC{{Uw;k z|NoDF|9|=lW4}O;p^u>s<U!NWlb0F$8~OrDp{vkuml^vO`WpHQ`V#sK`V{&E`Uv_E zN}x5U1>J?}&>PV6(4Q|c_9OHS^bi_Di_i_|I&=-1g8q1su}9E%(C5$?>OgbQQ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@@ -/* - * 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 916b1b53..450e81e6 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 00000000..2eae35a3 --- /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 fa576778..f7ff4c52 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 d7f74e56..43263a82 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 07a08876..6f7ae008 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) } -- GitLab