summaryrefslogtreecommitdiffstats
path: root/datarouter-prov
diff options
context:
space:
mode:
Diffstat (limited to 'datarouter-prov')
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/InternalServlet.java3
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java6
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java3
-rwxr-xr-xdatarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java4
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObject.java6
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java2
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/reports/FeedReport.java48
7 files changed, 22 insertions, 50 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/InternalServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/InternalServlet.java
index c35978b6..685d5528 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/InternalServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/InternalServlet.java
@@ -156,6 +156,7 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
@SuppressWarnings("serial")
public class InternalServlet extends ProxyServlet {
+ private static final Object lock = new Object();
private static Integer logseq = 0; // another piece of info to make log spool file names unique
//Adding EELF Logger Rally:US664892
private static EELFLogger eelflogger = EELFManager.getInstance()
@@ -454,7 +455,7 @@ public class InternalServlet extends ProxyServlet {
}
String spooldir = (new DB()).getProperties().getProperty("org.onap.dmaap.datarouter.provserver.spooldir");
String spoolname = String.format("%d-%d-", System.currentTimeMillis(), Thread.currentThread().getId());
- synchronized (logseq) {
+ synchronized (lock) {
// perhaps unnecessary, but it helps make the name unique
spoolname += logseq.toString();
logseq++;
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 f2c511c1..563e6f7f 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
@@ -64,6 +64,8 @@ public class Poker extends TimerTask {
*/
private static final String POKE_URL_TEMPLATE = "http://%s/internal/fetchProv";
+ private static final Object lock = new Object();
+
/**
* This is a singleton -- there is only one Poker object in the server
*/
@@ -109,7 +111,7 @@ public class Poker extends TimerTask {
* @param t2 the second timer set the outer bound on how long to wait. It cannot be reset.
*/
public void setTimers(long t1, long t2) {
- synchronized (thisPod) {
+ synchronized (lock) {
if (timer1 == 0 || t1 > timer1) {
timer1 = t1;
}
@@ -144,7 +146,7 @@ public class Poker extends TimerTask {
if (timer1 > 0) {
long now = System.currentTimeMillis();
boolean fire = false;
- synchronized (thisPod) {
+ synchronized (lock) {
if (now > timer1 || now > timer2) {
timer1 = timer2 = 0;
fire = true;
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java
index d500bb31..05502760 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java
@@ -64,6 +64,7 @@ public class PublishServlet extends BaseServlet {
private List<IngressRoute> irt;
//Adding EELF Logger Rally:US664892
private static EELFLogger eelflogger = EELFManager.getInstance().getLogger("org.onap.dmaap.datarouter.provisioning.PublishServlet");
+ private static final Object lock = new Object();
@Override
@@ -138,7 +139,7 @@ public class PublishServlet extends BaseServlet {
// Check to see if the IRT needs to be updated
Poker p = Poker.getPoker();
String s = p.getProvisioningString();
- synchronized (provstring) {
+ synchronized (lock) {
if (irt == null || (s.length() != provstring.length()) || !s.equals(provstring)) {
// Provisioning string has changed -- update the IRT
provstring = s;
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 3902dc63..b77062fa 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
@@ -546,10 +546,8 @@ public class StatisticsServlet extends BaseServlet {
intlogger.debug(filterQuery);
long start = System.currentTimeMillis();
DB db = new DB();
- ResultSet rs = null;
try (Connection conn = db.getConnection()) {
- try (PreparedStatement pst = conn.prepareStatement(filterQuery)) {
- rs = pst.executeQuery();
+ try (ResultSet rs = conn.prepareStatement(filterQuery).executeQuery()) {
if (outputType.equals("csv")) {
resp.setContentType("application/octet-stream");
Date date = new Date();
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObject.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObject.java
index dec3cc13..1518859a 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObject.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObject.java
@@ -1446,7 +1446,7 @@ public class LOGJSONObject {
try {
return this.toString(0);
} catch (Exception e) {
- return null;
+ return "";
}
}
@@ -1495,7 +1495,7 @@ public class LOGJSONObject {
*/
@SuppressWarnings("unchecked")
public static String valueToString(Object value) throws JSONException {
- if (value == null || value.equals(null)) {
+ if (value == null) {
return "null";
}
if (value instanceof JSONString) {
@@ -1601,7 +1601,7 @@ public class LOGJSONObject {
@SuppressWarnings("unchecked")
static final Writer writeValue(Writer writer, Object value,
int indentFactor, int indent) throws JSONException, IOException {
- if (value == null || value.equals(null)) {
+ if (value == null) {
writer.write("null");
} else if (value instanceof LOGJSONObject) {
((LOGJSONObject) value).write(writer, indentFactor, indent);
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java
index 15cc689c..0c6afdd7 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java
@@ -115,7 +115,7 @@ public class URLUtilities {
public static String generatePeerLogsURL() {
//Fixes for Itrack ticket - DATARTR-4#Fixing if only one Prov is configured, not to give exception to fill logs.
String peerPodUrl = getPeerPodName();
- if (peerPodUrl.equals("") || peerPodUrl==null) {
+ if (peerPodUrl == null || peerPodUrl.equals("")) {
return "";
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/reports/FeedReport.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/reports/FeedReport.java
index 4346a0ec..fe9c4601 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/reports/FeedReport.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/reports/FeedReport.java
@@ -72,36 +72,12 @@ public class FeedReport extends ReportBase {
try( PreparedStatement ps = conn.prepareStatement(SELECT_SQL)) {
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
- if (alg1) {
- String date = rs.getString("date");
- String type = rs.getString("type");
- int feedid = rs.getInt("feedid");
- int subid = type.equals("del") ? rs.getInt("delivery_subid") : 0;
- int count = rs.getInt("count");
- sb.append(date + "," + type + "," + feedid + "," + subid + "," + count + "\n");
- } else {
- String date = rs.getString("date");
- JSONObject datemap = jo.optJSONObject(date);
- if (datemap == null) {
- datemap = new JSONObject();
- jo.put(date, datemap);
- }
- int feed = rs.getInt("FEEDID");
- JSONObject feedmap = datemap.optJSONObject("" + feed);
- if (feedmap == null) {
- feedmap = new JSONObject();
- feedmap.put("pubcount", 0);
- datemap.put("" + feed, feedmap);
- }
- String type = rs.getString("TYPE");
- int count = rs.getInt("count");
- if (type.equals("pub")) {
- feedmap.put("pubcount", count);
- } else if (type.equals("del")) {
- String subid = "" + rs.getInt("DELIVERY_SUBID");
- feedmap.put(subid, count);
- }
- }
+ String date = rs.getString("date");
+ String type = rs.getString("type");
+ int feedid = rs.getInt("feedid");
+ int subid = type.equals("del") ? rs.getInt("delivery_subid") : 0;
+ int count = rs.getInt("count");
+ sb.append(date + "," + type + "," + feedid + "," + subid + "," + count + "\n");
}
}
}
@@ -110,15 +86,9 @@ public class FeedReport extends ReportBase {
e.printStackTrace();
}
logger.debug("Query time: " + (System.currentTimeMillis() - start) + " ms");
- try {
- PrintWriter os = new PrintWriter(outfile);
- if (alg1) {
- os.print("date,type,feedid,subid,count\n");
- os.print(sb.toString());
- } else {
- os.println(toHTML(jo));
- }
- os.close();
+ try (PrintWriter os = new PrintWriter(outfile)) {
+ os.print("date,type,feedid,subid,count\n");
+ os.print(sb.toString());
} catch (FileNotFoundException e) {
System.err.println("File cannot be written: " + outfile);
}