fix assumption error in CLI when updating/describing keyspace

patch by Pavel Yaskevich; reviewed by Dave Brosius for CASSANDRA-4322
This commit is contained in:
Pavel Yaskevich 2012-09-08 21:57:46 +03:00
parent e172a9b735
commit 98708d817f
2 changed files with 27 additions and 12 deletions

View File

@ -1,6 +1,7 @@
1.1.6
* Improve IAuthority interface by introducing fine-grained
access permissions and grant/revoke commands (CASSANDRA-4490)
* fix assumption error in CLI when updating/describing keyspace (CASSANDRA-4322)
1.1.5

View File

@ -1068,7 +1068,7 @@ public class CliClient
sessionState.out.println(mySchemaVersion);
validateSchemaIsSettled(mySchemaVersion);
keyspacesMap.remove(keyspaceName);
getKSMetaData(keySpace);
getKSMetaData(keyspaceName);
}
catch (InvalidRequestException e)
{
@ -1879,15 +1879,19 @@ public class CliClient
* Returns true if this.keySpace is set, false otherwise
* @return boolean
*/
private boolean hasKeySpace(boolean printError)
{
boolean hasKeyspace = keySpace != null;
if (!hasKeyspace && printError)
sessionState.err.println("Not authorized to a working keyspace.");
return hasKeyspace;
}
private boolean hasKeySpace()
{
if (keySpace == null)
{
sessionState.out.println("Not authenticated to a working keyspace.");
return false;
}
return true;
return hasKeySpace(true);
}
public String getKeySpace()
@ -2142,9 +2146,19 @@ public class CliClient
return;
int argCount = statement.getChildCount();
keyspacesMap.remove(keySpace);
KsDef currentKeySpace = getKSMetaData(keySpace);
if (keySpace == null && argCount == 0)
{
sessionState.out.println("Authenticate to a Keyspace, before using `describe` or `describe <column_family>`");
return;
}
KsDef currentKeySpace = null;
if (keySpace != null)
{
keyspacesMap.remove(keySpace);
currentKeySpace = getKSMetaData(keySpace);
}
if (argCount > 1) // in case somebody changes Cli grammar
throw new RuntimeException("`describe` command take maximum one argument. See `help describe;`");
@ -2996,7 +3010,7 @@ public class CliClient
public void replayAssumptions(String keyspace)
{
if (!CliMain.isConnected() || !hasKeySpace())
if (!CliMain.isConnected() || !hasKeySpace(false))
return;
Map<String, Map<String, String>> cfAssumes = assumptions.get(keyspace);