本文整理汇总了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
}