|
48 | 48 | import java.util.Optional; |
49 | 49 | import java.util.concurrent.TimeUnit; |
50 | 50 | import java.util.concurrent.atomic.AtomicBoolean; |
| 51 | +import java.util.concurrent.atomic.AtomicInteger; |
51 | 52 | import java.util.stream.Collectors; |
52 | 53 | import org.apache.commons.exec.CommandLine; |
53 | 54 | import org.apache.commons.exec.DefaultExecutor; |
|
62 | 63 | public class CcmBridge implements AutoCloseable { |
63 | 64 |
|
64 | 65 | private static final Logger LOG = LoggerFactory.getLogger(CcmBridge.class); |
| 66 | + private static final AtomicInteger CLUSTER_ID = new AtomicInteger(); |
65 | 67 |
|
66 | 68 | public static BackendType DISTRIBUTION = |
67 | 69 | BackendType.valueOf( |
@@ -209,7 +211,14 @@ private CcmBridge( |
209 | 211 | } else { |
210 | 212 | this.nodes = nodes; |
211 | 213 | } |
212 | | - this.ipPrefix = ipPrefix; |
| 214 | + |
| 215 | + if (ipPrefix == null || ipPrefix.isEmpty()) { |
| 216 | + Integer clusterId = CLUSTER_ID.addAndGet(1); |
| 217 | + this.ipPrefix = String.format("127.%d.%d.", clusterId / 255, (clusterId % 255) + 1); |
| 218 | + } else { |
| 219 | + this.ipPrefix = ipPrefix; |
| 220 | + } |
| 221 | + |
213 | 222 | this.cassandraConfiguration = cassandraConfiguration; |
214 | 223 | this.dseConfiguration = dseConfiguration; |
215 | 224 | this.rawDseYaml = dseConfigurationRawYaml; |
@@ -665,7 +674,7 @@ public static class Builder { |
665 | 674 | private final Map<String, Object> dseConfiguration = new LinkedHashMap<>(); |
666 | 675 | private final List<String> dseRawYaml = new ArrayList<>(); |
667 | 676 | private final List<String> jvmArgs = new ArrayList<>(); |
668 | | - private String ipPrefix = "127.0.0."; |
| 677 | + private String ipPrefix; |
669 | 678 | private final List<String> createOptions = new ArrayList<>(); |
670 | 679 | private final List<String> dseWorkloads = new ArrayList<>(); |
671 | 680 |
|
|
0 commit comments