Exemplo n.º 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();
 }
Exemplo n.º 2
0
 /** The time when the query started, in seconds since 1970. */
 public final long getWhen() {
   return header.getWhen();
 }