cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [3/3] git commit: Catch and log all REEs in Auth#setup instead of propagating
Date Mon, 10 Dec 2012 19:01:45 GMT
Catch and log all REEs in Auth#setup instead of propagating


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

Branch: refs/heads/trunk
Commit: 35a653cfded6d91937432a73630ddf4fd6be2b4d
Parents: 24f95e0
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Mon Dec 10 21:59:14 2012 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Mon Dec 10 21:59:14 2012 +0300

----------------------------------------------------------------------
 src/java/org/apache/cassandra/auth/Auth.java       |   14 +++++++-------
 .../org/apache/cassandra/cql3/QueryProcessor.java  |   12 ++----------
 .../cql3/statements/AlterUserStatement.java        |    4 ++--
 .../cql3/statements/CreateUserStatement.java       |    4 ++--
 .../cql3/statements/DropUserStatement.java         |    4 ++--
 5 files changed, 15 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/35a653cf/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 6791455..45b4435 100644
--- a/src/java/org/apache/cassandra/auth/Auth.java
+++ b/src/java/org/apache/cassandra/auth/Auth.java
@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql3.UntypedResultSet;
 import org.apache.cassandra.cql3.QueryProcessor;
-import org.apache.cassandra.exceptions.UnavailableException;
+import org.apache.cassandra.exceptions.RequestExecutionException;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.service.StorageService;
 
@@ -52,7 +52,7 @@ public class Auth
         {
             return !QueryProcessor.process(query).isEmpty();
         }
-        catch (UnavailableException e)
+        catch (RequestExecutionException e)
         {
             throw new RuntimeException(e);
         }
@@ -72,7 +72,7 @@ public class Auth
             UntypedResultSet result = QueryProcessor.process(query);
             return !result.isEmpty() && result.one().getBoolean("super");
         }
-        catch (UnavailableException e)
+        catch (RequestExecutionException e)
         {
             throw new RuntimeException(e);
         }
@@ -84,7 +84,7 @@ public class Auth
      * @param username Username to insert.
      * @param isSuper User's new status.
      */
-    public static void insertUser(String username, boolean isSuper) throws UnavailableException
+    public static void insertUser(String username, boolean isSuper) throws RequestExecutionException
     {
         QueryProcessor.process(String.format("INSERT INTO %s.%s (name, super) VALUES ('%s',
%s)",
                                              AUTH_KS,
@@ -98,7 +98,7 @@ public class Auth
      *
      * @param username Username to delete.
      */
-    public static void deleteUser(String username) throws UnavailableException
+    public static void deleteUser(String username) throws RequestExecutionException
     {
         QueryProcessor.process(String.format("DELETE FROM %s.%s WHERE name = '%s'",
                                              AUTH_KS,
@@ -128,9 +128,9 @@ public class Auth
                     if (QueryProcessor.process(String.format("SELECT * FROM %s.%s", AUTH_KS,
USERS_CF)).isEmpty())
                         insertUser(DEFAULT_SUPERUSER_NAME, true);
                 }
-                catch (UnavailableException e)
+                catch (RequestExecutionException e)
                 {
-                    logger.warn("Skipping default superuser setup: some nodes are unavailable");
+                    logger.warn("Skipping default superuser setup: some nodes are not ready");
                 }
             }
         };

http://git-wip-us.apache.org/repos/asf/cassandra/blob/35a653cf/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 e172e59..fec45e6 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) throws UnavailableException
+    public static UntypedResultSet process(String query) throws RequestExecutionException
     {
         try
         {
@@ -151,17 +151,9 @@ public class QueryProcessor
             else
                 return null;
         }
-        catch (UnavailableException e)
-        {
-            throw e;
-        }
-        catch (RequestExecutionException e)
-        {
-            throw new RuntimeException(e);
-        }
         catch (RequestValidationException e)
         {
-            throw new AssertionError(e);
+            throw new RuntimeException(e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/35a653cf/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 16872a2..68c3d0d 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterUserStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterUserStatement.java
@@ -23,8 +23,8 @@ import org.apache.cassandra.auth.IAuthenticator;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql3.UserOptions;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.exceptions.RequestExecutionException;
 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;
 
@@ -76,7 +76,7 @@ public class AlterUserStatement extends AuthenticationStatement
         }
     }
 
-    public ResultMessage execute(ClientState state) throws InvalidRequestException, UnavailableException
+    public ResultMessage execute(ClientState state) throws InvalidRequestException, RequestExecutionException
     {
         if (!opts.isEmpty())
             DatabaseDescriptor.getAuthenticator().alter(username, opts.getOptions());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/35a653cf/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 9611d9e..b1a91cd 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateUserStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateUserStatement.java
@@ -21,8 +21,8 @@ import org.apache.cassandra.auth.Auth;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql3.UserOptions;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.exceptions.RequestExecutionException;
 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;
 
@@ -56,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, UnavailableException
+    public ResultMessage execute(ClientState state) throws InvalidRequestException, RequestExecutionException
     {
         DatabaseDescriptor.getAuthenticator().create(username, opts.getOptions());
         Auth.insertUser(username, superuser);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/35a653cf/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 e5b9c2b..493cd23 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DropUserStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropUserStatement.java
@@ -21,8 +21,8 @@ import org.apache.cassandra.auth.Auth;
 import org.apache.cassandra.auth.AuthenticatedUser;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.exceptions.RequestExecutionException;
 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;
 
@@ -52,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, UnavailableException
+    public ResultMessage execute(ClientState state) throws InvalidRequestException, RequestExecutionException
     {
         // clean up permissions after the dropped user.
         DatabaseDescriptor.getAuthorizer().revokeAll(username);


Mime
View raw message