meta

package
v0.9.4-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2015 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultHostname is the default hostname if one is not provided.
	DefaultHostname = "localhost"

	// DefaultBindAddress is the default address to bind to.
	DefaultBindAddress = ":8088"

	// DefaultHeartbeatTimeout is the default heartbeat timeout for the store.
	DefaultHeartbeatTimeout = 1000 * time.Millisecond

	// DefaultElectionTimeout is the default election timeout for the store.
	DefaultElectionTimeout = 1000 * time.Millisecond

	// DefaultLeaderLeaseTimeout is the default leader lease for the store.
	DefaultLeaderLeaseTimeout = 500 * time.Millisecond

	// DefaultCommitTimeout is the default commit timeout for the store.
	DefaultCommitTimeout = 50 * time.Millisecond
)
View Source
const (
	// DefaultRetentionPolicyReplicaN is the default value of RetentionPolicyInfo.ReplicaN.
	DefaultRetentionPolicyReplicaN = 1

	// DefaultRetentionPolicyDuration is the default value of RetentionPolicyInfo.Duration.
	DefaultRetentionPolicyDuration = 7 * (24 * time.Hour)

	// MinRetentionPolicyDuration represents the minimum duration for a policy.
	MinRetentionPolicyDuration = time.Hour
)
View Source
const (
	MuxRaftHeader = 0
	MuxExecHeader = 1
	MuxRPCHeader  = 5

	// SaltBytes is the number of bytes used for salts
	SaltBytes = 32

	DefaultSyncNodeDelay = time.Second
)

tcp.Mux header bytes.

View Source
const (
	AutoCreateRetentionPolicyName   = "default"
	AutoCreateRetentionPolicyPeriod = 0
	RetentionPolicyMinDuration      = time.Hour

	// MaxAutoCreatedRetentionPolicyReplicaN is the maximum replication factor that will
	// be set for auto-created retention policies.
	MaxAutoCreatedRetentionPolicyReplicaN = 3
)

Retention policy settings.

View Source
const ExecMagic = "EXEC"

ExecMagic is the first 4 bytes sent to a remote exec connection to verify that it is coming from a remote exec client connection.

View Source
const (
	MaxMessageSize = 1024 * 1024 * 1024
)

Max size of a message before we treat the size as invalid

View Source
const (
	MaxRaftNodes = 3
)

Raft configuration.

Variables

