src/java/org/apache/cassandra/cli/CliClient.java
/**
     * Used to update keyspace definition attributes
     * @param statement - ANTRL tree representing current statement
     * @param ksDefToUpdate - keyspace definition to update
     * @return ksDef - updated keyspace definition
     */
Used to update keyspace definition attributes
@param statement - ANTRL tree representing current statement
@param ksDefToUpdate - keyspace definition to update
@return ksDef - updated keyspace definition
Used to update keyspace definition attributes @param statement - ANTRL tree representing current statement @param ksDefToUpdate - keyspace definition to update @return ksDef - updated keyspace definition
private KsDef updateKsDefAttributes(Tree statement, KsDef ksDefToUpdate)
    {
        KsDef ksDef = new KsDef(ksDefToUpdate);
        ksDef.unsetReplication_factor();
        ksDef.setCf_defs(new LinkedList<CfDef>());
        for(int i = 1; i < statement.getChildCount(); i += 2)
        {
            String currentStatement = statement.getChild(i).getText().toUpperCase();
            AddKeyspaceArgument mArgument = AddKeyspaceArgument.valueOf(currentStatement);
            String mValue = statement.getChild(i + 1).getText();
            switch(mArgument)
            {
            case PLACEMENT_STRATEGY:
                ksDef.setStrategy_class(CliUtils.unescapeSQLString(mValue));
                break;
            case STRATEGY_OPTIONS:
                ksDef.setStrategy_options(getStrategyOptionsFromTree(statement.getChild(i + 1)));
                break;
            case DURABLE_WRITES:
                ksDef.setDurable_writes(Boolean.parseBoolean(mValue));
                break;
            default:
                assert(false);
            }
        }
        if (ksDef.getStrategy_class().contains(".NetworkTopologyStrategy"))
        {
            Map<String, String> currentStrategyOptions = ksDef.getStrategy_options();
            if (currentStrategyOptions == null || currentStrategyOptions.isEmpty())
            {
                SimpleSnitch snitch = new SimpleSnitch();
                Map<String, String> options = new HashMap<String, String>();
                try
                {
                    options.put(snitch.getDatacenter(InetAddress.getLocalHost()), "1");
                }
                catch (UnknownHostException e)
                {
                    throw new RuntimeException(e);
                }
                ksDef.setStrategy_options(options);
            }
        }
        return ksDef;
    }
private KsDef updateKsDefAttributes ( Tree statement , KsDef ksDefToUpdate ) { KsDef ksDef = new KsDef ( ksDefToUpdate ) ; ksDef . unsetReplication_factor ( ) ; ksDef . setCf_defs ( new LinkedList < CfDef > ( ) ) ; for ( int i = 1 ; i < statement . getChildCount ( ) ; i += 2 ) { String currentStatement = statement . getChild ( i ) . getText ( ) . toUpperCase ( ) ; AddKeyspaceArgument mArgument = AddKeyspaceArgument . valueOf ( currentStatement ) ; String mValue = statement . getChild ( i + 1 ) . getText ( ) ; switch ( mArgument ) { case PLACEMENT_STRATEGY : ksDef . setStrategy_class ( CliUtils . unescapeSQLString ( mValue ) ) ; break ; case STRATEGY_OPTIONS : ksDef . setStrategy_options ( getStrategyOptionsFromTree ( statement . getChild ( i + 1 ) ) ) ; break ; case DURABLE_WRITES : ksDef . setDurable_writes ( Boolean . parseBoolean ( mValue ) ) ; break ; default : assert ( false ) ; } } if ( ksDef . getStrategy_class ( ) . contains ( ".NetworkTopologyStrategy" ) ) { Map < String , String > currentStrategyOptions = ksDef . getStrategy_options ( ) ; if ( currentStrategyOptions == null || currentStrategyOptions . isEmpty ( ) ) { SimpleSnitch snitch = new SimpleSnitch ( ) ; Map < String , String > options = new HashMap < String , String > ( ) ; try { options . put ( snitch . getDatacenter ( InetAddress . getLocalHost ( ) ) , "1" ) ; } catch ( UnknownHostException e ) { throw new RuntimeException ( e ) ; } ksDef . setStrategy_options ( options ) ; } } return ksDef ; }
Used to update keyspace definition attributes
 @param statement - ANTRL tree representing current statement
 @param ksDefToUpdate - keyspace definition to update
 @return ksDef - updated keyspace definition
Used to update keyspace definition attributes @param statement - ANTRL tree representing current statement @param ksDefToUpdate - keyspace definition to update @return ksDef - updated keyspace definition
// server helpfully sets deprecated replication factor when it sends a KsDef back, for older clients. // we need to unset that on the new KsDef we create to avoid being treated as a legacy client in return. // removing all column definitions - thrift system_update_keyspace method requires that //must match one of the above or we'd throw an exception at the valueOf statement above. // using default snitch options if strategy is NetworkTopologyStrategy and no options were set. // adding default data center from SimpleSnitch