本文整理汇总了Golang中github.com/pingcap/tidb/kv.Storage.UUID方法的典型用法代码示例。如果您正苦于以下问题:Golang Storage.UUID方法的具体用法?Golang Storage.UUID怎么用?Golang Storage.UUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pingcap/tidb/kv.Storage
的用法示例。
在下文中一共展示了Storage.UUID方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateSession
// CreateSession creates a new session environment.
func CreateSession(store kv.Storage) (Session, error) {
s := &session{
values: make(map[fmt.Stringer]interface{}),
store: store,
sid: atomic.AddInt64(&sessionID, 1),
}
domain, err := domap.Get(store)
if err != nil {
return nil, err
}
sessionctx.BindDomain(s, domain)
variable.BindSessionVars(s)
variable.GetSessionVars(s).SetStatusFlag(mysql.ServerStatusAutocommit, true)
// session implements variable.GlobalVarAccessor. Bind it to ctx.
variable.BindGlobalVarAccessor(s, s)
// session implements autocommit.Checker. Bind it to ctx
autocommit.BindAutocommitChecker(s, s)
sessionMu.Lock()
defer sessionMu.Unlock()
_, ok := storeBootstrapped[store.UUID()]
if !ok {
s.initing = true
bootstrap(s)
s.initing = false
storeBootstrapped[store.UUID()] = true
}
// TODO: Add auth here
privChecker := &privileges.UserPrivileges{}
privilege.BindPrivilegeChecker(s, privChecker)
return s, nil
}
示例2: isBoostrapped
func isBoostrapped(store kv.Storage) bool {
// check in memory
_, ok := storeBootstrapped[store.UUID()]
if ok {
return true
}
// check in kv store
err := kv.RunInNewTxn(store, false, func(txn kv.Transaction) error {
var err error
t := meta.NewMeta(txn)
ok, err = t.IsBootstrapped()
return errors.Trace(err)
})
if err != nil {
log.Fatalf("check bootstrapped err %v", err)
}
if ok {
// here mean memory is not ok, but other server has already finished it
storeBootstrapped[store.UUID()] = true
}
return ok
}
示例3: getStoreBootstrapVersion
func getStoreBootstrapVersion(store kv.Storage) int64 {
// check in memory
_, ok := storeBootstrapped[store.UUID()]
if ok {
return currentBootstrapVersion
}
var ver int64
// check in kv store
err := kv.RunInNewTxn(store, false, func(txn kv.Transaction) error {
var err error
t := meta.NewMeta(txn)
ver, err = t.GetBootstrapVersion()
return errors.Trace(err)
})
if err != nil {
log.Fatalf("check bootstrapped err %v", err)
}
if ver > notBootstrapped {
// here mean memory is not ok, but other server has already finished it
storeBootstrapped[store.UUID()] = true
}
return ver
}
示例4: CreateSession
// CreateSession creates a new session environment.
func CreateSession(store kv.Storage) (Session, error) {
s := &session{
values: make(map[fmt.Stringer]interface{}),
store: store,
sid: atomic.AddInt64(&sessionID, 1),
}
domain, err := domap.Get(store)
if err != nil {
return nil, err
}
sessionctx.BindDomain(s, domain)
variable.BindSessionVars(s)
variable.GetSessionVars(s).SetStatusFlag(mysql.ServerStatusAutocommit, true)
sessionMu.Lock()
defer sessionMu.Unlock()
_, ok := storeBootstrapped[store.UUID()]
if !ok {
bootstrap(s)
storeBootstrapped[store.UUID()] = true
}
// Add auth here
return s, nil
}
示例5: Get
func (dm *domainMap) Get(store kv.Storage) (d *domain.Domain, err error) {
key := store.UUID()
dm.mu.Lock()
defer dm.mu.Unlock()
d = dm.domains[key]
if d != nil {
return
}
if SchemaLease <= minSchemaLease {
SchemaLease = minSchemaLease
}
lease := SchemaLease
// if storage is local storage, we may in test environment or
// run server in single machine mode, so we don't need wait
// 2 * lease time for DDL operation.
if localstore.IsLocalStore(store) {
lease = 0
}
d, err = domain.NewDomain(store, lease)
if err != nil {
return nil, errors.Trace(err)
}
dm.domains[key] = d
return
}
示例6: finishBoostrap
func finishBoostrap(store kv.Storage) {
storeBootstrapped[store.UUID()] = true
err := kv.RunInNewTxn(store, true, func(txn kv.Transaction) error {
t := meta.NewMeta(txn)
err := t.FinishBootstrap()
return errors.Trace(err)
})
if err != nil {
log.Fatalf("finish bootstrap err %v", err)
}
}
示例7: Get
func (dm *domainMap) Get(store kv.Storage) (d *domain.Domain, err error) {
key := store.UUID()
dm.mu.Lock()
defer dm.mu.Unlock()
d = dm.domains[key]
if d != nil {
return
}
d, err = domain.NewDomain(store)
if err != nil {
return nil, errors.Trace(err)
}
dm.domains[key] = d
return
}
示例8: Get
func (dm *domainMap) Get(store kv.Storage) (d *domain.Domain, err error) {
key := store.UUID()
dm.mu.Lock()
defer dm.mu.Unlock()
d = dm.domains[key]
if d != nil {
return
}
lease := time.Duration(0)
if !localstore.IsLocalStore(store) {
lease = schemaLease
}
d, err = domain.NewDomain(store, lease)
if err != nil {
return nil, errors.Trace(err)
}
dm.domains[key] = d
return
}
示例9: Get
func (dm *domainMap) Get(store kv.Storage) (d *domain.Domain, err error) {
key := store.UUID()
dm.mu.Lock()
defer dm.mu.Unlock()
d = dm.domains[key]
if d != nil {
return
}
lease := time.Duration(0)
if !localstore.IsLocalStore(store) {
lease = schemaLease
}
err = util.RunWithRetry(defaultMaxRetries, retryInterval, func() (retry bool, err1 error) {
d, err1 = domain.NewDomain(store, lease)
return true, errors.Trace(err1)
})
if err != nil {
return nil, errors.Trace(err)
}
dm.domains[key] = d
return
}
示例10: Delete
func (dm *domainMap) Delete(store kv.Storage) {
dm.mu.Lock()
delete(dm.domains, store.UUID())
dm.mu.Unlock()
}