Showing
1 changed file
with
16 additions
and
0 deletions
1 | package com.yoho.unions.server.task; | 1 | package com.yoho.unions.server.task; |
2 | 2 | ||
3 | +import java.net.InetAddress; | ||
4 | +import java.net.UnknownHostException; | ||
3 | import java.text.SimpleDateFormat; | 5 | import java.text.SimpleDateFormat; |
4 | import java.util.Calendar; | 6 | import java.util.Calendar; |
5 | import java.util.Date; | 7 | import java.util.Date; |
@@ -9,6 +11,7 @@ import java.util.Map; | @@ -9,6 +11,7 @@ import java.util.Map; | ||
9 | import java.util.concurrent.locks.Lock; | 11 | import java.util.concurrent.locks.Lock; |
10 | import java.util.concurrent.locks.ReentrantLock; | 12 | import java.util.concurrent.locks.ReentrantLock; |
11 | 13 | ||
14 | +import org.apache.commons.lang3.StringUtils; | ||
12 | import org.slf4j.Logger; | 15 | import org.slf4j.Logger; |
13 | import org.slf4j.LoggerFactory; | 16 | import org.slf4j.LoggerFactory; |
14 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -43,6 +46,19 @@ public class UnionClickCountDayTask { | @@ -43,6 +46,19 @@ public class UnionClickCountDayTask { | ||
43 | //@Scheduled(cron = "* 0/2 * * * ?") | 46 | //@Scheduled(cron = "* 0/2 * * * ?") |
44 | public void run() { | 47 | public void run() { |
45 | 48 | ||
49 | + try { | ||
50 | + InetAddress addr = InetAddress.getLocalHost(); | ||
51 | + String ip = addr.getHostAddress(); | ||
52 | + logger.info("当前ip是:{}", ip); | ||
53 | + if (!StringUtils.equals("172.31.70.253", ip)) { | ||
54 | + logger.info("当前环境不是目标环境,不执行操作!"); | ||
55 | + return; | ||
56 | + } | ||
57 | + } catch (UnknownHostException e1) { | ||
58 | + logger.error("获取ip地址出错!"); | ||
59 | + return; | ||
60 | + } | ||
61 | + | ||
46 | Calendar time = Calendar.getInstance(); | 62 | Calendar time = Calendar.getInstance(); |
47 | time.set(Calendar.HOUR_OF_DAY, 0); | 63 | time.set(Calendar.HOUR_OF_DAY, 0); |
48 | time.set(Calendar.MINUTE, 0); | 64 | time.set(Calendar.MINUTE, 0); |
-
Please register or login to post a comment