本文整理匯總了Golang中github.com/Terry-Mao/bfs/libs/meta.Store.Info方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.Info方法的具體用法?Golang Store.Info怎麽用?Golang Store.Info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Terry-Mao/bfs/libs/meta.Store
的用法示例。
在下文中一共展示了Store.Info方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: checkNeedles
// checkNeedles check the store health.
func (p *Pitchfork) checkNeedles(store *meta.Store, stop chan struct{}) (err error) {
var (
status, i int
needle *meta.Needle
volume *meta.Volume
volumes []*meta.Volume
)
log.Infof("checkNeedles job start")
for {
select {
case <-stop:
log.Infof("checkNeedles job stop")
return
case <-time.After(p.config.HeadInterval):
break
}
if volumes, err = store.Info(); err != nil {
log.Errorf("get store info failed, retry host:%s", store.Stat)
continue
}
status = store.Status
for _, volume = range volumes {
if volume.Block.LastErr != nil {
break
} else {
for _, needle = range volume.CheckNeedles {
for i = 0; i < retryCount; i++ {
if err = store.Head(needle, volume.Id); err == nil {
break
}
}
if err != nil {
log.Errorf("head store failed, needle:%d host:%s", needle.Key, store.Stat)
store.Status = meta.StoreStatusFail
goto feedback
}
}
}
}
feedback:
if status != store.Status {
if err = p.zk.SetStore(store); err != nil {
log.Errorf("update store zk status failed, retry")
continue
}
if err = p.zk.setRoot(); err != nil {
log.Errorf("setRoot zk failed")
}
}
}
return
}
示例2: checkHealth
// checkHealth check the store health.
func (p *Pitchfork) checkHealth(store *meta.Store, stop chan struct{}) (err error) {
var (
status, i int
volume *meta.Volume
volumes []*meta.Volume
)
log.Infof("check_health job start")
for {
select {
case <-stop:
log.Infof("check_health job stop")
return
case <-time.After(p.config.GetInterval):
break
}
status = store.Status
store.Status = meta.StoreStatusHealth
for i = 0; i < retryCount; i++ {
if volumes, err = store.Info(); err == nil {
break
}
time.Sleep(retrySleep)
}
if err == nil {
for _, volume = range volumes {
if volume.Block.LastErr != nil {
log.Infof("get store block.lastErr:%s host:%s", volume.Block.LastErr, store.Stat)
store.Status = meta.StoreStatusFail
break
} else if volume.Block.Full() {
log.Infof("block: %s, offset: %d", volume.Block.File, volume.Block.Offset)
store.Status = meta.StoreStatusRead
}
if err = p.zk.SetVolumeState(volume); err != nil {
log.Errorf("zk.SetVolumeState() error(%v)", err)
}
}
} else {
log.Errorf("get store info failed, retry host:%s", store.Stat)
store.Status = meta.StoreStatusFail
}
if status != store.Status {
if err = p.zk.SetStore(store); err != nil {
log.Errorf("update store zk status failed, retry")
continue
}
}
}
return
}