mirror of
https://github.com/ctripcorp/zeus.git
synced 2024-09-21 08:06:08 +08:00
avoid constructor ex
This commit is contained in:
parent
edf7650359
commit
65c47c04bf
|
@ -26,7 +26,7 @@ public class AccessLogStatsAnalyzer implements LogStatsAnalyzer {
|
|||
private final LogTracker logTracker;
|
||||
private final LogParser logParser;
|
||||
|
||||
public AccessLogStatsAnalyzer() throws IOException {
|
||||
public AccessLogStatsAnalyzer() {
|
||||
this(new LogStatsAnalyzerConfigBuilder()
|
||||
.setLogFormat(new AccessLogLineFormat(AccessLogFormat).generate())
|
||||
.setLogFilename("/opt/logs/nginx/access.log")
|
||||
|
@ -84,7 +84,7 @@ public class AccessLogStatsAnalyzer implements LogStatsAnalyzer {
|
|||
private boolean allowTracking;
|
||||
private int trackerReadSize;
|
||||
|
||||
public LogStatsAnalyzerConfigBuilder setLogFilename(String logFilename) throws IOException {
|
||||
public LogStatsAnalyzerConfigBuilder setLogFilename(String logFilename) {
|
||||
this.logFilename = logFilename;
|
||||
return this;
|
||||
}
|
||||
|
@ -105,9 +105,8 @@ public class AccessLogStatsAnalyzer implements LogStatsAnalyzer {
|
|||
return this;
|
||||
}
|
||||
|
||||
public LogStatsAnalyzerConfig build() throws IOException {
|
||||
public LogStatsAnalyzerConfig build() {
|
||||
File f = new File(logFilename);
|
||||
if (f.exists() && f.isFile()) {
|
||||
String rootDir = f.getAbsoluteFile().getParentFile().getAbsolutePath();
|
||||
LogTrackerStrategy strategy = new LogTrackerStrategy()
|
||||
.setAllowLogRotate(true)
|
||||
|
@ -119,9 +118,6 @@ public class AccessLogStatsAnalyzer implements LogStatsAnalyzer {
|
|||
return new LogStatsAnalyzerConfig()
|
||||
.addFormat(logFormat)
|
||||
.setLogTracker(new AccessLogTracker(strategy));
|
||||
} else {
|
||||
throw new IOException(logFilename + " is not a file or does not exist.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,9 @@ public class AccessLogTracker implements LogTracker {
|
|||
|
||||
@Override
|
||||
public void start() throws IOException {
|
||||
if (!new File(getLogFilename()).exists()) {
|
||||
throw new IOException(logFilename + " is not a file or does not exist.");
|
||||
}
|
||||
raf = new RandomAccessFile(getLogFilename(), "r");
|
||||
fileChannel = raf.getChannel();
|
||||
if (allowTracking) {
|
||||
|
|
Loading…
Reference in a new issue