Merge branch 'cassandra-3.0' into cassandra-3.X
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e3f37c44 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e3f37c44 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e3f37c44 Branch: refs/heads/cassandra-3.X Commit: e3f37c44358a101809751aeac09a374713a01844 Parents: 574ca2e d81a490 Author: Sam Tunnicliffe <s...@beobal.com> Authored: Fri Nov 11 11:32:14 2016 +0000 Committer: Sam Tunnicliffe <s...@beobal.com> Committed: Fri Nov 11 11:32:14 2016 +0000 ---------------------------------------------------------------------- .../cassandra/auth/CassandraRoleManager.java | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/e3f37c44/src/java/org/apache/cassandra/auth/CassandraRoleManager.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/auth/CassandraRoleManager.java index 6c2a9ca,c3e2626..89f0e24 --- a/src/java/org/apache/cassandra/auth/CassandraRoleManager.java +++ b/src/java/org/apache/cassandra/auth/CassandraRoleManager.java @@@ -162,11 -161,10 +162,10 @@@ public class CassandraRoleManager imple // it, so we can continue to use the old tables while the cluster is upgraded. // Otherwise, we may need to create a default superuser role to enable others // to be added. - if (Schema.instance.getCFMetaData(AuthKeyspace.NAME, "users") != null) + if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "users") != null) { - legacySelectUserStatement = (SelectStatement) prepare("SELECT * FROM %s.%s WHERE name = ?", - SchemaConstants.AUTH_KEYSPACE_NAME, - LEGACY_USERS_TABLE); + legacySelectUserStatement = prepareLegacySelectUserStatement(); + scheduleSetupTask(() -> { convertLegacyData(); return null; @@@ -452,6 -450,13 +451,13 @@@ } } + private SelectStatement prepareLegacySelectUserStatement() + { + return (SelectStatement) prepare("SELECT * FROM %s.%s WHERE name = ?", - AuthKeyspace.NAME, ++ SchemaConstants.AUTH_KEYSPACE_NAME, + LEGACY_USERS_TABLE); + } + private CQLStatement prepare(String template, String keyspace, String table) { try @@@ -493,9 -498,14 +499,14 @@@ // If it exists, try the legacy users table in case the cluster // is in the process of being upgraded and so is running with mixed // versions of the authn schema. - return (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "users") != null) - ? getRoleFromTable(name, legacySelectUserStatement, LEGACY_ROW_TO_ROLE) - : getRoleFromTable(name, loadRoleStatement, ROW_TO_ROLE); - if (Schema.instance.getCFMetaData(AuthKeyspace.NAME, "users") == null) ++ if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "users") == null) + return getRoleFromTable(name, loadRoleStatement, ROW_TO_ROLE); + else + { + if (legacySelectUserStatement == null) + prepareLegacySelectUserStatement(); + return getRoleFromTable(name, legacySelectUserStatement, LEGACY_ROW_TO_ROLE); + } } catch (RequestExecutionException | RequestValidationException e) {