Repository: cassandra
Updated Branches:
  refs/heads/trunk 719bb3928 -> 37a9d405c


Don't expose internal classes over JMX

Patch by marcuse; reviewed by slebresne for CASSANDRA-7879


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

Branch: refs/heads/trunk
Commit: 45014886e89e5bd47bf2f4c9871391d77702ad82
Parents: c81dc4b
Author: Marcus Eriksson <marc...@apache.org>
Authored: Fri Sep 5 11:02:29 2014 +0200
Committer: Marcus Eriksson <marc...@apache.org>
Committed: Fri Sep 5 11:02:29 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../db/compaction/CompactionManager.java        |  9 +++++-
 .../cassandra/service/StorageService.java       | 12 ++++----
 .../cassandra/service/StorageServiceMBean.java  |  6 ++--
 .../org/apache/cassandra/tools/NodeProbe.java   | 30 ++++++++------------
 5 files changed, 30 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/45014886/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 93d77c1..befdcd7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.0
+ * Avoid exposing internal classes over JMX (CASSANDRA-7879)
  * Add null check for keys when freezing collection (CASSANDRA-7869)
 
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/45014886/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java 
b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
index 65c4882..09c068f 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -289,7 +289,14 @@ public class CompactionManager implements 
CompactionManagerMBean
         void execute(SSTableReader input) throws IOException;
     }
 
-    public enum AllSSTableOpStatus { ABORTED, SUCCESSFUL }
+    public enum AllSSTableOpStatus { ABORTED(1), SUCCESSFUL(0);
+        public final int statusCode;
+
+        AllSSTableOpStatus(int statusCode)
+        {
+            this.statusCode = statusCode;
+        }
+    }
 
     public AllSSTableOpStatus performScrub(final ColumnFamilyStore cfs, final 
boolean skipCorrupted) throws InterruptedException, ExecutionException
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/45014886/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java 
b/src/java/org/apache/cassandra/service/StorageService.java
index 735bf7b..5c6dbd6 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -2156,7 +2156,7 @@ public class StorageService extends 
NotificationBroadcasterSupport implements IE
         return 
Gossiper.instance.getCurrentGenerationNumber(FBUtilities.getBroadcastAddress());
     }
 
-    public CompactionManager.AllSSTableOpStatus forceKeyspaceCleanup(String 
keyspaceName, String... columnFamilies) throws IOException, ExecutionException, 
InterruptedException
+    public int forceKeyspaceCleanup(String keyspaceName, String... 
columnFamilies) throws IOException, ExecutionException, InterruptedException
     {
         if (keyspaceName.equals(Keyspace.SYSTEM_KS))
             throw new RuntimeException("Cleanup of the system keyspace is 
neither necessary nor wise");
@@ -2168,10 +2168,10 @@ public class StorageService extends 
NotificationBroadcasterSupport implements IE
             if (oneStatus != CompactionManager.AllSSTableOpStatus.SUCCESSFUL)
                 status = oneStatus;
         }
-        return status;
+        return status.statusCode;
     }
 
-    public CompactionManager.AllSSTableOpStatus scrub(boolean disableSnapshot, 
boolean skipCorrupted, String keyspaceName, String... columnFamilies) throws 
IOException, ExecutionException, InterruptedException
+    public int scrub(boolean disableSnapshot, boolean skipCorrupted, String 
keyspaceName, String... columnFamilies) throws IOException, ExecutionException, 
InterruptedException
     {
         CompactionManager.AllSSTableOpStatus status = 
CompactionManager.AllSSTableOpStatus.SUCCESSFUL;
         for (ColumnFamilyStore cfStore : getValidColumnFamilies(false, false, 
keyspaceName, columnFamilies))
@@ -2180,10 +2180,10 @@ public class StorageService extends 
NotificationBroadcasterSupport implements IE
             if (oneStatus != CompactionManager.AllSSTableOpStatus.SUCCESSFUL)
                 status = oneStatus;
         }
-        return status;
+        return status.statusCode;
     }
 
-    public CompactionManager.AllSSTableOpStatus upgradeSSTables(String 
keyspaceName, boolean excludeCurrentVersion, String... columnFamilies) throws 
IOException, ExecutionException, InterruptedException
+    public int upgradeSSTables(String keyspaceName, boolean 
excludeCurrentVersion, String... columnFamilies) throws IOException, 
ExecutionException, InterruptedException
     {
         CompactionManager.AllSSTableOpStatus status = 
CompactionManager.AllSSTableOpStatus.SUCCESSFUL;
         for (ColumnFamilyStore cfStore : getValidColumnFamilies(true, true, 
keyspaceName, columnFamilies))
@@ -2192,7 +2192,7 @@ public class StorageService extends 
NotificationBroadcasterSupport implements IE
             if (oneStatus != CompactionManager.AllSSTableOpStatus.SUCCESSFUL)
                 status = oneStatus;
         }
-        return status;
+        return status.statusCode;
     }
 
     public void forceKeyspaceCompaction(String keyspaceName, String... 
columnFamilies) throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/45014886/src/java/org/apache/cassandra/service/StorageServiceMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageServiceMBean.java 
b/src/java/org/apache/cassandra/service/StorageServiceMBean.java
index b4cc45b..8bb13ae 100644
--- a/src/java/org/apache/cassandra/service/StorageServiceMBean.java
+++ b/src/java/org/apache/cassandra/service/StorageServiceMBean.java
@@ -238,7 +238,7 @@ public interface StorageServiceMBean extends 
NotificationEmitter
     /**
      * Trigger a cleanup of keys on a single keyspace
      */
