metrictank: Index | Files

package cassandra

import ""


Package Files

cassandra.go config.go table.go


const Month_sec = 60 * 60 * 24 * 28
const QueryFmtRead = "SELECT ts, data FROM %s WHERE key IN ? AND ts >= ? AND ts < ?"
const QueryFmtWrite = "INSERT INTO %s (key, ts, data) values(?,?,?) USING TTL ?"
const Table_name_format = `metric_%d`


var CliConfig = NewStoreConfig()

func ConfigSetup Uses

func ConfigSetup() *flag.FlagSet

func ConvertTimeout Uses

func ConvertTimeout(timeout string, defaultUnit time.Duration) time.Duration

ConvertTimeout provides backwards compatibility for values that used to be specified as integers, while also allowing them to be specified as durations.

func IsStoreTable Uses

func IsStoreTable(name string) bool

type CassandraStore Uses

type CassandraStore struct {
    Session *cassandra.Session

    TTLTables TTLTables
    // contains filtered or unexported fields

func NewCassandraStore Uses

func NewCassandraStore(config *StoreConfig, ttls []uint32, schemaMaxChunkSpan uint32) (*CassandraStore, error)

NewCassandraStore creates a new cassandra store, using the provided retention ttl's in seconds

func (*CassandraStore) Add Uses

func (c *CassandraStore) Add(cwr *mdata.ChunkWriteRequest)

func (*CassandraStore) FindExistingTables Uses

func (c *CassandraStore) FindExistingTables(keyspace string) error

FindExistingTables set's the store's table definitions to what it can find in the database. WARNING: * does not set the windowSize property, because we don't know what the windowFactor was

we could actually figure it based on the table definition, assuming the schema isn't tampered with,
but there is no use case for this so we haven't implemented this.

* each table covers a range of TTL's. we set the TTL to the lower limit

so remember the TTL might have been up to twice as much

func (*CassandraStore) Search Uses

func (c *CassandraStore) Search(ctx context.Context, key schema.AMKey, ttl, start, end uint32) ([]chunk.IterGen, error)

Basic search of cassandra in the table for given ttl start inclusive, end exclusive

func (*CassandraStore) SearchTable Uses

func (c *CassandraStore) SearchTable(ctx context.Context, key schema.AMKey, table Table, start, end uint32) ([]chunk.IterGen, error)

Basic search of cassandra in given table start inclusive, end exclusive

func (*CassandraStore) SetTracer Uses

func (c *CassandraStore) SetTracer(t opentracing.Tracer)

func (*CassandraStore) Stop Uses

func (c *CassandraStore) Stop()

type ChunkReadRequest Uses

type ChunkReadRequest struct {
    // contains filtered or unexported fields

type StoreConfig Uses

type StoreConfig struct {
    Enabled                  bool
    Addrs                    string
    Keyspace                 string
    Consistency              string
    HostSelectionPolicy      string
    Timeout                  string
    ReadConcurrency          int
    WriteConcurrency         int
    ReadQueueSize            int
    WriteQueueSize           int
    Retries                  int
    WindowFactor             int
    OmitReadTimeout          string
    CqlProtocolVersion       int
    CreateKeyspace           bool
    DisableInitialHostLookup bool
    SSL                      bool
    CaPath                   string
    HostVerification         bool
    Auth                     bool
    Username                 string
    Password                 string
    SchemaFile               string
    ConnectionCheckInterval  time.Duration
    ConnectionCheckTimeout   time.Duration
    MaxChunkSpan             time.Duration

func NewStoreConfig Uses

func NewStoreConfig() *StoreConfig

return StoreConfig with default values set.

func (*StoreConfig) Validate Uses

func (cfg *StoreConfig) Validate(schemaMaxChunkSpan uint32) error

Validate makes sure the StoreConfig settings are valid

type TTLTables Uses

type TTLTables map[uint32]Table

TTLTables stores table definitions keyed by their TTL

func GetTTLTables Uses

func GetTTLTables(ttls []uint32, windowFactor int, nameFormat string) TTLTables

GetTTLTables returns table definitions for the given specifications (ttls is in seconds)

type Table Uses

type Table struct {
    Name       string
    QueryRead  string
    QueryWrite string
    WindowSize uint32
    TTL        uint32

func GetTable Uses

func GetTable(ttl uint32, windowFactor int, nameFormat string) Table

Package cassandra imports 21 packages (graph). Updated 2020-07-13. Refresh now. Tools for package owners.