View Source
var (
	// ErrStoreOpen is returned when opening an already open store.
	ErrStoreOpen = errors.New("store already open")

	// ErrStoreClosed is returned when closing an already closed store.
	ErrStoreClosed = errors.New("raft store already closed")

	// ErrTooManyPeers is returned when more than 3 peers are used.
	ErrTooManyPeers = errors.New("too many peers; influxdb v0.9.0 is limited to 3 nodes in a cluster")
)
View Source
var (
	// ErrNodeExists is returned when creating an already existing node.
	ErrNodeExists = errors.New("node already exists")

	// ErrNodeNotFound is returned when mutating a node that doesn't exist.
	ErrNodeNotFound = errors.New("node not found")

	// ErrNodesRequired is returned when at least one node is required for an operation.
	// This occurs when creating a shard group.
	ErrNodesRequired = errors.New("at least one node required")
)
View Source
var (
	// ErrDatabaseExists is returned when creating an already existing database.
	ErrDatabaseExists = errors.New("database already exists")

	// ErrDatabaseNotFound is returned when mutating a database that doesn't exist.
	ErrDatabaseNotFound = errors.New("database not found")

	// ErrDatabaseNameRequired is returned when creating a database without a name.
	ErrDatabaseNameRequired = errors.New("database name required")
)
View Source
var (
	// ErrRetentionPolicyExists is returned when creating an already existing policy.
	ErrRetentionPolicyExists = errors.New("retention policy already exists")

	// ErrRetentionPolicyDefault is returned when attempting a prohibited operation
	// on a default retention policy.
	ErrRetentionPolicyDefault = errors.New("retention policy is default")

	// ErrRetentionPolicyNotFound is returned when mutating a policy that doesn't exist.
	ErrRetentionPolicyNotFound = errors.New("retention policy not found")

	// ErrRetentionPolicyNameRequired is returned when creating a policy without a name.
	ErrRetentionPolicyNameRequired = errors.New("retention policy name required")

	// ErrRetentionPolicyNameExists is returned when renaming a policy to
	// the same name as another existing policy.
	ErrRetentionPolicyNameExists = errors.New("retention policy name already exists")

	// ErrRetentionPolicyDurationTooLow is returned when updating a retention
	// policy that has a duration lower than the allowed minimum.
	ErrRetentionPolicyDurationTooLow = errors.New(fmt.Sprintf("retention policy duration must be at least %s",
		RetentionPolicyMinDuration))

	// ErrReplicationFactorTooLow is returned when the replication factor is not in an
	// acceptable range.
	ErrReplicationFactorTooLow = errors.New("replication factor must be greater than 0")
)
View Source
var (
	// ErrShardGroupExists is returned when creating an already existing shard group.
	ErrShardGroupExists = errors.New("shard group already exists")

	// ErrShardGroupNotFound is returned when mutating a shard group that doesn't exist.
	ErrShardGroupNotFound = errors.New("shard group not found")
)
View Source
var (
	// ErrContinuousQueryExists is returned when creating an already existing continuous query.
	ErrContinuousQueryExists = errors.New("continuous query already exists")

	// ErrContinuousQueryNotFound is returned when removing a continuous query that doesn't exist.
	ErrContinuousQueryNotFound = errors.New("continuous query not found")
)
View Source
var (
	// ErrUserExists is returned when creating an already existing user.
	ErrUserExists = errors.New("user already exists")

	// ErrUserNotFound is returned when mutating a user that doesn't exist.
	ErrUserNotFound = errors.New("user not found")

	// ErrUsernameRequired is returned when creating a user without a username.
	ErrUsernameRequired = errors.New("username required")
)
View Source
var BcryptCost = 10

BcryptCost is the cost associated with generating password with Bcrypt. This setting is lowered during testing to improve test suite performance.

View Source
var ErrAuthenticate = errors.New("authentication failed")

ErrAuthenticate is returned when authentication fails.

Functions

func MarshalTime

func MarshalTime(t time.Time) int64

MarshalTime converts t to nanoseconds since epoch. A zero time returns 0.

func UnmarshalTime

func UnmarshalTime(v int64) time.Time

UnmarshalTime converts nanoseconds since epoch to time. A zero value returns a zero time.

Types

type Config

type Config struct {
	Dir                 string        `toml:"dir"`
	Hostname            string        `toml:"hostname"`
	BindAddress         string        `toml:"bind-address"`
	Peers               []string      `toml:"-"`
	RetentionAutoCreate bool          `toml:"retention-autocreate"`
	ElectionTimeout     toml.Duration `toml:"election-timeout"`
	HeartbeatTimeout    toml.Duration `toml:"heartbeat-timeout"`
	LeaderLeaseTimeout  toml.Duration `toml:"leader-lease-timeout"`
	CommitTimeout       toml.Duration `toml:"commit-timeout"`
	ClusterTracing      bool          `toml:"cluster-tracing"`
}

Config represents the meta configuration.

func NewConfig

func NewConfig() *Config

type ContinuousQueryInfo

type ContinuousQueryInfo struct {
	Name  string
	Query string
}

ContinuousQueryInfo represents metadata about a continuous query.

type Data

type Data struct {
	Term      uint64 // associated raft term
	Index     uint64 // associated raft index
	ClusterID uint64
	Nodes     []NodeInfo
	Databases []DatabaseInfo
	Users     []UserInfo

	MaxNodeID       uint64
	MaxShardGroupID uint64
	MaxShardID      uint64
}

