models

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OplogArchBasePath   = "oplog_" + utility.VersionStr + "/"
	ArchNameTSDelimiter = "_"
	ArchiveTypeOplog    = "oplog"
	ArchiveTypeGap      = "gap"
)

Archive path constants.

View Source
const (
	MaxDocumentSize = 16 * 1024 * 1024
)

Variables

View Source
var (
	ArchRegexp = regexp.MustCompile(`^(oplog|gap)_(?P<startTS>[0-9]+\.[0-9]+)_(?P<endTS>[0-9]+\.[0-9]+)\.(?P<Ext>[^$]+)$`)
)
View Source
var ErrorDescriptions = map[ErrorCode]string{
	SplitFound:        "last known document was not found",
	VersionChanged:    "schema version of the user credential documents changed",
	CollectionRenamed: "collection renamed",
}

ErrorDescriptions maps error codes to messages

Functions

func ArchInBackup added in v0.2.17

func ArchInBackup(arch Archive, backup *Backup) bool

ArchInBackup checks if archive and given backup overlaps each over.

func BsonTimestampFromOplogTS

func BsonTimestampFromOplogTS(ots Timestamp) primitive.Timestamp

BsonTimestampFromOplogTS builds BSON primitive from Timestamp

func LessTS

func LessTS(ots1, ots2 Timestamp) bool

LessTS returns if first timestamp less than second

func NewError

func NewError(code ErrorCode, msg string) error

NewError builds Error with error code and message

func PutOplogEntry added in v0.2.17

func PutOplogEntry(oplog *Oplog)

PutOplogEntry zeroes fields of Oplog struct and it to pool

func TimestampInInterval added in v0.2.17

func TimestampInInterval(ts, begin, end Timestamp) bool

TimestampInInterval checks if timestamp is in given interval.

Types

type Archive

type Archive struct {
	Start Timestamp
	End   Timestamp
	Ext   string
	Type  string
}

Archive defines oplog archive representation.

func ArchFromFilename

func ArchFromFilename(path string) (Archive, error)

ArchFromFilename builds Arch from given path. TODO: support empty extension

func NewArchive

func NewArchive(start, end Timestamp, ext, atype string) (Archive, error)

NewArchive builds Archive struct with given arguments.

func (Archive) Extension

func (a Archive) Extension() string

Extension returns extension of archive file name.

func (Archive) Filename

func (a Archive) Filename() string

Filename builds archive filename from timestamps, extension and type. example: oplog_1569009857.10_1569009101.99.lzma

func (Archive) In

func (a Archive) In(ts Timestamp) bool

In returns if oplog with given timestamp is exists in archive.

type Backup added in v0.2.17

type Backup struct {
	BackupName      string      `json:"BackupName,omitempty"`
	StartLocalTime  time.Time   `json:"StartLocalTime,omitempty"`
	FinishLocalTime time.Time   `json:"FinishLocalTime,omitempty"`
	UserData        interface{} `json:"UserData,omitempty"`
	MongoMeta       MongoMeta   `json:"MongoMeta,omitempty"`
	Permanent       bool        `json:"Permanent"`
	DataSize        int64       `json:"DataSize,omitempty"`
}

Backup represents backup sentinel data

func FirstOverlappingBackupForArch added in v0.2.17

func FirstOverlappingBackupForArch(arch Archive, backups []Backup) Backup

FirstOverlappingBackupForArch checks if archive overlaps any backup from given list. TODO: build btree to fix ugly complexity here

func (Backup) IsPermanent added in v1.1.1

func (b Backup) IsPermanent() bool

func (Backup) Name added in v1.1.1

func (b Backup) Name() string

func (Backup) StartTime added in v1.1.1

func (b Backup) StartTime() time.Time

type BackupMeta added in v0.2.18

type BackupMeta struct {
	Mongo      MongoMeta
	DataSize   int64
	Permanent  bool
	User       interface{}
	StartTime  time.Time
	FinishTime time.Time
}

BackupMeta includes mongodb and storage metadata

type Error

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

Error ...

func (*Error) Error

func (e *Error) Error() string

Error ...

type ErrorCode

type ErrorCode int

ErrorCode ...

const (
	ValidationMessagePrefix           = "oplog validate error"
	SplitFound              ErrorCode = iota
	VersionChanged          ErrorCode = iota
	CollectionRenamed       ErrorCode = iota
)

Error codes generation

type IsMaster

type IsMaster struct {
	IsMaster  bool
	LastWrite IsMasterLastWrite
}

IsMaster ...

type IsMasterLastWrite

type IsMasterLastWrite struct {
	OpTime         OpTime
	MajorityOpTime OpTime
}

IsMasterLastWrite ...

type MongoMeta added in v0.2.17

type MongoMeta struct {
	Before NodeMeta `json:"Before,omitempty"`
	After  NodeMeta `json:"After,omitempty"`
}

MongoMeta includes NodeMeta Before and after backup

type NodeMeta added in v0.2.17

type NodeMeta struct {
	LastTS    Timestamp `json:"LastTS,omitempty"`
	LastMajTS Timestamp `json:"LastMajTS,omitempty"`
}

NodeMeta represents MongoDB node metadata

type OpTime

type OpTime struct {
	TS   Timestamp
	Term int64
}

Optime ...

type Oplog

type Oplog struct {
	TS   Timestamp `bson:"ts"`
	Data []byte
}

Oplog represents oplog raw and parsed metadata.

func GetOplogEntry added in v0.2.17

func GetOplogEntry() *Oplog

GetOplogEntry fetches empty Oplog struct from pool

func OplogFromRaw

func OplogFromRaw(raw bson.Raw) (*Oplog, error)

OplogFromRaw tries to decode bytes to Oplog model

type Timestamp

type Timestamp struct {
	TS  uint32 `json:"TS"`
	Inc uint32 `json:"Inc"`
}

Timestamp represents oplog record uniq id.

func MaxTS

func MaxTS(ots1, ots2 Timestamp) Timestamp

MaxTS returns maximum of two timestamps.

func TimestampFromBson

func TimestampFromBson(bts primitive.Timestamp) Timestamp

TimestampFromBson builds Timestamp from BSON primitive

func TimestampFromStr

func TimestampFromStr(s string) (Timestamp, error)

TimestampFromStr builds Timestamp from string

func (Timestamp) String

func (ots Timestamp) String() string

String returns text representation of Timestamp struct

Jump to

Keyboard shortcuts

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