Documentation ¶
Index ¶
- Constants
- Variables
- func ReadTLV(r io.Reader) (byte, []byte, error)
- func WriteTLV(w io.Writer, typ byte, buf []byte) error
- type Config
- type ConsistencyLevel
- type MapShardRequest
- func (m *MapShardRequest) ChunkSize() int32
- func (m *MapShardRequest) MarshalBinary() ([]byte, error)
- func (m *MapShardRequest) Query() string
- func (m *MapShardRequest) SetChunkSize(chunkSize int32)
- func (m *MapShardRequest) SetQuery(query string)
- func (m *MapShardRequest) SetShardID(id uint64)
- func (m *MapShardRequest) ShardID() uint64
- func (m *MapShardRequest) UnmarshalBinary(buf []byte) error
- type MapShardResponse
- func (r *MapShardResponse) Code() int
- func (r *MapShardResponse) Data() []byte
- func (r *MapShardResponse) Fields() []string
- func (r *MapShardResponse) MarshalBinary() ([]byte, error)
- func (r *MapShardResponse) Message() string
- func (r *MapShardResponse) SetCode(code int)
- func (r *MapShardResponse) SetData(data []byte)
- func (r *MapShardResponse) SetFields(fields []string)
- func (r *MapShardResponse) SetMessage(message string)
- func (r *MapShardResponse) SetTagSets(tagsets []string)
- func (r *MapShardResponse) TagSets() []string
- func (r *MapShardResponse) UnmarshalBinary(buf []byte) error
- type PointsWriter
- type RemoteMapper
- type Service
- type ShardMapper
- type ShardMapping
- type ShardWriter
- type WritePointsRequest
- type WriteShardRequest
- func (w *WriteShardRequest) AddPoint(name string, value interface{}, timestamp time.Time, tags map[string]string)
- func (w *WriteShardRequest) AddPoints(points []tsdb.Point)
- func (w *WriteShardRequest) MarshalBinary() ([]byte, error)
- func (w *WriteShardRequest) Points() []tsdb.Point
- func (w *WriteShardRequest) SetShardID(id uint64)
- func (w *WriteShardRequest) ShardID() uint64
- func (w *WriteShardRequest) UnmarshalBinary(buf []byte) error
- type WriteShardResponse
- func (w *WriteShardResponse) Code() int
- func (w *WriteShardResponse) MarshalBinary() ([]byte, error)
- func (w *WriteShardResponse) Message() string
- func (w *WriteShardResponse) SetCode(code int)
- func (w *WriteShardResponse) SetMessage(message string)
- func (w *WriteShardResponse) UnmarshalBinary(buf []byte) error
Constants ¶
const ( // DefaultWriteTimeout is the default timeout for a complete write to succeed. DefaultWriteTimeout = 5 * time.Second // DefaultShardWriterTimeout is the default timeout set on shard writers. DefaultShardWriterTimeout = 5 * time.Second // DefaultShardMapperTimeout is the default timeout set on shard mappers. DefaultShardMapperTimeout = 5 * time.Second )
const MaxMessageSize = 1024 * 1024 * 1024 // 1GB
MaxMessageSize defines how large a message can be before we reject it
const MuxHeader = 2
MuxHeader is the header byte used in the TCP mux.
Variables ¶
var ( // ErrTimeout is returned when a write times out. ErrTimeout = errors.New("timeout") // ErrPartialWrite is returned when a write partially succeeds but does // not meet the requested consistency level. ErrPartialWrite = errors.New("partial write") // ErrWriteFailed is returned when no writes succeeded. ErrWriteFailed = errors.New("write failed") // ErrInvalidConsistencyLevel is returned when parsing the string version // of a consistency level. ErrInvalidConsistencyLevel = errors.New("invalid consistency level") )
Functions ¶
Types ¶
type Config ¶ added in v0.9.2
type Config struct { ForceRemoteShardMapping bool `toml:"force-remote-mapping"` WriteTimeout toml.Duration `toml:"write-timeout"` ShardWriterTimeout toml.Duration `toml:"shard-writer-timeout"` ShardMapperTimeout toml.Duration `toml:"shard-mapper-timeout"` }
Config represents the configuration for the clustering service.
type ConsistencyLevel ¶ added in v0.9.2
type ConsistencyLevel int
ConsistencyLevel represent a required replication criteria before a write can be returned as successful
const ( // ConsistencyLevelAny allows for hinted hand off, potentially no write happened yet ConsistencyLevelAny ConsistencyLevel = iota // ConsistencyLevelOne requires at least one data node acknowledged a write ConsistencyLevelOne // ConsistencyLevelOne requires a quorum of data nodes to acknowledge a write ConsistencyLevelQuorum // ConsistencyLevelAll requires all data nodes to acknowledge a write ConsistencyLevelAll )
func ParseConsistencyLevel ¶ added in v0.9.2
func ParseConsistencyLevel(level string) (ConsistencyLevel, error)
type MapShardRequest ¶ added in v0.9.3
type MapShardRequest struct {
// contains filtered or unexported fields
}
MapShardRequest represents the request to map a remote shard for a query.
func (*MapShardRequest) ChunkSize ¶ added in v0.9.3
func (m *MapShardRequest) ChunkSize() int32
func (*MapShardRequest) MarshalBinary ¶ added in v0.9.3
func (m *MapShardRequest) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object to a binary format.
func (*MapShardRequest) Query ¶ added in v0.9.3
func (m *MapShardRequest) Query() string
func (*MapShardRequest) SetChunkSize ¶ added in v0.9.3
func (m *MapShardRequest) SetChunkSize(chunkSize int32)
func (*MapShardRequest) SetQuery ¶ added in v0.9.3
func (m *MapShardRequest) SetQuery(query string)
func (*MapShardRequest) SetShardID ¶ added in v0.9.3
func (m *MapShardRequest) SetShardID(id uint64)
func (*MapShardRequest) ShardID ¶ added in v0.9.3
func (m *MapShardRequest) ShardID() uint64
func (*MapShardRequest) UnmarshalBinary ¶ added in v0.9.3
func (m *MapShardRequest) UnmarshalBinary(buf []byte) error
UnmarshalBinary populates MapShardRequest from a binary format.
type MapShardResponse ¶ added in v0.9.3
type MapShardResponse struct {
// contains filtered or unexported fields
}
MapShardResponse represents the response returned from a remote MapShardRequest call
func NewMapShardResponse ¶ added in v0.9.3
func NewMapShardResponse(code int, message string) *MapShardResponse
func (*MapShardResponse) Code ¶ added in v0.9.3
func (r *MapShardResponse) Code() int
func (*MapShardResponse) Data ¶ added in v0.9.3
func (r *MapShardResponse) Data() []byte
func (*MapShardResponse) Fields ¶ added in v0.9.3
func (r *MapShardResponse) Fields() []string
func (*MapShardResponse) MarshalBinary ¶ added in v0.9.3
func (r *MapShardResponse) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object to a binary format.
func (*MapShardResponse) Message ¶ added in v0.9.3
func (r *MapShardResponse) Message() string
func (*MapShardResponse) SetCode ¶ added in v0.9.3
func (r *MapShardResponse) SetCode(code int)
func (*MapShardResponse) SetData ¶ added in v0.9.3
func (r *MapShardResponse) SetData(data []byte)
func (*MapShardResponse) SetFields ¶ added in v0.9.3
func (r *MapShardResponse) SetFields(fields []string)
func (*MapShardResponse) SetMessage ¶ added in v0.9.3
func (r *MapShardResponse) SetMessage(message string)
func (*MapShardResponse) SetTagSets ¶ added in v0.9.3
func (r *MapShardResponse) SetTagSets(tagsets []string)
func (*MapShardResponse) TagSets ¶ added in v0.9.3
func (r *MapShardResponse) TagSets() []string
func (*MapShardResponse) UnmarshalBinary ¶ added in v0.9.3
func (r *MapShardResponse) UnmarshalBinary(buf []byte) error
UnmarshalBinary populates WritePointRequest from a binary format.
type PointsWriter ¶ added in v0.9.2
type PointsWriter struct { WriteTimeout time.Duration Logger *log.Logger MetaStore interface { NodeID() uint64 Database(name string) (di *meta.DatabaseInfo, err error) RetentionPolicy(database, policy string) (*meta.RetentionPolicyInfo, error) CreateShardGroupIfNotExists(database, policy string, timestamp time.Time) (*meta.ShardGroupInfo, error) ShardOwner(shardID uint64) (string, string, *meta.ShardGroupInfo) } TSDBStore interface { CreateShard(database, retentionPolicy string, shardID uint64) error WriteToShard(shardID uint64, points []tsdb.Point) error } ShardWriter interface { WriteShard(shardID, ownerID uint64, points []tsdb.Point) error } HintedHandoff interface { WriteShard(shardID, ownerID uint64, points []tsdb.Point) error } // contains filtered or unexported fields }
PointsWriter handles writes across multiple local and remote data nodes.
func NewPointsWriter ¶ added in v0.9.2
func NewPointsWriter() *PointsWriter
NewPointsWriter returns a new instance of PointsWriter for a node.
func (*PointsWriter) Close ¶ added in v0.9.2
func (w *PointsWriter) Close() error
func (*PointsWriter) MapShards ¶ added in v0.9.2
func (w *PointsWriter) MapShards(wp *WritePointsRequest) (*ShardMapping, error)
MapShards maps the points contained in wp to a ShardMapping. If a point maps to a shard group or shard that does not currently exist, it will be created before returning the mapping.
func (*PointsWriter) Open ¶ added in v0.9.2
func (w *PointsWriter) Open() error
func (*PointsWriter) WritePoints ¶ added in v0.9.2
func (w *PointsWriter) WritePoints(p *WritePointsRequest) error
WritePoints writes across multiple local and remote data nodes according the consistency level.
type RemoteMapper ¶ added in v0.9.2
type RemoteMapper struct {
// contains filtered or unexported fields
}
RemoteMapper implements the tsdb.Mapper interface. It connects to a remote node, sends a query, and interprets the stream of data that comes back.
func NewRemoteMapper ¶ added in v0.9.3
func NewRemoteMapper(c remoteShardConn, shardID uint64, stmt string, chunkSize int) *RemoteMapper
NewRemoteMapper returns a new remote mapper using the given connection.
func (*RemoteMapper) Fields ¶ added in v0.9.3
func (r *RemoteMapper) Fields() []string
func (*RemoteMapper) NextChunk ¶ added in v0.9.2
func (r *RemoteMapper) NextChunk() (chunk interface{}, err error)
NextChunk returns the next chunk read from the remote node to the client.
func (*RemoteMapper) Open ¶ added in v0.9.2
func (r *RemoteMapper) Open() (err error)
Open connects to the remote node and starts receiving data.
func (*RemoteMapper) TagSets ¶ added in v0.9.2
func (r *RemoteMapper) TagSets() []string
type Service ¶ added in v0.9.2
type Service struct { Listener net.Listener MetaStore interface { ShardOwner(shardID uint64) (string, string, *meta.ShardGroupInfo) } TSDBStore interface { CreateShard(database, policy string, shardID uint64) error WriteToShard(shardID uint64, points []tsdb.Point) error CreateMapper(shardID uint64, query string, chunkSize int) (tsdb.Mapper, error) } Logger *log.Logger // contains filtered or unexported fields }
Service processes data received over raw TCP connections.
func NewService ¶ added in v0.9.2
NewService returns a new instance of Service.
func (*Service) Close ¶ added in v0.9.2
Close shuts down the listener and waits for all connections to finish.
type ShardMapper ¶ added in v0.9.2
type ShardMapper struct { ForceRemoteMapping bool // All shards treated as remote. Useful for testing. MetaStore interface { NodeID() uint64 Node(id uint64) (ni *meta.NodeInfo, err error) } TSDBStore interface { CreateMapper(shardID uint64, query string, chunkSize int) (tsdb.Mapper, error) } // contains filtered or unexported fields }
ShardMapper is responsible for providing mappers for requested shards. It is responsible for creating those mappers from the local store, or reaching out to another node on the cluster.
func NewShardMapper ¶ added in v0.9.2
func NewShardMapper(timeout time.Duration) *ShardMapper
NewShardMapper returns a mapper of local and remote shards.
func (*ShardMapper) CreateMapper ¶ added in v0.9.2
func (s *ShardMapper) CreateMapper(sh meta.ShardInfo, stmt string, chunkSize int) (tsdb.Mapper, error)
CreateMapper returns a Mapper for the given shard ID.
type ShardMapping ¶ added in v0.9.2
type ShardMapping struct { Points map[uint64][]tsdb.Point // The points associated with a shard ID Shards map[uint64]*meta.ShardInfo // The shards that have been mapped, keyed by shard ID }
ShardMapping contains a mapping of a shards to a points.
func NewShardMapping ¶ added in v0.9.2
func NewShardMapping() *ShardMapping
NewShardMapping creates an empty ShardMapping
type ShardWriter ¶ added in v0.9.2
type ShardWriter struct { MetaStore interface { Node(id uint64) (ni *meta.NodeInfo, err error) } // contains filtered or unexported fields }
ShardWriter writes a set of points to a shard.
func NewShardWriter ¶ added in v0.9.2
func NewShardWriter(timeout time.Duration) *ShardWriter
NewShardWriter returns a new instance of ShardWriter.
func (*ShardWriter) Close ¶ added in v0.9.2
func (w *ShardWriter) Close() error
func (*ShardWriter) WriteShard ¶ added in v0.9.2
func (w *ShardWriter) WriteShard(shardID, ownerID uint64, points []tsdb.Point) error
type WritePointsRequest ¶ added in v0.9.2
type WritePointsRequest struct { Database string RetentionPolicy string ConsistencyLevel ConsistencyLevel Points []tsdb.Point }
WritePointsRequest represents a request to write point data to the cluster
type WriteShardRequest ¶ added in v0.9.2
type WriteShardRequest struct {
// contains filtered or unexported fields
}
WriteShardRequest represents the a request to write a slice of points to a shard
func (*WriteShardRequest) AddPoints ¶ added in v0.9.2
func (w *WriteShardRequest) AddPoints(points []tsdb.Point)
func (*WriteShardRequest) MarshalBinary ¶ added in v0.9.2
func (w *WriteShardRequest) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object to a binary format.
func (*WriteShardRequest) Points ¶ added in v0.9.2
func (w *WriteShardRequest) Points() []tsdb.Point
func (*WriteShardRequest) SetShardID ¶ added in v0.9.2
func (w *WriteShardRequest) SetShardID(id uint64)
func (*WriteShardRequest) ShardID ¶ added in v0.9.2
func (w *WriteShardRequest) ShardID() uint64
func (*WriteShardRequest) UnmarshalBinary ¶ added in v0.9.2
func (w *WriteShardRequest) UnmarshalBinary(buf []byte) error
UnmarshalBinary populates WritePointRequest from a binary format.
type WriteShardResponse ¶ added in v0.9.2
type WriteShardResponse struct {
// contains filtered or unexported fields
}
WriteShardResponse represents the response returned from a remote WriteShardRequest call
func (*WriteShardResponse) Code ¶ added in v0.9.2
func (w *WriteShardResponse) Code() int
func (*WriteShardResponse) MarshalBinary ¶ added in v0.9.2
func (w *WriteShardResponse) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object to a binary format.
func (*WriteShardResponse) Message ¶ added in v0.9.2
func (w *WriteShardResponse) Message() string
func (*WriteShardResponse) SetCode ¶ added in v0.9.2
func (w *WriteShardResponse) SetCode(code int)
func (*WriteShardResponse) SetMessage ¶ added in v0.9.2
func (w *WriteShardResponse) SetMessage(message string)
func (*WriteShardResponse) UnmarshalBinary ¶ added in v0.9.2
func (w *WriteShardResponse) UnmarshalBinary(buf []byte) error
UnmarshalBinary populates WritePointRequest from a binary format.