Data represents the top level collection of all metadata.

func (*Data) Clone

func (data *Data) Clone() *Data

Clone returns a copy of data with a new version.

func (*Data) CreateContinuousQuery

func (data *Data) CreateContinuousQuery(database, name, query string) error

CreateContinuousQuery adds a named continuous query to a database.

func (*Data) CreateDatabase

func (data *Data) CreateDatabase(name string) error

CreateDatabase creates a new database. Returns an error if name is blank or if a database with the same name already exists.

func (*Data) CreateNode

func (data *Data) CreateNode(host string) error

CreateNode adds a node to the metadata.

func (*Data) CreateRetentionPolicy

func (data *Data) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) error

CreateRetentionPolicy creates a new retention policy on a database. Returns an error if name is blank or if a database does not exist.

func (*Data) CreateShardGroup

func (data *Data) CreateShardGroup(database, policy string, timestamp time.Time) error

CreateShardGroup creates a shard group on a database and policy for a given timestamp.

func (*Data) CreateUser

func (data *Data) CreateUser(name, hash string, admin bool) error

CreateUser creates a new user.

func (*Data) Database

func (data *Data) Database(name string) *DatabaseInfo

Database returns a database by name.

func (*Data) DeleteNode

func (data *Data) DeleteNode(id uint64) error

DeleteNode removes a node from the metadata.

func (*Data) DeleteShardGroup

func (data *Data) DeleteShardGroup(database, policy string, id uint64) error

DeleteShardGroup removes a shard group from a database and retention policy by id.

func (*Data) DropContinuousQuery

func (data *Data) DropContinuousQuery(database, name string) error

DropContinuousQuery removes a continuous query.

func (*Data) DropDatabase

func (data *Data) DropDatabase(name string) error

DropDatabase removes a database by name.

func (*Data) DropRetentionPolicy

func (data *Data) DropRetentionPolicy(database, name string) error

DropRetentionPolicy removes a retention policy from a database by name.

func (*Data) DropUser

func (data *Data) DropUser(name string) error

DropUser removes an existing user by name.

func (*Data) MarshalBinary

func (data *Data) MarshalBinary() ([]byte, error)

MarshalBinary encodes the metadata to a binary format.

func (*Data) Node

func (data *Data) Node(id uint64) *NodeInfo

Node returns a node by id.

func (*Data) NodeByHost

func (data *Data) NodeByHost(host string) *NodeInfo

NodeByHost returns a node by hostname.

func (*Data) RetentionPolicy

func (data *Data) RetentionPolicy(database, name string) (*RetentionPolicyInfo, error)

RetentionPolicy returns a retention policy for a database by name.

func (*Data) SetAdminPrivilege added in v0.9.2

func (data *Data) SetAdminPrivilege(name string, admin bool) error

SetAdminPrivilege sets the admin privilege for a user.

func (*Data) SetDefaultRetentionPolicy

func (data *Data) SetDefaultRetentionPolicy(database, name string) error

SetDefaultRetentionPolicy sets the default retention policy for a database.

func (*Data) SetPrivilege

func (data *Data) SetPrivilege(name, database string, p influxql.Privilege) error

SetPrivilege sets a privilege for a user on a database.

func (*Data) ShardGroupByTimestamp

func (data *Data) ShardGroupByTimestamp(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)

ShardGroupByTimestamp returns the shard group on a database and policy for a given timestamp.

func (*Data) ShardGroups

func (data *Data) ShardGroups(database, policy string) ([]ShardGroupInfo, error)

ShardGroup returns a list of all shard groups on a database and policy.

func (*Data) ShardGroupsByTimeRange added in v0.9.2

func (data *Data) ShardGroupsByTimeRange(database, policy string, tmin, tmax time.Time) ([]ShardGroupInfo, error)

