Code Review
/
dmaap
/
messagerouter
/
mirroragent.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
[DMAAP MM] Update info.yaml
[dmaap/messagerouter/mirroragent.git]
/
src
/
main
/
java
/
org
/
onap
/
dmaap
/
mr
/
dmaapMMAgent
/
MirrorMakerAgent.java
diff --git
a/src/main/java/org/onap/dmaap/mr/dmaapMMAgent/MirrorMakerAgent.java
b/src/main/java/org/onap/dmaap/mr/dmaapMMAgent/MirrorMakerAgent.java
index
de19474
..
f47adfb
100644
(file)
--- a/
src/main/java/org/onap/dmaap/mr/dmaapMMAgent/MirrorMakerAgent.java
+++ b/
src/main/java/org/onap/dmaap/mr/dmaapMMAgent/MirrorMakerAgent.java
@@
-21,23
+21,20
@@
*******************************************************************************/
package org.onap.dmaap.mr.dmaapMMAgent;
*******************************************************************************/
package org.onap.dmaap.mr.dmaapMMAgent;
-import
java.io.BufferedReader
;
-import
java.io.DataOutputStream
;
+import
com.google.gson.Gson
;
+import
com.google.gson.internal.LinkedTreeMap
;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Properties;
import java.util.ArrayList;
import java.util.Properties;
-import org.
json.JSONObject
;
-import org.apache.log4j.Logger;
+import org.
apache.logging.log4j.LogManager
;
+import org.apache.log
ging.log
4j.Logger;
import org.jasypt.util.text.BasicTextEncryptor;
import org.jasypt.util.text.BasicTextEncryptor;
-
+import org.json.JSONObject;
import org.onap.dmaap.mr.dmaapMMAgent.dao.CreateMirrorMaker;
import org.onap.dmaap.mr.dmaapMMAgent.dao.DeleteMirrorMaker;
import org.onap.dmaap.mr.dmaapMMAgent.dao.ListMirrorMaker;
import org.onap.dmaap.mr.dmaapMMAgent.dao.CreateMirrorMaker;
import org.onap.dmaap.mr.dmaapMMAgent.dao.DeleteMirrorMaker;
import org.onap.dmaap.mr.dmaapMMAgent.dao.ListMirrorMaker;
@@
-45,15
+42,9
@@
import org.onap.dmaap.mr.dmaapMMAgent.dao.MirrorMaker;
import org.onap.dmaap.mr.dmaapMMAgent.dao.UpdateMirrorMaker;
import org.onap.dmaap.mr.dmaapMMAgent.dao.UpdateWhiteList;
import org.onap.dmaap.mr.dmaapMMAgent.utils.MirrorMakerProcessHandler;
import org.onap.dmaap.mr.dmaapMMAgent.dao.UpdateMirrorMaker;
import org.onap.dmaap.mr.dmaapMMAgent.dao.UpdateWhiteList;
import org.onap.dmaap.mr.dmaapMMAgent.utils.MirrorMakerProcessHandler;
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.internal.LinkedTreeMap;
-
-import com.sun.org.apache.xerces.internal.impl.dtd.models.CMAny;
-import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
public class MirrorMakerAgent {
public class MirrorMakerAgent {
-
static final Logger logger = Log
ger.getLogger(MirrorMakerAgent.class);
+
private static final Logger logger = LogMana
ger.getLogger(MirrorMakerAgent.class);
Properties mirrorMakerProperties = new Properties();
ListMirrorMaker mirrorMakers = null;
String mmagenthome = "/opt";
Properties mirrorMakerProperties = new Properties();
ListMirrorMaker mirrorMakers = null;
String mmagenthome = "/opt";
@@
-87,8
+78,7
@@
public class MirrorMakerAgent {
try {
agent.checkAgentProcess();
} catch (Exception e) {
try {
agent.checkAgentProcess();
} catch (Exception e) {
-
- e.printStackTrace();
+ logger.error("exception occured in checkAgentProcess ", e);
}
agent.readAgentTopic();
} else {
}
agent.readAgentTopic();
} else {
@@
-100,18
+90,17
@@
public class MirrorMakerAgent {
private boolean checkStartup() {
FileInputStream input = null;
try {
private boolean checkStartup() {
FileInputStream input = null;
try {
- //this.mmagenthome = System.getProperty("MMAGENTHOME");
input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
logger.info("mmagenthome is set :" + mmagenthome + " loading properties at /etc/mmagent.config");
} catch (IOException ex) {
input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
logger.info("mmagenthome is set :" + mmagenthome + " loading properties at /etc/mmagent.config");
} catch (IOException ex) {
- logger.error(mmagenthome + "/etc/mmagent.config not found.
Set -DMMAGENTHOME and check the config file"
);
+ logger.error(mmagenthome + "/etc/mmagent.config not found.
", ex
);
return false;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
return false;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
-
e.printStackTrace(
);
+
logger.error("exception occured in checkStartup "+e
);
}
}
}
}
}
}
@@
-119,16
+108,16
@@
public class MirrorMakerAgent {
input = null;
try {
input = new FileInputStream(kafkahome + "/bin/kafka-run-class.sh");
input = null;
try {
input = new FileInputStream(kafkahome + "/bin/kafka-run-class.sh");
- logger.info("kakahome is set :" + kafkahome);
+ logger.info("ka
f
kahome is set :" + kafkahome);
} catch (IOException ex) {
} catch (IOException ex) {
- logger.error(kafkahome + "/bin/kafka-run-class.sh not found. Make sure kafka home is set correctly");
+ logger.error(kafkahome + "/bin/kafka-run-class.sh not found. Make sure kafka home is set correctly"
, ex
);
return false;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
return false;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
-
e.printStackTrace(
);
+
logger.error("exception occured in checkStartup "+e
);
}
}
}
}
}
}
@@
-139,7
+128,7
@@
public class MirrorMakerAgent {
return false;
}
logger.info("Published to Topic :" + this.topicname + " Successfully");
return false;
}
logger.info("Published to Topic :" + this.topicname + " Successfully");
- response = topicUtil.subscribeTopic(topicURL, topicname, "1",
response, response
);
+ response = topicUtil.subscribeTopic(topicURL, topicname, "1",
mechid, password
);
if (response != null && response.startsWith("ERROR:")) {
logger.error("Problem subscribing to topic, please verify the config " + this.topicname + " MR URL is:"
+ this.topicURL + " Error is: " + response);
if (response != null && response.startsWith("ERROR:")) {
logger.error("Problem subscribing to topic, please verify the config " + this.topicname + " MR URL is:"
+ this.topicURL + " Error is: " + response);
@@
-176,21
+165,21
@@
public class MirrorMakerAgent {
prop.store(out, "");
} catch (Exception e) {
prop.store(out, "");
} catch (Exception e) {
-
e.printStackTrace(
);
+
logger.error("exception occured in checkPropertiesFile "+e
);
}
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
}
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
-
e.printStackTrace(
);
+
logger.error("exception occured in checkPropertiesFile ", e
);
}
}
if (out != null) {
try {
out.close();
} catch (IOException e) {
}
}
if (out != null) {
try {
out.close();
} catch (IOException e) {
-
e.printStackTrace(
);
+
logger.error("exception occured in checkPropertiesFile "+e
);
}
}
}
}
}
}
@@
-278,7
+267,7
@@
public class MirrorMakerAgent {
}
} catch (Exception e) {
}
} catch (Exception e) {
-
e.printStackTrace(
);
+
logger.error("exception occured in readAgentTopic ", e
);
}
}
}
}
@@
-316,13
+305,13
@@
public class MirrorMakerAgent {
out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
mirrorMakerProperties.store(out, "");
} catch (IOException ex) {
out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
mirrorMakerProperties.store(out, "");
} catch (IOException ex) {
-
ex.printStackTrace(
);
+
logger.error("exception occured in createMirrorMaker ", ex
);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
-
e.printStackTrace(
);
+
logger.error("exception occured in createMirrorMaker ", e
);
}
}
}
}
}
}
@@
-370,13
+359,13
@@
public class MirrorMakerAgent {
} catch (InterruptedException e) {
}
} catch (IOException ex) {
} catch (InterruptedException e) {
}
} catch (IOException ex) {
-
ex.printStackTrace(
);
+
logger.error("exception occured in updateMirrorMaker ", ex
);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
-
e.printStackTrace(
);
+
logger.error("exception occured in updateMirrorMaker ", e
);
}
}
}
}
}
}
@@
-413,13
+402,13
@@
public class MirrorMakerAgent {
} catch (InterruptedException e) {
}
} catch (IOException ex) {
} catch (InterruptedException e) {
}
} catch (IOException ex) {
-
ex.printStackTrace(
);
+
logger.error("exception occured in updateWhiteList ", ex
);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
-
e.printStackTrace(
);
+
logger.error("exception occured in updateWhiteList ", e
);
}
}
}
}
}
}
@@
-448,12
+437,14
@@
public class MirrorMakerAgent {
File file = new File(path);
file.delete();
} catch (Exception ex) {
File file = new File(path);
file.delete();
} catch (Exception ex) {
+ logger.error("exception occured in deleteMirrorMaker ", ex);
}
try {
String path = mmagenthome + "/etc/" + newMirrorMaker.name + "producer" + ".properties";
File file = new File(path);
file.delete();
} catch (Exception ex) {
}
try {
String path = mmagenthome + "/etc/" + newMirrorMaker.name + "producer" + ".properties";
File file = new File(path);
file.delete();
} catch (Exception ex) {
+ logger.error("exception occured in deleteMirrorMaker ", ex);
}
Gson g = new Gson();
mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
}
Gson g = new Gson();
mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
@@
-463,13
+454,13
@@
public class MirrorMakerAgent {
mirrorMakerProperties.store(out, "");
MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
} catch (IOException ex) {
mirrorMakerProperties.store(out, "");
MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
} catch (IOException ex) {
-
ex.printStackTrace(
);
+
logger.error("exception occured in deleteMirrorMaker ", ex
);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
-
e.printStackTrace(
);
+
logger.error("exception occured in deleteMirrorMaker ", e
);
}
}
}
}
}
}
@@
-488,7
+479,7
@@
public class MirrorMakerAgent {
if (mirrorMakerProperties.getProperty("mirrormakers") == null) {
this.mirrorMakers = new ListMirrorMaker();
ArrayList<MirrorMaker> list = this.mirrorMakers.getListMirrorMaker();
if (mirrorMakerProperties.getProperty("mirrormakers") == null) {
this.mirrorMakers = new ListMirrorMaker();
ArrayList<MirrorMaker> list = this.mirrorMakers.getListMirrorMaker();
- list = new ArrayList<
MirrorMaker
>();
+ list = new ArrayList<>();
this.mirrorMakers.setListMirrorMaker(list);
} else {
this.mirrorMakers = g.fromJson(mirrorMakerProperties.getProperty("mirrormakers"),
this.mirrorMakers.setListMirrorMaker(list);
} else {
this.mirrorMakers = g.fromJson(mirrorMakerProperties.getProperty("mirrormakers"),
@@
-505,13
+496,13
@@
public class MirrorMakerAgent {
textEncryptor.setPassword(secret);
this.password = textEncryptor.decrypt(mirrorMakerProperties.getProperty("password"));
} catch (Exception ex) {
textEncryptor.setPassword(secret);
this.password = textEncryptor.decrypt(mirrorMakerProperties.getProperty("password"));
} catch (Exception ex) {
-
// ex.printStackTrace(
);
+
logger.error("exception occured in loadProperties ", ex
);
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
-
// e.printStackTrace(
);
+
logger.error("exception occured in loadProperties ", e
);
}
}
}
}
}
}