cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r889794 - /incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
Date Fri, 11 Dec 2009 20:16:38 GMT
Author: jbellis
Date: Fri Dec 11 20:16:38 2009
New Revision: 889794

URL: http://svn.apache.org/viewvc?rev=889794&view=rev
Log:
reformat, rename away underscores from CompactionManager.  patch by jbellis

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java?rev=889794&r1=889793&r2=889794&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java Fri
Dec 11 20:16:38 2009
@@ -39,37 +39,35 @@
 
 public class CompactionManager implements CompactionManagerMBean
 {
-    public static String MBEAN_OBJECT_NAME = "org.apache.cassandra.db:type=CompactionManager";
-    private static CompactionManager instance_;
-    private static Lock lock_ = new ReentrantLock();
-    private static Logger logger_ = Logger.getLogger(CompactionManager.class);
-    private int minimumCompactionThreshold_ = 4; // compact this many sstables min at a time
+    public static final String MBEAN_OBJECT_NAME = "org.apache.cassandra.db:type=CompactionManager";
+    private static final Logger logger = Logger.getLogger(CompactionManager.class);
+    private static volatile CompactionManager instance;
+
+    private int minimumCompactionThreshold = 4; // compact this many sstables min at a time
     private int maximumCompactionThreshold = 32; // compact this many sstables max at a time
 
     public static CompactionManager instance()
     {
-        if ( instance_ == null )
+        if (instance == null)
         {
-            lock_.lock();
-            try
+            synchronized (CompactionManager.class)
             {
-                if ( instance_ == null )
+                try
                 {
-                    instance_ = new CompactionManager();
-                    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-                    mbs.registerMBean(instance_, new ObjectName(MBEAN_OBJECT_NAME));
+                    if (instance == null)
+                    {
+                        instance = new CompactionManager();
+                        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+                        mbs.registerMBean(instance, new ObjectName(MBEAN_OBJECT_NAME));
+                    }
+                }
+                catch (Exception e)
+                {
+                    throw new RuntimeException(e);
                 }
-            }
-            catch (Exception e)
-            {
-                throw new RuntimeException(e);
-            }
-            finally
-            {
-                lock_.unlock();
             }
         }
-        return instance_;
+        return instance;
     }
 
     static abstract class Compactor<T> implements Callable<T>
@@ -85,8 +83,8 @@
         public T call()
         {
         	T results;
-            if (logger_.isDebugEnabled())
-                logger_.debug("Starting " + this + ".");
+            if (logger.isDebugEnabled())
+                logger.debug("Starting " + this + ".");
             try
             {
                 results = compact();
@@ -95,8 +93,8 @@
             {
                 throw new RuntimeException(e);
             }
-            if (logger_.isDebugEnabled())
-                logger_.debug("Finished " + this + ".");
+            if (logger.isDebugEnabled())
+                logger.debug("Finished " + this + ".");
             return results;
         }
 
@@ -200,7 +198,7 @@
      */
     public Future<Integer> submit(final ColumnFamilyStore columnFamilyStore)
     {
-        return submit(columnFamilyStore, minimumCompactionThreshold_, maximumCompactionThreshold);
+        return submit(columnFamilyStore, minimumCompactionThreshold, maximumCompactionThreshold);
     }
 
     Future<Integer> submit(final ColumnFamilyStore columnFamilyStore, final int minThreshold,
final int maxThreshold)
@@ -233,7 +231,7 @@
      */
     public int getMinimumCompactionThreshold()
     {
-        return minimumCompactionThreshold_;
+        return minimumCompactionThreshold;
     }
 
     /**
@@ -241,7 +239,7 @@
      */
     public void setMinimumCompactionThreshold(int threshold)
     {
-        minimumCompactionThreshold_ = threshold;
+        minimumCompactionThreshold = threshold;
     }
 
     /**
@@ -262,7 +260,7 @@
 
     public void disableCompactions()
     {
-        minimumCompactionThreshold_ = 0;
+        minimumCompactionThreshold = 0;
         maximumCompactionThreshold = 0;
     }
 }



Mime
View raw message