Skip to content

Commit

Permalink
Remove unused ThreadBarrier class (#37666)
Browse files Browse the repository at this point in the history
This class is pretty complex and only used in a test where we can simply
fail the test with an assertion error.
  • Loading branch information
s1monw committed Jan 24, 2019
1 parent 4d4f860 commit d88b8a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 326 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.hamcrest.Matcher;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -169,7 +170,7 @@ public void run() {
public void testScaleUp() throws Exception {
final int min = between(1, 3);
final int max = between(min + 1, 6);
final ThreadBarrier barrier = new ThreadBarrier(max + 1);
final CyclicBarrier barrier = new CyclicBarrier(max + 1);

ThreadPoolExecutor pool =
EsExecutors.newScaling(getClass().getName() + "/" + getTestName(), min, max, between(1, 100), randomTimeUnit(),
Expand All @@ -179,16 +180,13 @@ public void testScaleUp() throws Exception {

for (int i = 0; i < max; ++i) {
final CountDownLatch latch = new CountDownLatch(1);
pool.execute(new Runnable() {
@Override
public void run() {
latch.countDown();
try {
barrier.await();
barrier.await();
} catch (Exception e) {
barrier.reset(e);
}
pool.execute(() -> {
latch.countDown();
try {
barrier.await();
barrier.await();
} catch (Exception e) {
throw new AssertionError(e);
}
});

Expand All @@ -207,7 +205,7 @@ public void run() {
public void testScaleDown() throws Exception {
final int min = between(1, 3);
final int max = between(min + 1, 6);
final ThreadBarrier barrier = new ThreadBarrier(max + 1);
final CyclicBarrier barrier = new CyclicBarrier(max + 1);

final ThreadPoolExecutor pool =
EsExecutors.newScaling(getClass().getName() + "/" + getTestName(), min, max, between(1, 100), TimeUnit.MILLISECONDS,
Expand All @@ -217,16 +215,13 @@ public void testScaleDown() throws Exception {

for (int i = 0; i < max; ++i) {
final CountDownLatch latch = new CountDownLatch(1);
pool.execute(new Runnable() {
@Override
public void run() {
latch.countDown();
try {
barrier.await();
barrier.await();
} catch (Exception e) {
barrier.reset(e);
}
pool.execute(() -> {
latch.countDown();
try {
barrier.await();
barrier.await();
} catch (Exception e) {
throw new AssertionError(e);
}
});

Expand Down

0 comments on commit d88b8a6

Please sign in to comment.