Skip to content

Commit

Permalink
[#9254] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad authored and ga-ram committed Oct 19, 2022
1 parent b58b598 commit e87daef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public ExecutorListener(int uriStatDataLimitSize, int collectInterval) {
this.clock = Clock.tick(collectInterval);

this.snapshotQueue = new ConcurrentLinkedQueue<>();
this.snapshotManager = new Snapshot<>(value -> new AgentUriStatData(value, uriStatDataLimitSize));
this.snapshotManager = new Snapshot<>(value -> new AgentUriStatData(value, uriStatDataLimitSize), AgentUriStatData::getBaseTimestamp);
}

@Override
Expand Down Expand Up @@ -138,7 +138,7 @@ public void executePollTimeout() {


private boolean checkAndFlushOldData(long currentBaseTimestamp) {
final AgentUriStatData snapshot = snapshotManager.takeSnapshot(currentBaseTimestamp, AgentUriStatData::getBaseTimestamp);
final AgentUriStatData snapshot = snapshotManager.takeSnapshot(currentBaseTimestamp);
if (snapshot != null) {
addCompletedData(snapshot);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ public class Snapshot<T> {

private T currentImage;
private final LongFunction<T> instanceFactory;
private final ToLongFunction<T> currentImageTimestamp;

public Snapshot(LongFunction<T> instanceFactory) {
public Snapshot(LongFunction<T> instanceFactory, ToLongFunction<T> currentImageTimestamp) {
this.instanceFactory = Objects.requireNonNull(instanceFactory, "instanceFactory");
this.currentImageTimestamp = Objects.requireNonNull(currentImageTimestamp, "currentImageTimestamp");
}

public T takeSnapshot(long currentBaseTimestamp, ToLongFunction<T> currentImageTimestamp) {
public T takeSnapshot(long currentBaseTimestamp) {
if (currentImage == null) {
return null;
}
Expand Down

0 comments on commit e87daef

Please sign in to comment.