Showing
5 changed files
with
51 additions
and
19 deletions
@@ -22,7 +22,7 @@ import com.yoho.search.base.monitor.PerformanceMonitor; | @@ -22,7 +22,7 @@ import com.yoho.search.base.monitor.PerformanceMonitor; | ||
22 | */ | 22 | */ |
23 | public class ControllerCostInterceptor implements HandlerInterceptor { | 23 | public class ControllerCostInterceptor implements HandlerInterceptor { |
24 | 24 | ||
25 | - private static final Logger CONTROLLER_COST = LoggerFactory.getLogger("CONTROLLER_COST"); | 25 | + static final Logger CONTROLLER_COST = LoggerFactory.getLogger("CONTROLLER_COST"); |
26 | 26 | ||
27 | private static final Logger CONTROLLER_PERFORMANCE = LoggerFactory.getLogger("CONTROLLER_PERFORMANCE"); | 27 | private static final Logger CONTROLLER_PERFORMANCE = LoggerFactory.getLogger("CONTROLLER_PERFORMANCE"); |
28 | 28 | ||
@@ -66,10 +66,8 @@ public class ControllerCostInterceptor implements HandlerInterceptor { | @@ -66,10 +66,8 @@ public class ControllerCostInterceptor implements HandlerInterceptor { | ||
66 | if (cost <= 500) { | 66 | if (cost <= 500) { |
67 | return; | 67 | return; |
68 | } | 68 | } |
69 | - | ||
70 | -// // 5、打印响应超过500ms的请求与参数 | ||
71 | -// CONTROLLER_COST.info("run more than 500ms ,cost [{}] ms, RequestURL: {}", cost, HttpServletRequestUtils.getRequestUrl(request)); | ||
72 | - | 69 | + // // 5、打印响应超过500ms的请求与参数 |
70 | + // CONTROLLER_COST.info("run more than 500ms ,cost [{}] ms, RequestURL: {}", cost, HttpServletRequestUtils.getRequestUrl(request)); | ||
73 | } catch (Exception e) { | 71 | } catch (Exception e) { |
74 | // TODO: handle exception | 72 | // TODO: handle exception |
75 | } finally { | 73 | } finally { |
@@ -250,4 +250,12 @@ public class SearchDynamicConfigService { | @@ -250,4 +250,12 @@ public class SearchDynamicConfigService { | ||
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | + /** | ||
254 | + * 使用性能高的召回场景 | ||
255 | + * | ||
256 | + * @return | ||
257 | + */ | ||
258 | + public boolean searchPersionalNewStrategyOpen() { | ||
259 | + return configReader.getBoolean("search.persional.newstrategy.open", false); | ||
260 | + } | ||
253 | } | 261 | } |
@@ -2,8 +2,6 @@ package com.yoho.search.service.scene; | @@ -2,8 +2,6 @@ package com.yoho.search.service.scene; | ||
2 | 2 | ||
3 | import java.util.Map; | 3 | import java.util.Map; |
4 | 4 | ||
5 | -import org.apache.commons.collections.MapUtils; | ||
6 | -import org.apache.commons.lang.StringUtils; | ||
7 | import org.slf4j.Logger; | 5 | import org.slf4j.Logger; |
8 | import org.slf4j.LoggerFactory; | 6 | import org.slf4j.LoggerFactory; |
9 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -12,7 +10,6 @@ import org.springframework.stereotype.Service; | @@ -12,7 +10,6 @@ import org.springframework.stereotype.Service; | ||
12 | import com.yoho.search.base.utils.SearchPageIdDefine; | 10 | import com.yoho.search.base.utils.SearchPageIdDefine; |
13 | import com.yoho.search.common.utils.SearchApiResultUtils; | 11 | import com.yoho.search.common.utils.SearchApiResultUtils; |
14 | import com.yoho.search.models.SearchApiResult; | 12 | import com.yoho.search.models.SearchApiResult; |
15 | -import com.yoho.search.service.recall.CommonSceneProductListService; | ||
16 | import com.yoho.search.service.scene.common.AbstractSceneService; | 13 | import com.yoho.search.service.scene.common.AbstractSceneService; |
17 | import com.yoho.search.service.scene.common.SceneProductListService; | 14 | import com.yoho.search.service.scene.common.SceneProductListService; |
18 | import com.yoho.search.service.scene.common.SceneSelectionsService; | 15 | import com.yoho.search.service.scene.common.SceneSelectionsService; |
@@ -26,8 +23,6 @@ public class CommonSceneService extends AbstractSceneService { | @@ -26,8 +23,6 @@ public class CommonSceneService extends AbstractSceneService { | ||
26 | private SceneProductListService sceneProductListService; | 23 | private SceneProductListService sceneProductListService; |
27 | @Autowired | 24 | @Autowired |
28 | private SceneSelectionsService sceneSelectionsService; | 25 | private SceneSelectionsService sceneSelectionsService; |
29 | - @Autowired | ||
30 | - private CommonSceneProductListService commonSceneProductListService; | ||
31 | 26 | ||
32 | @Override | 27 | @Override |
33 | public String pageId() { | 28 | public String pageId() { |
@@ -45,14 +40,7 @@ public class CommonSceneService extends AbstractSceneService { | @@ -45,14 +40,7 @@ public class CommonSceneService extends AbstractSceneService { | ||
45 | // 1、添加默认参数 | 40 | // 1、添加默认参数 |
46 | this.addParamsToParamMap(paramMap); | 41 | this.addParamsToParamMap(paramMap); |
47 | // 2、返回商品列表 | 42 | // 2、返回商品列表 |
48 | - int uid = MapUtils.getIntValue(paramMap, "uid", 0); | ||
49 | - String order = MapUtils.getString(paramMap, "order", ""); | ||
50 | - if (uid > 0 && StringUtils.isEmpty(order)) { | ||
51 | - return commonSceneProductListService.productListForPersional(paramMap); | ||
52 | - } else { | ||
53 | - return commonSceneProductListService.productListForDefault(paramMap); | ||
54 | - } | ||
55 | - // return sceneProductListService.productList(paramMap); | 43 | + return sceneProductListService.productList(paramMap); |
56 | } catch (Exception e) { | 44 | } catch (Exception e) { |
57 | logger.error("[func=CommonProductList][params=" + paramMap + "]", e); | 45 | logger.error("[func=CommonProductList][params=" + paramMap + "]", e); |
58 | return SearchApiResultUtils.errorSearchApiResult("CommonSceneService", paramMap, e); | 46 | return SearchApiResultUtils.errorSearchApiResult("CommonSceneService", paramMap, e); |
@@ -4,6 +4,7 @@ import java.util.ArrayList; | @@ -4,6 +4,7 @@ import java.util.ArrayList; | ||
4 | import java.util.List; | 4 | import java.util.List; |
5 | import java.util.Map; | 5 | import java.util.Map; |
6 | 6 | ||
7 | +import org.apache.commons.collections.MapUtils; | ||
7 | import org.apache.commons.lang.StringUtils; | 8 | import org.apache.commons.lang.StringUtils; |
8 | import org.slf4j.Logger; | 9 | import org.slf4j.Logger; |
9 | import org.slf4j.LoggerFactory; | 10 | import org.slf4j.LoggerFactory; |
@@ -19,9 +20,11 @@ import com.yoho.search.core.es.model.SearchResult; | @@ -19,9 +20,11 @@ import com.yoho.search.core.es.model.SearchResult; | ||
19 | import com.yoho.search.models.SearchApiResult; | 20 | import com.yoho.search.models.SearchApiResult; |
20 | import com.yoho.search.service.base.ProductListSortService; | 21 | import com.yoho.search.service.base.ProductListSortService; |
21 | import com.yoho.search.service.base.SearchCommonService; | 22 | import com.yoho.search.service.base.SearchCommonService; |
23 | +import com.yoho.search.service.base.SearchDynamicConfigService; | ||
22 | import com.yoho.search.service.base.index.ProductIndexBaseService; | 24 | import com.yoho.search.service.base.index.ProductIndexBaseService; |
23 | import com.yoho.search.service.helper.SearchParamHelper; | 25 | import com.yoho.search.service.helper.SearchParamHelper; |
24 | import com.yoho.search.service.helper.SearchSortHelper; | 26 | import com.yoho.search.service.helper.SearchSortHelper; |
27 | +import com.yoho.search.service.recall.CommonSceneProductListService; | ||
25 | 28 | ||
26 | @Service | 29 | @Service |
27 | public class SceneProductListService extends AbstractCacheAbleService { | 30 | public class SceneProductListService extends AbstractCacheAbleService { |
@@ -38,12 +41,46 @@ public class SceneProductListService extends AbstractCacheAbleService { | @@ -38,12 +41,46 @@ public class SceneProductListService extends AbstractCacheAbleService { | ||
38 | private SearchSortHelper searchSortHelper; | 41 | private SearchSortHelper searchSortHelper; |
39 | @Autowired | 42 | @Autowired |
40 | private ProductListSortService productListSortService; | 43 | private ProductListSortService productListSortService; |
44 | + @Autowired | ||
45 | + private SearchDynamicConfigService searchDynamicConfigService; | ||
46 | + @Autowired | ||
47 | + private CommonSceneProductListService commonSceneProductListService; | ||
41 | 48 | ||
42 | @Override | 49 | @Override |
43 | public SearchCache getSearchCache() { | 50 | public SearchCache getSearchCache() { |
44 | return searchCacheFactory.getSceneProductListSearchCache(); | 51 | return searchCacheFactory.getSceneProductListSearchCache(); |
45 | } | 52 | } |
46 | 53 | ||
54 | + private boolean isPersionalScene(Map<String, String> paramMap) { | ||
55 | + int uid = MapUtils.getIntValue(paramMap, "uid", 0); | ||
56 | + String order = MapUtils.getString(paramMap, "order", ""); | ||
57 | + if (uid > 0 && StringUtils.isEmpty(order)) { | ||
58 | + return true; | ||
59 | + } | ||
60 | + return false; | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * 场景化的商品列表接口 | ||
65 | + * | ||
66 | + * @param paramMap | ||
67 | + * @return | ||
68 | + */ | ||
69 | + public SearchApiResult productList(Map<String, String> paramMap) { | ||
70 | + // 1、新个性化方案是否打开 | ||
71 | + boolean searchPersionalNewStrategyOpen = searchDynamicConfigService.searchPersionalNewStrategyOpen(); | ||
72 | + if (!searchPersionalNewStrategyOpen) { | ||
73 | + return this.sceneProductListDefault(paramMap); | ||
74 | + } | ||
75 | + // 2、走新的个性化方案的场景 | ||
76 | + boolean isPersionalScene = this.isPersionalScene(paramMap); | ||
77 | + if (isPersionalScene) { | ||
78 | + return commonSceneProductListService.productListForPersional(paramMap); | ||
79 | + } else { | ||
80 | + return commonSceneProductListService.productListForDefault(paramMap); | ||
81 | + } | ||
82 | + } | ||
83 | + | ||
47 | /** | 84 | /** |
48 | * 获取商品列表 | 85 | * 获取商品列表 |
49 | * | 86 | * |
@@ -51,7 +88,7 @@ public class SceneProductListService extends AbstractCacheAbleService { | @@ -51,7 +88,7 @@ public class SceneProductListService extends AbstractCacheAbleService { | ||
51 | * @return | 88 | * @return |
52 | * @throws Exception | 89 | * @throws Exception |
53 | */ | 90 | */ |
54 | - public SearchApiResult productList(Map<String, String> paramMap) { | 91 | + private SearchApiResult sceneProductListDefault(Map<String, String> paramMap) { |
55 | try { | 92 | try { |
56 | // 1)构造搜索参数 | 93 | // 1)构造搜索参数 |
57 | SearchParam searchParam = this.buildProductListSearchParam(paramMap); | 94 | SearchParam searchParam = this.buildProductListSearchParam(paramMap); |
@@ -43,6 +43,7 @@ search.sortpage.recall.uid.mantissa=0,1,2,3,4,5,6,7,8,9 | @@ -43,6 +43,7 @@ search.sortpage.recall.uid.mantissa=0,1,2,3,4,5,6,7,8,9 | ||
43 | 43 | ||
44 | #rateLimit | 44 | #rateLimit |
45 | search.persional.rateLimit.open=true | 45 | search.persional.rateLimit.open=true |
46 | +search.persional.newstrategy.open=false | ||
46 | 47 | ||
47 | search.persional.rateLimit.brand.productList=200:2 | 48 | search.persional.rateLimit.brand.productList=200:2 |
48 | search.persional.rateLimit.brand.aggregations=100:2 | 49 | search.persional.rateLimit.brand.aggregations=100:2 |
-
Please register or login to post a comment