private void onCql3CreateKeyspace ( ) throws InvalidRequestException , UnavailableException , TimedOutException , SchemaDisagreementException , TException , UnsupportedEncodingException { String createKeyspace = CQLTranslator . CREATE_KEYSPACE ; String placement_strategy = csmd . getPlacement_strategy ( databaseName ) ; String replication_conf = CQLTranslator . SIMPLE_REPLICATION ; createKeyspace = createKeyspace . replace ( "$KEYSPACE" , Constants . ESCAPE_QUOTE + databaseName + Constants . ESCAPE_QUOTE ) ; Schema schema = CassandraPropertyReader . csmd . getSchema ( databaseName ) ; if ( schema != null && schema . getName ( ) != null && schema . getName ( ) . equalsIgnoreCase ( databaseName ) && schema . getSchemaProperties ( ) != null ) { Properties schemaProperties = schema . getSchemaProperties ( ) ; if ( placement_strategy . equalsIgnoreCase ( SimpleStrategy . class . getSimpleName ( ) ) || placement_strategy . equalsIgnoreCase ( SimpleStrategy . class . getName ( ) ) ) { String replicationFactor = schemaProperties . getProperty ( CassandraConstants . REPLICATION_FACTOR , CassandraConstants . DEFAULT_REPLICATION_FACTOR ) ; replication_conf = replication_conf . replace ( "$REPLICATION_FACTOR" , replicationFactor ) ; createKeyspace = createKeyspace . replace ( "$CLASS" , placement_strategy ) ; } else if ( placement_strategy . equalsIgnoreCase ( NetworkTopologyStrategy . class . getSimpleName ( ) ) || placement_strategy . equalsIgnoreCase ( NetworkTopologyStrategy . class . getName ( ) ) ) { if ( schema . getDataCenters ( ) != null && ! schema . getDataCenters ( ) . isEmpty ( ) ) { StringBuilder builder = new StringBuilder ( ) ; for ( DataCenter dc : schema . getDataCenters ( ) ) { builder . append ( CQLTranslator . QUOTE_STR ) ; builder . append ( dc . getName ( ) ) ; builder . append ( CQLTranslator . QUOTE_STR ) ; builder . append ( ":" ) ; builder . append ( dc . getValue ( ) ) ; builder . append ( CQLTranslator . COMMA_STR ) ; } builder . delete ( builder . lastIndexOf ( CQLTranslator . COMMA_STR ) , builder . length ( ) ) ; replication_conf = builder . toString ( ) ; } } createKeyspace = createKeyspace . replace ( "$CLASS" , placement_strategy ) ; createKeyspace = createKeyspace . replace ( "$REPLICATION" , replication_conf ) ; boolean isDurableWrites = Boolean . parseBoolean ( schemaProperties . getProperty ( CassandraConstants . DURABLE_WRITES , "true" ) ) ; createKeyspace = createKeyspace . replace ( "$DURABLE_WRITES" , isDurableWrites + "" ) ; } else { createKeyspace = createKeyspace . replace ( "$CLASS" , placement_strategy ) ; replication_conf = replication_conf . replace ( "$REPLICATION_FACTOR" , ( CharSequence ) externalProperties . getOrDefault ( CassandraConstants . REPLICATION_FACTOR , CassandraConstants . DEFAULT_REPLICATION_FACTOR ) ) ; createKeyspace = createKeyspace . replace ( "$REPLICATION" , replication_conf ) ; createKeyspace = createKeyspace . replace ( "$DURABLE_WRITES" , "true" ) ; } cassandra_client . execute_cql3_query ( ByteBuffer . wrap ( createKeyspace . getBytes ( Constants . CHARSET_UTF8 ) ) , Compression . NONE , ConsistencyLevel . ONE ) ; KunderaCoreUtils . printQuery ( createKeyspace , showQuery ) ; }
On cql3 create keyspace .