From d8e2aa279555afcd08f270c9f436e58b9fa6bd96 Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Mon, 24 Jun 2024 17:47:55 +0100 Subject: [PATCH] Remove the unnamed Pipe constructor and update tests to set a pipe name Signed-off-by: Matthew Whitehead --- .../qbft/BFTPivotSelectorFromPeers.java | 6 ++++++ .../snapsync/SnapWorldStateDownloader.java | 1 - .../worldstate/LoadLocalDataStepTest.java | 2 +- .../sync/snapsync/LoadLocalDataStepTest.java | 2 +- .../besu/services/pipeline/Pipe.java | 19 ------------------- .../pipeline/BatchingReadPipeTest.java | 3 ++- .../services/pipeline/CompleterStageTest.java | 3 ++- .../pipeline/FlatMapProcessorTest.java | 6 ++++-- .../pipeline/IteratorSourceStageTest.java | 3 ++- .../services/pipeline/MapProcessorTest.java | 6 ++++-- .../besu/services/pipeline/PipeTest.java | 3 ++- .../pipeline/ProcessingStageTest.java | 4 ++-- 12 files changed, 26 insertions(+), 32 deletions(-) diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/BFTPivotSelectorFromPeers.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/BFTPivotSelectorFromPeers.java index 6ad632defc4..7437b349a2a 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/BFTPivotSelectorFromPeers.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/BFTPivotSelectorFromPeers.java @@ -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); } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java index 54f9c1f296a..9ae49b93c77 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java @@ -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); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/LoadLocalDataStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/LoadLocalDataStepTest.java index 6707ed97054..582bdff6335 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/LoadLocalDataStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/LoadLocalDataStepTest.java @@ -51,7 +51,7 @@ public class LoadLocalDataStepTest { private final Task task = new StubTask(request); private final Pipe> 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()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/LoadLocalDataStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/LoadLocalDataStepTest.java index 9027538ce51..06f92460c27 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/LoadLocalDataStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/LoadLocalDataStepTest.java @@ -55,7 +55,7 @@ public class LoadLocalDataStepTest { private final Task task = new StubTask(request); private final Pipe> 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); diff --git a/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipe.java b/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipe.java index 2a02941b170..63fb01bad13 100644 --- a/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipe.java +++ b/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipe.java @@ -46,25 +46,6 @@ public class Pipe implements ReadPipe, WritePipe { 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. * diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/BatchingReadPipeTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/BatchingReadPipeTest.java index fb90128fbb3..da0908e8148 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/BatchingReadPipeTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/BatchingReadPipeTest.java @@ -31,7 +31,8 @@ public class BatchingReadPipeTest { - private final Pipe source = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER); + private final Pipe 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 batchingPipe = new BatchingReadPipe<>(source, 3, batchCounter); diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/CompleterStageTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/CompleterStageTest.java index ef3e29afebe..ea4a81a9d98 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/CompleterStageTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/CompleterStageTest.java @@ -24,7 +24,8 @@ public class CompleterStageTest { - private final Pipe pipe = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER); + private final Pipe pipe = + new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "test_pipe"); private final List output = new ArrayList<>(); private final CompleterStage stage = new CompleterStage<>("name", pipe, output::add); diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/FlatMapProcessorTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/FlatMapProcessorTest.java index 1012d3b0123..4e3b8cfa513 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/FlatMapProcessorTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/FlatMapProcessorTest.java @@ -28,8 +28,10 @@ public class FlatMapProcessorTest { - private final Pipe input = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER); - private final Pipe output = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER); + private final Pipe input = + new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "input_pipe"); + private final Pipe output = + new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "output_pipe"); @SuppressWarnings("unchecked") private final Function> mapper = mock(Function.class); diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/IteratorSourceStageTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/IteratorSourceStageTest.java index 02052615b75..915a90b1fd3 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/IteratorSourceStageTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/IteratorSourceStageTest.java @@ -22,7 +22,8 @@ public class IteratorSourceStageTest { - private final Pipe output = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER); + private final Pipe output = + new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "output_pipe"); private final IteratorSourceStage stage = new IteratorSourceStage<>("name", Iterators.forArray("a", "b", "c", "d"), output); diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/MapProcessorTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/MapProcessorTest.java index 0d7a913c3e3..7698e8d3279 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/MapProcessorTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/MapProcessorTest.java @@ -27,8 +27,10 @@ public class MapProcessorTest { - private final Pipe input = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER); - private final Pipe output = new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER); + private final Pipe input = + new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "intput_pipe"); + private final Pipe output = + new Pipe<>(10, NO_OP_COUNTER, NO_OP_COUNTER, NO_OP_COUNTER, "output_pipe"); @SuppressWarnings("unchecked") private final Function processor = mock(Function.class); diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipeTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipeTest.java index c838bc887a3..c4a7a88b527 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipeTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipeTest.java @@ -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 pipe = new Pipe<>(5, inputCounter, outputCounter, abortedItemCounter); + private final Pipe pipe = + new Pipe<>(5, inputCounter, outputCounter, abortedItemCounter, "test_pipe"); @Test public void shouldNotHaveMoreWhenEmptyAndClosed() { diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/ProcessingStageTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/ProcessingStageTest.java index efbe16da668..a07530f5497 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/ProcessingStageTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/ProcessingStageTest.java @@ -34,9 +34,9 @@ public class ProcessingStageTest { private final Pipe 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 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 singleStep; private ProcessingStage stage;