Documentation
¶
Index ¶
- Constants
- Variables
- func InitGlobalManualScheduler(route *dbcfg.RouteTable, n int)
- type Bucket
- type ByName
- type Feedback
- type Host
- func (host *Host) Append(key string, value []byte) (bool, error)
- func (host *Host) Close()
- func (host *Host) Delete(key string) (bool, error)
- func (host *Host) Get(key string) (*mc.Item, error)
- func (host *Host) GetMulti(keys []string) (map[string]*mc.Item, error)
- func (host *Host) Incr(key string, value int) (int, error)
- func (host *Host) Len() int
- func (host *Host) Process(key string, args []string) (string, string)
- func (host *Host) Set(key string, item *mc.Item, noreply bool) (bool, error)
- type HostInBucket
- type ManualScheduler
- func (sch *ManualScheduler) Close()
- func (sch *ManualScheduler) DivideKeysByBucket(keys []string) [][]string
- func (sch *ManualScheduler) Feedback(host *Host, key string, startTime time.Time, data float64)
- func (sch *ManualScheduler) FeedbackError(host *Host, key string, startTime time.Time, errorCode float64)
- func (sch *ManualScheduler) FeedbackLatency(host *Host, key string, startTime time.Time, timeUsed time.Duration)
- func (sch *ManualScheduler) GetBucketInfo(bucketID int64) map[string]map[string]map[string][]Response
- func (sch *ManualScheduler) GetHostsByKey(key string) (hosts []*Host)
- func (sch *ManualScheduler) LatenciesStats() map[string]map[string][QUEUECAP]Response
- func (sch *ManualScheduler) Partition() map[string]map[string]int
- func (sch *ManualScheduler) Stats() map[string]map[string]float64
- type Partition
- type Response
- type RingQueue
- type Scheduler
- type Storage
- type StorageClient
- func (c *StorageClient) Append(key string, value []byte) (ok bool, err error)
- func (c *StorageClient) Clean()
- func (c *StorageClient) Close()
- func (c *StorageClient) Delete(key string) (flag bool, err error)
- func (c *StorageClient) Get(key string) (item *mc.Item, err error)
- func (c *StorageClient) GetMulti(keys []string) (rs map[string]*mc.Item, err error)
- func (c *StorageClient) GetSuccessedTargets() []string
- func (c *StorageClient) Incr(key string, value int) (result int, err error)
- func (c *StorageClient) Len() int
- func (c *StorageClient) Process(key string, args []string) (string, string)
- func (c *StorageClient) Set(key string, item *mc.Item, noreply bool) (ok bool, err error)
Constants ¶
View Source
const ( TIMEINTERVAL = 30 * 1000 * 1000 * 1000 // proxy 链接 后端 超时时间 为 3 秒,清空 30s 之前的数据,30 * 1000 * 1000 * 1000 QUEUECAP = 60 )
View Source
const ( FeedbackNonConnectErrSet = -10 FeedbackNonConnectErrDelete = -10 FeedbackConnectErrDefault = -2 FeedbackNonConnectErrDefault = -5 )
View Source
const CONSISTENTLEN = 100
View Source
const (
// 最少保留 MINKEYS/count 的 key 在某一个节点上
MINKEYS = 1
)
View Source
const RINGLEN = 60
View Source
const (
WAIT_FOR_RETRY = "wait for retry"
)
Variables ¶
View Source
var ( ErrQueueFull = errors.New("queue full") ErrQueueEmpty = errors.New("queue empty") )
View Source
var ( // ErrWriteFailed 表示成功写入的节点数小于 StorageClient.W ErrWriteFailed = errors.New("write failed") )
Functions ¶
func InitGlobalManualScheduler ¶
func InitGlobalManualScheduler(route *dbcfg.RouteTable, n int)
Types ¶
type Bucket ¶
type Bucket struct { ID int // contains filtered or unexported fields }
type ByName ¶
type ByName []*HostInBucket
type Host ¶
type HostInBucket ¶
type HostInBucket struct {
// contains filtered or unexported fields
}
type ManualScheduler ¶
type ManualScheduler struct { N int // contains filtered or unexported fields }
route request by configure
func NewManualScheduler ¶
func NewManualScheduler(route *dbcfg.RouteTable, n int) *ManualScheduler
func (*ManualScheduler) Close ¶
func (sch *ManualScheduler) Close()
func (*ManualScheduler) DivideKeysByBucket ¶
func (sch *ManualScheduler) DivideKeysByBucket(keys []string) [][]string
func (*ManualScheduler) FeedbackError ¶
func (*ManualScheduler) FeedbackLatency ¶
func (*ManualScheduler) GetBucketInfo ¶
func (sch *ManualScheduler) GetBucketInfo(bucketID int64) map[string]map[string]map[string][]Response
return addr:score:offset:response
func (*ManualScheduler) GetHostsByKey ¶
func (sch *ManualScheduler) GetHostsByKey(key string) (hosts []*Host)
func (*ManualScheduler) LatenciesStats ¶
func (sch *ManualScheduler) LatenciesStats() map[string]map[string][QUEUECAP]Response
type Partition ¶
一致性哈希变种
func NewPartition ¶
--- Partition --------------------------------------------------------------
type RingQueue ¶
func NewRingQueue ¶
func NewRingQueue() *RingQueue
type Scheduler ¶
type Scheduler interface { // feedback for auto routing FeedbackError(host *Host, key string, startTime time.Time, errorCode float64) FeedbackLatency(host *Host, key string, startTime time.Time, timeUsed time.Duration) // route a key to hosts GetHostsByKey(key string) (hosts []*Host) // route some keys to group of hosts DivideKeysByBucket(keys []string) [][]string // internal status Stats() map[string]map[string]float64 // get latencies of hosts in the bucket LatenciesStats() map[string]map[string][QUEUECAP]Response // get percentage of hosts in the bucket Partition() map[string]map[string]int // return average latency and arc(percentage) GetBucketInfo(bucketID int64) map[string]map[string]map[string][]Response Close() }
Scheduler: route request to nodes
func GetScheduler ¶
func GetScheduler() Scheduler
type Storage ¶
type Storage struct { }
func (*Storage) Client ¶
func (s *Storage) Client() mc.StorageClient
type StorageClient ¶
type StorageClient struct { // SuccessedTargets is a list of addrs on which the client request was ran // successfully. SuccessedTargets []string // Dynamo NWR model, please refer to Dynamo paper for details. N, W, R int // contains filtered or unexported fields }
client for gobeansdb
func NewStorageClient ¶
func NewStorageClient(n int, w int, r int) (c *StorageClient)
func (*StorageClient) Append ¶
func (c *StorageClient) Append(key string, value []byte) (ok bool, err error)
func (*StorageClient) Clean ¶
func (c *StorageClient) Clean()
func (*StorageClient) Close ¶
func (c *StorageClient) Close()
func (*StorageClient) Delete ¶
func (c *StorageClient) Delete(key string) (flag bool, err error)
TODO: 弄清楚为什么 delete 不遵循 NWR 规则
func (*StorageClient) GetSuccessedTargets ¶
func (c *StorageClient) GetSuccessedTargets() []string
func (*StorageClient) Incr ¶
func (c *StorageClient) Incr(key string, value int) (result int, err error)
NOTE: Incr command may has consistency problem link: http://github.com/douban/gobeansproxy/issues/7
func (*StorageClient) Len ¶
func (c *StorageClient) Len() int
Click to show internal directories.
Click to hide internal directories.