ShardGroupsByTimeRange returns a list of all shard groups on a database and policy that may contain data for the specified time range. Shard groups are sorted by start time.

func (*Data) UnmarshalBinary

func (data *Data) UnmarshalBinary(buf []byte) error

UnmarshalBinary decodes the object from a binary format.

func (*Data) UpdateRetentionPolicy

func (data *Data) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error

UpdateRetentionPolicy updates an existing retention policy.

func (*Data) UpdateUser

func (data *Data) UpdateUser(name, hash string) error

UpdateUser updates the password hash of an existing user.

func (*Data) User

func (data *Data) User(username string) *UserInfo

User returns a user by username.

func (*Data) UserPrivilege added in v0.9.2

func (data *Data) UserPrivilege(name, database string) (*influxql.Privilege, error)

UserPrivilege gets the privilege for a user on a database.

func (*Data) UserPrivileges added in v0.9.1

func (data *Data) UserPrivileges(name string) (map[string]influxql.Privilege, error)

UserPrivileges gets the privileges for a user.

type DatabaseInfo

type DatabaseInfo struct {
	Name                   string
	DefaultRetentionPolicy string
	RetentionPolicies      []RetentionPolicyInfo
	ContinuousQueries      []ContinuousQueryInfo
}

DatabaseInfo represents information about a database in the system.

func (DatabaseInfo) RetentionPolicy

func (di DatabaseInfo) RetentionPolicy(name string) *RetentionPolicyInfo

RetentionPolicy returns a retention policy by name.

func (DatabaseInfo) ShardInfos added in v0.9.4

func (di DatabaseInfo) ShardInfos() []ShardInfo

ShardInfos returns a list of all shards' info for the database.

type HashPasswordFn added in v0.9.1

type HashPasswordFn func(password string) ([]byte, error)

HashPasswordFn represnets a password hashing function.

type JoinResult added in v0.9.3

type JoinResult struct {
	RaftEnabled bool
	RaftNodes   []string
	NodeID      uint64
}

type NodeInfo

type NodeInfo struct {
	ID   uint64
	Host string
}

NodeInfo represents information about a single node in the cluster.

type Reply added in v0.9.3

type Reply interface {
	GetHeader() *internal.ResponseHeader
}

type RetentionPolicyInfo

type RetentionPolicyInfo struct {
	Name               string
	ReplicaN           int
	Duration           time.Duration
	ShardGroupDuration time.Duration
	ShardGroups        []ShardGroupInfo
}

RetentionPolicyInfo represents metadata about a retention policy.

func NewRetentionPolicyInfo

func NewRetentionPolicyInfo(name string) *RetentionPolicyInfo

NewRetentionPolicyInfo returns a new instance of RetentionPolicyInfo with defaults set.

func (*RetentionPolicyInfo) DeletedShardGroups

func (rpi *RetentionPolicyInfo) DeletedShardGroups() []*ShardGroupInfo

DeletedShardGroups returns the Shard Groups which are marked as deleted.

func (*RetentionPolicyInfo) ExpiredShardGroups

func (rpi *RetentionPolicyInfo) ExpiredShardGroups(t time.Time) []*ShardGroupInfo

ExpiredShardGroups returns the Shard Groups which are considered expired, for the given time.

func (*RetentionPolicyInfo) ShardGroupByTimestamp

func (rpi *RetentionPolicyInfo) ShardGroupByTimestamp(timestamp time.Time) *ShardGroupInfo

ShardGroupByTimestamp returns the shard group in the policy that contains the timestamp.

type RetentionPolicyUpdate

type RetentionPolicyUpdate struct {
	Name     *string
	Duration *time.Duration
	ReplicaN *int
}

RetentionPolicyUpdate represents retention policy fields to be updated.

func (*RetentionPolicyUpdate) SetDuration

func (rpu *RetentionPolicyUpdate) SetDuration(v time.Duration)

