You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2018/05/29 12:29:55 UTC

[ambari] branch trunk updated: AMBARI-23963. Logfeeder errors out with OOM GC overhead limit exceeded (~500 MB LRU cache size) (#1394)

This is an automated email from the ASF dual-hosted git repository.

oleewere pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new e410e8c  AMBARI-23963. Logfeeder errors out with OOM GC overhead limit exceeded (~500 MB LRU cache size) (#1394)
e410e8c is described below

commit e410e8c8370430e82105dd371038b77078af8d91
Author: Olivér Szabó <ol...@gmail.com>
AuthorDate: Tue May 29 14:29:48 2018 +0200

    AMBARI-23963. Logfeeder errors out with OOM GC overhead limit exceeded (~500 MB LRU cache size) (#1394)
---
 .../logfeeder/plugin/input/cache/LRUCache.java     | 28 +++++++++++++---------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/ambari-logsearch/ambari-logsearch-logfeeder-plugin-api/src/main/java/org/apache/ambari/logfeeder/plugin/input/cache/LRUCache.java b/ambari-logsearch/ambari-logsearch-logfeeder-plugin-api/src/main/java/org/apache/ambari/logfeeder/plugin/input/cache/LRUCache.java
index 9ee8743..5e13811 100644
--- a/ambari-logsearch/ambari-logsearch-logfeeder-plugin-api/src/main/java/org/apache/ambari/logfeeder/plugin/input/cache/LRUCache.java
+++ b/ambari-logsearch/ambari-logsearch-logfeeder-plugin-api/src/main/java/org/apache/ambari/logfeeder/plugin/input/cache/LRUCache.java
@@ -18,8 +18,6 @@
  */
 package org.apache.ambari.logfeeder.plugin.input.cache;
 
-import com.google.common.collect.EvictingQueue;
-
 import java.io.Serializable;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -34,13 +32,13 @@ public class LRUCache implements Serializable {
   private final String fileName;
   private final long dedupInterval;
   private final boolean lastDedupEnabled;
-  private final EvictingQueue<String> mostRecentLogs;
+  private final String[] mostRecentLogs;
 
   public LRUCache(final int limit, final String fileName, final long dedupInterval, boolean lastDedupEnabled) {
     this.fileName = fileName;
     this.dedupInterval = dedupInterval;
     this.lastDedupEnabled = lastDedupEnabled;
-    this.mostRecentLogs = EvictingQueue.create(1); // for now, we will just store 1 mru entry
+    this.mostRecentLogs = new String[1]; // for now, we will just store 1 mru entry TODO: use an MRU implementation
     keyValueMap = new LinkedHashMap<String, Long>(16, 0.75f, true) {
       @Override
       protected boolean removeEldestEntry(final Map.Entry<String, Long> eldest) {
@@ -54,12 +52,12 @@ public class LRUCache implements Serializable {
     Long existingValue = keyValueMap.get(key);
     if (existingValue == null) {
       result = true;
-    } else if (lastDedupEnabled && mostRecentLogs.contains(key)) { // TODO: get peek element if mostRecentLogs will contain more than 1 element
+    } else if (lastDedupEnabled && containsMRUKey(key)) { // TODO: get peek element if mostRecentLogs will contain more than 1 element
       result = false;
     } else if (Math.abs(value - existingValue) < dedupInterval) {
       result = false;
     }
-    mostRecentLogs.add(key);
+    addMRUKey(key);
     return result;
   }
 
@@ -70,14 +68,10 @@ public class LRUCache implements Serializable {
   }
 
   public Long get(String key) {
-    mostRecentLogs.add(key);
+    addMRUKey(key);
     return keyValueMap.get(key);
   }
 
-  public String getMRUKey() {
-    return mostRecentLogs.peek();
-  }
-
   public int size() {
     return keyValueMap.size();
   }
@@ -97,4 +91,16 @@ public class LRUCache implements Serializable {
   public boolean isLastDedupEnabled() {
     return lastDedupEnabled;
   }
+
+  public String getMRUKey() {
+    return mostRecentLogs[0];
+  }
+
+  private void addMRUKey(String key) {
+    mostRecentLogs[0] = key;
+  }
+
+  private boolean containsMRUKey(String key) {
+    return key != null && key.equals(mostRecentLogs[0]);
+  }
 }

-- 
To stop receiving notification emails like this one, please contact
oleewere@apache.org.