RECORD_ID BIGINT UNSIGNED NOT NULL PRIMARY KEY, /* unique ID for this record */
CONTENT_LENGTH_2 BIGINT,
+ FILENAME VARCHAR(256), /* Name of the file being published on DR */
INDEX (FEEDID) USING BTREE,
INDEX (DELIVERY_SUBID) USING BTREE,
('DELIVERY_MAX_AGE', '86400'),
('DELIVERY_MAX_RETRY_INTERVAL', '3600'),
('DELIVERY_RETRY_RATIO', '2'),
- ('LOGROLL_INTERVAL', '300'),
+ ('LOGROLL_INTERVAL', '30'),
('PROV_AUTH_ADDRESSES', 'dmaap-dr-prov|dmaap-dr-node'),
('PROV_AUTH_SUBJECTS', ''),
('PROV_MAXFEED_COUNT', '10000'),
uploaddir = logdir + "/.spool";
(new File(uploaddir)).mkdirs();
long now = System.currentTimeMillis();
- long intvl = StatusLog.parseInterval(config.getEventLogInterval(), 300000);
+ long intvl = StatusLog.parseInterval(config.getEventLogInterval(), 30000);
long when = now - now % intvl + intvl + 20000L;
config.getTimer().scheduleAtFixedRate(this, when - now, intvl);
worker = new Uploader();
private void localconfig() {
followredirects = Boolean.parseBoolean(getProvParam("FOLLOW_REDIRECTS", "false"));
- eventloginterval = getProvParam("LOGROLL_INTERVAL", "5m");
+ eventloginterval = getProvParam("LOGROLL_INTERVAL", "30s");
initfailuretimer = 10000;
maxfailuretimer = 3600000;
expirationtimer = 86400000;
* Get a provisioned configuration parameter (from the provisioning server configuration)
*
* @param name The name of the parameter
- * @param deflt The value to use if the parameter is not defined
+ * @param defaultValue The value to use if the parameter is not defined
* @return The value of the parameter or deflt if it is not defined.
*/
- public String getProvParam(String name, String deflt) {
+ public String getProvParam(String name, String defaultValue) {
name = config.getProvParam(name);
if (name == null) {
- name = deflt;
+ name = defaultValue;
}
return (name);
}
}
/**
- * Parse an interval of the form xxhyymzzs and round it to the nearest whole fraction of 24 hours. If no units are specified, assume seconds.
+ * Parse an interval of the form xxhyymzzs and round it to the nearest whole fraction of 24 hours.If no units are specified, assume seconds.
*/
public static long parseInterval(String interval, int def) {
try {
ps.setNull(16, Types.INTEGER);\r
ps.setNull(17, Types.VARCHAR);\r
ps.setLong(19, contentLength2);\r
+ ps.setNull(20, Types.VARCHAR);\r
}\r
}\r
ps.setNull(16, Types.INTEGER);\r
ps.setNull(17, Types.VARCHAR);\r
ps.setNull(19, Types.BIGINT);\r
+ ps.setNull(20, Types.VARCHAR);\r
}\r
}\r
ps.setInt(16, getAttempts());\r
ps.setString(17, getReason());\r
ps.setNull(19, Types.BIGINT);\r
+ ps.setNull(20, Types.VARCHAR);\r
}\r
}\r
private final String reason;\r
private final long record_id;\r
private final long clength2;\r
+ private final String fileName;\r
\r
public LogRecord(ResultSet rs) throws SQLException {\r
super(rs);\r
\r
this.record_id = rs.getLong("RECORD_ID");\r
this.clength2 = rs.getLong("CONTENT_LENGTH_2");\r
+ this.fileName = rs.getString("FILENAME");\r
}\r
\r
public LogRecord(String[] pp) throws ParseException {\r
this.reason = pp[17];\r
\r
this.record_id = Long.parseLong(pp[18]);\r
- this.clength2 = (pp.length == 20) ? Long.parseLong(pp[19]) : 0;\r
+ this.clength2 = (pp.length == 21) ? Long.parseLong(pp[19]) : 0;\r
+ this.fileName = pp[20];\r
}\r
\r
public long getRecordId() {\r
ps.setNull(17, Types.VARCHAR);\r
ps.setLong(18, record_id);\r
ps.setNull(19, Types.BIGINT);\r
+ ps.setString(20, fileName);\r
} else if (type.equals("del")) {\r
ps.setNull(9, Types.VARCHAR);\r
ps.setNull(10, Types.VARCHAR);\r
ps.setNull(17, Types.VARCHAR);\r
ps.setLong(18, record_id);\r
ps.setNull(19, Types.BIGINT);\r
+ ps.setString(20, fileName);\r
} else if (type.equals("exp")) {\r
ps.setNull(9, Types.VARCHAR);\r
ps.setNull(10, Types.VARCHAR);\r
ps.setString(17, reason);\r
ps.setLong(18, record_id);\r
ps.setNull(19, Types.BIGINT);\r
+ ps.setString(20, fileName);\r
} else if (type.equals("pbf")) {\r
ps.setString(9, feedFileid);\r
ps.setString(10, remoteAddr);\r
ps.setNull(17, Types.VARCHAR);\r
ps.setLong(18, record_id);\r
ps.setLong(19, clength2);\r
+ ps.setString(20, fileName);\r
} else if (type.equals("dlx")) {\r
ps.setNull(9, Types.VARCHAR);\r
ps.setNull(10, Types.VARCHAR);\r
ps.setNull(17, Types.VARCHAR);\r
ps.setLong(18, record_id);\r
ps.setLong(19, clength2);\r
+ ps.setString(20, fileName);\r
}\r
}\r
\r
ps.setNull(16, Types.INTEGER);\r
ps.setNull(17, Types.VARCHAR);\r
ps.setLong(19, getContentLengthReceived());\r
+ ps.setNull(20, Types.VARCHAR);\r
}\r
}\r
import java.text.ParseException;\r
import java.util.LinkedHashMap;\r
\r
+import org.apache.commons.lang3.StringUtils;\r
import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;\r
\r
\r
private String remoteAddr;\r
private String user;\r
private int status;\r
+ private String fileName;\r
\r
public PublishRecord(String[] pp) throws ParseException {\r
super(pp);\r
-// This is too slow!\r
-// Matcher m = Pattern.compile(".*/publish/(\\d+)/(.*)$").matcher(pp[4]);\r
-// if (!m.matches())\r
-// throw new ParseException("bad pattern", 0);\r
-// this.feedFileid = m.group(2);\r
int ix = pp[4].indexOf("/publish/");\r
if (ix < 0)\r
throw new ParseException("bad pattern", 0);\r
this.remoteAddr = pp[8];\r
this.user = pp[9];\r
this.status = Integer.parseInt(pp[10]);\r
+ this.fileName = StringUtils.substringAfterLast(this.getRequestUri(), "/");\r
}\r
\r
public PublishRecord(ResultSet rs) throws SQLException {\r
this.remoteAddr = rs.getString("REMOTE_ADDR");\r
this.user = rs.getString("USER");\r
this.status = rs.getInt("STATUS");\r
+ this.fileName = StringUtils.substringAfterLast(this.getRequestUri(), "/");\r
}\r
\r
public String getFeedFileid() {\r
this.status = status;\r
}\r
\r
+ public String getFileName() { return fileName;}\r
+\r
+ public void setFileName(String fileName) { this.fileName = fileName; }\r
+\r
\r
public LOGJSONObject reOrderObject(LOGJSONObject jo) {\r
LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<String, Object>();\r
logrecordObj.put("type", jo.get("type"));\r
logrecordObj.put("date", jo.get("date"));\r
logrecordObj.put("contentLength", jo.get("contentLength"));\r
+ logrecordObj.put("fileName", jo.get("fileName"));\r
\r
LOGJSONObject newjo = new LOGJSONObject(logrecordObj);\r
return newjo;\r
public LOGJSONObject asJSONObject() {\r
LOGJSONObject jo = super.asJSONObject();\r
jo.put("type", "pub");\r
-// jo.put("feedFileid", feedFileid);\r
-// jo.put("remoteAddr", remoteAddr);\r
-// jo.put("user", user);\r
+ jo.put("feedFileid", feedFileid);\r
+ jo.put("remoteAddr", remoteAddr);\r
+ jo.put("user", user);\r
jo.put("sourceIP", remoteAddr);\r
jo.put("endpointId", user);\r
jo.put("statusCode", status);\r
+ jo.put("fileName", fileName);\r
\r
LOGJSONObject newjo = this.reOrderObject(jo);\r
\r
ps.setNull(16, Types.INTEGER);\r
ps.setNull(17, Types.VARCHAR);\r
ps.setNull(19, Types.BIGINT);\r
+ ps.setString(20, getFileName());\r
}\r
}\r
/**\r
* The PreparedStatement which is loaded by a <i>Loadable</i>.\r
*/\r
- public static final String INSERT_SQL = "insert into LOG_RECORDS values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";\r
+ public static final String INSERT_SQL = "insert into LOG_RECORDS values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";\r
/**\r
* Each server can assign this many IDs\r
*/\r
RECORD_ID BIGINT UNSIGNED NOT NULL PRIMARY KEY, /* unique ID for this record */
CONTENT_LENGTH_2 BIGINT,
+ FILENAME VARCHAR(256), /* Name of the file being published on DR */
INDEX (FEEDID) USING BTREE,
INDEX (DELIVERY_SUBID) USING BTREE,
('DELIVERY_MAX_AGE', '86400'),
('DELIVERY_MAX_RETRY_INTERVAL', '3600'),
('DELIVERY_RETRY_RATIO', '2'),
- ('LOGROLL_INTERVAL', '300'),
+ ('LOGROLL_INTERVAL', '30'),
('PROV_AUTH_ADDRESSES', 'dmaap-dr-prov|dmaap-dr-node'),
('PROV_AUTH_SUBJECTS', ''),
('PROV_MAXFEED_COUNT', '10000'),
publishRecord.setRemoteAddr("172.100.0.4");
publishRecord.setStatus(201);
publishRecord.setUser("user2");
+ publishRecord.setFileName("fileName");
LOGJSONObject publishRecordJson = createPublishRecordJson();
Assert.assertEquals(publishRecordJson.toString(), publishRecord.asJSONObject().toString());
}
publishRecordMap.put("type", "pub");
publishRecordMap.put("date", "2018-08-29T10:10:10.543Z");
publishRecordMap.put("contentLength", 285);
+ publishRecordMap.put("fileName", "fileName");
return new LOGJSONObject(publishRecordMap);
}
}
RECORD_ID BIGINT UNSIGNED NOT NULL PRIMARY KEY, /* unique ID for this record */
CONTENT_LENGTH_2 BIGINT,
+ FILENAME VARCHAR(256), /* Name of the file being published on DR */
INDEX (FEEDID) USING BTREE,
INDEX (DELIVERY_SUBID) USING BTREE,