本文整理匯總了Golang中github.com/Terry-Mao/bfs/libs/meta.Store.CanWrite方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.CanWrite方法的具體用法?Golang Store.CanWrite怎麽用?Golang Store.CanWrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Terry-Mao/bfs/libs/meta.Store
的用法示例。
在下文中一共展示了Store.CanWrite方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Update
// Update when zk updates
func (d *Dispatcher) Update(group map[int][]string,
store map[string]*meta.Store, volume map[int32]*meta.VolumeState,
storeVolume map[string][]int32) (err error) {
var (
gid int
i int
vid int32
gids []int
sid string
stores []string
restSpace, minScore, score int
totalAdd, totalAddDelay uint64
write, ok bool
storeMeta *meta.Store
volumeState *meta.VolumeState
)
gids = []int{}
for gid, stores = range group {
write = true
// check all stores can writeable by the group.
for _, sid = range stores {
if storeMeta, ok = store[sid]; !ok {
log.Errorf("idStore cannot match store: %s", sid)
break
}
if !storeMeta.CanWrite() {
write = false
break
}
}
if !write {
continue
}
// calc score
for _, sid = range stores {
totalAdd, totalAddDelay, restSpace, minScore = 0, 0, 0, 0
// get all volumes by the store.
for _, vid = range storeVolume[sid] {
volumeState = volume[vid]
totalAdd = totalAdd + volumeState.TotalWriteProcessed
restSpace = restSpace + int(volumeState.FreeSpace)
totalAddDelay = totalAddDelay + volumeState.TotalWriteDelay
}
score = d.calScore(int(totalAdd), int(totalAddDelay), restSpace)
if score < minScore || minScore == 0 {
minScore = score
}
}
for i = 0; i < minScore; i++ {
gids = append(gids, gid)
}
}
d.gids = gids
return
}
示例2: DelStores
// DelStores get delable stores for http del
func (d *Directory) DelStores(key int64, cookie int32) (vid int32, stores []string, err error) {
var (
n *meta.Needle
ok bool
store string
svrs []string
storeMeta *meta.Store
)
if n, err = d.hbase.Get(key); err != nil {
log.Errorf("hbase.Get error(%v)", err)
err = errors.ErrHbase
return
}
if n == nil {
err = errors.ErrNeedleNotExist
return
}
if n.Cookie != cookie {
err = errors.ErrNeedleCookie
return
}
vid = n.Vid
if svrs, ok = d.volumeStore[n.Vid]; !ok {
err = errors.ErrZookeeperDataError
return
}
stores = make([]string, 0, len(svrs))
for _, store = range svrs {
if storeMeta, ok = d.store[store]; !ok {
err = errors.ErrZookeeperDataError
return
}
if !storeMeta.CanWrite() {
err = errors.ErrStoreNotAvailable
return
}
stores = append(stores, storeMeta.Api)
}
if err = d.hbase.Del(key); err != nil {
log.Errorf("hbase.Del error(%v)", err)
err = errors.ErrHbase
}
return
}