-
Notifications
You must be signed in to change notification settings - Fork 100
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
SNOW-1061848: Introduce TopicPartitionChannel interface #851
SNOW-1061848: Introduce TopicPartitionChannel interface #851
Conversation
7a1b7e4
to
548854e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally OK for me. I think that the ExposingInternalsTopicPartition interface should be either directly implemented on a particular TopicPartitionChannel implementation or available only in tests
import dev.failsafe.Fallback; | ||
import net.snowflake.ingest.streaming.SnowflakeStreamingIngestChannel; | ||
|
||
public interface ExposingInternalsTopicPartitionChannel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid confusion, the intention was to create this interface as a midstep before investing time in further refactoring. These methods existed already in the previous implementation and were freely accessible by other classes (used to have protected
modifier).
In the future, I'd like to get rid of the interface but for now, I'd like to focus on discussing whether having a single interface TopicPartitionChannel
with 2 implementations (buffered and non-buffered) is the way to go.
The idea is to quickly create a space for a new implementation - DirectTopicPartitionChannel
and implement it.
Additional refactoring will be done afterward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to imagine how I would approach this problem and I was thinking about:
- Creating a builder for this class to have only one constructo
- Creating an abstract class instead of interface. Abstract class would contain
channel
and all methods that are not related to buffering (like getOffsetSafeToCommitToKafka, closeChannel, isChannelClose, getChannelNameFormat).
But I am also ok with the interface-based approach.
Thanks, let me rethink this approach. The interface can be easily replaced with an abstract class, so I'll merge it as it is now. In one of the next iterations it can be considered for replace. |
@VisibleForTesting | ||
protected long getOffsetPersistedInSnowflake() { | ||
public long getOffsetPersistedInSnowflake() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need to change visibility of these methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i saw the other interface few lines down..
public class DirectTopicPartitionChannel implements TopicPartitionChannel { | ||
@Override | ||
public long getOffsetPersistedInSnowflake() { | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this probably doesn't hurt, as it isn't used anywhere, but i tent do throw UnsupportedOperationException for such initial stub methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me leave it as it is now, it will be replaced in the next iterations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. solid baseline for further work. i like the name refactor.
548854e
to
70ee895
Compare
Overview
SNOW-1061848
We want to remove double buffering from the project completely, which is quite a significant change, so we need to temporarily support running with and without the additional buffer.
This PR is a first attempt to extract an interface that both approaches (with and without buffer) will implement so we can easily switch between them.
Pre-review checklist
snowflake.ingestion.method
.Yes
- Added end to end and Unit Tests.No
- Suggest why it is not param protected