mirror of
https://github.com/alibaba/DataX.git
synced 2025-05-02 19:50:29 +08:00
obwriter: adapted for short jdbc url
This commit is contained in:
parent
c0351b8d76
commit
26d1f11c1b
@ -20,7 +20,6 @@ import com.alibaba.datax.plugin.rdbms.writer.Constant;
|
||||
import com.alibaba.datax.plugin.rdbms.writer.Key;
|
||||
import com.alibaba.datax.plugin.rdbms.writer.util.WriterUtil;
|
||||
import com.alibaba.datax.plugin.writer.oceanbasev10writer.task.ConcurrentTableWriterTask;
|
||||
import com.alibaba.datax.plugin.writer.oceanbasev10writer.task.SingleTableWriterTask;
|
||||
import com.alibaba.datax.plugin.writer.oceanbasev10writer.util.ObWriterUtils;
|
||||
|
||||
/**
|
||||
|
@ -24,8 +24,26 @@ public class ServerConnectInfo {
|
||||
this.tenantName = ss[1].trim().split(":")[1];
|
||||
this.jdbcUrl = ss[2].replace("jdbc:mysql:", "jdbc:oceanbase:");
|
||||
} else {
|
||||
throw new RuntimeException ("jdbc url format is not correct: " + jdbcUrl);
|
||||
this.jdbcUrl = jdbcUrl.replace("jdbc:mysql:", "jdbc:oceanbase:");
|
||||
if (username.contains("@") && username.contains("#")) {
|
||||
this.userName = username.substring(0, username.indexOf("@"));
|
||||
this.tenantName = username.substring(username.indexOf("@") + 1, username.indexOf("#"));
|
||||
this.clusterName = username.substring(username.indexOf("#") + 1);
|
||||
} else if (username.contains(":")) {
|
||||
String[] config = username.split(":");
|
||||
if (config.length != 3) {
|
||||
throw new RuntimeException ("username format is not correct: " + username);
|
||||
}
|
||||
this.clusterName = config[0];
|
||||
this.tenantName = config[1];
|
||||
this.userName = config[2];
|
||||
} else {
|
||||
this.clusterName = null;
|
||||
this.tenantName = null;
|
||||
this.userName = username;
|
||||
}
|
||||
}
|
||||
|
||||
this.password = password;
|
||||
parseJdbcUrl(jdbcUrl);
|
||||
}
|
||||
@ -51,8 +69,11 @@ public class ServerConnectInfo {
|
||||
}
|
||||
|
||||
public String getFullUserName() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(userName).append("@").append(tenantName).append("#").append(clusterName);
|
||||
StringBuilder builder = new StringBuilder(userName);
|
||||
if (tenantName != null && clusterName != null) {
|
||||
builder.append("@").append(tenantName).append("#").append(clusterName);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public class ConcurrentTableWriterTask extends CommonRdbmsWriter.Task {
|
||||
partCalculator = new ObPartitionIdCalculator(connectInfo.ipPort, tableEntryKey);
|
||||
} catch (Exception ex) {
|
||||
++retry;
|
||||
LOG.warn("create new part calculator failed, retry ... {}", retry, ex);
|
||||
LOG.warn("create new part calculator failed, retry {}: {}", retry, ex.getMessage());
|
||||
}
|
||||
} while (partCalculator == null && retry < 3); // try 3 times
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user