recoverylog

package
v2.0.212+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChecksumMismatch    = fmt.Errorf("checksum mismatch")
	ErrExpectedHintedFnode = fmt.Errorf("op is not create, and an Fnode was hinted")
	ErrFnodeNotTracked     = fmt.Errorf("fnode not tracked")
	ErrLinkExists          = fmt.Errorf("link exists")
	ErrNoSuchLink          = fmt.Errorf("fnode has no such link")
	ErrNotHintedAuthor     = fmt.Errorf("op author does not match the next hinted author")
	ErrPropertyExists      = fmt.Errorf("property exists")
	ErrWrongSeqNo          = fmt.Errorf("wrong sequence number")
)
View Source
var (
	ErrInvalidLengthRecordedOp = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowRecordedOp   = fmt.Errorf("proto: integer overflow")
)

Functions

This section is empty.

Types

type Author

type Author uint32

Author is a random, unique ID which identifies a processes that creates RecordedOps. It's used by FSM to allow for reconciliation of divergent histories in the recovery log, through hints as to which Authors produced which Segments in the final history.

func NewRandomAuthorID

func NewRandomAuthorID() (Author, error)

NewRandomAuthorID creates and returns a new, randomized Author ID.

type FSM

type FSM struct {
	// Recovery log which this FSM tracks operations of.
	Log pb.Journal

	// Expected sequence number and checksum of next operation.
	NextSeqNo    int64
	NextChecksum uint32

	// Target paths and contents of small files which are managed outside of
	// regular Fnode tracking. Property updates are triggered upon rename of
	// a tracked Fnode to a well-known property file path.
	//
	// Property paths must be "sinks" which:
	//  * Are never directly written to.
	//  * Are never renamed or linked from.
	//  * Have exactly one hard-link (eg, only "rename" to the property path is
	//    supported; "link" is not as it would introduce a second hard-link).
	Properties map[string]string

	// Maps from Fnode to current state of the node.
	LiveNodes map[Fnode]*fnodeState
	// Indexes current target paths of LiveNodes.
	Links map[string]Fnode
	// contains filtered or unexported fields
}

FSM implements a finite state machine over RecordedOp. In particular FSM applies RecordedOp in order, verifying the SeqNo and Checksum of each operation. This ensures that only operations which are linear and consistent are applied.

func NewFSM

func NewFSM(hints FSMHints) (*FSM, error)

NewFSM returns an FSM which is prepared to apply the provided |hints|.

func (*FSM) Apply

func (m *FSM) Apply(op *RecordedOp, frame []byte) error

Apply attempts to transition the FSMs state by |op| & |frame|. It either performs a transition, or returns an error detailing how the operation is not consistent with prior applied operations or hints. A state transition occurs if and only if the returned err is nil, with one exception: ErrFnodeNotTracked may be returned to indicate that the operation is consistent and a transition occurred, but that FSMHints also indicate the Fnode no longer exists at the point-in-time at which the FSMHints were created, and the caller may therefor want to skip corresponding local playback actions.

func (*FSM) BuildHints

func (m *FSM) BuildHints() FSMHints

BuildHints constructs FSMHints which enable a future FSM to rebuild this FSM's state.

type FSMHints

type FSMHints struct {
	// Log is the Journal name holding recorded log content.
	Log github_com_LiveRamp_gazette_v2_pkg_protocol.Journal `protobuf:"bytes,1,opt,name=log,proto3,casttype=github.com/LiveRamp/gazette/v2/pkg/protocol.Journal" json:"log,omitempty"`
	// Live Fnodes and their Segments as-of the generation of these FSMHints.
	LiveNodes []FnodeSegments `protobuf:"bytes,2,rep,name=live_nodes,json=liveNodes" json:"live_nodes"`
	// Property files and contents as-of the generation of these FSMHints.
	Properties []Property `protobuf:"bytes,3,rep,name=properties" json:"properties"`
}

