entity

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const NodeStatusOk = "UN"

NodeStatusOk a normal database node status (Up, Normal)

View Source
const SnapshotTagDateFormat = "01-02-2006-15-04"

SnapshotTagDateFormat a date format used in snapshot tag

Variables

This section is empty.

Functions

func BackupDateToPath

func BackupDateToPath(date time.Time) string

BackupDateToPath converts a date to a directory path, where the backup will be stored in s3

func NewSnapshotTag

func NewSnapshotTag(domainName string, now time.Time) string

NewSnapshotTag creates a snapshot tag based on database domain name and current time

Types

type Archive added in v0.2.0

type Archive struct {
	Method         string         `yaml:"method"`
	ArchiveOptions ArchiveOptions `yaml:"options"`
}

Archive method and options for compress

type ArchiveOptions added in v0.2.0

type ArchiveOptions struct {
	Compression string `yaml:"compression"`
	Threads     string `yaml:"threads"`
}

ArchiveOptions options for compress. compression level and number of threads used for compression

type BackupMetadata

type BackupMetadata struct {
	DateCreated time.Time `yaml:"dateCreated"`
	Host        string
	Keyspaces   []string
	SnapshotTag string    `yaml:"snapshotTag"`
	BuildInfo   BuildInfo `yaml:"buildInfo"`
	Archive     Archive   `yaml:"archive"`
}

BackupMetadata is written along with each backup, that will help us implement the restoration in the future.

func (BackupMetadata) Bytes

func (b BackupMetadata) Bytes() []byte

type BackupResult

type BackupResult struct {
	Error         error
	DateStarted   time.Time
	Duration      time.Duration
	SnapshotTag   string
	Keyspaces     []string
	Uploaded      bool
	CleanupResult CleanupResult
}

BackupResult a result of running a backup on a single database node

type BackupResults

type BackupResults struct {
	TotalNodes    int
	BackedUpNodes int
	ByHost        map[string]BackupResult
	Error         error
}

BackupResults a list of backup results on multiple database nodes

func (BackupResults) Report

func (b BackupResults) Report() string

Report creates a human-readable report about backup results

type BuildInfo

type BuildInfo struct {
	Version string
	Commit  string
	Date    string
}

BuildInfo app build info

type CleanupResult

type CleanupResult struct {
	// an error that occurred while cleaning up files on a database node, if any
	LocalError error
	// an error that occurred while cleaning up a backup in remote storage, if any
	RemoteError          error
	RemovedRemoteBackups []RemoteBackup
}

type Credentials

type Credentials struct {
	User     string
	Password string
}

Credentials scylladb credentials

type Node

type Node struct {
	Info NodeInfo
	// a shell command executor on this node
	Cmd cmd.Executor
	// an SSH connection error, if any
	ConnectionErr error
}

func NewNode

func NewNode(info NodeInfo, cmdExecutor cmd.Executor, connectionErr error) *Node

type NodeBinaries

type NodeBinaries struct {
	Cqlsh    string
	Nodetool string
}

NodeBinaries paths to scylladb executables on database node

type NodeCallback

type NodeCallback func(ctx context.Context, node *Node) NodeCallbackResult

NodeCallback a callback function to be applied on database node

type NodeCallbackResult

type NodeCallbackResult struct {
	Host  string
	Value interface{}
	Err   error
}

NodeCallbackResult a result of running a callback on database node

func CallbackError

func CallbackError(err error) NodeCallbackResult

CallbackError creates a callback result with a given error

func CallbackErrorWithValue

func CallbackErrorWithValue(err error, value interface{}) NodeCallbackResult

CallbackErrorWithValue creates a callback result with a given error and value

func CallbackOk

func CallbackOk(value interface{}) NodeCallbackResult

CallbackOk creates a callback result with a given value

type NodeCallbackResults

type NodeCallbackResults map[string]NodeCallbackResult

NodeCallbackResults callback results by hosts

func (NodeCallbackResults) Error

func (results NodeCallbackResults) Error() error

Returns errors from callback results (if any) as a single error

type NodeInfo

type NodeInfo struct {
	// ip or domain name
	Host        string
	IpAddress   string
	DomainName  string
	DataPath    string
	ClusterName string
	Datacenter  string
	// a status according to `nodetool status`
	Status   string
	Binaries NodeBinaries
}

NodeInfo database node information

func NewNodeInfo

func NewNodeInfo(host, dataPath string, binaries NodeBinaries, resolveDns bool) NodeInfo

NewNodeInfo initializes a node information. If resolveDns=true, then it will attempt to resolve the domain name and/or IP address.

func (NodeInfo) IsStatusOk

func (n NodeInfo) IsStatusOk() bool

func (NodeInfo) RemoteStoragePath

func (n NodeInfo) RemoteStoragePath() string

RemoteStoragePath returns a path where the backup from a node should be stored in s3. The format is "cluster-name/datacenter/domain-name"

func (NodeInfo) ShortDomainName

func (n NodeInfo) ShortDomainName() string

ShortDomainName returns a short domain name of a node (up to the first "."), if it is known. Otherwise, returns the "host" value from configuration. Short name is used as a part of a backup path when storing it in s3.

type RemoteBackup

type RemoteBackup struct {
	Path        string
	HostPrefix  string
	DateCreated time.Time
	Removed     bool
	RemoveError error
}

RemoteBackup a backup info in remote storage

func NewRemoteBackupFromPath

func NewRemoteBackupFromPath(path string) (RemoteBackup, error)

NewRemoteBackupFromPath parses a backup info from its path in remote storage

func (RemoteBackup) IsExpired

func (r RemoteBackup) IsExpired(now time.Time, retention time.Duration) bool

IsExpired whether a backup has expired

func (RemoteBackup) String

func (r RemoteBackup) String() string

type RemoteBackupsByHost

type RemoteBackupsByHost map[string][]RemoteBackup

type RepairResult

type RepairResult struct {
	Output   string
	Duration time.Duration
}

RepairResult a result of "nodetool repair" command

type RepairResults

type RepairResults struct {
	TotalNodes    int
	RepairedNodes int
	ByHost        map[string]RepairResult
	Error         error
}

RepairResults results of "nodetool repair" on multiple database nodes

func (RepairResults) Report

func (r RepairResults) Report() string

Report creates a human-readable report string about repair results to be used in a notification

type Snapshot

type Snapshot struct {
	Tag string
	// keeps the snapshots of specific database tables and indices
	Items []SnapshotItem
}

Snapshot holds an information about database snapshot

type SnapshotItem

type SnapshotItem struct {
	Keyspace     string
	ColumnFamily string
}

SnapshotItem a table or index, part of a snapshot

type Snapshots

type Snapshots map[string]Snapshot

Snapshots a set of snapshots, where the map key is snapshot tag

func ParseSnapshots

func ParseSnapshots(output string) Snapshots

ParseSnapshots returns a list of snapshots based on `nodetool listsnapshot` output.

type SnapshotsByNode

type SnapshotsByNode map[string]Snapshots

SnapshotsByNode a set of snapshots on multiple nodes, where the map key is a hostname

Jump to

Keyboard shortcuts

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