Documentation ¶
Index ¶
- Constants
- Variables
- func MarshalTime(t time.Time) int64
- func UnmarshalTime(v int64) time.Time
- type Config
- type ContinuousQueryInfo
- type Data
- func (data *Data) Clone() *Data
- func (data *Data) CreateContinuousQuery(database, name, query string) error
- func (data *Data) CreateDatabase(name string) error
- func (data *Data) CreateNode(host string) error
- func (data *Data) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) error
- func (data *Data) CreateShardGroup(database, policy string, timestamp time.Time) error
- func (data *Data) CreateSubscription(database, rp, name, mode string, destinations []string) error
- func (data *Data) CreateUser(name, hash string, admin bool) error
- func (data *Data) Database(name string) *DatabaseInfo
- func (data *Data) DeleteNode(id uint64, force bool) error
- func (data *Data) DeleteShardGroup(database, policy string, id uint64) error
- func (data *Data) DropContinuousQuery(database, name string) error
- func (data *Data) DropDatabase(name string) error
- func (data *Data) DropRetentionPolicy(database, name string) error
- func (data *Data) DropSubscription(database, rp, name string) error
- func (data *Data) DropUser(name string) error
- func (data *Data) MarshalBinary() ([]byte, error)
- func (data *Data) Node(id uint64) *NodeInfo
- func (data *Data) NodeByHost(host string) *NodeInfo
- func (data *Data) RetentionPolicy(database, name string) (*RetentionPolicyInfo, error)
- func (data *Data) SetAdminPrivilege(name string, admin bool) error
- func (data *Data) SetDefaultRetentionPolicy(database, name string) error
- func (data *Data) SetPrivilege(name, database string, p influxql.Privilege) error
- func (data *Data) ShardGroupByTimestamp(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)
- func (data *Data) ShardGroups(database, policy string) ([]ShardGroupInfo, error)
- func (data *Data) ShardGroupsByTimeRange(database, policy string, tmin, tmax time.Time) ([]ShardGroupInfo, error)
- func (data *Data) UnmarshalBinary(buf []byte) error
- func (data *Data) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error
- func (data *Data) UpdateUser(name, hash string) error
- func (data *Data) User(username string) *UserInfo
- func (data *Data) UserPrivilege(name, database string) (*influxql.Privilege, error)
- func (data *Data) UserPrivileges(name string) (map[string]influxql.Privilege, error)
- type DatabaseInfo
- type HashPasswordFn
- type JoinResult
- type NodeInfo
- type NodeInfos
- type Reply
- type RetentionPolicyInfo
- type RetentionPolicyUpdate
- type ShardGroupInfo
- type ShardGroupInfos
- type ShardInfo
- type ShardOwner
- type StatementExecutor
- type Store
- func (s *Store) AddPeer(addr string) error
- func (s *Store) AdminUserExists() (exists bool, err error)
- func (s *Store) Authenticate(username, password string) (ui *UserInfo, err error)
- func (s *Store) Close() error
- func (s *Store) ClusterID() (id uint64, err error)
- func (s *Store) CreateContinuousQuery(database, name, query string) error
- func (s *Store) CreateDatabase(name string) (*DatabaseInfo, error)
- func (s *Store) CreateDatabaseIfNotExists(name string) (*DatabaseInfo, error)
- func (s *Store) CreateDatabaseWithRetentionPolicy(name string, rpi *RetentionPolicyInfo) (*DatabaseInfo, error)
- func (s *Store) CreateNode(host string) (*NodeInfo, error)
- func (s *Store) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error)
- func (s *Store) CreateRetentionPolicyIfNotExists(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error)
- func (s *Store) CreateShardGroup(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)
- func (s *Store) CreateShardGroupIfNotExists(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)
- func (s *Store) CreateSubscription(database, rp, name, mode string, destinations []string) error
- func (s *Store) CreateUser(name, password string, admin bool) (*UserInfo, error)
- func (s *Store) Database(name string) (di *DatabaseInfo, err error)
- func (s *Store) Databases() (dis []DatabaseInfo, err error)
- func (s *Store) DefaultRetentionPolicy(database string) (rpi *RetentionPolicyInfo, err error)
- func (s *Store) DeleteNode(id uint64, force bool) error
- func (s *Store) DeleteShardGroup(database, policy string, id uint64) error
- func (s *Store) DropContinuousQuery(database, name string) error
- func (s *Store) DropDatabase(name string) error
- func (s *Store) DropRetentionPolicy(database, name string) error
- func (s *Store) DropSubscription(database, rp, name string) error
- func (s *Store) DropUser(name string) error
- func (s *Store) Err() <-chan error
- func (s *Store) GetHashPasswordFn() HashPasswordFn
- func (s *Store) IDPath() string
- func (s *Store) IsLeader() bool
- func (s *Store) IsLocal() bool
- func (s *Store) Leader() string
- func (s *Store) MarshalBinary() ([]byte, error)
- func (s *Store) Node(id uint64) (ni *NodeInfo, err error)
- func (s *Store) NodeByHost(host string) (ni *NodeInfo, err error)
- func (s *Store) NodeID() uint64
- func (s *Store) Nodes() (a []NodeInfo, err error)
- func (s *Store) Open() error
- func (s *Store) Path() string
- func (s *Store) Peers() ([]string, error)
- func (s *Store) PrecreateShardGroups(from, to time.Time) error
- func (s *Store) Ready() <-chan struct{}
- func (s *Store) RetentionPolicies(database string) (a []RetentionPolicyInfo, err error)
- func (s *Store) RetentionPolicy(database, name string) (rpi *RetentionPolicyInfo, err error)
- func (s *Store) SetAdminPrivilege(username string, admin bool) error
- func (s *Store) SetData(data *Data) error
- func (s *Store) SetDefaultRetentionPolicy(database, name string) error
- func (s *Store) SetHashPasswordFn(fn HashPasswordFn)
- func (s *Store) SetPeers(addrs []string) error
- func (s *Store) SetPrivilege(username, database string, p influxql.Privilege) error
- func (s *Store) ShardGroupByTimestamp(database, policy string, timestamp time.Time) (sgi *ShardGroupInfo, err error)
- func (s *Store) ShardGroups(database, policy string) (a []ShardGroupInfo, err error)
- func (s *Store) ShardGroupsByTimeRange(database, policy string, tmin, tmax time.Time) (a []ShardGroupInfo, err error)
- func (s *Store) ShardOwner(shardID uint64) (database, policy string, sgi *ShardGroupInfo)
- func (s *Store) Snapshot() error
- func (s *Store) UpdateNode(id uint64, host string) (*NodeInfo, error)
- func (s *Store) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error
- func (s *Store) UpdateUser(name, password string) error
- func (s *Store) User(name string) (ui *UserInfo, err error)
- func (s *Store) UserCount() (count int, err error)
- func (s *Store) UserPrivilege(username, database string) (p *influxql.Privilege, err error)
- func (s *Store) UserPrivileges(username string) (p map[string]influxql.Privilege, err error)
- func (s *Store) Users() (a []UserInfo, err error)
- func (s *Store) VisitRetentionPolicies(f func(d DatabaseInfo, r RetentionPolicyInfo))
- func (s *Store) WaitForDataChanged() error
- func (s *Store) WaitForLeader(timeout time.Duration) error
- type SubscriptionInfo
- type UserInfo
Constants ¶
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 // DefaultRaftPromotionEnabled is the default for auto promoting a node to a raft node when needed DefaultRaftPromotionEnabled = true // DefaultLoggingEnabled determines if log messages are printed for the meta service DefaultLoggingEnabled = true )
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 )
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.
const ( AutoCreateRetentionPolicyName = "default" AutoCreateRetentionPolicyPeriod = 0 // MaxAutoCreatedRetentionPolicyReplicaN is the maximum replication factor that will // be set for auto-created retention policies. MaxAutoCreatedRetentionPolicyReplicaN = 3 )
Retention policy settings.
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.
const (
MaxMessageSize = 1024 * 1024 * 1024
)
Max size of a message before we treat the size as invalid
const (
MaxRaftNodes = 3
)
Raft configuration.
Variables ¶
var ( // ErrStoreOpen is returned when opening an already open store. ErrStoreOpen = newError("store already open") // ErrStoreClosed is returned when closing an already closed store. ErrStoreClosed = newError("raft store already closed") // ErrTooManyPeers is returned when more than 3 peers are used. ErrTooManyPeers = newError("too many peers; influxdb v0.9.0 is limited to 3 nodes in a cluster") )
var ( // ErrNodeExists is returned when creating an already existing node. ErrNodeExists = newError("node already exists") // ErrNodeNotFound is returned when mutating a node that doesn't exist. ErrNodeNotFound = newError("node not found") // ErrNodesRequired is returned when at least one node is required for an operation. // This occurs when creating a shard group. ErrNodesRequired = newError("at least one node required") // ErrNodeIDRequired is returned when using a zero node id. ErrNodeIDRequired = newError("node id must be greater than 0") // ErrNodeUnableToDropFinalNode is returned if the node being dropped is the last // node in the cluster ErrNodeUnableToDropFinalNode = newError("unable to drop the final node in a cluster") )
var ( // ErrDatabaseExists is returned when creating an already existing database. ErrDatabaseExists = newError("database already exists") // ErrDatabaseNameRequired is returned when creating a database without a name. ErrDatabaseNameRequired = newError("database name required") )
var ( // ErrRetentionPolicyExists is returned when creating an already existing policy. ErrRetentionPolicyExists = newError("retention policy already exists") // ErrRetentionPolicyDefault is returned when attempting a prohibited operation // on a default retention policy. ErrRetentionPolicyDefault = newError("retention policy is default") // ErrRetentionPolicyNameRequired is returned when creating a policy without a name. ErrRetentionPolicyNameRequired = newError("retention policy name required") // ErrRetentionPolicyNameExists is returned when renaming a policy to // the same name as another existing policy. ErrRetentionPolicyNameExists = newError("retention policy name already exists") // ErrRetentionPolicyDurationTooLow is returned when updating a retention // policy that has a duration lower than the allowed minimum. ErrRetentionPolicyDurationTooLow = newError(fmt.Sprintf("retention policy duration must be at least %s", MinRetentionPolicyDuration)) // ErrReplicationFactorTooLow is returned when the replication factor is not in an // acceptable range. ErrReplicationFactorTooLow = newError("replication factor must be greater than 0") )
var ( // ErrShardGroupExists is returned when creating an already existing shard group. ErrShardGroupExists = newError("shard group already exists") // ErrShardGroupNotFound is returned when mutating a shard group that doesn't exist. ErrShardGroupNotFound = newError("shard group not found") // ErrShardNotReplicated is returned if the node requested to be dropped has // the last copy of a shard present and the force keyword was not used ErrShardNotReplicated = newError("shard not replicated") )
var ( // ErrContinuousQueryExists is returned when creating an already existing continuous query. ErrContinuousQueryExists = newError("continuous query already exists") // ErrContinuousQueryNotFound is returned when removing a continuous query that doesn't exist. ErrContinuousQueryNotFound = newError("continuous query not found") )
var ( // ErrSubscriptionExists is returned when creating an already existing subscription. ErrSubscriptionExists = newError("subscription already exists") // ErrSubscriptionNotFound is returned when removing a subscription that doesn't exist. ErrSubscriptionNotFound = newError("subscription not found") )
var ( // ErrUserExists is returned when creating an already existing user. ErrUserExists = newError("user already exists") // ErrUserNotFound is returned when mutating a user that doesn't exist. ErrUserNotFound = newError("user not found") // ErrUsernameRequired is returned when creating a user without a username. ErrUsernameRequired = newError("username required") )
var BcryptCost = 10
BcryptCost is the cost associated with generating password with Bcrypt. This setting is lowered during testing to improve test suite performance.
var ErrAuthenticate = errors.New("authentication failed")
ErrAuthenticate is returned when authentication fails.
Functions ¶
func MarshalTime ¶
MarshalTime converts t to nanoseconds since epoch. A zero time returns 0.
func UnmarshalTime ¶
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"` RaftPromotionEnabled bool `toml:"raft-promotion-enabled"` LoggingEnabled bool `toml:"logging-enabled"` }
Config represents the meta configuration.
type ContinuousQueryInfo ¶
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) CreateContinuousQuery ¶
CreateContinuousQuery adds a named continuous query to a database.
func (*Data) CreateDatabase ¶
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 ¶
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 ¶
CreateShardGroup creates a shard group on a database and policy for a given timestamp.
func (*Data) CreateSubscription ¶ added in v0.9.5
CreateSubscription adds a named subscription to a database and retention policy.
func (*Data) CreateUser ¶
CreateUser creates a new user.
func (*Data) Database ¶
func (data *Data) Database(name string) *DatabaseInfo
Database returns a database by name.
func (*Data) DeleteNode ¶
DeleteNode removes a node from the metadata.
func (*Data) DeleteShardGroup ¶
DeleteShardGroup removes a shard group from a database and retention policy by id.
func (*Data) DropContinuousQuery ¶
DropContinuousQuery removes a continuous query.
func (*Data) DropDatabase ¶
DropDatabase removes a database by name.
func (*Data) DropRetentionPolicy ¶
DropRetentionPolicy removes a retention policy from a database by name.
func (*Data) DropSubscription ¶ added in v0.9.5
DropSubscription removes a subscription.
func (*Data) MarshalBinary ¶
MarshalBinary encodes the metadata to a binary format.
func (*Data) NodeByHost ¶
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
SetAdminPrivilege sets the admin privilege for a user.
func (*Data) SetDefaultRetentionPolicy ¶
SetDefaultRetentionPolicy sets the default retention policy for a database.
func (*Data) SetPrivilege ¶
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)
ShardGroups 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 ¶
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 ¶
UpdateUser updates the password hash of an existing user.
func (*Data) UserPrivilege ¶ added in v0.9.2
UserPrivilege gets the privilege for a user on a database.
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.5
func (di DatabaseInfo) ShardInfos() []ShardInfo
ShardInfos returns a list of all shards' info for the database.
type HashPasswordFn ¶ added in v0.9.1
HashPasswordFn represnets a password hashing function.
type JoinResult ¶ added in v0.9.3
JoinResult defines the join result structure.
type NodeInfos ¶ added in v0.9.5
type NodeInfos []NodeInfo
NodeInfos is a slice of NodeInfo used for sorting
type Reply ¶ added in v0.9.3
type Reply interface {
GetHeader() *internal.ResponseHeader
}
Reply defines the interface for Reply objects.
type RetentionPolicyInfo ¶
type RetentionPolicyInfo struct { Name string ReplicaN int Duration time.Duration ShardGroupDuration time.Duration ShardGroups []ShardGroupInfo Subscriptions []SubscriptionInfo }
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 ¶
RetentionPolicyUpdate represents retention policy fields to be updated.
func (*RetentionPolicyUpdate) SetDuration ¶
func (rpu *RetentionPolicyUpdate) SetDuration(v time.Duration)
SetDuration sets the RetentionPolicyUpdate.Duration
func (*RetentionPolicyUpdate) SetName ¶
func (rpu *RetentionPolicyUpdate) SetName(v string)
SetName sets the RetentionPolicyUpdate.Name
func (*RetentionPolicyUpdate) SetReplicaN ¶
func (rpu *RetentionPolicyUpdate) SetReplicaN(v int)
SetReplicaN sets the RetentionPolicyUpdate.ReplicaN
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 (sgi *ShardGroupInfo) ShardFor(hash uint64) ShardInfo
ShardFor returns the ShardInfo for a Point hash
type ShardGroupInfos ¶ added in v0.9.2
type ShardGroupInfos []ShardGroupInfo
ShardGroupInfos is a collection of 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
OwnedBy returns whether the shard's owner IDs includes nodeID.
func (*ShardInfo) UnmarshalBinary ¶ added in v0.9.5
UnmarshalBinary decodes the object from a binary format.
type ShardOwner ¶ added in v0.9.5
type ShardOwner struct {
NodeID uint64
}
ShardOwner represents a node that owns a shard.
type StatementExecutor ¶
type StatementExecutor struct { Store interface { Node(id uint64) (ni *NodeInfo, err error) Nodes() ([]NodeInfo, error) Peers() ([]string, error) Leader() string DeleteNode(nodeID uint64, force bool) error Database(name string) (*DatabaseInfo, error) Databases() ([]DatabaseInfo, error) CreateDatabase(name string) (*DatabaseInfo, error) CreateDatabaseWithRetentionPolicy(name string, rpi *RetentionPolicyInfo) (*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 CreateSubscription(database, rp, name, mode string, destinations []string) error DropSubscription(database, rp, 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 (*Store) AdminUserExists ¶
AdminUserExists returns true if an admin user exists on the system.
func (*Store) Authenticate ¶
Authenticate retrieves a user with a matching username and password.
func (*Store) ClusterID ¶
ClusterID returns the unique identifier for the cluster. This is generated once a node has been created.
func (*Store) CreateContinuousQuery ¶
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) CreateDatabaseWithRetentionPolicy ¶
func (s *Store) CreateDatabaseWithRetentionPolicy(name string, rpi *RetentionPolicyInfo) (*DatabaseInfo, error)
CreateDatabaseWithRetentionPolicy creates a new database with an explicit retention policy in the store.
func (*Store) CreateNode ¶
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) CreateSubscription ¶ added in v0.9.5
CreateSubscription creates a new subscription on the store.
func (*Store) CreateUser ¶
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 ¶
DeleteNode removes a node from the metastore by id.
func (*Store) DeleteShardGroup ¶
DeleteShardGroup removes an existing shard group from a policy by ID.
func (*Store) DropContinuousQuery ¶
DropContinuousQuery removes a continuous query from the store.
func (*Store) DropDatabase ¶
DropDatabase removes a database from the metastore by name.
func (*Store) DropRetentionPolicy ¶
DropRetentionPolicy removes a policy from a database by name.
func (*Store) DropSubscription ¶ added in v0.9.5
DropSubscription removes a subscription from the store.
func (*Store) GetHashPasswordFn ¶ added in v0.9.1
func (s *Store) GetHashPasswordFn() HashPasswordFn
GetHashPasswordFn returns the current password hashing function.
func (*Store) IsLocal ¶ added in v0.9.5
IsLocal returns true if the store is currently participating in local raft.
func (*Store) Leader ¶
Leader returns what the store thinks is the current leader. An empty string indicates no leader exists.
func (*Store) MarshalBinary ¶
MarshalBinary encodes the store's data to a binary protobuf format.
func (*Store) NodeByHost ¶
NodeByHost returns a node by hostname.
func (*Store) NodeID ¶
NodeID returns the identifier for the local node. Panics if the node has not joined the cluster.
func (*Store) Path ¶
Path returns the root path when open. Returns an empty string when the store is closed.
func (*Store) PrecreateShardGroups ¶
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
SetAdminPrivilege sets the admin privilege for a user on a database.
func (*Store) SetData ¶
SetData force overwrites the root data. This should only be used when restoring a snapshot.
func (*Store) SetDefaultRetentionPolicy ¶
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) SetPrivilege ¶
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)
ShardOwner looks up for a specific shard and return the shard group information related with the shard.
func (*Store) UpdateNode ¶ added in v0.9.3
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 ¶
UpdateUser updates an existing user in the store.
func (*Store) UserPrivilege ¶ added in v0.9.2
UserPrivilege returns the privilege for a database.
func (*Store) UserPrivileges ¶ added in v0.9.1
UserPrivileges returns a list of all databases.
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
WaitForDataChanged will block the current goroutine until the metastore index has be updated.
type SubscriptionInfo ¶ added in v0.9.5
SubscriptionInfo hold the subscription information