diff options
author | Bharat saraswal <bharat.saraswal@huawei.com> | 2017-09-20 21:33:45 +0530 |
---|---|---|
committer | Bharat saraswal <bharat.saraswal@huawei.com> | 2017-09-21 15:03:02 +0000 |
commit | ce21545c8db4d39aa869f3b03e0d42dd91fb098d (patch) | |
tree | 3d7c647e4eb36f062f0617de8fbc8bd303bd2ce6 /common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java | |
parent | 9676feb7225fdfc5353c86f6805cb0df32f965f6 (diff) |
Redundant code removal and hadrcoded strings
Issue-Id:POLICY-252
Change-Id: I839811ba15d0c478c83c03818087d3153b77ddb1
Signed-off-by: Bharat saraswal <bharat.saraswal@huawei.com>
Diffstat (limited to 'common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java')
-rw-r--r-- | common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java index 58699867..6c31a990 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java @@ -23,62 +23,62 @@ package org.onap.policy.common.logging.eelf; import java.util.concurrent.ConcurrentHashMap; /** - * - * EventTrackInfo contains a ConcurrentHashMap of EventData - * + * EventTrackInfo contains a ConcurrentHashMap of EventData. */ public class EventTrackInfo { - private ConcurrentHashMap<String, EventData> eventInfo = null; - - public EventTrackInfo() { - /* - * An initial capacity of 16 ensures the number of elements before resizing happens - * Load factor of 0,9 ensures a dense packaging inside ConcurrentHashMap which will optimize memory use - * ConcurencyLevel set to 1 will ensure that only one shard is created and maintained - */ - eventInfo = new ConcurrentHashMap<>(16, 0.9f, 1); - } - - /** - * Returns an instance of EventData associated to this requestID - * @param requestID - * @return EventData - */ - public EventData getEventDataByRequestID(String requestID){ - return eventInfo.get(requestID); - } - - /** - * Stores an EventData object in a ConcurrentHashMap using its requestID as key. - * @param event - */ - public void storeEventData(EventData event){ - - if(event == null || event.getRequestID() == null || event.getRequestID().isEmpty()){ - return; - } - //in case override the start time, check the original event was already stored or not - if(!eventInfo.containsKey(event.getRequestID())){ - eventInfo.put(event.getRequestID(), event); - } - } - - /** - * Removes an EventData object from a ConcurrentHashMap using the eventId as key. - * @param eventId - */ - public void remove(String eventId){ - if(eventInfo != null){ - eventInfo.remove(eventId); - } - } - - /** - * Returns a ConcurrentHashMap of EventData - */ - public ConcurrentHashMap<String, EventData> getEventInfo() { - return eventInfo; - } + private ConcurrentHashMap<String, EventData> eventInfo = null; + + public EventTrackInfo() { + /* + * An initial capacity of 16 ensures the number of elements before resizing happens + * Load factor of 0,9 ensures a dense packaging inside ConcurrentHashMap which will optimize memory use + * Concurrency Level set to 1 will ensure that only one shard is created and maintained + */ + eventInfo = new ConcurrentHashMap<>(16, 0.9f, 1); + } + + /** + * Returns an instance of EventData associated to this requestID + * @param requestID request id + * @return EventData + */ + public EventData getEventDataByRequestID(String requestID) { + return eventInfo.get(requestID); + } + + /** + * Stores an EventData object in a ConcurrentHashMap using its requestID as key. + * @param event event data + */ + public void storeEventData(EventData event) { + + if (event != null) { + String id = event.getRequestID(); + if (id == null || id.isEmpty()) { + return; + } + //in case override the start time, check the original event was already stored or not + if (!eventInfo.containsKey(id)) { + eventInfo.put(id, event); + } + } + } + + /** + * Removes an EventData object from a ConcurrentHashMap using the eventId as key. + * @param eventId event id + */ + public void remove(String eventId) { + if (eventInfo != null) { + eventInfo.remove(eventId); + } + } + /** + * Returns a ConcurrentHashMap of EventData + */ + public ConcurrentHashMap<String, EventData> getEventInfo() { + return eventInfo; + } } |