Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support backend ssl && support ob #3892

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public boolean isExistXid(String xaId) {
}

private void checkResidualXid(boolean isStartup) {
if (SystemConfig.getInstance().getBackendMode() == SystemConfig.BackendMode.OB) {
return;
}
Set<Long> usedXaid = getCurrentUsedXaids();
usedXaid.add(DbleServer.getInstance().getXaIDInc());
if (LOGGER.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ public KeyVariables call() {
if (columnIsolation == null) {
return keyVariables;
}
String[] columns = new String[]{COLUMN_LOWER_CASE, COLUMN_AUTOCOMMIT, COLUMN_READONLY, COLUMN_MAX_PACKET, columnIsolation, COLUMN_VERSION, COLUMN_BACK_LOG};

String[] columns;
if (SystemConfig.getInstance().getBackendMode() == SystemConfig.BackendMode.OB) {
columns = new String[]{COLUMN_LOWER_CASE, COLUMN_AUTOCOMMIT, COLUMN_READONLY, COLUMN_MAX_PACKET, columnIsolation, COLUMN_VERSION};
} else {
columns = new String[]{COLUMN_LOWER_CASE, COLUMN_AUTOCOMMIT, COLUMN_READONLY, COLUMN_MAX_PACKET, columnIsolation, COLUMN_VERSION, COLUMN_BACK_LOG};
}

StringBuilder sql = new StringBuilder("select ");
for (int i = 0; i < columns.length; i++) {
if (i != 0) {
Expand Down Expand Up @@ -125,7 +132,9 @@ public void onResult(SQLQueryResult<Map<String, String>> result) {
keyVariablesTmp.setTargetMaxPacketSize(SystemConfig.getInstance().getMaxPacketSize() + KeyVariables.MARGIN_PACKET_SIZE);
keyVariablesTmp.setReadOnly(result.getResult().get(COLUMN_READONLY).equals("1"));
keyVariablesTmp.setVersion(result.getResult().get(COLUMN_VERSION));
keyVariablesTmp.setBackLog(Integer.parseInt(result.getResult().get(COLUMN_BACK_LOG)));
if (SystemConfig.getInstance().getBackendMode() != SystemConfig.BackendMode.OB) {
keyVariablesTmp.setBackLog(Integer.parseInt(result.getResult().get(COLUMN_BACK_LOG)));
}

if (needSync) {
boolean checkNeedSync = false;
Expand Down
56 changes: 50 additions & 6 deletions src/main/java/com/actiontech/dble/config/model/SystemConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ private SystemConfig() {

private String serverCertificateKeyStoreUrl = null;
private String serverCertificateKeyStorePwd = null;
private String clientCertificateKeyStoreUrl = null;
private String clientCertificateKeyStorePwd = null;


private String trustCertificateKeyStoreUrl = null;
private String trustCertificateKeyStorePwd = null;

Expand All @@ -253,8 +257,10 @@ private SystemConfig() {
private String gmsslBothPfxPwd = null;
private String gmsslRcaPem = null;
private String gmsslOcaPem = null;
private boolean supportSSL = false;
private boolean supportFrontSSL = false;
private boolean supportBackSSL = false;

private BackendMode backendMode = BackendMode.MYSQL;
private int enableAsyncRelease = 1;
//unit: ms
private long releaseTimeout = 10L;
Expand Down Expand Up @@ -309,6 +315,22 @@ public void setServerCertificateKeyStorePwd(String serverCertificateKeyStorePwd)
}
}

public String getClientCertificateKeyStoreUrl() {
return clientCertificateKeyStoreUrl;
}

public void setClientCertificateKeyStoreUrl(String clientCertificateKeyStoreUrl) {
this.clientCertificateKeyStoreUrl = clientCertificateKeyStoreUrl;
}

public String getClientCertificateKeyStorePwd() {
return clientCertificateKeyStorePwd;
}

public void setClientCertificateKeyStorePwd(String clientCertificateKeyStorePwd) {
this.clientCertificateKeyStorePwd = clientCertificateKeyStorePwd;
}

public String getTrustCertificateKeyStoreUrl() {
return trustCertificateKeyStoreUrl;
}
Expand Down Expand Up @@ -1842,15 +1864,30 @@ public void setDataCenter(String dataCenter) {
this.dataCenter = dataCenter;
}

public boolean isSupportSSL() {
return supportSSL;
public boolean isSupportFrontSSL() {
return supportFrontSSL;
}

@SuppressWarnings("unused")
public void setSupportSSL(boolean supportSSL) {
this.supportSSL = supportSSL;
public void setSupportFrontSSL(boolean supportFrontSSL) {
this.supportFrontSSL = supportFrontSSL;
}

public boolean isSupportBackSSL() {
return supportBackSSL;
}

public void setSupportBackSSL(boolean supportBackSSL) {
this.supportBackSSL = supportBackSSL;
}

public BackendMode getBackendMode() {
return backendMode;
}

public void setBackendMode(BackendMode backendMode) {
this.backendMode = backendMode;
}

public int getEnableMemoryBufferMonitor() {
return enableMemoryBufferMonitor;
Expand Down Expand Up @@ -2039,13 +2076,16 @@ public String toString() {
", closeHeartBeatRecord=" + closeHeartBeatRecord +
", serverCertificateKeyStoreUrl=" + serverCertificateKeyStoreUrl +
", serverCertificateKeyStorePwd=" + serverCertificateKeyStorePwd +
", clientCertificateKeyStoreUrl=" + clientCertificateKeyStoreUrl +
", clientCertificateKeyStorePwd=" + clientCertificateKeyStorePwd +
", supportBackSSL=" + supportBackSSL +
", trustCertificateKeyStoreUrl=" + trustCertificateKeyStoreUrl +
", trustCertificateKeyStorePwd=" + trustCertificateKeyStorePwd +
", gmsslBothPfx=" + gmsslBothPfx +
", gmsslBothPfxPwd=" + gmsslBothPfxPwd +
", gmsslRcaPem=" + gmsslRcaPem +
", gmsslOcaPem=" + gmsslOcaPem +
", supportSSL=" + supportSSL +
", supportFrontSSL=" + supportFrontSSL +
", enableRoutePenetration=" + enableRoutePenetration +
", routePenetrationRules='" + routePenetrationRules + '\'' +
", enableSessionActiveRatioStat=" + enableSessionActiveRatioStat +
Expand Down Expand Up @@ -2102,4 +2142,8 @@ private void checkChineseProperty(String val, String name) {
problemReporter.warn("Property [ " + name + " ] " + val + " in bootstrap.cnf is illegal,the " + Charset.defaultCharset().name() + " encoding is recommended, Property [ " + name + " ] show be use u4E00-u9FA5a-zA-Z_0-9\\-\\.");
}
}

public enum BackendMode {
MYSQL, OB
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ public static void mapping(Object target, Properties src, ProblemReporter proble
src.remove(propertyName);
continue;
}
} else if (cls.isEnum()) {
try {
value = Enum.valueOf((Class<Enum>) cls, (valStr).toUpperCase());
} catch (IllegalArgumentException e) {
String propertyName = pd.getName();
String message = getEnumErrorMessage(propertyName, valStr, cls);
if (problemReporter != null) {
problemReporter.warn(message);
errorParameters.add(message);
} else {
LOGGER.warn(message);
}
src.remove(propertyName);
continue;
}
}
if (value != null) {
Method method = pd.getWriteMethod();
Expand Down Expand Up @@ -135,6 +150,19 @@ public static Properties mappingFromSystemProperty(Object target, ProblemReporte
systemProperties.remove(propertyName);
continue;
}
} else if (cls.isEnum()) {
try {
value = Enum.valueOf((Class<Enum>) cls, valStr);
} catch (IllegalArgumentException e) {
String msg = getEnumErrorMessage(propertyName, valStr, cls);
if (problemReporter != null) {
problemReporter.warn(msg);
} else {
LOGGER.warn(msg);
}
systemProperties.remove(propertyName);
continue;
}
}
if (value != null) {
Method method = pd.getWriteMethod();
Expand Down Expand Up @@ -276,4 +304,12 @@ private static String getTypeErrorMessage(String name, String values, Class<?> c
return sb.toString();
}

private static String getEnumErrorMessage(String name, String values, Class<?> cls) {
String message = getErrorCompatibleMessage(name);
StringBuilder sb = new StringBuilder(message);
sb.append("property [ ").append(name).append(" ] '").append(values).append("' isn't a valid value.");
return sb.toString();
}


}
Loading
Loading