当前位置: 首页>>代码示例>>Golang>>正文


Golang Store.Status方法代码示例

本文整理汇总了Golang中github.com/Terry-Mao/bfs/libs/meta.Store.Status方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.Status方法的具体用法?Golang Store.Status怎么用?Golang Store.Status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/Terry-Mao/bfs/libs/meta.Store的用法示例。


在下文中一共展示了Store.Status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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
}
开发者ID:xiaoma20082008,项目名称:bfs,代码行数:51,代码来源:pitchfork.go

示例2: 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
}
开发者ID:wtmmac,项目名称:bfs,代码行数:53,代码来源:pitchfork.go


注:本文中的github.com/Terry-Mao/bfs/libs/meta.Store.Status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。