FSMHints represents a manifest of Fnodes which were still live (eg, having remaining links) at the time the FSMHints were produced, as well as any Properties. It allows a Player of the log to identify minimal Segments which must be read to recover all Fnodes, and also contains sufficient metadata for a Player to resolve all possible conflicts it could encounter while reading the log, to arrive at a consistent view of file state which exactly matches that of the Recorder producing the FSMHints. Next tag: 4.

func (*FSMHints) Descriptor

func (*FSMHints) Descriptor() ([]byte, []int)

func (FSMHints) LiveLogSegments

func (m FSMHints) LiveLogSegments() ([]Fnode, SegmentSet, error)

LiveLogSegments flattens hinted LiveNodes into an ordered list of Fnodes, and the set of recovery log Segments which fully contain them.

func (*FSMHints) Marshal

func (m *FSMHints) Marshal() (dAtA []byte, err error)

func (*FSMHints) MarshalTo

func (m *FSMHints) MarshalTo(dAtA []byte) (int, error)

func (*FSMHints) ProtoMessage

func (*FSMHints) ProtoMessage()

func (*FSMHints) ProtoSize

func (m *FSMHints) ProtoSize() (n int)

func (*FSMHints) Reset

func (m *FSMHints) Reset()

func (*FSMHints) String

func (m *FSMHints) String() string

func (*FSMHints) Unmarshal

func (m *FSMHints) Unmarshal(dAtA []byte) error

func (*FSMHints) Validate

func (h *FSMHints) Validate() error

Validate validates a FSMHints instance. TODO: consider additional validation.

func (*FSMHints) XXX_DiscardUnknown

func (m *FSMHints) XXX_DiscardUnknown()

func (*FSMHints) XXX_Marshal

func (m *FSMHints) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FSMHints) XXX_Merge

func (dst *FSMHints) XXX_Merge(src proto.Message)

func (*FSMHints) XXX_Size

func (m *FSMHints) XXX_Size() int

func (*FSMHints) XXX_Unmarshal

func (m *FSMHints) XXX_Unmarshal(b []byte) error

type FileRecorder

type FileRecorder struct {
	*Recorder
	// contains filtered or unexported fields
}

FileRecorder records operations applied to a specific file opened with RecordCreate.

func (*FileRecorder) RecordWrite

func (r *FileRecorder) RecordWrite(data []byte)

RecordWrite records the write of |data| at the current file offset.

type Fnode

type Fnode int64

An Fnode is an identifier which represents a file across its renames, links, and un-links within a file-system. When a file is created, it's assigned an Fnode value equal to the RecordedOp.SeqNo which created it.

type FnodeSegments

type FnodeSegments struct {
	// Fnode being hinted.
	Fnode Fnode `protobuf:"varint,1,opt,name=fnode,proto3,casttype=Fnode" json:"fnode,omitempty"`
	// Segments of the Fnode in the log. Currently, FSM tracks only a single
	// Segment per Fnode per Author. A specific implication of this is that Fnodes
	// modified over long periods of time will result in Segments spanning large
	// chunks of the log. For best performance, Fnodes should be opened & written
	// once, and then never be modified again (this is RocksDB's behavior).
	// If supporting this case is desired, FSM will have to be a bit smarter about
	// not extending Segments which gap over significant portions of the log
	// (eg, there's a trade-off to make over size of the hinted manifest, vs
	// savings incurred on playback by being able to skip portions of the log).
	Segments []Segment `protobuf:"bytes,2,rep,name=segments" json:"segments"`
}

FnodeSegments captures log Segments containing all RecordedOps of the Fnode.

func (*FnodeSegments) Descriptor

func (*FnodeSegments) Descriptor() ([]byte, []int)

func (*FnodeSegments) Marshal

func (m *FnodeSegments) Marshal() (dAtA []byte, err error)

func (*FnodeSegments) MarshalTo

func (m *FnodeSegments) MarshalTo(dAtA []byte) (int, error)

func (*FnodeSegments) ProtoMessage

func (*FnodeSegments) ProtoMessage()

func (*FnodeSegments) ProtoSize

func (m *FnodeSegments) ProtoSize() (n int)

