@@ -0,0 +1,2412 @@
+package io.rainfall.generator;%0A%0Aimport io.rainfall.SequenceGenerator;%0Aimport io.rainfall.configuration.DistributedConfig;%0A%0Aimport java.util.concurrent.atomic.AtomicLong;%0A%0A/**%0A * Striped %7B@link SequenceGenerator%7D that divides the range of generated sequences into %3Ccode%3EinstanceCount%3C/code%3E%0A * sub-ranges.%0A * %3Cp%3E%0A * This generator is useful in scenarios where multiple independent JVMs are being used and need%0A * to generate unique sequences as each JVM will get its own sub-range to generate from, provided that each JVM%0A * supplies a distinct index with the given %7B@link InstanceIndexSupplier%7D.%0A * %3Cp%3E%0A * Indices supplied by %7B@link InstanceIndexSupplier%7D must be in the range %3Ccode%3E0 -%3E (instanceCount - 1)%3C/code%3E.%0A */%0Apublic class StripedLongSequenceGenerator implements SequenceGenerator %7B%0A%0A  private final AtomicLong next;%0A  private final long begin;%0A  private final long end;%0A%0A  public StripedLongSequenceGenerator(final DistributedConfig distributedConfig) %7B%0A    this(distributedConfig.getNbClients(), new InstanceIndexSupplier() %7B%0A      @Override%0A      public Integer get() %7B%0A        return distributedConfig.getCurrentClientId();%0A      %7D%0A    %7D);%0A  %7D%0A%0A  public StripedLongSequenceGenerator(int instanceCount, InstanceIndexSupplier instanceIndexSupplier) %7B%0A    this(instanceCount, instanceIndexSupplier, Long.MAX_VALUE);%0A  %7D%0A%0A  public StripedLongSequenceGenerator(int instanceCount, InstanceIndexSupplier instanceIndexSupplier, long totalRange) %7B%0A    int instanceIndex = instanceIndexSupplier.get();%0A    if (instanceIndex %3C 0) %7B%0A      throw new IllegalArgumentException(%22Supplied instance index '%22 + instanceIndex + %22' is lower than 0%22);%0A    %7D%0A    if (instanceIndex %3E= instanceCount) %7B%0A      throw new IllegalArgumentException(%22Supplied instance index '%22 + instanceIndex + %22' is higher than instance count of %22 + instanceCount);%0A    %7D%0A    long localRange = totalRange / instanceCount;%0A    this.begin = instanceIndex * localRange;%0A    this.end = begin + localRange - 1;%0A    this.next = new AtomicLong(begin);%0A  %7D%0A%0A  @Override%0A  public long next() %7B%0A    while (true) %7B%0A      long value = next.getAndIncrement();%0A      if (value %3C= end) %7B%0A        return value;%0A      %7D%0A      next.compareAndSet(value, begin);%0A    %7D%0A  %7D%0A%0A  @Override%0A  public String getDescription() %7B%0A    return %22StripedLong sequence between %22 + begin + %22 and %22 + end;%0A  %7D%0A%0A  public interface InstanceIndexSupplier %7B%0A    Integer get();%0A  %7D%0A%0A%7D%0A

add StripedLongSequenceGenerator