cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1021935 - in /cassandra/trunk: ./ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/io/ test/unit/org/apache/cassandra/db/
Date Tue, 12 Oct 2010 21:40:06 GMT
Author: jbellis
Date: Tue Oct 12 21:40:05 2010
New Revision: 1021935

URL: http://svn.apache.org/viewvc?rev=1021935&view=rev
Log:
expose in-progress compaction type in jmx
patch by jbellis; reviewed by gdusbabek for CASSANDRA-1586

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
    cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManagerMBean.java
    cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1021935&r1=1021934&r2=1021935&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Tue Oct 12 21:40:05 2010
@@ -29,6 +29,7 @@ dev
  * delete temp files on failed compactions (CASSANDRA-1596)
  * avoid blocking for dead nodes during removetoken (CASSANDRA-1605)
  * remove ConsistencyLevel.ZERO (CASSANDRA-1607)
+ * expose in-progress compaction type in jmx (CASSANDRA-1586)
 
 
 0.7-beta2

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java?rev=1021935&r1=1021934&r2=1021935&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java Tue Oct 12 21:40:05
2010
@@ -149,18 +149,6 @@ public class CompactionManager implement
         executor.submit(runnable).get();
     }
 
-    public Future<List<SSTableReader>> submitAnticompaction(final ColumnFamilyStore
cfStore, final Collection<Range> ranges, final InetAddress target)
-    {
-        Callable<List<SSTableReader>> callable = new Callable<List<SSTableReader>>()
-        {
-            public List<SSTableReader> call() throws IOException
-            {
-                return doAntiCompaction(cfStore, cfStore.getSSTables(), ranges, target);
-            }
-        };
-        return executor.submit(callable);
-    }
-
     public void performMajor(final ColumnFamilyStore cfStore) throws InterruptedException,
ExecutionException
     {
         submitMajor(cfStore, 0, (int) (System.currentTimeMillis() / 1000) - cfStore.metadata.gcGraceSeconds).get();
@@ -424,8 +412,7 @@ public class CompactionManager implement
      */
     private void doValidationCompaction(ColumnFamilyStore cfs, AntiEntropyService.Validator
validator) throws IOException
     {
-        Collection<SSTableReader> sstables = cfs.getSSTables();
-        CompactionIterator ci = new CompactionIterator(cfs, sstables, (int) (System.currentTimeMillis()
/ 1000) - cfs.metadata.gcGraceSeconds, true);
+        CompactionIterator ci = new ValidationCompactionIterator(cfs);
         executor.beginCompaction(cfs, ci);
         try
         {
@@ -537,6 +524,20 @@ public class CompactionManager implement
         return executor.submit(callable);
     }
 
+    private static class ValidationCompactionIterator extends CompactionIterator
+    {
+        public ValidationCompactionIterator(ColumnFamilyStore cfs) throws IOException
+        {
+            super(cfs, cfs.getSSTables(), (int) (System.currentTimeMillis() / 1000) - cfs.metadata.gcGraceSeconds,
true);
+        }
+
+        @Override
+        public String getTaskType()
+        {
+            return "Validation";
+        }
+    }
+
     private static class AntiCompactionIterator extends CompactionIterator
     {
         private Set<SSTableScanner> scanners;
@@ -582,7 +583,7 @@ public class CompactionManager implement
 
         public String getTaskType()
         {
-            return "Anticompaction";
+            return "Cleanup";
         }
     }
 
@@ -649,6 +650,11 @@ public class CompactionManager implement
         {
             return ci == null ? null : ci.getBytesRead();
         }
+
+        public String getType()
+        {
+            return ci == null ? null : ci.getTaskType();
+        }
     }
 
     public String getColumnFamilyInProgress()
@@ -666,6 +672,11 @@ public class CompactionManager implement
         return executor.getBytesCompleted();
     }
 
+    public String getCompactionType()
+    {
+        return executor.getType();
+    }
+
     public int getPendingTasks()
     {
         int n = 0;

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManagerMBean.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManagerMBean.java?rev=1021935&r1=1021934&r2=1021935&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManagerMBean.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManagerMBean.java Tue Oct 12
21:40:05 2010
@@ -37,6 +37,11 @@ public interface CompactionManagerMBean
     public Long getBytesCompacted();
 
     /**
+     * @return the type of compaction operation currently in progress; null if none
+     */
+    public String getCompactionType();
+
+    /**
      * @return estimated number of compactions remaining to perform
      */
     public int getPendingTasks();

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java?rev=1021935&r1=1021934&r2=1021935&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java Tue Oct 12 21:40:05
2010
@@ -163,6 +163,6 @@ implements Closeable, ICompactionInfo
 
     public String getTaskType()
     {
-        return "Compaction";
+        return major ? "Major" : "Minor";
     }
 }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=1021935&r1=1021934&r2=1021935&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java Tue Oct 12
21:40:05 2010
@@ -113,37 +113,6 @@ public class ColumnFamilyStoreTest exten
         TableTest.reTest(store, r);
     }
 
-    /**
-     * Writes out a bunch of keys into an SSTable, then runs anticompaction on a range.
-     * Checks to see if anticompaction returns true.
-     */
-    private void testAntiCompaction(String columnFamilyName, int insertsPerTable) throws
IOException, ExecutionException, InterruptedException
-    {
-        List<RowMutation> rms = new ArrayList<RowMutation>();
-        for (int j = 0; j < insertsPerTable; j++)
-        {
-            String key = String.valueOf(j);
-            RowMutation rm = new RowMutation("Keyspace1", key.getBytes());
-            rm.add(new QueryPath(columnFamilyName, null, "0".getBytes()), new byte[0], new
TimestampClock(j));
-            rms.add(rm);
-        }
-        ColumnFamilyStore store = Util.writeColumnFamily(rms);
-
-        List<Range> ranges  = new ArrayList<Range>();
-        IPartitioner partitioner = new CollatingOrderPreservingPartitioner();
-        Range r = Util.range(partitioner, "0", "zzzzzzz");
-        ranges.add(r);
-
-        List<SSTableReader> fileList = CompactionManager.instance.submitAnticompaction(store,
ranges, InetAddress.getByName("127.0.0.1")).get();
-        assert fileList.size() >= 1;
-    }
-
-    @Test
-    public void testAntiCompaction1() throws IOException, ExecutionException, InterruptedException
-    {
-        testAntiCompaction("Standard1", 100);
-    }
-
     @Test
     public void testSkipStartKey() throws IOException, ExecutionException, InterruptedException
     {



Mime
View raw message