23
23
24
24
import com .datastax .oss .driver .api .core .Version ;
25
25
import com .datastax .oss .driver .shaded .guava .common .base .Joiner ;
26
+ import com .datastax .oss .driver .shaded .guava .common .base .Preconditions ;
26
27
import com .datastax .oss .driver .shaded .guava .common .collect .ImmutableMap ;
27
28
import com .datastax .oss .driver .shaded .guava .common .collect .Maps ;
28
29
import com .datastax .oss .driver .shaded .guava .common .io .Resources ;
@@ -179,6 +180,8 @@ public class CcmBridge implements AutoCloseable {
179
180
private final List <String > dseWorkloads ;
180
181
private final String jvmArgs ;
181
182
183
+ private final int sniProxyPort ;
184
+
182
185
private CcmBridge (
183
186
Path configDirectory ,
184
187
int [] nodes ,
@@ -188,7 +191,8 @@ private CcmBridge(
188
191
List <String > dseConfigurationRawYaml ,
189
192
List <String > createOptions ,
190
193
Collection <String > jvmArgs ,
191
- List <String > dseWorkloads ) {
194
+ List <String > dseWorkloads ,
195
+ int sniProxyPort ) {
192
196
this .configDirectory = configDirectory ;
193
197
if (nodes .length == 1 ) {
194
198
// Hack to ensure that the default DC is always called 'dc1': pass a list ('-nX:0') even if
@@ -216,6 +220,7 @@ private CcmBridge(
216
220
}
217
221
this .jvmArgs = allJvmArgs .toString ();
218
222
this .dseWorkloads = dseWorkloads ;
223
+ this .sniProxyPort = sniProxyPort ;
219
224
}
220
225
221
226
// Copied from Netty's PlatformDependent to avoid the dependency on Netty
@@ -290,6 +295,14 @@ private String getCcmVersionString(Version version) {
290
295
return version .toString ();
291
296
}
292
297
298
+ public String getScyllaCloudConfigPathString () {
299
+ return configDirectory .toFile ().getAbsolutePath () + "/" + CLUSTER_NAME + "/config_data.yaml" ;
300
+ }
301
+
302
+ public String getIpPrefix () {
303
+ return ipPrefix ;
304
+ }
305
+
293
306
public void create () {
294
307
if (created .compareAndSet (false , true )) {
295
308
if (INSTALL_DIRECTORY != null ) {
@@ -359,7 +372,12 @@ public void reloadCore(int node, String keyspace, String table, boolean reindex)
359
372
public void start () {
360
373
if (started .compareAndSet (false , true )) {
361
374
try {
362
- execute ("start" , jvmArgs , "--wait-for-binary-proto" );
375
+ execute (
376
+ "start" ,
377
+ jvmArgs ,
378
+ "--wait-for-binary-proto" ,
379
+ (sniProxyPort >= 0 ? "--sni-proxy" : "" ),
380
+ (sniProxyPort > 0 ? "--sni-port=" + sniProxyPort : "" ));
363
381
} catch (RuntimeException re ) {
364
382
// if something went wrong starting CCM, see if we can also dump the error
365
383
executeCheckLogError ();
@@ -510,6 +528,8 @@ public static class Builder {
510
528
511
529
private final Path configDirectory ;
512
530
531
+ private int sniProxyPort = -1 ;
532
+
513
533
private Builder () {
514
534
try {
515
535
this .configDirectory = Files .createTempDirectory ("ccm" );
@@ -614,6 +634,14 @@ public Builder withDseWorkloads(String... workloads) {
614
634
return this ;
615
635
}
616
636
637
+ /** Enable SNI proxy and use given port number. Port 0 means any port. */
638
+ public Builder withSniProxy (int port ) {
639
+ Preconditions .checkArgument (port >= 0 );
640
+ Preconditions .checkArgument (port <= 65535 );
641
+ this .sniProxyPort = port ;
642
+ return this ;
643
+ }
644
+
617
645
public CcmBridge build () {
618
646
return new CcmBridge (
619
647
configDirectory ,
@@ -624,7 +652,8 @@ public CcmBridge build() {
624
652
dseRawYaml ,
625
653
createOptions ,
626
654
jvmArgs ,
627
- dseWorkloads );
655
+ dseWorkloads ,
656
+ sniProxyPort );
628
657
}
629
658
}
630
659
}
0 commit comments