|
@@ -31,15 +31,12 @@ public class TopOneVideoContainer {
|
|
public String odpsEndpoint;
|
|
public String odpsEndpoint;
|
|
public static final String sqlExp="select * from top_return_videolist_hh where dt={dt};";
|
|
public static final String sqlExp="select * from top_return_videolist_hh where dt={dt};";
|
|
|
|
|
|
-
|
|
|
|
|
|
+ private Timer timer;
|
|
|
|
|
|
@PostConstruct
|
|
@PostConstruct
|
|
public void init(){
|
|
public void init(){
|
|
- refreshTopVideoIdCache();
|
|
|
|
- Timer timer = new Timer();
|
|
|
|
- // 计算距离下一个小时的第15分钟还有多少毫秒
|
|
|
|
- long delay = calculateDelay();
|
|
|
|
- // 定时任务在每小时的第15分钟执行
|
|
|
|
|
|
+// refreshTopVideoIdCache();
|
|
|
|
+ timer = new Timer();
|
|
timer.schedule(new TimerTask() {
|
|
timer.schedule(new TimerTask() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
@@ -49,7 +46,8 @@ public class TopOneVideoContainer {
|
|
log.error("svc=timerTask taskName=refreshTopVideoIdCache e={}",Arrays.toString(e.getStackTrace()));
|
|
log.error("svc=timerTask taskName=refreshTopVideoIdCache e={}",Arrays.toString(e.getStackTrace()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }, delay, 60 * 60 * 1000);
|
|
|
|
|
|
+ }, 0);
|
|
|
|
+
|
|
}
|
|
}
|
|
public void refreshTopVideoIdCache(){
|
|
public void refreshTopVideoIdCache(){
|
|
Account account = new AliyunAccount(odpsAccessId, odpsAccessKey);
|
|
Account account = new AliyunAccount(odpsAccessId, odpsAccessKey);
|
|
@@ -74,7 +72,33 @@ public class TopOneVideoContainer {
|
|
idList.add(Long.parseLong(record.get("videoid").toString()));
|
|
idList.add(Long.parseLong(record.get("videoid").toString()));
|
|
}
|
|
}
|
|
videoMap=tempMap;
|
|
videoMap=tempMap;
|
|
- System.out.println("刷新top1视频缓存成功");
|
|
|
|
|
|
+ if(videoMap.size()==0){
|
|
|
|
+ timer.schedule(new TimerTask() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ try {
|
|
|
|
+ refreshTopVideoIdCache();
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("svc=timerTask taskName=refreshTopVideoIdCache e={}",Arrays.toString(e.getStackTrace()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }, 30*1000);
|
|
|
|
+ }else {
|
|
|
|
+ // 计算距离下一个小时的第15分钟还有多少毫秒
|
|
|
|
+ long delay = calculateDelay();
|
|
|
|
+ // 定时任务在每小时的第15分钟执行
|
|
|
|
+ timer.schedule(new TimerTask() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ try {
|
|
|
|
+ refreshTopVideoIdCache();
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("svc=timerTask taskName=refreshTopVideoIdCache status=failed e={}",Arrays.toString(e.getStackTrace()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }, delay);
|
|
|
|
+ }
|
|
|
|
+ log.info("svc=timerTask taskName=refreshTopVideoIdCache status=success videoMap={}",JSONObject.toJSONString(videoMap));
|
|
}
|
|
}
|
|
|
|
|
|
public boolean inNoAdTopVideo(Long appType,Long videoId){
|
|
public boolean inNoAdTopVideo(Long appType,Long videoId){
|