-
Notifications
You must be signed in to change notification settings - Fork 237
improve: filter only own updates for read-after-write-conistency #3414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
csviri
wants to merge
48
commits into
operator-framework:main
Choose a base branch
from
csviri:event-filter-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
9ae44e3
improve: filter only own updates for read-after-write-conistency
csviri 67a7799
wip
csviri da29019
wip
csviri b881622
wip
csviri 3fa7f44
Event filtering with recording
csviri e0999cd
test fix
csviri 5926b5f
Simplified EventHandling
csviri 5755ddf
unit tests fix
csviri eec9ead
small fix, test repeats
csviri 7d655ab
improvements and releated unit tests
csviri 78d37d3
cleanup
csviri ab31610
improve: filter only own updates for read-after-write-conistency with…
csviri c104c43
improvements on edge cases
csviri 01461a8
Potential fix for pull request finding
csviri 0a02991
delete related improvements and unit tests
csviri 61a2bef
delete handling improvements and test improvements
csviri d81c4b9
wip
csviri 8897e99
tests
csviri b0d303d
test fix
csviri a4ccc1d
fix typo
csviri 9b8182b
Potential fix for pull request finding
csviri fca8bf5
fixes
csviri f5ce1c3
improve: filter only own updates for read-after-write-conistency with…
csviri df93f1a
test fixes
csviri b6d6e82
logging and improvements
csviri d3e6992
test AI identified cases
csviri 028863f
fix: only filter own events
csviri 73d867c
wip
csviri 34d776d
improvements and test fixes
csviri 67c39f9
improvements
csviri 24801d2
fix resource cache read
csviri c303353
support for re-list
csviri f779318
simple algorithm, refined tests
csviri 57d3a90
naming fix
csviri a509cf0
small fixes
csviri 2c103d4
cleanup
csviri 1ac63fc
cleanup
csviri 2330ec0
additional tests
csviri 5d1b0a8
addiotinal tests and docs improvements
csviri ef10e12
wip
csviri ec72a28
wip
csviri f1079f5
prepare for re-list
csviri 52f1de1
wip
csviri 4ef6e6e
wip
csviri 309fb9c
Potential fix for pull request finding
csviri e7ad144
wip
csviri 55f530a
fix filtering
csviri 662328a
logging
csviri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 0 additions & 72 deletions
72
...java/io/javaoperatorsdk/operator/processing/event/source/informer/EventFilterDetails.java
This file was deleted.
Oops, something went wrong.
128 changes: 128 additions & 0 deletions
128
...java/io/javaoperatorsdk/operator/processing/event/source/informer/EventFilterSupport.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| /* | ||
| * Copyright Java Operator SDK Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.javaoperatorsdk.operator.processing.event.source.informer; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import io.javaoperatorsdk.operator.processing.event.ResourceID; | ||
|
|
||
| public class EventFilterSupport { | ||
|
|
||
| private static final Logger log = LoggerFactory.getLogger(EventFilterSupport.class); | ||
|
|
||
| private final Map<ResourceID, EventFilterWindow> eventFilterWindows = new HashMap<>(); | ||
| private boolean ongoingReList = false; | ||
|
|
||
| public synchronized void startEventFilteringModify(ResourceID resourceID) { | ||
| var existing = eventFilterWindows.get(resourceID); | ||
| var ed = | ||
| eventFilterWindows.computeIfAbsent(resourceID, id -> new EventFilterWindow(ongoingReList)); | ||
| ed.increaseActiveUpdates(); | ||
| log.debug( | ||
| "startEventFilteringModify: id={}, windowReused={}, ongoingReList={}", | ||
| resourceID, | ||
| existing != null, | ||
| ongoingReList); | ||
| } | ||
|
|
||
| public synchronized Optional<GenericResourceEvent> doneEventFilterModify(ResourceID resourceID) { | ||
| var ed = eventFilterWindows.get(resourceID); | ||
| if (ed == null) { | ||
| log.debug("doneEventFilterModify: no window for id={}", resourceID); | ||
| return Optional.empty(); | ||
| } | ||
| ed.decreaseActiveUpdates(); | ||
| log.debug("doneEventFilterModify: id={}", resourceID); | ||
| return check(ed, resourceID); | ||
| } | ||
|
|
||
| public synchronized Optional<GenericResourceEvent> processEvent( | ||
| ResourceID resourceId, GenericResourceEvent genericResourceEvent) { | ||
| var ed = eventFilterWindows.get(resourceId); | ||
| if (ed != null) { | ||
| log.debug( | ||
| "processEvent: buffering event in window. id={}, action={}, rv={}", | ||
| resourceId, | ||
| genericResourceEvent.getAction(), | ||
| genericResourceEvent | ||
| .getResource() | ||
| .map(r -> r.getMetadata().getResourceVersion()) | ||
| .orElse("?")); | ||
| ed.addRelatedEvent(genericResourceEvent); | ||
| return check(ed, resourceId); | ||
| } else { | ||
| log.debug( | ||
| "processEvent: no active window, surfacing directly. id={}, action={}", | ||
| resourceId, | ||
| genericResourceEvent.getAction()); | ||
| return Optional.of(genericResourceEvent); | ||
| } | ||
| } | ||
|
|
||
| private Optional<GenericResourceEvent> check( | ||
| EventFilterWindow eventFilterWindow, ResourceID resourceID) { | ||
| var res = eventFilterWindow.check(); | ||
| if (eventFilterWindow.canBeRemoved()) { | ||
| log.debug("Removing empty event filter window. id={}", resourceID); | ||
| eventFilterWindows.remove(resourceID); | ||
| } | ||
| return res; | ||
| } | ||
|
|
||
| public synchronized void addToOwnResourceVersions(ResourceID resourceId, String resourceVersion) { | ||
| var window = eventFilterWindows.get(resourceId); | ||
| if (window != null) { | ||
| log.debug("Recording own resourceVersion. id={}, rv={}", resourceId, resourceVersion); | ||
| window.addToOwnResourceVersions(resourceVersion); | ||
| } else { | ||
| log.debug( | ||
| "addToOwnResourceVersions: no active window for id={}, rv={} (skipped)", | ||
| resourceId, | ||
| resourceVersion); | ||
| } | ||
| } | ||
|
|
||
| public synchronized void handleGhostResourceRemoval(ResourceID resourceId) { | ||
| log.debug("Ghost resource removal: discarding event filter window. id={}", resourceId); | ||
| eventFilterWindows.remove(resourceId); | ||
| } | ||
|
|
||
| // for testing purposes | ||
| synchronized Map<ResourceID, EventFilterWindow> getEventFilterWindows() { | ||
| return eventFilterWindows; | ||
| } | ||
|
|
||
| public synchronized void setStartingReList() { | ||
| log.debug("ReList starting: tagging {} active window(s)", eventFilterWindows.size()); | ||
| ongoingReList = true; | ||
| eventFilterWindows.values().forEach(EventFilterWindow::setReListStarted); | ||
| } | ||
|
|
||
| public synchronized void setRelistFinished() { | ||
| log.debug("ReList finished: clearing tag from {} active window(s)", eventFilterWindows.size()); | ||
| ongoingReList = false; | ||
| eventFilterWindows.values().forEach(EventFilterWindow::setReListFinished); | ||
| } | ||
|
|
||
| public synchronized boolean isActiveUpdateFor(ResourceID resourceId) { | ||
| return eventFilterWindows.containsKey(resourceId); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.