49
49
50
50
public class CcmBridge implements AutoCloseable {
51
51
52
- private static final Logger logger = LoggerFactory .getLogger (CcmBridge .class );
53
-
54
- private final int [] nodes ;
55
-
56
- private final Path configDirectory ;
57
-
58
- private final AtomicBoolean started = new AtomicBoolean ();
59
-
60
- private final AtomicBoolean created = new AtomicBoolean ();
61
-
62
- private final String ipPrefix ;
63
-
64
- private final Map <String , Object > cassandraConfiguration ;
65
- private final Map <String , Object > dseConfiguration ;
66
- private final List <String > rawDseYaml ;
67
- private final List <String > createOptions ;
68
- private final List <String > dseWorkloads ;
69
-
70
- private final String jvmArgs ;
52
+ private static final Logger LOG = LoggerFactory .getLogger (CcmBridge .class );
71
53
72
54
public static final Version VERSION =
73
- Objects .requireNonNull (Version .parse (System .getProperty ("ccm.version" , "3.11 .0" )));
55
+ Objects .requireNonNull (Version .parse (System .getProperty ("ccm.version" , "4.0 .0" )));
74
56
75
57
public static final String INSTALL_DIRECTORY = System .getProperty ("ccm.directory" );
76
58
@@ -126,6 +108,26 @@ public class CcmBridge implements AutoCloseable {
126
108
private static final Version V3_0_15 = Version .parse ("3.0.15" );
127
109
private static final Version V2_1_19 = Version .parse ("2.1.19" );
128
110
111
+ static {
112
+ if (DSE_ENABLEMENT ) {
113
+ LOG .info ("CCM Bridge configured with DSE version {}" , VERSION );
114
+ } else {
115
+ LOG .info ("CCM Bridge configured with Apache Cassandra version {}" , VERSION );
116
+ }
117
+ }
118
+
119
+ private final int [] nodes ;
120
+ private final Path configDirectory ;
121
+ private final AtomicBoolean started = new AtomicBoolean ();
122
+ private final AtomicBoolean created = new AtomicBoolean ();
123
+ private final String ipPrefix ;
124
+ private final Map <String , Object > cassandraConfiguration ;
125
+ private final Map <String , Object > dseConfiguration ;
126
+ private final List <String > rawDseYaml ;
127
+ private final List <String > createOptions ;
128
+ private final List <String > dseWorkloads ;
129
+ private final String jvmArgs ;
130
+
129
131
private CcmBridge (
130
132
Path configDirectory ,
131
133
int [] nodes ,
@@ -141,10 +143,7 @@ private CcmBridge(
141
143
// Hack to ensure that the default DC is always called 'dc1': pass a list ('-nX:0') even if
142
144
// there is only one DC (with '-nX', CCM configures `SimpleSnitch`, which hard-codes the name
143
145
// to 'datacenter1')
144
- int [] tmp = new int [2 ];
145
- tmp [0 ] = nodes [0 ];
146
- tmp [1 ] = 0 ;
147
- this .nodes = tmp ;
146
+ this .nodes = new int [] {nodes [0 ], 0 };
148
147
} else {
149
148
this .nodes = nodes ;
150
149
}
@@ -351,27 +350,27 @@ private void executeCheckLogError() {
351
350
352
351
private void execute (CommandLine cli , boolean forceErrorLogging ) {
353
352
if (forceErrorLogging ) {
354
- logger .error ("Executing: " + cli );
353
+ LOG .error ("Executing: " + cli );
355
354
} else {
356
- logger .debug ("Executing: " + cli );
355
+ LOG .debug ("Executing: " + cli );
357
356
}
358
357
ExecuteWatchdog watchDog = new ExecuteWatchdog (TimeUnit .MINUTES .toMillis (10 ));
359
358
try (LogOutputStream outStream =
360
359
new LogOutputStream () {
361
360
@ Override
362
361
protected void processLine (String line , int logLevel ) {
363
362
if (forceErrorLogging ) {
364
- logger .error ("ccmout> {}" , line );
363
+ LOG .error ("ccmout> {}" , line );
365
364
} else {
366
- logger .debug ("ccmout> {}" , line );
365
+ LOG .debug ("ccmout> {}" , line );
367
366
}
368
367
}
369
368
};
370
369
LogOutputStream errStream =
371
370
new LogOutputStream () {
372
371
@ Override
373
372
protected void processLine (String line , int logLevel ) {
374
- logger .error ("ccmerr> {}" , line );
373
+ LOG .error ("ccmerr> {}" , line );
375
374
}
376
375
}) {
377
376
Executor executor = new DefaultExecutor ();
@@ -381,8 +380,7 @@ protected void processLine(String line, int logLevel) {
381
380
382
381
int retValue = executor .execute (cli );
383
382
if (retValue != 0 ) {
384
- logger .error (
385
- "Non-zero exit code ({}) returned from executing ccm command: {}" , retValue , cli );
383
+ LOG .error ("Non-zero exit code ({}) returned from executing ccm command: {}" , retValue , cli );
386
384
}
387
385
} catch (IOException ex ) {
388
386
if (watchDog .killedProcess ()) {
@@ -413,7 +411,7 @@ private static File createTempStore(String storePath) {
413
411
f .deleteOnExit ();
414
412
Resources .copy (CcmBridge .class .getResource (storePath ), os );
415
413
} catch (IOException e ) {
416
- logger .warn ("Failure to write keystore, SSL-enabled servers may fail to start." , e );
414
+ LOG .warn ("Failure to write keystore, SSL-enabled servers may fail to start." , e );
417
415
}
418
416
return f ;
419
417
}
0 commit comments