aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/main
diff options
context:
space:
mode:
authorUsaraswat <saraswat.urwashi@amdocs.com>2018-02-15 10:51:41 -0500
committerUsaraswat <saraswat.urwashi@amdocs.com>2018-02-15 11:53:14 -0500
commit994af15b37645138e3dba72da556057534d975fd (patch)
treeb66eb41d9814799ded048ff09d950ac0c3cfc5f7 /common/src/main
parent16c4941d63b517e26067492aae621b2e03321ec4 (diff)
Optimize number of MsoLogger instances
Each call to getMsoLogger creates a new instance of MsoLogger which is a potential memory leak Change-Id: Ib0dda3abbf45d8633b4c8a2d49aa9d5c87e12931 Issue-ID: LOG-174 Signed-off-by: Usaraswat <saraswat.urwashi@amdocs.com>
Diffstat (limited to 'common/src/main')
-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;
+ }
}
/**