// 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, errors.Errorf("unable to allocate %d store IDs for node %d: %s", inc, nodeID, err) } return roachpb.StoreID(r.ValueInt() - inc + 1), nil }
// allocateNodeID increments the node id generator key to allocate // a new, unique node id. func allocateNodeID(db *client.DB) (roachpb.NodeID, error) { r, err := db.Inc(keys.NodeIDGenerator, 1) if err != nil { return 0, errors.Errorf("unable to allocate node ID: %s", err) } return roachpb.NodeID(r.ValueInt()), nil }