cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: ninja-followup 5003
Date Sat, 08 Dec 2012 16:40:11 GMT
Updated Branches:
  refs/heads/cassandra-1.2.0 66706d1cc -> 62b9037d1


ninja-followup 5003


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

Branch: refs/heads/cassandra-1.2.0
Commit: 62b9037d1a2baa859b8bef27a4329f60a3bf356b
Parents: 66706d1
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Sat Dec 8 19:39:35 2012 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Sat Dec 8 19:39:35 2012 +0300

----------------------------------------------------------------------
 src/java/org/apache/cassandra/auth/Auth.java       |   28 +++++++++++----
 .../org/apache/cassandra/cql3/QueryProcessor.java  |    6 +++-
 .../cql3/statements/AlterUserStatement.java        |    3 +-
 .../cql3/statements/CreateUserStatement.java       |    3 +-
 .../cql3/statements/DropUserStatement.java         |    3 +-
 5 files changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/62b9037d/src/java/org/apache/cassandra/auth/Auth.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/auth/Auth.java b/src/java/org/apache/cassandra/auth/Auth.java
index 95312fe..123ffe6 100644
--- a/src/java/org/apache/cassandra/auth/Auth.java
+++ b/src/java/org/apache/cassandra/auth/Auth.java
@@ -24,7 +24,7 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql3.UntypedResultSet;
 import org.apache.cassandra.cql3.QueryProcessor;
-import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.exceptions.UnavailableException;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.WrappedRunnable;
@@ -45,7 +45,14 @@ public class Auth
     public static boolean isExistingUser(String username)
     {
         String query = String.format("SELECT * FROM %s.%s WHERE name = '%s'", AUTH_KS, USERS_CF,
escape(username));
-        return !QueryProcessor.process(query).isEmpty();
+        try
+        {
+            return !QueryProcessor.process(query).isEmpty();
+        }
+        catch (UnavailableException e)
+        {
+            throw new RuntimeException(e);
+        }
     }
 
     /**
@@ -57,8 +64,15 @@ public class Auth
     public static boolean isSuperuser(String username)
     {
         String query = String.format("SELECT super FROM %s.%s WHERE name = '%s'", AUTH_KS,
USERS_CF, escape(username));
-        UntypedResultSet result = QueryProcessor.process(query);
-        return !result.isEmpty() && result.one().getBoolean("super");
+        try
+        {
+            UntypedResultSet result = QueryProcessor.process(query);
+            return !result.isEmpty() && result.one().getBoolean("super");
+        }
+        catch (UnavailableException e)
+        {
+            throw new RuntimeException(e);
+        }
     }
 
     /**
@@ -67,7 +81,7 @@ public class Auth
      * @param username Username to insert.
      * @param isSuper User's new status.
      */
-    public static void insertUser(String username, boolean isSuper)
+    public static void insertUser(String username, boolean isSuper) throws UnavailableException
     {
         QueryProcessor.process(String.format("INSERT INTO %s.%s (name, super) VALUES ('%s',
%s)",
                                              AUTH_KS,
@@ -81,7 +95,7 @@ public class Auth
      *
      * @param username Username to delete.
      */
-    public static void deleteUser(String username)
+    public static void deleteUser(String username) throws UnavailableException
     {
         QueryProcessor.process(String.format("DELETE FROM %s.%s WHERE name = '%s'",
                                              AUTH_KS,
@@ -103,7 +117,7 @@ public class Auth
         // schedule seeding a superuser in RING_DELAY milliseconds.
         Runnable runnable = new WrappedRunnable()
         {
-            public void runMayThrow() throws InvalidRequestException
+            public void runMayThrow() throws UnavailableException
             {
                 // insert a default superuser if AUTH_KS.USERS_CF is empty.
                 if (QueryProcessor.process(String.format("SELECT * FROM %s.%s", AUTH_KS,
USERS_CF)).isEmpty())

http://git-wip-us.apache.org/repos/asf/cassandra/blob/62b9037d/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index b68f3c2..e172e59 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -140,7 +140,7 @@ public class QueryProcessor
         return processStatement(getStatement(queryString, queryState.getClientState()).statement,
cl, queryState, Collections.<ByteBuffer>emptyList());
     }
 
-    public static UntypedResultSet process(String query)
+    public static UntypedResultSet process(String query) throws UnavailableException
     {
         try
         {
@@ -151,6 +151,10 @@ public class QueryProcessor
             else
                 return null;
         }
+        catch (UnavailableException e)
+        {
+            throw e;
+        }
         catch (RequestExecutionException e)
         {
             throw new RuntimeException(e);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/62b9037d/src/java/org/apache/cassandra/cql3/statements/AlterUserStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/AlterUserStatement.java b/src/java/org/apache/cassandra/cql3/statements/AlterUserStatement.java
index 61655db..16872a2 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterUserStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterUserStatement.java
@@ -24,6 +24,7 @@ import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql3.UserOptions;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.exceptions.UnauthorizedException;
+import org.apache.cassandra.exceptions.UnavailableException;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.transport.messages.ResultMessage;
 
@@ -75,7 +76,7 @@ public class AlterUserStatement extends AuthenticationStatement
         }
     }
 
-    public ResultMessage execute(ClientState state) throws InvalidRequestException
+    public ResultMessage execute(ClientState state) throws InvalidRequestException, UnavailableException
     {
         if (!opts.isEmpty())
             DatabaseDescriptor.getAuthenticator().alter(username, opts.getOptions());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/62b9037d/src/java/org/apache/cassandra/cql3/statements/CreateUserStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateUserStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateUserStatement.java
index 6dd1b93..9611d9e 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateUserStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateUserStatement.java
@@ -22,6 +22,7 @@ import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql3.UserOptions;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.exceptions.UnauthorizedException;
+import org.apache.cassandra.exceptions.UnavailableException;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.transport.messages.ResultMessage;
 
@@ -55,7 +56,7 @@ public class CreateUserStatement extends AuthenticationStatement
             throw new UnauthorizedException("Only superusers are allowed to perfrom CREATE
USER queries");
     }
 
-    public ResultMessage execute(ClientState state) throws InvalidRequestException
+    public ResultMessage execute(ClientState state) throws InvalidRequestException, UnavailableException
     {
         DatabaseDescriptor.getAuthenticator().create(username, opts.getOptions());
         Auth.insertUser(username, superuser);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/62b9037d/src/java/org/apache/cassandra/cql3/statements/DropUserStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DropUserStatement.java b/src/java/org/apache/cassandra/cql3/statements/DropUserStatement.java
index af92fda..e5b9c2b 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DropUserStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropUserStatement.java
@@ -22,6 +22,7 @@ import org.apache.cassandra.auth.AuthenticatedUser;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.exceptions.UnauthorizedException;
+import org.apache.cassandra.exceptions.UnavailableException;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.transport.messages.ResultMessage;
 
@@ -51,7 +52,7 @@ public class DropUserStatement extends AuthenticationStatement
             throw new UnauthorizedException("Only superusers are allowed to perfrom DROP
USER queries");
     }
 
-    public ResultMessage execute(ClientState state) throws InvalidRequestException
+    public ResultMessage execute(ClientState state) throws InvalidRequestException, UnavailableException
     {
         // clean up permissions after the dropped user.
         DatabaseDescriptor.getAuthorizer().revokeAll(username);


Mime
View raw message