Authored by qinchao

去掉不用的类

package com.monitor.common.service;
/**
* Created by zhengyouwei on 2017/1/13.
*/
public interface ZookeeperService {
String getData(String code);
}
package com.monitor.common.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.monitor.common.config.SendsmsConfig;
import com.monitor.common.config.SnsMobileConfig;
import com.monitor.common.service.ZookeeperService;
import com.monitor.common.util.MD5Util;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.common.service.AlarmMsgService;
import com.monitor.common.service.HttpRestClientService;
import com.monitor.common.util.MD5Util;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.influxdb.mapper.MonitorAlarmMapper;
import com.monitor.model.domain.QcloudSms;
import com.monitor.model.request.ZkTreeAllReq;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -20,12 +16,10 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Created by yoho on 2016/5/3.
... ... @@ -43,13 +37,8 @@ public class AlarmMsgServiceImpl implements AlarmMsgService {
@Autowired
private MonitorAlarmMapper monitorAlarmMapper;
@Autowired
private ZookeeperService zookeeperService;
private Logger logger = LoggerFactory.getLogger(AlarmMsgServiceImpl.class);
private static final int CONTENT_SUB_LENGTH = 250;
public static final String DEFAULT_SENT_LOCK = "sent_lock";
... ... @@ -91,9 +80,6 @@ public class AlarmMsgServiceImpl implements AlarmMsgService {
return false;
}
}*/
if(true){
return true;
}
//无需发送
... ...
... ... @@ -2,10 +2,8 @@ package com.monitor.common.service.impl;
import com.alibaba.fastjson.JSON;
import com.monitor.common.config.SendsmsConfig;
import com.monitor.common.config.SnsMobileConfig;
import com.monitor.common.service.HttpRestClientService;
import com.monitor.common.service.VoiceMsgService;
import com.monitor.common.service.ZookeeperService;
import com.monitor.common.util.MD5Util;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.influxdb.mapper.MonitorAlarmMapper;
... ... @@ -33,9 +31,6 @@ public class VoiceMsgServiceImpl implements VoiceMsgService {
@Autowired
private SendsmsConfig sendsmsConfig;
@Autowired
private ZookeeperService zookeeperService;
public final Logger DEBUG = LoggerFactory.getLogger(getClass());
@Override
... ...
package com.monitor.common.service.impl;
import com.model.MObjectInfo;
import com.monitor.common.service.ZookeeperService;
import com.monitor.mysql.mapper.MObjectInfoMapper;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by zhengyouwei on 2017/1/13.
*/
@Service
public class ZookeeperServiceImpl implements ZookeeperService {
@Autowired
MObjectInfoMapper mObjectInfoMapper;
private static String ZK_PATH = "/yh/config/";
private static String AWS = "zookeeper_aws";
@Override
public String getData(String code) {
String hostIp = getHostIp(AWS);
RetryPolicy retryPolicy = new RetryOneTime(1000);
CuratorFramework client = CuratorFrameworkFactory.newClient(hostIp + ":2181", 5 * 1000, 5 * 1000, retryPolicy);
client.start();
try {
String data = new String(client.getData().forPath(ZK_PATH + code));
return data;
} catch (Exception e) {
}finally {
client.close();
}
return null; }
public String getHostIp(String name){
List<MObjectInfo> mlist = mObjectInfoMapper.getMoInfosByAlias(name);
String hostIp = "";
for (MObjectInfo obj : mlist) {
hostIp = obj.getMoHostIp();
break;
}
return hostIp;
}
}
package com.monitor.other.util;
import javax.annotation.PostConstruct;
import org.apache.commons.lang3.StringUtils;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryNTimes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import lombok.Getter;
/**
*
*/
@Component
public class ZkClientUtil {
public static final Logger logger = LoggerFactory.getLogger(ZkClientUtil.class);
@Value("${zookeeper.address}")
private String zkAddress;
@Getter
private CuratorFramework curatorFramework;
/**
* zk默认路径
*/
private final static String ZK_DEFAULT_PATH = "/yh/config/";
@PostConstruct
public void init() {
//不用
/*RetryPolicy policy = new RetryNTimes(3, 5 * 1000);
curatorFramework = CuratorFrameworkFactory.newClient(zkAddress, 60 * 1000, 30 * 1000, policy);
try {
curatorFramework.start();
} catch (Exception e) {
logger.error("Failed to connect with {} , error {}", zkAddress, e);
throw e;
}*/
}
/**
* 获取zk配置的值
* @param key
* @return
*/
public String getString(String key,String defaultValue){
/*try{
byte[] values = curatorFramework.getData().forPath(ZK_DEFAULT_PATH + key);
if((null == values) || (values.length == 0)){
return defaultValue;
}
String value = new String(values);
if(StringUtils.isBlank(value)){
return defaultValue;
}else{
return value;
}
}catch(Exception e){
logger.warn(" - ZkClientUtil - getString - error", e);
try {
curatorFramework.create().creatingParentsIfNeeded().forPath(ZK_DEFAULT_PATH + key, defaultValue.getBytes());
return defaultValue;
} catch (Exception e1) {
logger.warn(" - ZkClientUtil - getString - error", e1);
return defaultValue;
}
}*/
return null;
}
}