func (*RetentionPolicyUpdate) SetName

func (rpu *RetentionPolicyUpdate) SetName(v string)

func (*RetentionPolicyUpdate) SetReplicaN

func (rpu *RetentionPolicyUpdate) SetReplicaN(v int)

type ShardGroupInfo

type ShardGroupInfo struct {
	ID        uint64
	StartTime time.Time
	EndTime   time.Time
	DeletedAt time.Time
	Shards    []ShardInfo
}

ShardGroupInfo represents metadata about a shard group. The DeletedAt field is important because it makes it clear that a ShardGroup has been marked as deleted, and allow the system to be sure that a ShardGroup is not simply missing. If the DeletedAt is set, the system can safely delete any associated shards.

func (*ShardGroupInfo) Contains

func (sgi *ShardGroupInfo) Contains(timestamp time.Time) bool

Contains return true if the shard group contains data for the timestamp.

func (*ShardGroupInfo) Deleted

func (sgi *ShardGroupInfo) Deleted() bool

Deleted returns whether this ShardGroup has been deleted.

func (*ShardGroupInfo) Overlaps

func (sgi *ShardGroupInfo) Overlaps(min, max time.Time) bool

Overlaps return whether the shard group contains data for the time range between min and max

func (*ShardGroupInfo) ShardFor

func (s *ShardGroupInfo) ShardFor(hash uint64) ShardInfo

ShardFor returns the ShardInfo for a Point hash

type ShardGroupInfos added in v0.9.2

type ShardGroupInfos []ShardGroupInfo

func (ShardGroupInfos) Len added in v0.9.2

func (a ShardGroupInfos) Len() int

func (ShardGroupInfos) Less added in v0.9.2

func (a ShardGroupInfos) Less(i, j int) bool

func (ShardGroupInfos) Swap added in v0.9.2

func (a ShardGroupInfos) Swap(i, j int)

type ShardInfo

type ShardInfo struct {
	ID     uint64
	Owners []ShardOwner
}

ShardInfo represents metadata about a shard.

func (ShardInfo) OwnedBy added in v0.9.2

func (si ShardInfo) OwnedBy(nodeID uint64) bool

OwnedBy returns whether the shard's owner IDs includes nodeID.

func (*ShardInfo) UnmarshalBinary added in v0.9.4

func (si *ShardInfo) UnmarshalBinary(buf []byte) error

UnmarshalBinary decodes the object from a binary format.

type ShardOwner added in v0.9.4

type ShardOwner struct {
	NodeID uint64
}

ShardOwner represents a node that owns a shard.

type StatementExecutor

type StatementExecutor struct {
	Store interface {
		Nodes() ([]NodeInfo, error)
		Peers() ([]string, error)

		Database(name string) (*DatabaseInfo, error)
		Databases() ([]DatabaseInfo, error)
		CreateDatabase(name string) (*DatabaseInfo, error)
		DropDatabase(name string) error

		DefaultRetentionPolicy(database string) (*RetentionPolicyInfo, error)
		CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error)
		UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error
		SetDefaultRetentionPolicy(database, name string) error
		DropRetentionPolicy(database, name string) error

		Users() ([]UserInfo, error)
		CreateUser(name, password string, admin bool) (*UserInfo, error)
		UpdateUser(name, password string) error
		DropUser(name string) error
		SetPrivilege(username, database string, p influxql.Privilege) error
		SetAdminPrivilege(username string, admin bool) error
		UserPrivileges(username string) (map[string]influxql.Privilege, error)
		UserPrivilege(username, database string) (*influxql.Privilege, error)

		CreateContinuousQuery(database, name, query string) error
		DropContinuousQuery(database, name string) error
	}
}

StatementExecutor translates InfluxQL queries to meta store methods.

func (*StatementExecutor) ExecuteStatement

func (e *StatementExecutor) ExecuteStatement(stmt influxql.Statement) *influxql.Result

