Example #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();
 }
Example #2
0
 /** Server ID of the server that created the event. */
 public final long getServerId() {
   return header.getServerId();
 }