-    public CompactionManager.AllSSTableOpStatus forceKeyspaceCleanup(String 
keyspaceName, String... columnFamilies) throws IOException, ExecutionException, 
InterruptedException;
+    public int forceKeyspaceCleanup(String keyspaceName, String... 
columnFamilies) throws IOException, ExecutionException, InterruptedException;
 
     /**
      * Scrub (deserialize + reserialize at the latest version, skipping bad 
rows if any) the given keyspace.
@@ -246,13 +246,13 @@ public interface StorageServiceMBean extends 
NotificationEmitter
      *
      * Scrubbed CFs will be snapshotted first, if disableSnapshot is false
      */
-    public CompactionManager.AllSSTableOpStatus scrub(boolean disableSnapshot, 
boolean skipCorrupted, String keyspaceName, String... columnFamilies) throws 
IOException, ExecutionException, InterruptedException;
+    public int scrub(boolean disableSnapshot, boolean skipCorrupted, String 
keyspaceName, String... columnFamilies) throws IOException, ExecutionException, 
InterruptedException;
 
     /**
      * Rewrite all sstables to the latest version.
      * Unlike scrub, it doesn't skip bad rows and do not snapshot sstables 
first.
      */
-    public CompactionManager.AllSSTableOpStatus upgradeSSTables(String 
keyspaceName, boolean excludeCurrentVersion, String... columnFamilies) throws 
IOException, ExecutionException, InterruptedException;
+    public int upgradeSSTables(String keyspaceName, boolean 
excludeCurrentVersion, String... columnFamilies) throws IOException, 
ExecutionException, InterruptedException;
 
     /**
      * Flush all memtables for the given column families, or all 
columnfamilies for the given keyspace

http://git-wip-us.apache.org/repos/asf/cassandra/blob/45014886/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java 
b/src/java/org/apache/cassandra/tools/NodeProbe.java
index 1a2364b..3f3073d 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -186,51 +186,45 @@ public class NodeProbe implements AutoCloseable
         jmxc.close();
     }
 
-    public CompactionManager.AllSSTableOpStatus forceKeyspaceCleanup(String 
keyspaceName, String... columnFamilies) throws IOException, ExecutionException, 
InterruptedException
+    public int forceKeyspaceCleanup(String keyspaceName, String... 
columnFamilies) throws IOException, ExecutionException, InterruptedException
     {
         return ssProxy.forceKeyspaceCleanup(keyspaceName, columnFamilies);
     }
 
-    public CompactionManager.AllSSTableOpStatus scrub(boolean disableSnapshot, 
boolean skipCorrupted, String keyspaceName, String... columnFamilies) throws 
IOException, ExecutionException, InterruptedException
+    public int scrub(boolean disableSnapshot, boolean skipCorrupted, String 
keyspaceName, String... columnFamilies) throws IOException, ExecutionException, 
InterruptedException
     {
         return ssProxy.scrub(disableSnapshot, skipCorrupted, keyspaceName, 
columnFamilies);
     }
 
-    public CompactionManager.AllSSTableOpStatus upgradeSSTables(String 
keyspaceName, boolean excludeCurrentVersion, String... columnFamilies) throws 
IOException, ExecutionException, InterruptedException
+    public int upgradeSSTables(String keyspaceName, boolean 
excludeCurrentVersion, String... columnFamilies) throws IOException, 
ExecutionException, InterruptedException
     {
         return ssProxy.upgradeSSTables(keyspaceName, excludeCurrentVersion, 
columnFamilies);
     }
 
     public void forceKeyspaceCleanup(PrintStream out, String keyspaceName, 
String... columnFamilies) throws IOException, ExecutionException, 
InterruptedException
     {
-        switch (forceKeyspaceCleanup(keyspaceName, columnFamilies))
+        if (forceKeyspaceCleanup(keyspaceName, columnFamilies) != 0)
         {
-            case ABORTED:
-                failed = true;
-                out.println("Aborted cleaning up atleast one column family in 
keyspace "+keyspaceName+", check server logs for more information.");
-                break;
+            failed = true;
+            out.println("Aborted cleaning up atleast one column family in 
keyspace "+keyspaceName+", check server logs for more information.");
         }
     }
 
     public void scrub(PrintStream out, boolean disableSnapshot, boolean 
skipCorrupted, String keyspaceName, String... columnFamilies) throws 
IOException, ExecutionException, InterruptedException
     {
-        switch (scrub(disableSnapshot, skipCorrupted, keyspaceName, 
columnFamilies))
+        if (scrub(disableSnapshot, skipCorrupted, keyspaceName, 
columnFamilies) != 0)
         {
-            case ABORTED:
-                failed = true;
-                out.println("Aborted scrubbing atleast one column family in 
keyspace "+keyspaceName+", check server logs for more information.");
-                break;
+            failed = true;
+            out.println("Aborted scrubbing atleast one column family in 
keyspace "+keyspaceName+", check server logs for more information.");
         }
     }
 
     public void upgradeSSTables(PrintStream out, String keyspaceName, boolean 
excludeCurrentVersion, String... columnFamilies) throws IOException, 
ExecutionException, InterruptedException
     {
-        switch (upgradeSSTables(keyspaceName, excludeCurrentVersion, 
columnFamilies))
+        if (upgradeSSTables(keyspaceName, excludeCurrentVersion, 
columnFamilies) != 0)
         {
-            case ABORTED:
-                failed = true;
-                out.println("Aborted upgrading sstables for atleast one column 
family in keyspace "+keyspaceName+", check server logs for more information.");
-                break;
+            failed = true;
+            out.println("Aborted upgrading sstables for atleast one column 
family in keyspace "+keyspaceName+", check server logs for more information.");
         }
     }
 

Reply via email to