Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Vanadium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
Himabindu Pucha | f9ec56f | 2015-06-02 11:34:05 -0700 | [diff] [blame] | 5 | package interfaces |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 6 | |
Himabindu Pucha | 12e1a12 | 2015-06-08 15:59:09 -0700 | [diff] [blame] | 7 | import ( |
Adam Sadovsky | f2efeb5 | 2015-08-31 14:17:49 -0700 | [diff] [blame] | 8 | wire "v.io/v23/services/syncbase/nosql" |
Sergey Rogulenko | c2e60f6 | 2015-06-23 14:50:58 -0700 | [diff] [blame] | 9 | "v.io/v23/security/access" |
Himabindu Pucha | 12e1a12 | 2015-06-08 15:59:09 -0700 | [diff] [blame] | 10 | ) |
| 11 | |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 12 | // Sync defines methods for data exchange between Syncbases. |
| 13 | // TODO(hpucha): Flesh this out further. |
| 14 | type Sync interface { |
Jatin Lodhia | 456b81f | 2015-10-05 17:21:28 -0700 | [diff] [blame^] | 15 | // GetTime returns metadata related to syncbase clock like syncbase clock |
| 16 | // timestamps, last NTP timestamp, num reboots, etc. |
| 17 | GetTime(req TimeReq, initiator string) (TimeResp | error) |
| 18 | |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 19 | // GetDeltas returns the responder's current generation vector and all |
| 20 | // the missing log records when compared to the initiator's generation |
Himabindu Pucha | b41fc14 | 2015-09-10 17:10:57 -0700 | [diff] [blame] | 21 | // vector for one Database for either SyncGroup metadata or data. |
| 22 | GetDeltas(req DeltaReq, initiator string) stream<_, DeltaResp> error {access.Read} |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 23 | |
| 24 | // SyncGroup-related methods. |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 25 | |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame] | 26 | // PublishSyncGroup is invoked on the SyncGroup name (typically served |
| 27 | // by a "central" peer) to publish the SyncGroup. It takes the name of |
| 28 | // Syncbase doing the publishing (the publisher) and returns the name |
| 29 | // of the Syncbase where the SyncGroup is published (the publishee). |
| 30 | // This allows the publisher and the publishee to learn of each other. |
| 31 | // When a SyncGroup is published, the publishee is given the SyncGroup |
| 32 | // metadata, its current version at the publisher, and the current |
| 33 | // SyncGroup generation vector. The generation vector serves as a |
| 34 | // checkpoint at the time of publishing. The publishing proceeds |
| 35 | // asynchronously, and the publishee learns the SyncGroup history |
| 36 | // through the routine p2p sync process and determines when it has |
| 37 | // caught up to the level of knowledge at the time of publishing using |
| 38 | // the checkpointed generation vector. Until that point, the publishee |
| 39 | // locally deems the SyncGroup to be in a pending state and does not |
| 40 | // mutate it. Thus it locally rejects SyncGroup joins or updates to |
| 41 | // its spec until it is caught up on the SyncGroup history. |
| 42 | PublishSyncGroup(publisher string, sg SyncGroup, version string, genvec PrefixGenVector) (string | error) {access.Write} |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 43 | |
Himabindu Pucha | 12e1a12 | 2015-06-08 15:59:09 -0700 | [diff] [blame] | 44 | // JoinSyncGroupAtAdmin is invoked by a prospective SyncGroup member's |
| 45 | // Syncbase on a SyncGroup admin. It checks whether the requestor is |
| 46 | // allowed to join the named SyncGroup, and if so, adds the requestor to |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame] | 47 | // the SyncGroup. It returns a copy of the updated SyncGroup metadata, |
| 48 | // its version, and the SyncGroup generation vector at the time of the |
| 49 | // join. Similar to the PublishSyncGroup scenario, the joiner at that |
| 50 | // point does not have the SyncGroup history and locally deems it to be |
| 51 | // in a pending state and does not mutate it. This means it rejects |
| 52 | // local updates to the SyncGroup spec or, if it were also an admin on |
| 53 | // the SyncGroup, it would reject SyncGroup joins until it is caught up |
| 54 | // on the SyncGroup history through p2p sync. |
| 55 | JoinSyncGroupAtAdmin(sgName, joinerName string, myInfo wire.SyncGroupMemberInfo) (sg SyncGroup, version string, genvec PrefixGenVector | error) {access.Read} |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 56 | |
| 57 | // BlobSync methods. |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 58 | |
| 59 | // HaveBlob verifies that the peer has the requested blob, and if |
| 60 | // present, returns its size. |
| 61 | HaveBlob(br wire.BlobRef) (int64 | error) |
| 62 | |
| 63 | // FetchBlob fetches the requested blob. |
| 64 | FetchBlob(br wire.BlobRef) stream<_, []byte> error |
| 65 | |
| 66 | // Methods for incremental blob transfer. The transfer starts with the |
| 67 | // receiver making a FetchBlobRecipe call to the sender for a given |
| 68 | // BlobRef. The sender, in turn, sends the chunk hashes of all the |
| 69 | // chunks that make up the requested blob (blob recipe). The receiver |
| 70 | // looks up the chunk hashes in its local blob store, and identifies the |
| 71 | // missing ones. The receiver then fetches the missing chunks using a |
| 72 | // FetchChunks call from the sender. Finally, the receiver finishes the |
| 73 | // blob fetch by combining the chunks obtained over the network with the |
| 74 | // already available local chunks as per the blob recipe. |
| 75 | FetchBlobRecipe(br wire.BlobRef) stream<_, ChunkHash> error |
| 76 | FetchChunks() stream<ChunkHash, ChunkData> error |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 77 | } |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame] | 78 | |
| 79 | error ( |
| 80 | DupSyncGroupPublish(name string) {"en": "duplicate publish on SyncGroup: {name}"} |
| 81 | ) |