@@ -236,12 +236,33 @@ public void create() {
236236 Arrays .stream (nodes ).mapToObj (n -> "" + n ).collect (Collectors .joining (":" )),
237237 createOptions .stream ().collect (Collectors .joining (" " )));
238238
239+ Version cassandraVersion = getCassandraVersion ();
239240 for (Map .Entry <String , Object > conf : cassandraConfiguration .entrySet ()) {
240- execute ("updateconf" , String .format ("%s:%s" , conf .getKey (), conf .getValue ()));
241+ String originalKey = conf .getKey ();
242+ Object originalValue = conf .getValue ();
243+ execute (
244+ "updateconf" ,
245+ String .join (
246+ ":" ,
247+ getConfigKey (originalKey , originalValue , cassandraVersion ),
248+ getConfigValue (originalKey , originalValue , cassandraVersion )));
241249 }
242- if (getCassandraVersion ().compareTo (Version .V2_2_0 ) >= 0 ) {
243- execute ("updateconf" , "enable_user_defined_functions:true" );
250+
251+ // If we're dealing with anything more recent than 2.2 explicitly enable UDF... but run it
252+ // through our conversion process to make
253+ // sure more recent versions don't have a problem.
254+ if (cassandraVersion .compareTo (Version .V2_2_0 ) >= 0 ) {
255+ String originalKey = "enable_user_defined_functions" ;
256+ Object originalValue = "true" ;
257+ execute (
258+ "updateconf" ,
259+ String .join (
260+ ":" ,
261+ getConfigKey (originalKey , originalValue , cassandraVersion ),
262+ getConfigValue (originalKey , originalValue , cassandraVersion )));
244263 }
264+
265+ // Note that we aren't performing any substitution on DSE key/value props (at least for now)
245266 if (DSE_ENABLEMENT ) {
246267 for (Map .Entry <String , Object > conf : dseConfiguration .entrySet ()) {
247268 execute ("updatedseconf" , String .format ("%s:%s" , conf .getKey (), conf .getValue ()));
@@ -463,6 +484,40 @@ private Optional<Integer> overrideJvmVersionForDseWorkloads() {
463484 return Optional .empty ();
464485 }
465486
487+ private static String IN_MS_STR = "_in_ms" ;
488+ private static int IN_MS_STR_LENGTH = IN_MS_STR .length ();
489+ private static String ENABLE_STR = "enable_" ;
490+ private static int ENABLE_STR_LENGTH = ENABLE_STR .length ();
491+ private static String IN_KB_STR = "_in_kb" ;
492+ private static int IN_KB_STR_LENGTH = IN_KB_STR .length ();
493+
494+ @ SuppressWarnings ("unused" )
495+ private String getConfigKey (String originalKey , Object originalValue , Version cassandraVersion ) {
496+
497+ // At least for now we won't support substitutions on nested keys. This requires an extra
498+ // traversal of the string
499+ // but we'll live with that for now
500+ if (originalKey .contains ("." )) return originalKey ;
501+ if (cassandraVersion .compareTo (Version .V4_1_0 ) < 0 ) return originalKey ;
502+ if (originalKey .endsWith (IN_MS_STR ))
503+ return originalKey .substring (0 , originalKey .length () - IN_MS_STR_LENGTH );
504+ if (originalKey .startsWith (ENABLE_STR ))
505+ return originalKey .substring (ENABLE_STR_LENGTH ) + "_enabled" ;
506+ if (originalKey .endsWith (IN_KB_STR ))
507+ return originalKey .substring (0 , originalKey .length () - IN_KB_STR_LENGTH );
508+ return originalKey ;
509+ }
510+
511+ private String getConfigValue (
512+ String originalKey , Object originalValue , Version cassandraVersion ) {
513+
514+ String originalValueStr = originalValue .toString ();
515+ if (cassandraVersion .compareTo (Version .V4_1_0 ) < 0 ) return originalValueStr ;
516+ if (originalKey .endsWith (IN_MS_STR )) return originalValueStr + "ms" ;
517+ if (originalKey .endsWith (IN_KB_STR )) return originalValueStr + "KiB" ;
518+ return originalValueStr ;
519+ }
520+
466521 public static Builder builder () {
467522 return new Builder ();
468523 }
0 commit comments