X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Futils%2FLogfileLoader.java;h=ab1a3a78eb72d1ee39a68820d7f443600fb4cf82;hb=5da50e90e6c78700d48d7468849d4a1599a249b3;hp=8975f1612f4f96203f07cf6b490390e2b904951d;hpb=ac12c63cc36197e569fba1c54e45b1b999384321;p=dmaap%2Fdatarouter.git diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LogfileLoader.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LogfileLoader.java index 8975f161..ab1a3a78 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LogfileLoader.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LogfileLoader.java @@ -100,7 +100,7 @@ public class LogfileLoader extends Thread { /** * The PreparedStatement which is loaded by a Loadable. */ - public static final String INSERT_SQL = "insert into LOG_RECORDS values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + public static final String INSERT_SQL = "insert into LOG_RECORDS values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; /** * Each server can assign this many IDs */ @@ -188,6 +188,7 @@ public class LogfileLoader extends Thread { try { Thread.sleep(1000L); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); } idle = false; } else { @@ -213,7 +214,6 @@ public class LogfileLoader extends Thread { } } catch (Exception e) { logger.warn("PROV0020: Caught exception in LogfileLoader: " + e); - e.printStackTrace(); } } } @@ -274,7 +274,7 @@ public class LogfileLoader extends Thread { } } catch (SQLException e) { System.err.println(e); - e.printStackTrace(); + logger.error(e); } finally { db.release(conn); } @@ -296,7 +296,7 @@ public class LogfileLoader extends Thread { } } catch (SQLException e) { System.err.println(e); - e.printStackTrace(); + logger.error(e); } finally { db.release(conn); } @@ -321,7 +321,7 @@ public class LogfileLoader extends Thread { } } catch (SQLException e) { System.err.println(e); - e.printStackTrace(); + logger.error(e); } finally { db.release(conn); } @@ -332,26 +332,25 @@ public class LogfileLoader extends Thread { Connection conn = null; try { conn = db.getConnection(); - Statement stmt = conn.createStatement(); - // Build a bitset of all records in the LOG_RECORDS table - // We need to run this SELECT in stages, because otherwise we run out of memory! RLEBitSet nbs = new RLEBitSet(); - final long stepsize = 6000000L; - boolean go_again = true; - for (long i = 0; go_again; i += stepsize) { - String sql = String.format("select RECORD_ID from LOG_RECORDS LIMIT %d,%d", i, stepsize); - try(ResultSet rs = stmt.executeQuery(sql)) { - go_again = false; - while (rs.next()) { - long n = rs.getLong("RECORD_ID"); - nbs.set(n); - go_again = true; + try(Statement stmt = conn.createStatement()) { + // Build a bitset of all records in the LOG_RECORDS table + // We need to run this SELECT in stages, because otherwise we run out of memory! + final long stepsize = 6000000L; + boolean go_again = true; + for (long i = 0; go_again; i += stepsize) { + String sql = String.format("select RECORD_ID from LOG_RECORDS LIMIT %d,%d", i, stepsize); + try (ResultSet rs = stmt.executeQuery(sql)) { + go_again = false; + while (rs.next()) { + long n = rs.getLong("RECORD_ID"); + nbs.set(n); + go_again = true; + } } } } - stmt.close(); seq_set = nbs; - // Compare with the range for this server // Determine the next ID for this set of record IDs RLEBitSet tbs = (RLEBitSet) nbs.clone(); @@ -376,7 +375,7 @@ public class LogfileLoader extends Thread { logger.debug(String.format("initializeNextid, next ID is %d (%x)", nextid, nextid)); } catch (SQLException e) { System.err.println(e); - e.printStackTrace(); + logger.error(e); } finally { db.release(conn); } @@ -417,19 +416,15 @@ public class LogfileLoader extends Thread { } catch (SQLException e) { logger.warn("PROV8003 Invalid value in record: " + line); logger.debug(e); - e.printStackTrace(); } catch (NumberFormatException e) { logger.warn("PROV8004 Invalid number in record: " + line); logger.debug(e); - e.printStackTrace(); } catch (ParseException e) { logger.warn("PROV8005 Invalid date in record: " + line); logger.debug(e); - e.printStackTrace(); } catch (Exception e) { logger.warn("PROV8006 Invalid pattern in record: " + line); logger.debug(e); - e.printStackTrace(); } total++; }