summaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src
diff options
context:
space:
mode:
Diffstat (limited to 'datarouter-prov/src')
-rwxr-xr-xdatarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java2
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java21
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java102
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java2
-rwxr-xr-xdatarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java936
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java48
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java21
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java5
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java35
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java26
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java8
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java2
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java5
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java1
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java21
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java2
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/JSONUtilities.java4
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTask.java8
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSet.java2
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilter.java65
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java12
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecordTest.java4
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/FeedTest.java4
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java8
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilterTest.java2
25 files changed, 663 insertions, 683 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
index e730db4a..159a8966 100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
@@ -278,7 +278,7 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
eventlogger = EELFManager.getInstance().getLogger("EventLog");
}
if (intlogger == null) {
- this.intlogger = EELFManager.getInstance().getLogger("InternalLog");
+ intlogger = EELFManager.getInstance().getLogger("InternalLog");
}
if (authz == null) {
authz = new ProvAuthorizer(this);
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java
index 4432913f..484d54b5 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java
@@ -46,6 +46,9 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
*/
@SuppressWarnings("serial")
public class GroupServlet extends ProxyServlet {
+
+ public static final String MISSING_HEADER_MESSAGE = "Missing " + BEHALF_HEADER + " header.";
+
/**
* DELETE on the <GRUPS> -- not supported.
*/
@@ -80,11 +83,10 @@ public class GroupServlet extends ProxyServlet {
}
String bhdr = req.getHeader(BEHALF_HEADER);
if (bhdr == null) {
- message = "Missing "+BEHALF_HEADER+" header.";
- elr.setMessage(message);
+ elr.setMessage(MISSING_HEADER_MESSAGE);
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, MISSING_HEADER_MESSAGE, eventlogger);
return;
}
@@ -131,11 +133,10 @@ public class GroupServlet extends ProxyServlet {
}
String bhdr = req.getHeader(BEHALF_HEADER);
if (bhdr == null) {
- message = "Missing "+BEHALF_HEADER+" header.";
- elr.setMessage(message);
+ elr.setMessage(MISSING_HEADER_MESSAGE);
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, MISSING_HEADER_MESSAGE, eventlogger);
return;
}
int groupid = getIdFromPath(req);
@@ -241,11 +242,10 @@ public class GroupServlet extends ProxyServlet {
}
String bhdr = req.getHeader(BEHALF_HEADER);
if (bhdr == null) {
- message = "Missing "+BEHALF_HEADER+" header.";
- elr.setMessage(message);
+ elr.setMessage(MISSING_HEADER_MESSAGE);
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, MISSING_HEADER_MESSAGE, eventlogger);
return;
}
@@ -284,8 +284,6 @@ public class GroupServlet extends ProxyServlet {
sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
return;
}
- //gup.setFeedid(feedid);
- //sub.setSubscriber(bhdr); // set from X-DMAAP-DR-ON-BEHALF-OF header
// Check if this group already exists; not an error (yet), just warn
Group gb2 = Group.getGroupMatching(gup);
@@ -296,7 +294,6 @@ public class GroupServlet extends ProxyServlet {
return;
}
-
// Create GROUPS table entries
if (doInsert(gup)) {
// send response
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java
index 762ab4e5..e3b9c57b 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java
@@ -164,8 +164,8 @@ public class LogServlet extends BaseServlet {
eventlogger.error(elr.toString());
sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
} finally {
- eelfLogger.info(EelfMsgs.EXIT);
- }
+ eelfLogger.info(EelfMsgs.EXIT);
+ }
}
/**
* GET a logging URL -- retrieve logging data for a feed or subscription.
@@ -246,13 +246,13 @@ public class LogServlet extends BaseServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doPut", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");
- String message = "PUT not allowed for the logURL.";
- EventLogRecord elr = new EventLogRecord(req);
- elr.setMessage(message);
- elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");
+ String message = "PUT not allowed for the logURL.";
+ EventLogRecord elr = new EventLogRecord(req);
+ elr.setMessage(message);
+ elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ eventlogger.error(elr.toString());
+ sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
} finally {
eelfLogger.info(EelfMsgs.EXIT);
}
@@ -265,13 +265,13 @@ public class LogServlet extends BaseServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doPost", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF, req.getHeader(BEHALF_HEADER));
- String message = "POST not allowed for the logURL.";
- EventLogRecord elr = new EventLogRecord(req);
- elr.setMessage(message);
- elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF, req.getHeader(BEHALF_HEADER));
+ String message = "POST not allowed for the logURL.";
+ EventLogRecord elr = new EventLogRecord(req);
+ elr.setMessage(message);
+ elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ eventlogger.error(elr.toString());
+ sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
} finally {
eelfLogger.info(EelfMsgs.EXIT);
}
@@ -307,25 +307,32 @@ public class LogServlet extends BaseServlet {
s = req.getParameter("filename");
if (s != null) {
- map.put(FILENAMESQL, " AND FILENAME = '"+s+"'");
+ map.put(FILENAMESQL, " AND FILENAME = '" + s + "'");
}
s = req.getParameter("statusCode");
if (s != null) {
String sql = null;
- if ("success".equals(s)) {
- sql = " AND STATUS >= 200 AND STATUS < 300";
- } else if ("redirect".equals(s)) {
- sql = " AND STATUS >= 300 AND STATUS < 400";
- } else if ("failure".equals(s)) {
- sql = " AND STATUS >= 400";
- } else {
- try {
- Integer n = Integer.parseInt(s);
- if ((n >= 100 && n < 600) || (n == -1))
- sql = " AND STATUS = " + n;
- } catch (NumberFormatException e) {
- }
+ switch (s) {
+ case "success":
+ sql = " AND STATUS >= 200 AND STATUS < 300";
+ break;
+ case "redirect":
+ sql = " AND STATUS >= 300 AND STATUS < 400";
+ break;
+ case "failure":
+ sql = " AND STATUS >= 400";
+ break;
+ default:
+ try {
+ int n = Integer.parseInt(s);
+ if ((n >= 100 && n < 600) || (n == -1)) {
+ sql = " AND STATUS = " + n;
+ }
+ } catch (NumberFormatException e) {
+ intlogger.error("Failed to parse input", e);
+ }
+ break;
}
if (sql == null) {
map.put("err", "bad statusCode");
@@ -383,22 +390,22 @@ public class LogServlet extends BaseServlet {
Date d = sdf.parse(s);
return d.getTime();
} catch (ParseException parseException) {
- intlogger.error("Exception in getting Time :- "+parseException.getMessage(),parseException);
+ intlogger.error("Exception in getting Time :- " + parseException.getMessage(),parseException);
}
try {
// Also allow a long (in ms); useful for testing
return Long.parseLong(s);
} catch (NumberFormatException numberFormatException) {
- intlogger.error("Exception in getting Time :- "+numberFormatException.getMessage(),numberFormatException);
+ intlogger.error("Exception in getting Time :- " + numberFormatException.getMessage(),numberFormatException);
}
- intlogger.info("Error parsing time="+s);
+ intlogger.info("Error parsing time=" + s);
return -1;
}
private void getPublishRecordsForFeed(int feedid, RowHandler rh, Map<String, String> map) {
String type = map.get("type");
if ("all".equals(type) || "pub".equals(type)) {
- String sql = LOG_RECORDSSQL+feedid
+ String sql = LOG_RECORDSSQL + feedid
+ " AND TYPE = 'pub'"
+ map.get(TIMESQL) + map.get(PUBLISHSQL) + map.get(STATUSSQL) + map.get(FILENAMESQL);
getRecordsForSQL(sql, rh);
@@ -407,7 +414,7 @@ public class LogServlet extends BaseServlet {
private void getDeliveryRecordsForFeed(int feedid, RowHandler rh, Map<String, String> map) {
String type = map.get("type");
if ("all".equals(type) || "del".equals(type)) {
- String sql = LOG_RECORDSSQL+feedid
+ String sql = LOG_RECORDSSQL + feedid
+ " AND TYPE = 'del'"
+ map.get(TIMESQL) + map.get(PUBLISHSQL) + map.get(RESULTSQL);
getRecordsForSQL(sql, rh);
@@ -416,7 +423,7 @@ public class LogServlet extends BaseServlet {
private void getDeliveryRecordsForSubscription(int subid, RowHandler rh, Map<String, String> map) {
String type = map.get("type");
if ("all".equals(type) || "del".equals(type)) {
- String sql = "select * from LOG_RECORDS where DELIVERY_SUBID = "+subid
+ String sql = "select * from LOG_RECORDS where DELIVERY_SUBID = " + subid
+ " AND TYPE = 'del'"
+ map.get(TIMESQL) + map.get(PUBLISHSQL) + map.get(RESULTSQL);
getRecordsForSQL(sql, rh);
@@ -427,7 +434,7 @@ public class LogServlet extends BaseServlet {
if ("all".equals(type) || "exp".equals(type)) {
String st = map.get(STATUSSQL);
if (st == null || st.length() == 0) {
- String sql = LOG_RECORDSSQL+feedid
+ String sql = LOG_RECORDSSQL + feedid
+ " AND TYPE = 'exp'"
+ map.get(TIMESQL) + map.get(PUBLISHSQL) + map.get(REASON_SQL);
getRecordsForSQL(sql, rh);
@@ -439,13 +446,14 @@ public class LogServlet extends BaseServlet {
if ("all".equals(type) || "exp".equals(type)) {
String st = map.get(STATUSSQL);
if (st == null || st.length() == 0) {
- String sql = "select * from LOG_RECORDS where DELIVERY_SUBID = "+subid
+ String sql = "select * from LOG_RECORDS where DELIVERY_SUBID = " + subid
+ " AND TYPE = 'exp'"
+ map.get(TIMESQL) + map.get(PUBLISHSQL) + map.get(REASON_SQL);
getRecordsForSQL(sql, rh);
}
}
}
+
private void getRecordsForSQL(String sql, RowHandler rh) {
intlogger.debug(sql);
long start = System.currentTimeMillis();
@@ -453,19 +461,19 @@ public class LogServlet extends BaseServlet {
Connection conn = null;
try {
conn = db.getConnection();
- try( Statement stmt = conn.createStatement()){
- try(ResultSet rs = stmt.executeQuery(sql)){
- while (rs.next()) {
- rh.handleRow(rs);
- }
- }
- }
+ try (Statement stmt = conn.createStatement()) {
+ try (ResultSet rs = stmt.executeQuery(sql)) {
+ while (rs.next()) {
+ rh.handleRow(rs);
+ }
+ }
+ }
} catch (SQLException sqlException) {
- intlogger.info("Failed to get Records. Exception = " +sqlException.getMessage(),sqlException);
+ intlogger.info("Failed to get Records. Exception = " + sqlException.getMessage(),sqlException);
} finally {
if (conn != null)
db.release(conn);
}
- intlogger.debug("Time: " + (System.currentTimeMillis()-start) + " ms");
+ intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms");
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java
index 6cb8520d..f1660f94 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java
@@ -82,7 +82,7 @@ public class Poker extends TimerTask {
private Poker() {
timer1 = timer2 = 0;
Timer rolex = new Timer();
- logger = EELFManager.getInstance().getLogger("InternalLog");;
+ logger = EELFManager.getInstance().getLogger("InternalLog");
try {
thisPod = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java
index 9cbce0a8..b0695449 100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java
@@ -56,508 +56,492 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
public class StatisticsServlet extends BaseServlet {
- private static final long TWENTYFOUR_HOURS = (24 * 60 * 60 * 1000L);
- private static final String FMT1 = "yyyy-MM-dd'T'HH:mm:ss'Z'";
- private static final String FMT2 = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
-
-
-
- /**
- * DELETE a logging URL -- not supported.
- */
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) {
- String message = "DELETE not allowed for the logURL.";
- EventLogRecord elr = new EventLogRecord(req);
- elr.setMessage(message);
- elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
- }
-
- /**
- * GET a Statistics URL -- retrieve Statistics data for a feed or subscription. See the
- * <b>Statistics API</b> document for details on how this method should be invoked.
- */
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) {
-
- Map<String, String> map = buildMapFromRequest(req);
- if (map.get("err") != null) {
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Invalid arguments: " + map.get("err"), eventlogger);
- return;
- }
- // check Accept: header??
+ private static final long TWENTYFOUR_HOURS = (24 * 60 * 60 * 1000L);
+ private static final String FMT1 = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+ private static final String FMT2 = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
+ public static final String FEEDID = "FEEDID";
+
+
+ /**
+ * DELETE a logging URL -- not supported.
+ */
+ @Override
+ public void doDelete(HttpServletRequest req, HttpServletResponse resp) {
+ String message = "DELETE not allowed for the logURL.";
+ EventLogRecord elr = new EventLogRecord(req);
+ elr.setMessage(message);
+ elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ eventlogger.error(elr.toString());
+ sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
+ }
+
+ /**
+ * GET a Statistics URL -- retrieve Statistics data for a feed or subscription. See the
+ * <b>Statistics API</b> document for details on how this method should be invoked.
+ */
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) {
+ Map<String, String> map = buildMapFromRequest(req);
+ if (map.get("err") != null) {
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Invalid arguments: " + map.get("err"), eventlogger);
+ return;
+ }
+ // check Accept: header??
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType(LOGLIST_CONTENT_TYPE);
+ String outputType = "json";
+ if (req.getParameter(FEEDID) == null && req.getParameter(GROUPID) == null) {
+ try {
+ resp.getOutputStream().print("Invalid request, Feedid or Group ID is required.");
+ } catch (IOException ioe) {
+ eventlogger.error("PROV0171 StatisticsServlet.doGet: " + ioe.getMessage(), ioe);
+ }
+ }
+ if (req.getParameter(FEEDID) != null && req.getParameter(GROUPID) == null) {
+ map.put(FEEDIDS, req.getParameter(FEEDID).replace("|", ","));
+ }
+ if (req.getParameter(GROUPID) != null && req.getParameter(FEEDID) == null) {
+ StringBuilder groupid1;
+ try {
+ groupid1 = this.getFeedIdsByGroupId(Integer.parseInt(req.getParameter(GROUPID)));
+ map.put(FEEDIDS, groupid1.toString());
+ } catch (NumberFormatException | SQLException e) {
+ eventlogger.error("PROV0172 StatisticsServlet.doGet: " + e.getMessage(), e);
+ }
+ }
+ if (req.getParameter(GROUPID) != null && req.getParameter(FEEDID) != null) {
+ StringBuilder groupid1;
+ try {
+ groupid1 = this.getFeedIdsByGroupId(Integer.parseInt(req.getParameter(GROUPID)));
+ groupid1.append(",");
+ groupid1.append(req.getParameter(FEEDID).replace("|", ","));
+ map.put(FEEDIDS, groupid1.toString());
+ } catch (NumberFormatException | SQLException e) {
+ eventlogger.error("PROV0173 StatisticsServlet.doGet: " + e.getMessage(), e);
+ }
+ }
+ if (req.getParameter(SUBID) != null && req.getParameter(FEEDID) != null) {
+ String subidstr = "and e.DELIVERY_SUBID in("
+ + req.getParameter(SUBID).replace("|", ",") + ")";
+ map.put(SUBID, subidstr);
+ }
+ if (req.getParameter(SUBID) != null && req.getParameter(GROUPID) != null) {
+ String subidstr = "and e.DELIVERY_SUBID in("
+ + req.getParameter(SUBID).replace("|", ",") + ")";
+ map.put(SUBID, subidstr);
+ }
+ if (req.getParameter("type") != null) {
+ map.put(EVENT_TYPE, req.getParameter("type").replace("|", ","));
+ }
+ if (req.getParameter(OUTPUT_TYPE) != null) {
+ map.put(OUTPUT_TYPE, req.getParameter(OUTPUT_TYPE));
+ }
+ if (req.getParameter(START_TIME) != null) {
+ map.put(START_TIME, req.getParameter(START_TIME));
+ }
+ if (req.getParameter(END_TIME) != null) {
+ map.put(END_TIME, req.getParameter(END_TIME));
+ }
+ if (req.getParameter("time") != null) {
+ map.put(START_TIME, req.getParameter("time"));
+ map.put(END_TIME, null);
+ }
+ if (req.getParameter(OUTPUT_TYPE) != null) {
+ outputType = req.getParameter(OUTPUT_TYPE);
+ }
+ try {
+ this.getRecordsForSQL(map, outputType, resp.getOutputStream(), resp);
+ } catch (IOException ioe) {
+ eventlogger.error("PROV0174 StatisticsServlet.doGet: " + ioe.getMessage(), ioe);
+ }
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.setContentType(LOGLIST_CONTENT_TYPE);
+ }
- String outputType = "json";
- if (req.getParameter(FEEDID) == null && req.getParameter(GROUPID) == null) {
- try {
- resp.getOutputStream().print("Invalid request, Feedid or Group ID is required.");
- } catch (IOException ioe) {
- eventlogger.error("PROV0171 StatisticsServlet.doGet: " + ioe.getMessage(), ioe);
- }
+ /**
+ * rsToJson - Converting RS to JSON object
+ *
+ * @param out ServletOutputStream, rs as ResultSet
+ * @throws IOException, SQLException
+ */
+ public void rsToCSV(ResultSet rs, ServletOutputStream out) throws IOException, SQLException {
+ String header = "FEEDNAME,FEEDID,FILES_PUBLISHED,PUBLISH_LENGTH, FILES_DELIVERED, "
+ + "DELIVERED_LENGTH, SUBSCRIBER_URL, SUBID, PUBLISH_TIME,DELIVERY_TIME, AverageDelay\n";
+ out.write(header.getBytes());
+
+ while (rs.next()) {
+ String line = rs.getString("FEEDNAME")
+ + ","
+ + rs.getString(FEEDID)
+ + ","
+ + rs.getString("FILES_PUBLISHED")
+ + ","
+ + rs.getString("PUBLISH_LENGTH")
+ + ","
+ + rs.getString("FILES_DELIVERED")
+ + ","
+ + rs.getString("DELIVERED_LENGTH")
+ + ","
+ + rs.getString("SUBSCRIBER_URL")
+ + ","
+ + rs.getString("SUBID")
+ + ","
+ + rs.getString("PUBLISH_TIME")
+ + ","
+ + rs.getString("DELIVERY_TIME")
+ + ","
+ + rs.getString("AverageDelay")
+ + ","
+ + "\n";
+ out.write(line.getBytes());
+ out.flush();
+ }
}
- if (req.getParameter(FEEDID) != null && req.getParameter(GROUPID) == null) {
- map.put(FEEDIDS, req.getParameter(FEEDID).replace("|", ","));
+ /**
+ * rsToJson - Converting RS to JSON object
+ *
+ * @param out ServletOutputStream, rs as ResultSet
+ * @throws IOException, SQLException
+ */
+ private void rsToJson(ResultSet rs, ServletOutputStream out) throws IOException, SQLException {
+ String[] fields = {"FEEDNAME", FEEDID, "FILES_PUBLISHED", "PUBLISH_LENGTH", "FILES_DELIVERED",
+ "DELIVERED_LENGTH", "SUBSCRIBER_URL", "SUBID", "PUBLISH_TIME", "DELIVERY_TIME",
+ "AverageDelay"};
+ StringBuilder line = new StringBuilder();
+ line.append("[\n");
+ while (rs.next()) {
+ LOGJSONObject j2 = new LOGJSONObject();
+ for (String key : fields) {
+ Object v = rs.getString(key);
+ if (v != null) {
+ j2.put(key.toLowerCase(), v);
+ } else {
+ j2.put(key.toLowerCase(), "");
+ }
+ }
+ line.append(j2.toString());
+ line.append(",\n");
+ }
+ line.append("]");
+ out.print(line.toString());
+ }
+
+ /**
+ * getFeedIdsByGroupId - Getting FEEDID's by GROUP ID.
+ *
+ * @throws SQLException Query SQLException.
+ */
+ private StringBuilder getFeedIdsByGroupId(int groupIds) throws SQLException {
+ DB db = null;
+ Connection conn = null;
+ ResultSet resultSet = null;
+ String sqlGoupid = null;
+ StringBuilder feedIds = new StringBuilder();
+ try {
+ db = new DB();
+ conn = db.getConnection();
+ sqlGoupid = " SELECT FEEDID from FEEDS WHERE GROUPID = ?";
+ try (PreparedStatement prepareStatement = conn.prepareStatement(sqlGoupid)) {
+ prepareStatement.setInt(1, groupIds);
+ resultSet = prepareStatement.executeQuery();
+ while (resultSet.next()) {
+ feedIds.append(resultSet.getInt(FEEDID));
+ feedIds.append(",");
+ }
+ feedIds.deleteCharAt(feedIds.length() - 1);
+ eventlogger.info("PROV0177 StatisticsServlet.getFeedIdsByGroupId: feedIds = " + feedIds.toString());
+ }
+ } catch (SQLException e) {
+ eventlogger.error("PROV0175 StatisticsServlet.getFeedIdsByGroupId: " + e.getMessage(), e);
+ } finally {
+ try {
+ if (resultSet != null) {
+ resultSet.close();
+ }
+ if (conn != null) {
+ db.release(conn);
+ }
+ } catch (Exception e) {
+ eventlogger.error("PROV0176 StatisticsServlet.getFeedIdsByGroupId: " + e.getMessage(), e);
+ }
+ }
+ return feedIds;
}
- if (req.getParameter(GROUPID) != null && req.getParameter(FEEDID) == null) {
- StringBuffer groupid1 = new StringBuffer();
- try {
- groupid1 = this.getFeedIdsByGroupId(Integer.parseInt(req.getParameter(GROUPID)));
- map.put(FEEDIDS, groupid1.toString());
- } catch (NumberFormatException | SQLException e) {
- eventlogger.error("PROV0172 StatisticsServlet.doGet: " + e.getMessage(), e);
- }
- }
- if (req.getParameter(GROUPID) != null && req.getParameter(FEEDID) != null) {
- StringBuffer groupid1 = new StringBuffer();
-
- try {
- groupid1 = this.getFeedIdsByGroupId(Integer.parseInt(req.getParameter(GROUPID)));
- groupid1.append(",");
- groupid1.append(req.getParameter(FEEDID).replace("|", ","));
- map.put(FEEDIDS, groupid1.toString());
- } catch (NumberFormatException | SQLException e) {
- eventlogger.error("PROV0173 StatisticsServlet.doGet: " + e.getMessage(), e);
- }
- }
+ /**
+ * queryGeneretor - Generating sql query
+ *
+ * @param map as key value pare of all user input fields
+ */
+ private String queryGeneretor(Map<String, String> map) throws ParseException {
- if (req.getParameter(SUBID) != null && req.getParameter(FEEDID) != null) {
- StringBuffer subidstr = new StringBuffer();
- subidstr.append("and e.DELIVERY_SUBID in(");
+ String sql;
+ String eventType = null;
+ String feedids = null;
+ String startTime = null;
+ String endTime = null;
+ String subid = " ";
+ if (map.get(EVENT_TYPE) != null) {
+ eventType = map.get(EVENT_TYPE);
+ }
+ if (map.get(FEEDIDS) != null) {
+ feedids = map.get(FEEDIDS);
+ }
+ if (map.get(START_TIME) != null) {
+ startTime = map.get(START_TIME);
+ }
+ if (map.get(END_TIME) != null) {
+ endTime = map.get(END_TIME);
+ }
+ if ("all".equalsIgnoreCase(eventType)) {
+ eventType = "PUB','DEL, EXP, PBF";
+ }
+ if (map.get(SUBID) != null) {
+ subid = map.get(SUBID);
+ }
- subidstr.append(req.getParameter(SUBID).replace("|", ","));
- subidstr.append(")");
- map.put(SUBID, subidstr.toString());
- }
- if (req.getParameter(SUBID) != null && req.getParameter(GROUPID) != null) {
- StringBuffer subidstr = new StringBuffer();
- subidstr.append("and e.DELIVERY_SUBID in(");
+ eventlogger.info("Generating sql query to get Statistics resultset. ");
- subidstr.append(req.getParameter(SUBID).replace("|", ","));
- subidstr.append(")");
- map.put(SUBID, subidstr.toString());
- }
- if (req.getParameter("type") != null) {
- map.put(EVENT_TYPE, req.getParameter("type").replace("|", ","));
- }
- if (req.getParameter(OUTPUT_TYPE) != null) {
- map.put(OUTPUT_TYPE, req.getParameter(OUTPUT_TYPE));
- }
- if (req.getParameter(START_TIME) != null) {
- map.put(START_TIME, req.getParameter(START_TIME));
- }
- if (req.getParameter(END_TIME) != null) {
- map.put(END_TIME, req.getParameter(END_TIME));
- }
+ if (endTime == null && startTime == null) {
- if (req.getParameter("time") != null) {
- map.put(START_TIME, req.getParameter("time"));
- map.put(END_TIME, null);
- }
+ sql = "SELECT (SELECT NAME FROM FEEDS AS f WHERE f.FEEDID in(" + feedids
+ + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, (SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + feedids
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + feedids
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED, sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL, e.DELIVERY_SUBID as SUBID, e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
+ + feedids + ") " + subid + " AND m.STATUS=204 AND e.RESULT=204 group by SUBID";
- if (req.getParameter(OUTPUT_TYPE) != null) {
- outputType = req.getParameter(OUTPUT_TYPE);
- }
- try {
- this.getRecordsForSQL(map, outputType, resp.getOutputStream(), resp);
- } catch (IOException ioe) {
- eventlogger.error("PROV0174 StatisticsServlet.doGet: " + ioe.getMessage(), ioe);
- }
+ return sql;
+ } else if (startTime != null && endTime == null) {
+
+ long inputTimeInMilli = 60000 * Long.parseLong(startTime);
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ long currentTimeInMilli = cal.getTimeInMillis();
+ long compareTime = currentTimeInMilli - inputTimeInMilli;
+
+ sql = "SELECT (SELECT NAME FROM FEEDS AS f WHERE f.FEEDID in(" + feedids
+ + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, (SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + feedids
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + feedids
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED, sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL, e.DELIVERY_SUBID as SUBID, e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
+ + feedids + ") " + subid + " AND m.STATUS=204 AND e.RESULT=204 and e.event_time>="
+ + compareTime + " group by SUBID";
+
+ return sql;
- }
-
-
- /**
- * rsToJson - Converting RS to JSON object
- *
- * @param out ServletOutputStream, rs as ResultSet
- * @throws IOException, SQLException
- */
- public void rsToCSV(ResultSet rs, ServletOutputStream out) throws IOException, SQLException {
- String header = "FEEDNAME,FEEDID,FILES_PUBLISHED,PUBLISH_LENGTH, FILES_DELIVERED, DELIVERED_LENGTH, SUBSCRIBER_URL, SUBID, PUBLISH_TIME,DELIVERY_TIME, AverageDelay\n";
-
- out.write(header.getBytes());
-
- while (rs.next()) {
- StringBuffer line = new StringBuffer();
- line.append(rs.getString("FEEDNAME"));
- line.append(",");
- line.append(rs.getString("FEEDID"));
- line.append(",");
- line.append(rs.getString("FILES_PUBLISHED"));
- line.append(",");
- line.append(rs.getString("PUBLISH_LENGTH"));
- line.append(",");
- line.append(rs.getString("FILES_DELIVERED"));
- line.append(",");
- line.append(rs.getString("DELIVERED_LENGTH"));
- line.append(",");
- line.append(rs.getString("SUBSCRIBER_URL"));
- line.append(",");
- line.append(rs.getString("SUBID"));
- line.append(",");
- line.append(rs.getString("PUBLISH_TIME"));
- line.append(",");
- line.append(rs.getString("DELIVERY_TIME"));
- line.append(",");
- line.append(rs.getString("AverageDelay"));
- line.append(",");
-
- line.append("\n");
- out.write(line.toString().getBytes());
- out.flush();
- }
- }
-
- /**
- * rsToJson - Converting RS to JSON object
- *
- * @param out ServletOutputStream, rs as ResultSet
- * @throws IOException, SQLException
- */
- public void rsToJson(ResultSet rs, ServletOutputStream out) throws IOException, SQLException {
-
- String[] fields = {"FEEDNAME", "FEEDID", "FILES_PUBLISHED", "PUBLISH_LENGTH", "FILES_DELIVERED",
- "DELIVERED_LENGTH", "SUBSCRIBER_URL", "SUBID", "PUBLISH_TIME", "DELIVERY_TIME",
- "AverageDelay"};
- StringBuffer line = new StringBuffer();
-
- line.append("[\n");
-
- while (rs.next()) {
- LOGJSONObject j2 = new LOGJSONObject();
- for (String key : fields) {
- Object v = rs.getString(key);
- if (v != null) {
- j2.put(key.toLowerCase(), v);
} else {
- j2.put(key.toLowerCase(), "");
+ SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ Date startDate = inFormat.parse(startTime);
+ Date endDate = inFormat.parse(endTime);
+
+ long startInMillis = startDate.getTime();
+ long endInMillis = endDate.getTime();
+
+ sql = "SELECT (SELECT NAME FROM FEEDS AS f WHERE f.FEEDID in(" + feedids
+ + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, (SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + feedids
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + feedids
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED, sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL, e.DELIVERY_SUBID as SUBID, e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
+ + feedids + ") " + subid + " AND m.STATUS=204 AND e.RESULT=204 and e.event_time between " + startInMillis
+ + " and " + endInMillis + " group by SUBID";
+
+
+ return sql;
}
- }
- line = line.append(j2.toString());
- line.append(",\n");
- }
- line.append("]");
- out.print(line.toString());
- }
-
- /**
- * getFeedIdsByGroupId - Getting FEEDID's by GROUP ID.
- *
- * @throws SQLException Query SQLException.
- */
- public StringBuffer getFeedIdsByGroupId(int groupIds) throws SQLException {
-
- DB db = null;
- Connection conn = null;
- ResultSet resultSet = null;
- String sqlGoupid = null;
- StringBuffer feedIds = new StringBuffer();
-
- try {
- db = new DB();
- conn = db.getConnection();
- sqlGoupid = " SELECT FEEDID from FEEDS WHERE GROUPID = ?";
- try(PreparedStatement prepareStatement = conn.prepareStatement(sqlGoupid)) {
- prepareStatement.setInt(1, groupIds);
- resultSet = prepareStatement.executeQuery();
- while (resultSet.next()) {
- feedIds.append(resultSet.getInt("FEEDID"));
- feedIds.append(",");
- }
- feedIds.deleteCharAt(feedIds.length() - 1);
- System.out.println("feedIds" + feedIds.toString());
- }
- } catch (SQLException e) {
- eventlogger.error("PROV0175 StatisticsServlet.getFeedIdsByGroupId: " + e.getMessage(), e);
- } finally {
- try {
- if (resultSet != null) {
- resultSet.close();
- resultSet = null;
- }
- if (conn != null) {
- db.release(conn);
- }
- } catch (Exception e) {
- eventlogger.error("PROV0176 StatisticsServlet.getFeedIdsByGroupId: " + e.getMessage(), e);
- }
- }
- return feedIds;
- }
-
-
- /**
- * queryGeneretor - Generating sql query
- *
- * @param map as key value pare of all user input fields
- */
- public String queryGeneretor(Map<String, String> map) throws ParseException {
-
- String sql = null;
- String eventType = null;
- String feedids = null;
- String start_time = null;
- String end_time = null;
- String subid = " ";
- if (map.get(EVENT_TYPE) != null) {
- eventType = map.get(EVENT_TYPE);
- }
- if (map.get(FEEDIDS) != null) {
- feedids = map.get(FEEDIDS);
- }
- if (map.get(START_TIME) != null) {
- start_time = map.get(START_TIME);
- }
- if (map.get(END_TIME) != null) {
- end_time = map.get(END_TIME);
- }
- if ("all".equalsIgnoreCase(eventType)) {
- eventType = "PUB','DEL, EXP, PBF";
- }
- if (map.get(SUBID) != null) {
- subid = map.get(SUBID);
}
- eventlogger.info("Generating sql query to get Statistics resultset. ");
-
- if (end_time == null && start_time == null) {
-
- sql = "SELECT (SELECT NAME FROM FEEDS AS f WHERE f.FEEDID in(" + feedids
- + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, (SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
- + feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
- + feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED, sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL, e.DELIVERY_SUBID as SUBID, e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
- + feedids + ") " + subid + " AND m.STATUS=204 AND e.RESULT=204 group by SUBID";
-
- return sql;
- } else if (start_time != null && end_time == null) {
-
- long inputTimeInMilli = 60000 * Long.parseLong(start_time);
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- long currentTimeInMilli = cal.getTimeInMillis();
- long compareTime = currentTimeInMilli - inputTimeInMilli;
-
- sql = "SELECT (SELECT NAME FROM FEEDS AS f WHERE f.FEEDID in(" + feedids
- + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, (SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
- + feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
- + feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED, sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL, e.DELIVERY_SUBID as SUBID, e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
- + feedids + ") " + subid + " AND m.STATUS=204 AND e.RESULT=204 and e.event_time>="
- + compareTime + " group by SUBID";
-
- return sql;
-
- } else {
- SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
- Date startDate = inFormat.parse(start_time);
- Date endDate = inFormat.parse(end_time);
-
- long startInMillis = startDate.getTime();
- long endInMillis = endDate.getTime();
-
- {
-
- sql = "SELECT (SELECT NAME FROM FEEDS AS f WHERE f.FEEDID in(" + feedids
- + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, (SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
- + feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
- + feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED, sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL, e.DELIVERY_SUBID as SUBID, e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
- + feedids + ") " + subid
- + " AND m.STATUS=204 AND e.RESULT=204 and e.event_time between " + startInMillis
- + " and " + endInMillis + " group by SUBID";
-
- }
- return sql;
- }
- }
-
-
- /**
- * PUT a Statistics URL -- not supported.
- */
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) {
- String message = "PUT not allowed for the StatisticsURL.";
- EventLogRecord elr = new EventLogRecord(req);
- elr.setMessage(message);
- elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
- }
-
- /**
- * POST a Statistics URL -- not supported.
- */
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) {
- String message = "POST not allowed for the StatisticsURL.";
- EventLogRecord elr = new EventLogRecord(req);
- elr.setMessage(message);
- elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
- }
-
- private Map<String, String> buildMapFromRequest(HttpServletRequest req) {
- Map<String, String> map = new HashMap<>();
- String s = req.getParameter("type");
- if (s != null) {
- if ("pub".equals(s) || "del".equals(s) || "exp".equals(s)) {
- map.put("type", s);
- } else {
- map.put("err", "bad type");
- return map;
- }
- } else {
- map.put("type", "all");
- }
- map.put("publishSQL", "");
- map.put("statusSQL", "");
- map.put("resultSQL", "");
- map.put(REASON_SQL, "");
-
- s = req.getParameter("publishId");
- if (s != null) {
- if (s.indexOf("'") >= 0) {
- map.put("err", "bad publishId");
- return map;
- }
- map.put("publishSQL", " AND PUBLISH_ID = '" + s + "'");
- }
- s = req.getParameter("statusCode");
- if (s != null) {
- String sql = null;
- if ("success".equals(s)) {
- sql = " AND STATUS >= 200 AND STATUS < 300";
- } else if ("redirect".equals(s)) {
- sql = " AND STATUS >= 300 AND STATUS < 400";
- } else if ("failure".equals(s)) {
- sql = " AND STATUS >= 400";
- } else {
- try {
- Integer n = Integer.parseInt(s);
- if ((n >= 100 && n < 600) || (n == -1)) {
- sql = " AND STATUS = " + n;
- }
- } catch (NumberFormatException e) {
+ /**
+ * PUT a Statistics URL -- not supported.
+ */
+ @Override
+ public void doPut(HttpServletRequest req, HttpServletResponse resp) {
+ String message = "PUT not allowed for the StatisticsURL.";
+ EventLogRecord elr = new EventLogRecord(req);
+ elr.setMessage(message);
+ elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ eventlogger.error(elr.toString());
+ sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
+ }
+
+ /**
+ * POST a Statistics URL -- not supported.
+ */
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) {
+ String message = "POST not allowed for the StatisticsURL.";
+ EventLogRecord elr = new EventLogRecord(req);
+ elr.setMessage(message);
+ elr.setResult(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ eventlogger.error(elr.toString());
+ sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
+ }
+
+ private Map<String, String> buildMapFromRequest(HttpServletRequest req) {
+ Map<String, String> map = new HashMap<>();
+ String s = req.getParameter("type");
+ if (s != null) {
+ if ("pub".equals(s) || "del".equals(s) || "exp".equals(s)) {
+ map.put("type", s);
+ } else {
+ map.put("err", "bad type");
+ return map;
+ }
+ } else {
+ map.put("type", "all");
+ }
+ map.put("publishSQL", "");
+ map.put("statusSQL", "");
+ map.put("resultSQL", "");
+ map.put(REASON_SQL, "");
+
+ s = req.getParameter("publishId");
+ if (s != null) {
+ if (s.indexOf("'") >= 0) {
+ map.put("err", "bad publishId");
+ return map;
+ }
+ map.put("publishSQL", " AND PUBLISH_ID = '" + s + "'");
+ }
+
+ s = req.getParameter("statusCode");
+ if (s != null) {
+ String sql = null;
+ switch (s) {
+ case "success":
+ sql = " AND STATUS >= 200 AND STATUS < 300";
+ break;
+ case "redirect":
+ sql = " AND STATUS >= 300 AND STATUS < 400";
+ break;
+ case "failure":
+ sql = " AND STATUS >= 400";
+ break;
+ default:
+ try {
+ int n = Integer.parseInt(s);
+ if ((n >= 100 && n < 600) || (n == -1)) {
+ sql = " AND STATUS = " + n;
+ }
+ } catch (NumberFormatException e) {
+ eventlogger.error("Failed to parse input", e);
+ }
+ break;
+ }
+ if (sql == null) {
+ map.put("err", "bad statusCode");
+ return map;
+ }
+ map.put("statusSQL", sql);
+ map.put("resultSQL", sql.replaceAll("STATUS", "RESULT"));
}
- }
- if (sql == null) {
- map.put("err", "bad statusCode");
- return map;
- }
- map.put("statusSQL", sql);
- map.put("resultSQL", sql.replaceAll("STATUS", "RESULT"));
- }
- s = req.getParameter("expiryReason");
- if (s != null) {
- map.put("type", "exp");
- if ("notRetryable".equals(s)) {
- map.put(REASON_SQL, " AND REASON = 'notRetryable'");
- } else if ("retriesExhausted".equals(s)) {
- map.put(REASON_SQL, " AND REASON = 'retriesExhausted'");
- } else if ("diskFull".equals(s)) {
- map.put(REASON_SQL, " AND REASON = 'diskFull'");
- } else if ("other".equals("other")) {
- map.put(REASON_SQL, " AND REASON = 'other'");
- } else {
- map.put("err", "bad expiryReason");
+ s = req.getParameter("expiryReason");
+ if (s != null) {
+ map.put("type", "exp");
+ switch (s) {
+ case "notRetryable":
+ map.put(REASON_SQL, " AND REASON = 'notRetryable'");
+ break;
+ case "retriesExhausted":
+ map.put(REASON_SQL, " AND REASON = 'retriesExhausted'");
+ break;
+ case "diskFull":
+ map.put(REASON_SQL, " AND REASON = 'diskFull'");
+ break;
+ case "other":
+ map.put(REASON_SQL, " AND REASON = 'other'");
+ break;
+ default:
+ map.put("err", "bad expiryReason");
+ return map;
+ }
+ }
+
+ long stime = getTimeFromParam(req.getParameter("start"));
+ if (stime < 0) {
+ map.put("err", "bad start");
+ return map;
+ }
+ long etime = getTimeFromParam(req.getParameter("end"));
+ if (etime < 0) {
+ map.put("err", "bad end");
+ return map;
+ }
+ if (stime == 0 && etime == 0) {
+ etime = System.currentTimeMillis();
+ stime = etime - TWENTYFOUR_HOURS;
+ } else if (stime == 0) {
+ stime = etime - TWENTYFOUR_HOURS;
+ } else if (etime == 0) {
+ etime = stime + TWENTYFOUR_HOURS;
+ }
+ map.put("timeSQL", String.format(" AND EVENT_TIME >= %d AND EVENT_TIME <= %d", stime, etime));
return map;
- }
}
- long stime = getTimeFromParam(req.getParameter("start"));
- if (stime < 0) {
- map.put("err", "bad start");
- return map;
- }
- long etime = getTimeFromParam(req.getParameter("end"));
- if (etime < 0) {
- map.put("err", "bad end");
- return map;
- }
- if (stime == 0 && etime == 0) {
- etime = System.currentTimeMillis();
- stime = etime - TWENTYFOUR_HOURS;
- } else if (stime == 0) {
- stime = etime - TWENTYFOUR_HOURS;
- } else if (etime == 0) {
- etime = stime + TWENTYFOUR_HOURS;
+ private long getTimeFromParam(final String s) {
+ if (s == null) {
+ return 0;
+ }
+ try {
+ // First, look for an RFC 3339 date
+ String fmt = (s.indexOf('.') > 0) ? FMT2 : FMT1;
+ SimpleDateFormat sdf = new SimpleDateFormat(fmt);
+ Date d = sdf.parse(s);
+ return d.getTime();
+ } catch (ParseException e) {
+ intlogger.error("Exception in getting Time :- " + e.getMessage(), e);
+ }
+ try {
+ // Also allow a long (in ms); useful for testing
+ return Long.parseLong(s);
+ } catch (NumberFormatException e) {
+ intlogger.error("Exception in getting Time :- " + e.getMessage(), e);
+ }
+ intlogger.info("Error parsing time=" + s);
+ return -1;
}
- map.put("timeSQL", String.format(" AND EVENT_TIME >= %d AND EVENT_TIME <= %d", stime, etime));
- return map;
- }
- private long getTimeFromParam(final String s) {
- if (s == null) {
- return 0;
- }
- try {
- // First, look for an RFC 3339 date
- String fmt = (s.indexOf('.') > 0) ? FMT2 : FMT1;
- SimpleDateFormat sdf = new SimpleDateFormat(fmt);
- Date d = sdf.parse(s);
- return d.getTime();
- } catch (ParseException e) {
- }
- try {
- // Also allow a long (in ms); useful for testing
- return Long.parseLong(s);
- } catch (NumberFormatException e) {
- }
- intlogger.info("Error parsing time=" + s);
- return -1;
- }
-
- private void getRecordsForSQL(Map<String, String> map, String outputType, ServletOutputStream out, HttpServletResponse resp) {
- try {
-
- String filterQuery = this.queryGeneretor(map);
- eventlogger.debug("SQL Query for Statistics resultset. " + filterQuery);
- intlogger.debug(filterQuery);
- long start = System.currentTimeMillis();
- DB db = new DB();
- try (Connection conn = db.getConnection()) {
- try (ResultSet rs = conn.prepareStatement(filterQuery).executeQuery()) {
- if ("csv".equals(outputType)) {
- resp.setContentType("application/octet-stream");
- Date date = new Date();
- SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-YYYY HH:mm:ss");
- resp.setHeader("Content-Disposition",
- "attachment; filename=\"result:" + dateFormat.format(date) + ".csv\"");
- eventlogger.info("Generating CSV file from Statistics resultset");
-
- rsToCSV(rs, out);
- } else {
- eventlogger.info("Generating JSON for Statistics resultset");
- this.rsToJson(rs, out);
- }
- }
- } catch (SQLException e) {
- eventlogger.error("SQLException:" + e);
- }
- intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms");
- } catch (IOException e) {
- eventlogger.error("IOException - Generating JSON/CSV:" + e);
- } catch (JSONException e) {
- eventlogger.error("JSONException - executing SQL query:" + e);
- } catch (ParseException e) {
- eventlogger.error("ParseException - executing SQL query:" + e);
+ private void getRecordsForSQL(Map<String, String> map, String outputType, ServletOutputStream out, HttpServletResponse resp) {
+ try {
+ String filterQuery = this.queryGeneretor(map);
+ eventlogger.debug("SQL Query for Statistics resultset. " + filterQuery);
+ intlogger.debug(filterQuery);
+ long start = System.currentTimeMillis();
+ DB db = new DB();
+ try (Connection conn = db.getConnection()) {
+ try (ResultSet rs = conn.prepareStatement(filterQuery).executeQuery()) {
+ if ("csv".equals(outputType)) {
+ resp.setContentType("application/octet-stream");
+ Date date = new Date();
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-YYYY HH:mm:ss");
+ resp.setHeader("Content-Disposition",
+ "attachment; filename=\"result:" + dateFormat.format(date) + ".csv\"");
+ eventlogger.info("Generating CSV file from Statistics resultset");
+ rsToCSV(rs, out);
+ } else {
+ eventlogger.info("Generating JSON for Statistics resultset");
+ this.rsToJson(rs, out);
+ }
+ }
+ db.release(conn);
+ } catch (SQLException e) {
+ eventlogger.error("SQLException:" + e);
+ }
+ intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms");
+ } catch (IOException e) {
+ eventlogger.error("IOException - Generating JSON/CSV:" + e);
+ } catch (JSONException e) {
+ eventlogger.error("JSONException - executing SQL query:" + e);
+ } catch (ParseException e) {
+ eventlogger.error("ParseException - executing SQL query:" + e);
+ }
}
- }
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java
index 125c50d8..715c5e14 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java
@@ -24,16 +24,18 @@
package org.onap.dmaap.datarouter.provisioning;
+import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.util.ArrayList;
import java.util.List;
-import java.util.Vector;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.dmaap.datarouter.authz.AuthorizationResponse;
@@ -41,11 +43,6 @@ import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
import org.onap.dmaap.datarouter.provisioning.beans.Subscription;
import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
-
/**
* This servlet handles provisioning for the &lt;subscriptionURL&gt; which is generated by the provisioning server to
* handle the inspection, modification, and deletion of a particular subscription to a feed. It supports DELETE to
@@ -515,16 +512,16 @@ public class SubscriptionServlet extends ProxyServlet {
* A Thread class used to serially send reset notifications to all nodes in the DR network, when a POST is received
* for a subscription.
*/
- public class SubscriberNotifyThread extends Thread {
+ public static class SubscriberNotifyThread extends Thread {
- public static final String URL_TEMPLATE = "http://%s/internal/resetSubscription/%d";
- private List<String> urls = new Vector<>();
+ static final String URL_TEMPLATE = "http://%s/internal/resetSubscription/%d";
+ private List<String> urls = new ArrayList<>();
- public SubscriberNotifyThread() {
+ SubscriberNotifyThread() {
setName("SubscriberNotifyThread");
}
- public void resetSubscription(int subid) {
+ void resetSubscription(int subid) {
for (String nodename : BaseServlet.getNodes()) {
String u = String.format(URL_TEMPLATE, nodename, subid);
urls.add(u);
@@ -533,23 +530,26 @@ public class SubscriptionServlet extends ProxyServlet {
@Override
public void run() {
-
try {
while (!urls.isEmpty()) {
- String u = urls.remove(0);
- try {
- URL url = new URL(u);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.connect();
- conn.getContentLength(); // Force the GET through
- conn.disconnect();
- } catch (IOException e) {
- intlogger.info("PROV0194 Error accessing URL: " + u + ": " + e.getMessage(), e);
- }
+ String url = urls.remove(0);
+ forceGetThrough(url);
}
} catch (Exception e) {
intlogger.warn("PROV0195 Caught exception in SubscriberNotifyThread: " + e.getMessage(), e);
}
}
+
+ private void forceGetThrough(String url) {
+ try {
+ URL urlObj = new URL(url);
+ HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();
+ conn.connect();
+ conn.getContentLength(); // Force the GET through
+ conn.disconnect();
+ } catch (IOException e) {
+ intlogger.info("PROV0194 Error accessing URL: " + url + ": " + e.getMessage(), e);
+ }
+ }
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java
index 0bce4910..648c4e54 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java
@@ -41,6 +41,9 @@ import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;
* @version $Id: DeliveryRecord.java,v 1.9 2014/03/12 19:45:41 eby Exp $
*/
public class DeliveryRecord extends BaseLogRecord {
+
+ private static final String STATUS_CODE = "statusCode";
+ private static final String DELIVERY_ID = "deliveryId";
private int subid;
private String fileid;
private int result;
@@ -53,12 +56,12 @@ public class DeliveryRecord extends BaseLogRecord {
*/
public DeliveryRecord(String[] pp) throws ParseException {
super(pp);
- String fileid = pp[5];
- if (fileid.lastIndexOf('/') >= 0) {
- fileid = fileid.substring(fileid.lastIndexOf('/') + 1);
+ String thisFileid = pp[5];
+ if (thisFileid.lastIndexOf('/') >= 0) {
+ thisFileid = thisFileid.substring(thisFileid.lastIndexOf('/') + 1);
}
this.subid = Integer.parseInt(pp[4]);
- this.fileid = fileid;
+ this.fileid = thisFileid;
this.result = Integer.parseInt(pp[10]);
this.user = pp[9];
if (this.user != null && this.user.length() > 50) {
@@ -119,14 +122,12 @@ public class DeliveryRecord extends BaseLogRecord {
public LOGJSONObject reOrderObject(LOGJSONObject jo) {
LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();
- logrecordObj.put("statusCode", jo.get("statusCode"));
- logrecordObj.put("deliveryId", jo.get("deliveryId"));
+ logrecordObj.put(STATUS_CODE, jo.get(STATUS_CODE));
+ logrecordObj.put(DELIVERY_ID, jo.get(DELIVERY_ID));
logrecordObj.put("publishId", jo.get("publishId"));
logrecordObj.put("requestURI", jo.get("requestURI"));
- //logrecordObj.put("sourceIP", jo.get("sourceIP"));
logrecordObj.put("method", jo.get("method"));
logrecordObj.put("contentType", jo.get("contentType"));
- //logrecordObj.put("endpointId", jo.get("endpointId"));
logrecordObj.put("type", jo.get("type"));
logrecordObj.put("date", jo.get("date"));
logrecordObj.put("contentLength", jo.get("contentLength"));
@@ -139,8 +140,8 @@ public class DeliveryRecord extends BaseLogRecord {
public LOGJSONObject asJSONObject() {
LOGJSONObject jo = super.asJSONObject();
jo.put("type", "del");
- jo.put("deliveryId", user);
- jo.put("statusCode", result);
+ jo.put(DELIVERY_ID, user);
+ jo.put(STATUS_CODE, result);
return this.reOrderObject(jo);
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java
index 54d5b39f..2b6462db 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java
@@ -57,10 +57,6 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
public EgressRoute(int subid, int nodeid) {
this.subid = subid;
this.nodeid = nodeid;
- // Note: unlike for Feeds, it subscriptions can be removed from the tables, so it is
- // possible that an orphan ERT entry can exist if a sub is removed.
- // if (Subscription.getSubscriptionById(subid) == null)
- // throw new IllegalArgumentException("No such subscription: "+subid);
}
public EgressRoute(int subid, String node) {
@@ -149,7 +145,6 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
ps.setInt(1, this.subid);
ps.setInt(2, this.nodeid);
ps.execute();
- ps.close();
rv = true;
} catch (SQLException e) {
intlogger.warn("PROV0005 doInsert: " + e.getMessage(), e);
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java
index d812036a..4c7fffaa 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java
@@ -41,9 +41,12 @@ import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;
* @version $Id: ExpiryRecord.java,v 1.4 2013/10/28 18:06:52 eby Exp $
*/
public class ExpiryRecord extends BaseLogRecord {
+
+ public static final String EXPIRY_REASON = "expiryReason";
+ public static final String ATTEMPTS = "attempts";
private int subid;
private String fileid;
- private int attempts;
+ private int deliveryAttempts;
private String reason;
/**
@@ -53,13 +56,13 @@ public class ExpiryRecord extends BaseLogRecord {
*/
public ExpiryRecord(String[] pp) throws ParseException {
super(pp);
- String fileid = pp[5];
- if (fileid.lastIndexOf('/') >= 0) {
- fileid = fileid.substring(fileid.lastIndexOf('/') + 1);
+ String thisFileid = pp[5];
+ if (thisFileid.lastIndexOf('/') >= 0) {
+ thisFileid = thisFileid.substring(thisFileid.lastIndexOf('/') + 1);
}
this.subid = Integer.parseInt(pp[4]);
- this.fileid = fileid;
- this.attempts = Integer.parseInt(pp[10]);
+ this.fileid = thisFileid;
+ this.deliveryAttempts = Integer.parseInt(pp[10]);
this.reason = pp[9];
if (!reason.equals("notRetryable") && !reason.equals("retriesExhausted") && !reason.equals("diskFull")) {
this.reason = "other";
@@ -75,7 +78,7 @@ public class ExpiryRecord extends BaseLogRecord {
super(rs);
this.subid = rs.getInt("DELIVERY_SUBID");
this.fileid = rs.getString("DELIVERY_FILEID");
- this.attempts = rs.getInt("ATTEMPTS");
+ this.deliveryAttempts = rs.getInt("ATTEMPTS");
this.reason = rs.getString("REASON");
}
@@ -95,12 +98,12 @@ public class ExpiryRecord extends BaseLogRecord {
this.fileid = fileid;
}
- public int getAttempts() {
- return attempts;
+ public int getDeliveryAttempts() {
+ return deliveryAttempts;
}
- public void setAttempts(int attempts) {
- this.attempts = attempts;
+ public void setDeliveryAttempts(int deliveryAttempts) {
+ this.deliveryAttempts = deliveryAttempts;
}
public String getReason() {
@@ -119,9 +122,9 @@ public class ExpiryRecord extends BaseLogRecord {
public LOGJSONObject reOrderObject(LOGJSONObject jo) {
LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();
- logrecordObj.put("expiryReason", jo.get("expiryReason"));
+ logrecordObj.put(EXPIRY_REASON, jo.get(EXPIRY_REASON));
logrecordObj.put("publishId", jo.get("publishId"));
- logrecordObj.put("attempts", jo.get("attempts"));
+ logrecordObj.put(ATTEMPTS, jo.get(ATTEMPTS));
logrecordObj.put("requestURI", jo.get("requestURI"));
logrecordObj.put("method", jo.get("method"));
logrecordObj.put("contentType", jo.get("contentType"));
@@ -136,8 +139,8 @@ public class ExpiryRecord extends BaseLogRecord {
public LOGJSONObject asJSONObject() {
LOGJSONObject jo = super.asJSONObject();
jo.put("type", "exp");
- jo.put("expiryReason", reason);
- jo.put("attempts", attempts);
+ jo.put(EXPIRY_REASON, reason);
+ jo.put(ATTEMPTS, deliveryAttempts);
return reOrderObject(jo);
}
@@ -153,7 +156,7 @@ public class ExpiryRecord extends BaseLogRecord {
ps.setInt(13, getSubid());
ps.setString(14, getFileid());
ps.setNull(15, Types.INTEGER);
- ps.setInt(16, getAttempts());
+ ps.setInt(16, getDeliveryAttempts());
ps.setString(17, getReason());
ps.setNull(19, Types.BIGINT);
ps.setNull(20, Types.VARCHAR);
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java
index a8be6b3f..4a14da2f 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java
@@ -200,7 +200,7 @@ public class Feed extends Syncable {
Feed feed = map.get(id);
if (feed != null) {
FeedEndpointID epi = new FeedEndpointID(rs);
- Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
+ Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpointIDS();
ecoll.add(epi);
}
}
@@ -212,7 +212,7 @@ public class Feed extends Syncable {
int id = rs.getInt("FEEDID");
Feed feed = map.get(id);
if (feed != null) {
- Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
+ Collection<String> acoll = feed.getAuthorization().getEndpointAddrs();
acoll.add(rs.getString("ADDR"));
}
}
@@ -281,7 +281,7 @@ public class Feed extends Syncable {
if (feed != null) {
sql = "select * from FEED_ENDPOINT_IDS where FEEDID = " + feed.feedid;
try (ResultSet rs = stmt.executeQuery(sql)) {
- Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
+ Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpointIDS();
while (rs.next()) {
FeedEndpointID epi = new FeedEndpointID(rs);
ecoll.add(epi);
@@ -289,7 +289,7 @@ public class Feed extends Syncable {
}
sql = "select * from FEED_ENDPOINT_ADDRS where FEEDID = " + feed.feedid;
try (ResultSet rs = stmt.executeQuery(sql)) {
- Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
+ Collection<String> acoll = feed.getAuthorization().getEndpointAddrs();
while (rs.next()) {
acoll.add(rs.getString("ADDR"));
}
@@ -413,9 +413,9 @@ public class Feed extends Syncable {
//Fortify scan fixes - Privacy Violation
throw new InvalidObjectException("password field is too long (" + fid.getPassword() + ")");
}
- this.authorization.getEndpoint_ids().add(fid);
+ this.authorization.getEndpointIDS().add(fid);
}
- if (this.authorization.getEndpoint_ids().isEmpty()) {
+ if (this.authorization.getEndpointIDS().isEmpty()) {
throw new InvalidObjectException("need to specify at least one endpoint_id");
}
endPointIds = jauth.getJSONArray("endpoint_addrs");
@@ -424,7 +424,7 @@ public class Feed extends Syncable {
if (!JSONUtilities.validIPAddrOrSubnet(addr)) {
throw new InvalidObjectException("bad IP addr or subnet mask: " + addr);
}
- this.authorization.getEndpoint_addrs().add(addr);
+ this.authorization.getEndpointAddrs().add(addr);
}
this.publisher = jo.optString("publisher", "");
@@ -651,7 +651,7 @@ public class Feed extends Syncable {
FeedAuthorization auth = getAuthorization();
String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
try (PreparedStatement ps2 = conn.prepareStatement(sql)) {
- for (FeedEndpointID fid : auth.getEndpoint_ids()) {
+ for (FeedEndpointID fid : auth.getEndpointIDS()) {
ps2.setInt(1, feedid);
ps2.setString(2, fid.getId());
ps2.setString(3, fid.getPassword());
@@ -662,7 +662,7 @@ public class Feed extends Syncable {
// Create FEED_ENDPOINT_ADDRS rows
sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
try (PreparedStatement ps2 = conn.prepareStatement(sql)) {
- for (String t : auth.getEndpoint_addrs()) {
+ for (String t : auth.getEndpointAddrs()) {
ps2.setInt(1, feedid);
ps2.setString(2, t);
ps2.executeUpdate();
@@ -705,8 +705,8 @@ public class Feed extends Syncable {
Feed oldobj = getFeedById(feedid);
PreparedStatement ps = null;
try {
- Set<FeedEndpointID> newset = getAuthorization().getEndpoint_ids();
- Set<FeedEndpointID> oldset = oldobj.getAuthorization().getEndpoint_ids();
+ Set<FeedEndpointID> newset = getAuthorization().getEndpointIDS();
+ Set<FeedEndpointID> oldset = oldobj.getAuthorization().getEndpointIDS();
// Insert new FEED_ENDPOINT_IDS rows
String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
@@ -735,8 +735,8 @@ public class Feed extends Syncable {
ps.close();
// Insert new FEED_ENDPOINT_ADDRS rows
- Set<String> newset2 = getAuthorization().getEndpoint_addrs();
- Set<String> oldset2 = oldobj.getAuthorization().getEndpoint_addrs();
+ Set<String> newset2 = getAuthorization().getEndpointAddrs();
+ Set<String> oldset2 = oldobj.getAuthorization().getEndpointAddrs();
sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
ps = conn.prepareStatement(sql);
for (String t : newset2) {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
index ff08f594..fad6a33f 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
@@ -60,19 +60,19 @@ public class FeedAuthorization implements JSONable {
this.classification = classification;
}
- public Set<FeedEndpointID> getEndpoint_ids() {
+ public Set<FeedEndpointID> getEndpointIDS() {
return endpointIds;
}
- public void setEndpoint_ids(Set<FeedEndpointID> endpointIds) {
+ public void setEndpointIDS(Set<FeedEndpointID> endpointIds) {
this.endpointIds = endpointIds;
}
- public Set<String> getEndpoint_addrs() {
+ public Set<String> getEndpointAddrs() {
return endpointAddrs;
}
- public void setEndpoint_addrs(Set<String> endpointAddrs) {
+ public void setEndpointAddrs(Set<String> endpointAddrs) {
this.endpointAddrs = endpointAddrs;
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java
index 779bffa8..d3ee6436 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java
@@ -24,9 +24,7 @@
package org.onap.dmaap.datarouter.provisioning.beans;
-import java.io.InvalidObjectException;
import java.util.Objects;
-
import org.json.JSONObject;
/**
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java
index e0756f9f..3f685900 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java
@@ -152,10 +152,7 @@ public class Group extends Syncable {
*/
public static Group getGroupMatching(Group gup, int groupid) {
String sql = String.format(
- "select * from GROUPS where NAME = '%s' and GROUPID != %d ",
- gup.getName(),
- gup.getGroupid()
- );
+ "select * from GROUPS where NAME = '%s' and GROUPID != %d ", gup.getName(), gup.getGroupid());
List<Group> list = getGroupsForSQL(sql);
return !list.isEmpty() ? list.get(0) : null;
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java
index f1fa54c7..555c5b69 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java
@@ -398,7 +398,6 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
ps.setString(2, userid);
ps.setString(3, subnet);
ps.execute();
- ps.close();
// Delete the NodeSet
ps2.setInt(1, nodelist);
ps2.execute();
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java
index 4afb61cd..f5a2000a 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java
@@ -42,6 +42,11 @@ import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;
*/
public class PublishRecord extends BaseLogRecord {
+
+ public static final String STATUS_CODE = "statusCode";
+ public static final String SOURCE_IP = "sourceIP";
+ public static final String ENDPOINT_ID = "endpointId";
+ public static final String FILE_NAME = "fileName";
private String feedFileid;
private String remoteAddr;
private String user;
@@ -134,17 +139,17 @@ public class PublishRecord extends BaseLogRecord {
LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();
- logrecordObj.put("statusCode", jo.get("statusCode"));
+ logrecordObj.put(STATUS_CODE, jo.get(STATUS_CODE));
logrecordObj.put("publishId", jo.get("publishId"));
logrecordObj.put("requestURI", jo.get("requestURI"));
- logrecordObj.put("sourceIP", jo.get("sourceIP"));
+ logrecordObj.put(SOURCE_IP, jo.get(SOURCE_IP));
logrecordObj.put("method", jo.get("method"));
logrecordObj.put("contentType", jo.get("contentType"));
- logrecordObj.put("endpointId", jo.get("endpointId"));
+ logrecordObj.put(ENDPOINT_ID, jo.get(ENDPOINT_ID));
logrecordObj.put("type", jo.get("type"));
logrecordObj.put("date", jo.get("date"));
logrecordObj.put("contentLength", jo.get("contentLength"));
- logrecordObj.put("fileName", jo.get("fileName"));
+ logrecordObj.put(FILE_NAME, jo.get(FILE_NAME));
return new LOGJSONObject(logrecordObj);
}
@@ -157,10 +162,10 @@ public class PublishRecord extends BaseLogRecord {
jo.put("feedFileid", feedFileid);
jo.put("remoteAddr", remoteAddr);
jo.put("user", user);
- jo.put("sourceIP", remoteAddr);
- jo.put("endpointId", user);
- jo.put("statusCode", status);
- jo.put("fileName", fileName);
+ jo.put(SOURCE_IP, remoteAddr);
+ jo.put(ENDPOINT_ID, user);
+ jo.put(STATUS_CODE, status);
+ jo.put(FILE_NAME, fileName);
return this.reOrderObject(jo);
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java
index 9c10fb3d..c076ffb4 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java
@@ -24,9 +24,7 @@
package org.onap.dmaap.datarouter.provisioning.beans;
-import java.io.InvalidObjectException;
import java.util.Objects;
-
import org.json.JSONObject;
/**
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/JSONUtilities.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/JSONUtilities.java
index 2d4e22b3..9abd5a83 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/JSONUtilities.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/JSONUtilities.java
@@ -39,6 +39,10 @@ import java.util.Collection;
public class JSONUtilities {
private static final EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog");
+
+ private JSONUtilities(){
+
+ }
/**
* Does the String <i>v</i> represent a valid Internet address (with or without a
* mask length appended).
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTask.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTask.java
index c34e9541..7cb1c02a 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTask.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTask.java
@@ -27,6 +27,8 @@ package org.onap.dmaap.datarouter.provisioning.utils;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
import java.util.Objects;
import java.util.Properties;
import java.util.TimerTask;
@@ -76,7 +78,11 @@ public class PurgeLogDirTask extends TimerTask {
long exptime = System.currentTimeMillis() - interval;
for (File logfile : Objects.requireNonNull(dir.listFiles())) {
if (logfile.lastModified() < exptime) {
- logfile.delete();
+ try {
+ Files.delete(logfile.toPath());
+ } catch (IOException e) {
+ utilsLogger.error("Failed to delete file: " + logfile.getPath(), e);
+ }
}
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSet.java
index 7914c81d..b57ceb12 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSet.java
@@ -129,7 +129,7 @@ public class RLEBitSet {
@Override
public int hashCode() {
- return new Long(start ^ nbits).hashCode();
+ return Long.valueOf(start ^ nbits).hashCode();
}
@Override
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilter.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilter.java
index b0fd4f40..da06f6bb 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilter.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilter.java
@@ -24,6 +24,8 @@
package org.onap.dmaap.datarouter.provisioning.utils;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -32,8 +34,6 @@ import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
-import java.util.Vector;
-
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -42,12 +42,10 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.eclipse.jetty.continuation.Continuation;
import org.eclipse.jetty.continuation.ContinuationSupport;
-import org.eclipse.jetty.server.*;
+import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.Request;
import org.onap.dmaap.datarouter.provisioning.beans.Parameters;
/**
@@ -88,9 +86,9 @@ import org.onap.dmaap.datarouter.provisioning.beans.Parameters;
* @version $Id: ThrottleFilter.java,v 1.2 2014/03/12 19:45:41 eby Exp $
*/
public class ThrottleFilter extends TimerTask implements Filter {
- public static final int DEFAULT_N = 10;
- public static final int DEFAULT_M = 5;
- public static final String THROTTLE_MARKER = "org.onap.dmaap.datarouter.provisioning.THROTTLE_MARKER";
+ private static final int DEFAULT_N = 10;
+ private static final int DEFAULT_M = 5;
+ private static final String THROTTLE_MARKER = "org.onap.dmaap.datarouter.provisioning.THROTTLE_MARKER";
private static final String JETTY_REQUEST = "org.eclipse.jetty.server.Request";
private static final long ONE_MINUTE = 60000L;
private static final int ACTION_DROP = 0;
@@ -98,8 +96,8 @@ public class ThrottleFilter extends TimerTask implements Filter {
// Configuration
private static boolean enabled = false; // enabled or not
- private static int n_requests = 0; // number of requests in M minutes
- private static int m_minutes = 0; // sampling period
+ private static int numRequests = 0; // number of requests in M minutes
+ private static int samplingPeriod = 0; // sampling period
private static int action = ACTION_DROP; // action to take (throttle or drop)
private static EELFLogger logger = EELFManager.getInstance().getLogger("InternalLog");
@@ -121,19 +119,20 @@ public class ThrottleFilter extends TimerTask implements Filter {
try {
Class.forName(JETTY_REQUEST);
String v = p.getValue();
- if (v != null && !v.equals("off")) {
+ if (v != null && !"off".equals(v)) {
String[] pp = v.split(",");
if (pp != null) {
- n_requests = (pp.length > 0) ? getInt(pp[0], DEFAULT_N) : DEFAULT_N;
- m_minutes = (pp.length > 1) ? getInt(pp[1], DEFAULT_M) : DEFAULT_M;
- action = (pp.length > 2 && pp[2] != null && pp[2].equalsIgnoreCase("throttle")) ? ACTION_THROTTLE : ACTION_DROP;
+ numRequests = (pp.length > 0) ? getInt(pp[0], DEFAULT_N) : DEFAULT_N;
+ samplingPeriod = (pp.length > 1) ? getInt(pp[1], DEFAULT_M) : DEFAULT_M;
+ action = (pp.length > 2 && pp[2] != null && "throttle".equalsIgnoreCase(pp[2])) ? ACTION_THROTTLE : ACTION_DROP;
enabled = true;
// ACTION_THROTTLE is not currently working, so is not supported
if (action == ACTION_THROTTLE) {
action = ACTION_DROP;
logger.info("Throttling is not currently supported; action changed to DROP");
}
- logger.info("ThrottleFilter is ENABLED for /publish requests; N=" + n_requests + ", M=" + m_minutes + ", Action=" + action);
+ logger.info("ThrottleFilter is ENABLED for /publish requests; N=" + numRequests + ", M=" + samplingPeriod
+ + ", Action=" + action);
return;
}
}
@@ -175,27 +174,29 @@ public class ThrottleFilter extends TimerTask implements Filter {
public void dropFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws IOException, ServletException {
int rate = getRequestRate(request);
- if (rate >= n_requests) {
+ if (rate >= numRequests) {
// drop request - only works under Jetty
- String m = String.format("Dropping connection: %s %d bad connections in %d minutes", getConnectionId(request), rate, m_minutes);
+ String m = String.format("Dropping connection: %s %d bad connections in %d minutes", getConnectionId(request), rate,
+ samplingPeriod);
logger.info(m);
- Request base_request = (request instanceof Request)
+ Request baseRequest = (request instanceof Request)
? (Request) request
: HttpConnection.getCurrentConnection().getHttpChannel().getRequest();
- base_request.getHttpChannel().getEndPoint().close();
+ baseRequest.getHttpChannel().getEndPoint().close();
} else {
chain.doFilter(request, response);
}
}
- public void throttleFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
+ private void throttleFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws IOException, ServletException {
// throttle request
String id = getConnectionId(request);
int rate = getRequestRate(request);
Object results = request.getAttribute(THROTTLE_MARKER);
- if (rate >= n_requests && results == null) {
- String m = String.format("Throttling connection: %s %d bad connections in %d minutes", getConnectionId(request), rate, m_minutes);
+ if (rate >= numRequests && results == null) {
+ String m = String.format("Throttling connection: %s %d bad connections in %d minutes",
+ getConnectionId(request), rate, samplingPeriod);
logger.info(m);
Continuation continuation = ContinuationSupport.getContinuation(request);
continuation.suspend();
@@ -214,22 +215,22 @@ public class ThrottleFilter extends TimerTask implements Filter {
}
}
- private Map<String, List<Continuation>> suspended_requests = new HashMap<>();
+ private Map<String, List<Continuation>> suspendedRequests = new HashMap<>();
private void register(String id, Continuation continuation) {
- synchronized (suspended_requests) {
- List<Continuation> list = suspended_requests.get(id);
+ synchronized (suspendedRequests) {
+ List<Continuation> list = suspendedRequests.get(id);
if (list == null) {
list = new ArrayList<>();
- suspended_requests.put(id, list);
+ suspendedRequests.put(id, list);
}
list.add(continuation);
}
}
private void resume(String id) {
- synchronized (suspended_requests) {
- List<Continuation> list = suspended_requests.get(id);
+ synchronized (suspendedRequests) {
+ List<Continuation> list = suspendedRequests.get(id);
if (list != null) {
// when the waited for event happens
Continuation continuation = list.remove(0);
@@ -248,7 +249,7 @@ public class ThrottleFilter extends TimerTask implements Filter {
*/
private int getRequestRate(HttpServletRequest request) {
String expecthdr = request.getHeader("Expect");
- if (expecthdr != null && expecthdr.equalsIgnoreCase("100-continue"))
+ if (expecthdr != null && "100-continue".equalsIgnoreCase(expecthdr))
return 0;
String key = getConnectionId(request);
@@ -263,11 +264,11 @@ public class ThrottleFilter extends TimerTask implements Filter {
}
public class Counter {
- private List<Long> times = new Vector<>(); // a record of request times
+ private List<Long> times = new ArrayList<>(); // a record of request times
public int prune() {
try {
- long n = System.currentTimeMillis() - (m_minutes * ONE_MINUTE);
+ long n = System.currentTimeMillis() - (samplingPeriod * ONE_MINUTE);
long t = times.get(0);
while (t < n) {
times.remove(0);
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java
index 7ef52ff8..7b77a1ea 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java
@@ -64,15 +64,7 @@ public class EgressRouteTest {
}
@Test
- public void Verify_NetworkRoute_Is_Added_Successfully() throws SQLException {
- Assert.assertEquals(1, EgressRoute.getAllEgressRoutes().size());
- egressRoute.doInsert(db.getConnection());
- Assert.assertEquals(2, EgressRoute.getAllEgressRoutes().size());
- egressRoute.doDelete(db.getConnection());
- }
-
- @Test
- public void Verify_NetworkRoute_Is_Removed_Successfully() throws SQLException {
+ public void Verify_EgressRoute_Is_Removed_Successfully() throws SQLException {
Assert.assertEquals(1, EgressRoute.getAllEgressRoutes().size());
EgressRoute egressRoute = new EgressRoute(1, 1);
egressRoute.doDelete(db.getConnection());
@@ -80,7 +72,7 @@ public class EgressRouteTest {
}
@Test
- public void Verify_NetworkRoute_Is_Updated_Successfully() throws SQLException {
+ public void Verify_EgressRoute_Is_Updated_Successfully() throws SQLException {
EgressRoute egressRoute = new EgressRoute(1, 1);
EgressRoute egressRoute1 = new EgressRoute(1, 1);
Assert.assertEquals(egressRoute.hashCode(), egressRoute1.hashCode());
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecordTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecordTest.java
index 34a6d979..1bf34e40 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecordTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecordTest.java
@@ -46,7 +46,7 @@ public class ExpiryRecordTest {
Assert.assertEquals(2000, expiryRecord.getContentLength());
Assert.assertEquals(285, expiryRecord.getSubid());
Assert.assertEquals("file.txt", expiryRecord.getFileid());
- Assert.assertEquals(100, expiryRecord.getAttempts());
+ Assert.assertEquals(100, expiryRecord.getDeliveryAttempts());
Assert.assertEquals("other", expiryRecord.getReason());
}
@@ -63,7 +63,7 @@ public class ExpiryRecordTest {
expiryRecord.setMethod("PUT");
expiryRecord.setSubid(322);
expiryRecord.setFileid("file.txt");
- expiryRecord.setAttempts(125);
+ expiryRecord.setDeliveryAttempts(125);
expiryRecord.setReason("Out of memory");
LOGJSONObject expiryRecordJson = createBaseLogRecordJson();
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/FeedTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/FeedTest.java
index dcab5410..9db43223 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/FeedTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/FeedTest.java
@@ -140,8 +140,8 @@ public class FeedTest {
setA.add(new FeedEndpointID("1", "Name"));
Set setB = new HashSet();
setB.add("172.0.0.1");
- fa.setEndpoint_ids(setA);
- fa.setEndpoint_addrs(setB);
+ fa.setEndpointIDS(setA);
+ fa.setEndpointAddrs(setB);
feed.setAuthorization(fa);
Assert.assertEquals(feed.doInsert(connection), false);
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java
index df786b55..d727bc77 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java
@@ -64,14 +64,6 @@ public class NetworkRouteTest {
}
@Test
- public void Verify_NetworkRoute_Is_Added_Successfully() throws SQLException {
- Assert.assertEquals(1, NetworkRoute.getAllNetworkRoutes().size());
- networkRoute.doInsert(db.getConnection());
- Assert.assertEquals(2, NetworkRoute.getAllNetworkRoutes().size());
- networkRoute.doDelete(db.getConnection());
- }
-
- @Test
public void Verify_NetworkRoute_Is_Removed_Successfully() throws SQLException {
Assert.assertEquals(1, NetworkRoute.getAllNetworkRoutes().size());
NetworkRoute networkRoute = new NetworkRoute("stub_from.", "stub_to.");
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilterTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilterTest.java
index a8e919b7..94ef3b72 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilterTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilterTest.java
@@ -108,7 +108,7 @@ public class ThrottleFilterTest {
List<Continuation> continuation_list = new ArrayList<>();
continuation_list.add(continuation);
suspended_requests.put("null/-1", continuation_list);
- FieldUtils.writeDeclaredField(throttlefilter, "suspended_requests", suspended_requests, true);
+ FieldUtils.writeDeclaredField(throttlefilter, "suspendedRequests", suspended_requests, true);
throttlefilter.doFilter(request, response, filterchain);
verify(continuation, times(1)).setAttribute(anyString(), any());
verify(continuation, times(1)).resume();