Commit 8ac48834 authored by 谢森's avatar 谢森

<dev> 判断时间段内无数据

parent 0cf4e4e5
......@@ -95,7 +95,7 @@ public class HdfsLogDesensitization implements Serializable {
this.hdfsUri = String.valueOf(conf.get(ConfigConstants.HDFS_URI)).trim();
this.hdfsUser = String.valueOf(conf.get(ConfigConstants.HDFS_USER)).trim();
this.hdfsSrc = hdfsUri + String.valueOf(conf.get(ConfigConstants.HDFS_SRC)).trim();
this.hdfsDest = hdfsUri + String.valueOf(conf.get(ConfigConstants.HDFS_DEST)).trim();
this.hdfsDest = hdfsUri + String.valueOf(conf.get(ConfigConstants.HDFS_DEST)).trim();
this.core = String.valueOf(conf.get(ConfigConstants.CORE)).trim();
this.startTime = String.valueOf(conf.get(ConfigConstants.START_TIME));
this.endTime = String.valueOf(conf.get(ConfigConstants.END_TIME));
......@@ -276,28 +276,33 @@ public class HdfsLogDesensitization implements Serializable {
FileSystem fileSystem = null;
List<String> betweenDate = DateUtil.getBetweenDate(startTime, endTime);
List<String> dateList = DateUtil.date2date(betweenDate);
try {
fileSystem = FileSystem.get(new URI(hdfsUri), conf, hdfsUser);
for (String item : dateList) {
path = hdfsSrc + item;
List<String> hdfsLogFiles = getHdfsLogFilesByPath(fileSystem, path);
logFiles.addAll(hdfsLogFiles);
}
} catch (IOException e) {
log.error(String.valueOf(e));
} catch (InterruptedException e) {
log.error(String.valueOf(e));
} catch (URISyntaxException e) {
log.error(String.valueOf(e));
} finally {
if (null != fileSystem) {
try {
fileSystem.close();
} catch (IOException e) {
log.error(String.valueOf(e));
if (dateList.size() > 0) {
try {
fileSystem = FileSystem.get(new URI(hdfsUri), conf, hdfsUser);
for (String item : dateList) {
path = hdfsSrc + item;
List<String> hdfsLogFiles = getHdfsLogFilesByPath(fileSystem, path);
logFiles.addAll(hdfsLogFiles);
}
} catch (IOException e) {
log.error(String.valueOf(e));
} catch (InterruptedException e) {
log.error(String.valueOf(e));
} catch (URISyntaxException e) {
log.error(String.valueOf(e));
} finally {
if (null != fileSystem) {
try {
fileSystem.close();
} catch (IOException e) {
log.error(String.valueOf(e));
}
}
}
} else {
log.warn("{} -- {} 时间段内无数据,请注意时间范围", startTime, endTime);
}
return logFiles;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment