|
|
|
@ -12,6 +12,7 @@ import org.redisson.client.RedisClient;
|
|
|
|
|
public abstract class BaseConcurrentTest extends BaseTest {
|
|
|
|
|
|
|
|
|
|
protected void testMultiInstanceConcurrency(int iterations, final RedissonRunnable runnable) throws InterruptedException {
|
|
|
|
|
System.out.println("Multi Instance Concurrent Job Interation:" + iterations);
|
|
|
|
|
ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors() * 2);
|
|
|
|
|
final Map<Integer, RedissonClient> instances = new HashMap<>();
|
|
|
|
|
|
|
|
|
@ -27,11 +28,16 @@ public abstract class BaseConcurrentTest extends BaseTest {
|
|
|
|
|
pool.submit(() -> {
|
|
|
|
|
IntStream.range(0, iterations)
|
|
|
|
|
.parallel()
|
|
|
|
|
.forEach((i) -> runnable.run(instances.get(i)));
|
|
|
|
|
.forEach((i) -> {
|
|
|
|
|
if (RedissonRuntimeEnvironment.isTravis) {
|
|
|
|
|
System.out.println("Travis please don't kill me, I am still running.");
|
|
|
|
|
}
|
|
|
|
|
runnable.run(instances.get(i));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
pool.shutdown();
|
|
|
|
|
Assert.assertTrue(pool.awaitTermination(5, TimeUnit.MINUTES));
|
|
|
|
|
Assert.assertTrue(pool.awaitTermination(RedissonRuntimeEnvironment.isTravis ? 10 : 3, TimeUnit.MINUTES));
|
|
|
|
|
|
|
|
|
|
System.out.println("multi: " + (System.currentTimeMillis() - watch));
|
|
|
|
|
|
|
|
|
@ -48,18 +54,25 @@ public abstract class BaseConcurrentTest extends BaseTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void testSingleInstanceConcurrency(int iterations, final RedissonRunnable runnable) throws InterruptedException {
|
|
|
|
|
System.out.println("Single Instance Concurrent Job Interation:" + iterations);
|
|
|
|
|
final RedissonClient r = BaseTest.createInstance();
|
|
|
|
|
long watch = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors() * 2);
|
|
|
|
|
System.out.println("");
|
|
|
|
|
pool.submit(() -> {
|
|
|
|
|
IntStream.range(0, iterations)
|
|
|
|
|
.parallel()
|
|
|
|
|
.forEach((i) -> runnable.run(r));
|
|
|
|
|
.forEach((i) -> {
|
|
|
|
|
if (RedissonRuntimeEnvironment.isTravis) {
|
|
|
|
|
System.out.println("Travis please don't kill me, I am still running.");
|
|
|
|
|
}
|
|
|
|
|
runnable.run(r);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
pool.shutdown();
|
|
|
|
|
Assert.assertTrue(pool.awaitTermination(5, TimeUnit.MINUTES));
|
|
|
|
|
Assert.assertTrue(pool.awaitTermination(RedissonRuntimeEnvironment.isTravis ? 10 : 3, TimeUnit.MINUTES));
|
|
|
|
|
|
|
|
|
|
System.out.println(System.currentTimeMillis() - watch);
|
|
|
|
|
|
|
|
|
|