Skip to content

Commit

Permalink
fix(polling): Fast-forward flag correctly influencing send events (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert committed Mar 22, 2018
1 parent cdd8cde commit f6b532a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ public void pollSingle(PollContext ctx) {
.ofNullable(getPartitionUpperThreshold(ctx.partitionName))
.orElse(igorProperties.getSpinnaker().getPollingSafeguard().getItemUpperThreshold());

boolean sendEvents = !ctx.fastForward;
int deltaSize = delta.getItems().size();
if (deltaSize > upperThreshold) {
if (ctx.fastForward) {
log.warn(
"Fast forwarding items ({}) in {} {}",
deltaSize, kv("monitor", monitorName), kv("partition", ctx.partitionName)
);
sendEvents = false;
} else {
log.warn(
"Number of items ({}) to cache exceeds upper threshold ({}) in {} {}",
Expand All @@ -133,7 +135,7 @@ deltaSize, upperThreshold, kv("monitor", monitorName), kv("partition", ctx.parti
}
}

commitDelta(delta, ctx.fastForward);
commitDelta(delta, sendEvents);
registry.gauge(itemsCachedId.withTags("monitor", monitorName, "partition", ctx.partitionName)).set(deltaSize);
registry.gauge(itemsOverThresholdId.withTags("monitor", monitorName, "partition", ctx.partitionName)).set(0);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public PollContext(String partitionName) {
}

public PollContext(String partitionName, Map<String, Object> context) {
this(partitionName, context, true);
this(partitionName, context, false);
}

public PollContext(String partitionName, boolean fastForward) {
Expand All @@ -42,6 +42,6 @@ public PollContext(String partitionName, Map<String, Object> context, boolean fa
}

public PollContext fastForward() {
return new PollContext(partitionName, context, false);
return new PollContext(partitionName, context, true);
}
}

0 comments on commit f6b532a

Please sign in to comment.