* * Licensed under the Apache License, Version 2.0 (the "License");\r
* * you may not use this file except in compliance with the License.\r
* * You may obtain a copy of the License at\r
- * * \r
+ * *\r
* * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
+ * *\r
* * Unless required by applicable law or agreed to in writing, software\r
* * distributed under the License is distributed on an "AS IS" BASIS,\r
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
\r
/**\r
* This class provides a {@link TimerTask} that purges old logfiles\r
- * (older than the number of days specified by the com.att.research.datarouter.provserver.logretention property).\r
+ * (older than the number of days specified by the org.onap.dmaap.datarouter.provserver.logretention property).\r
+ *\r
* @author Robert Eby\r
* @version $Id: PurgeLogDirTask.java,v 1.2 2013/07/05 13:48:05 eby Exp $\r
*/\r
public class PurgeLogDirTask extends TimerTask {\r
- private static final long ONEDAY = 86400000L;\r
+ private static final long ONEDAY = 86400000L;\r
+\r
+ private final String logdir;\r
+ private final long interval;\r
\r
- private final String logdir;\r
- private final long interval;\r
+ public PurgeLogDirTask() {\r
+ Properties p = (new DB()).getProperties();\r
+ logdir = p.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir");\r
+ String s = p.getProperty("org.onap.dmaap.datarouter.provserver.logretention", "30");\r
+ long n = 30;\r
+ try {\r
+ n = Long.parseLong(s);\r
+ } catch (NumberFormatException e) {\r
+ // ignore\r
+ }\r
+ interval = n * ONEDAY;\r
+ }\r
\r
- public PurgeLogDirTask() {\r
- Properties p = (new DB()).getProperties();\r
- logdir = p.getProperty("com.att.research.datarouter.provserver.accesslog.dir");\r
- String s = p.getProperty("com.att.research.datarouter.provserver.logretention", "30");\r
- long n = 30;\r
- try {\r
- n = Long.parseLong(s);\r
- } catch (NumberFormatException e) {\r
- // ignore\r
- }\r
- interval = n * ONEDAY;\r
- }\r
- @Override\r
- public void run() {\r
- try {\r
- File dir = new File(logdir);\r
- if (dir.exists()) {\r
- long exptime = System.currentTimeMillis() - interval;\r
- for (File logfile : dir.listFiles()) {\r
- if (logfile.lastModified() < exptime)\r
- logfile.delete();\r
- }\r
- }\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- }\r
+ @Override\r
+ public void run() {\r
+ try {\r
+ File dir = new File(logdir);\r
+ if (dir.exists()) {\r
+ long exptime = System.currentTimeMillis() - interval;\r
+ for (File logfile : dir.listFiles()) {\r
+ if (logfile.lastModified() < exptime)\r
+ logfile.delete();\r
+ }\r
+ }\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
}\r