-
Notifications
You must be signed in to change notification settings - Fork 220
Temporal resource cache in Event Source #965
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
Merged
Merged
Changes from 28 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
1cb3457
feat: up to date resource from get resource
csviri 5ecfe4b
feature: populate change to informer after latest update
csviri cdd91b3
fix: sample change
csviri b501d19
fix: integration tests
csviri f53b46e
fix: temporal cache for reading resources after update
csviri 58d52cd
docs: temporal cache
csviri 71e54df
fix: remove not used method
csviri d0033fa
fix: unit test for temp cache
csviri 40e4063
fix: unit test wip
csviri 38fbed8
fix: unit test dependent resource
csviri bf71615
fix: format
csviri 2dbdbf3
Merge branch 'next' into dr-up-to-date-get-resource
csviri 9d31856
Merge branch 'next' into dr-up-to-date-get-resource
csviri ec2a72c
feature: Handling just updated resources in informers and related log…
csviri 6e3c5ed
fix: remove feature flag for informer event filter
csviri b4286bf
fix: unit and integration tests
csviri 49f008c
fix: logging
csviri 26e14d5
fix: loggings
csviri e6a0aa8
fix: test condition
csviri 73afe1e
fix: bulletproof resource version filter
csviri a39dc1c
fix: recording wip
csviri b2910a3
fix: algorithm for event syncing
csviri c176c7f
docs: explanation
csviri 3d13950
fix: format
csviri 87c6b20
fix: dependent resource integration
csviri 980a4c1
Merge branch 'next' into temporal-resource-cache-in-eventsource
csviri 30d8cd8
fix: build fix merged next
csviri 56bbe97
fix: dependent support resource update
csviri 253c805
fix: integration test
csviri abc15f4
docs: wip
csviri 1fade82
Update operator-framework-core/src/main/java/io/javaoperatorsdk/opera…
csviri 2c6e1be
fix: format, some fixes from review
csviri a65d24e
fix: fixes for CR
csviri 51e6494
fix: naming and unit tests
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,5 +32,4 @@ | |
* @return the label selector | ||
*/ | ||
String labelSelector() default EMPTY_STRING; | ||
|
||
} |
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
65 changes: 65 additions & 0 deletions
65
...c/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/EventBuffer.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,65 @@ | ||
package io.javaoperatorsdk.operator.processing.event.source.informer; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.processing.event.ResourceID; | ||
|
||
public class EventBuffer<R extends HasMetadata> { | ||
|
||
private final Map<ResourceID, ArrayList<R>> resourceEvents = new ConcurrentHashMap<>(); | ||
|
||
void startEventRecording(ResourceID resourceID) { | ||
resourceEvents.putIfAbsent(resourceID, new ArrayList<>()); | ||
} | ||
|
||
public boolean isEventsRecordedFor(ResourceID resourceID) { | ||
return resourceEvents.get(resourceID) != null; | ||
} | ||
|
||
public void stopEventRecording(ResourceID resourceID) { | ||
resourceEvents.remove(resourceID); | ||
} | ||
|
||
public void eventReceived(R resource) { | ||
resourceEvents.get(ResourceID.fromResource(resource)).add(resource); | ||
} | ||
|
||
public boolean containsEventsFor(ResourceID resourceID) { | ||
csviri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return !resourceEvents.get(resourceID).isEmpty(); | ||
} | ||
|
||
public boolean containsEventWithResourceVersion(ResourceID resourceID, String resourceVersion) { | ||
List<R> events = resourceEvents.get(resourceID); | ||
if (events == null) { | ||
return false; | ||
} | ||
if (events.isEmpty()) { | ||
return false; | ||
} else { | ||
return events.stream() | ||
.anyMatch(e -> e.getMetadata().getResourceVersion().equals(resourceVersion)); | ||
} | ||
} | ||
|
||
public boolean containsEventWithVersionButItsNotLastOne( | ||
ResourceID resourceID, String resourceVersion) { | ||
List<R> resources = resourceEvents.get(resourceID); | ||
if (resources.isEmpty()) { | ||
csviri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
throw new IllegalStateException("No events for resource id: " + resourceID); | ||
} | ||
return !resources | ||
.get(resources.size() - 1) | ||
csviri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.getMetadata() | ||
.getResourceVersion() | ||
.equals(resourceVersion); | ||
} | ||
|
||
public R getLastEvent(ResourceID resourceID) { | ||
List<R> resources = resourceEvents.get(resourceID); | ||
return resources.get(resources.size() - 1); | ||
csviri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
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.