func (*FnodeSegments) Reset

func (m *FnodeSegments) Reset()

func (*FnodeSegments) String

func (m *FnodeSegments) String() string

func (*FnodeSegments) Unmarshal

func (m *FnodeSegments) Unmarshal(dAtA []byte) error

func (*FnodeSegments) XXX_DiscardUnknown

func (m *FnodeSegments) XXX_DiscardUnknown()

func (*FnodeSegments) XXX_Marshal

func (m *FnodeSegments) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FnodeSegments) XXX_Merge

func (dst *FnodeSegments) XXX_Merge(src proto.Message)

func (*FnodeSegments) XXX_Size

func (m *FnodeSegments) XXX_Size() int

func (*FnodeSegments) XXX_Unmarshal

func (m *FnodeSegments) XXX_Unmarshal(b []byte) error

type Player

type Player struct {
	FSM *FSM   // FSM recovered at Play completion. Nil if an error was encountered.
	Dir string // Local directory into which the log is recovered.
	// contains filtered or unexported fields
}

Player reads from a log to rebuild encoded file operations onto the local filesystem.

func NewPlayer

func NewPlayer() *Player

NewPlayer returns a new Player for recovering a log.

func (*Player) Done

func (p *Player) Done() <-chan struct{}

Done returns a channel which selects when Play has completed. If Play returned no error, then Player.FSM & Dir will hold the recovered FSM and its local directory. Otherwise, both will be zero-valued.

func (*Player) FinishAtWriteHead

func (p *Player) FinishAtWriteHead()

FinishAtWriteHead requests that playback complete upon reaching the current write head. Only one invocation of FinishAtWriteHead or InjectHandoff may be made of a Player instance.

func (*Player) InjectHandoff

func (p *Player) InjectHandoff(author Author)

InjectHandoff requests that playback complete upon injecting a no-op handoff of the given |author| at the log head. Only one invocation of InjectHandoff or FinishAtWriteHead may be made of a Player instance. |author| must be non- zero or InjectHandoff panics.

func (*Player) Play

func (p *Player) Play(ctx context.Context, hints FSMHints, dir string, ajc client.AsyncJournalClient) error

Play uses the prepared Player to play back the FSMHints. It returns on the first encountered unrecoverable error, including context cancellation, or upon a successful FinishAtWriteHead or InjectHandoff.

func (*Player) Tailing

func (p *Player) Tailing() <-chan struct{}

Tailing returns a channel which selects when Play has reached the log write head, and is tailing new log operations as they arrive.

type Property

type Property struct {
	// Filesystem path of this property, relative to the common base directory.
	Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	// Complete file content of this property.
	Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
}

Property is a small file which rarely changes, and is thus managed outside of regular Fnode tracking. See FSM.Properties.

func (*Property) Descriptor

func (*Property) Descriptor() ([]byte, []int)

func (*Property) Marshal

func (m *Property) Marshal() (dAtA []byte, err error)

func (*Property) MarshalTo

func (m *Property) MarshalTo(dAtA []byte) (int, error)

func (*Property) ProtoMessage

func (*Property) ProtoMessage()

func (*Property) ProtoSize

func (m *Property) ProtoSize() (n int)

func (*Property) Reset

func (m *Property) Reset()

func (*Property) String

func (m *Property) String() string

func (*Property) Unmarshal

func (m *Property) Unmarshal(dAtA []byte) error

func (*Property) XXX_DiscardUnknown

func (m *Property) XXX_DiscardUnknown()

func (*Property) XXX_Marshal

func (m *Property) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Property) XXX_Merge

func (dst *Property) XXX_Merge(src proto.Message)

func (*Property) XXX_Size

func (m *Property) XXX_Size() int

func (*Property) XXX_Unmarshal

func (m *Property) XXX_Unmarshal(b []byte) error

type RecordedAferoFS

type RecordedAferoFS struct {
	*Recorder
	afero.Fs
}

RecordedAferoFS adapts a Recorder to wrap a afero.Fs instance.

