Authored by 胡古飞

fix interface

... ... @@ -6,6 +6,7 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.search.consumer.service.logic.tools.ForbiddenPageIdsLogicService;
... ... @@ -18,9 +19,9 @@ public class ForbiddenPageIdsController {
@Autowired
private BigDataRedisOper<?,?> bigDataRedisOper;
@RequestMapping(value = "/forbiddenPageIds")
@RequestMapping(value = "/reloadForbiddenPageIds")
@ResponseBody
public Map<String, Object> forbiddenBrands() {
public Map<String, Object> reloadForbiddenPageIds() {
Map<String, Object> testResult = new HashMap<String, Object>();
try {
testResult.put("data", forbiddenPageIdsLogicService.reloadForbiddenPageIds());
... ... @@ -34,6 +35,22 @@ public class ForbiddenPageIdsController {
return testResult;
}
@RequestMapping(value = "/getPageIdForbiddenSkns")
@ResponseBody
public Map<String, Object> reloadForbiddenPageIds(@RequestParam(defaultValue="2") String pageId) {
Map<String, Object> testResult = new HashMap<String, Object>();
try {
testResult.put("data", forbiddenPageIdsLogicService.getPageIdForbiddenSkns(pageId));
testResult.put("code", 200);
testResult.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
testResult.put("code", 400);
testResult.put("message", e.getMessage());
}
return testResult;
}
@RequestMapping(value = "/testRecomListDataid")
@ResponseBody
... ...
... ... @@ -30,30 +30,56 @@ 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>();
}
return skn_forbiddenPageIds_map.get(pageId);
}
public synchronized Map<String, List<String>> reloadForbiddenPageIds() {
INDEX_REBUILD_LOG.info("do reloadForbiddenPageIds .........");
List<String> allPageIds = SearchPageIdDefine.getAllPgeIds();
Map<String, List<String>> temp = new HashMap<String, List<String>>();
for (String pageId : allPageIds) {
Set<String> forbiddenSknSet = this.getPageForbiddenSknSet(pageId);
for (String forbiddenSkn : forbiddenSknSet) {
List<String> pageIds = temp.get(forbiddenSkn);
if (pageIds == null) {
pageIds = new ArrayList<String>();
temp.put(forbiddenSkn, pageIds);
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) {
Set<String> forbiddenSknSet = this.getPageForbiddenSknSet(pageId);
for (String forbiddenSkn : forbiddenSknSet) {
List<String> pageIds = temp.get(forbiddenSkn);
if (pageIds == null) {
pageIds = new ArrayList<String>();
temp.put(forbiddenSkn, pageIds);
}
pageIds.add(pageId);
}
pageIds.add(pageId);
pageCountMap.put(pageId, forbiddenSknSet.size());
}
skn_forbiddenPageIds_map = temp;
} catch (Exception e) {
INDEX_REBUILD_LOG.error(e.getMessage(), e);
} finally {
isReloading = false;
}
skn_forbiddenPageIds_map = temp;
return skn_forbiddenPageIds_map;
return pageCountMap;
}
private synchronized void checkAndInit() {
if (skn_forbiddenPageIds_map == null) {
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);
}
}
}
private Set<String> getPageForbiddenSknSet(String pageId) {
... ...