mosche commented on code in PR #22525:
URL: https://github.com/apache/beam/pull/22525#discussion_r936292439


##########
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:
   I considered doing that, though it would mean an additional lookup the get 
the `TimeDomain` first. That didn't seem worth it ... But no real preference 
from my side.



-- 
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]

Reply via email to