ExecuteStatement executes stmt against the meta store as user.

type Store

type Store struct {

	// The address used by other nodes to reach this node.
	RemoteAddr net.Addr

	// The listeners to accept raft and remote exec connections from.
	RaftListener net.Listener
	ExecListener net.Listener

	// The listener for higher-level, cluster operations
	RPCListener net.Listener

	// The advertised hostname of the store.
	Addr net.Addr

	// The amount of time before a follower starts a new election.
	HeartbeatTimeout time.Duration

	// The amount of time before a candidate starts a new election.
	ElectionTimeout time.Duration

	// The amount of time without communication to the cluster before a
	// leader steps down to a follower state.
	LeaderLeaseTimeout time.Duration

	// The amount of time without an apply before sending a heartbeat.
	CommitTimeout time.Duration

	Logger *log.Logger
	// contains filtered or unexported fields
}

Store represents a raft-backed metastore.

func NewStore

func NewStore(c *Config) *Store

NewStore returns a new instance of Store.

func (*Store) AddPeer added in v0.9.3

func (s *Store) AddPeer(addr string) error

AddPeer adds addr to the list of peers in the cluster.

func (*Store) AdminUserExists

func (s *Store) AdminUserExists() (exists bool, err error)

AdminUserExists returns true if an admin user exists on the system.

func (*Store) Authenticate

func (s *Store) Authenticate(username, password string) (ui *UserInfo, err error)

Authenticate retrieves a user with a matching username and password.

func (*Store) Close

func (s *Store) Close() error

Close closes the store and shuts down the node in the cluster.

func (*Store) ClusterID

func (s *Store) ClusterID() (id uint64, err error)

ClusterID returns the unique identifier for the cluster. This is generated once a node has been created.

func (*Store) CreateContinuousQuery

func (s *Store) CreateContinuousQuery(database, name, query string) error

CreateContinuousQuery creates a new continuous query on the store.

func (*Store) CreateDatabase

func (s *Store) CreateDatabase(name string) (*DatabaseInfo, error)

CreateDatabase creates a new database in the store.

func (*Store) CreateDatabaseIfNotExists

func (s *Store) CreateDatabaseIfNotExists(name string) (*DatabaseInfo, error)

CreateDatabaseIfNotExists creates a new database in the store if it doesn't already exist.

func (*Store) CreateNode

func (s *Store) CreateNode(host string) (*NodeInfo, error)

CreateNode creates a new node in the store.

func (*Store) CreateRetentionPolicy

func (s *Store) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error)

CreateRetentionPolicy creates a new retention policy for a database.

func (*Store) CreateRetentionPolicyIfNotExists

func (s *Store) CreateRetentionPolicyIfNotExists(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error)

CreateRetentionPolicyIfNotExists creates a new policy in the store if it doesn't already exist.

func (*Store) CreateShardGroup

func (s *Store) CreateShardGroup(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)

CreateShardGroup creates a new shard group in a retention policy for a given time.

func (*Store) CreateShardGroupIfNotExists

func (s *Store) CreateShardGroupIfNotExists(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)

CreateShardGroupIfNotExists creates a new shard group if one doesn't already exist.

func (*Store) CreateUser

func (s *Store) CreateUser(name, password string, admin bool) (*UserInfo, error)

CreateUser creates a new user in the store.

func (*Store) Database

func (s *Store) Database(name string) (di *DatabaseInfo, err error)

Database returns a database by name.

func (*Store) Databases

func (s *Store) Databases() (dis []DatabaseInfo, err error)

Databases returns a list of all databases.

func (*Store) DefaultRetentionPolicy

func (s *Store) DefaultRetentionPolicy(database string) (rpi *RetentionPolicyInfo, err error)

DefaultRetentionPolicy returns the default retention policy for a database.

func (*Store) DeleteNode

func (s *Store) DeleteNode(id uint64) error

