TheNeuralBit commented on code in PR #22525:
URL: https://github.com/apache/beam/pull/22525#discussion_r936020620
##########
runners/core-java/src/main/java/org/apache/beam/runners/core/InMemoryTimerInternals.java:
##########
@@ -155,10 +156,18 @@ public void setTimer(TimerData timerData) {
@Override
public void deleteTimer(
StateNamespace namespace, String timerId, String timerFamilyId,
TimeDomain timeDomain) {
- throw new UnsupportedOperationException("Canceling a timer by ID is not
yet supported.");
+ TimerData removedTimer = existingTimers.remove(namespace, timerId + '+' +
timerFamilyId);
+ if (removedTimer != null) {
+ Preconditions.checkState(
+ removedTimer.getDomain().equals(timeDomain),
+ "%s doesn't match time domain %s of timer",
+ timeDomain,
+ removedTimer.getDomain());
Review Comment:
I don't really have context here, but I wonder if we should do this check
first, and unconditionally, so that we don't end up with a partially removed
timer?
##########
runners/core-java/src/main/java/org/apache/beam/runners/core/InMemoryTimerInternals.java:
##########
@@ -155,10 +156,18 @@ public void setTimer(TimerData timerData) {
@Override
public void deleteTimer(
StateNamespace namespace, String timerId, String timerFamilyId,
TimeDomain timeDomain) {
- throw new UnsupportedOperationException("Canceling a timer by ID is not
yet supported.");
+ TimerData removedTimer = existingTimers.remove(namespace, timerId + '+' +
timerFamilyId);
+ if (removedTimer != null) {
+ Preconditions.checkState(
+ removedTimer.getDomain().equals(timeDomain),
+ "%s doesn't match time domain %s of timer",
+ timeDomain,
+ removedTimer.getDomain());
+ timersForDomain(timeDomain).remove(removedTimer);
+ }
}
- /** @deprecated use {@link #deleteTimer(StateNamespace, String,
TimeDomain)}. */
+ /** @deprecated use {@link #deleteTimer(StateNamespace, String, String,
TimeDomain)}. */
Review Comment:
Maybe this should defer to the `deleteTimer(StateNamespace, String, String,
TimeDomain)` implementation?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]