Skip to content

[Issue 10445][pulsar-io] Exposed SubscriptionType in the SinkContext - #10446

Merged
sijie merged 3 commits into
apache:masterfrom
dlg99:context_subscription
May 8, 2021
Merged

[Issue 10445][pulsar-io] Exposed SubscriptionType in the SinkContext#10446
sijie merged 3 commits into
apache:masterfrom
dlg99:context_subscription

Conversation

@dlg99

@dlg99 dlg99 commented Apr 29, 2021

Copy link
Copy Markdown
Contributor

Fixes #10445

Motivation

SinkContext should expose Subscription type to the Sink
More context: #9927 (comment)

Needed for #9927

Modifications

Added getSubscriptionType() to the SinkContext interface and ContextImpl

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing unit tests

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • The public API: yes

New method added to the interface that is a public API. Default method implementation is provided.

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? JavaDocs

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall is good.

I would also add a (unit, non integration) test in order to ensure that the Sink receives the value.

Comment thread pulsar-io/core/src/main/java/org/apache/pulsar/io/core/ConnectorContext.java Outdated
Comment thread pulsar-io/core/src/main/java/org/apache/pulsar/io/core/ConnectorContext.java Outdated
@dlg99
dlg99 requested a review from eolivelli April 30, 2021 17:45

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@dlg99
dlg99 force-pushed the context_subscription branch from 6a422d5 to 1fd766d Compare May 3, 2021 15:38
@dlg99

dlg99 commented May 3, 2021

Copy link
Copy Markdown
Contributor Author

rebased on current master

@dlg99 dlg99 changed the title [Issue 10445][pulsar-io] Exposed SubscriptionType in the ConnectorContext [Issue 10445][pulsar-io] Exposed SubscriptionType in the SinkContext May 3, 2021

@sijie sijie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before merging this pull request, we should get stakeholders like @jerrypeng and @srkukarni to confirm if this API works for them.

Comment thread pulsar-io/core/src/main/java/org/apache/pulsar/io/core/SinkContext.java Outdated
@dlg99
dlg99 requested a review from sijie May 4, 2021 02:42
@dlg99

dlg99 commented May 4, 2021

Copy link
Copy Markdown
Contributor Author

@jerrypeng @srkukarni Do you have any feedback on this? (I cannot add you to reviewers, no permissions)

@eolivelli
eolivelli requested review from jerrypeng and srkukarni May 5, 2021 08:07
@eolivelli

Copy link
Copy Markdown
Contributor

@jerrypeng @srkukarni ping.
this patch is blocking another bigger work.
can you please take a quick look ?

@jerrypeng

jerrypeng commented May 7, 2021

Copy link
Copy Markdown
Contributor

I don't see any red flags in this PR but I also don't understand adding this functionality will be useful.

@dlg99 based the comments

#9927 (comment)

It seem like the subscription type should be checked at submission time and be rejected if a wrong subscription type is used.

If we are checking the subscription type during the sink open, what are we going to do if the subscription type is wrong? Just go into a crash loop?

@dlg99

dlg99 commented May 7, 2021

Copy link
Copy Markdown
Contributor Author

If we are checking the subscription type during the sink open, what are we going to do if the subscription type is wrong? Just go into a crash loop?

@jerrypeng This is not different from what's happening in other connectors now. I agree we can consider adding something to handle it better, but this is out of the scope of this PR.

if (kafkaSinkConfig.getBatchSize() <= 0) {
throw new IllegalArgumentException("Invalid Kafka Producer batchSize : "
+ kafkaSinkConfig.getBatchSize());
}
if (kafkaSinkConfig.getMaxRequestSize() <= 0) {
throw new IllegalArgumentException("Invalid Kafka Producer maxRequestSize : "
+ kafkaSinkConfig.getMaxRequestSize());
}

checkArgument(isNotBlank(kinesisSinkConfig.getAwsKinesisStreamName()), "empty kinesis-stream name");
checkArgument(isNotBlank(kinesisSinkConfig.getAwsEndpoint()) ||
isNotBlank(kinesisSinkConfig.getAwsRegion()),
"Either the aws-end-point or aws-region must be set");
checkArgument(isNotBlank(kinesisSinkConfig.getAwsCredentialPluginParam()), "empty aws-credential param");

etc

@jerrypeng

Copy link
Copy Markdown
Contributor

I am not a fan of adding new interfaces to support a not well thought out behavior that might be changed in the future but I don't see a major problem with this as well.

@eolivelli

Copy link
Copy Markdown
Contributor

Thank you @jerrypeng

@sijie you left "request changes" status.
Do you agree to merge this patch ?

@sijie sijie added this to the 2.8.0 milestone May 8, 2021
@sijie
sijie merged commit b5fd8ef into apache:master May 8, 2021
eolivelli pushed a commit to eolivelli/pulsar that referenced this pull request May 11, 2021
…pache#10446)

Fixes apache#10445

### Motivation

SinkContext should expose Subscription type to the Sink
More context: apache#9927 (comment)

Needed for apache#9927

### Modifications

Added `getSubscriptionType()` to the `SinkContext` interface and `ContextImpl`
@dlg99
dlg99 deleted the context_subscription branch October 14, 2021 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SinkContext should expose Subscription type to the Sink

4 participants