accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1333047 - /accumulo/trunk/server/src/main/java/org/apache/accumulo/server/Accumulo.java
Date Wed, 02 May 2012 13:47:28 GMT
Author: ecn
Date: Wed May  2 13:47:28 2012
New Revision: 1333047

URL: http://svn.apache.org/viewvc?rev=1333047&view=rev
Log:
ACCUMULO-49 monitor swappiness everywhere all the time

Modified:
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/Accumulo.java

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/Accumulo.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/Accumulo.java?rev=1333047&r1=1333046&r2=1333047&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/Accumulo.java (original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/Accumulo.java Wed May 
2 13:47:28 2012
@@ -17,10 +17,13 @@
 package org.apache.accumulo.server;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Map.Entry;
+import java.util.TimerTask;
 import java.util.TreeMap;
 
 import org.apache.accumulo.core.Constants;
@@ -30,6 +33,7 @@ import org.apache.accumulo.core.util.Uti
 import org.apache.accumulo.core.util.Version;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.conf.ServerConfiguration;
+import org.apache.accumulo.server.util.time.SimpleTimer;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -129,8 +133,40 @@ public class Accumulo {
       else
         log.info(entry.getKey() + " = " + entry.getValue());
     }
+    
+    monitorSwappiness();
   }
   
+  /**
+   * 
+   */
+  public static void monitorSwappiness() {
+    SimpleTimer.getInstance().schedule(new TimerTask() {
+      @Override
+      public void run() {
+        try {
+          File swappiness = new File("/proc/sys/vm/swappiness");
+          if (swappiness.exists() && swappiness.canRead()) {
+            InputStream is = new FileInputStream("/proc/sys/vm/swappiness");
+            try {
+              byte[] buffer = new byte[10];
+              int bytes = is.read(buffer);
+              String setting = new String(buffer, 0, bytes);
+              if (bytes > 0 && Integer.parseInt(setting) > 0) {
+                log.warn("System swappiness setting is greater than zero (" + setting + ")
which can cause time-sensitive operations to be delayed. "
+                    + " Accumulo is time sensitive because it needs to maintain distributed
lock agreement.");
+              }
+            } finally {
+              is.close();
+            }
+          }
+        } catch (Throwable t) {
+          log.error(t, t);
+        }
+      }
+    }, 1000, 10 * 1000);
+  }
+
   public static String getLocalAddress(String[] args) throws UnknownHostException {
     InetAddress result = InetAddress.getLocalHost();
     for (int i = 0; i < args.length - 1; i++) {



Mime
View raw message