Move ethTaskTimer to abstract root (#775)

This field is in enough subclasses it should just be kept in the abstract root.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Danno Ferrin 6 years ago committed by GitHub
parent 494640ecbc
commit 96dfc5aa30
  1. 4
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractEthTask.java
  2. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractRetryingPeerTask.java
  3. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/CompleteBlocksTask.java
  4. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DetermineCommonAncestorTask.java
  5. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DownloadHeaderSequenceTask.java
  6. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/GetBlockFromPeerTask.java
  7. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/ImportBlocksTask.java
  8. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PipelinedImportChainSegmentTask.java
  9. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/RetryingGetHeaderFromPeerByNumberTask.java

@ -26,13 +26,15 @@ import java.util.function.Supplier;
public abstract class AbstractEthTask<T> implements EthTask<T> {
protected double taskTimeInSec = -1.0D;
protected OperationTimer taskTimer;
protected final LabelledMetric<OperationTimer> ethTasksTimer;
protected final OperationTimer taskTimer;
protected final AtomicReference<CompletableFuture<T>> result = new AtomicReference<>();
protected volatile Collection<CompletableFuture<?>> subTaskFutures =
new ConcurrentLinkedDeque<>();
/** @param ethTasksTimer The metrics timer to use to time the duration of the task. */
protected AbstractEthTask(final LabelledMetric<OperationTimer> ethTasksTimer) {
this.ethTasksTimer = ethTasksTimer;
taskTimer = ethTasksTimer.labels(getClass().getSimpleName());
}

@ -43,7 +43,6 @@ public abstract class AbstractRetryingPeerTask<T extends Collection<?>> extends
private final EthContext ethContext;
private final int maxRetries;
private int retryCount = 0;
private final LabelledMetric<OperationTimer> ethTasksTimer;
private Optional<EthPeer> assignedPeer = Optional.empty();
/**
@ -57,7 +56,6 @@ public abstract class AbstractRetryingPeerTask<T extends Collection<?>> extends
final LabelledMetric<OperationTimer> ethTasksTimer) {
super(ethTasksTimer);
this.ethContext = ethContext;
this.ethTasksTimer = ethTasksTimer;
this.maxRetries = maxRetries;
}

@ -46,7 +46,6 @@ public class CompleteBlocksTask<C> extends AbstractRetryingPeerTask<List<Block>>
private final EthContext ethContext;
private final ProtocolSchedule<C> protocolSchedule;
private final LabelledMetric<OperationTimer> ethTasksTimer;
private final List<BlockHeader> headers;
private final Map<Long, Block> blocks;
@ -61,7 +60,6 @@ public class CompleteBlocksTask<C> extends AbstractRetryingPeerTask<List<Block>>
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<>();

@ -36,7 +36,6 @@ public class DetermineCommonAncestorTask<C> extends AbstractEthTask<BlockHeader>
private final EthContext ethContext;
private final ProtocolSchedule<C> protocolSchedule;
private final ProtocolContext<C> protocolContext;
private final LabelledMetric<OperationTimer> ethTasksTimer;
private final EthPeer peer;
private final int headerRequestSize;
@ -56,7 +55,6 @@ public class DetermineCommonAncestorTask<C> extends AbstractEthTask<BlockHeader>
this.protocolSchedule = protocolSchedule;
this.ethContext = ethContext;
this.protocolContext = protocolContext;
this.ethTasksTimer = ethTasksTimer;
this.peer = peer;
this.headerRequestSize = headerRequestSize;

@ -52,7 +52,6 @@ public class DownloadHeaderSequenceTask<C> extends AbstractRetryingPeerTask<List
private final EthContext ethContext;
private final ProtocolContext<C> protocolContext;
private final ProtocolSchedule<C> protocolSchedule;
private final LabelledMetric<OperationTimer> ethTasksTimer;
private final BlockHeader[] headers;
private final BlockHeader referenceHeader;
@ -75,7 +74,6 @@ public class DownloadHeaderSequenceTask<C> extends AbstractRetryingPeerTask<List
this.ethContext = ethContext;
this.referenceHeader = referenceHeader;
this.segmentLength = segmentLength;
this.ethTasksTimer = ethTasksTimer;
startingBlockNumber = referenceHeader.getNumber() - segmentLength;
headers = new BlockHeader[segmentLength];

@ -35,7 +35,6 @@ public class GetBlockFromPeerTask extends AbstractPeerTask<Block> {
private static final Logger LOG = LogManager.getLogger();
private final ProtocolSchedule<?> protocolSchedule;
private final LabelledMetric<OperationTimer> ethTasksTimer;
private final Hash hash;
protected GetBlockFromPeerTask(
@ -45,7 +44,6 @@ public class GetBlockFromPeerTask extends AbstractPeerTask<Block> {
final LabelledMetric<OperationTimer> ethTasksTimer) {
super(ethContext, ethTasksTimer);
this.protocolSchedule = protocolSchedule;
this.ethTasksTimer = ethTasksTimer;
this.hash = hash;
}

@ -42,7 +42,6 @@ public class ImportBlocksTask<C> extends AbstractPeerTask<List<Block>> {
private final ProtocolContext<C> protocolContext;
private final ProtocolSchedule<C> protocolSchedule;
private final LabelledMetric<OperationTimer> ethTasksTimer;
private final long startNumber;
private final BlockHeader referenceHeader;
@ -61,7 +60,6 @@ public class ImportBlocksTask<C> extends AbstractPeerTask<List<Block>> {
this.protocolContext = protocolContext;
this.referenceHeader = referenceHeader;
this.maxBlocks = maxBlocks;
this.ethTasksTimer = ethTasksTimer;
this.startNumber = referenceHeader.getNumber();
}

@ -45,7 +45,6 @@ public class PipelinedImportChainSegmentTask<C, B> extends AbstractEthTask<List<
private final ProtocolContext<C> protocolContext;
private final ProtocolSchedule<C> protocolSchedule;
private final List<B> importedBlocks = new ArrayList<>();
private final LabelledMetric<OperationTimer> ethTasksTimer;
// First header is assumed to already be imported
private final List<BlockHeader> checkpointHeaders;
@ -76,7 +75,6 @@ public class PipelinedImportChainSegmentTask<C, B> extends AbstractEthTask<List<
this.protocolSchedule = protocolSchedule;
this.protocolContext = protocolContext;
this.ethContext = ethContext;
this.ethTasksTimer = ethTasksTimer;
this.checkpointHeaders = checkpointHeaders;
this.chunksInTotal = checkpointHeaders.size() - 1;
this.blockHandler = blockHandler;

@ -28,7 +28,6 @@ public class RetryingGetHeaderFromPeerByNumberTask
extends AbstractRetryingPeerTask<List<BlockHeader>> {
private final ProtocolSchedule<?> protocolSchedule;
private final EthContext ethContext;
private final LabelledMetric<OperationTimer> 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;
}

Loading…
Cancel
Save