Skip to content

Commit

Permalink
feat(alibaba#6506): Can change betaIps multiple times in beta(or gray).
Browse files Browse the repository at this point in the history
1. And fix SQL `encrypted_data_key=?WHERE`.
  • Loading branch information
CherishCai committed Apr 22, 2022
1 parent a9e2cbd commit 414ad44
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public static void updateMd5(String groupKey, String md5, long lastModifiedTs, S
public static void updateBetaMd5(String groupKey, String md5, List<String> ips4Beta, long lastModifiedTs,
String encryptedDataKey) {
CacheItem cache = makeSure(groupKey, encryptedDataKey, true);
if (cache.md54Beta == null || !cache.md54Beta.equals(md5)) {
if (cache.md54Beta == null || !cache.md54Beta.equals(md5) || !ips4Beta.equals(cache.ips4Beta)) {
cache.isBeta = true;
cache.md54Beta = md5;
cache.lastModifiedTs4Beta = lastModifiedTs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ public void updateConfigInfo4Beta(ConfigInfo configInfo, String betaIps, String
try {
String md5 = MD5Utils.md5Hex(configInfo.getContent(), Constants.ENCODE);

final String sql = "UPDATE config_info_beta SET content=?,md5=?,src_ip=?,src_user=?,gmt_modified=?,app_name=?,encrypted_data_key=? WHERE data_id=? AND group_id=? AND tenant_id=?";
final String sql = "UPDATE config_info_beta SET content=?,md5=?,beta_ips=?,src_ip=?,src_user=?,gmt_modified=?,app_name=?,encrypted_data_key=? WHERE data_id=? AND group_id=? AND tenant_id=?";

final Object[] args = new Object[] {configInfo.getContent(), md5, srcIp, srcUser, time, appNameTmp,
final Object[] args = new Object[] {configInfo.getContent(), md5, betaIps, srcIp, srcUser, time, appNameTmp,
encryptedDataKey, configInfo.getDataId(), configInfo.getGroup(), tenantTmp};

EmbeddedStorageContextUtils.onModifyConfigBetaInfo(configInfo, betaIps, srcIp, time);
Expand All @@ -381,9 +381,9 @@ public boolean updateConfigInfo4BetaCas(ConfigInfo configInfo, String betaIps, S
try {
String md5 = MD5Utils.md5Hex(configInfo.getContent(), Constants.ENCODE);

final String sql = "UPDATE config_info_beta SET content=?,md5=?,src_ip=?,src_user=?,gmt_modified=?,app_name=? WHERE data_id=? AND group_id=? AND tenant_id=? AND (md5=? OR md5 IS NULL OR md5='')";
final String sql = "UPDATE config_info_beta SET content=?,md5=?,beta_ips=?,src_ip=?,src_user=?,gmt_modified=?,app_name=? WHERE data_id=? AND group_id=? AND tenant_id=? AND (md5=? OR md5 IS NULL OR md5='')";

final Object[] args = new Object[] {configInfo.getContent(), md5, srcIp, srcUser, time, appNameTmp,
final Object[] args = new Object[] {configInfo.getContent(), md5, betaIps, srcIp, srcUser, time, appNameTmp,
configInfo.getDataId(), configInfo.getGroup(), tenantTmp, configInfo.getMd5()};

EmbeddedStorageContextUtils.onModifyConfigBetaInfo(configInfo, betaIps, srcIp, time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ public void updateConfigInfo4Beta(ConfigInfo configInfo, String betaIps, String
: configInfo.getEncryptedDataKey();
try {
jt.update(
"UPDATE config_info_beta SET content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=?,app_name=?,encrypted_data_key = ?WHERE "
+ "data_id=? AND group_id=? AND tenant_id=?", configInfo.getContent(), md5, srcIp, srcUser,
"UPDATE config_info_beta SET content=?, md5=?, beta_ips=?, src_ip=?,src_user=?,gmt_modified=?,app_name=?,encrypted_data_key=? "
+ " WHERE data_id=? AND group_id=? AND tenant_id=?", configInfo.getContent(), md5, betaIps, srcIp, srcUser,
time, appNameTmp, encryptedDataKey, configInfo.getDataId(), configInfo.getGroup(), tenantTmp);
} catch (CannotGetJdbcConnectionException e) {
LogUtil.FATAL_LOG.error("[db-error] " + e.toString(), e);
Expand All @@ -324,9 +324,9 @@ public boolean updateConfigInfo4BetaCas(ConfigInfo configInfo, String betaIps, S
String md5 = MD5Utils.md5Hex(configInfo.getContent(), Constants.ENCODE);
try {
return jt
.update("UPDATE config_info_beta SET content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=?,app_name=? WHERE "
+ "data_id=? AND group_id=? AND tenant_id=? AND (md5=? or md5 is null or md5='')",
configInfo.getContent(), md5, srcIp, srcUser, time, appNameTmp, configInfo.getDataId(),
.update("UPDATE config_info_beta SET content=?, md5=?, beta_ips=?, src_ip=?,src_user=?,gmt_modified=?,app_name=? "
+ " WHERE data_id=? AND group_id=? AND tenant_id=? AND (md5=? or md5 is null or md5='')",
configInfo.getContent(), md5, betaIps, srcIp, srcUser, time, appNameTmp, configInfo.getDataId(),
configInfo.getGroup(), tenantTmp, configInfo.getMd5()) > 0;
} catch (CannotGetJdbcConnectionException e) {
LogUtil.FATAL_LOG.error("[db-error] " + e.toString(), e);
Expand Down Expand Up @@ -2261,8 +2261,8 @@ public void updateConfigInfoAtomic(final ConfigInfo configInfo, final String src

try {
jt.update("UPDATE config_info SET content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=?,"
+ "app_name=?,c_desc=?,c_use=?,effect=?,type=?,c_schema=?,encrypted_data_key=?"
+ "WHERE data_id=? AND group_id=? AND tenant_id=?", configInfo.getContent(), md5Tmp, srcIp, srcUser,
+ "app_name=?,c_desc=?,c_use=?,effect=?,type=?,c_schema=?,encrypted_data_key=? "
+ " WHERE data_id=? AND group_id=? AND tenant_id=?", configInfo.getContent(), md5Tmp, srcIp, srcUser,
time, appNameTmp, desc, use, effect, type, schema, encryptedDataKey, configInfo.getDataId(),
configInfo.getGroup(), tenantTmp);
} catch (CannotGetJdbcConnectionException e) {
Expand Down

0 comments on commit 414ad44

Please sign in to comment.