Authored by 胡古飞

Merge branch 'master' into 5.6-global

# Conflicts:
#	service/src/main/java/com/yoho/search/consumer/service/logic/tools/ForbiddenPageIdsLogicService.java
... ... @@ -21,20 +21,20 @@ import com.yoho.search.core.personalized.BigDataRedisOper;
public class ForbiddenPageIdsLogicService {
private static final Logger logger = LoggerFactory.getLogger(ForbiddenPageIdsLogicService.class);
private final Logger INDEX_REBUILD_LOG = LoggerFactory.getLogger("INDEX_REBULDER");
@Autowired
private BigDataRedisOper<String, String> bigDataRedisOper;
private static final String key = "SEARCH_FORBIDDEN_SKNLIST_%s";
private Map<String, List<String>> sknForbiddenPageIdsMap = null;
private Map<String, Integer> pageForbiddenSknCountMap = null;
private volatile boolean isReloading = false;
public synchronized void reloadForbiddenPageIds() {
try {
INDEX_REBUILD_LOG.info("do reloadForbiddenPageIds .........");
isReloading = true;
List<String> allPageIds = SearchPageIdDefine.getAllPgeIds();
Map<String, List<String>> sknForbiddenPageIdsMap_temp = new HashMap<String, List<String>>();
Map<String, Integer> pageForbiddenSknCountMap_temp = new HashMap<String, Integer>();
... ... @@ -54,6 +54,8 @@ public class ForbiddenPageIdsLogicService {
pageForbiddenSknCountMap = pageForbiddenSknCountMap_temp;
} catch (Exception e) {
INDEX_REBUILD_LOG.error(e.getMessage(), e);
} finally {
isReloading = false;
}
}
... ... @@ -69,29 +71,30 @@ public class ForbiddenPageIdsLogicService {
}
}
private boolean isNeedReload() {
if (sknForbiddenPageIdsMap == null) {
return true;
public Map<String, Integer> getPageForbiddenSknCountMap() {
if (sknForbiddenPageIdsMap == null || sknForbiddenPageIdsMap.isEmpty()) {
reloadForbiddenPageIds();
}
return false;
return this.pageForbiddenSknCountMap;
}
private void checkAndInit() {
if (!isNeedReload()) {
while (isReloading) {
try {
Thread.sleep(1000);
} catch (Exception e) {
}
}
if (sknForbiddenPageIdsMap != null) {
return;
}
synchronized (ForbiddenPageIdsLogicService.class) {
if (isNeedReload()) {
if (sknForbiddenPageIdsMap == null) {
reloadForbiddenPageIds();
}
}
}
public Map<String, Integer> getPageForbiddenSknCountMap() {
checkAndInit();
return this.pageForbiddenSknCountMap;
}
public String getSknForbiddenPageIds(String productSkn) {
checkAndInit();
if (StringUtils.isBlank(productSkn)) {
... ...