|
38 | 38 | import com.google.common.util.concurrent.AsyncFunction; |
39 | 39 | import com.google.common.util.concurrent.FutureCallback; |
40 | 40 |
|
| 41 | +import org.slf4j.Logger; |
| 42 | +import org.slf4j.LoggerFactory; |
| 43 | + |
41 | 44 | import org.apache.cassandra.concurrent.ExecutorFactory; |
42 | 45 | import org.apache.cassandra.config.ParameterizedClass; |
43 | 46 | import org.apache.cassandra.distributed.Cluster; |
|
112 | 115 | @SuppressWarnings("RedundantCast") |
113 | 116 | public class ClusterSimulation<S extends Simulation> implements AutoCloseable |
114 | 117 | { |
| 118 | + private static final Logger logger = LoggerFactory.getLogger(ClusterSimulation.class); |
| 119 | + |
115 | 120 | public static final Class<?>[] SHARE = new Class[] |
116 | 121 | { |
117 | 122 | AsyncFunction.class, |
@@ -188,6 +193,7 @@ public static abstract class Builder<S extends Simulation> |
188 | 193 | protected HeapPool.Logged.Listener memoryListener; |
189 | 194 | protected SimulatedTime.Listener timeListener = (i1, i2) -> {}; |
190 | 195 | protected LongConsumer onThreadLocalRandomCheck; |
| 196 | + protected Boolean useTrieMemtable = null; // null = random |
191 | 197 |
|
192 | 198 | public Debug debug() |
193 | 199 | { |
@@ -516,6 +522,12 @@ public Builder<S> onThreadLocalRandomCheck(LongConsumer runnable) |
516 | 522 | return this; |
517 | 523 | } |
518 | 524 |
|
| 525 | + public Builder<S> useTrieMemtable(boolean useTrie) |
| 526 | + { |
| 527 | + this.useTrieMemtable = useTrie; |
| 528 | + return this; |
| 529 | + } |
| 530 | + |
519 | 531 | public abstract ClusterSimulation<S> create(long seed) throws IOException; |
520 | 532 | } |
521 | 533 |
|
@@ -654,6 +666,12 @@ public ClusterSimulation(RandomSource random, long seed, int uniqueNum, |
654 | 666 |
|
655 | 667 | execution = new SimulatedExecution(); |
656 | 668 |
|
| 669 | + boolean useTrieMemtable = builder.useTrieMemtable != null |
| 670 | + ? builder.useTrieMemtable |
| 671 | + : random.uniform(0, 2) == 0; // 50/50 chance |
| 672 | + logger.info("Seed 0x{} using memtable: {}", Long.toHexString(seed), |
| 673 | + useTrieMemtable ? "TrieMemtable" : "SkipListMemtable"); |
| 674 | + |
657 | 675 | KindOfSequence kindOfDriftSequence = Choices.uniform(KindOfSequence.values()).choose(random); |
658 | 676 | KindOfSequence kindOfDiscontinuitySequence = Choices.uniform(KindOfSequence.values()).choose(random); |
659 | 677 | time = new SimulatedTime(numOfNodes, random, 1577836800000L /*Jan 1st UTC*/, builder.clockDriftNanos, kindOfDriftSequence, |
@@ -700,6 +718,14 @@ public ClusterSimulation(RandomSource random, long seed, int uniqueNum, |
700 | 718 |
|
701 | 719 | if (commitlogCompressed) |
702 | 720 | config.set("commitlog_compression", new ParameterizedClass(LZ4Compressor.class.getName(), emptyMap())); |
| 721 | + |
| 722 | + if (useTrieMemtable) |
| 723 | + { |
| 724 | + config.set("memtable", Map.of( |
| 725 | + "configurations", Map.of( |
| 726 | + "default", Map.of("class_name", "TrieMemtable")))); |
| 727 | + } |
| 728 | + |
703 | 729 | configUpdater.accept(threadAllocator.update(config)); |
704 | 730 | }) |
705 | 731 | .withInstanceInitializer(new IInstanceInitializer() |
|
0 commit comments