Showing
5 changed files
with
2 additions
and
161 deletions
1 | package com.monitor.common.service.impl; | 1 | package com.monitor.common.service.impl; |
2 | 2 | ||
3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
4 | -import com.alibaba.fastjson.JSONArray; | ||
5 | import com.monitor.common.config.SendsmsConfig; | 4 | import com.monitor.common.config.SendsmsConfig; |
6 | -import com.monitor.common.config.SnsMobileConfig; | ||
7 | -import com.monitor.common.service.ZookeeperService; | ||
8 | -import com.monitor.common.util.MD5Util; | ||
9 | -import com.monitor.influxdb.contants.InfluxDBContants; | ||
10 | import com.monitor.common.service.AlarmMsgService; | 5 | import com.monitor.common.service.AlarmMsgService; |
11 | import com.monitor.common.service.HttpRestClientService; | 6 | import com.monitor.common.service.HttpRestClientService; |
7 | +import com.monitor.common.util.MD5Util; | ||
8 | +import com.monitor.influxdb.contants.InfluxDBContants; | ||
12 | import com.monitor.influxdb.mapper.MonitorAlarmMapper; | 9 | import com.monitor.influxdb.mapper.MonitorAlarmMapper; |
13 | import com.monitor.model.domain.QcloudSms; | 10 | import com.monitor.model.domain.QcloudSms; |
14 | -import com.monitor.model.request.ZkTreeAllReq; | ||
15 | import org.apache.commons.lang.StringUtils; | 11 | import org.apache.commons.lang.StringUtils; |
16 | import org.slf4j.Logger; | 12 | import org.slf4j.Logger; |
17 | import org.slf4j.LoggerFactory; | 13 | import org.slf4j.LoggerFactory; |
@@ -20,12 +16,10 @@ import org.springframework.scheduling.annotation.Scheduled; | @@ -20,12 +16,10 @@ import org.springframework.scheduling.annotation.Scheduled; | ||
20 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
21 | 17 | ||
22 | import java.io.UnsupportedEncodingException; | 18 | import java.io.UnsupportedEncodingException; |
23 | -import java.net.URLEncoder; | ||
24 | import java.util.ArrayList; | 19 | import java.util.ArrayList; |
25 | import java.util.HashMap; | 20 | import java.util.HashMap; |
26 | import java.util.List; | 21 | import java.util.List; |
27 | import java.util.Map; | 22 | import java.util.Map; |
28 | -import java.util.concurrent.ConcurrentHashMap; | ||
29 | 23 | ||
30 | /** | 24 | /** |
31 | * Created by yoho on 2016/5/3. | 25 | * Created by yoho on 2016/5/3. |
@@ -43,13 +37,8 @@ public class AlarmMsgServiceImpl implements AlarmMsgService { | @@ -43,13 +37,8 @@ public class AlarmMsgServiceImpl implements AlarmMsgService { | ||
43 | @Autowired | 37 | @Autowired |
44 | private MonitorAlarmMapper monitorAlarmMapper; | 38 | private MonitorAlarmMapper monitorAlarmMapper; |
45 | 39 | ||
46 | - @Autowired | ||
47 | - private ZookeeperService zookeeperService; | ||
48 | - | ||
49 | private Logger logger = LoggerFactory.getLogger(AlarmMsgServiceImpl.class); | 40 | private Logger logger = LoggerFactory.getLogger(AlarmMsgServiceImpl.class); |
50 | 41 | ||
51 | - private static final int CONTENT_SUB_LENGTH = 250; | ||
52 | - | ||
53 | 42 | ||
54 | public static final String DEFAULT_SENT_LOCK = "sent_lock"; | 43 | public static final String DEFAULT_SENT_LOCK = "sent_lock"; |
55 | 44 | ||
@@ -91,9 +80,6 @@ public class AlarmMsgServiceImpl implements AlarmMsgService { | @@ -91,9 +80,6 @@ public class AlarmMsgServiceImpl implements AlarmMsgService { | ||
91 | return false; | 80 | return false; |
92 | } | 81 | } |
93 | }*/ | 82 | }*/ |
94 | - if(true){ | ||
95 | - return true; | ||
96 | - } | ||
97 | 83 | ||
98 | 84 | ||
99 | //无需发送 | 85 | //无需发送 |
@@ -2,10 +2,8 @@ package com.monitor.common.service.impl; | @@ -2,10 +2,8 @@ package com.monitor.common.service.impl; | ||
2 | 2 | ||
3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
4 | import com.monitor.common.config.SendsmsConfig; | 4 | import com.monitor.common.config.SendsmsConfig; |
5 | -import com.monitor.common.config.SnsMobileConfig; | ||
6 | import com.monitor.common.service.HttpRestClientService; | 5 | import com.monitor.common.service.HttpRestClientService; |
7 | import com.monitor.common.service.VoiceMsgService; | 6 | import com.monitor.common.service.VoiceMsgService; |
8 | -import com.monitor.common.service.ZookeeperService; | ||
9 | import com.monitor.common.util.MD5Util; | 7 | import com.monitor.common.util.MD5Util; |
10 | import com.monitor.influxdb.contants.InfluxDBContants; | 8 | import com.monitor.influxdb.contants.InfluxDBContants; |
11 | import com.monitor.influxdb.mapper.MonitorAlarmMapper; | 9 | import com.monitor.influxdb.mapper.MonitorAlarmMapper; |
@@ -33,9 +31,6 @@ public class VoiceMsgServiceImpl implements VoiceMsgService { | @@ -33,9 +31,6 @@ public class VoiceMsgServiceImpl implements VoiceMsgService { | ||
33 | @Autowired | 31 | @Autowired |
34 | private SendsmsConfig sendsmsConfig; | 32 | private SendsmsConfig sendsmsConfig; |
35 | 33 | ||
36 | - @Autowired | ||
37 | - private ZookeeperService zookeeperService; | ||
38 | - | ||
39 | public final Logger DEBUG = LoggerFactory.getLogger(getClass()); | 34 | public final Logger DEBUG = LoggerFactory.getLogger(getClass()); |
40 | 35 | ||
41 | @Override | 36 | @Override |
1 | -package com.monitor.common.service.impl; | ||
2 | - | ||
3 | -import com.model.MObjectInfo; | ||
4 | -import com.monitor.common.service.ZookeeperService; | ||
5 | -import com.monitor.mysql.mapper.MObjectInfoMapper; | ||
6 | -import org.apache.curator.RetryPolicy; | ||
7 | -import org.apache.curator.framework.CuratorFramework; | ||
8 | -import org.apache.curator.framework.CuratorFrameworkFactory; | ||
9 | -import org.apache.curator.retry.RetryOneTime; | ||
10 | -import org.springframework.beans.factory.annotation.Autowired; | ||
11 | -import org.springframework.stereotype.Service; | ||
12 | - | ||
13 | -import java.util.List; | ||
14 | - | ||
15 | -/** | ||
16 | - * Created by zhengyouwei on 2017/1/13. | ||
17 | - */ | ||
18 | -@Service | ||
19 | -public class ZookeeperServiceImpl implements ZookeeperService { | ||
20 | - | ||
21 | - @Autowired | ||
22 | - MObjectInfoMapper mObjectInfoMapper; | ||
23 | - | ||
24 | - private static String ZK_PATH = "/yh/config/"; | ||
25 | - | ||
26 | - private static String AWS = "zookeeper_aws"; | ||
27 | - | ||
28 | - @Override | ||
29 | - public String getData(String code) { | ||
30 | - String hostIp = getHostIp(AWS); | ||
31 | - RetryPolicy retryPolicy = new RetryOneTime(1000); | ||
32 | - CuratorFramework client = CuratorFrameworkFactory.newClient(hostIp + ":2181", 5 * 1000, 5 * 1000, retryPolicy); | ||
33 | - client.start(); | ||
34 | - try { | ||
35 | - String data = new String(client.getData().forPath(ZK_PATH + code)); | ||
36 | - return data; | ||
37 | - } catch (Exception e) { | ||
38 | - }finally { | ||
39 | - client.close(); | ||
40 | - } | ||
41 | - return null; } | ||
42 | - | ||
43 | - public String getHostIp(String name){ | ||
44 | - List<MObjectInfo> mlist = mObjectInfoMapper.getMoInfosByAlias(name); | ||
45 | - String hostIp = ""; | ||
46 | - for (MObjectInfo obj : mlist) { | ||
47 | - hostIp = obj.getMoHostIp(); | ||
48 | - break; | ||
49 | - } | ||
50 | - return hostIp; | ||
51 | - | ||
52 | - } | ||
53 | -} |
1 | -package com.monitor.other.util; | ||
2 | - | ||
3 | -import javax.annotation.PostConstruct; | ||
4 | - | ||
5 | -import org.apache.commons.lang3.StringUtils; | ||
6 | -import org.apache.curator.RetryPolicy; | ||
7 | -import org.apache.curator.framework.CuratorFramework; | ||
8 | -import org.apache.curator.framework.CuratorFrameworkFactory; | ||
9 | -import org.apache.curator.retry.RetryNTimes; | ||
10 | -import org.slf4j.Logger; | ||
11 | -import org.slf4j.LoggerFactory; | ||
12 | -import org.springframework.beans.factory.annotation.Value; | ||
13 | -import org.springframework.stereotype.Component; | ||
14 | - | ||
15 | -import lombok.Getter; | ||
16 | - | ||
17 | -/** | ||
18 | - * | ||
19 | - */ | ||
20 | -@Component | ||
21 | -public class ZkClientUtil { | ||
22 | - public static final Logger logger = LoggerFactory.getLogger(ZkClientUtil.class); | ||
23 | - | ||
24 | - @Value("${zookeeper.address}") | ||
25 | - private String zkAddress; | ||
26 | - | ||
27 | - @Getter | ||
28 | - private CuratorFramework curatorFramework; | ||
29 | - | ||
30 | - /** | ||
31 | - * zk默认路径 | ||
32 | - */ | ||
33 | - private final static String ZK_DEFAULT_PATH = "/yh/config/"; | ||
34 | - | ||
35 | - @PostConstruct | ||
36 | - public void init() { | ||
37 | - //不用 | ||
38 | - /*RetryPolicy policy = new RetryNTimes(3, 5 * 1000); | ||
39 | - curatorFramework = CuratorFrameworkFactory.newClient(zkAddress, 60 * 1000, 30 * 1000, policy); | ||
40 | - try { | ||
41 | - curatorFramework.start(); | ||
42 | - } catch (Exception e) { | ||
43 | - logger.error("Failed to connect with {} , error {}", zkAddress, e); | ||
44 | - throw e; | ||
45 | - }*/ | ||
46 | - } | ||
47 | - | ||
48 | - /** | ||
49 | - * 获取zk配置的值 | ||
50 | - * @param key | ||
51 | - * @return | ||
52 | - */ | ||
53 | - public String getString(String key,String defaultValue){ | ||
54 | - /*try{ | ||
55 | - byte[] values = curatorFramework.getData().forPath(ZK_DEFAULT_PATH + key); | ||
56 | - if((null == values) || (values.length == 0)){ | ||
57 | - return defaultValue; | ||
58 | - } | ||
59 | - String value = new String(values); | ||
60 | - if(StringUtils.isBlank(value)){ | ||
61 | - return defaultValue; | ||
62 | - }else{ | ||
63 | - return value; | ||
64 | - } | ||
65 | - }catch(Exception e){ | ||
66 | - logger.warn(" - ZkClientUtil - getString - error", e); | ||
67 | - try { | ||
68 | - curatorFramework.create().creatingParentsIfNeeded().forPath(ZK_DEFAULT_PATH + key, defaultValue.getBytes()); | ||
69 | - return defaultValue; | ||
70 | - } catch (Exception e1) { | ||
71 | - logger.warn(" - ZkClientUtil - getString - error", e1); | ||
72 | - return defaultValue; | ||
73 | - } | ||
74 | - }*/ | ||
75 | - return null; | ||
76 | - } | ||
77 | -} |
-
Please register or login to post a comment