DeleteNode removes a node from the metastore by id.

func (*Store) DeleteShardGroup

func (s *Store) DeleteShardGroup(database, policy string, id uint64) error

DeleteShardGroup removes an existing shard group from a policy by ID.

func (*Store) DropContinuousQuery

func (s *Store) DropContinuousQuery(database, name string) error

DropContinuousQuery removes a continuous query from the store.

func (*Store) DropDatabase

func (s *Store) DropDatabase(name string) error

DropDatabase removes a database from the metastore by name.

func (*Store) DropRetentionPolicy

func (s *Store) DropRetentionPolicy(database, name string) error

DropRetentionPolicy removes a policy from a database by name.

func (*Store) DropUser

func (s *Store) DropUser(name string) error

DropUser removes a user from the metastore by name.

func (*Store) Err

func (s *Store) Err() <-chan error

Err returns a channel for all out-of-band errors.

func (*Store) GetHashPasswordFn added in v0.9.1

func (s *Store) GetHashPasswordFn() HashPasswordFn

GetHashPasswordFn returns the current password hashing function.

func (*Store) IDPath

func (s *Store) IDPath() string

IDPath returns the path to the local node ID file.

func (*Store) IsLeader

func (s *Store) IsLeader() bool

IsLeader returns true if the store is currently the leader.

func (*Store) Leader

func (s *Store) Leader() string

Leader returns what the store thinks is the current leader. An empty string indicates no leader exists.

func (*Store) MarshalBinary

func (s *Store) MarshalBinary() ([]byte, error)

MarshalBinary encodes the store's data to a binary protobuf format.

func (*Store) Node

func (s *Store) Node(id uint64) (ni *NodeInfo, err error)

Node returns a node by id.

func (*Store) NodeByHost

func (s *Store) NodeByHost(host string) (ni *NodeInfo, err error)

NodeByHost returns a node by hostname.

func (*Store) NodeID

func (s *Store) NodeID() uint64

NodeID returns the identifier for the local node. Panics if the node has not joined the cluster.

func (*Store) Nodes

func (s *Store) Nodes() (a []NodeInfo, err error)

Nodes returns a list of all nodes.

func (*Store) Open

func (s *Store) Open() error

Open opens and initializes the raft store.

func (*Store) Path

func (s *Store) Path() string

Path returns the root path when open. Returns an empty string when the store is closed.

func (*Store) Peers added in v0.9.3

func (s *Store) Peers() ([]string, error)

Peers returns the list of peers in the cluster.

func (*Store) PrecreateShardGroups

func (s *Store) PrecreateShardGroups(from, to time.Time) error

PrecreateShardGroups creates shard groups whose endtime is before the 'to' time passed in, but is yet to expire before 'from'. This is to avoid the need for these shards to be created when data for the corresponding time range arrives. Shard creation involves Raft consensus, and precreation avoids taking the hit at write-time.

func (*Store) Ready

func (s *Store) Ready() <-chan struct{}

Ready returns a channel that is closed once the store is initialized.

func (*Store) RetentionPolicies

func (s *Store) RetentionPolicies(database string) (a []RetentionPolicyInfo, err error)

RetentionPolicies returns a list of all retention policies for a database.

func (*Store) RetentionPolicy

func (s *Store) RetentionPolicy(database, name string) (rpi *RetentionPolicyInfo, err error)

RetentionPolicy returns a retention policy for a database by name.

func (*Store) SetAdminPrivilege added in v0.9.2

func (s *Store) SetAdminPrivilege(username string, admin bool) error

SetAdminPrivilege sets the admin privilege for a user on a database.

func (*Store) SetData

func (s *Store) SetData(data *Data) error

SetData force overwrites the root data. This should only be used when restoring a snapshot.

func (*Store) SetDefaultRetentionPolicy

func (s *Store) SetDefaultRetentionPolicy(database, name string) error

