Version: v0.0.0-...-e504476 Latest Latest

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

Go to latest
Published: Oct 12, 2016 License: Apache-2.0 Imports: 22 Imported by: 2




This section is empty.


This section is empty.


This section is empty.


type Agent

type Agent struct {
	// contains filtered or unexported fields

Agent provides methods to run commands and interface with remote cassandra cluster nodes via ssh. TODO: add mutex to agent operations, to enable multi thread.

func NewAgent

func NewAgent(config *Config) *Agent

NewAgent returns a new Agent.

func (*Agent) List

func (a *Agent) List(host, dir, t string) ([]string, error)

List files of given type in directory on remote host. Does not run recursive.

func (*Agent) ListDirs

func (a *Agent) ListDirs(host, dir string) ([]string, error)

ListDirs on remote host in given directory.

func (*Agent) ListFiles

func (a *Agent) ListFiles(host, dir string) ([]string, error)

ListFiles on remote host in given directory.

func (*Agent) ReadFile

func (a *Agent) ReadFile(host, file string) (io.Reader, error)

ReadFile from remote machine and return bytes.

func (*Agent) Run

func (a *Agent) Run(host, cmd string) ([]byte, error)

Run command on remote host and return combined stderr and stdout outputs.

func (*Agent) UploadFile

func (a *Agent) UploadFile(host, localFile, remotePath string) error

UploadFile from local machine to remote host.

type Cassandra

type Cassandra struct {
	// contains filtered or unexported fields

Cassandra provides methods to interface with a Cassandra cluster.

func NewCassandra

func NewCassandra(config *Config, agent *Agent) *Cassandra

NewCassandra returns a new Cassandra object.

func (*Cassandra) Hosts

func (c *Cassandra) Hosts() []string

Hosts returns slice of cassandra hosts

func (*Cassandra) SchemaBackup

func (c *Cassandra) SchemaBackup(host string) (string, error)

SchemaBackup takes backup of a keyspace and saves it on remote machine

func (*Cassandra) Snapshot

func (c *Cassandra) Snapshot(host, ts string) ([]string, []string, error)

Snapshot takes incremental or full snapshot.

func (*Cassandra) SnapshotFull

func (c *Cassandra) SnapshotFull(host, ts string) ([]string, []string, error)

SnapshotFull takes a full snapshot.

func (*Cassandra) SnapshotInc

func (c *Cassandra) SnapshotInc(host string) ([]string, []string, error)

SnapshotInc takes an incremental backup.

type Config

type Config struct {
	AwsAccessKey       string `yaml:"aws-access-key"`
	AwsBasePath        string `yaml:"aws-base-path"`
	AwsBucket          string `yaml:"aws-bucket"`
	AwsRegion          string `yaml:"aws-region"`
	AwsSecretKey       string `yaml:"aws-secret-key"`
	CassandraClasspath string `yaml:"cassandra-classpath"`
	CassandraConf      string `yaml:"cassandra-conf"`
	CqlshPath          string `yaml:"cqlsh-path"`
	Host               string
	Incremental        bool
	Keyspace           string
	Nodetool           string
	TempDir            string `yaml:"temp-dir"`
	PrivateKey         string `yaml:"private-key"`
	Snapshot           string
	Sstableloader      string
	User               string

Config holds priam configuration parameters.

func DefaultConfig

func DefaultConfig() (*Config, error)

DefaultConfig provides a starting point config for priam.

func NewConfig

func NewConfig() (*Config, error)

NewConfig returns priam configuration. It starts with the default config, superseeding these by parameters in config file, and finally superseeding them with command line flags.

func (*Config) String

func (c *Config) String() string

String returns config in json string representation

type Priam

type Priam struct {
	// contains filtered or unexported fields

Priam object provides backup and restore of cassandra DB to AWS S3.

func New

func New(config *Config) *Priam

New returns a new Priam object.

func (*Priam) Backup

func (p *Priam) Backup() error

Backup flushes all cassandra tables to disk identifies the appropriate files and copies them to the specified AWS S3 bucket.

func (*Priam) History

func (p *Priam) History() error

History prints the current list of backups in S3.

func (*Priam) NewTimestamp

func (p *Priam) NewTimestamp() string

NewTimestamp generates a new timestamp which is based on current time. The code assumes timestamps are monotonically increasing and is used by restore function to determine which backup is the latest as well as the order of incremental backups.

func (*Priam) Restore

func (p *Priam) Restore() error

Restore cassandra from a given snapshot. TODO: if restoring from a cassandra node then skip copying file to cassandra host.

func (*Priam) SnapshotHistory

func (p *Priam) SnapshotHistory() error

SnapshotHistory returns snapshot history

type S3

type S3 struct {
	// contains filtered or unexported fields

S3 object interfaces with AWS S3.

func NewS3

func NewS3(config *Config, agent *Agent) *S3

NewS3 creates a new S3 object to interface with AWS S3.

func (*S3) SnapshotHistory

func (s *S3) SnapshotHistory() (*SnapshotHistory, error)

SnapshotHistory retrieves snapshot history from S3.

func (*S3) UploadFile

func (s *S3) UploadFile(host, file, key string) error

UploadFile uploads a file to AWS S3.

func (*S3) UploadFiles

func (s *S3) UploadFiles(parent, timestamp, host string, files []string) error

UploadFiles uploads a list of files to AWS S3.

type SnapshotHistory

type SnapshotHistory struct {
	// contains filtered or unexported fields

SnapshotHistory provides the history of all snapshots in S3 for a keyspace. parent is set only for incremental backups.

func NewSnapshotHistory

func NewSnapshotHistory() *SnapshotHistory

NewSnapshotHistory initializes new snapshot history.

func (*SnapshotHistory) Add

func (h *SnapshotHistory) Add(key string)

Add key to snapshot history.

func (*SnapshotHistory) Keys

func (h *SnapshotHistory) Keys(snapshot string) ([]string, error)

Keys returns all keys for a given snapshot including keys for parent snapshots if this is an incremental backup.

func (*SnapshotHistory) List

func (h *SnapshotHistory) List() []string

List returns a ordered list of timestamps.

func (*SnapshotHistory) Parent

func (h *SnapshotHistory) Parent(snapshot string) string

Parent returns parent for this snapshot, returns itself if not incremental.

func (*SnapshotHistory) String

func (h *SnapshotHistory) String() string

String representation of snapshot history.

func (*SnapshotHistory) Valid

func (h *SnapshotHistory) Valid(snapshot string) bool

Valid returns true if a valid snapshot.

Jump to

Keyboard shortcuts

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