Index | Files

package serverlog

import ""

Package serverlog maintains logs for directory servers, permitting replay, recovering, and mirroring.


Package Files

doc.go log.go


var MaxLogSize int64 = 100 * 1024 * 1024 // 100 MB

MaxLogSize is the maximum size of a single log file. It can be modified, such as for testing.

func HasLog Uses

func HasLog(user upspin.UserName, directory string) (bool, error)

HasLog reports whether user has logs in its directory.

func ListUsers Uses

func ListUsers(directory string) ([]upspin.UserName, error)

ListUsers returns all user names found in the given log directory.

func ListUsersWithSuffix Uses

func ListUsersWithSuffix(suffix, directory string) ([]upspin.UserName, error)

ListUsersWithSuffix returns a list is user names found in the given log directory that contain the required suffix, without the leading "+". The special suffix "*" matches all users with a non-empty suffix.

type Entry Uses

type Entry struct {
    Op    Operation
    Entry upspin.DirEntry

Entry is the unit of logging.

type Operation Uses

type Operation int

Operation is the kind of operation performed on the DirEntry.

const (
    Put Operation = iota

Operations on dir entries that are logged.

type Reader Uses

type Reader struct {
    // contains filtered or unexported fields

Reader reads LogEntries from the log.

func (*Reader) Close Uses

func (r *Reader) Close() error

Close closes the reader.

func (*Reader) EndOffset Uses

func (r *Reader) EndOffset() int64

EndOffset returns the offset of the end of the current file or -1 on error. TODO: Used only in a test in ../tree. Could be deleted.

func (*Reader) ReadAt Uses

func (r *Reader) ReadAt(offset int64) (le Entry, next int64, err error)

ReadAt reads an entry from the log at offset. It returns the log entry and the next offset. If offset is negative, which may correspond to an invalid sequence number processed by OffsetOf, it returns an error.

type User Uses

type User struct {
    // contains filtered or unexported fields

User holds the log state for a single user.

func Open Uses

func Open(userName upspin.UserName, directory string, fac upspin.Factotum, store storage.Storage) (*User, error)

Open returns a User structure holding the open logs for the user in the named local file system's directory. If the user does not already have logs in this directory, Open will create them.

If a store is provided then the root will be backed up to that storage backend whenever it changes, so that the tree may be recovered in the event that the log directory is lost or corrupted. If store is non-nil then the provided factotum must also be non-nil, as it is used to geneate the secret reference under which the root is backed up.

Only one User can be opened for a given user in a given directory or logs could be corrupted. It is the caller's responsibility to provide this guarantee.

func (*User) Append Uses

func (u *User) Append(e *Entry) error

Append appends a Entry to the end of the writer log.

func (*User) AppendOffset Uses

func (u *User) AppendOffset() int64

AppendOffset returns the offset of the end of the written log file or -1 on error.

func (*User) Close Uses

func (u *User) Close() error

func (*User) DeleteLogs Uses

func (u *User) DeleteLogs() error

DeleteLogs deletes all data for a user in its directory. Any existing logs associated with user must not be used subsequently.

func (*User) DeleteRoot Uses

func (u *User) DeleteRoot() error

DeleteRoot deletes the root.

func (*User) Name Uses

func (u *User) Name() upspin.UserName

func (*User) NewReader Uses

func (u *User) NewReader() (*Reader, error)

NewReader makes a reader of the user's log.

func (*User) OffsetOf Uses

func (u *User) OffsetOf(seq int64) int64

OffsetOf returns the global offset in the user's logs for this sequence number. It returns -1 if the sequence number does not appear in the logs. ReadAt will return an error if asked to read at a negative offset.

func (*User) ReadOffset Uses

func (u *User) ReadOffset() (int64, error)

ReadOffset reads from stable storage the offset saved by SaveOffset.

func (*User) ReadOnlyClone Uses

func (u *User) ReadOnlyClone() (*User, error)

ReadOnlyClone returns a copy of the user structure with no writer, creating a read-only accessor for the logs.

func (*User) Root Uses

func (u *User) Root() (*upspin.DirEntry, error)

Root returns the user's root by retrieving it from local stable storage.

func (*User) SaveOffset Uses

func (u *User) SaveOffset(offset int64) error

SaveOffset saves to stable storage the offset to process next.

func (*User) SaveRoot Uses

func (u *User) SaveRoot(root *upspin.DirEntry) error

SaveRoot saves the user's root entry to stable storage.

func (*User) Truncate Uses

func (u *User) Truncate(offset int64) error

Truncate truncates the write log at offset.

func (*User) V1Transition Uses

func (u *User) V1Transition() upspin.Time

V1Transition returns a time that marks the transition from old (version 0) logs to version 1. DirEntries created before this time use the old Sequence number scheme, in which the upper 23 bits are noise. These should be cleared before reporting the sequence number to the client.

func (*User) Write Uses

func (u *User) Write(b []byte) (int, error)

Write implements io.Writer for the our User type. It is the method clients use to append data to the set of log files. TODO: Used only in a test of corrupted data in ../tree - could be deleted.

Package serverlog imports 15 packages (graph) and is imported by 2 packages. Updated 2019-05-26. Refresh now. Tools for package owners.