本文整理匯總了Golang中github.com/encryptio/slime/internal/store.Store.UUID方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.UUID方法的具體用法?Golang Store.UUID怎麽用?Golang Store.UUID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/encryptio/slime/internal/store.Store
的用法示例。
在下文中一共展示了Store.UUID方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: rebalanceFile
//.........這裏部分代碼省略.........
// we should move chunk minI on minS to maxS
err := m.db.RunTx(func(ctx kvl.Ctx) error {
l, err := meta.Open(ctx)
if err != nil {
return err
}
return l.WALMark(f.PrefixID)
})
if err != nil {
return false, err
}
defer func() {
// TODO: how to handle errors here?
m.db.RunTx(func(ctx kvl.Ctx) error {
l, err := meta.Open(ctx)
if err != nil {
return err
}
return l.WALClear(f.PrefixID)
})
}()
localKey := localKeyFor(&f, minI)
data, st, err := minS.Get(localKey, store.GetOptions{})
if err != nil {
return false, err
}
setCASV := store.CASV{
Present: true,
SHA256: st.SHA256,
Data: data,
}
err = maxS.CAS(localKey, store.MissingV, setCASV, nil)
if err != nil {
return false, err
}
newF := f
newF.Locations = make([][16]byte, len(f.Locations))
copy(newF.Locations, f.Locations)
newF.Locations[minI] = maxS.UUID()
err = m.db.RunTx(func(ctx kvl.Ctx) error {
l, err := meta.Open(ctx)
if err != nil {
return err
}
f2, err := l.GetFile(f.Path)
if err != nil {
return err
}
if f2.PrefixID != f.PrefixID {
return errModifiedDuringBalance
}
if len(f2.Locations) != len(f.Locations) {
return errModifiedDuringBalance
}
for i, floc := range f.Locations {
if floc != f2.Locations[i] {
return errModifiedDuringBalance
}
}
err = l.SetFile(&newF)
if err != nil {
return err
}
return nil
})
if err != nil {
maxS.CAS(localKey, setCASV, store.MissingV, nil) // ignore error
return false, err
}
err = minS.CAS(localKey, setCASV, store.MissingV, nil)
if err != nil {
log.Printf("Couldn't remove rebalanced chunk from old location %v: %v",
uuid.Fmt(maxS.UUID()), err)
}
fe := finderEntries[minS.UUID()]
fe.Free += int64(len(data))
finderEntries[minS.UUID()] = fe
fe = finderEntries[maxS.UUID()]
fe.Free -= int64(len(data))
finderEntries[maxS.UUID()] = fe
return true, nil
}