cassandra

package
v1.23.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2017 License: MIT Imports: 24 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCQLFile

func ParseCQLFile(filePath string) ([]string, error)

ParseCQLFile takes a cql file path as input and returns an array of cql statements on success.

func RunBackupTool

func RunBackupTool(args []string)

RunBackupTool runs the backup tool

func RunSchemaUpdateTool

func RunSchemaUpdateTool(args []string)

RunSchemaUpdateTool runs the schema update tool

func ValidateBackupConfig

func ValidateBackupConfig(cfg *BackupToolConfig) error

ValidateBackupConfig validates the given config

func ValidateRestoreConfig

func ValidateRestoreConfig(cfg *BackupToolConfig) error

ValidateRestoreConfig validate the given restore config

Types

type AWSConfig

type AWSConfig struct {
	Region         string `yaml:"Region"`
	S3Bucket       string `yaml:"S3Bucket"`
	SecretFilePath string `yaml:"SecretFilePath"`
}

AWSConfig contains aws specific configuratoin

type BackupConfig

type BackupConfig struct {
	Schedule        string `yaml:"Schedule"`
	HourOfDay       int    `yaml:"HourOfDay"`
	Keyspace        string `yaml:"Keyspace"`
	SchemaBackupDir string `yaml:"SchemaBackupDir"`
}

BackupConfig has all the backup specific configurations

type BackupCron

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

BackupCron represents a background job that schedules backup tasks based on a pre-defined schedule

func NewBackupCron

func NewBackupCron(svc string, cfg *BackupToolConfig) *BackupCron

NewBackupCron returns a cron task that schedules backup based on a schedule

func (*BackupCron) Run

func (cron *BackupCron) Run()

Run runs the cron task

func (*BackupCron) ScheduleNow

func (cron *BackupCron) ScheduleNow(date string) error

ScheduleNow schedules a one time back up immediately

type BackupTask

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

BackupTask runs a single run of backup for cassandra

func NewBackupTask

func NewBackupTask(config *BackupToolConfig, snapshotName string, hostname string, secret *Secret) (*BackupTask, error)

NewBackupTask creates and returns a task that captures a snapshot from cassandra and uploads the artifacts to S3. The snapshot will be captured with the given snapshotName the artifacts will be stored in S3 under the same name. Following is the key naming used in S3:

bucket:cherami
       - deployment-name
            - cassandra/backups/keyspace
               - metadata-servername
                  - snapshotName
                        snapshotName_keyspace_schema.txt
                        snapshotName_keyspace_peers.json
                        table1-hexstring
                             - file1.db
                             - manifest.json
                        table2-hexstring
                             .....

func (*BackupTask) Run

func (task *BackupTask) Run() error

Run runs the backup task

func (*BackupTask) Stop

func (task *BackupTask) Stop(d time.Duration) bool

Stop sends a stop signal and waits until timeout for the task to quit

type BackupToolConfig

type BackupToolConfig struct {
	Deployment  string                     `yaml:"Deployment"`
	RootDirPath string                     `yaml:"RootDirPath"`
	AWS         AWSConfig                  `yaml:"AWS"`
	Logging     configure.LogConfiguration `yaml:"Logging"`
	Backup      BackupConfig               `yaml:"Backup"`
	Restore     RestoreConfig              `yaml:"Restore"`
}

BackupToolConfig is the configuration used for cassandra-backup tool

type CQLClient

type CQLClient interface {
	// Exec executes the cql statement
	Exec(stmt string) error
	// ReadSchemaVersion returns the current schema version for the keyspace
	ReadSchemaVersion() (int64, error)
	// UpdateSchemaVersion updates the schema version for the keyspace
	UpdateSchemaVersion(newVersion int64, minCompatibleVersion int64) error
	// WriteSchemaUpdateLog adds an entry to the schema update history table
	WriteSchemaUpdateLog(oldVersion int64, newVersion int64, manifestMD5 string, desc string) error
}

CQLClient is the interface for implementations that provide way to talk to cassandra through CQL

type ConfigError

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

ConfigError represents any error for the Config handler

func (*ConfigError) Error

func (e *ConfigError) Error() string

Error implements the required error interface

type Manifest

type Manifest struct {
	CurrVersion          int64
	MinCompatibleVersion int64
	Description          string
	SchemaUpdateCqlFiles []string
	// contains filtered or unexported fields
}

Manifest represents the json deserialized object for the schema update manifest

type NodeTool

type NodeTool interface {
	// CreateSnapshot captures a cassandra snapshot
	CreateSnapshot(name string, keyspace string) error
	// ClearSnapshot clears a specific cassandra snapshot
	ClearSnapshot(name string) error
	// ClearAllSnapshots clears all cassandra snapshots
	ClearAllSnapshots() error
	// DescKeyspace describes a given keyspace
	DescKeyspace(keyspace string) (string, error)
	// GetPeers returns the cassandra peers
	GetPeers() ([]string, error)
}

NodeTool is an interface that Cassandra's node tool wrappers must adhere to

func NewNodeTool

func NewNodeTool(serverName string) NodeTool

NewNodeTool returns a node too wrapper

type NodeToolError

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

NodeToolError represents any error thrown by the NodeTool

func (*NodeToolError) Error

func (e *NodeToolError) Error() string

Error implements the required error interface

type RestoreConfig

type RestoreConfig struct {
	SnapshotDate     string `yaml:"SnapshotDate"`
	SnapshotHostname string `yaml:"SnapshotHostname"`
	OutputDirPath    string `yaml:"OutputDirPath"`
	Keyspace         string `yaml:"Keyspace"`
}

RestoreConfig has snapshot restore specific configuration

type RestoreTask

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

RestoreTask represents a task that restores a backup snapshot from S3 to disk

func NewRestoreTask

func NewRestoreTask(cfg *BackupToolConfig, secret *Secret) (*RestoreTask, error)

NewRestoreTask returns a new instance of task that fetches a cassandra snapshot from s3 and stores it onto a given output dir.

func (*RestoreTask) Run

func (task *RestoreTask) Run() error

Run runs the restore task

type SchemaUpdateTask

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

SchemaUpdateTask represents a task that takes a config for schema upgrade and in turn, runs the upgrade

func NewSchemaUpdateTask

func NewSchemaUpdateTask(config *SchemaUpdaterConfig) (*SchemaUpdateTask, error)

NewSchemaUpdateTask creates and returns a new SchemaUpdateTask

func (*SchemaUpdateTask) Run

func (task *SchemaUpdateTask) Run() error

Run runs the task

type SchemaUpdaterConfig

type SchemaUpdaterConfig struct {
	Keyspace         string
	HostsCsv         string
	IsDryRun         bool
	SkipVersionCheck bool
	ManifestFilePath string
	ProtoVersion     int
}

SchemaUpdaterConfig represents the configuration for the schema update task

type Secret

type Secret struct {
	AWSAccessKeyID string        `yaml:"aws_access_key_id"`
	AWSSecretKey   string        `yaml:"aws_secret_access_key"`
	Snapshot       SnapshotCreds `yaml:"snapshot"`
}

Secret represents the credentials that come from langley

func LoadSecret

func LoadSecret(path string) (*Secret, error)

LoadSecret loads the secret yaml from the given path

type SnapshotCreds

type SnapshotCreds struct {
	AESMasterKey string `yaml:"aesMasterKey"`
}

SnapshotCreds are the secrets needed to encrypt snapshot data

type TaskError

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

TaskError represents any error thrown by a task within this pkg

func (*TaskError) Error

func (e *TaskError) Error() string

Error implements the required error interface

Jump to

Keyboard shortcuts

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