.getLogger("org.onap.dmaap.datarouter.node.NodeServlet");
static {
- try {
- final String ws = "\\s*";
- // assume that \\ and \" have been replaced by X
- final String string = "\"[^\"]*\"";
- //String string = "\"(?:[^\"\\\\]|\\\\.)*\"";
- final String number = "[+-]?(?:\\.\\d+|(?:0|[1-9]\\d*)(?:\\.\\d*)?)(?:[eE][+-]?\\d+)?";
- final String value = "(?:" + string + "|" + number + "|null|true|false)";
- final String item = string + ws + ":" + ws + value + ws;
- final String object = ws + "\\{" + ws + "(?:" + item + "(?:" + "," + ws + item + ")*)?\\}" + ws;
- MetaDataPattern = Pattern.compile(object, Pattern.DOTALL);
- } catch (Exception e) {
- }
+ final String ws = "\\s*";
+ // assume that \\ and \" have been replaced by X
+ final String string = "\"[^\"]*\"";
+ //String string = "\"(?:[^\"\\\\]|\\\\.)*\"";
+ final String number = "[+-]?(?:\\.\\d+|(?:0|[1-9]\\d*)(?:\\.\\d*)?)(?:[eE][+-]?\\d+)?";
+ final String value = "(?:" + string + "|" + number + "|null|true|false)";
+ final String item = string + ws + ":" + ws + value + ws;
+ final String object = ws + "\\{" + ws + "(?:" + item + "(?:" + "," + ws + item + ")*)?\\}" + ws;
+ MetaDataPattern = Pattern.compile(object, Pattern.DOTALL);
}
/**
private static EELFLogger eelfLogger = EELFManager.getInstance()
.getLogger("org.onap.dmaap.datarouter.node.NodeUtils");
private static Logger nodeUtilsLogger = Logger.getLogger("org.onap.dmaap.datarouter.node.NodeUtils");
- private static SimpleDateFormat logDate;
-
- static {
- logDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- logDate.setTimeZone(TimeZone.getTimeZone("GMT"));
- }
private NodeUtils() {
}
* Format a logging timestamp as yyyy-mm-ddThh:mm:ss.mmmZ
*/
public static synchronized String logts(Date when) {
+ SimpleDateFormat logDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ logDate.setTimeZone(TimeZone.getTimeZone("GMT"));
return (logDate.format(when));
}
@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()
}
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++;
*/
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
*/
* @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;
}
if (timer1 > 0) {
long now = System.currentTimeMillis();
boolean fire = false;
- synchronized (thisPod) {
+ synchronized (lock) {
if (now > timer1 || now > timer2) {
timer1 = timer2 = 0;
fire = true;
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
// 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;
intlogger.debug(filterQuery);\r
long start = System.currentTimeMillis();\r
DB db = new DB();\r
- ResultSet rs = null;\r
try (Connection conn = db.getConnection()) {\r
- try (PreparedStatement pst = conn.prepareStatement(filterQuery)) {\r
- rs = pst.executeQuery();\r
+ try (ResultSet rs = conn.prepareStatement(filterQuery).executeQuery()) {\r
if (outputType.equals("csv")) {\r
resp.setContentType("application/octet-stream");\r
Date date = new Date();\r
try {
return this.toString(0);
} catch (Exception e) {
- return null;
+ return "";
}
}
*/
@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) {
@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);
public static String generatePeerLogsURL() {\r
//Fixes for Itrack ticket - DATARTR-4#Fixing if only one Prov is configured, not to give exception to fill logs.\r
String peerPodUrl = getPeerPodName();\r
- if (peerPodUrl.equals("") || peerPodUrl==null) {\r
+ if (peerPodUrl == null || peerPodUrl.equals("")) {\r
return "";\r
}\r
\r
try( PreparedStatement ps = conn.prepareStatement(SELECT_SQL)) {\r
try (ResultSet rs = ps.executeQuery()) {\r
while (rs.next()) {\r
- if (alg1) {\r
- String date = rs.getString("date");\r
- String type = rs.getString("type");\r
- int feedid = rs.getInt("feedid");\r
- int subid = type.equals("del") ? rs.getInt("delivery_subid") : 0;\r
- int count = rs.getInt("count");\r
- sb.append(date + "," + type + "," + feedid + "," + subid + "," + count + "\n");\r
- } else {\r
- String date = rs.getString("date");\r
- JSONObject datemap = jo.optJSONObject(date);\r
- if (datemap == null) {\r
- datemap = new JSONObject();\r
- jo.put(date, datemap);\r
- }\r
- int feed = rs.getInt("FEEDID");\r
- JSONObject feedmap = datemap.optJSONObject("" + feed);\r
- if (feedmap == null) {\r
- feedmap = new JSONObject();\r
- feedmap.put("pubcount", 0);\r
- datemap.put("" + feed, feedmap);\r
- }\r
- String type = rs.getString("TYPE");\r
- int count = rs.getInt("count");\r
- if (type.equals("pub")) {\r
- feedmap.put("pubcount", count);\r
- } else if (type.equals("del")) {\r
- String subid = "" + rs.getInt("DELIVERY_SUBID");\r
- feedmap.put(subid, count);\r
- }\r
- }\r
+ String date = rs.getString("date");\r
+ String type = rs.getString("type");\r
+ int feedid = rs.getInt("feedid");\r
+ int subid = type.equals("del") ? rs.getInt("delivery_subid") : 0;\r
+ int count = rs.getInt("count");\r
+ sb.append(date + "," + type + "," + feedid + "," + subid + "," + count + "\n");\r
}\r
}\r
}\r
e.printStackTrace();\r
}\r
logger.debug("Query time: " + (System.currentTimeMillis() - start) + " ms");\r
- try {\r
- PrintWriter os = new PrintWriter(outfile);\r
- if (alg1) {\r
- os.print("date,type,feedid,subid,count\n");\r
- os.print(sb.toString());\r
- } else {\r
- os.println(toHTML(jo));\r
- }\r
- os.close();\r
+ try (PrintWriter os = new PrintWriter(outfile)) {\r
+ os.print("date,type,feedid,subid,count\n");\r
+ os.print(sb.toString());\r
} catch (FileNotFoundException e) {\r
System.err.println("File cannot be written: " + outfile);\r
}\r
private static Logger logger =
Logger.getLogger("org.onap.dmaap.datarouter.subscriber.SampleSubscriberServlet");
- private String outputDirectory;
- private String basicAuth;
+ private static String outputDirectory;
+ private static String basicAuth;
/**
* Configure the SampleSubscriberServlet.