SetDefaultRetentionPolicy sets the default retention policy for a database.

func (*Store) SetHashPasswordFn added in v0.9.1

func (s *Store) SetHashPasswordFn(fn HashPasswordFn)

SetHashPasswordFn sets the password hashing function.

func (*Store) SetPeers

func (s *Store) SetPeers(addrs []string) error

SetPeers sets a list of peers in the cluster.

func (*Store) SetPrivilege

func (s *Store) SetPrivilege(username, database string, p influxql.Privilege) error

SetPrivilege sets a privilege for a user on a database.

func (*Store) ShardGroupByTimestamp

func (s *Store) ShardGroupByTimestamp(database, policy string, timestamp time.Time) (sgi *ShardGroupInfo, err error)

ShardGroupByTimestamp returns a shard group for a policy by timestamp.

func (*Store) ShardGroups

func (s *Store) ShardGroups(database, policy string) (a []ShardGroupInfo, err error)

ShardGroups returns a list of all shard groups for a policy by timestamp.

func (*Store) ShardGroupsByTimeRange added in v0.9.2

func (s *Store) ShardGroupsByTimeRange(database, policy string, tmin, tmax time.Time) (a []ShardGroupInfo, err error)

ShardGroupsByTimeRange returns a slice of ShardGroups that may contain data for the given time range. ShardGroups are sorted by start time.

func (*Store) ShardOwner

func (s *Store) ShardOwner(shardID uint64) (database, policy string, sgi *ShardGroupInfo)

func (*Store) Snapshot added in v0.9.1

func (s *Store) Snapshot() error

Snapshot saves a snapshot of the current state.

func (*Store) UpdateNode added in v0.9.3

func (s *Store) UpdateNode(id uint64, host string) (*NodeInfo, error)

UpdateNode updates an existing node in the store.

func (*Store) UpdateRetentionPolicy

func (s *Store) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error

UpdateRetentionPolicy updates an existing retention policy.

func (*Store) UpdateUser

func (s *Store) UpdateUser(name, password string) error

UpdateUser updates an existing user in the store.

func (*Store) User

func (s *Store) User(name string) (ui *UserInfo, err error)

User returns a user by name.

func (*Store) UserCount

func (s *Store) UserCount() (count int, err error)

UserCount returns the number of users defined in the cluster.

func (*Store) UserPrivilege added in v0.9.2

func (s *Store) UserPrivilege(username, database string) (p *influxql.Privilege, err error)

UserPrivilege returns the privilege for a database.

func (*Store) UserPrivileges added in v0.9.1

func (s *Store) UserPrivileges(username string) (p map[string]influxql.Privilege, err error)

UserPrivileges returns a list of all databases.

func (*Store) Users

func (s *Store) Users() (a []UserInfo, err error)

Users returns a list of all users.

func (*Store) VisitRetentionPolicies

func (s *Store) VisitRetentionPolicies(f func(d DatabaseInfo, r RetentionPolicyInfo))

VisitRetentionPolicies calls the given function with full retention policy details.

func (*Store) WaitForDataChanged added in v0.9.3

func (s *Store) WaitForDataChanged() error

WaitForDataChanged will block the current goroutine until the metastore index has be updated.

func (*Store) WaitForLeader added in v0.9.1

func (s *Store) WaitForLeader(timeout time.Duration) error

WaitForLeader sleeps until a leader is found or a timeout occurs. timeout == 0 means to wait forever.

type UserInfo

type UserInfo struct {
	Name       string
	Hash       string
	Admin      bool
	Privileges map[string]influxql.Privilege
}

UserInfo represents metadata about a user in the system.

func (*UserInfo) Authorize

func (ui *UserInfo) Authorize(privilege influxql.Privilege, database string) bool

Authorize returns true if the user is authorized and false if not.

Directories

Path Synopsis
Package internal is a generated protocol buffer package.
Package internal is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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