-
Notifications
You must be signed in to change notification settings - Fork 5
add wiring for creating checkpoints of responsive kv stores #458
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Submodule rs3
updated
from fb2d8f to 125749
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
114 changes: 114 additions & 0 deletions
114
kafka-client/src/main/java/dev/responsive/kafka/internal/db/rs3/TableCheckpoint.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,114 @@ | ||
| package dev.responsive.kafka.internal.db.rs3; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; | ||
| import dev.responsive.kafka.internal.db.rs3.client.PssCheckpoint; | ||
| import java.io.IOException; | ||
| import java.nio.charset.Charset; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.Optional; | ||
|
|
||
| public class TableCheckpoint { | ||
| private static final ObjectMapper MAPPER = new ObjectMapper(); | ||
|
|
||
| static { | ||
| MAPPER.registerModule(new Jdk8Module()); | ||
| } | ||
|
|
||
| final List<TablePssCheckpoint> pssCheckpoints; | ||
|
|
||
| @JsonCreator | ||
| public TableCheckpoint( | ||
| @JsonProperty("pssCheckpoints") final List<TablePssCheckpoint> pssCheckpoints | ||
| ) { | ||
| this.pssCheckpoints = List.copyOf(Objects.requireNonNull(pssCheckpoints)); | ||
| } | ||
|
|
||
| @JsonProperty("pssCheckpoints") | ||
| public List<TablePssCheckpoint> pssCheckpoints() { | ||
| return pssCheckpoints; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(final Object o) { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (!(o instanceof TableCheckpoint)) { | ||
| return false; | ||
| } | ||
| final TableCheckpoint that = (TableCheckpoint) o; | ||
| return Objects.equals(pssCheckpoints, that.pssCheckpoints); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hashCode(pssCheckpoints); | ||
| } | ||
|
|
||
| public static class TablePssCheckpoint { | ||
| final Optional<Long> writtenOffset; | ||
| final PssCheckpoint checkpoint; | ||
|
|
||
| @JsonCreator | ||
| public TablePssCheckpoint( | ||
| @JsonProperty("writtenOffset") final Optional<Long> writtenOffset, | ||
| @JsonProperty("checkpoint") final PssCheckpoint checkpoint | ||
| ) { | ||
| this.writtenOffset = Objects.requireNonNull(writtenOffset); | ||
| this.checkpoint = Objects.requireNonNull(checkpoint); | ||
| } | ||
|
|
||
| @JsonProperty("writtenOffset") | ||
| public Optional<Long> writtenOffset() { | ||
| return writtenOffset; | ||
| } | ||
|
|
||
| @JsonProperty("checkpoint") | ||
| public PssCheckpoint checkpoint() { | ||
| return checkpoint; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(final Object o) { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (!(o instanceof TablePssCheckpoint)) { | ||
| return false; | ||
| } | ||
| final TablePssCheckpoint that = (TablePssCheckpoint) o; | ||
| return Objects.equals(writtenOffset, that.writtenOffset) | ||
| && Objects.equals(checkpoint, that.checkpoint); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(writtenOffset, checkpoint); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return new String(TableCheckpoint.serialize(this), Charset.defaultCharset()); | ||
| } | ||
|
|
||
| public static byte[] serialize(TableCheckpoint tableCheckpoint) { | ||
| try { | ||
| return MAPPER.writeValueAsBytes(tableCheckpoint); | ||
| } catch (final IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
|
|
||
| public static TableCheckpoint deserialize(byte[] serialized) { | ||
| try { | ||
| return MAPPER.readValue(serialized, TableCheckpoint.class); | ||
| } catch (final IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
| } | ||
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
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.