func (RecordedAferoFS) Create

func (r RecordedAferoFS) Create(name string) (afero.File, error)

func (RecordedAferoFS) OpenFile

func (r RecordedAferoFS) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

func (RecordedAferoFS) Remove

func (r RecordedAferoFS) Remove(name string) error

func (RecordedAferoFS) RemoveAll

func (r RecordedAferoFS) RemoveAll(path string) error

func (RecordedAferoFS) Rename

func (r RecordedAferoFS) Rename(oldname, newname string) error

type RecordedOp

type RecordedOp struct {
	// Monotonically-increasing sequence number of this operation.
	SeqNo int64 `protobuf:"varint,1,opt,name=seq_no,json=seqNo,proto3" json:"seq_no,omitempty"`
	// Previous FSM checksum to which this operation should be applied (eg, the
	// expected checksum arrived at after applying the previous operation.
	Checksum uint32 `protobuf:"fixed32,2,opt,name=checksum,proto3" json:"checksum,omitempty"`
	// Author is the unique ID of the Recorder which wrote this RecordedOp.
	// Each Recorder randomly generates an Author ID at startup, and thereafter
	// applies it to all operations it records.
	Author Author `protobuf:"fixed32,3,opt,name=author,proto3,casttype=Author" json:"author,omitempty"`
	// First and last byte offset (exclusive) of this RecordedOp. These are meta-
	// fields which are not populated in the recorded log (as Recorders cannot
	// know at what offsets their writes will land in the log). Instead, Players
	// attach offsets as they deserialize RecordedOps from the committed log.
	FirstOffset int64              `protobuf:"varint,9,opt,name=first_offset,json=firstOffset,proto3" json:"first_offset,omitempty"`
	LastOffset  int64              `protobuf:"varint,10,opt,name=last_offset,json=lastOffset,proto3" json:"last_offset,omitempty"`
	Create      *RecordedOp_Create `protobuf:"bytes,4,opt,name=create" json:"create,omitempty"`
	Link        *RecordedOp_Link   `protobuf:"bytes,5,opt,name=link" json:"link,omitempty"`
	Unlink      *RecordedOp_Link   `protobuf:"bytes,6,opt,name=unlink" json:"unlink,omitempty"`
	Write       *RecordedOp_Write  `protobuf:"bytes,7,opt,name=write" json:"write,omitempty"`
	// Property indicates a property file has been created or updated.
	Property *Property `protobuf:"bytes,8,opt,name=property" json:"property,omitempty"`
}

RecordedOp records states changes occuring within a local file-system. Next tag: 11.

func (*RecordedOp) Descriptor

func (*RecordedOp) Descriptor() ([]byte, []int)

func (*RecordedOp) Marshal

func (m *RecordedOp) Marshal() (dAtA []byte, err error)

func (*RecordedOp) MarshalTo

func (m *RecordedOp) MarshalTo(dAtA []byte) (int, error)

func (*RecordedOp) ProtoMessage

func (*RecordedOp) ProtoMessage()

func (*RecordedOp) ProtoSize

func (m *RecordedOp) ProtoSize() (n int)

func (*RecordedOp) Reset

func (m *RecordedOp) Reset()

func (*RecordedOp) String

func (m *RecordedOp) String() string

func (*RecordedOp) Unmarshal

func (m *RecordedOp) Unmarshal(dAtA []byte) error

func (*RecordedOp) XXX_DiscardUnknown

func (m *RecordedOp) XXX_DiscardUnknown()

func (*RecordedOp) XXX_Marshal

func (m *RecordedOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RecordedOp) XXX_Merge

func (dst *RecordedOp) XXX_Merge(src proto.Message)

func (*RecordedOp) XXX_Size

func (m *RecordedOp) XXX_Size() int

func (*RecordedOp) XXX_Unmarshal

func (m *RecordedOp) XXX_Unmarshal(b []byte) error

type RecordedOp_Create

type RecordedOp_Create struct {
	// Filesystem path of this file, relative to the common base directory.
	Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
}

