Skip to content

Commit

Permalink
Support OceanBase 4.x and fix OceanBase writer.
Browse files Browse the repository at this point in the history
  • Loading branch information
dingxiaobo committed Oct 26, 2022
1 parent c91dc5f commit aa1c822
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class ObVersion implements Comparable<ObVersion> {
private int patchNumber;

public static final ObVersion V2276 = valueOf("2.2.76");
public static final ObVersion V4000 = valueOf("4.0.0.0");

private static final ObVersion DEFAULT_VERSION =
valueOf(System.getProperty("defaultObVersion","3.2.3.0"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ public static PartInfo getObMySQLPartInfoBySQL(Configuration config, String tabl

conn = DBUtil.getConnection(DataBaseType.OceanBase, jdbcUrl, username, password);
ObVersion obVersion = ObReaderUtils.getObVersion(conn);
if (obVersion.compareTo(ObVersion.V2276) >= 0) {
if (obVersion.compareTo(ObVersion.V2276) >= 0 &&
obVersion.compareTo(ObVersion.V4000) < 0) {
allTable = "__all_table_v2";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public ConcurrentTableWriterTask(DataBaseType dataBaseType) {
private Condition condition = lock.newCondition();

private long startTime;
private boolean isOb2 = false;
private String obWriteMode = "update";
private boolean isOracleCompatibleMode = false;
private String obUpdateColumns = null;
Expand Down Expand Up @@ -130,12 +129,6 @@ public void init(Configuration config) {
concurrentWriter = new ConcurrentTableWriter(config, connectInfo, writeRecordSql);
allTaskInQueue = false;
}

String version = config.getString(Config.OB_VERSION);
int pIdx = version.lastIndexOf('.');
if ((Float.valueOf(version.substring(0, pIdx)) >= 2.1f)) {
isOb2 = true;
}
}

private void initPartCalculator(ServerConnectInfo connectInfo) {
Expand Down Expand Up @@ -313,7 +306,7 @@ private void addRecordToCache(final Record record) {
LOG.warn("fail to get partition id: " + e1.getMessage() + ", record: " + record);
}

if (partId == null && isOb2) {
if (partId == null) {
LOG.debug("fail to calculate parition id, just put into the default buffer.");
partId = Long.MAX_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ private static synchronized Connection connect(DataBaseType dataBaseType,
// unit ms
prop.put("oracle.jdbc.ReadTimeout", socketTimeout);
}
if (dataBaseType == DataBaseType.OceanBase) {
url = url.replace("jdbc:mysql:", "jdbc:oceanbase:");
}

return connect(dataBaseType, url, prop);
}
Expand Down

0 comments on commit aa1c822

Please sign in to comment.