serverlog

package
v0.0.0-...-70e5bc8 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
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.

Functions

func HasLog

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

HasLog reports whether user has logs in its directory.

func ListUsers

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

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

func ListUsersWithSuffix

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.

Types

type Entry

type Entry struct {
	Op    Operation
	Entry upspin.DirEntry
}

Entry is the unit of logging.

type Operation

type Operation int

Operation is the kind of operation performed on the DirEntry.

const (
	Put Operation = iota
	Delete
)

Operations on dir entries that are logged.

type Reader

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

Reader reads LogEntries from the log.

func (*Reader) Close

func (r *Reader) Close() error

Close closes the reader.

func (*Reader) EndOffset

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

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

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

User holds the log state for a single user.

func Open

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

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

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

func (*User) AppendOffset

func (u *User) AppendOffset() int64

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

func (*User) Close

func (u *User) Close() error

func (*User) DeleteLogs

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

func (u *User) DeleteRoot() error

DeleteRoot deletes the root.

func (*User) Name

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

func (*User) NewReader

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

NewReader makes a reader of the user's log.

func (*User) OffsetOf

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

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

ReadOffset reads from stable storage the offset saved by SaveOffset.

func (*User) ReadOnlyClone

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

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

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

func (*User) SaveOffset

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

SaveOffset saves to stable storage the offset to process next.

func (*User) SaveRoot

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

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

func (*User) Truncate

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

Truncate truncates the write log at offset.

func (*User) V1Transition

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

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.

Jump to

Keyboard shortcuts

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