|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectnet.neoremind.fountain.eventposition.GtIdSet
public class GtIdSet
MySQL 5.6之后引入Gtid_set数据结构,目的是为了轻量级的记录大量的连续全局事务ID, 比如已经在从数据库上执行的全局事务ID, 或者主库上正在运行的全局事务ID。这些集合往往包含海量的全局事务ID。
在连续的情况下,可以在常数时间内判断一个GtID是否包含在集合内。 这很容易用来检查一个GtID是否已经执行过,因此可以用在防止MySQL事务在同一个Slave上重复执行这类场景。 Gtid_set的结构是一个以sidno,通常为server uuid,为序号的数组,每个数组元素都指向一条Interval组成的链表,链表中的每个Interval 用来存放一组事务ID的区段,例如 (1,5)。Gtid_set | sidno: 1 | -> Interval (1, 5) -> Interval (11, 18) | sidno: 2 | -> Interval (1, 27) -> Interval (29, 115) -> Interval (117, 129) | sidno: 3 | -> Interval (1, 154)可以用如下命令看主库已经执行过的GtIdSet集合:show global variables like '%gtid_executed%'\G
************************** 1. row *************************** Variable_name: gtid_executed Value: 10a27632-a909-11e2-8bc7-0010184e9e08:1-4, 153c0406-a909-11e2-8bc7-0010184e9e08:1-3, 7a07cd08-ac1b-11e2-9fcf-0010184e9e08:1-31这个数据结构在发送com-binlog-dump-gtid命令时候会用到,主要用于构建从库已经执行过的gtid集合,主库就不发送增量下来了。
GtId,
com-binlog-dump-gtid| 构造方法摘要 | |
|---|---|
GtIdSet()
|
|
| 方法摘要 | |
|---|---|
void |
addGtId(byte[] sid,
Long gtId)
递增gtid gtid要大于等于interval end,否则抛出GtIdInvalidException异常 |
static GtIdSet |
buildFromString(String str)
从字符串还原GtIdSet类对象 |
void |
encode(ByteArrayOutputStream out)
从库把自己的gtid_executed发送给主,这个数据结构封装了写socket stream的格式。 |
List<GtId> |
getGtIdList()
|
int |
length()
SID block的长度,按照这个计算: 注意,这里只支持1个interval的情况。 |
void |
setGtIdList(List<GtId> gtIdList)
|
String |
toString()
按照05b47d41-7b10-11e2-9fff-00241db92e69:1-19;4f65e570-7b32-11e2-a0de-00241db92e69:1这个格式打印 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 构造方法详细信息 |
|---|
public GtIdSet()
| 方法详细信息 |
|---|
public static GtIdSet buildFromString(String str)
str - 例如05b47d41-7b10-11e2-9fff-00241db92e69:1-19;4f65e570-7b32-11e2-a0de-00241db92e69:22-66
public String toString()
Object 中的 toString
public void addGtId(byte[] sid,
Long gtId)
throws GtIdInvalidException
sid - server uuid 16byte arraygtId - 当前处理的gtid
GtIdInvalidExceptionpublic int length()
8 n_sids
for n_sids {
string[16] SID
8 n_intervals
for n_intervals {
8 start (signed)
8 end (signed)
}
}
public void encode(ByteArrayOutputStream out)
throws IOException
8 n_sids
for n_sids {
string[16] SID
8 n_intervals
for n_intervals {
8 start (signed)
8 end (signed)
}
}
解释如下:
# n_sid ulong 8bytes == which size is the gtid_set # | sid uuid 16bytes UUID as a binary # | n_intervals ulong 8bytes == how many intervals are sent for this gtid # | | start ulong 8bytes Start position of this interval # | | stop ulong 8bytes Stop position of this interval
IOExceptionpublic List<GtId> getGtIdList()
public void setGtIdList(List<GtId> gtIdList)
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||