Create a new "File Node" (Fnode), initially linked to |path|. Fnodes play a similar role to Posix inodes: they identify a specific file object while being invariant to (and spanning across) its current or future path links. The assigned Fnode ID is the |seq_no| of this RecordedOp.

func (*RecordedOp_Create) Descriptor

func (*RecordedOp_Create) Descriptor() ([]byte, []int)

func (*RecordedOp_Create) Marshal

func (m *RecordedOp_Create) Marshal() (dAtA []byte, err error)

func (*RecordedOp_Create) MarshalTo

func (m *RecordedOp_Create) MarshalTo(dAtA []byte) (int, error)

func (*RecordedOp_Create) ProtoMessage

func (*RecordedOp_Create) ProtoMessage()

func (*RecordedOp_Create) ProtoSize

func (m *RecordedOp_Create) ProtoSize() (n int)

func (*RecordedOp_Create) Reset

func (m *RecordedOp_Create) Reset()

func (*RecordedOp_Create) String

func (m *RecordedOp_Create) String() string

func (*RecordedOp_Create) Unmarshal

func (m *RecordedOp_Create) Unmarshal(dAtA []byte) error

func (*RecordedOp_Create) XXX_DiscardUnknown

func (m *RecordedOp_Create) XXX_DiscardUnknown()

func (*RecordedOp_Create) XXX_Marshal

func (m *RecordedOp_Create) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RecordedOp_Create) XXX_Merge

func (dst *RecordedOp_Create) XXX_Merge(src proto.Message)

func (*RecordedOp_Create) XXX_Size

func (m *RecordedOp_Create) XXX_Size() int

func (*RecordedOp_Create) XXX_Unmarshal

func (m *RecordedOp_Create) XXX_Unmarshal(b []byte) error
type RecordedOp_Link struct {
	// Fnode being linked or unlinked.
	Fnode Fnode `protobuf:"varint,1,opt,name=fnode,proto3,casttype=Fnode" json:"fnode,omitempty"`
	// Filesystem path being un/linked, relative to the common base directory.
	Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
}

Link or unlink an Fnode to a filesystem path.

func (*RecordedOp_Link) Descriptor

func (*RecordedOp_Link) Descriptor() ([]byte, []int)

func (*RecordedOp_Link) Marshal

func (m *RecordedOp_Link) Marshal() (dAtA []byte, err error)

func (*RecordedOp_Link) MarshalTo

func (m *RecordedOp_Link) MarshalTo(dAtA []byte) (int, error)

func (*RecordedOp_Link) ProtoMessage

func (*RecordedOp_Link) ProtoMessage()

func (*RecordedOp_Link) ProtoSize

func (m *RecordedOp_Link) ProtoSize() (n int)

func (*RecordedOp_Link) Reset

func (m *RecordedOp_Link) Reset()

func (*RecordedOp_Link) String

func (m *RecordedOp_Link) String() string

func (*RecordedOp_Link) Unmarshal

func (m *RecordedOp_Link) Unmarshal(dAtA []byte) error

func (*RecordedOp_Link) XXX_DiscardUnknown

func (m *RecordedOp_Link) XXX_DiscardUnknown()

func (*RecordedOp_Link) XXX_Marshal

func (m *RecordedOp_Link) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RecordedOp_Link) XXX_Merge

func (dst *RecordedOp_Link) XXX_Merge(src proto.Message)

func (*RecordedOp_Link) XXX_Size

func (m *RecordedOp_Link) XXX_Size() int

func (*RecordedOp_Link) XXX_Unmarshal

func (m *RecordedOp_Link) XXX_Unmarshal(b []byte) error

type RecordedOp_Write

type RecordedOp_Write struct {
	// Fnode being written to.
	Fnode Fnode `protobuf:"varint,1,opt,name=fnode,proto3,casttype=Fnode" json:"fnode,omitempty"`
	// Byte-offset within the file to which this write is applied.
	Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
	// Length of the write.
	Length int64 `protobuf:"varint,3,opt,name=length,proto3" json:"length,omitempty"`
}

