本文整理汇总了Golang中github.com/youtube/vitess/go/vt/mysqlctl/proto.AppendGTID函数的典型用法代码示例。如果您正苦于以下问题:Golang AppendGTID函数的具体用法?Golang AppendGTID怎么用?Golang AppendGTID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AppendGTID函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: positionCmd
func positionCmd(mysqld *mysqlctl.Mysqld, subFlags *flag.FlagSet, args []string) error {
subFlags.Parse(args)
if len(args) < 3 {
return fmt.Errorf("Not enough arguments for position operation.")
}
pos1, err := myproto.DecodeReplicationPosition(args[1])
if err != nil {
return err
}
switch args[0] {
case "equal":
pos2, err := myproto.DecodeReplicationPosition(args[2])
if err != nil {
return err
}
fmt.Println(pos1.Equal(pos2))
case "at_least":
pos2, err := myproto.DecodeReplicationPosition(args[2])
if err != nil {
return err
}
fmt.Println(pos1.AtLeast(pos2))
case "append":
gtid, err := myproto.DecodeGTID(args[2])
if err != nil {
return err
}
fmt.Println(myproto.AppendGTID(pos1, gtid))
}
return nil
}
开发者ID:haoqoo,项目名称:vitess,代码行数:34,代码来源:mysqlctl.go
示例2: writeRecoveryPosition
// writeRecoveryPosition will write the current GTID as the recovery position
// for the next transaction.
// We will also try to get the timestamp for the transaction. Two cases:
// - we have statements, and they start with a SET TIMESTAMP that we
// can parse: then we update transaction_timestamp in blp_checkpoint
// with it, and set SecondsBehindMaster to now() - transaction_timestamp
// - otherwise (the statements are probably filtered out), we leave
// transaction_timestamp alone (keeping the old value), and we don't
// change SecondsBehindMaster
func (blp *BinlogPlayer) writeRecoveryPosition(tx *proto.BinlogTransaction) error {
now := time.Now().Unix()
blp.blpPos.Position = myproto.AppendGTID(blp.blpPos.Position, tx.GTIDField.Value)
updateRecovery := UpdateBlpCheckpoint(blp.blpPos.Uid, blp.blpPos.Position, now, tx.Timestamp)
qr, err := blp.exec(updateRecovery)
if err != nil {
return fmt.Errorf("Error %v in writing recovery info %v", err, updateRecovery)
}
if qr.RowsAffected != 1 {
return fmt.Errorf("Cannot update blp_recovery table, affected %v rows", qr.RowsAffected)
}
blp.blplStats.SetLastPosition(blp.blpPos.Position)
if tx.Timestamp != 0 {
blp.blplStats.SecondsBehindMaster.Set(now - tx.Timestamp)
}
return nil
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:28,代码来源:binlog_player.go
示例3: parseEvents
//.........这里部分代码省略.........
format, err = ev.Format()
if err != nil {
return pos, fmt.Errorf("can't parse FORMAT_DESCRIPTION_EVENT: %v, event data: %#v", err, ev)
}
continue
}
// We can't parse anything until we get a FORMAT_DESCRIPTION_EVENT that
// tells us the size of the event header.
if format.IsZero() {
// The only thing that should come before the FORMAT_DESCRIPTION_EVENT
// is a fake ROTATE_EVENT, which the master sends to tell us the name
// of the current log file.
if ev.IsRotate() {
continue
}
return pos, fmt.Errorf("got a real event before FORMAT_DESCRIPTION_EVENT: %#v", ev)
}
// Strip the checksum, if any. We don't actually verify the checksum, so discard it.
ev, _, err = ev.StripChecksum(format)
if err != nil {
return pos, fmt.Errorf("can't strip checksum from binlog event: %v, event data: %#v", err, ev)
}
// Update the GTID if the event has one. The actual event type could be
// something special like GTID_EVENT (MariaDB, MySQL 5.6), or it could be
// an arbitrary event with a GTID in the header (Google MySQL).
if ev.HasGTID(format) {
gtid, err = ev.GTID(format)
if err != nil {
return pos, fmt.Errorf("can't get GTID from binlog event: %v, event data: %#v", err, ev)
}
pos = myproto.AppendGTID(pos, gtid)
}
switch {
case ev.IsGTID(): // GTID_EVENT
if ev.IsBeginGTID(format) {
begin()
}
case ev.IsXID(): // XID_EVENT (equivalent to COMMIT)
if err = commit(ev.Timestamp()); err != nil {
return pos, err
}
case ev.IsIntVar(): // INTVAR_EVENT
name, value, err := ev.IntVar(format)
if err != nil {
return pos, fmt.Errorf("can't parse INTVAR_EVENT: %v, event data: %#v", err, ev)
}
statements = append(statements, proto.Statement{
Category: proto.BL_SET,
Sql: fmt.Sprintf("SET %s=%d", name, value),
})
case ev.IsRand(): // RAND_EVENT
seed1, seed2, err := ev.Rand(format)
if err != nil {
return pos, fmt.Errorf("can't parse RAND_EVENT: %v, event data: %#v", err, ev)
}
statements = append(statements, proto.Statement{
Category: proto.BL_SET,
Sql: fmt.Sprintf("SET @@RAND_SEED1=%d, @@RAND_SEED2=%d", seed1, seed2),
})
case ev.IsQuery(): // QUERY_EVENT
// Extract the query string and group into transactions.
q, err := ev.Query(format)
开发者ID:richarwu,项目名称:vitess,代码行数:67,代码来源:binlog_streamer.go
示例4: AppendGTID
// AppendGTID updates the current replication position by appending a GTID to
// the set of transactions that have been processed.
func (rci *RowcacheInvalidator) AppendGTID(gtid myproto.GTID) {
rci.posMutex.Lock()
defer rci.posMutex.Unlock()
rci.pos = myproto.AppendGTID(rci.pos, gtid)
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:7,代码来源:rowcache_invalidator.go
注:本文中的github.com/youtube/vitess/go/vt/mysqlctl/proto.AppendGTID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论