******************************************************************************/
package org.onap.dmaap.datarouter.node;
-import java.util.*;
-import java.util.regex.*;
-import java.io.*;
-import java.nio.file.*;
-import java.text.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.TimerTask;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Cleanup of old log files.
* <p>
- * Periodically scan the log directory for log files that are older than
- * the log file retention interval, and delete them. In a future release,
- * This class will also be responsible for uploading events logs to the
- * log server to support the log query APIs.
+ * Periodically scan the log directory for log files that are older than the log file retention interval, and delete
+ * them. In a future release, This class will also be responsible for uploading events logs to the log server to
+ * support the log query APIs.
*/
public class LogManager extends TimerTask {
+
private NodeConfigManager config;
private Matcher isnodelog;
private Matcher iseventlog;
private String logdir;
private class Uploader extends Thread implements DeliveryQueueHelper {
+
public long getInitFailureTimer() {
return (10000L);
}
+ public long getWaitForFileProcessFailureTimer() {
+ return (600000L);
+ }
+
public double getFailureBackoff() {
return (2.0);
}
return (86400000);
}
- public String getDestURL(DestInfo dest, String fileid) {
+ public String getDestURL(DestInfo destinationInfo, String fileid) {
return (config.getEventLogUrl());
}
- public void handleUnreachable(DestInfo dest) {
+ public void handleUnreachable(DestInfo destinationInfo) {
}
- public boolean handleRedirection(DestInfo dest, String location, String fileid) {
+ public boolean handleRedirection(DestInfo destinationInfo, String location, String fileid) {
return (false);
}
private DeliveryQueue dq;
public Uploader() {
- dq = new DeliveryQueue(this, new DestInfo("LogUpload", uploaddir, null, null, null, config.getMyName(), config.getMyAuth(), false, false));
+ dq = new DeliveryQueue(this,
+ new DestInfo("LogUpload", uploaddir, null, null, null, config.getMyName(), config.getMyAuth(), false, false, false, false, false));
setDaemon(true);
setName("Log Uploader");
start();
f.delete();
}
}
- try {
+ try (Writer w = new FileWriter(uploaddir + "/.lastqueued")) {
(new File(uploaddir + "/.meta")).delete();
- Writer w = new FileWriter(uploaddir + "/.lastqueued");
w.write(lastqueued + "\n");
- w.close();
} catch (Exception e) {
}
}
/**
* Construct a log manager
* <p>
- * The log manager will check for expired log files every 5 minutes
- * at 20 seconds after the 5 minute boundary. (Actually, the
- * interval is the event log rollover interval, which
- * defaults to 5 minutes).
+ * The log manager will check for expired log files every 5 minutes at 20 seconds after the 5 minute boundary.
+ * (Actually, the interval is the event log rollover interval, which defaults to 5 minutes).
*/
public LogManager(NodeConfigManager config) {
this.config = config;
uploaddir = logdir + "/.spool";
(new File(uploaddir)).mkdirs();
long now = System.currentTimeMillis();
- long intvl = StatusLog.parseInterval(config.getEventLogInterval(), 300000);
+ long intvl = StatusLog.parseInterval(config.getEventLogInterval(), 30000);
long when = now - now % intvl + intvl + 20000L;
config.getTimer().scheduleAtFixedRate(this, when - now, intvl);
worker = new Uploader();