cassandra

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2017 License: MIT Imports: 17 Imported by: 10

README

What

This package contains the tooling for cadence cassandra operations.

How

  • Run make bins
  • You should see an executable cadence-cassandra-tool

Setting up initial cassandra schema on a new cluster

./cadence-cassandra-tool -ep 127.0.0.1 -k cadence setup-schema -v 0.0 -- this sets up just the schema version tables with initial version of 0.0
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cadence -- upgrades your schema to the latest version

Updating schema on an existing cluster

You can only upgrade to a new version after the initial setup done above.

./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cadence -v x.x -y -- executes a dryrun of upgrade to version x.x
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cadence -v x.x    -- actually executes the upgrade to version x.x

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 RunTool

func RunTool(args []string) error

RunTool runs the cadence-cassandra-tool command line tool

func SetupSchema

func SetupSchema(config *SetupSchemaConfig) error

SetupSchema setups the cassandra schema

Types

type BaseConfig

type BaseConfig struct {
	CassHosts    string
	CassKeyspace string
}

BaseConfig is the common config for all of the tasks that work with cassandra

type CQLClient

type CQLClient interface {
	// Exec executes a cql statement
	Exec(stmt string) error
	// ListTables lists the table names in a keyspace
	ListTables() ([]string, error)
	// ListTypes lists the user defined types in a keyspace
	ListTypes() ([]string, error)
	// CreateKeyspace creates a keyspace, if it doesn't exist
	// it uses SimpleStrategy by default
	CreateKeyspace(name string, replicas int) error
	// DropTable drops the given table
	DropTable(name string) error
	// DropType drops a user defined type from keyspace
	DropType(name string) error
	// DropKeyspace drops a keyspace
	DropKeyspace(keyspace string) error
	// CreateSchemaVersionTables sets up the schema version tables
	CreateSchemaVersionTables() error
	// ReadSchemaVersion returns the current schema version for the keyspace
	ReadSchemaVersion() (string, error)
	// UpdateSchemaVersion updates the schema version for the keyspace
	UpdateSchemaVersion(newVersion string, minCompatibleVersion string) error
	// WriteSchemaUpdateLog adds an entry to the schema update history table
	WriteSchemaUpdateLog(oldVersion string, newVersion string, manifestMD5 string, desc string) error
	// Close gracefully closes the client object
	Close()
}

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

type ConfigError

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

ConfigError is an error type that represents a problem with the config

func (*ConfigError) Error

func (e *ConfigError) Error() string

type CreateKeyspaceConfig

type CreateKeyspaceConfig struct {
	BaseConfig
	ReplicationFactor int
}

CreateKeyspaceConfig holds the config params needed to create a cassandra keyspace

type SetupSchemaConfig

type SetupSchemaConfig struct {
	BaseConfig
	SchemaFilePath    string
	InitialVersion    string
	Overwrite         bool // overwrite previous data
	DisableVersioning bool // do not use schema versioning
}

SetupSchemaConfig holds the config params need by the SetupSchemaTask

type SetupSchemaTask

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

SetupSchemaTask represents a task that sets up cassandra schema on a specified keyspace

type UpdateSchemaConfig

type UpdateSchemaConfig struct {
	BaseConfig
	TargetVersion string
	SchemaDir     string
	IsDryRun      bool
}

UpdateSchemaConfig holds the config params for executing a UpdateSchemaTask

type UpdateSchemaTask

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

UpdateSchemaTask represents a task that executes a cassandra schema upgrade

func NewUpdateSchemaTask

func NewUpdateSchemaTask(config *UpdateSchemaConfig) (*UpdateSchemaTask, error)

NewUpdateSchemaTask returns a new instance of UpdateSchemaTask

Jump to

Keyboard shortcuts

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