X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Fbeans%2FLogRecord.java;h=b26e551b3a66e13977c665f212ad08e1696454fb;hb=8280a5e1a6cfd155edfafe882439b8c04c6a4509;hp=51c162ef8fd3c7b5ffeeb17ab882f3caae896793;hpb=7fdcc68d546fe95a7863de512bcda09f01e5d39e;p=dmaap%2Fdatarouter.git diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java index 51c162ef..b26e551b 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java @@ -57,44 +57,13 @@ public class LogRecord extends BaseLogRecord { * @throws IOException in case of I/O error */ private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog"); - - /** - * Get Log Records. - * @param os outputstream - * @param bs RLEBitSet object - * @throws IOException in case of I/O error - */ - public static void printLogRecords(OutputStream os, RLEBitSet bs) throws IOException { - final String sql = "select * from LOG_RECORDS where RECORD_ID >= ? AND RECORD_ID <= ?"; - DB db = new DB(); - try (Connection conn = db.getConnection()) { - Iterator iter = bs.getRangeIterator(); - try (PreparedStatement ps = conn.prepareStatement(sql)) { - while (iter.hasNext()) { - Long[] nxt = iter.next(); - ps.setLong(1, nxt[0]); - ps.setLong(2, nxt[1]); - try (ResultSet rs = ps.executeQuery()) { - while (rs.next()) { - LogRecord lr = new LogRecord(rs); - os.write(lr.toString().getBytes()); - } - ps.clearParameters(); - } - } - } - } catch (SQLException e) { - intlogger.error("PROV0001 printLogRecords: " + e.getMessage(), e); - } - } - private final String type; - private final String feedFileid; + private final String feedFileID; private final String remoteAddr; private final String user; private final int status; - private final int subid; - private final String fileid; + private final int subID; + private final String fileID; private final int result; private final int attempts; private final String reason; @@ -110,13 +79,13 @@ public class LogRecord extends BaseLogRecord { public LogRecord(ResultSet rs) throws SQLException { super(rs); this.type = rs.getString("TYPE"); - this.feedFileid = rs.getString("FEED_FILEID"); + this.feedFileID = rs.getString("FEED_FILEID"); this.remoteAddr = rs.getString("REMOTE_ADDR"); this.user = rs.getString("USER"); this.status = rs.getInt("STATUS"); - this.subid = rs.getInt("DELIVERY_SUBID"); - this.fileid = rs.getString("DELIVERY_FILEID"); + this.subID = rs.getInt("DELIVERY_SUBID"); + this.fileID = rs.getString("DELIVERY_FILEID"); this.result = rs.getInt("RESULT"); this.attempts = rs.getInt("ATTEMPTS"); @@ -135,13 +104,13 @@ public class LogRecord extends BaseLogRecord { public LogRecord(String[] pp) throws ParseException { super(pp); this.type = pp[8]; - this.feedFileid = pp[9]; + this.feedFileID = pp[9]; this.remoteAddr = pp[10]; this.user = pp[11]; this.status = Integer.parseInt(pp[12]); - this.subid = Integer.parseInt(pp[13]); - this.fileid = pp[14]; + this.subID = Integer.parseInt(pp[13]); + this.fileID = pp[14]; this.result = Integer.parseInt(pp[15]); this.attempts = Integer.parseInt(pp[16]); @@ -152,6 +121,36 @@ public class LogRecord extends BaseLogRecord { this.fileName = pp[20]; } + /** + * Get Log Records. + * @param os outputstream + * @param bs RLEBitSet object + * @throws IOException in case of I/O error + */ + public static void printLogRecords(OutputStream os, RLEBitSet bs) throws IOException { + final String sql = "select * from LOG_RECORDS where RECORD_ID >= ? AND RECORD_ID <= ?"; + DB db = new DB(); + try (Connection conn = db.getConnection()) { + Iterator iter = bs.getRangeIterator(); + try (PreparedStatement ps = conn.prepareStatement(sql)) { + while (iter.hasNext()) { + Long[] nxt = iter.next(); + ps.setLong(1, nxt[0]); + ps.setLong(2, nxt[1]); + try (ResultSet rs = ps.executeQuery()) { + while (rs.next()) { + LogRecord lr = new LogRecord(rs); + os.write(lr.toString().getBytes()); + } + ps.clearParameters(); + } + } + } + } catch (SQLException e) { + intlogger.error("PROV0001 printLogRecords: " + e.getMessage(), e); + } + } + public long getRecordId() { return recordId; } @@ -168,12 +167,12 @@ public class LogRecord extends BaseLogRecord { + getContentType() + "|" + getContentLength() + "|" + type + "|" - + feedFileid + "|" + + feedFileID + "|" + remoteAddr + "|" + user + "|" + status + "|" - + subid + "|" - + fileid + "|" + + subID + "|" + + fileID + "|" + result + "|" + attempts + "|" + reason + "|" @@ -187,7 +186,7 @@ public class LogRecord extends BaseLogRecord { ps.setString(1, type); super.load(ps); // loads fields 2-8 if (type.equals("pub")) { - ps.setString(9, feedFileid); + ps.setString(9, feedFileID); ps.setString(10, remoteAddr); ps.setString(11, user); ps.setInt(12, status); @@ -204,8 +203,8 @@ public class LogRecord extends BaseLogRecord { ps.setNull(10, Types.VARCHAR); ps.setString(11, user); ps.setNull(12, Types.INTEGER); - ps.setInt(13, subid); - ps.setString(14, fileid); + ps.setInt(13, subID); + ps.setString(14, fileID); ps.setInt(15, result); ps.setNull(16, Types.INTEGER); ps.setNull(17, Types.VARCHAR); @@ -217,8 +216,8 @@ public class LogRecord extends BaseLogRecord { ps.setNull(10, Types.VARCHAR); ps.setNull(11, Types.VARCHAR); ps.setNull(12, Types.INTEGER); - ps.setInt(13, subid); - ps.setString(14, fileid); + ps.setInt(13, subID); + ps.setString(14, fileID); ps.setNull(15, Types.INTEGER); ps.setInt(16, attempts); ps.setString(17, reason); @@ -226,7 +225,7 @@ public class LogRecord extends BaseLogRecord { ps.setNull(19, Types.BIGINT); ps.setString(20, fileName); } else if (type.equals("pbf")) { - ps.setString(9, feedFileid); + ps.setString(9, feedFileID); ps.setString(10, remoteAddr); ps.setString(11, user); ps.setNull(12, Types.INTEGER); @@ -243,7 +242,7 @@ public class LogRecord extends BaseLogRecord { ps.setNull(10, Types.VARCHAR); ps.setNull(11, Types.VARCHAR); ps.setNull(12, Types.INTEGER); - ps.setInt(13, subid); + ps.setInt(13, subID); ps.setNull(14, Types.VARCHAR); ps.setNull(15, Types.INTEGER); ps.setNull(16, Types.INTEGER);