Skip to content

Commit

Permalink
Remove the unnamed Pipe constructor and update tests to set a pipe name
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Whitehead <[email protected]>
  • Loading branch information
matthew1001 committed Jun 24, 2024
1 parent 0a7f111 commit d8e2aa2
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public BFTPivotSelectorFromPeers(
LOG.info("Creating pivot block selector for BFT node");
}

/**
* Determine if our node is a BFT validator node
*
* @param validatorProvider the validator provider
* @return true if we are a validator
*/
protected boolean weAreAValidator(final ValidatorProvider validatorProvider) {
return validatorProvider.nodeIsValidator(nodeKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings("unused")
public class SnapWorldStateDownloader implements WorldStateDownloader {

private static final Logger LOG = LoggerFactory.getLogger(SnapWorldStateDownloader.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class LoadLocalDataStepTest {
private final Task<NodeDataRequest> task = new StubTask(request);

private final Pipe<Task<NodeDataRequest>> completedTasks =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "test_pipe");
private final LoadLocalDataStep loadLocalDataStep =
new LoadLocalDataStep(
new WorldStateStorageCoordinator(worldStateKeyValueStorage), new NoOpMetricsSystem());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class LoadLocalDataStepTest {
private final Task<SnapDataRequest> task = new StubTask(request);

private final Pipe<Task<SnapDataRequest>> completedTasks =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "test_pipe");

private final SnapSyncProcessState snapSyncState = mock(SnapSyncProcessState.class);
private final SnapWorldDownloadState downloadState = mock(SnapWorldDownloadState.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,6 @@ public class Pipe<T> implements ReadPipe<T>, WritePipe<T> {
private final AtomicBoolean aborted = new AtomicBoolean();
private String pipeName = "";

/**
* Instantiates a new Pipe.
*
* @param capacity the capacity
* @param inputCounter the input counter
* @param outputCounter the output counter
* @param abortedItemCounter the aborted item counter
*/
public Pipe(
final int capacity,
final Counter inputCounter,
final Counter outputCounter,
final Counter abortedItemCounter) {
queue = new ArrayBlockingQueue<>(capacity);
this.inputCounter = inputCounter;
this.outputCounter = outputCounter;
this.abortedItemCounter = abortedItemCounter;
}

/**
* Instantiates a new Pipe.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

public class BatchingReadPipeTest {

private final Pipe<String> source = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
private final Pipe<String> source =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "source_pipe");
private final Counter batchCounter = mock(Counter.class);
private final BatchingReadPipe<String> batchingPipe =
new BatchingReadPipe<>(source, 3, batchCounter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

public class CompleterStageTest {

private final Pipe<String> pipe = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
private final Pipe<String> pipe =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "test_pipe");
private final List<String> output = new ArrayList<>();
private final CompleterStage<String> stage = new CompleterStage<>("name", pipe, output::add);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@

public class FlatMapProcessorTest {

private final Pipe<String> input = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
private final Pipe<String> output = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
private final Pipe<String> input =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "input_pipe");
private final Pipe<String> output =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "output_pipe");

@SuppressWarnings("unchecked")
private final Function<String, Stream<String>> mapper = mock(Function.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

public class IteratorSourceStageTest {

private final Pipe<String> output = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
private final Pipe<String> output =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "output_pipe");

private final IteratorSourceStage<String> stage =
new IteratorSourceStage<>("name", Iterators.forArray("a", "b", "c", "d"), output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@

public class MapProcessorTest {

private final Pipe<String> input = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
private final Pipe<String> output = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
private final Pipe<String> input =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "intput_pipe");
private final Pipe<String> output =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "output_pipe");

@SuppressWarnings("unchecked")
private final Function<String, String> processor = mock(Function.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class PipeTest {
private final Counter inputCounter = mock(Counter.class);
private final Counter outputCounter = mock(Counter.class);
private final Counter abortedItemCounter = mock(Counter.class);
private final Pipe<String> pipe = new Pipe<>(5, inputCounter, outputCounter, abortedItemCounter);
private final Pipe<String> pipe =
new Pipe<>(5, inputCounter, outputCounter, abortedItemCounter, "test_pipe");

@Test
public void shouldNotHaveMoreWhenEmptyAndClosed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
public class ProcessingStageTest {

private final Pipe<String> inputPipe =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "input_pipe");
private final Pipe<String> outputPipe =
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER);
new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "output_pipe");
@Mock private Processor<String, String> singleStep;
private ProcessingStage<String, String> stage;

Expand Down

0 comments on commit d8e2aa2

Please sign in to comment.