Documentation ¶
Index ¶
- Constants
- func AddNames(ctx *context.T, ss interfaces.SyncServerMethods, svr rpc.Server) error
- func Close(ss interfaces.SyncServerMethods)
- func New(ctx *context.T, sv interfaces.Service, blobStEngine, blobRootDir string, ...) (*syncService, error)
- func NewSyncDatabase(db interfaces.Database) *syncDatabase
- type BatchInfo
- type BatchInfoTarget
- func (t *BatchInfoTarget) FinishField(_, _ vdl.Target) error
- func (t *BatchInfoTarget) FinishFields(_ vdl.FieldsTarget) error
- func (t *BatchInfoTarget) StartField(name string) (key, field vdl.Target, _ error)
- func (t *BatchInfoTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
- func (t *BatchInfoTarget) ZeroField(name string) error
- type DagNode
- type DagNodeTarget
- func (t *DagNodeTarget) FinishField(_, _ vdl.Target) error
- func (t *DagNodeTarget) FinishFields(_ vdl.FieldsTarget) error
- func (t *DagNodeTarget) StartField(name string) (key, field vdl.Target, _ error)
- func (t *DagNodeTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
- func (t *DagNodeTarget) ZeroField(name string) error
- type DbSyncState
- type DbSyncStateTarget
- func (t *DbSyncStateTarget) FinishField(_, _ vdl.Target) error
- func (t *DbSyncStateTarget) FinishFields(_ vdl.FieldsTarget) error
- func (t *DbSyncStateTarget) StartField(name string) (key, field vdl.Target, _ error)
- func (t *DbSyncStateTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
- func (t *DbSyncStateTarget) ZeroField(name string) error
- type LocalLogRec
- type LocalLogRecTarget
- func (t *LocalLogRecTarget) FinishField(_, _ vdl.Target) error
- func (t *LocalLogRecTarget) FinishFields(_ vdl.FieldsTarget) error
- func (t *LocalLogRecTarget) StartField(name string) (key, field vdl.Target, _ error)
- func (t *LocalLogRecTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
- func (t *LocalLogRecTarget) ZeroField(name string) error
- type SgLocalState
- type SgLocalStateTarget
- func (t *SgLocalStateTarget) FinishField(_, _ vdl.Target) error
- func (t *SgLocalStateTarget) FinishFields(_ vdl.FieldsTarget) error
- func (t *SgLocalStateTarget) StartField(name string) (key, field vdl.Target, _ error)
- func (t *SgLocalStateTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
- func (t *SgLocalStateTarget) ZeroField(name string) error
- type SyncData
- type SyncDataTarget
- func (t *SyncDataTarget) FinishField(_, _ vdl.Target) error
- func (t *SyncDataTarget) FinishFields(_ vdl.FieldsTarget) error
- func (t *SyncDataTarget) StartField(name string) (key, field vdl.Target, _ error)
- func (t *SyncDataTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
- func (t *SyncDataTarget) ZeroField(name string) error
Constants ¶
const ( NoVersion = "" NoBatchId = uint64(0) )
Variables ¶
This section is empty.
Functions ¶
func AddNames ¶
func AddNames(ctx *context.T, ss interfaces.SyncServerMethods, svr rpc.Server) error
AddNames publishes all the names for this Syncbase instance gathered from all the syncgroups it is currently participating in. This is needed when syncbased is restarted so that it can republish itself at the names being used in the syncgroups.
func Close ¶
func Close(ss interfaces.SyncServerMethods)
Close waits for spawned sync threads to shut down, and closes the local blob store handle.
func New ¶
func New(ctx *context.T, sv interfaces.Service, blobStEngine, blobRootDir string, cl *vclock.VClock, publishInNh bool) (*syncService, error)
New creates a new sync module.
Concurrency: sync initializes four goroutines at startup: a "watcher", a "syncer", a "neighborhood scanner", and a "peer manager". The "watcher" thread is responsible for watching the store for changes to its objects. The "syncer" thread is responsible for periodically contacting peers to fetch changes from them. The "neighborhood scanner" thread continuously scans the neighborhood to learn of other Syncbases and syncgroups in its neighborhood. The "peer manager" thread continuously maintains viable peers that the syncer can pick from. In addition, the sync module responds to incoming RPCs from remote sync modules and local clients.
func NewSyncDatabase ¶
func NewSyncDatabase(db interfaces.Database) *syncDatabase
Types ¶
type BatchInfo ¶
BatchInfo holds the information on a write batch:
- The map of syncable (versioned) objects: {oid: version}
- The map of linked objects {oid: version} that were not explicitly written as part of the batch but were reaffirmed during conflict resolution along with other objects written in this batch by the app by choosing "pickLocal" or "pickRemote". NOTE: this map is non empty only for batches created during conflict resolution. Unlike the Objects map, the collection of oid:version present in this map do not point back to this batch. They point to the batches that there were originally created in.
- The total count of batch objects, including non-syncable ones.
TODO(rdaoud): add support to track the read and scan sets.
func (*BatchInfo) FillVDLTarget ¶
func (*BatchInfo) MakeVDLTarget ¶
type BatchInfoTarget ¶
type BatchInfoTarget struct { Value *BatchInfo vdl.TargetBase vdl.FieldsTargetBase // contains filtered or unexported fields }
func (*BatchInfoTarget) FinishField ¶
func (t *BatchInfoTarget) FinishField(_, _ vdl.Target) error
func (*BatchInfoTarget) FinishFields ¶
func (t *BatchInfoTarget) FinishFields(_ vdl.FieldsTarget) error
func (*BatchInfoTarget) StartField ¶
func (t *BatchInfoTarget) StartField(name string) (key, field vdl.Target, _ error)
func (*BatchInfoTarget) StartFields ¶
func (t *BatchInfoTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
func (*BatchInfoTarget) ZeroField ¶
func (t *BatchInfoTarget) ZeroField(name string) error
type DagNode ¶
type DagNode struct { Level uint64 // node distance from root Parents []string // references to parent versions Logrec string // reference to log record BatchId uint64 // ID of a write batch Deleted bool // true if the change was a delete PermId string // ID of the permissions controlling this version PermVers string // current version of the permissions object }
DagNode holds the information on an object mutation in the DAG. The node information is extracted from the log records exchanged between Syncbases. They are also stored in the DAG node to improve DAG traversal for conflict resolution and pruning without having to fetch the full log record.
func (*DagNode) MakeVDLTarget ¶
type DagNodeTarget ¶
type DagNodeTarget struct { Value *DagNode vdl.TargetBase vdl.FieldsTargetBase // contains filtered or unexported fields }
func (*DagNodeTarget) FinishField ¶
func (t *DagNodeTarget) FinishField(_, _ vdl.Target) error
func (*DagNodeTarget) FinishFields ¶
func (t *DagNodeTarget) FinishFields(_ vdl.FieldsTarget) error
func (*DagNodeTarget) StartField ¶
func (t *DagNodeTarget) StartField(name string) (key, field vdl.Target, _ error)
func (*DagNodeTarget) StartFields ¶
func (t *DagNodeTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
func (*DagNodeTarget) ZeroField ¶
func (t *DagNodeTarget) ZeroField(name string) error
type DbSyncState ¶
type DbSyncState struct { GenVecs interfaces.Knowledge // knowledge capturing the locally-known generations of remote peers for data in Database. SgGenVecs interfaces.Knowledge // knowledge capturing the locally-known generations of remote peers for syncgroups in Database. IsPaused bool // tracks whether sync is paused by client. }
DbSyncState represents the persistent sync state of a Database.
func (*DbSyncState) FillVDLTarget ¶
func (*DbSyncState) MakeVDLTarget ¶
func (m *DbSyncState) MakeVDLTarget() vdl.Target
func (DbSyncState) VDLIsZero ¶
func (x DbSyncState) VDLIsZero() bool
type DbSyncStateTarget ¶
type DbSyncStateTarget struct { Value *DbSyncState vdl.TargetBase vdl.FieldsTargetBase // contains filtered or unexported fields }
func (*DbSyncStateTarget) FinishField ¶
func (t *DbSyncStateTarget) FinishField(_, _ vdl.Target) error
func (*DbSyncStateTarget) FinishFields ¶
func (t *DbSyncStateTarget) FinishFields(_ vdl.FieldsTarget) error
func (*DbSyncStateTarget) StartField ¶
func (t *DbSyncStateTarget) StartField(name string) (key, field vdl.Target, _ error)
func (*DbSyncStateTarget) StartFields ¶
func (t *DbSyncStateTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
func (*DbSyncStateTarget) ZeroField ¶
func (t *DbSyncStateTarget) ZeroField(name string) error
type LocalLogRec ¶
type LocalLogRec struct { Metadata interfaces.LogRecMetadata Pos uint64 // position in the Database log. }
LocalLogRec represents the persistent local state of a log record. Metadata is synced across peers, while pos is local-only.
func (*LocalLogRec) FillVDLTarget ¶
func (*LocalLogRec) MakeVDLTarget ¶
func (m *LocalLogRec) MakeVDLTarget() vdl.Target
func (LocalLogRec) VDLIsZero ¶
func (x LocalLogRec) VDLIsZero() bool
type LocalLogRecTarget ¶
type LocalLogRecTarget struct { Value *LocalLogRec vdl.TargetBase vdl.FieldsTargetBase // contains filtered or unexported fields }
func (*LocalLogRecTarget) FinishField ¶
func (t *LocalLogRecTarget) FinishField(_, _ vdl.Target) error
func (*LocalLogRecTarget) FinishFields ¶
func (t *LocalLogRecTarget) FinishFields(_ vdl.FieldsTarget) error
func (*LocalLogRecTarget) StartField ¶
func (t *LocalLogRecTarget) StartField(name string) (key, field vdl.Target, _ error)
func (*LocalLogRecTarget) StartFields ¶
func (t *LocalLogRecTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
func (*LocalLogRecTarget) ZeroField ¶
func (t *LocalLogRecTarget) ZeroField(name string) error
type SgLocalState ¶
type SgLocalState struct { // The count of local joiners to the same syncgroup. NumLocalJoiners uint32 // The syncgroup is watched when the sync Watcher starts processing the // syncgroup data. When a syncgroup is created or joined, an entry is // added to the Watcher queue (log) to inform it from which point to // start accepting store mutations, an asynchronous notification similar // to regular store mutations. When the Watcher processes that queue // entry, it sets this bit to true. When Syncbase restarts, the value // of this bit allows the new sync Watcher to recreate its in-memory // state by resuming to watch only the prefixes of syncgroups that were // previously being watched. Watched bool // The syncgroup was published here by this remote peer (if non-empty // string), typically the syncgroup creator. In this case the syncgroup // cannot be GCed locally even if it has no local joiners. RemotePublisher string // The syncgroup is in pending state on a device that learns the current // state of the syncgroup from another device but has not yet received // through peer-to-peer sync the history of the changes (DAG and logs). // This happens in two cases: // 1- A joiner was accepted into a syncgroup by a syncgroup admin and // only given the current syncgroup info synchronously and will // receive the full history later via p2p sync. // 2- A remote server where the syncgroup is published was told by the // syncgroup publisher the current syncgroup info synchronously and // will receive the full history later via p2p sync. // The pending state is over when the device reaches or exceeds the // knowledge level indicated in the pending genvec. While SyncPending // is true, no local syncgroup mutations are allowed (i.e. no join or // set-spec requests). SyncPending bool PendingGenVec interfaces.GenVector }
SgLocalState holds the syncgroup local state, only relevant to this member (i.e. the local Syncbase). This is needed for crash recovery of the internal state transitions of the syncgroup.
func (*SgLocalState) FillVDLTarget ¶
func (*SgLocalState) MakeVDLTarget ¶
func (m *SgLocalState) MakeVDLTarget() vdl.Target
func (SgLocalState) VDLIsZero ¶
func (x SgLocalState) VDLIsZero() bool
type SgLocalStateTarget ¶
type SgLocalStateTarget struct { Value *SgLocalState vdl.TargetBase vdl.FieldsTargetBase // contains filtered or unexported fields }
func (*SgLocalStateTarget) FinishField ¶
func (t *SgLocalStateTarget) FinishField(_, _ vdl.Target) error
func (*SgLocalStateTarget) FinishFields ¶
func (t *SgLocalStateTarget) FinishFields(_ vdl.FieldsTarget) error
func (*SgLocalStateTarget) StartField ¶
func (t *SgLocalStateTarget) StartField(name string) (key, field vdl.Target, _ error)
func (*SgLocalStateTarget) StartFields ¶
func (t *SgLocalStateTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
func (*SgLocalStateTarget) ZeroField ¶
func (t *SgLocalStateTarget) ZeroField(name string) error
type SyncData ¶
type SyncData struct {
Id uint64
}
SyncData represents the persistent state of the sync module.
func (*SyncData) MakeVDLTarget ¶
type SyncDataTarget ¶
type SyncDataTarget struct { Value *SyncData vdl.TargetBase vdl.FieldsTargetBase // contains filtered or unexported fields }
func (*SyncDataTarget) FinishField ¶
func (t *SyncDataTarget) FinishField(_, _ vdl.Target) error
func (*SyncDataTarget) FinishFields ¶
func (t *SyncDataTarget) FinishFields(_ vdl.FieldsTarget) error
func (*SyncDataTarget) StartField ¶
func (t *SyncDataTarget) StartField(name string) (key, field vdl.Target, _ error)
func (*SyncDataTarget) StartFields ¶
func (t *SyncDataTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
func (*SyncDataTarget) ZeroField ¶
func (t *SyncDataTarget) ZeroField(name string) error