Exemple #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();
 }
Exemple #2
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();
 }