}
public List<File> decompressed(String fileName) {
- List<File> filelist = new ArrayList<File>();
+ List<File> filelist = new ArrayList<>();
if (fileName.indexOf(".gz") > 1) {
try {
unzip.deCompress();
file = new File(orgFile);
}
- File[] files = file.listFiles();
-
- return files;
+ return file.listFiles();
}
private List<String> ftpDownload(CollectVo collectVo) {
- List<String> fileList = new ArrayList<String>();
+ List<String> fileList = new ArrayList<>();
// IP
String ip = collectVo.getIP();
// port
// download
String dir = collectVo.getRemotepath();
- List<String> searchExprList = new ArrayList<String>();
- String[] FPath = dir.split(";");
- for (int i = 0; i < FPath.length; i++) {
+ List<String> searchExprList = new ArrayList<>();
+ String[] fPath = dir.split(";");
+ for (int i = 0; i < fPath.length; i++) {
int oldSize = searchExprList.size();
- String conpath = FPath[i] + collectVo.getMatch();
+ String conpath = fPath[i] + collectVo.getMatch();
HashMap<String, String> varMap = new HashMap<>();
long collectPeriod = 900;
try {
log.error(" collect fail ", e1);
return fileList;
}
- List<AFtpRemoteFile> remoteFiles = new ArrayList<AFtpRemoteFile>();
+ List<AFtpRemoteFile> remoteFiles = new ArrayList<>();
for (String expr : searchExprList) {
ftpClient.chdir(nowdir);
- String keys[] = parseExprKeys(expr);
+ String[] keys = parseExprKeys(expr);
String ftpRegular = keys[1];
String ftpDir = keys[0];
public List<String> getPathNoRegular(List<String> searchExprList, FTPInterface ftpCache) throws IOException {
boolean isregular = false;
- List<String> regularList = new ArrayList<String>();
+ List<String> regularList = new ArrayList<>();
for (String regular : searchExprList) {
Pattern lpattern = null;
try {
regularList.add(regular);
}
}
- if (isregular == true) {
+ if (isregular) {
getPathNoRegular(regularList, ftpCache);
}
return regularList;
-/*
- * Copyright 2017 BOCO Corporation. CMCC Technologies Co., Ltd
+/**
+ * Copyright 2017 BOCO Corporation
+ * Copyright 2018 CMCC Technologies Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public class ConfigurationManager extends DriverThread {
- public final static String CONFIG_PROPERTIES_LOCATION = Constant.SYS_CFG + "config.properties";
- protected static Log log = LogFactory.getLog(ConfigurationManager.class);
+ public static final String CONFIG_PROPERTIES_LOCATION = Constant.SYS_CFG + "config.properties";
+ protected static final Log log = LogFactory.getLog(ConfigurationManager.class);
/**
* ESM Cache
*/
@VisibleForTesting
- static Map<String, EMSInfo> emsInfoCache = new ConcurrentHashMap<String, EMSInfo>();
+ static Map<String, EMSInfo> emsInfoCache = new ConcurrentHashMap<>();
@VisibleForTesting
static Properties properties = null;
- private static Map<String, CrontabVo> emsCrontab = new ConcurrentHashMap<String, CrontabVo>();
- private static List<String> emsIdList = new ArrayList<String>();
+ private static Map<String, CrontabVo> emsCrontab = new ConcurrentHashMap<>();
+ private static List<String> emsIdList = new ArrayList<>();
public static synchronized List<EMSInfo> getAllEMSInfos() {
- List<EMSInfo> list = new ArrayList<EMSInfo>();
+ List<EMSInfo> list = new ArrayList<>();
for (EMSInfo emsinfo : emsInfoCache.values()) {
list.add(emsinfo);
}
}
public static synchronized EMSInfo getEMSInfoByName(String emsName) {
- EMSInfo emsInfo = emsInfoCache.get(emsName);
- return emsInfo;
+ return emsInfoCache.get(emsName);
}
public static synchronized Properties getProperties() {
log.debug("not exists " + path);
return null;
}
- Map<String, CrontabVo> tmpcache = new HashMap<String, CrontabVo>();
+ Map<String, CrontabVo> tmpcache = new HashMap<>();
try (
InputStream is = new FileInputStream(cfg)){
class ReceiveSource extends Thread {
long timeStamp = System.currentTimeMillis();
-
+
+ @Override
public void run() {
while (true) {
}
private Map<String, EMSInfo> getEmsInfo(String emsId) {
- Map<String, EMSInfo> tmpcache = new ConcurrentHashMap<String, EMSInfo>();
+ Map<String, EMSInfo> tmpcache = new ConcurrentHashMap<>();
String msbAddress = properties.getProperty("msbAddress");
String emstUrl = properties.getProperty("esr_emsUrl");
//set emsId to url
log.debug(getemstUrl + " result=" + emsResult);
JSONObject reagobj = JSONObject.parseObject(emsResult);
- JSONObject esr_system_info_list = reagobj.getJSONObject("esr-system-info-list");
- JSONArray esr_system_info = esr_system_info_list.getJSONArray("esr-system-info");
- Iterator<Object> it = esr_system_info.iterator();
+ JSONObject esrSystemInfoList = reagobj.getJSONObject("esr-system-info-list");
+ JSONArray esrSystemInfo = esrSystemInfoList.getJSONArray("esr-system-info");
+ Iterator<Object> it = esrSystemInfo.iterator();
EMSInfo emsInfo = new EMSInfo();
emsInfo.setName(emsId);
tmpcache.put(emsId, emsInfo);
while (it.hasNext()) {
Object obj = it.next();
JSONObject collect = (JSONObject) obj;
- String system_type = (String) collect.get("system-type");
+ String systemType = (String) collect.get("system-type");
CollectVo collectVo = new CollectVo();
- if (Constant.COLLECT_TYPE_CM.equalsIgnoreCase(system_type)) {
- CrontabVo crontabVo = emsCrontab.get(system_type);
+ if (Constant.COLLECT_TYPE_CM.equalsIgnoreCase(systemType)) {
+ CrontabVo crontabVo = emsCrontab.get(systemType);
if (crontabVo != null) {
- collectVo.setType(system_type);
+ collectVo.setType(systemType);
collectVo.setCrontab(crontabVo.getCrontab());
collectVo.setIP(collect.getString("ip-address"));
collectVo.setPort(collect.getString("port"));
collectVo.setPassive(collect.getString("passive"));
collectVo.setGranularity(crontabVo.getGranularity());
} else {
- log.error("emsCrontab.get(system_type) result crontabVo is null system_type=[" + system_type + "] emsCrontabMap=" + emsCrontab);
+ log.error("emsCrontab.get(systemType) result crontabVo is null systemType=[" + systemType + "] emsCrontabMap=" + emsCrontab);
}
- } else if (Constant.COLLECT_TYPE_PM.equalsIgnoreCase(system_type)) {
- CrontabVo crontabVo = emsCrontab.get(system_type);
+ } else if (Constant.COLLECT_TYPE_PM.equalsIgnoreCase(systemType)) {
+ CrontabVo crontabVo = emsCrontab.get(systemType);
if (crontabVo != null) {
- collectVo.setType(system_type);
+ collectVo.setType(systemType);
collectVo.setCrontab(crontabVo.getCrontab());
collectVo.setIP(collect.getString("ip-address"));
collectVo.setPort(collect.getString("port"));
collectVo.setPassive(collect.getString("passive"));
collectVo.setGranularity(crontabVo.getGranularity());
} else {
- log.error("emsCrontab.get(system_type) result crontabVo is null system_type=[" + system_type + "]");
+ log.error("emsCrontab.get(systemType) result crontabVo is null systemType=[" + systemType + "]");
}
- } else if (Constant.COLLECT_TYPE_ALARM.equalsIgnoreCase(system_type)) {
- CrontabVo crontabVo = emsCrontab.get(system_type);
+ } else if (Constant.COLLECT_TYPE_ALARM.equalsIgnoreCase(systemType)) {
+ CrontabVo crontabVo = emsCrontab.get(systemType);
if (crontabVo != null) {
collectVo.setIscollect(crontabVo.isIscollect());
- collectVo.setType(system_type);
+ collectVo.setType(systemType);
collectVo.setIP(collect.getString("ip-address"));
collectVo.setPort(collect.getString("port"));
collectVo.setUser(collect.getString("user-name"));
collectVo.setPassword(collect.getString("password"));
collectVo.setReadTimeout(crontabVo.getReadTimeout());
} else {
- log.error("emsCrontab.get(system_type) result crontabVo is null system_type=[" + system_type + "]");
+ log.error("emsCrontab.get(systemType) result crontabVo is null systemType=[" + systemType + "]");
}
} else {
- log.error("ems system-type =" + system_type + " ");
+ log.error("ems system-type =" + systemType + " ");
}
- emsInfo.putCollectMap(system_type, collectVo);
+ emsInfo.putCollectMap(systemType, collectVo);
}
return tmpcache;
}
private List<String> getEmsIdList() {
- List<String> emsIds = new ArrayList<String>();
+ List<String> emsIds = new ArrayList<>();
//http
String msbAddress = properties.getProperty("msbAddress");
String url = properties.getProperty("esr_ems_listUrl");
String result = HttpClientUtil.doGet(getemsListUrl, Constant.ENCODING_UTF8);
log.debug(getemsListUrl + " result=" + result);
JSONObject reagobj = JSONObject.parseObject(result);
- JSONArray esr_emsIds = reagobj.getJSONArray("esr-ems");
- Iterator<Object> it = esr_emsIds.iterator();
+ JSONArray esrEmsIds = reagobj.getJSONArray("esr-ems");
+ Iterator<Object> it = esrEmsIds.iterator();
while (it.hasNext()) {
Object obj = it.next();
JSONObject emsId = (JSONObject) obj;