Skip to content

Commit

Permalink
[feature](binlog) Allow BarrierLog to wrap another binlog
Browse files Browse the repository at this point in the history
to make it worked in old doris version without breaking compatibility
  • Loading branch information
w41ter committed Oct 31, 2024
1 parent ac6a868 commit 23d7b48
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/persist/BarrierLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.doris.common.io.Text;
import org.apache.doris.common.io.Writable;
import org.apache.doris.persist.gson.GsonUtils;
import org.apache.doris.thrift.TBinlogType;

import com.google.gson.annotations.SerializedName;

Expand All @@ -37,6 +38,11 @@ public class BarrierLog implements Writable {
@SerializedName(value = "tableName")
String tableName;

@SerializedName(value = "binlogType")
int binlogType;
@SerializedName(value = "binlog")
String binlog;

public BarrierLog() {
}

Expand All @@ -47,6 +53,28 @@ public BarrierLog(long dbId, String dbName, long tableId, String tableName) {
this.tableName = tableName;
}

// A trick: Wrap the binlog as part of the BarrierLog so that it can work in
// the old Doris version without breaking the compatibility.
public BarrierLog(long dbId, long tableId, TBinlogType binlogType, String binlog) {
this.dbId = dbId;
this.tableId = tableId;
this.binlogType = binlogType.getValue();
this.binlog = binlog;
}

public boolean hasBinlog() {
return binlog != null;
}

public String getBinlog() {
return binlog;
}

// null is returned if binlog is not set or binlogType is not recognized.
public TBinlogType getBinlogType() {
return binlog == null ? null : TBinlogType.findByValue(binlogType);
}

public long getDbId() {
return dbId;
}
Expand Down

0 comments on commit 23d7b48

Please sign in to comment.