Authored by wangnan

Merge branch 'wn_promotion' into gray

Showing 60 changed files with 556 additions and 306 deletions
package com.yoho.search.dal;
import com.yoho.search.dal.model.PromotionProductFlags;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface PromotionProductFlagsMapper {
int deleteByPrimaryKey(Integer id);
int insert(PromotionProductFlags record);
int insertSelective(PromotionProductFlags record);
PromotionProductFlags selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(PromotionProductFlags record);
int updateByPrimaryKey(PromotionProductFlags record);
int selectCount();
List<PromotionProductFlags> selectPageLists(@Param(value="offset")Integer offset, @Param(value="pageSize")Integer pageSize);
}
\ No newline at end of file
... ...
package com.yoho.search.dal.model;
/**
* Created by wangnan on 2017/5/10.
*/
public class PromotionBO {
private Integer id;
private String title;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.search.dal.PromotionProductFlagsMapper">
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.PromotionProductFlags">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="title" property="title" jdbcType="VARCHAR"/>
<result column="flag_value" property="flagValue" jdbcType="INTEGER"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, title, flag_value, remark
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List"/>
from promotion_product_flags
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from promotion_product_flags
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.search.dal.model.PromotionProductFlags">
insert into promotion_product_flags (id, title, flag_value,
remark)
values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{flagValue,jdbcType=INTEGER},
#{remark,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.PromotionProductFlags">
insert into promotion_product_flags
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="title != null">
title,
</if>
<if test="flagValue != null">
flag_value,
</if>
<if test="remark != null">
remark,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="flagValue != null">
#{flagValue,jdbcType=INTEGER},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.PromotionProductFlags">
update promotion_product_flags
<set>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="flagValue != null">
flag_value = #{flagValue,jdbcType=INTEGER},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.PromotionProductFlags">
update promotion_product_flags
set title = #{title,jdbcType=VARCHAR},
flag_value = #{flagValue,jdbcType=INTEGER},
remark = #{remark,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCount" resultType="java.lang.Integer" timeout="20000">
SELECT count(id) FROM promotion_product_flags
</select>
<select id="selectPageLists" resultMap="BaseResultMap" timeout="20000">
select
<include refid="Base_Column_List" />
from promotion_product_flags limit #{offset},#{pageSize}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -4,6 +4,7 @@ import com.yoho.search.consumer.index.common.IIndexBuilder;
import com.yoho.search.consumer.service.base.BrandService;
import com.yoho.search.consumer.service.bo.BrandBO;
import com.yoho.search.dal.model.Brand;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -34,6 +35,9 @@ public class BrandIndexBuilder extends IIndexBuilder {
private List<BrandBO> getBrandBOs(int start, int limit) {
List<Brand> brandList = brandService.getBrandPageLists(start, limit);
if(CollectionUtils.isEmpty(brandList)){
return new ArrayList<>();
}
List<BrandBO> brandBOList = new ArrayList<>();
for (Brand brand : brandList) {
BrandBO brandBO = new BrandBO();
... ...
package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.consumer.index.common.IIndexBuilder;
import com.yoho.search.dal.PromotionProductFlagsMapper;
import com.yoho.search.dal.model.PromotionBO;
import com.yoho.search.dal.model.PromotionProductFlags;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* Created by wangnan on 2017/5/10.
*/
@Component
public class PromotionIndexBuilder extends IIndexBuilder {
@Autowired
private PromotionProductFlagsMapper promotionProductFlagsMapper;
@Override
public int getTotalCount() throws Exception {
return promotionProductFlagsMapper.selectCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
return this.getPromotionBOs(offset, limit);
}
@Override
public String getId(Object object) {
return ((PromotionBO) object).getId().toString();
}
public List<PromotionBO> getPromotionBOs(Integer id) {
List<PromotionProductFlags> promotionProductFlagsList = new ArrayList<>();
PromotionProductFlags promotionProductFlags = promotionProductFlagsMapper.selectByPrimaryKey(id);
promotionProductFlagsList.add(promotionProductFlags);
return this.buildPromotionBOs(promotionProductFlagsList);
}
public List<PromotionBO> getPromotionBOs(int start, int limit) {
List<PromotionProductFlags> promotionProductFlagsList = promotionProductFlagsMapper.selectPageLists(start, limit);
return this.buildPromotionBOs(promotionProductFlagsList);
}
private List<PromotionBO> buildPromotionBOs(List<PromotionProductFlags> promotionProductFlagsList) {
if (CollectionUtils.isEmpty(promotionProductFlagsList)) {
return new ArrayList<>();
}
List<PromotionBO> promotionBOS = new ArrayList<>();
for (PromotionProductFlags promotionProductFlag : promotionProductFlagsList) {
PromotionBO promotionBO = new PromotionBO();
promotionBO.setId(promotionProductFlag.getFlagValue());
promotionBO.setTitle(promotionProductFlag.getTitle());
promotionBOS.add(promotionBO);
}
return promotionBOS;
}
}
... ...
... ... @@ -14,7 +14,7 @@ import java.util.Map;
*/
@Component
public class GeneralBuilder {
public final static Map<Integer, String> countryFieldMap = new HashMap<Integer, String>() {
protected final static Map<Integer, String> countryFieldMap = new HashMap<Integer, String>() {
{
put(374, "美国");
put(44, "英国");
... ...
... ... @@ -24,7 +24,7 @@ public class GoodsBuilder {
@Autowired
private TblImgUrlLogicService tblImgUrlLogicService;
public final static Map<Integer, String> colorFieldMap = new HashMap<Integer, String>() {
protected final static Map<Integer, String> colorFieldMap = new HashMap<Integer, String>() {
{
put(1, "白色");
put(2, "黑色");
... ...
... ... @@ -45,7 +45,7 @@ public class SizeBuilder {
if (size.getSortId() == 0) {
defaultId = size.getId();
}
if (size.getSortId() == smallSortId) {
if (size.getSortId().equals(smallSortId)) {
sizeIds.append(size.getId() + ",");
needDefaultId = false;
break;
... ...
... ... @@ -45,9 +45,11 @@ public abstract class AbstractMqListener implements ApplicationEventPublisherAwa
public abstract String getIndexName();
public void init() {}
public void init() {
}
public void finish() {}
public void finish() {
}
public void process(AbstractMqListener abstractMqListener, Message message) {
abstractMqListener.init();
... ... @@ -98,18 +100,29 @@ public abstract class AbstractMqListener implements ApplicationEventPublisherAwa
try {
rebuildFlagService.waitingRebuildingIndex();
long nowTimeMillis = System.currentTimeMillis();
if(publisher!=null){
if (publisher != null) {
publisher.publishEvent(new SearchLogsEvent("MqListener", EventReportEnum.ABSTRACTMQLISTENER_WAITINGREBUILDINGINDEX.getMoudleName(), "monitor", nowTimeMillis + ""));
// 记录上报的日志
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,ModuleName is [{}]", nowTimeMillis, "MqListener", "consumer");
}
} catch (Exception e) {
if(publisher!=null){
publisher.publishEvent(new SearchEvent(EventReportEnum.ABSTRACTMQLISTENER_WAITINGREBUILDINGINDEX.getEventName(),
EventReportEnum.ABSTRACTMQLISTENER_WAITINGREBUILDINGINDEX.getFunctionName(), EventReportEnum.ABSTRACTMQLISTENER_WAITINGREBUILDINGINDEX.getMoudleName(),
"exception", IgnoreSomeException.filterSomeException(e), null));
if (publisher != null) {
publisher.publishEvent(buildSearchEvent(EventReportEnum.ABSTRACTMQLISTENER_WAITINGREBUILDINGINDEX, e));
}
logger.error(e.getMessage(), e);
}
}
protected SearchEvent buildSearchEvent(EventReportEnum eventReportEnum, Exception e) {
return new SearchEvent(eventReportEnum.getEventName(),
eventReportEnum.getFunctionName(),
eventReportEnum.getMoudleName(),
"exception",
IgnoreSomeException.filterSomeException(e),
null);
}
protected SearchLogsEvent buildSearchLogsEvent(EventReportEnum eventReportEnum, long nowTimeMillis) {
return new SearchLogsEvent("MqListener", eventReportEnum.getMoudleName(), "monitor", nowTimeMillis + "");
}
}
... ...
package com.yoho.search.consumer.index.increment.db;
package com.yoho.search.consumer.index.increment.database;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.dynwords.EsWordDefService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.EsWordDef;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -31,13 +29,16 @@ public class EsWordDefMqListener extends AbstractMqListener implements ChannelAw
private EsWordDefService esWordDefService;
@Override
public String getIndexName() {
return null;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.ESWORDDEF_MQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.ESWORDDEF_MQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.ESWORDDEF_MQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.ESWORDDEF_MQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -67,9 +68,4 @@ public class EsWordDefMqListener extends AbstractMqListener implements ChannelAw
esWordDefService.delete(Integer.valueOf(id));
logger.info("[func=deleteData][key={}][id={}][cost={}ms]", key, id, (System.currentTimeMillis() - begin));
}
@Override
public String getIndexName() {
return null;
}
}
... ...
package com.yoho.search.consumer.index.increment.db;
package com.yoho.search.consumer.index.increment.database;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ParameterMakeService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ParameterMake;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -33,13 +30,10 @@ public class ParameterMakeMqListener extends AbstractMqListener implements Chann
try {
process(this, message);
long nowTimeMillis=System.currentTimeMillis();
publisher.publishEvent(new SearchLogsEvent("MqListener", EventReportEnum.PARAMETERMAKEMQLISTENER_ONMESSAGE.getMoudleName(), "monitor",nowTimeMillis+""));
// 记录上报的日志
publisher.publishEvent(buildSearchLogsEvent(EventReportEnum.PARAMETERMAKEMQLISTENER_ONMESSAGE,nowTimeMillis));
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,MoudleName is [{}]",nowTimeMillis, "MqListener", "consumer");
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PARAMETERMAKEMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.PARAMETERMAKEMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PARAMETERMAKEMQLISTENER_ONMESSAGE.getMoudleName(),"exception", IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PARAMETERMAKEMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.db;
package com.yoho.search.consumer.index.increment.database;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.index.increment.productIndex.ProductAttributePropertyValuesMqListener;
import com.yoho.search.consumer.service.base.ProductAttributeService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductAttribute;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -32,8 +30,7 @@ public class ProductAttributeMqListener extends AbstractMqListener implements Ch
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTATTRIBUTEMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTATTRIBUTEMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTATTRIBUTEMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTATTRIBUTEMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.db;
package com.yoho.search.consumer.index.increment.database;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.PromotionInfoService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.PromotionInfo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -31,8 +29,7 @@ public class PromotionInfoMqListener extends AbstractMqListener implements Chann
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PROMOTIONINFOMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PROMOTIONINFOMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PROMOTIONINFOMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PROMOTIONINFOMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.db;
package com.yoho.search.consumer.index.increment.database;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.PromotionParamsService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.PromotionParams;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -31,8 +29,7 @@ public class PromotionParamsMqListener extends AbstractMqListener implements Cha
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PROMOTIONPARAMSDMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PROMOTIONPARAMSDMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PROMOTIONPARAMSDMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PROMOTIONPARAMSDMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.db;
package com.yoho.search.consumer.index.increment.database;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.index.increment.otherIndex.RobotQuestionMqListener;
import com.yoho.search.consumer.service.logic.SalesCategoryLogicService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.SalesCategory;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -22,17 +17,20 @@ import java.util.Map;
@Component
public class SalesCategoryMqListener extends AbstractMqListener implements ChannelAwareMessageListener {
private static final Logger logger = LoggerFactory.getLogger(RobotQuestionMqListener.class);
@Autowired
private SalesCategoryLogicService salesCategoryLogicService;
@Override
public String getIndexName() {
return null;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE
.getFunctionName(), EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.SALESCATEGORYMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -57,10 +55,4 @@ public class SalesCategoryMqListener extends AbstractMqListener implements Chann
salesCategoryLogicService.deleteById(Integer.valueOf(id));
salesCategoryLogicService.doReload();
}
@Override
public String getIndexName() {
return null;
}
}
... ...
package com.yoho.search.consumer.index.increment.db;
package com.yoho.search.consumer.index.increment.database;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ScoreRuleService;
import com.yoho.search.consumer.service.logic.ScoreRuleLogicService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ScoreRule;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -34,12 +32,16 @@ public class ScoreRuleMqListener extends AbstractMqListener implements ChannelAw
private ScoreRuleLogicService scoreRuleLogicService;
@Override
public String getIndexName() {
return null;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.SCORERULEMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.SCORERULEMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.SCORERULEMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.SCORERULEMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -75,10 +77,5 @@ public class ScoreRuleMqListener extends AbstractMqListener implements ChannelAw
logger.info("[func=deleteData][id={}][cost={}ms]", id, System.currentTimeMillis() - begin);
}
}
@Override
public String getIndexName() {
return null;
}
}
... ...
package com.yoho.search.consumer.index.increment.db;
package com.yoho.search.consumer.index.increment.database;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ShopsBrandsService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ShopsBrands;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -24,13 +22,15 @@ import java.util.Map;
*/
@Component
public class ShopsBrandsMqListener extends AbstractMqListener implements ChannelAwareMessageListener {
private static final Logger logger = LoggerFactory.getLogger(ShopsBrandsMqListener.class);
@Autowired
private ShopsBrandsService shopsBrandsService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_SHOPS;
return null;
}
@Override
... ... @@ -42,9 +42,7 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.SHOPSBRADNSMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.SHOPSBRADNSMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.SHOPSBRADNSMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.SHOPSBRADNSMQLISTENER_ONMESSAGE, e));
Thread.sleep(1000);
throw e;
}
... ... @@ -72,5 +70,4 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel
shopsBrandsService.delete(Integer.valueOf(id));
logger.info("[func=deleteData][step=deleteFromDb][indexName={}] [id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin));
}
}
... ...
package com.yoho.search.consumer.index.increment.db;
package com.yoho.search.consumer.index.increment.database;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.StandardService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Standard;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -15,38 +12,33 @@ import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class StandardMqListener extends AbstractMqListener implements ChannelAwareMessageListener, ApplicationEventPublisherAware {
public class StandardMqListener extends AbstractMqListener implements ChannelAwareMessageListener{
private static final Logger logger = LoggerFactory.getLogger(StandardMqListener.class);
private static final Logger SEARCH_EVENT_LOG = LoggerFactory.getLogger("SEARCH_EVENT_LOG");
@Autowired
private StandardService standardService;
protected ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
public String getIndexName() {
return null;
}
@Autowired
private StandardService standardService;
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
long nowTimeMillis = System.currentTimeMillis();
publisher.publishEvent(new SearchLogsEvent("MqListener", EventReportEnum.STANDARDMQLISTENER_ONMESSAGE.getMoudleName(), "monitor", nowTimeMillis + ""));
publisher.publishEvent(buildSearchLogsEvent(EventReportEnum.STANDARDMQLISTENER_ONMESSAGE, nowTimeMillis));
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,MoudleName is [{}]", nowTimeMillis, "MqListener", "consumer");
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.STANDARDMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.STANDARDMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.STANDARDMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.STANDARDMQLISTENER_ONMESSAGE, e));
Thread.sleep(1000);
throw e;
}
... ... @@ -74,8 +66,5 @@ public class StandardMqListener extends AbstractMqListener implements ChannelAwa
logger.info("[func=deleteData][id={}][cost={}ms]", id, (System.currentTimeMillis() - begin));
}
@Override
public String getIndexName() {
return null;
}
}
... ...
... ... @@ -2,7 +2,6 @@ package com.yoho.search.consumer.index.increment.otherIndex;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -11,7 +10,6 @@ import com.yoho.search.consumer.index.fullbuild.ProductIndexIndexBuilder;
import com.yoho.search.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.BrandService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Brand;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -27,6 +25,7 @@ import java.util.Map;
public class BrandMqListener extends AbstractMqListener implements ChannelAwareMessageListener {
private static final Logger logger = LoggerFactory.getLogger(BrandMqListener.class);
@Autowired
private BrandService brandService;
@Autowired
... ... @@ -56,8 +55,7 @@ public class BrandMqListener extends AbstractMqListener implements ChannelAwareM
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.BRANDMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.BRANDMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.BRANDMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.BRANDMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}finally {
... ...
... ... @@ -2,7 +2,6 @@ package com.yoho.search.consumer.index.increment.otherIndex;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -10,7 +9,6 @@ import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.HelperService;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Helper;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -49,9 +47,7 @@ public class HelperMqListener extends AbstractMqListener implements ChannelAware
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.HELPERMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.HELPERMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.HELPERMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.HELPERMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -9,7 +8,6 @@ import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductColorService;
import com.yoho.search.consumer.service.logic.productIndex.ProductGoodsLogicService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductColor;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -47,9 +45,7 @@ public class ProductColorMqListener extends AbstractMqListener implements Channe
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTCOLORMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.PRODUCTCOLORMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTCOLORMQLISTENER_ONMESSAGE.getMoudleName(),"exception", IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTCOLORMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}finally {
... ...
... ... @@ -2,7 +2,6 @@ package com.yoho.search.consumer.index.increment.otherIndex;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -10,7 +9,6 @@ import com.yoho.search.base.utils.PriceUtil;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductPricePlanService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductPricePlan;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -47,9 +45,7 @@ public class ProductPricePlanMqListener extends AbstractMqListener implements Ch
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTPRICEPLANMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.PRODUCTPRICEPLANMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTPRICEPLANMQLISTENER_ONMESSAGE.getMoudleName(),"exception",IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTPRICEPLANMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -10,7 +9,6 @@ import com.yoho.search.consumer.index.fullbuild.ProductIndexIndexBuilder;
import com.yoho.search.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductSortService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductSort;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -35,7 +33,6 @@ public class ProductSortMqListener extends AbstractMqListener implements Channel
@Autowired
private TblProductNewIndexBuilder tblProductNewIndexBuilder;
@Override
public void finish() {
productIndexIndexBuilder.init();
... ... @@ -51,9 +48,7 @@ public class ProductSortMqListener extends AbstractMqListener implements Channel
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTSORTMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.PRODUCTSORTMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTSORTMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTSORTMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}finally {
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.PromotionIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.PromotionProductFlagsService;
import com.yoho.search.dal.model.PromotionBO;
import com.yoho.search.dal.model.PromotionProductFlags;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* Created by wangnan on 2017/5/11.
*/
@Component
public class PromotionProductFlagsMqListener extends AbstractMqListener implements ChannelAwareMessageListener {
private static final Logger logger = LoggerFactory.getLogger(PromotionProductFlagsMqListener.class);
@Autowired
private PromotionProductFlagsService promotionProductFlagsService;
@Autowired
private IYohoIndexService indexService;
@Autowired
private PromotionIndexBuilder promotionIndexBuilder;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PROMOTION;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(buildSearchEvent(EventReportEnum.PROMOTIONPRODUCTFLAGSMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
}
@Override
public void updateData(Map data, String indexName, String key) throws Exception {
long begin = System.currentTimeMillis();
PromotionProductFlags promotionProductFlags = new PromotionProductFlags();
promotionProductFlags = (PromotionProductFlags) ConvertUtils.toJavaBean(promotionProductFlags, data);
if (promotionProductFlags == null || promotionProductFlags.getId() == null) {
return;
}
promotionProductFlagsService.saveOrUpdate(promotionProductFlags);
this.updateIndex(promotionProductFlags.getId(), indexName);
logger.info("[func=updateData][id={}][cost={}ms]", promotionProductFlags.getId(), (System.currentTimeMillis() - begin));
}
@Override
public void deleteData(String id, String indexName, String key) throws Exception {
if (StringUtils.isBlank(id)) {
return;
}
long begin = System.currentTimeMillis();
PromotionProductFlags promotionProductFlags = promotionProductFlagsService.getById(Integer.valueOf(id));
if(promotionProductFlags!=null){
String indexId = promotionProductFlags.getFlagValue().toString();
indexService.deleteIndexData(indexName, indexId);
logger.info("[func=deleteData][step=delete Index data][id={}][cost={}ms]", id, System.currentTimeMillis() - begin);
}
promotionProductFlagsService.delete(Integer.valueOf(id));
logger.info("[func=deleteData][step=delete DB data][id={}][cost={}ms]", id, System.currentTimeMillis() - begin);
}
private void updateIndex(Integer id, String indexName) throws Exception {
long begin = System.currentTimeMillis();
List<PromotionBO> promotionBOList = promotionIndexBuilder.getPromotionBOs(id);
if (CollectionUtils.isNotEmpty(promotionBOList)) {
PromotionBO promotionBO = promotionBOList.get(0);
String idValue = String.valueOf(promotionBO.getId());
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(promotionBO);
indexService.updateIndexData(indexName, idValue, jsonObject);
logger.info("[func=updateIndex][id={}][cost={}ms]", id, System.currentTimeMillis() - begin);
}
}
}
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.RobotQuestionService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.RobotQuestion;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -46,9 +44,7 @@ public class RobotQuestionMqListener extends AbstractMqListener implements Chann
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE.getMoudleName(),"exception", IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
... ... @@ -2,7 +2,6 @@ package com.yoho.search.consumer.index.increment.otherIndex;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -11,7 +10,6 @@ import com.yoho.search.consumer.index.fullbuild.ProductIndexIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ShopService;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Shops;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -59,9 +57,7 @@ public class ShopsMqListener extends AbstractMqListener implements ChannelAwareM
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.SHOPSMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.SHOPSMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.SHOPSMQLISTENER_ONMESSAGE.getMoudleName(),"exception", IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.SHOPSMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -9,7 +8,6 @@ import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.SizeService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Size;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -51,9 +49,7 @@ public class SizeMqListener extends AbstractMqListener implements ChannelAwareMe
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.SIZEMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.SIZEMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.SIZEMQLISTENER_ONMESSAGE.getMoudleName(),"exception", IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.SIZEMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}finally {
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.StyleService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Style;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -43,9 +41,7 @@ public class StyleMqListener extends AbstractMqListener implements ChannelAwareM
}
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.STYLEMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.STYLEMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.STYLEMQLISTENER_ONMESSAGE.getMoudleName(),"exception", IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.STYLEMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -11,7 +10,6 @@ import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.SuggestConversionCustomService;
import com.yoho.search.consumer.service.base.SuggestConversionService;
import com.yoho.search.consumer.suggests.common.SuggestionConstants;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.SuggestConversion;
import com.yoho.search.dal.model.SuggestConversionCustom;
import org.apache.commons.lang3.StringUtils;
... ... @@ -40,12 +38,16 @@ public class SuggestConversionCustomMqListener extends AbstractMqListener implem
private IYohoIndexService indexService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_CONVERSION;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.SUGGESTCONVERSIONCUSTOMMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.SUGGESTCONVERSIONCUSTOMMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.SUGGESTCONVERSIONCUSTOMMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.SUGGESTCONVERSIONCUSTOMMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -100,8 +102,5 @@ public class SuggestConversionCustomMqListener extends AbstractMqListener implem
}
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_CONVERSION;
}
}
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.*;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
... ... @@ -10,7 +9,6 @@ import com.yoho.search.consumer.service.base.SuggestWordDefService;
import com.yoho.search.consumer.suggests.common.KeywordType;
import com.yoho.search.consumer.suggests.common.SuggestionConstants;
import com.yoho.search.consumer.suggests.counter.KeywordCounterService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.SuggestWordCustom;
import com.yoho.search.dal.model.SuggestWordDef;
import org.apache.commons.lang3.StringUtils;
... ... @@ -45,12 +43,16 @@ public class SuggestWordCustomMqListener extends AbstractMqListener implements C
private IYohoIndexService indexService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_SUGGEST;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.SUGGESTWORDCUSTOMMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.SUGGESTWORDCUSTOMMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.SUGGESTWORDCUSTOMMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.SUGGESTWORDCUSTOMMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -128,9 +130,6 @@ public class SuggestWordCustomMqListener extends AbstractMqListener implements C
}
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_SUGGEST;
}
}
... ...
... ... @@ -3,14 +3,13 @@ package com.yoho.search.consumer.index.increment.productIndex;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ActivityProductService;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ActivityProduct;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
... ... @@ -45,8 +44,7 @@ public class ActivityProductMqListener extends AbstractMqListener implements Cha
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.ACTIVITYPRODUCTMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.ACTIVITYPRODUCTMQLISTENER_ONMESSAGE
.getFunctionName(), EventReportEnum.ACTIVITYPRODUCTMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.ACTIVITYPRODUCTMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -91,15 +89,15 @@ public class ActivityProductMqListener extends AbstractMqListener implements Cha
List<ActivityProduct> activityProducts = activityProductService.getBySkn(productSkn);
JSONArray jsonArray = new JSONArray();
Map<String, Object> indexData = new HashMap<>();
indexData.put("productId", productId);
indexData.put(ProductIndexEsField.productId, productId);
if (CollectionUtils.isEmpty(activityProducts)) {
jsonArray.add(new JSONObject());
indexData.put("activities", jsonArray);
}else{
indexData.put(ProductIndexEsField.activities, jsonArray);
} else {
for (ActivityProduct activityProduct : activityProducts) {
jsonArray.add(activityProductService.getActivities(activityProduct));
}
indexData.put("activities", jsonArray);
indexData.put(ProductIndexEsField.activities, jsonArray);
}
this.updateProductIndexWithDataMap(indexData, Integer.valueOf(productId), key, begin);
logger.info(" [func=updateProductIndex][key={}][productId={}][cost={}ms]", key, productId,
... ...
... ... @@ -2,7 +2,6 @@ package com.yoho.search.consumer.index.increment.productIndex;
import com.alibaba.fastjson.JSONArray;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -11,7 +10,6 @@ import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.GoodsImagesService;
import com.yoho.search.consumer.service.base.GoodsService;
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.GoodsImages;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -45,8 +43,7 @@ public class GoodsImagesMqListener extends AbstractMqListener implements Channel
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.GOODSIMAGESMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.GOODSIMAGESMQLISTENER_ONMESSAGE
.getFunctionName(), EventReportEnum.GOODSIMAGESMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.GOODSIMAGESMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.productIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.common.CostStatistics;
import com.yoho.search.consumer.service.base.GoodsService;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Goods;
import com.yoho.search.dal.model.Product;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -43,8 +41,7 @@ public class GoodsMqListener extends AbstractStorageRelatedMqListener implements
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.GOODSMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.GOODSMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.GOODSMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.GOODSMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.productIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
... ... @@ -10,7 +9,6 @@ import com.yoho.search.consumer.common.CostStatistics;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductActivitiesLinkService;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductActivitiesLink;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -49,9 +47,7 @@ public class ProductActivitiesLinkMqListener extends AbstractMqListener implemen
// 记录上报的日志
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,MoudleName is [{}]", nowTimeMillis, "MqListener", "consumer");
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTACTIVITIESLINKMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.PRODUCTACTIVITIESLINKMQLISTENER_ONMESSAGE.getFunctionName(), EventReportEnum.PRODUCTACTIVITIESLINKMQLISTENER_ONMESSAGE.getMoudleName(),
"exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTACTIVITIESLINKMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.productIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -9,7 +8,6 @@ import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductAttributeService;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Product;
import com.yoho.search.dal.model.ProductAttributePropertyValues;
import org.apache.commons.lang3.StringUtils;
... ... @@ -41,9 +39,7 @@ public class ProductAttributePropertyValuesMqListener extends AbstractMqListener
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTATTRIBUTEPROPERTYVALUESMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTATTRIBUTEPROPERTYVALUESMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTATTRIBUTEPROPERTYVALUESMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
Thread.sleep(1000);
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTATTRIBUTEPROPERTYVALUESMQLISTENER_ONMESSAGE,e));
throw e;
}
}
... ...
package com.yoho.search.consumer.index.increment.productIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -9,7 +8,6 @@ import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductExtService;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Product;
import com.yoho.search.dal.model.ProductExtWithBLOBs;
import org.apache.commons.lang3.StringUtils;
... ... @@ -35,13 +33,17 @@ public class ProductExtMqListener extends AbstractMqListener implements ChannelA
@Autowired
private IYohoIndexService indexService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTEXTMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTEXTMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTEXTMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTEXTMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -91,8 +93,5 @@ public class ProductExtMqListener extends AbstractMqListener implements ChannelA
logger.info("[func=deleteData][indexName={}][skn={}][cost={}ms]", indexName, skn, (System.currentTimeMillis() - begin));
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
}
... ...
... ... @@ -2,7 +2,6 @@ package com.yoho.search.consumer.index.increment.productIndex;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
... ... @@ -10,7 +9,6 @@ import com.yoho.search.consumer.index.fullbuild.ProductIndexIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductIndexService;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -68,8 +66,7 @@ public class ProductIndexMqListener extends AbstractMqListener implements Channe
try {
indexService.updateIndexData(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, id, data);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTINDEXMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTINDEXMQLISTENER_ONMESSAGE
.getFunctionName(), EventReportEnum.PRODUCTINDEXMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTINDEXMQLISTENER_ONMESSAGE,e));
logger.error("[func=onMessage][step=error][indexName={}][id={}][cost={}ms][error={}]", ISearchConstants.INDEX_NAME_PRODUCT_INDEX, id,
(System.currentTimeMillis() - begin), e.getMessage());
this.sendProductIndexMessage(Integer.parseInt(id), key);
... ... @@ -107,9 +104,7 @@ public class ProductIndexMqListener extends AbstractMqListener implements Channe
amqpTemplate.convertAndSend(channel, json);
} catch (AmqpException e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.ABSTRACTMQLISTENER_SENDPRODUCTINDEXMESSAGE.getEventName(),
EventReportEnum.ABSTRACTMQLISTENER_SENDPRODUCTINDEXMESSAGE.getFunctionName(), EventReportEnum.ABSTRACTMQLISTENER_SENDPRODUCTINDEXMESSAGE.getMoudleName(),
"exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.ABSTRACTMQLISTENER_SENDPRODUCTINDEXMESSAGE,e));
logger.error(e.getMessage(), e);
}
logger.info("[func=sendMessage][step=success][key={}][id={}][cost={}ms]", key, productId, System.currentTimeMillis() - begin);
... ...
package com.yoho.search.consumer.index.increment.productIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductKeywordsService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductKeywords;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -38,9 +36,7 @@ public class ProductKeywordsMqListener extends AbstractMqListener implements Cha
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTKEYWORDSMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.PRODUCTKEYWORDSMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTKEYWORDSMQLISTENER_ONMESSAGE.getMoudleName(),"exception", IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTKEYWORDSMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
... ... @@ -3,7 +3,6 @@ package com.yoho.search.consumer.index.increment.productIndex;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -17,7 +16,6 @@ import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.consumer.service.bo.ProductIBO;
import com.yoho.search.consumer.service.logic.productIndex.viewBuilder.ProductPriceBuilder;
import com.yoho.search.consumer.service.logic.tools.SpecialDealLogicService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Product;
import com.yoho.search.dal.model.ProductPrice;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -77,14 +75,12 @@ public class ProductMqListener extends AbstractMqListener implements ChannelAwar
retryCount++;
logger.warn("process data occur exception and retry. json: {}", json);
if (retryCount > MAX_RETRY_TIMES) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTMQLISTENER_ONMESSAGE
.getFunctionName(), EventReportEnum.PRODUCTMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTMQLISTENER_ONMESSAGE,e));
}
}
}
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
}
}
... ... @@ -155,8 +151,7 @@ public class ProductMqListener extends AbstractMqListener implements ChannelAwar
this.updateProductIndexWithJsonString(jsonObject.toJSONString(), productId, key, System.currentTimeMillis());
logger.info("[step4=updateToEs success][key={}][productId={}][cost={}ms]", key, productId, costStatistics.getCost());
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTMQLISTENER_UPDATEDATA.getEventName(), EventReportEnum.PRODUCTMQLISTENER_UPDATEDATA.getFunctionName(),
EventReportEnum.PRODUCTMQLISTENER_UPDATEDATA.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTMQLISTENER_UPDATEDATA,e));
logger.error("[step4=updateToEs error][key={}][productId={}][cost={}ms][execption={}]", key, productId, costStatistics.getCost(), e.getMessage());
productIndexMqListener.sendProductIndexMessage(productId, key);
}
... ...
... ... @@ -3,7 +3,6 @@ package com.yoho.search.consumer.index.increment.productIndex;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -11,7 +10,6 @@ import com.yoho.search.consumer.common.CostStatistics;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductPoolDetailService;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductPoolDetail;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -46,8 +44,7 @@ public class ProductPoolDetailMqListener extends AbstractMqListener implements C
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTPOOLDETAILMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTPOOLDETAILMQLISTENER_ONMESSAGE
.getFunctionName(), EventReportEnum.PRODUCTPOOLDETAILMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTPOOLDETAILMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.productIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -10,7 +9,6 @@ import com.yoho.search.consumer.service.base.ProductPriceService;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.consumer.service.bo.ProductPriceBO;
import com.yoho.search.consumer.service.logic.productIndex.viewBuilder.ProductPriceBuilder;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Product;
import com.yoho.search.dal.model.ProductPrice;
import org.apache.commons.lang3.StringUtils;
... ... @@ -46,8 +44,7 @@ public class ProductPriceMqListener extends AbstractMqListener implements Channe
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTPRICEMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTPRICEMQLISTENER_ONMESSAGE
.getFunctionName(), EventReportEnum.PRODUCTPRICEMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTPRICEMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.productIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductSearchService;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductSearch;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -30,14 +28,17 @@ public class ProductSearchMqListener extends AbstractMqListener implements Chann
@Autowired
private ProductService productService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTSEARCHMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.PRODUCTSEARCHMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTSEARCHMQLISTENER_ONMESSAGE.getMoudleName(),"exception", IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTSEARCHMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -86,10 +87,7 @@ public class ProductSearchMqListener extends AbstractMqListener implements Chann
(System.currentTimeMillis() - begin));
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
private void updateProductIndex(ProductSearch productSearch, String key, long begin) {
// 1、参数校验
... ...
... ... @@ -2,13 +2,11 @@ package com.yoho.search.consumer.index.increment.productIndex;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductStandardRelationService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductStandardRelation;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -27,6 +25,11 @@ public class ProductStandardRelationMqListener extends AbstractMqListener implem
@Autowired
private ProductStandardRelationService productStandardRelationService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
... ... @@ -44,9 +47,7 @@ public class ProductStandardRelationMqListener extends AbstractMqListener implem
updateData(json.getObject("data", Map.class), key);
}
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTSTANDARDRELATIONMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.PRODUCTSTANDARDRELATIONMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTSTANDARDRELATIONMQLISTENER_ONMESSAGE.getMoudleName(),"exception", IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTSTANDARDRELATIONMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -113,8 +114,5 @@ public class ProductStandardRelationMqListener extends AbstractMqListener implem
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
}
... ...
package com.yoho.search.consumer.index.increment.productIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductStyleRelationService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductStyleRelation;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -31,9 +29,7 @@ public class ProductStyleRelationMqListener extends AbstractMqListener implement
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTSTYLERELATIONMQLISTENER_ONMESSAGE.getEventName(),
EventReportEnum.PRODUCTSTYLERELATIONMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTSTYLERELATIONMQLISTENER_ONMESSAGE.getMoudleName(),"exception",IgnoreSomeException.filterSomeException(e),null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTSTYLERELATIONMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.productIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
... ... @@ -10,7 +9,6 @@ import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.consumer.service.base.ProductTimingService;
import com.yoho.search.consumer.service.logic.productIndex.StorageUpdateTimeLogicService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Product;
import com.yoho.search.dal.model.ProductTiming;
import com.yoho.search.dal.model.StorageUpdateTime;
... ... @@ -21,8 +19,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
... ... @@ -34,7 +30,7 @@ import java.util.Map;
* Created by wangnan on 2016/11/24.
*/
@Component
public class ProductTimingMqListener extends AbstractMqListener implements ChannelAwareMessageListener, ApplicationEventPublisherAware {
public class ProductTimingMqListener extends AbstractMqListener implements ChannelAwareMessageListener{
private static final Logger logger = LoggerFactory.getLogger(ProductTimingMqListener.class);
... ... @@ -47,11 +43,10 @@ public class ProductTimingMqListener extends AbstractMqListener implements Chann
@Autowired
private StorageUpdateTimeLogicService storageUpdateTimeLogicService;
protected ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
@Override
... ... @@ -63,8 +58,7 @@ public class ProductTimingMqListener extends AbstractMqListener implements Chann
// 记录上报的日志
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,MoudleName is [{}]", nowTimeMillis, "MqListener", "consumer");
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTTIMINGMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTTIMINGMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.PRODUCTTIMINGMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.PRODUCTTIMINGMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ... @@ -82,7 +76,7 @@ public class ProductTimingMqListener extends AbstractMqListener implements Chann
logger.info("[func=updateData][step=success][tableName=productTiming][id={}][cost={}ms]", productTiming.getId(),(System.currentTimeMillis() - begin));
//更新productIndex
Product product = productService.getBySkn(productTiming.getProductSkn());
if (product != null && product.getId() != null && product.getId() != null) {
if (product != null && product.getId() != null) {
this.updateProductIndex(product.getId(), product.getErpProductId(), System.currentTimeMillis());
logger.info("[class=ProductTimingMqListener][func=updateProductIndex][id={}][cost={}ms]", productTiming.getId(),(System.currentTimeMillis() - begin));
}
... ... @@ -99,7 +93,7 @@ public class ProductTimingMqListener extends AbstractMqListener implements Chann
if (productTiming != null && productTiming.getProductSkn() != null) {
//更新productIndex
Product product = productService.getBySkn(productTiming.getProductSkn());
if (product != null && product.getId() != null && product.getId() != null) {
if (product != null && product.getId() != null) {
this.updateProductIndex(product.getId(), product.getErpProductId(), System.currentTimeMillis());
logger.info("[class=ProductTimingMqListener][func=updateProductIndex][id={}][cost={}ms]", id, (System.currentTimeMillis() - begin));
}
... ... @@ -124,8 +118,4 @@ public class ProductTimingMqListener extends AbstractMqListener implements Chann
this.updateProductIndexWithDataMap(indexData, productId, null, begin);
}
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
}
}
... ...
package com.yoho.search.consumer.index.increment.productIndex;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -9,7 +8,6 @@ import com.yoho.search.consumer.common.CostStatistics;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.consumer.service.base.StorageService;
import com.yoho.search.consumer.service.logic.productIndex.StorageUpdateTimeLogicService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Product;
import com.yoho.search.dal.model.Storage;
import com.yoho.search.dal.model.StorageUpdateTime;
... ... @@ -48,8 +46,7 @@ public class StorageMqListener extends AbstractStorageRelatedMqListener implemen
try {
process(this, message);
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.STORAGEMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.STORAGEMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.STORAGEMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.STORAGEMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.tbl;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -11,7 +9,6 @@ import com.yoho.search.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.TblBrandService;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.TblBrand;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -65,12 +62,11 @@ public class TblBrandMqListener extends AbstractMqListener implements ChannelAwa
try {
process(this, message);
long nowTimeMillis = System.currentTimeMillis();
publisher.publishEvent(new SearchLogsEvent("MqListener", EventReportEnum.TBLBRANDMQLISTENER_ONMESSAGE.getMoudleName(), "monitor", nowTimeMillis + ""));
publisher.publishEvent(buildSearchLogsEvent(EventReportEnum.TBLBRANDMQLISTENER_ONMESSAGE, nowTimeMillis));
// 记录上报的日志
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,MoudleName is [{}]", nowTimeMillis, "MqListener", "consumer");
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.TBLBRANDMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.TBLBRANDMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.TBLBRANDMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.TBLBRANDMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}finally {
... ...
package com.yoho.search.consumer.index.increment.tbl;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.index.increment.bulks.GlobalIndexBulkService;
import com.yoho.search.consumer.service.base.TblProductService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.TblProduct;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -55,12 +52,11 @@ public class TblProductMqListener extends AbstractMqListener implements ChannelA
try {
process(this, message);
long nowTimeMillis = System.currentTimeMillis();
publisher.publishEvent(new SearchLogsEvent("MqListener", EventReportEnum.TBLPRODUCTMQLISTENER_ONMESSAGE.getMoudleName(), "monitor", nowTimeMillis + ""));
publisher.publishEvent(buildSearchLogsEvent(EventReportEnum.TBLPRODUCTMQLISTENER_ONMESSAGE, nowTimeMillis));
// 记录上报的日志
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,ModuleName is [{}]", nowTimeMillis, "MqListener", "consumer");
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.TBLPRODUCTMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.TBLPRODUCTMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.TBLPRODUCTMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.TBLPRODUCTMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.tbl;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.index.increment.bulks.GlobalIndexBulkService;
import com.yoho.search.consumer.service.base.TblProductSkcService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.TblProductSkc;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -48,12 +45,11 @@ public class TblProductSkcMqListener extends AbstractMqListener implements Chann
try {
process(this, message);
long nowTimeMillis = System.currentTimeMillis();
publisher.publishEvent(new SearchLogsEvent("MqListener", EventReportEnum.TBLPRODUCTSKCMQLISTENER_ONMESSAGE.getMoudleName(), "monitor", nowTimeMillis + ""));
publisher.publishEvent(buildSearchLogsEvent(EventReportEnum.TBLPRODUCTSKCMQLISTENER_ONMESSAGE, nowTimeMillis) );
// 记录上报的日志
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,MoudleName is [{}]", nowTimeMillis, "MqListener", "consumer");
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.TBLPRODUCTSKCMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.TBLPRODUCTSKCMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.TBLPRODUCTSKCMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.TBLPRODUCTSKCMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.tbl;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.index.increment.bulks.GlobalIndexBulkService;
import com.yoho.search.consumer.service.base.TblProductSkuService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.TblProductSku;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -49,12 +46,11 @@ public class TblProductSkuMqListener extends AbstractMqListener implements Chann
try {
process(this, message);
long nowTimeMillis = System.currentTimeMillis();
publisher.publishEvent(new SearchLogsEvent("MqListener", EventReportEnum.TBLPRODUCTSKUMQLISTENER_ONMESSAGE.getMoudleName(), "monitor", nowTimeMillis + ""));
publisher.publishEvent(buildSearchLogsEvent(EventReportEnum.TBLPRODUCTSKUMQLISTENER_ONMESSAGE, nowTimeMillis));
// 记录上报的日志
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,MoudleName is [{}]", nowTimeMillis, "MqListener", "consumer");
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.TBLPRODUCTSKUMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.TBLPRODUCTSKUMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.TBLPRODUCTSKUMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.TBLPRODUCTSKUMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}
... ...
package com.yoho.search.consumer.index.increment.tbl;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -11,7 +9,6 @@ import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.index.increment.bulks.GlobalIndexBulkService;
import com.yoho.search.consumer.service.base.TblProductService;
import com.yoho.search.consumer.service.base.TblSiteService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.TblSite;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -61,12 +58,11 @@ public class TblSiteMqListener extends AbstractMqListener implements ChannelAwar
try {
process(this, message);
long nowTimeMillis = System.currentTimeMillis();
publisher.publishEvent(new SearchLogsEvent("MqListener", EventReportEnum.TBLSITEMQLISTENER_ONMESSAGE.getMoudleName(), "monitor", nowTimeMillis + ""));
publisher.publishEvent(buildSearchLogsEvent(EventReportEnum.TBLSITEMQLISTENER_ONMESSAGE, nowTimeMillis) );
// 记录上报的日志
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,MoudleName is [{}]", nowTimeMillis, "MqListener", "consumer");
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.TBLSITEMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.TBLSITEMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.TBLSITEMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.TBLSITEMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}finally {
... ...
package com.yoho.search.consumer.index.increment.tbl;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.TblSortService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.TblSort;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -53,12 +50,11 @@ public class TblSortMqListener extends AbstractMqListener implements ChannelAwar
try {
process(this, message);
long nowTimeMillis = System.currentTimeMillis();
publisher.publishEvent(new SearchLogsEvent("MqListener", EventReportEnum.TBLSORTMQLISTENER_ONMESSAGE.getMoudleName(), "monitor", nowTimeMillis + ""));
publisher.publishEvent(buildSearchLogsEvent(EventReportEnum.TBLSORTMQLISTENER_ONMESSAGE, nowTimeMillis) );
// 记录上报的日志
SEARCH_EVENT_LOG.info("report to influxDb,currentTimeMillis is [{}],EventName is [{}] ,MoudleName is [{}]", nowTimeMillis, "MqListener", "consumer");
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.TBLSORTMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.TBLSORTMQLISTENER_ONMESSAGE.getFunctionName(),
EventReportEnum.TBLSORTMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
publisher.publishEvent(buildSearchEvent(EventReportEnum.TBLSORTMQLISTENER_ONMESSAGE,e));
Thread.sleep(1000);
throw e;
}finally {
... ...
... ... @@ -46,6 +46,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_PRICE_PLAN);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_HELPER);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_SHOPS);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PROMOTION);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX);
logger.info("indexRebuildJob execute end----[end={}][cost={}]", System.currentTimeMillis(), (System.currentTimeMillis() - begin));
}
... ...
{
"promotion": {
"_all": {
"enabled": false
},
"_source": {
"enabled": true
},
"properties": {
"id": {
"type": "long"
},
"title": {
"type": "string"
}
}
}
}
\ No newline at end of file
... ...
package com.yoho.search.consumer.service.base;
import com.yoho.search.dal.PromotionProductFlagsMapper;
import com.yoho.search.dal.model.PromotionProductFlags;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* Created by wangnan on 2017/5/11.
*/
@Component
public class PromotionProductFlagsService {
@Autowired
private PromotionProductFlagsMapper promotionProductFlagsMapper;
public PromotionProductFlags getById(Integer id) {
return promotionProductFlagsMapper.selectByPrimaryKey(id);
}
public int insert(PromotionProductFlags promotionProductFlags) {
return promotionProductFlagsMapper.insert(promotionProductFlags);
}
public int update(PromotionProductFlags promotionProductFlags) {
return promotionProductFlagsMapper.updateByPrimaryKeySelective(promotionProductFlags);
}
public int saveOrUpdate(PromotionProductFlags promotionProductFlags) {
if (promotionProductFlags.getId() == null || promotionProductFlagsMapper.selectByPrimaryKey(promotionProductFlags.getId()) == null) {
return promotionProductFlagsMapper.insert(promotionProductFlags);
} else {
return promotionProductFlagsMapper.updateByPrimaryKeySelective(promotionProductFlags);
}
}
public int delete(Integer id) {
return promotionProductFlagsMapper.deleteByPrimaryKey(id);
}
public List<PromotionProductFlags> getPageLists(int start, int size) {
return promotionProductFlagsMapper.selectPageLists(start, size);
}
public int count() {
return promotionProductFlagsMapper.selectCount();
}
}
... ...
package com.yoho.search.consumer.service.base;
import java.util.List;
import com.yoho.search.dal.RobotQuestionMapper;
import com.yoho.search.dal.model.RobotQuestion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yoho.search.dal.RobotQuestionMapper;
import com.yoho.search.dal.model.RobotQuestion;
import java.util.List;
/**
* Created by wangnan on 2016/11/28.
... ...
... ... @@ -66,7 +66,7 @@ public class ForbidenSortBrandLogicService {
}
brandIds.add(forbiddenSortBrand.getBrandId());
}
//remove from db
//remove from database
forbiddenSortBrandMapper.deleteAll();
long begin = System.currentTimeMillis();
logger.info("deleteAll forbiddenSortBrand success [cost={}]", (System.currentTimeMillis() - begin));
... ...
... ... @@ -81,6 +81,7 @@
<rabbit:queue durable="true" exclusive="false" name="data_update_channel_scorerule" />
<rabbit:queue durable="true" exclusive="false" name="data_update_channel_promotioninfo" />
<rabbit:queue durable="true" exclusive="false" name="data_update_channel_promotionparams" />
<rabbit:queue durable="true" exclusive="false" name="data_update_channel_promotionproductflags" />
<rabbit:template exchange="${search.mq.exchange}" id="amqpTemplate"
connection-factory="connectionFactory" message-converter="jsonMessageConverter" />
... ... @@ -164,5 +165,7 @@
<rabbit:listener queue-names="data_update_channel_scorerule" ref="scoreRuleMqListener" />
<rabbit:listener queue-names="data_update_channel_promotioninfo" ref="promotionInfoMqListener" />
<rabbit:listener queue-names="data_update_channel_promotionparams" ref="promotionParamsMqListener" />
<rabbit:listener queue-names="data_update_channel_promotionproductflags" ref="promotionProductFlagsMqListener" />
</rabbit:listener-container>
</beans>
\ No newline at end of file
... ...
... ... @@ -186,5 +186,17 @@
<builderClass>com.yoho.search.consumer.index.fullbuild.HelperIndexBuilder</builderClass>
<mappingFile>esmapping/helper.json</mappingFile>
</index>
<index>
<name>promotion</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="1"/>
<property key="refresh_interval" value="10s"/>
<property key="translog.flush_threshold_ops" value="10000"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.PromotionIndexBuilder</builderClass>
<mappingFile>esmapping/promotion.json</mappingFile>
</index>
</client>
</IndexConfigs>
\ No newline at end of file
... ...
... ... @@ -187,6 +187,18 @@
<mappingFile>esmapping/helper.json</mappingFile>
</index>
<index>
<name>promotion</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="${search.index.number_of_replicas}"/>
<property key="refresh_interval" value="${search.index.refresh_interval}"/>
<property key="translog.flush_threshold_ops" value="${search.index.translog.flush_threshold_ops}"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.PromotionIndexBuilder</builderClass>
<mappingFile>esmapping/promotion.json</mappingFile>
</index>
</client>
</IndexConfigs>
... ...