本文整理汇总了Golang中github.com/cockroachdb/cockroach/roachpb.StoreID函数的典型用法代码示例。如果您正苦于以下问题:Golang StoreID函数的具体用法?Golang StoreID怎么用?Golang StoreID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StoreID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestStorePoolGetStoreDetails
func TestStorePoolGetStoreDetails(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper, g, _, sp := createTestStorePool(TestTimeUntilStoreDeadOff)
defer stopper.Stop()
sg := gossiputil.NewStoreGossiper(g)
sg.GossipStores(uniqueStore, t)
if detail := sp.getStoreDetail(roachpb.StoreID(1)); detail.dead {
t.Errorf("Present storeDetail came back as dead, expected it to be alive. %+v", detail)
}
if detail := sp.getStoreDetail(roachpb.StoreID(2)); detail.dead {
t.Errorf("Absent storeDetail came back as dead, expected it to be alive. %+v", detail)
}
}
开发者ID:liugangnhm,项目名称:cockroach,代码行数:15,代码来源:store_pool_test.go
示例2: getStoreList
// GetStoreList returns a storeList that contains all active stores that
// contain the required attributes and their associated stats.
// TODO(embark, spencer): consider using a reverse index map from
// Attr->stores, for efficiency. Ensure that entries in this map still
// have an opportunity to be garbage collected.
func (sp *StorePool) getStoreList(required roachpb.Attributes, excludeNodes []roachpb.NodeID, deterministic bool) StoreList {
sp.mu.RLock()
defer sp.mu.RUnlock()
// Convert list of excluded nodes to a map for quick lookup.
excludeMap := map[roachpb.NodeID]struct{}{}
for _, nodeID := range excludeNodes {
excludeMap[nodeID] = struct{}{}
}
var storeIDs roachpb.StoreIDSlice
for storeID := range sp.stores {
storeIDs = append(storeIDs, storeID)
}
// Sort the stores by key if deterministic is requested. This is only for
// unit testing.
if deterministic {
sort.Sort(storeIDs)
}
sl := StoreList{}
for _, storeID := range storeIDs {
detail := sp.stores[roachpb.StoreID(storeID)]
if _, ok := excludeMap[detail.desc.Node.NodeID]; ok {
continue
}
if !detail.dead && required.IsSubset(*detail.desc.CombinedAttrs()) {
desc := detail.desc
sl.add(&desc)
}
}
return sl
}
开发者ID:nporsche,项目名称:cockroach,代码行数:37,代码来源:store_pool.go
示例3: updateCountString
// updateCountString describes the update counts that were recorded by
// storeEventReader. The formatting is appropriate to paste into this test if
// as a new expected value.
func (ser *storeEventReader) updateCountString() string {
var buffer bytes.Buffer
w := tabwriter.NewWriter(&buffer, 2, 1, 2, ' ', 0)
var storeIDs sort.IntSlice
for storeID := range ser.perStoreUpdateCount {
storeIDs = append(storeIDs, int(storeID))
}
sort.Sort(storeIDs)
for _, storeID := range storeIDs {
if countset, ok := ser.perStoreUpdateCount[roachpb.StoreID(storeID)]; ok {
fmt.Fprintf(w, "%T(%d): {\n", storeID, storeID)
var methodIDs sort.IntSlice
for methodID := range countset {
methodIDs = append(methodIDs, int(methodID))
}
sort.Sort(methodIDs)
for _, methodID := range methodIDs {
method := roachpb.Method(methodID)
if count, okCount := countset[method]; okCount {
fmt.Fprintf(w, "\tproto.%s:\t%d,\n", method, count)
} else {
panic("unreachable!")
}
}
} else {
panic("unreachable!")
}
fmt.Fprintf(w, "},\n")
}
return buffer.String()
}
开发者ID:nporsche,项目名称:cockroach,代码行数:38,代码来源:client_event_test.go
示例4: TestStoresVisitStores
func TestStoresVisitStores(t *testing.T) {
defer leaktest.AfterTest(t)
ls := NewStores()
numStores := 10
for i := 0; i < numStores; i++ {
ls.AddStore(&Store{Ident: roachpb.StoreIdent{StoreID: roachpb.StoreID(i)}})
}
visit := make([]bool, numStores)
err := ls.VisitStores(func(s *Store) error { visit[s.Ident.StoreID] = true; return nil })
if err != nil {
t.Errorf("unexpected error on visit: %s", err.Error())
}
for i, visited := range visit {
if !visited {
t.Errorf("store %d was not visited", i)
}
}
err = ls.VisitStores(func(s *Store) error { return errors.New("") })
if err == nil {
t.Errorf("expected visit error")
}
}
开发者ID:haint504,项目名称:cockroach,代码行数:25,代码来源:stores_test.go
示例5: getStoreList
// GetStoreList returns a storeList that contains all active stores that
// contain the required attributes and their associated stats. It also returns
// the number of total alive stores.
// TODO(embark, spencer): consider using a reverse index map from
// Attr->stores, for efficiency. Ensure that entries in this map still
// have an opportunity to be garbage collected.
func (sp *StorePool) getStoreList(required roachpb.Attributes, deterministic bool) (StoreList, int) {
sp.mu.RLock()
defer sp.mu.RUnlock()
var storeIDs roachpb.StoreIDSlice
for storeID := range sp.stores {
storeIDs = append(storeIDs, storeID)
}
// Sort the stores by key if deterministic is requested. This is only for
// unit testing.
if deterministic {
sort.Sort(storeIDs)
}
sl := StoreList{}
var aliveStoreCount int
for _, storeID := range storeIDs {
detail := sp.stores[roachpb.StoreID(storeID)]
if !detail.dead && detail.desc != nil {
aliveStoreCount++
if required.IsSubset(*detail.desc.CombinedAttrs()) {
sl.add(detail.desc)
}
}
}
return sl, aliveStoreCount
}
开发者ID:petermattis,项目名称:cockroach,代码行数:32,代码来源:store_pool.go
示例6: ReplicaDescriptor
// ReplicaDescriptor implements the Storage interface by returning a
// dummy descriptor.
func (m *MemoryStorage) ReplicaDescriptor(groupID roachpb.RangeID, replicaID roachpb.ReplicaID) (roachpb.ReplicaDescriptor, error) {
return roachpb.ReplicaDescriptor{
ReplicaID: replicaID,
NodeID: roachpb.NodeID(replicaID),
StoreID: roachpb.StoreID(replicaID),
}, nil
}
开发者ID:ruo91,项目名称:cockroach,代码行数:9,代码来源:storage.go
示例7: TestStoresVisitStores
func TestStoresVisitStores(t *testing.T) {
defer leaktest.AfterTest(t)()
ls := NewStores(hlc.NewClock(hlc.UnixNano))
numStores := 10
for i := 0; i < numStores; i++ {
ls.AddStore(&Store{Ident: roachpb.StoreIdent{StoreID: roachpb.StoreID(i)}})
}
visit := make([]bool, numStores)
err := ls.VisitStores(func(s *Store) error { visit[s.Ident.StoreID] = true; return nil })
if err != nil {
t.Errorf("unexpected error on visit: %s", err.Error())
}
for i, visited := range visit {
if !visited {
t.Errorf("store %d was not visited", i)
}
}
errBoom := errors.New("boom")
if err := ls.VisitStores(func(s *Store) error {
return errBoom
}); err != errBoom {
t.Errorf("got unexpected error %v", err)
}
}
开发者ID:yangxuanjia,项目名称:cockroach,代码行数:27,代码来源:stores_test.go
示例8: getStoreList
// GetStoreList returns a storeList that contains all active stores that
// contain the required attributes and their associated stats. It also returns
// the number of total alive stores.
// TODO(embark, spencer): consider using a reverse index map from
// Attr->stores, for efficiency. Ensure that entries in this map still
// have an opportunity to be garbage collected.
func (sp *StorePool) getStoreList(required roachpb.Attributes, deterministic bool) (StoreList, int) {
sp.mu.RLock()
defer sp.mu.RUnlock()
var storeIDs roachpb.StoreIDSlice
for storeID := range sp.mu.stores {
storeIDs = append(storeIDs, storeID)
}
// Sort the stores by key if deterministic is requested. This is only for
// unit testing.
if deterministic {
sort.Sort(storeIDs)
}
now := sp.clock.Now().GoTime()
sl := StoreList{}
var aliveStoreCount int
for _, storeID := range storeIDs {
detail := sp.mu.stores[roachpb.StoreID(storeID)]
matched := detail.match(now, required)
if matched >= storeMatchAlive {
aliveStoreCount++
}
if matched == storeMatchMatched {
sl.add(detail.desc)
}
}
return sl, aliveStoreCount
}
开发者ID:csdigi,项目名称:cockroach,代码行数:34,代码来源:store_pool.go
示例9: BootstrapCluster
// BootstrapCluster bootstraps a multiple stores using the provided engines and
// cluster ID. The first bootstrapped store contains a single range spanning
// all keys. Initial range lookup metadata is populated for the range.
//
// Returns a KV client for unittest purposes. Caller should close the returned
// client.
func BootstrapCluster(clusterID string, engines []engine.Engine, stopper *stop.Stopper) (*client.DB, error) {
ctx := storage.StoreContext{}
ctx.ScanInterval = 10 * time.Minute
ctx.Clock = hlc.NewClock(hlc.UnixNano)
// Create a KV DB with a local sender.
lSender := kv.NewLocalSender()
sender := kv.NewTxnCoordSender(lSender, ctx.Clock, false, nil, stopper)
ctx.DB = client.NewDB(sender)
ctx.Transport = multiraft.NewLocalRPCTransport(stopper)
for i, eng := range engines {
sIdent := roachpb.StoreIdent{
ClusterID: clusterID,
NodeID: 1,
StoreID: roachpb.StoreID(i + 1),
}
// The bootstrapping store will not connect to other nodes so its
// StoreConfig doesn't really matter.
s := storage.NewStore(ctx, eng, &roachpb.NodeDescriptor{NodeID: 1})
// Verify the store isn't already part of a cluster.
if len(s.Ident.ClusterID) > 0 {
return nil, util.Errorf("storage engine already belongs to a cluster (%s)", s.Ident.ClusterID)
}
// Bootstrap store to persist the store ident.
if err := s.Bootstrap(sIdent, stopper); err != nil {
return nil, err
}
// Create first range, writing directly to engine. Note this does
// not create the range, just its data. Only do this if this is the
// first store.
if i == 0 {
// TODO(marc): this is better than having storage/ import sql, but still
// not great. Find a better place to keep those.
initialValues := sql.GetInitialSystemValues()
if err := s.BootstrapRange(initialValues); err != nil {
return nil, err
}
}
if err := s.Start(stopper); err != nil {
return nil, err
}
lSender.AddStore(s)
// Initialize node and store ids. Only initialize the node once.
if i == 0 {
if nodeID, err := allocateNodeID(ctx.DB); nodeID != sIdent.NodeID || err != nil {
return nil, util.Errorf("expected to initialize node id allocator to %d, got %d: %s",
sIdent.NodeID, nodeID, err)
}
}
if storeID, err := allocateStoreIDs(sIdent.NodeID, 1, ctx.DB); storeID != sIdent.StoreID || err != nil {
return nil, util.Errorf("expected to initialize store id allocator to %d, got %d: %s",
sIdent.StoreID, storeID, err)
}
}
return ctx.DB, nil
}
开发者ID:JonathanHub,项目名称:cockroach,代码行数:66,代码来源:node.go
示例10: allocateStoreIDs
// allocateStoreIDs increments the store id generator key for the
// specified node to allocate "inc" new, unique store ids. The
// first ID in a contiguous range is returned on success.
func allocateStoreIDs(nodeID roachpb.NodeID, inc int64, db *client.DB) (roachpb.StoreID, error) {
r, err := db.Inc(keys.StoreIDGenerator, inc)
if err != nil {
return 0, util.Errorf("unable to allocate %d store IDs for node %d: %s", inc, nodeID, err)
}
return roachpb.StoreID(r.ValueInt() - inc + 1), nil
}
开发者ID:gechong,项目名称:cockroach,代码行数:10,代码来源:node.go
示例11: createReplicaSlice
func createReplicaSlice() ReplicaSlice {
rs := ReplicaSlice(nil)
for i := 0; i < 5; i++ {
rs = append(rs, ReplicaInfo{ReplicaDescriptor: roachpb.ReplicaDescriptor{StoreID: roachpb.StoreID(i + 1)}})
}
return rs
}
开发者ID:danieldeb,项目名称:cockroach,代码行数:7,代码来源:replica_slice_test.go
示例12: TestSendRPCRetry
// TestSendRPCRetry verifies that sendRPC failed on first address but succeed on
// second address, the second reply should be successfully returned back.
func TestSendRPCRetry(t *testing.T) {
defer leaktest.AfterTest(t)
g, s := makeTestGossip(t)
defer s()
g.SetNodeID(1)
if err := g.SetNodeDescriptor(&roachpb.NodeDescriptor{NodeID: 1}); err != nil {
t.Fatal(err)
}
// Fill RangeDescriptor with 2 replicas
var descriptor = roachpb.RangeDescriptor{
RangeID: 1,
StartKey: roachpb.RKey("a"),
EndKey: roachpb.RKey("z"),
}
for i := 1; i <= 2; i++ {
addr := util.MakeUnresolvedAddr("tcp", fmt.Sprintf("node%d", i))
nd := &roachpb.NodeDescriptor{
NodeID: roachpb.NodeID(i),
Address: util.MakeUnresolvedAddr(addr.Network(), addr.String()),
}
if err := g.AddInfoProto(gossip.MakeNodeIDKey(roachpb.NodeID(i)), nd, time.Hour); err != nil {
t.Fatal(err)
}
descriptor.Replicas = append(descriptor.Replicas, roachpb.ReplicaDescriptor{
NodeID: roachpb.NodeID(i),
StoreID: roachpb.StoreID(i),
})
}
// Define our rpcSend stub which returns success on the second address.
var testFn rpcSendFn = func(_ rpc.Options, method string, addrs []net.Addr, getArgs func(addr net.Addr) proto.Message, getReply func() proto.Message, _ *rpc.Context) ([]proto.Message, error) {
if method == "Node.Batch" {
// reply from first address failed
_ = getReply()
// reply from second address succeed
batchReply := getReply().(*roachpb.BatchResponse)
reply := &roachpb.ScanResponse{}
batchReply.Add(reply)
reply.Rows = append([]roachpb.KeyValue{}, roachpb.KeyValue{Key: roachpb.Key("b"), Value: roachpb.Value{}})
return []proto.Message{batchReply}, nil
}
return nil, util.Errorf("unexpected method %v", method)
}
ctx := &DistSenderContext{
RPCSend: testFn,
RangeDescriptorDB: mockRangeDescriptorDB(func(_ roachpb.RKey, _, _ bool) ([]roachpb.RangeDescriptor, *roachpb.Error) {
return []roachpb.RangeDescriptor{descriptor}, nil
}),
}
ds := NewDistSender(ctx, g)
scan := roachpb.NewScan(roachpb.Key("a"), roachpb.Key("d"), 1)
sr, err := client.SendWrapped(ds, nil, scan)
if err != nil {
t.Fatal(err)
}
if l := len(sr.(*roachpb.ScanResponse).Rows); l != 1 {
t.Fatalf("expected 1 row; got %d", l)
}
}
开发者ID:welfeng2016,项目名称:cockroach,代码行数:61,代码来源:dist_sender_test.go
示例13: TestMembershipChange
func TestMembershipChange(t *testing.T) {
defer leaktest.AfterTest(t)
stopper := stop.NewStopper()
cluster := newTestCluster(nil, 4, stopper, t)
defer stopper.Stop()
// Create a group with a single member, cluster.nodes[0].
groupID := roachpb.RangeID(1)
cluster.createGroup(groupID, 0, 1)
// An automatic election is triggered since this is a single-node Raft group,
// so we don't need to call triggerElection.
// Consume and apply the membership change events.
for i := 0; i < 4; i++ {
go func(i int) {
for {
e, ok := <-cluster.events[i].MembershipChangeCommitted
if !ok {
return
}
e.Callback(nil)
}
}(i)
}
// Add each of the other three nodes to the cluster.
for i := 1; i < 4; i++ {
ch := cluster.nodes[0].ChangeGroupMembership(groupID, makeCommandID(),
raftpb.ConfChangeAddNode,
roachpb.ReplicaDescriptor{
NodeID: cluster.nodes[i].nodeID,
StoreID: roachpb.StoreID(cluster.nodes[i].nodeID),
ReplicaID: roachpb.ReplicaID(cluster.nodes[i].nodeID),
}, nil)
<-ch
}
// TODO(bdarnell): verify that the channel events are sent out correctly.
/*
for i := 0; i < 10; i++ {
log.Infof("tick %d", i)
cluster.tickers[0].Tick()
time.Sleep(5 * time.Millisecond)
}
// Each node is notified of each other node's joining.
for i := 0; i < 4; i++ {
for j := 1; j < 4; j++ {
select {
case e := <-cluster.events[i].MembershipChangeCommitted:
if e.NodeID != cluster.nodes[j].nodeID {
t.Errorf("node %d expected event for %d, got %d", i, j, e.NodeID)
}
default:
t.Errorf("node %d did not get expected event for %d", i, j)
}
}
}*/
}
开发者ID:nporsche,项目名称:cockroach,代码行数:59,代码来源:multiraft_test.go
示例14: getRemoveTarget
// getRemoveTarget queries the allocator for the store that contains a replica
// that can be removed.
func (r *Range) getRemoveTarget() (roachpb.StoreID, error) {
// Pass in an invalid store ID since we don't consider range leases as part
// of the simulator.
removeStore, err := r.allocator.RemoveTarget(r.desc.Replicas, roachpb.StoreID(-1))
if err != nil {
return 0, err
}
return removeStore.StoreID, nil
}
开发者ID:yangxuanjia,项目名称:cockroach,代码行数:11,代码来源:range.go
示例15: OutputEpoch
// OutputEpoch writes to the epochWRiter the current free capacity for all
// stores.
func (c *Cluster) OutputEpoch() {
fmt.Fprintf(c.epochWriter, "%d:\t", c.epoch)
for _, storeID := range c.storeIDs {
store := c.stores[roachpb.StoreID(storeID)]
capacity := store.getCapacity(len(c.rangeIDsByStore[storeID]))
fmt.Fprintf(c.epochWriter, "%d/%.0f%%\t", len(c.rangeIDsByStore[storeID]), float64(capacity.Available)/float64(capacity.Capacity)*100)
}
fmt.Fprintf(c.epochWriter, "\n")
}
开发者ID:bogdanbatog,项目名称:cockroach,代码行数:12,代码来源:cluster.go
示例16: TestSendRPCRetry
// TestSendRPCRetry verifies that sendRPC failed on first address but succeed on
// second address, the second reply should be successfully returned back.
func TestSendRPCRetry(t *testing.T) {
defer leaktest.AfterTest(t)
g, s := makeTestGossip(t)
defer s()
g.SetNodeID(1)
if err := g.SetNodeDescriptor(&roachpb.NodeDescriptor{NodeID: 1}); err != nil {
t.Fatal(err)
}
// Fill RangeDescriptor with 2 replicas
var descriptor = roachpb.RangeDescriptor{
RangeID: 1,
StartKey: roachpb.RKey("a"),
EndKey: roachpb.RKey("z"),
}
for i := 1; i <= 2; i++ {
addr := util.MakeUnresolvedAddr("tcp", fmt.Sprintf("node%d", i))
nd := &roachpb.NodeDescriptor{
NodeID: roachpb.NodeID(i),
Address: util.MakeUnresolvedAddr(addr.Network(), addr.String()),
}
if err := g.AddInfoProto(gossip.MakeNodeIDKey(roachpb.NodeID(i)), nd, time.Hour); err != nil {
t.Fatal(err)
}
descriptor.Replicas = append(descriptor.Replicas, roachpb.ReplicaDescriptor{
NodeID: roachpb.NodeID(i),
StoreID: roachpb.StoreID(i),
})
}
var testFn rpcSendFn = func(_ SendOptions, _ ReplicaSlice,
args roachpb.BatchRequest, _ *rpc.Context) (proto.Message, error) {
batchReply := &roachpb.BatchResponse{}
reply := &roachpb.ScanResponse{}
batchReply.Add(reply)
reply.Rows = append([]roachpb.KeyValue{}, roachpb.KeyValue{Key: roachpb.Key("b"), Value: roachpb.Value{}})
return batchReply, nil
}
ctx := &DistSenderContext{
RPCSend: testFn,
RangeDescriptorDB: mockRangeDescriptorDB(func(_ roachpb.RKey, _, _ bool) ([]roachpb.RangeDescriptor, *roachpb.Error) {
return []roachpb.RangeDescriptor{descriptor}, nil
}),
}
ds := NewDistSender(ctx, g)
scan := roachpb.NewScan(roachpb.Key("a"), roachpb.Key("d"), 1)
sr, err := client.SendWrapped(ds, nil, scan)
if err != nil {
t.Fatal(err)
}
if l := len(sr.(*roachpb.ScanResponse).Rows); l != 1 {
t.Fatalf("expected 1 row; got %d", l)
}
}
开发者ID:danieldeb,项目名称:cockroach,代码行数:55,代码来源:dist_sender_test.go
示例17: GetFirstStoreID
// GetFirstStoreID is a utility function returning the StoreID of the first
// store on this node.
func (ts *TestServer) GetFirstStoreID() roachpb.StoreID {
firstStoreID := roachpb.StoreID(-1)
err := ts.Stores().VisitStores(func(s *storage.Store) error {
if firstStoreID == -1 {
firstStoreID = s.Ident.StoreID
}
return nil
})
if err != nil {
panic(err)
}
return firstStoreID
}
开发者ID:YuleiXiao,项目名称:cockroach,代码行数:15,代码来源:testserver.go
示例18: TestReproposeConfigChange
// TestReproposeConfigChange verifies the behavior when multiple
// configuration changes are in flight at once. Raft prohibits this,
// but any configuration changes that are dropped by this rule should
// be reproposed when the previous change completes.
func TestReproposeConfigChange(t *testing.T) {
defer leaktest.AfterTest(t)
stopper := stop.NewStopper()
defer stopper.Stop()
const clusterSize = 4
const groupSize = 3
cluster := newTestCluster(nil, clusterSize, stopper, t)
const groupID = roachpb.RangeID(1)
const leader = 0
const proposer = 1
cluster.createGroup(groupID, leader, groupSize)
cluster.elect(leader, groupID)
targetDesc := roachpb.ReplicaDescriptor{
NodeID: cluster.nodes[groupSize].nodeID,
StoreID: roachpb.StoreID(cluster.nodes[groupSize].nodeID),
ReplicaID: roachpb.ReplicaID(cluster.nodes[groupSize].nodeID),
}
// Add a node and immediately remove it without waiting for the
// first change to commit.
addErrCh := cluster.nodes[proposer].ChangeGroupMembership(groupID, makeCommandID(),
raftpb.ConfChangeAddNode, targetDesc, nil)
removeErrCh := cluster.nodes[proposer].ChangeGroupMembership(groupID, makeCommandID(),
raftpb.ConfChangeRemoveNode, targetDesc, nil)
// The add command will commit first; then it needs to be applied.
// Apply it on the proposer node before the leader.
e := <-cluster.events[proposer].MembershipChangeCommitted
e.Callback(nil)
e = <-cluster.events[leader].MembershipChangeCommitted
e.Callback(nil)
// Now wait for both commands to commit.
select {
case err := <-addErrCh:
if err != nil {
t.Errorf("add failed: %s", err)
}
case <-time.After(time.Second):
t.Errorf("add timed out")
}
select {
case err := <-removeErrCh:
if err != nil {
t.Errorf("remove failed: %s", err)
}
case <-time.After(time.Second):
t.Errorf("remove timed out")
}
}
开发者ID:haint504,项目名称:cockroach,代码行数:55,代码来源:multiraft_test.go
示例19: TestBookieReserveMaxBytes
// TestBookieReserveMaxBytes ensures that over-booking doesn't occur when trying
// to reserve more bytes than maxReservedBytes.
func TestBookieReserveMaxBytes(t *testing.T) {
defer leaktest.AfterTest(t)()
previousReservedBytes := 10
stopper, _, b := createTestBookie(time.Hour, previousReservedBytes*2, int64(previousReservedBytes))
defer stopper.Stop()
// Load up reservations with a size of 1 each.
for i := 1; i <= previousReservedBytes; i++ {
req := roachpb.ReservationRequest{
StoreRequestHeader: roachpb.StoreRequestHeader{
StoreID: roachpb.StoreID(i),
NodeID: roachpb.NodeID(i),
},
RangeID: roachpb.RangeID(i),
RangeSize: 1,
}
if !b.Reserve(context.Background(), req, nil).Reserved {
t.Errorf("%d: could not add reservation", i)
}
verifyBookie(t, b, i, i, int64(i))
}
overbookedReq := roachpb.ReservationRequest{
StoreRequestHeader: roachpb.StoreRequestHeader{
StoreID: roachpb.StoreID(previousReservedBytes + 1),
NodeID: roachpb.NodeID(previousReservedBytes + 1),
},
RangeID: roachpb.RangeID(previousReservedBytes + 1),
RangeSize: 1,
}
if b.Reserve(context.Background(), overbookedReq, nil).Reserved {
t.Errorf("expected reservation to fail due to too many already existing reservations, but it succeeded")
}
// The same numbers from the last call to verifyBookie.
verifyBookie(t, b, previousReservedBytes, previousReservedBytes, int64(previousReservedBytes))
}
开发者ID:yangxuanjia,项目名称:cockroach,代码行数:40,代码来源:reservation_test.go
示例20: TestStoresRemoveStore
func TestStoresRemoveStore(t *testing.T) {
defer leaktest.AfterTest(t)
ls := NewStores()
storeID := roachpb.StoreID(89)
ls.AddStore(&Store{Ident: roachpb.StoreIdent{StoreID: storeID}})
ls.RemoveStore(&Store{Ident: roachpb.StoreIdent{StoreID: storeID}})
if ls.HasStore(storeID) {
t.Errorf("expted local sender to remove storeID=%d", storeID)
}
}
开发者ID:haint504,项目名称:cockroach,代码行数:14,代码来源:stores_test.go
注:本文中的github.com/cockroachdb/cockroach/roachpb.StoreID函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论