summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2018-02-21 09:56:30 +0000
committerGerrit Code Review <gerrit@onap.org>2018-02-21 09:56:30 +0000
commit7028cbe90f84f3ea8b872632297ac6cc2e2b48db (patch)
treed518f3a5e4527610bf76e4f6210f0263fe46d021
parentabebcbec32768b48d6ad5513d82ea94a12d98f01 (diff)
parent994af15b37645138e3dba72da556057534d975fd (diff)
Merge "Optimize number of MsoLogger instances"
-rw-r--r--common/src/main/java/org/openecomp/mso/logger/MsoLogger.java46
1 files changed, 36 insertions, 10 deletions
diff --git a/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java b/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java
index 86aedc1a43..b8c4aed8fa 100644
--- a/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java
+++ b/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java
@@ -144,15 +144,16 @@ public class MsoLogger {
// For internal logging of the initialization of MSO logs
private static final Logger LOGGER = Logger.getLogger(MsoLogger.class.getName());
- private MsoLogger(MsoLogger.Catalog cat) {
- this.logger = EELFManager.getInstance().getErrorLogger();
- this.auditLogger = EELFManager.getInstance().getAuditLogger();
- this.metricsLogger = EELFManager.getInstance().getMetricsLogger();
- MsoLogger.initialization();
- setDefaultLogCatalog(cat);
- }
- private static synchronized void initialization() {
+ // Since four adaptors are using the instance of MsoLogger which will be referenced everywhere
+ // hence limiting the number of MsoLogger instances to five.
+ private static final MsoLogger generalMsoLogger = new MsoLogger(Catalog.GENERAL);
+ private static final MsoLogger apihLogger = new MsoLogger(Catalog.APIH);
+ private static final MsoLogger asdcLogger = new MsoLogger(Catalog.ASDC);
+ private static final MsoLogger raLogger = new MsoLogger(Catalog.RA);
+ private static final MsoLogger bpelLogger = new MsoLogger(Catalog.BPEL);
+
+ static {
if (instanceUUID == null || ("").equals(instanceUUID)) {
instanceUUID = getInstanceUUID();
}
@@ -170,15 +171,40 @@ public class MsoLogger {
}
}
+ // Singleton instances of the EELFLogger of all types are referenced by MsoLogger
+ private MsoLogger(Catalog cat) {
+ this.logger = EELFManager.getInstance().getErrorLogger();
+ this.auditLogger = EELFManager.getInstance().getAuditLogger();
+ this.metricsLogger = EELFManager.getInstance().getMetricsLogger();
+ this.setDefaultLogCatalog(cat);
+ }
+
+
+
/**
* Get the MsoLogger based on the catalog
- *
+ * This method is fixed now to resolve the total number of objects that are getting created
+ * everytime this function gets called. Its supposed to have fixed number of instance per java process.
+ *
* @param cat
* Catalog of the logger
* @return the MsoLogger
*/
public static synchronized MsoLogger getMsoLogger(MsoLogger.Catalog cat) {
- return new MsoLogger(cat);
+ switch (cat) {
+ case GENERAL:
+ return generalMsoLogger;
+ case APIH:
+ return apihLogger;
+ case RA:
+ return raLogger;
+ case BPEL:
+ return bpelLogger;
+ case ASDC:
+ return asdcLogger;
+ default:
+ return generalMsoLogger;
+ }
}
/**