本文整理匯總了Golang中github.com/cockroachdb/cockroach/storage.Store.StoreID方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.StoreID方法的具體用法?Golang Store.StoreID怎麽用?Golang Store.StoreID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/storage.Store
的用法示例。
在下文中一共展示了Store.StoreID方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createSplitRanges
func createSplitRanges(store *storage.Store) (*proto.RangeDescriptor, *proto.RangeDescriptor, error) {
args := adminSplitArgs(proto.KeyMin, []byte("b"), 1, store.StoreID())
if _, err := store.ExecuteCmd(context.Background(), &args); err != nil {
return nil, nil, err
}
rangeA := store.LookupReplica([]byte("a"), nil)
rangeB := store.LookupReplica([]byte("c"), nil)
if bytes.Equal(rangeA.Desc().StartKey, rangeB.Desc().StartKey) {
log.Errorf("split ranges keys are equal %q!=%q", rangeA.Desc().StartKey, rangeB.Desc().StartKey)
}
return rangeA.Desc(), rangeB.Desc(), nil
}
示例2: createSplitRanges
func createSplitRanges(store *storage.Store) (*roachpb.RangeDescriptor, *roachpb.RangeDescriptor, error) {
args := adminSplitArgs(roachpb.KeyMin, []byte("b"), 1, store.StoreID())
if _, err := client.SendWrapped(store, nil, &args); err != nil {
return nil, nil, err
}
rangeA := store.LookupReplica([]byte("a"), nil)
rangeB := store.LookupReplica([]byte("c"), nil)
if bytes.Equal(rangeA.Desc().StartKey, rangeB.Desc().StartKey) {
log.Errorf("split ranges keys are equal %q!=%q", rangeA.Desc().StartKey, rangeB.Desc().StartKey)
}
return rangeA.Desc(), rangeB.Desc(), nil
}
示例3: createSplitRanges
func createSplitRanges(store *storage.Store) (*proto.RangeDescriptor, *proto.RangeDescriptor, error) {
args, reply := adminSplitArgs(engine.KeyMin, []byte("b"), 1, store.StoreID())
if err := store.ExecuteCmd(proto.AdminSplit, args, reply); err != nil {
return nil, nil, err
}
rangeA := store.LookupRange([]byte("a"), nil)
rangeB := store.LookupRange([]byte("c"), nil)
if bytes.Equal(rangeA.Desc().StartKey, rangeB.Desc().StartKey) {
log.Errorf("split ranges keys are equal %q!=%q", rangeA.Desc().StartKey, rangeB.Desc().StartKey)
}
return rangeA.Desc(), rangeB.Desc(), nil
}
示例4: fillRange
// fillRange writes keys with the given prefix and associated values
// until bytes bytes have been written.
func fillRange(store *storage.Store, rangeID roachpb.RangeID, prefix roachpb.Key, bytes int64, t *testing.T) {
src := rand.New(rand.NewSource(0))
for {
var ms engine.MVCCStats
if err := engine.MVCCGetRangeStats(store.Engine(), rangeID, &ms); err != nil {
t.Fatal(err)
}
keyBytes, valBytes := ms.KeyBytes, ms.ValBytes
if keyBytes+valBytes >= bytes {
return
}
key := append(append([]byte(nil), prefix...), randutil.RandBytes(src, 100)...)
val := randutil.RandBytes(src, int(src.Int31n(1<<8)))
pArgs := putArgs(key, val, rangeID, store.StoreID())
if _, err := client.SendWrapped(store, nil, &pArgs); err != nil {
t.Fatal(err)
}
}
}
示例5: fillRange
// fillRange writes keys with the given prefix and associated values
// until bytes bytes have been written.
func fillRange(store *storage.Store, rangeID proto.RangeID, prefix proto.Key, bytes int64, t *testing.T) {
src := rand.New(rand.NewSource(0))
for {
var ms engine.MVCCStats
if err := engine.MVCCGetRangeStats(store.Engine(), rangeID, &ms); err != nil {
t.Fatal(err)
}
keyBytes, valBytes := ms.KeyBytes, ms.ValBytes
if keyBytes+valBytes >= bytes {
return
}
key := append(append([]byte(nil), prefix...), randutil.RandBytes(src, 100)...)
val := randutil.RandBytes(src, int(src.Int31n(1<<8)))
pArgs := putArgs(key, val, rangeID, store.StoreID())
pArgs.Timestamp = store.Clock().Now()
if _, err := store.ExecuteCmd(context.Background(), &pArgs); err != nil {
t.Fatal(err)
}
}
}