diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractEthTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractEthTask.java index 8dec1e100b..23506e834c 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractEthTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractEthTask.java @@ -26,13 +26,15 @@ import java.util.function.Supplier; public abstract class AbstractEthTask implements EthTask { protected double taskTimeInSec = -1.0D; - protected OperationTimer taskTimer; + protected final LabelledMetric ethTasksTimer; + protected final OperationTimer taskTimer; protected final AtomicReference> result = new AtomicReference<>(); protected volatile Collection> subTaskFutures = new ConcurrentLinkedDeque<>(); /** @param ethTasksTimer The metrics timer to use to time the duration of the task. */ protected AbstractEthTask(final LabelledMetric ethTasksTimer) { + this.ethTasksTimer = ethTasksTimer; taskTimer = ethTasksTimer.labels(getClass().getSimpleName()); } diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractRetryingPeerTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractRetryingPeerTask.java index 7499d287af..4d8fe66161 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractRetryingPeerTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractRetryingPeerTask.java @@ -43,7 +43,6 @@ public abstract class AbstractRetryingPeerTask> extends private final EthContext ethContext; private final int maxRetries; private int retryCount = 0; - private final LabelledMetric ethTasksTimer; private Optional assignedPeer = Optional.empty(); /** @@ -57,7 +56,6 @@ public abstract class AbstractRetryingPeerTask> extends final LabelledMetric ethTasksTimer) { super(ethTasksTimer); this.ethContext = ethContext; - this.ethTasksTimer = ethTasksTimer; this.maxRetries = maxRetries; } diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/CompleteBlocksTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/CompleteBlocksTask.java index b087d6391b..13162cf830 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/CompleteBlocksTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/CompleteBlocksTask.java @@ -46,7 +46,6 @@ public class CompleteBlocksTask extends AbstractRetryingPeerTask> private final EthContext ethContext; private final ProtocolSchedule protocolSchedule; - private final LabelledMetric ethTasksTimer; private final List headers; private final Map blocks; @@ -61,7 +60,6 @@ public class CompleteBlocksTask extends AbstractRetryingPeerTask> checkArgument(headers.size() > 0, "Must supply a non-empty headers list"); this.protocolSchedule = protocolSchedule; this.ethContext = ethContext; - this.ethTasksTimer = ethTasksTimer; this.headers = headers; this.blocks = new HashMap<>(); diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DetermineCommonAncestorTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DetermineCommonAncestorTask.java index 19e4a2d8b4..d7808ec013 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DetermineCommonAncestorTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DetermineCommonAncestorTask.java @@ -36,7 +36,6 @@ public class DetermineCommonAncestorTask extends AbstractEthTask private final EthContext ethContext; private final ProtocolSchedule protocolSchedule; private final ProtocolContext protocolContext; - private final LabelledMetric ethTasksTimer; private final EthPeer peer; private final int headerRequestSize; @@ -56,7 +55,6 @@ public class DetermineCommonAncestorTask extends AbstractEthTask this.protocolSchedule = protocolSchedule; this.ethContext = ethContext; this.protocolContext = protocolContext; - this.ethTasksTimer = ethTasksTimer; this.peer = peer; this.headerRequestSize = headerRequestSize; diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DownloadHeaderSequenceTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DownloadHeaderSequenceTask.java index 1481fee42a..1c568993e3 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DownloadHeaderSequenceTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DownloadHeaderSequenceTask.java @@ -52,7 +52,6 @@ public class DownloadHeaderSequenceTask extends AbstractRetryingPeerTask protocolContext; private final ProtocolSchedule protocolSchedule; - private final LabelledMetric ethTasksTimer; private final BlockHeader[] headers; private final BlockHeader referenceHeader; @@ -75,7 +74,6 @@ public class DownloadHeaderSequenceTask extends AbstractRetryingPeerTask { private static final Logger LOG = LogManager.getLogger(); private final ProtocolSchedule protocolSchedule; - private final LabelledMetric ethTasksTimer; private final Hash hash; protected GetBlockFromPeerTask( @@ -45,7 +44,6 @@ public class GetBlockFromPeerTask extends AbstractPeerTask { final LabelledMetric ethTasksTimer) { super(ethContext, ethTasksTimer); this.protocolSchedule = protocolSchedule; - this.ethTasksTimer = ethTasksTimer; this.hash = hash; } diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/ImportBlocksTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/ImportBlocksTask.java index 31c3db6df9..a14776822a 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/ImportBlocksTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/ImportBlocksTask.java @@ -42,7 +42,6 @@ public class ImportBlocksTask extends AbstractPeerTask> { private final ProtocolContext protocolContext; private final ProtocolSchedule protocolSchedule; - private final LabelledMetric ethTasksTimer; private final long startNumber; private final BlockHeader referenceHeader; @@ -61,7 +60,6 @@ public class ImportBlocksTask extends AbstractPeerTask> { this.protocolContext = protocolContext; this.referenceHeader = referenceHeader; this.maxBlocks = maxBlocks; - this.ethTasksTimer = ethTasksTimer; this.startNumber = referenceHeader.getNumber(); } diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PipelinedImportChainSegmentTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PipelinedImportChainSegmentTask.java index 239a921ae2..7affe89504 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PipelinedImportChainSegmentTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PipelinedImportChainSegmentTask.java @@ -45,7 +45,6 @@ public class PipelinedImportChainSegmentTask extends AbstractEthTask protocolContext; private final ProtocolSchedule protocolSchedule; private final List importedBlocks = new ArrayList<>(); - private final LabelledMetric ethTasksTimer; // First header is assumed to already be imported private final List checkpointHeaders; @@ -76,7 +75,6 @@ public class PipelinedImportChainSegmentTask extends AbstractEthTask> { private final ProtocolSchedule protocolSchedule; private final EthContext ethContext; - private final LabelledMetric ethTasksTimer; private final long pivotBlockNumber; private RetryingGetHeaderFromPeerByNumberTask( @@ -40,7 +39,6 @@ public class RetryingGetHeaderFromPeerByNumberTask super(ethContext, maxRetries, ethTasksTimer); this.protocolSchedule = protocolSchedule; this.ethContext = ethContext; - this.ethTasksTimer = ethTasksTimer; this.pivotBlockNumber = pivotBlockNumber; }