Authored by 胡古飞

fix

... ... @@ -30,7 +30,7 @@ public class ForbiddenPageIdsLogicService {
private static final String key = "SEARCH_FORBIDDEN_SKNLIST_%s";
private Map<String, List<String>> skn_forbiddenPageIds_map = null;
public List<String> getPageIdForbiddenSkns(String pageId) {
if (skn_forbiddenPageIds_map == null || skn_forbiddenPageIds_map.isEmpty()) {
return new ArrayList<String>();
... ... @@ -38,13 +38,10 @@ public class ForbiddenPageIdsLogicService {
return skn_forbiddenPageIds_map.get(pageId);
}
private volatile boolean isReloading = false;
public synchronized Map<String, Integer> reloadForbiddenPageIds() {
Map<String, Integer> pageCountMap = new HashMap<String, Integer>();
try {
INDEX_REBUILD_LOG.info("do reloadForbiddenPageIds .........");
isReloading = true;
List<String> allPageIds = SearchPageIdDefine.getAllPgeIds();
Map<String, List<String>> temp = new HashMap<String, List<String>>();
for (String pageId : allPageIds) {
... ... @@ -63,23 +60,9 @@ public class ForbiddenPageIdsLogicService {
} catch (Exception e) {
INDEX_REBUILD_LOG.error(e.getMessage(), e);
} finally {
isReloading = false;
}
return pageCountMap;
}
private synchronized void checkAndInit() {
if (skn_forbiddenPageIds_map == null || skn_forbiddenPageIds_map.isEmpty()) {
reloadForbiddenPageIds();
}
while (isReloading) {
try {
INDEX_REBUILD_LOG.info("is reloading ForbiddenPageIds ,wait 1000ms .........");
Thread.sleep(1000);
} catch (Exception e) {
INDEX_REBUILD_LOG.error(e.getMessage(), e);
}
}
return pageCountMap;
}
private Set<String> getPageForbiddenSknSet(String pageId) {
... ... @@ -94,6 +77,24 @@ public class ForbiddenPageIdsLogicService {
}
}
private boolean isNeedReload() {
if (skn_forbiddenPageIds_map == null || skn_forbiddenPageIds_map.isEmpty()) {
return true;
}
return false;
}
private void checkAndInit() {
if (!isNeedReload()) {
return;
}
synchronized (ForbiddenPageIdsLogicService.class) {
if (isNeedReload()) {
reloadForbiddenPageIds();
}
}
}
public String getSknForbiddenPageIds(ProductIBO productIBO) {
checkAndInit();
Integer productSkn = productIBO.getProductSkn();
... ...