Authored by linlong

Merge branch 'master' into fix_0223

... ... @@ -75,7 +75,7 @@ public class GdtTransTask {
String url = urlEode(unionActivity,transInfo);
//改成httpclient方式调用
Pair<Integer, String> pair = HttpUtils.httpGet(url);
log.info("GdtTransTask call union success url={}, and result={}", url, pair);
log.info("GdtTransTask call union success url={},and ordercode is {}, and result={}", url,transInfo.getOrdercode(), pair);
if (pair.getLeft() != 200) {
log.warn("callback error with request={}", url);
}
... ...
package com.yoho.unions.server.task;
import com.netflix.config.DynamicPropertyFactory;
import com.netflix.config.DynamicStringProperty;
import com.yoho.core.common.utils.LocalIp;
import com.yoho.service.model.union.request.TransPinYouRequestBO;
import com.yoho.service.model.union.request.ViewPinYouRequestBO;
import com.yoho.unions.common.redis.RedisListCache;
... ... @@ -40,14 +43,30 @@ public class PinYouTask {
@Scheduled(cron = "0 0 6 * * ?")
public void run(){
log.info("begin run pinyoutask");
DynamicStringProperty taskHostPro = DynamicPropertyFactory.getInstance().getStringProperty("union.host", "172.31.16.99");
String localIp = LocalIp.getLocalIp();
localIp = localIp == null ? "" : localIp;
String taskHost = taskHostPro.get();
log.info("ScheduledPinYouTask: localIp is {}, taskHost is {}", localIp, taskHost);
if(!taskHost.equals(localIp)){
log.warn("ScheduledPinYouTask service: execute timetask host is not local host");
return;
}
//从redis里面获取大数据的数据
Long viewSize = redisListCache.size(UNION_VIEW_KEY);
Long transSize = redisListCache.size(UNION_TRANS_KEY);
List<ViewPinYouRequestBO> viewPinYouRequestBOList = new ArrayList<>();
int viewSizeInt = viewSize == null ? 0 : viewSize.intValue();
int transSizeInt = transSize == null ? 0:transSize.intValue();
log.info("viewSize is {},transSize is {}",viewSizeInt,viewSizeInt);
log.info("viewSize is {},transSize is {}",viewSizeInt,transSizeInt);
List<TransPinYouRequestBO> transPinYouRequestBOList = new ArrayList<>();
if(transSizeInt>0){
for(int i=0; i < transSizeInt; i++){
TransPinYouRequestBO transPinYouRequestBO = redisListCache.rightPop(UNION_TRANS_KEY, TransPinYouRequestBO.class);
log.info("transPinYouRequestBO is {}",transPinYouRequestBO);
transPinYouRequestBOList.add(transPinYouRequestBO);
}
}
if(viewSizeInt>0){
for(int i=0; i < viewSizeInt; i++){
... ... @@ -55,10 +74,11 @@ public class PinYouTask {
viewPinYouRequestBOList.add(viewPinYouRequestBO);
}
}
if(transSizeInt>0){
for(int i=0; i < transSizeInt; i++){
TransPinYouRequestBO transPinYouRequestBO = redisListCache.rightPop(UNION_TRANS_KEY, TransPinYouRequestBO.class);
transPinYouRequestBOList.add(transPinYouRequestBO);
if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){
log.info("transPinYouRequestBOList size is {}",transPinYouRequestBOList.size());
for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){
sendTrans(transPinYouRequestBO);
}
}
... ... @@ -69,12 +89,6 @@ public class PinYouTask {
}
}
if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){
log.info("transPinYouRequestBOList size is {}",transPinYouRequestBOList.size());
for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){
sendTrans(transPinYouRequestBO);
}
}
}
//给品友推送访问数据
... ...