cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: cli: Add JMX authentication support
Date Fri, 15 Feb 2013 19:45:18 GMT
Updated Branches:
  refs/heads/cassandra-1.1 9828c63b4 -> 4c98854bb


cli: Add JMX authentication support

Patch by MichaƂ Michalski; reviewed by Aleksey Yeschenko for
CASSANDRA-5080


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

Branch: refs/heads/cassandra-1.1
Commit: 4c98854bb2f40f6d78aab1efcc9fda0bd8f42b12
Parents: 9828c63
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Fri Feb 15 22:40:39 2013 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Fri Feb 15 22:40:39 2013 +0300

----------------------------------------------------------------------
 CHANGES.txt                                        |    4 ++++
 src/java/org/apache/cassandra/cli/CliOptions.java  |   14 ++++++++++++++
 .../org/apache/cassandra/cli/CliSessionState.java  |    8 ++++++--
 3 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c98854b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1ef799f..4e1db62 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+1.1.11
+ * cli: Add JMX authentication support (CASSANDRA-5080)
+
+
 1.1.10
  * fix saved key cache not loading at startup (CASSANDRA-5166)
  * fix ConcurrentModificationException in getBootstrapSource (CASSANDRA-5170)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c98854b/src/java/org/apache/cassandra/cli/CliOptions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cli/CliOptions.java b/src/java/org/apache/cassandra/cli/CliOptions.java
index c582728..3616f5d 100644
--- a/src/java/org/apache/cassandra/cli/CliOptions.java
+++ b/src/java/org/apache/cassandra/cli/CliOptions.java
@@ -43,6 +43,8 @@ public class CliOptions
     private static final String HELP_OPTION = "help";
     private static final String FILE_OPTION = "file";
     private static final String JMX_PORT_OPTION = "jmxport";
+    private static final String JMX_USERNAME_OPTION = "jmxusername";
+    private static final String JMX_PASSWORD_OPTION = "jmxpassword";
     private static final String VERBOSE_OPTION  = "verbose";
     private static final String SCHEMA_MIGRATION_WAIT_TIME = "schema-mwt";
 
@@ -63,6 +65,8 @@ public class CliOptions
         options.addOption("k",  KEYSPACE_OPTION, "KEYSPACE", "cassandra keyspace user is
authenticated against");
         options.addOption("f",  FILE_OPTION,     "FILENAME", "load statements from the specific
file");
         options.addOption(null, JMX_PORT_OPTION, "JMX-PORT", "JMX service port");
+        options.addOption(null, JMX_USERNAME_OPTION, "JMX-USERNAME", "JMX service username");
+        options.addOption(null, JMX_PASSWORD_OPTION, "JMX-PASSWORD", "JMX service password");
         options.addOption(null, SCHEMA_MIGRATION_WAIT_TIME,  "TIME", "Schema migration wait
time (secs.), default is 10 secs");
 
         // options without argument
@@ -157,6 +161,16 @@ public class CliOptions
                 css.jmxPort = Integer.parseInt(cmd.getOptionValue(JMX_PORT_OPTION));
             }
 
+            if (cmd.hasOption(JMX_USERNAME_OPTION))
+            {
+                css.jmxUsername = cmd.getOptionValue(JMX_USERNAME_OPTION);
+            }
+
+            if (cmd.hasOption(JMX_PASSWORD_OPTION))
+            {
+                css.jmxPassword = cmd.getOptionValue(JMX_PASSWORD_OPTION);
+            }
+
             if (cmd.hasOption(HELP_OPTION))
             {
                 printUsage();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c98854b/src/java/org/apache/cassandra/cli/CliSessionState.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cli/CliSessionState.java b/src/java/org/apache/cassandra/cli/CliSessionState.java
index 9f956fd..b2b64dd 100644
--- a/src/java/org/apache/cassandra/cli/CliSessionState.java
+++ b/src/java/org/apache/cassandra/cli/CliSessionState.java
@@ -39,6 +39,8 @@ public class CliSessionState
     public boolean batch = false; // enable/disable batch processing mode
     public String  filename = ""; // file to read commands from
     public int     jmxPort = 7199;// JMX service port
+    public String  jmxUsername;   // JMX service username
+    public String  jmxPassword;   // JMX service password
     public boolean verbose = false; // verbose output
     public int     schema_mwt = 10 * 1000;    // Schema migration wait time (secs.)
     /*
@@ -74,11 +76,13 @@ public class CliSessionState
     {
         try
         {
-            return new NodeProbe(hostName, jmxPort);
+            return jmxUsername != null && jmxPassword != null
+                   ? new NodeProbe(hostName, jmxPort, jmxUsername, jmxPassword)
+                   : new NodeProbe(hostName, jmxPort);
         }
         catch (Exception e)
         {
-            err.printf("WARNING: Could not connect to the JMX on %s:%d, information won't
be shown.%n%n", hostName, jmxPort);
+            err.printf("WARNING: Could not connect to the JMX on %s:%d - some information
won't be shown.%n%n", hostName, jmxPort);
         }
 
         return null;


Mime
View raw message