예제 #1
0
 private Header createHeader(
     String binlogFile, LogHeader logHeader, String schemaName, String tableName) {
   // header会做信息冗余,方便以后做检索或者过滤
   Header.Builder headerBuilder = Header.newBuilder();
   headerBuilder.setVersion(version);
   headerBuilder.setLogfileName(binlogFile);
   headerBuilder.setLogfileOffset(logHeader.getLogPos() - logHeader.getEventLen());
   headerBuilder.setServerId(logHeader.getServerId());
   headerBuilder.setServerenCode(UTF_8); // 经过java输出后所有的编码为unicode
   headerBuilder.setExecuteTime(logHeader.getWhen() * 1000L);
   headerBuilder.setSourceType(Type.MYSQL);
   if (schemaName != null) {
     headerBuilder.setSchemaName(StringUtils.lowerCase(schemaName));
   }
   if (tableName != null) {
     headerBuilder.setTableName(StringUtils.lowerCase(tableName));
   }
   headerBuilder.setEventLength(logHeader.getEventLen());
   return headerBuilder.build();
 }
예제 #2
0
 /** The time when the query started, in seconds since 1970. */
 public final long getWhen() {
   return header.getWhen();
 }
예제 #3
0
 /**
  * The position of the next event in the master binary log, in bytes from the beginning of the
  * file. In a binlog that is not a relay log, this is just the position of the next event, in
  * bytes from the beginning of the file. In a relay log, this is the position of the next event in
  * the master's binlog.
  */
 public final long getLogPos() {
   return header.getLogPos();
 }
예제 #4
0
 /** Server ID of the server that created the event. */
 public final long getServerId() {
   return header.getServerId();
 }
예제 #5
0
 /**
  * The total size of this event, in bytes. In other words, this is the sum of the sizes of
  * Common-Header, Post-Header, and Body.
  */
 public final int getEventLen() {
   return header.getEventLen();
 }