Write indicates |length| bytes should be written at |offset| to |fnode|. In a serialization stream, we expect |length| raw bytes of content to immediately follow this operation.

func (*RecordedOp_Write) Descriptor

func (*RecordedOp_Write) Descriptor() ([]byte, []int)

func (*RecordedOp_Write) Marshal

func (m *RecordedOp_Write) Marshal() (dAtA []byte, err error)

func (*RecordedOp_Write) MarshalTo

func (m *RecordedOp_Write) MarshalTo(dAtA []byte) (int, error)

func (*RecordedOp_Write) ProtoMessage

func (*RecordedOp_Write) ProtoMessage()

func (*RecordedOp_Write) ProtoSize

func (m *RecordedOp_Write) ProtoSize() (n int)

func (*RecordedOp_Write) Reset

func (m *RecordedOp_Write) Reset()

func (*RecordedOp_Write) String

func (m *RecordedOp_Write) String() string

func (*RecordedOp_Write) Unmarshal

func (m *RecordedOp_Write) Unmarshal(dAtA []byte) error

func (*RecordedOp_Write) XXX_DiscardUnknown

func (m *RecordedOp_Write) XXX_DiscardUnknown()

func (*RecordedOp_Write) XXX_Marshal

func (m *RecordedOp_Write) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RecordedOp_Write) XXX_Merge

func (dst *RecordedOp_Write) XXX_Merge(src proto.Message)

func (*RecordedOp_Write) XXX_Size

func (m *RecordedOp_Write) XXX_Size() int

func (*RecordedOp_Write) XXX_Unmarshal

func (m *RecordedOp_Write) XXX_Unmarshal(b []byte) error

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder observes a sequence of changes to a file-system, and preserves those changes via a written Gazette journal of file-system operations. Note that we can't ever fail to write some portion of the recorded log, and then return control back to the database (and its client). To do so would allow for inconsistency in the local database state, vs the recorded log. For this reason, Recorder's implementation is crash-only and panics on error.

func NewRecorder

func NewRecorder(fsm *FSM, id Author, dir string, cl client.AsyncJournalClient) *Recorder

NewRecorder creates and returns a Recorder.

func (*Recorder) BuildHints

func (r *Recorder) BuildHints() (FSMHints, error)

BuildHints returns FSMHints which may be played back to fully reconstruct the local filesystem state observed by this Recorder. It may block while pending operations sync to the log.

func (*Recorder) RecordCreate

func (r *Recorder) RecordCreate(path string) *FileRecorder

RecordCreate records the creation of file |path|, and returns a FileRecorder which records file operations.

func (r *Recorder) RecordLink(src, target string)

RecordLink records the creation of a hard link from |src| to |target|.

func (*Recorder) RecordRemove

func (r *Recorder) RecordRemove(path string)

RecordRemove records the removal of the file at |path|.

func (*Recorder) RecordRename

func (r *Recorder) RecordRename(src, target string)

RecordRename records the rename of |src| to |target|.

func (*Recorder) StrongBarrier

func (r *Recorder) StrongBarrier() *client.AsyncAppend

StrongBarrier issues a zero-byte append which has dependencies on all other pending appends of the AsyncAppendClient. When this barrier completes, it is guaranteed that all writes of the AsyncAppendClient which were pending at issuance of the barrier (including writes of this Recorder) have committed.

func (*Recorder) WeakBarrier

func (r *Recorder) WeakBarrier() *client.AsyncAppend

WeakBarrier issues a zero-byte append with no dependencies. When this barrier completes, it is guaranteed that all content recorded prior to the barrier has also committed. Writes to *other* journals which were pending at issuance of the barrier may still be ongoing.

type Segment

