作者:camlistor
项目:camlistor
func (s *storage) StorageGeneration() (initTime time.Time, random string, err error) {
sgen, sok := s.small.(blobserver.Generationer)
lgen, lok := s.large.(blobserver.Generationer)
if !sok || !lok {
return time.Time{}, "", blobserver.GenerationNotSupportedError("underlying storage engines don't support Generationer")
}
st, srand, err := sgen.StorageGeneration()
if err != nil {
return
}
lt, lrand, err := lgen.StorageGeneration()
if err != nil {
return
}
hash := sha1.New()
io.WriteString(hash, srand)
io.WriteString(hash, lrand)
maxTime := func(a, b time.Time) time.Time {
if a.After(b) {
return a
}
return b
}
return maxTime(lt, st), fmt.Sprintf("%x", hash.Sum(nil)), nil
}
作者:camarox5
项目:coreos-baremeta
func (sto *condStorage) StorageGeneration() (initTime time.Time, random string, err error) {
if gener, ok := sto.read.(blobserver.Generationer); ok {
return gener.StorageGeneration()
}
err = blobserver.GenerationNotSupportedError(fmt.Sprintf("blobserver.Generationer not implemented on %T", sto.read))
return
}
作者:camarox5
项目:coreos-baremeta
func (sto *condStorage) ResetStorageGeneration() error {
if gener, ok := sto.read.(blobserver.Generationer); ok {
return gener.ResetStorageGeneration()
}
return blobserver.GenerationNotSupportedError(fmt.Sprintf("blobserver.Generationer not implemented on %T", sto.read))
}