本文整理汇总了Golang中github.com/jcloudpub/speedy/chunkmaster/metadata.Chunkserver.UpdateTime方法的典型用法代码示例。如果您正苦于以下问题:Golang Chunkserver.UpdateTime方法的具体用法?Golang Chunkserver.UpdateTime怎么用?Golang Chunkserver.UpdateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jcloudpub/speedy/chunkmaster/metadata.Chunkserver
的用法示例。
在下文中一共展示了Chunkserver.UpdateTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: reportChunkserverInfo
func reportChunkserverInfo(key string, chunkserver *metadata.Chunkserver, oldChunkserver *metadata.Chunkserver) error {
if oldChunkserver.Status == INIT_STATUS {
err := mdDriver.UpdateChunkserverInfo(chunkserver, INIT_STATUS, RW_STATUS)
if err != nil {
return err
}
chunkserver.Status = RW_STATUS
}
if RW_STATUS == oldChunkserver.Status {
err := mdDriver.UpdateChunkserverInfo(chunkserver, RW_STATUS, RW_STATUS)
if err != nil {
return err
}
chunkserver.Status = RW_STATUS
}
if RO_STATUS == oldChunkserver.Status {
err := mdDriver.UpdateChunkserverInfo(chunkserver, RO_STATUS, RW_STATUS)
if err != nil {
return err
}
log.Infof("[reportChunkserverInfo] update RO_STATUS to RW_STATUS chunkserver: %v", key)
chunkserver.Status = RW_STATUS
}
chunkserver.UpdateTime = time.Now()
lock.Lock()
_, ok := serverInfo[key]
if !ok {
lock.Unlock()
return fmt.Errorf("do not exist: %v", chunkserver)
}
serverInfo[key] = chunkserver
lock.Unlock()
return nil
}
示例2: addChunkserver
func addChunkserver(chunkserver *metadata.Chunkserver) error {
chunkserver.Status = INIT_STATUS
chunkserver.TotalFreeSpace = 0
chunkserver.MaxFreeSpace = 0
chunkserver.PendingWrites = 0
chunkserver.WritingCount = 0
chunkserver.DataDir = ""
chunkserver.ReadingCount = 0
chunkserver.TotalChunks = 0
chunkserver.ConnectionsCount = 0
err := mdDriver.AddChunkserver(chunkserver)
if err != nil {
return err
}
lock.Lock()
defer lock.Unlock()
key := fmt.Sprintf("%d:%s:%d", chunkserver.GroupId, chunkserver.Ip, chunkserver.Port)
chunkserver.UpdateTime = time.Now()
serverInfo[key] = chunkserver
return nil
}