Skip to content
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

Merged

Conversation

sfc-gh-akowalczyk
Copy link
Contributor

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

  • This change should be part of a Behavior Change Release. See go/behavior-change.
  • This change has passed Merge gate tests
  • Snowpipe Changes
  • Snowpipe Streaming Changes
  • This change is TEST-ONLY
  • This change is README/Javadocs only
  • This change is protected by a config parameter <PARAMETER_NAME> eg snowflake.ingestion.method.
    • Yes - Added end to end and Unit Tests.
    • No - Suggest why it is not param protected
  • Is his change protected by parameter <PARAMETER_NAME> on the server side?
    • The parameter/feature is not yet active in production (partial rollout or PrPr, see Changes for Unreleased Features and Fixes).
    • If there is an issue, it can be safely mitigated by turning the parameter off. This is also verified by a test (See go/ppp).

@sfc-gh-akowalczyk sfc-gh-akowalczyk requested a review from a team as a code owner May 23, 2024 12:04
@sfc-gh-akowalczyk sfc-gh-akowalczyk force-pushed the akowalczyk/snow-1061848-remove-double-buffer branch from 7a1b7e4 to 548854e Compare May 23, 2024 12:05
Copy link
Contributor

@sfc-gh-dseweryn sfc-gh-dseweryn left a 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 {
Copy link
Contributor Author

@sfc-gh-akowalczyk sfc-gh-akowalczyk May 23, 2024

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.

Copy link
Contributor

@sfc-gh-mbobowski sfc-gh-mbobowski left a 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:

  1. Creating a builder for this class to have only one constructo
  2. 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.

@sfc-gh-akowalczyk
Copy link
Contributor Author

sfc-gh-akowalczyk commented May 23, 2024

I tried to imagine how I would approach this problem and I was thinking about:

  1. Creating a builder for this class to have only one constructo
  2. 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() {
Copy link
Contributor

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?

Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

@sfc-gh-gjachimko sfc-gh-gjachimko left a 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.

@sfc-gh-akowalczyk sfc-gh-akowalczyk force-pushed the akowalczyk/snow-1061848-remove-double-buffer branch from 548854e to 70ee895 Compare May 27, 2024 09:46
@sfc-gh-akowalczyk sfc-gh-akowalczyk merged commit 15df711 into master May 27, 2024
77 of 81 checks passed
@sfc-gh-akowalczyk sfc-gh-akowalczyk deleted the akowalczyk/snow-1061848-remove-double-buffer branch May 27, 2024 10:58
ConfluentSemaphore pushed a commit to confluentinc/snowflake-kafka-connector that referenced this pull request Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants