|
15 | 15 | */ |
16 | 16 | package com.google.pubsub.kafka.source; |
17 | 17 |
|
18 | | -import com.google.api.gax.core.CredentialsProvider; |
19 | | -import com.google.cloud.pubsub.v1.stub.GrpcSubscriberStub; |
20 | | -import com.google.cloud.pubsub.v1.stub.SubscriberStubSettings; |
21 | | -import com.google.common.annotations.VisibleForTesting; |
22 | | -import com.google.pubsub.kafka.common.ConnectorCredentialsProvider; |
23 | 18 | import com.google.pubsub.kafka.common.ConnectorUtils; |
24 | 19 | import com.google.pubsub.kafka.common.Version; |
25 | | -import com.google.pubsub.v1.GetSubscriptionRequest; |
26 | 20 | import java.util.ArrayList; |
27 | 21 | import java.util.Arrays; |
28 | 22 | import java.util.HashMap; |
|
33 | 27 | import org.apache.kafka.common.config.ConfigDef.Type; |
34 | 28 | import org.apache.kafka.common.config.ConfigException; |
35 | 29 | import org.apache.kafka.connect.connector.Task; |
36 | | -import org.apache.kafka.connect.errors.ConnectException; |
37 | 30 | import org.apache.kafka.connect.source.SourceConnector; |
38 | 31 | import org.slf4j.Logger; |
39 | 32 | import org.slf4j.LoggerFactory; |
@@ -135,15 +128,6 @@ public String version() { |
135 | 128 |
|
136 | 129 | @Override |
137 | 130 | public void start(Map<String, String> props) { |
138 | | - // Do a validation of configs here too so that we do not pass null objects to |
139 | | - // verifySubscription(). |
140 | | - Map<String, Object> validated = config().parse(props); |
141 | | - String cpsProject = validated.get(ConnectorUtils.CPS_PROJECT_CONFIG).toString(); |
142 | | - String cpsSubscription = validated.get(CPS_SUBSCRIPTION_CONFIG).toString(); |
143 | | - ConnectorCredentialsProvider credentialsProvider = |
144 | | - ConnectorCredentialsProvider.fromConfig(validated); |
145 | | - |
146 | | - verifySubscription(cpsProject, cpsSubscription, credentialsProvider); |
147 | 131 | this.props = props; |
148 | 132 | log.info("Started the CloudPubSubSourceConnector"); |
149 | 133 | } |
@@ -286,36 +270,6 @@ public ConfigDef config() { |
286 | 270 | "The Pub/Sub endpoint to use."); |
287 | 271 | } |
288 | 272 |
|
289 | | - /** |
290 | | - * Check whether the user provided Cloud Pub/Sub subscription name specified by {@link |
291 | | - * #CPS_SUBSCRIPTION_CONFIG} exists or not. |
292 | | - */ |
293 | | - @VisibleForTesting |
294 | | - public void verifySubscription( |
295 | | - String cpsProject, String cpsSubscription, CredentialsProvider credentialsProvider) { |
296 | | - try { |
297 | | - SubscriberStubSettings subscriberStubSettings = |
298 | | - SubscriberStubSettings.newBuilder() |
299 | | - .setTransportChannelProvider( |
300 | | - SubscriberStubSettings.defaultGrpcTransportProviderBuilder() |
301 | | - .setMaxInboundMessageSize(20 << 20) // 20MB |
302 | | - .build()) |
303 | | - .setCredentialsProvider(credentialsProvider) |
304 | | - .build(); |
305 | | - GrpcSubscriberStub stub = GrpcSubscriberStub.create(subscriberStubSettings); |
306 | | - GetSubscriptionRequest request = |
307 | | - GetSubscriptionRequest.newBuilder() |
308 | | - .setSubscription( |
309 | | - String.format( |
310 | | - ConnectorUtils.CPS_SUBSCRIPTION_FORMAT, cpsProject, cpsSubscription)) |
311 | | - .build(); |
312 | | - stub.getSubscriptionCallable().call(request); |
313 | | - } catch (Exception e) { |
314 | | - throw new ConnectException( |
315 | | - "Error verifying the subscription " + cpsSubscription + " for project " + cpsProject, e); |
316 | | - } |
317 | | - } |
318 | | - |
319 | 273 | @Override |
320 | 274 | public void stop() {} |
321 | 275 | } |
0 commit comments