accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [03/21] accumulo git commit: ACCUMULO-3801 moved GarbageCollectionLogger to proper module
Date Wed, 20 May 2015 16:24:47 GMT
ACCUMULO-3801 moved GarbageCollectionLogger to proper module


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/c16fd9d1
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/c16fd9d1
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/c16fd9d1

Branch: refs/heads/1.7
Commit: c16fd9d1552085bf135c399e1ca32fad3737edb3
Parents: 4db7766
Author: Keith Turner <kturner@apache.org>
Authored: Tue May 12 11:08:53 2015 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Tue May 12 12:00:09 2015 -0400

----------------------------------------------------------------------
 .../server/GarbageCollectionLogger.java         | 116 +++++++++++++++++++
 .../server/GarbageCollectionLogger.java         | 116 -------------------
 2 files changed, 116 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/c16fd9d1/server/base/src/main/java/org/apache/accumulo/server/GarbageCollectionLogger.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/GarbageCollectionLogger.java
b/server/base/src/main/java/org/apache/accumulo/server/GarbageCollectionLogger.java
new file mode 100644
index 0000000..389a544
--- /dev/null
+++ b/server/base/src/main/java/org/apache/accumulo/server/GarbageCollectionLogger.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server;
+
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.ManagementFactory;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.server.util.Halt;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GarbageCollectionLogger {
+  private static final Logger log = LoggerFactory.getLogger(GarbageCollectionLogger.class);
+
+  private final HashMap<String,Long> prevGcTime = new HashMap<String,Long>();
+  private long lastMemorySize = 0;
+  private long gcTimeIncreasedCount = 0;
+  private static long lastMemoryCheckTime = 0;
+
+  public GarbageCollectionLogger() {}
+
+  public synchronized void logGCInfo(AccumuloConfiguration conf) {
+    final long now = System.currentTimeMillis();
+
+    List<GarbageCollectorMXBean> gcmBeans = ManagementFactory.getGarbageCollectorMXBeans();
+    Runtime rt = Runtime.getRuntime();
+
+    StringBuilder sb = new StringBuilder("gc");
+
+    boolean sawChange = false;
+
+    long maxIncreaseInCollectionTime = 0;
+
+    for (GarbageCollectorMXBean gcBean : gcmBeans) {
+      Long prevTime = prevGcTime.get(gcBean.getName());
+      long pt = 0;
+      if (prevTime != null) {
+        pt = prevTime;
+      }
+
+      long time = gcBean.getCollectionTime();
+
+      if (time - pt != 0) {
+        sawChange = true;
+      }
+
+      long increaseInCollectionTime = time - pt;
+      sb.append(String.format(" %s=%,.2f(+%,.2f) secs", gcBean.getName(), time / 1000.0,
increaseInCollectionTime / 1000.0));
+      maxIncreaseInCollectionTime = Math.max(increaseInCollectionTime, maxIncreaseInCollectionTime);
+      prevGcTime.put(gcBean.getName(), time);
+    }
+
+    long mem = rt.freeMemory();
+    if (maxIncreaseInCollectionTime == 0) {
+      gcTimeIncreasedCount = 0;
+    } else {
+      gcTimeIncreasedCount++;
+      if (gcTimeIncreasedCount > 3 && mem < rt.maxMemory() * 0.05) {
+        log.warn("Running low on memory");
+        gcTimeIncreasedCount = 0;
+      }
+    }
+
+    if (mem > lastMemorySize) {
+      sawChange = true;
+    }
+
+    String sign = "+";
+    if (mem - lastMemorySize <= 0) {
+      sign = "";
+    }
+
+    sb.append(String.format(" freemem=%,d(%s%,d) totalmem=%,d", mem, sign, (mem - lastMemorySize),
rt.totalMemory()));
+
+    if (sawChange) {
+      log.debug(sb.toString());
+    }
+
+    final long keepAliveTimeout = conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT);
+    if (lastMemoryCheckTime > 0 && lastMemoryCheckTime < now) {
+      final long diff = now - lastMemoryCheckTime;
+      if (diff > keepAliveTimeout + 1000) {
+        log.warn(String.format("GC pause checker not called in a timely fashion. Expected
every %.1f seconds but was %.1f seconds since last check",
+            keepAliveTimeout / 1000., diff / 1000.));
+      }
+      lastMemoryCheckTime = now;
+      return;
+    }
+
+    if (maxIncreaseInCollectionTime > keepAliveTimeout) {
+      Halt.halt("Garbage collection may be interfering with lock keep-alive.  Halting.",
-1);
+    }
+
+    lastMemorySize = mem;
+    lastMemoryCheckTime = now;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c16fd9d1/server/tserver/src/main/java/org/apache/accumulo/server/GarbageCollectionLogger.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/server/GarbageCollectionLogger.java
b/server/tserver/src/main/java/org/apache/accumulo/server/GarbageCollectionLogger.java
deleted file mode 100644
index 389a544..0000000
--- a/server/tserver/src/main/java/org/apache/accumulo/server/GarbageCollectionLogger.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server;
-
-import java.lang.management.GarbageCollectorMXBean;
-import java.lang.management.ManagementFactory;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.server.util.Halt;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GarbageCollectionLogger {
-  private static final Logger log = LoggerFactory.getLogger(GarbageCollectionLogger.class);
-
-  private final HashMap<String,Long> prevGcTime = new HashMap<String,Long>();
-  private long lastMemorySize = 0;
-  private long gcTimeIncreasedCount = 0;
-  private static long lastMemoryCheckTime = 0;
-
-  public GarbageCollectionLogger() {}
-
-  public synchronized void logGCInfo(AccumuloConfiguration conf) {
-    final long now = System.currentTimeMillis();
-
-    List<GarbageCollectorMXBean> gcmBeans = ManagementFactory.getGarbageCollectorMXBeans();
-    Runtime rt = Runtime.getRuntime();
-
-    StringBuilder sb = new StringBuilder("gc");
-
-    boolean sawChange = false;
-
-    long maxIncreaseInCollectionTime = 0;
-
-    for (GarbageCollectorMXBean gcBean : gcmBeans) {
-      Long prevTime = prevGcTime.get(gcBean.getName());
-      long pt = 0;
-      if (prevTime != null) {
-        pt = prevTime;
-      }
-
-      long time = gcBean.getCollectionTime();
-
-      if (time - pt != 0) {
-        sawChange = true;
-      }
-
-      long increaseInCollectionTime = time - pt;
-      sb.append(String.format(" %s=%,.2f(+%,.2f) secs", gcBean.getName(), time / 1000.0,
increaseInCollectionTime / 1000.0));
-      maxIncreaseInCollectionTime = Math.max(increaseInCollectionTime, maxIncreaseInCollectionTime);
-      prevGcTime.put(gcBean.getName(), time);
-    }
-
-    long mem = rt.freeMemory();
-    if (maxIncreaseInCollectionTime == 0) {
-      gcTimeIncreasedCount = 0;
-    } else {
-      gcTimeIncreasedCount++;
-      if (gcTimeIncreasedCount > 3 && mem < rt.maxMemory() * 0.05) {
-        log.warn("Running low on memory");
-        gcTimeIncreasedCount = 0;
-      }
-    }
-
-    if (mem > lastMemorySize) {
-      sawChange = true;
-    }
-
-    String sign = "+";
-    if (mem - lastMemorySize <= 0) {
-      sign = "";
-    }
-
-    sb.append(String.format(" freemem=%,d(%s%,d) totalmem=%,d", mem, sign, (mem - lastMemorySize),
rt.totalMemory()));
-
-    if (sawChange) {
-      log.debug(sb.toString());
-    }
-
-    final long keepAliveTimeout = conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT);
-    if (lastMemoryCheckTime > 0 && lastMemoryCheckTime < now) {
-      final long diff = now - lastMemoryCheckTime;
-      if (diff > keepAliveTimeout + 1000) {
-        log.warn(String.format("GC pause checker not called in a timely fashion. Expected
every %.1f seconds but was %.1f seconds since last check",
-            keepAliveTimeout / 1000., diff / 1000.));
-      }
-      lastMemoryCheckTime = now;
-      return;
-    }
-
-    if (maxIncreaseInCollectionTime > keepAliveTimeout) {
-      Halt.halt("Garbage collection may be interfering with lock keep-alive.  Halting.",
-1);
-    }
-
-    lastMemorySize = mem;
-    lastMemoryCheckTime = now;
-  }
-
-}


Mime
View raw message