DB utils update for db initialization
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / utils / LogfileLoader.java
index 830e21c..45b8788 100644 (file)
@@ -59,7 +59,7 @@ import org.onap.dmaap.datarouter.provisioning.beans.PublishRecord;
 \r
 /**\r
  * This class provides methods that run in a separate thread, in order to process logfiles uploaded into the spooldir.\r
- * These logfiles are loaded into the MySQL LOG_RECORDS table. In a running provisioning server, there should only be\r
+ * These logfiles are loaded into the MariaDB LOG_RECORDS table. In a running provisioning server, there should only be\r
  * two places where records can be loaded into this table; here, and in the method DB.retroFit4() which may be run at\r
  * startup to load the old (1.0) style log tables into LOG_RECORDS;\r
  * <p>This method maintains an {@link RLEBitSet} which can be used to easily see what records are presently in the\r
@@ -148,7 +148,7 @@ public class LogfileLoader extends Thread {
        }\r
        /**\r
         * Run continuously to look for new logfiles in the spool directory and import them into the DB.\r
-        * The spool is checked once per second.  If free space on the MySQL filesystem falls below\r
+        * The spool is checked once per second.  If free space on the MariaDB filesystem falls below\r
         * REQUIRED_FREE_PCT (normally 20%) then the oldest logfile entries are removed and the LOG_RECORDS\r
         * table is compacted until free space rises above the threshold.\r
         */\r
@@ -361,72 +361,7 @@ public class LogfileLoader extends Thread {
                        db.release(conn);\r
                }\r
        }\r
-// OLD CODE - commented here for historical purposes\r
-//\r
-//     private boolean pruneRecordsOldAlgorithm() {\r
-//             // Determine space available -- available space must be at least 20% under /opt/app/mysql\r
-//             int pct = getFreePercentage();\r
-//             boolean did1 = false;\r
-//             while (pct < REQUIRED_FREE_PCT) {\r
-//                     logger.info("PROV8008: Free space is " + pct + "% - removing old log entries");\r
-//                     boolean didit = removeOldestEntries();\r
-//                     pct = didit ? getFreePercentage() : 100; // don't loop endlessly\r
-//                     did1 |= didit;\r
-//             }\r
-//             return did1;\r
-//     }\r
-//     private int getFreePercentage() {\r
-//             FileSystem fs = (Paths.get("/opt/app/mysql")).getFileSystem();\r
-//             long total = 0;\r
-//             long avail = 0;\r
-//             try {\r
-//                     for (FileStore store : fs.getFileStores()) {\r
-//                             total += store.getTotalSpace();\r
-//                             avail += store.getUsableSpace();\r
-//                     }\r
-//             } catch (IOException e) {\r
-//             }\r
-//             try { fs.close(); } catch (Exception e) { }\r
-//             return (int)((avail * 100) / total);\r
-//     }\r
-//     private boolean removeOldestEntries() {\r
-//             // Remove the last days worth of entries\r
-//             Connection conn = null;\r
-//             try {\r
-//                     conn = db.getConnection();\r
-//                     Statement stmt = conn.createStatement();\r
-//                     ResultSet rs = stmt.executeQuery("select min(event_time) as MIN from LOG_RECORDS");\r
-//                     if (rs != null) {\r
-//                             if (rs.next()) {\r
-//                                     // Compute the end of the first day of logs\r
-//                                     long first = rs.getLong("MIN");\r
-//                                     Calendar cal = new GregorianCalendar();\r
-//                                     cal.setTime(new Date(first));\r
-//                                     cal.add(Calendar.DAY_OF_YEAR, 1);\r
-//                                     cal.set(Calendar.HOUR_OF_DAY, 0);\r
-//                                     cal.set(Calendar.MINUTE, 0);\r
-//                                     cal.set(Calendar.SECOND, 0);\r
-//                                     cal.set(Calendar.MILLISECOND, 0);\r
-//                                     if (!stmt.execute("delete from LOG_RECORDS where event_time < " + cal.getTimeInMillis())) {\r
-//                                             int count = stmt.getUpdateCount();\r
-//                                             logger.info("PROV0009: Removed "+count+" old log entries.");\r
-//                                             stmt.execute("OPTIMIZE TABLE LOG_RECORDS");\r
-//                                     }\r
-//                                     rs.close();\r
-//                                     stmt.close();\r
-//                                     return true;\r
-//                             }\r
-//                             rs.close();\r
-//                     }\r
-//                     stmt.close();\r
-//             } catch (SQLException e) {\r
-//                     System.err.println(e);\r
-//                     e.printStackTrace();\r
-//             } finally {\r
-//                     db.release(conn);\r
-//             }\r
-//             return false;\r
-//     }\r
+\r
        @SuppressWarnings("resource")\r
        private int[] process(File f) {\r
                int ok = 0, total = 0;\r