Code Review
/
dmaap
/
datarouter.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Code style cleanup for prov authz and beans
[dmaap/datarouter.git]
/
datarouter-prov
/
src
/
main
/
java
/
org
/
onap
/
dmaap
/
datarouter
/
provisioning
/
beans
/
LogRecord.java
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
cbddbf4
..
51c162e
100644
(file)
--- 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
@@
-24,6
+24,8
@@
\r
package org.onap.dmaap.datarouter.provisioning.beans;
\r
\r
\r
package org.onap.dmaap.datarouter.provisioning.beans;
\r
\r
+import com.att.eelf.configuration.EELFLogger;
\r
+import com.att.eelf.configuration.EELFManager;
\r
import java.io.IOException;
\r
import java.io.OutputStream;
\r
import java.sql.Connection;
\r
import java.io.IOException;
\r
import java.io.OutputStream;
\r
import java.sql.Connection;
\r
@@
-34,11
+36,10
@@
import java.sql.Types;
import java.text.ParseException;
\r
import java.util.Iterator;
\r
\r
import java.text.ParseException;
\r
import java.util.Iterator;
\r
\r
-import com.att.eelf.configuration.EELFLogger;
\r
-import com.att.eelf.configuration.EELFManager;
\r
import org.onap.dmaap.datarouter.provisioning.utils.DB;
\r
import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
\r
\r
import org.onap.dmaap.datarouter.provisioning.utils.DB;
\r
import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
\r
\r
+
\r
/**
\r
* The representation of a Log Record, as retrieved from the DB. Since this record format is only used to replicate
\r
* between provisioning servers, it is very bare-bones; e.g. there are no field setters and only 1 getter.
\r
/**
\r
* The representation of a Log Record, as retrieved from the DB. Since this record format is only used to replicate
\r
* between provisioning servers, it is very bare-bones; e.g. there are no field setters and only 1 getter.
\r
@@
-53,10
+54,16
@@
public class LogRecord extends BaseLogRecord {
*
\r
* @param os the {@link OutputStream} to print the records on
\r
* @param bs the {@link RLEBitSet} listing the record IDs to print
\r
*
\r
* @param os the {@link OutputStream} to print the records on
\r
* @param bs the {@link RLEBitSet} listing the record IDs to print
\r
- * @throws IOException
\r
+ * @throws IOException
in case of I/O error
\r
*/
\r
private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog");
\r
\r
*/
\r
private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog");
\r
\r
+ /**
\r
+ * Get Log Records.
\r
+ * @param os outputstream
\r
+ * @param bs RLEBitSet object
\r
+ * @throws IOException in case of I/O error
\r
+ */
\r
public static void printLogRecords(OutputStream os, RLEBitSet bs) throws IOException {
\r
final String sql = "select * from LOG_RECORDS where RECORD_ID >= ? AND RECORD_ID <= ?";
\r
DB db = new DB();
\r
public static void printLogRecords(OutputStream os, RLEBitSet bs) throws IOException {
\r
final String sql = "select * from LOG_RECORDS where RECORD_ID >= ? AND RECORD_ID <= ?";
\r
DB db = new DB();
\r
@@
-64,9
+71,9
@@
public class LogRecord extends BaseLogRecord {
Iterator<Long[]> iter = bs.getRangeIterator();
\r
try (PreparedStatement ps = conn.prepareStatement(sql)) {
\r
while (iter.hasNext()) {
\r
Iterator<Long[]> iter = bs.getRangeIterator();
\r
try (PreparedStatement ps = conn.prepareStatement(sql)) {
\r
while (iter.hasNext()) {
\r
- Long[] n = iter.next();
\r
- ps.setLong(1, n[0]);
\r
- ps.setLong(2, n[1]);
\r
+ Long[] n
xt
= iter.next();
\r
+ ps.setLong(1, n
xt
[0]);
\r
+ ps.setLong(2, n
xt
[1]);
\r
try (ResultSet rs = ps.executeQuery()) {
\r
while (rs.next()) {
\r
LogRecord lr = new LogRecord(rs);
\r
try (ResultSet rs = ps.executeQuery()) {
\r
while (rs.next()) {
\r
LogRecord lr = new LogRecord(rs);
\r
@@
-91,10
+98,15
@@
public class LogRecord extends BaseLogRecord {
private final int result;
\r
private final int attempts;
\r
private final String reason;
\r
private final int result;
\r
private final int attempts;
\r
private final String reason;
\r
- private final long record
_i
d;
\r
+ private final long record
I
d;
\r
private final long clength2;
\r
private final String fileName;
\r
\r
private final long clength2;
\r
private final String fileName;
\r
\r
+ /**
\r
+ * LogRecord constructor.
\r
+ * @param rs ResultSet from SQL statement
\r
+ * @throws SQLException in case of SQL error
\r
+ */
\r
public LogRecord(ResultSet rs) throws SQLException {
\r
super(rs);
\r
this.type = rs.getString("TYPE");
\r
public LogRecord(ResultSet rs) throws SQLException {
\r
super(rs);
\r
this.type = rs.getString("TYPE");
\r
@@
-110,11
+122,16
@@
public class LogRecord extends BaseLogRecord {
this.attempts = rs.getInt("ATTEMPTS");
\r
this.reason = rs.getString("REASON");
\r
\r
this.attempts = rs.getInt("ATTEMPTS");
\r
this.reason = rs.getString("REASON");
\r
\r
- this.record
_i
d = rs.getLong("RECORD_ID");
\r
+ this.record
I
d = rs.getLong("RECORD_ID");
\r
this.clength2 = rs.getLong("CONTENT_LENGTH_2");
\r
this.fileName = rs.getString("FILENAME");
\r
}
\r
\r
this.clength2 = rs.getLong("CONTENT_LENGTH_2");
\r
this.fileName = rs.getString("FILENAME");
\r
}
\r
\r
+ /**
\r
+ * LogRecord Constructor from string array.
\r
+ * @param pp string array of LogRecord attributes
\r
+ * @throws ParseException in case of parse error
\r
+ */
\r
public LogRecord(String[] pp) throws ParseException {
\r
super(pp);
\r
this.type = pp[8];
\r
public LogRecord(String[] pp) throws ParseException {
\r
super(pp);
\r
this.type = pp[8];
\r
@@
-130,13
+147,13
@@
public class LogRecord extends BaseLogRecord {
this.attempts = Integer.parseInt(pp[16]);
\r
this.reason = pp[17];
\r
\r
this.attempts = Integer.parseInt(pp[16]);
\r
this.reason = pp[17];
\r
\r
- this.record
_i
d = Long.parseLong(pp[18]);
\r
+ this.record
I
d = Long.parseLong(pp[18]);
\r
this.clength2 = (pp.length == 21) ? Long.parseLong(pp[19]) : 0;
\r
this.fileName = pp[20];
\r
}
\r
\r
public long getRecordId() {
\r
this.clength2 = (pp.length == 21) ? Long.parseLong(pp[19]) : 0;
\r
this.fileName = pp[20];
\r
}
\r
\r
public long getRecordId() {
\r
- return record
_i
d;
\r
+ return record
I
d;
\r
}
\r
\r
@Override
\r
}
\r
\r
@Override
\r
@@
-160,7
+177,7
@@
public class LogRecord extends BaseLogRecord {
+ result + "|"
\r
+ attempts + "|"
\r
+ reason + "|"
\r
+ result + "|"
\r
+ attempts + "|"
\r
+ reason + "|"
\r
- + record
_i
d + "|"
\r
+ + record
I
d + "|"
\r
+ clength2
\r
+ "\n";
\r
}
\r
+ clength2
\r
+ "\n";
\r
}
\r
@@
-179,7
+196,7
@@
public class LogRecord extends BaseLogRecord {
ps.setNull(15, Types.INTEGER);
\r
ps.setNull(16, Types.INTEGER);
\r
ps.setNull(17, Types.VARCHAR);
\r
ps.setNull(15, Types.INTEGER);
\r
ps.setNull(16, Types.INTEGER);
\r
ps.setNull(17, Types.VARCHAR);
\r
- ps.setLong(18, record
_i
d);
\r
+ ps.setLong(18, record
I
d);
\r
ps.setNull(19, Types.BIGINT);
\r
ps.setString(20, fileName);
\r
} else if (type.equals("del")) {
\r
ps.setNull(19, Types.BIGINT);
\r
ps.setString(20, fileName);
\r
} else if (type.equals("del")) {
\r
@@
-192,7
+209,7
@@
public class LogRecord extends BaseLogRecord {
ps.setInt(15, result);
\r
ps.setNull(16, Types.INTEGER);
\r
ps.setNull(17, Types.VARCHAR);
\r
ps.setInt(15, result);
\r
ps.setNull(16, Types.INTEGER);
\r
ps.setNull(17, Types.VARCHAR);
\r
- ps.setLong(18, record
_i
d);
\r
+ ps.setLong(18, record
I
d);
\r
ps.setNull(19, Types.BIGINT);
\r
ps.setString(20, fileName);
\r
} else if (type.equals("exp")) {
\r
ps.setNull(19, Types.BIGINT);
\r
ps.setString(20, fileName);
\r
} else if (type.equals("exp")) {
\r
@@
-205,7
+222,7
@@
public class LogRecord extends BaseLogRecord {
ps.setNull(15, Types.INTEGER);
\r
ps.setInt(16, attempts);
\r
ps.setString(17, reason);
\r
ps.setNull(15, Types.INTEGER);
\r
ps.setInt(16, attempts);
\r
ps.setString(17, reason);
\r
- ps.setLong(18, record
_i
d);
\r
+ ps.setLong(18, record
I
d);
\r
ps.setNull(19, Types.BIGINT);
\r
ps.setString(20, fileName);
\r
} else if (type.equals("pbf")) {
\r
ps.setNull(19, Types.BIGINT);
\r
ps.setString(20, fileName);
\r
} else if (type.equals("pbf")) {
\r
@@
-218,7
+235,7
@@
public class LogRecord extends BaseLogRecord {
ps.setNull(15, Types.INTEGER);
\r
ps.setNull(16, Types.INTEGER);
\r
ps.setNull(17, Types.VARCHAR);
\r
ps.setNull(15, Types.INTEGER);
\r
ps.setNull(16, Types.INTEGER);
\r
ps.setNull(17, Types.VARCHAR);
\r
- ps.setLong(18, record
_i
d);
\r
+ ps.setLong(18, record
I
d);
\r
ps.setLong(19, clength2);
\r
ps.setString(20, fileName);
\r
} else if (type.equals("dlx")) {
\r
ps.setLong(19, clength2);
\r
ps.setString(20, fileName);
\r
} else if (type.equals("dlx")) {
\r
@@
-231,13
+248,13
@@
public class LogRecord extends BaseLogRecord {
ps.setNull(15, Types.INTEGER);
\r
ps.setNull(16, Types.INTEGER);
\r
ps.setNull(17, Types.VARCHAR);
\r
ps.setNull(15, Types.INTEGER);
\r
ps.setNull(16, Types.INTEGER);
\r
ps.setNull(17, Types.VARCHAR);
\r
- ps.setLong(18, record
_i
d);
\r
+ ps.setLong(18, record
I
d);
\r
ps.setLong(19, clength2);
\r
ps.setString(20, fileName);
\r
}
\r
}
\r
\r
ps.setLong(19, clength2);
\r
ps.setString(20, fileName);
\r
}
\r
}
\r
\r
- public static void main(String[] a) throws IOException {
\r
- LogRecord.printLogRecords(System.out, new RLEBitSet(a[0]));
\r
+ public static void main(String[] a
rgs
) throws IOException {
\r
+ LogRecord.printLogRecords(System.out, new RLEBitSet(a
rgs
[0]));
\r
}
\r
}
\r
}
\r
}
\r