Authored by Gino Zhang

删除废弃的类 修改日志

package com.yoho.search.consumer.suggests.common;
import org.apache.commons.lang3.StringUtils;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Created by ginozhang on 2016/11/25.
*/
public class RetryBusinessContext {
private int pageNo;
private int limit;
private Set<String> keywords = new HashSet<>();
private Map<String, Integer> countMap;
public RetryBusinessContext() {
}
public RetryBusinessContext(int pageNo, int limit) {
this.pageNo = pageNo;
this.limit = limit;
}
public void addKeyword(String keyword) {
if (StringUtils.isNotEmpty(keyword)) {
keywords.add(keyword.trim());
}
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public Set<String> getKeywords() {
return keywords;
}
public void setKeywords(Set<String> keywords) {
this.keywords = keywords;
}
public Map<String, Integer> getCountMap() {
return countMap;
}
public void setCountMap(Map<String, Integer> countMap) {
this.countMap = countMap;
}
}
package com.yoho.search.consumer.suggests.common;
import org.springframework.util.Assert;
/**
* Created by ginozhang on 2016/11/25.
*/
public class RetryBusinessContextHolder {
private static final ThreadLocal<RetryBusinessContext> threadLocal = new ThreadLocal<RetryBusinessContext>();
public static void init(RetryBusinessContext context) {
Assert.notNull(context);
threadLocal.set(context);
}
public static RetryBusinessContext get() {
return (RetryBusinessContext) threadLocal.get();
}
public static void destroy() {
threadLocal.set(null);
}
}
... ... @@ -46,22 +46,23 @@ public abstract class AbstractSuggestionCounter implements ApplicationEventPubli
@Override
public boolean doBusiness(int pageNo, int batchSize) {
Map<String, Object> keywordMap = getKeywordMap(pageNo, batchSize);
int size = keywordMap != null ? keywordMap.size() : 0;
logger.info("[{} business][pageNo={}][wordSize={}]", flowName(), pageNo, size);
logger.trace("[{} business][pageNo={}][keywordMap={}]", flowName(), pageNo, keywordMap);
if (size == 0) {
int fetchSize = keywordMap != null ? keywordMap.size() : 0;
if (fetchSize == 0) {
logger.info("[{} business][pageNo={}][fetchWordSize={}]", flowName(), pageNo, fetchSize);
return true;
}
Map<String, Integer> countMap = keywordCounterService.batchCount(keywordMap.keySet().stream().collect(Collectors.toList()));
size = countMap != null ? countMap.size() : 0;
logger.info("[{} business][pageNo={}][countMapSize={}]", flowName(), pageNo, size);
logger.trace("[{} business][pageNo={}][countMap={}]", flowName(), pageNo, countMap);
if (size == 0) {
int countMapSize = countMap != null ? countMap.size() : 0;
if (countMapSize == 0) {
logger.info("[{} business][pageNo={}][countMapSize={}]", flowName(), pageNo, countMapSize);
return false;
}
return persistence(keywordMap, filter(pageNo, countMap));
Map<String, Integer> filterMap = filter(pageNo, countMap);
logger.info("[{} business][pageNo={}][fetchWordSize={}][countMapSize={}][countMapSize={}]", flowName(), pageNo, fetchSize, countMapSize, filterMap.size());
logger.trace("[{} business][pageNo={}][keywordMap={}][countMap={}][filterMap={}]", flowName(), pageNo, keywordMap, countMap, filterMap);
return persistence(keywordMap, filterMap);
}
protected Map<String, Integer> filter(int pageNo, Map<String, Integer> countMap) {
... ... @@ -73,8 +74,6 @@ public abstract class AbstractSuggestionCounter implements ApplicationEventPubli
}
});
logger.info("[{} business][pageNo={}][filterMapSize={}]", flowName(), pageNo, countMap.size(), filterMap.size());
logger.trace("[{} business][pageNo={}][filterMap={}]", flowName(), pageNo, filterMap);
return filterMap;
}
... ...