-
Notifications
You must be signed in to change notification settings - Fork 31
Added describeConsumer method to TopicClient #332
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 2 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
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 |
|---|---|---|
|
|
@@ -8,5 +8,5 @@ public enum Codec { | |
| GZIP, | ||
| LZOP, | ||
| ZSTD, | ||
| CUSTOM | ||
| CUSTOM; | ||
| } | ||
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
32 changes: 32 additions & 0 deletions
32
topic/src/main/java/tech/ydb/topic/description/ConsumerDescription.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,32 @@ | ||
| package tech.ydb.topic.description; | ||
|
|
||
|
|
||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import tech.ydb.proto.topic.YdbTopic; | ||
|
|
||
| /** | ||
| * | ||
| * @author Aleksandr Gorshenin | ||
| */ | ||
| public class ConsumerDescription { | ||
| private final Consumer consumer; | ||
| private final List<ConsumerPartitionInfo> partitions; | ||
|
|
||
| public ConsumerDescription(YdbTopic.DescribeConsumerResult result) { | ||
| this.consumer = new Consumer(result.getConsumer()); | ||
| this.partitions = result.getPartitionsList().stream() | ||
| .map(ConsumerPartitionInfo::new) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| public Consumer getConsumer() { | ||
| return consumer; | ||
| } | ||
|
|
||
| public List<ConsumerPartitionInfo> getPartitions() { | ||
| return partitions; | ||
| } | ||
|
|
||
| } |
181 changes: 181 additions & 0 deletions
181
topic/src/main/java/tech/ydb/topic/description/ConsumerPartitionInfo.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,181 @@ | ||
| package tech.ydb.topic.description; | ||
|
|
||
| import java.time.Duration; | ||
| import java.time.Instant; | ||
| import java.util.List; | ||
|
|
||
| import tech.ydb.core.utils.ProtobufUtils; | ||
| import tech.ydb.proto.topic.YdbTopic; | ||
|
|
||
| /** | ||
| * @author Nikolay Perfilov | ||
alex268 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
| public class ConsumerPartitionInfo { | ||
| private final long partitionId; | ||
| private final boolean active; | ||
| private final List<Long> childPartitionIds; | ||
| private final List<Long> parentPartitionIds; | ||
| private final PartitionStats partitionStats; | ||
| private final ConsumerStats consumerStats; | ||
| private final PartitionLocation location; | ||
|
|
||
| public ConsumerPartitionInfo(YdbTopic.DescribeConsumerResult.PartitionInfo result) { | ||
| this.partitionId = result.getPartitionId(); | ||
| this.active = result.getActive(); | ||
| this.childPartitionIds = result.getChildPartitionIdsList(); | ||
| this.parentPartitionIds = result.getParentPartitionIdsList(); | ||
| this.partitionStats = new PartitionStats(result.getPartitionStats()); | ||
| this.consumerStats = new ConsumerStats(result.getPartitionConsumerStats()); | ||
| this.location = new PartitionLocation(result.getPartitionLocation()); | ||
| } | ||
|
|
||
| /** | ||
| * @return Partition identifier. | ||
| */ | ||
| public long getPartitionId() { | ||
| return partitionId; | ||
| } | ||
|
|
||
| /** | ||
| * @return Is partition open for write. | ||
| */ | ||
| public boolean isActive() { | ||
| return active; | ||
| } | ||
|
|
||
| /** | ||
| * @return Ids of partitions which was formed when this partition was split or merged. | ||
| */ | ||
| public List<Long> getChildPartitionIds() { | ||
| return childPartitionIds; | ||
| } | ||
|
|
||
| /** | ||
| * @return Ids of partitions from which this partition was formed by split or merge. | ||
| */ | ||
| public List<Long> getParentPartitionIds() { | ||
| return parentPartitionIds; | ||
| } | ||
|
|
||
| /** | ||
| * @return Stats for partition, filled only when include_stats in request is true. | ||
| */ | ||
| public PartitionStats getPartitionStats() { | ||
| return partitionStats; | ||
| } | ||
|
|
||
| /** | ||
| * @return Stats for consumer of this partition, filled only when include_stats in request is true. | ||
| */ | ||
| public ConsumerStats getConsumerStats() { | ||
| return consumerStats; | ||
| } | ||
|
|
||
| /** | ||
| * @return Partition location, filled only when include_location in request is true. | ||
| */ | ||
| public PartitionLocation getPartitionLocation() { | ||
| return location; | ||
| } | ||
|
|
||
| public static class ConsumerStats { | ||
| private final long lastReadOffset; | ||
| private final long committedOffset; | ||
| private final String readSessionId; | ||
| private final Instant partitionReadSessionCreateTime; | ||
| private final Instant lastReadTime; | ||
| private final Duration maxReadTimeLag; | ||
| private final Duration maxWriteTimeLag; | ||
|
|
||
| private final MultipleWindowsStat bytesRead; | ||
| private final String readerName; | ||
| private final int connectionNodeId; | ||
|
|
||
| public ConsumerStats(YdbTopic.DescribeConsumerResult.PartitionConsumerStats stats) { | ||
| this.lastReadOffset = stats.getLastReadOffset(); | ||
| this.committedOffset = stats.getCommittedOffset(); | ||
| this.readSessionId = stats.getReadSessionId(); | ||
| this.partitionReadSessionCreateTime = ProtobufUtils.protoToInstant( | ||
| stats.getPartitionReadSessionCreateTime() | ||
| ); | ||
| this.lastReadTime = ProtobufUtils.protoToInstant(stats.getLastReadTime()); | ||
| this.maxReadTimeLag = ProtobufUtils.protoToDuration(stats.getMaxReadTimeLag()); | ||
| this.maxWriteTimeLag = ProtobufUtils.protoToDuration(stats.getMaxWriteTimeLag()); | ||
| this.bytesRead = new MultipleWindowsStat(stats.getBytesRead()); | ||
| this.readerName = stats.getReaderName(); | ||
| this.connectionNodeId = stats.getConnectionNodeId(); | ||
| } | ||
|
|
||
| /** | ||
| * @return Last read offset from this partition. | ||
| */ | ||
| public long getLastReadOffset() { | ||
| return lastReadOffset; | ||
| } | ||
|
|
||
| /** | ||
| * @return Committed offset for this partition. | ||
| */ | ||
| public long getCommittedOffset() { | ||
| return committedOffset; | ||
| } | ||
|
|
||
| /** | ||
| * @return Reading this partition read session identifier. | ||
| */ | ||
| public String getReadSessionId() { | ||
| return readSessionId; | ||
| } | ||
|
|
||
| /** | ||
| * @return Timestamp of providing this partition to this session by server. | ||
| */ | ||
| public Instant getPartitionReadSessionCreateTime() { | ||
| return partitionReadSessionCreateTime; | ||
| } | ||
|
|
||
| /** | ||
| * @return Timestamp of last read from this partition. | ||
| */ | ||
| public Instant getLastReadTime() { | ||
| return lastReadTime; | ||
| } | ||
|
|
||
| /** | ||
| * @return Maximum of differences between timestamp of read and write timestamp for all messages, read during last | ||
| * minute. | ||
| */ | ||
| public Duration getMaxReadTimeLag() { | ||
| return maxReadTimeLag; | ||
| } | ||
|
|
||
| /** | ||
| * @return Maximum of differences between write timestamp and create timestamp for all messages, read during last | ||
| * minute. | ||
| */ | ||
| public Duration getMaxWriteTimeLag() { | ||
| return maxWriteTimeLag; | ||
| } | ||
|
|
||
| /** | ||
| * @return How much bytes were read during several windows statistics from this partition. | ||
| */ | ||
| public MultipleWindowsStat getBytesRead() { | ||
| return bytesRead; | ||
| } | ||
|
|
||
| /** | ||
| * @return Read session name, provided by client. | ||
| */ | ||
| public String getReaderName() { | ||
| return readerName; | ||
| } | ||
|
|
||
| /** | ||
| * @return Host where read session connected. | ||
| */ | ||
| public int getConnectionNodeId() { | ||
| return connectionNodeId; | ||
| } | ||
| } | ||
| } | ||
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.