Skip to content

Commit

Permalink
[ISSUE#7780] Fix a-b-a problem (#7783)
Browse files Browse the repository at this point in the history
  • Loading branch information
nailcui authored Apr 27, 2022
1 parent 896bddd commit 92a0eb0
Showing 1 changed file with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ public static boolean dump(String dataId, String group, String tenant, String co

try {
final String md5 = MD5Utils.md5Hex(content, Constants.ENCODE);

if (lastModifiedTs < ConfigCacheService.getLastModifiedTs(groupKey)) {
DUMP_LOG.warn("[dump-ignore] the content is old. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}", groupKey, md5, ConfigCacheService.getLastModifiedTs(groupKey),
lastModifiedTs);
return true;
}
if (md5.equals(ConfigCacheService.getContentMd5(groupKey)) && DiskUtil.targetFile(dataId, group, tenant).exists()) {
DUMP_LOG.warn("[dump-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}", groupKey, md5, ConfigCacheService.getLastModifiedTs(groupKey),
Expand Down Expand Up @@ -158,6 +163,12 @@ public static boolean dumpBeta(String dataId, String group, String tenant, Strin

try {
final String md5 = MD5Utils.md5Hex(content, Constants.ENCODE);
if (lastModifiedTs < ConfigCacheService.getLastModifiedTs4Beta(groupKey)) {
DUMP_LOG.warn("[dump-beta-ignore] the content is old. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}", groupKey, md5,
ConfigCacheService.getLastModifiedTs4Beta(groupKey), lastModifiedTs);
return true;
}
if (md5.equals(ConfigCacheService.getContentBetaMd5(groupKey)) && DiskUtil.targetBetaFile(dataId, group, tenant).exists()) {
DUMP_LOG.warn("[dump-beta-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}", groupKey, md5, ConfigCacheService.getLastModifiedTs(groupKey),
Expand Down Expand Up @@ -203,6 +214,12 @@ public static boolean dumpTag(String dataId, String group, String tenant, String

try {
final String md5 = MD5Utils.md5Hex(content, Constants.ENCODE);
if (lastModifiedTs < ConfigCacheService.getTagLastModifiedTs(groupKey, tag)) {
DUMP_LOG.warn("[dump-tag-ignore] the tag is old. groupKey={}, md5={}, lastTagModifiedOld={}, "
+ "lastModifiedNew={}", groupKey, md5,
ConfigCacheService.getTagLastModifiedTs(groupKey, tag), lastModifiedTs);
return true;
}
if (md5.equals(ConfigCacheService.getContentTagMd5(groupKey, tag)) && DiskUtil.targetTagFile(dataId, group, tenant, tag).exists()) {
DUMP_LOG.warn("[dump-tag-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}", groupKey, md5, ConfigCacheService.getLastModifiedTs(groupKey),
Expand Down Expand Up @@ -246,6 +263,12 @@ public static boolean dumpChange(String dataId, String group, String tenant, Str

try {
final String md5 = MD5Utils.md5Hex(content, Constants.ENCODE);
if (lastModifiedTs < ConfigCacheService.getLastModifiedTs(groupKey)) {
DUMP_LOG.warn("[dump-ignore] the content is old. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}", groupKey, md5, ConfigCacheService.getLastModifiedTs(groupKey),
lastModifiedTs);
return true;
}
if (!PropertyUtil.isDirectRead()) {
String localMd5 = DiskUtil.getLocalConfigMd5(dataId, group, tenant);
if (md5.equals(localMd5)) {
Expand Down Expand Up @@ -614,6 +637,19 @@ public static long getLastModifiedTs(String groupKey) {
return (null != item) ? item.lastModifiedTs : 0L;
}

public static long getLastModifiedTs4Beta(String groupKey) {
CacheItem item = CACHE.get(groupKey);
return (null != item) ? item.lastModifiedTs4Beta : 0L;
}

public static long getTagLastModifiedTs(String groupKey, String tag) {
CacheItem item = CACHE.get(groupKey);
if (item == null || item.getTagLastModifiedTs() == null) {
return 0L;
}
return item.getTagLastModifiedTs().getOrDefault(tag, 0L);
}

public static boolean isUptodate(String groupKey, String md5) {
String serverMd5 = ConfigCacheService.getContentMd5(groupKey);
return StringUtils.equals(md5, serverMd5);
Expand Down

0 comments on commit 92a0eb0

Please sign in to comment.