private KsDef setKeySpaceOptions ( String keyspace ) { KsDef ksDef = new KsDef ( ) ; ksDef . setName ( keyspace ) ; Map < String , Object > ksDefs = m_service . getParamMap ( "ks_defaults" ) ; if ( ksDefs != null ) { for ( String name : ksDefs . keySet ( ) ) { Object value = ksDefs . get ( name ) ; try { KsDef . _Fields field = KsDef . _Fields . findByName ( name ) ; if ( field == null ) { m_logger . warn ( "Unknown KeySpace option: {} -- ignoring" , name ) ; } else { ksDef . setFieldValue ( field , value ) ; } } catch ( Exception e ) { m_logger . warn ( "Error setting Keyspace option '" + name + "' to '" + value + "' -- ignoring" , e ) ; } } } // Legacy support: ReplicationFactor -> replication_factor if ( m_service . getParam ( "ReplicationFactor" ) != null ) { Map < String , String > stratOpts = new HashMap <> ( ) ; stratOpts . put ( "replication_factor" , m_service . getParamString ( "ReplicationFactor" ) ) ; ksDef . setStrategy_options ( stratOpts ) ; } // required: strategy_class, strategy_options, replication_factor, cf_defs, durable_writes if ( ! ksDef . isSetStrategy_class ( ) ) { ksDef . setStrategy_class ( DEFAULT_KS_STRATEGY_CLASS ) ; } if ( ! ksDef . isSetStrategy_options ( ) ) { Map < String , String > stratOpts = new HashMap <> ( ) ; stratOpts . put ( "replication_factor" , DEFAULT_KS_REPLICATION_FACTOR ) ; ksDef . setStrategy_options ( stratOpts ) ; } if ( ! ksDef . isSetCf_defs ( ) ) { ksDef . setCf_defs ( DEFAULT_KS_CF_DEFS ) ; } if ( ! ksDef . isSetDurable_writes ( ) ) { ksDef . setDurable_writes ( DEFAULT_KS_DURABLE_WRITES ) ; } return ksDef ; }
Build KsDef from doradus . yaml and DBService - specific options .