type Segment struct {
	// Author which wrote RecordedOps of this Segment.
	Author Author `protobuf:"fixed32,1,opt,name=author,proto3,casttype=Author" json:"author,omitempty"`
	// First (lowest) sequence number of RecordedOps within this Segment.
	FirstSeqNo int64 `protobuf:"varint,2,opt,name=first_seq_no,json=firstSeqNo,proto3" json:"first_seq_no,omitempty"`
	// First byte offset of the Segment, where |first_seq_no| is recorded.
	// If this Segment was produced by a Recorder, this is guaranteed only to be a
	// lower-bound (eg, a Player reading at this offset may encounter irrelevant
	// operations prior to the RecordedOp indicated by the tuple
	// (|author|, |first_seq_no|, |first_checksum|). If a Player produced the Segment,
	// first_offset is exact.
	FirstOffset int64 `protobuf:"varint,3,opt,name=first_offset,json=firstOffset,proto3" json:"first_offset,omitempty"`
	// Checksum of the RecordedOp having |first_seq_no|.
	FirstChecksum uint32 `protobuf:"fixed32,4,opt,name=first_checksum,json=firstChecksum,proto3" json:"first_checksum,omitempty"`
	// Last (highest, inclusive) sequence number of RecordedOps within this Segment.
	LastSeqNo int64 `protobuf:"varint,5,opt,name=last_seq_no,json=lastSeqNo,proto3" json:"last_seq_no,omitempty"`
	// Last offset (exclusive) of the Segment. Zero means the offset is not known
	// (eg, because the Segment was produced by a Recorder).
	LastOffset int64 `protobuf:"varint,6,opt,name=last_offset,json=lastOffset,proto3" json:"last_offset,omitempty"`
}

Segment is a contiguous chunk of recovery log written by a single Author. Recorders track Segments they have written, for use in providing hints to future readers of the log. A key point to understand is that Gazette append semantics mean that Recorders *cannot know* exactly what offsets their writes are applied to in the log, nor guarantee that their operations are not being interleaved with those of other writers. Log Players are aware of these limitations, and use Segments to resolve conflicts of possible interpretation of the log. Segments produced by a Player are exact, since Players observe all recorded operations at their exact offsets. Next tag: 7.

func (*Segment) Descriptor

func (*Segment) Descriptor() ([]byte, []int)

func (*Segment) Marshal

func (m *Segment) Marshal() (dAtA []byte, err error)

func (*Segment) MarshalTo

func (m *Segment) MarshalTo(dAtA []byte) (int, error)

func (*Segment) ProtoMessage

func (*Segment) ProtoMessage()

func (*Segment) ProtoSize

func (m *Segment) ProtoSize() (n int)

func (*Segment) Reset

func (m *Segment) Reset()

func (*Segment) String

func (m *Segment) String() string

func (*Segment) Unmarshal

func (m *Segment) Unmarshal(dAtA []byte) error

func (Segment) Validate

func (s Segment) Validate() error

Validate returns an error if the Segment is inconsistent.

func (*Segment) XXX_DiscardUnknown

func (m *Segment) XXX_DiscardUnknown()

func (*Segment) XXX_Marshal

func (m *Segment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Segment) XXX_Merge

func (dst *Segment) XXX_Merge(src proto.Message)

func (*Segment) XXX_Size

func (m *Segment) XXX_Size() int

func (*Segment) XXX_Unmarshal

func (m *Segment) XXX_Unmarshal(b []byte) error

type SegmentSet

type SegmentSet []Segment

SegmentSet is a collection of Segment with the following invariants:

  • Entries have strictly increasing SeqNo, and are non-overlapping (s[i].LastSeqNo < s[i+1].SeqNo; note this implies a single author for any covered SeqNo).
  • Entries have monotonically increasing FirstOffset.
  • Entries have monotonically increasing LastOffset, however a strict suffix of entries are permitted to have a LastOffset of zero (implied infinite LastOffset).

func (*SegmentSet) Add

func (s *SegmentSet) Add(segment Segment) error

Add a Segment to this SegmentSet. An error is returned if |segment| would result in an inconsistent SegmentSet.

func (SegmentSet) Intersect

func (s SegmentSet) Intersect(firstOffset, lastOffset int64) SegmentSet

Intersect returns a slice of this SegmentSet which overlaps with the provided [firstOffset, lastOffset) range.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL