Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Move ethTaskTimer to abstract root #775

Merged
merged 1 commit into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
Expand All @@ -57,7 +56,6 @@ public AbstractRetryingPeerTask(
final LabelledMetric<OperationTimer> ethTasksTimer) {
super(ethTasksTimer);
this.ethContext = ethContext;
this.ethTasksTimer = ethTasksTimer;
this.maxRetries = maxRetries;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -61,7 +60,6 @@ private CompleteBlocksTask(
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<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -56,7 +55,6 @@ private DetermineCommonAncestorTask(
this.protocolSchedule = protocolSchedule;
this.ethContext = ethContext;
this.protocolContext = protocolContext;
this.ethTasksTimer = ethTasksTimer;
this.peer = peer;
this.headerRequestSize = headerRequestSize;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -75,7 +74,6 @@ private DownloadHeaderSequenceTask(
this.ethContext = ethContext;
this.referenceHeader = referenceHeader;
this.segmentLength = segmentLength;
this.ethTasksTimer = ethTasksTimer;

startingBlockNumber = referenceHeader.getNumber() - segmentLength;
headers = new BlockHeader[segmentLength];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -45,7 +44,6 @@ protected GetBlockFromPeerTask(
final LabelledMetric<OperationTimer> ethTasksTimer) {
super(ethContext, ethTasksTimer);
this.protocolSchedule = protocolSchedule;
this.ethTasksTimer = ethTasksTimer;
this.hash = hash;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -61,7 +60,6 @@ protected ImportBlocksTask(
this.protocolContext = protocolContext;
this.referenceHeader = referenceHeader;
this.maxBlocks = maxBlocks;
this.ethTasksTimer = ethTasksTimer;

this.startNumber = referenceHeader.getNumber();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,7 +75,6 @@ protected PipelinedImportChainSegmentTask(
this.protocolSchedule = protocolSchedule;
this.protocolContext = protocolContext;
this.ethContext = ethContext;
this.ethTasksTimer = ethTasksTimer;
this.checkpointHeaders = checkpointHeaders;
this.chunksInTotal = checkpointHeaders.size() - 1;
this.blockHandler = blockHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -40,7 +39,6 @@ private RetryingGetHeaderFromPeerByNumberTask(
super(ethContext, maxRetries, ethTasksTimer);
this.protocolSchedule = protocolSchedule;
this.ethContext = ethContext;
this.ethTasksTimer = ethTasksTimer;
this.pivotBlockNumber = pivotBlockNumber;
}

Expand Down