001/* 002 * Copyright (c) 2007-2022 The Cascading Authors. All Rights Reserved. 003 * 004 * Project and contact information: https://cascading.wensel.net/ 005 * 006 * This file is part of the Cascading project. 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020 021package cascading.local.tap.kafka; 022 023import java.net.URI; 024import java.util.Properties; 025 026import cascading.local.tap.kafka.commit.CommittingConsumer; 027import org.apache.kafka.clients.consumer.Consumer; 028 029/** 030 * Class KafkaCommittingTap commits consumer record offsets on completion of successful or failed flows, and revoked 031 * partitions from a rebalance. 032 * <p> 033 * if the flow failed, the failed record will be the next record to read on that given partition. 034 * 035 * @param <K> the type parameter 036 * @param <V> the type parameter 037 */ 038public class KafkaCommittingTap<K, V> extends KafkaTap<K, V> 039 { 040 /** 041 * Instantiates a new Committing kafka tap. 042 * 043 * @param defaultProperties the default properties 044 * @param scheme the scheme 045 * @param identifier the identifier 046 */ 047 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, URI identifier ) 048 { 049 super( defaultProperties, scheme, identifier ); 050 } 051 052 /** 053 * Instantiates a new Committing kafka tap. 054 * 055 * @param scheme the scheme 056 * @param identifier the identifier 057 * @param pollTimeout the poll timeout 058 */ 059 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, URI identifier, long pollTimeout ) 060 { 061 super( scheme, identifier, pollTimeout ); 062 } 063 064 /** 065 * Instantiates a new Committing kafka tap. 066 * 067 * @param scheme the scheme 068 * @param identifier the identifier 069 * @param numPartitions the num partitions 070 * @param replicationFactor the replication factor 071 */ 072 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, URI identifier, int numPartitions, short replicationFactor ) 073 { 074 super( scheme, identifier, numPartitions, replicationFactor ); 075 } 076 077 /** 078 * Instantiates a new Committing kafka tap. 079 * 080 * @param scheme the scheme 081 * @param identifier the identifier 082 * @param pollTimeout the poll timeout 083 * @param numPartitions the num partitions 084 * @param replicationFactor the replication factor 085 */ 086 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, URI identifier, long pollTimeout, int numPartitions, short replicationFactor ) 087 { 088 super( scheme, identifier, pollTimeout, numPartitions, replicationFactor ); 089 } 090 091 /** 092 * Instantiates a new Committing kafka tap. 093 * 094 * @param scheme the scheme 095 * @param identifier the identifier 096 */ 097 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, URI identifier ) 098 { 099 super( scheme, identifier ); 100 } 101 102 /** 103 * Instantiates a new Committing kafka tap. 104 * 105 * @param defaultProperties the default properties 106 * @param scheme the scheme 107 * @param identifier the identifier 108 * @param pollTimeout the poll timeout 109 */ 110 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, URI identifier, long pollTimeout ) 111 { 112 super( defaultProperties, scheme, identifier, pollTimeout ); 113 } 114 115 /** 116 * Instantiates a new Committing kafka tap. 117 * 118 * @param defaultProperties the default properties 119 * @param scheme the scheme 120 * @param identifier the identifier 121 * @param numPartitions the num partitions 122 * @param replicationFactor the replication factor 123 */ 124 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, URI identifier, int numPartitions, short replicationFactor ) 125 { 126 super( defaultProperties, scheme, identifier, numPartitions, replicationFactor ); 127 } 128 129 /** 130 * Instantiates a new Committing kafka tap. 131 * 132 * @param defaultProperties the default properties 133 * @param scheme the scheme 134 * @param identifier the identifier 135 * @param pollTimeout the poll timeout 136 * @param numPartitions the num partitions 137 * @param replicationFactor the replication factor 138 */ 139 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, URI identifier, long pollTimeout, int numPartitions, short replicationFactor ) 140 { 141 super( defaultProperties, scheme, identifier, pollTimeout, numPartitions, replicationFactor ); 142 } 143 144 /** 145 * Instantiates a new Committing kafka tap. 146 * 147 * @param defaultProperties the default properties 148 * @param scheme the scheme 149 * @param identifier the identifier 150 * @param clientID the client id 151 */ 152 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID ) 153 { 154 super( defaultProperties, scheme, identifier, clientID ); 155 } 156 157 /** 158 * Instantiates a new Committing kafka tap. 159 * 160 * @param defaultProperties the default properties 161 * @param scheme the scheme 162 * @param identifier the identifier 163 * @param clientID the client id 164 * @param groupID the group id 165 */ 166 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID, String groupID ) 167 { 168 super( defaultProperties, scheme, identifier, clientID, groupID ); 169 } 170 171 /** 172 * Instantiates a new Committing kafka tap. 173 * 174 * @param scheme the scheme 175 * @param identifier the identifier 176 * @param clientID the client id 177 * @param pollTimeout the poll timeout 178 */ 179 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID, long pollTimeout ) 180 { 181 super( scheme, identifier, clientID, pollTimeout ); 182 } 183 184 /** 185 * Instantiates a new Committing kafka tap. 186 * 187 * @param scheme the scheme 188 * @param identifier the identifier 189 * @param clientID the client id 190 * @param numPartitions the num partitions 191 * @param replicationFactor the replication factor 192 */ 193 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID, int numPartitions, short replicationFactor ) 194 { 195 super( scheme, identifier, clientID, numPartitions, replicationFactor ); 196 } 197 198 /** 199 * Instantiates a new Committing kafka tap. 200 * 201 * @param scheme the scheme 202 * @param identifier the identifier 203 * @param clientID the client id 204 * @param pollTimeout the poll timeout 205 * @param numPartitions the num partitions 206 * @param replicationFactor the replication factor 207 */ 208 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID, long pollTimeout, int numPartitions, short replicationFactor ) 209 { 210 super( scheme, identifier, clientID, pollTimeout, numPartitions, replicationFactor ); 211 } 212 213 /** 214 * Instantiates a new Committing kafka tap. 215 * 216 * @param scheme the scheme 217 * @param identifier the identifier 218 * @param clientID the client id 219 */ 220 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID ) 221 { 222 super( scheme, identifier, clientID ); 223 } 224 225 /** 226 * Instantiates a new Committing kafka tap. 227 * 228 * @param scheme the scheme 229 * @param identifier the identifier 230 * @param clientID the client id 231 * @param groupID the group id 232 */ 233 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID, String groupID ) 234 { 235 super( scheme, identifier, clientID, groupID ); 236 } 237 238 /** 239 * Instantiates a new Committing kafka tap. 240 * 241 * @param defaultProperties the default properties 242 * @param scheme the scheme 243 * @param identifier the identifier 244 * @param clientID the client id 245 * @param pollTimeout the poll timeout 246 */ 247 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID, long pollTimeout ) 248 { 249 super( defaultProperties, scheme, identifier, clientID, pollTimeout ); 250 } 251 252 /** 253 * Instantiates a new Committing kafka tap. 254 * 255 * @param defaultProperties the default properties 256 * @param scheme the scheme 257 * @param identifier the identifier 258 * @param clientID the client id 259 * @param numPartitions the num partitions 260 * @param replicationFactor the replication factor 261 */ 262 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID, int numPartitions, short replicationFactor ) 263 { 264 super( defaultProperties, scheme, identifier, clientID, numPartitions, replicationFactor ); 265 } 266 267 /** 268 * Instantiates a new Committing kafka tap. 269 * 270 * @param defaultProperties the default properties 271 * @param scheme the scheme 272 * @param identifier the identifier 273 * @param clientID the client id 274 * @param pollTimeout the poll timeout 275 * @param numPartitions the num partitions 276 * @param replicationFactor the replication factor 277 */ 278 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID, long pollTimeout, int numPartitions, short replicationFactor ) 279 { 280 super( defaultProperties, scheme, identifier, clientID, pollTimeout, numPartitions, replicationFactor ); 281 } 282 283 /** 284 * Instantiates a new Committing kafka tap. 285 * 286 * @param defaultProperties the default properties 287 * @param scheme the scheme 288 * @param identifier the identifier 289 * @param clientID the client id 290 * @param groupID the group id 291 * @param pollTimeout the poll timeout 292 * @param numPartitions the num partitions 293 * @param replicationFactor the replication factor 294 */ 295 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, URI identifier, String clientID, String groupID, long pollTimeout, int numPartitions, short replicationFactor ) 296 { 297 super( defaultProperties, scheme, identifier, clientID, groupID, pollTimeout, numPartitions, replicationFactor ); 298 } 299 300 /** 301 * Instantiates a new Committing kafka tap. 302 * 303 * @param scheme the scheme 304 * @param hostname the hostname 305 * @param pollTimeout the poll timeout 306 * @param topics the topics 307 */ 308 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, String hostname, long pollTimeout, String... topics ) 309 { 310 super( scheme, hostname, pollTimeout, topics ); 311 } 312 313 /** 314 * Instantiates a new Committing kafka tap. 315 * 316 * @param scheme the scheme 317 * @param hostname the hostname 318 * @param pollTimeout the poll timeout 319 * @param numPartitions the num partitions 320 * @param replicationFactor the replication factor 321 * @param topics the topics 322 */ 323 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, String hostname, long pollTimeout, int numPartitions, short replicationFactor, String... topics ) 324 { 325 super( scheme, hostname, pollTimeout, numPartitions, replicationFactor, topics ); 326 } 327 328 /** 329 * Instantiates a new Committing kafka tap. 330 * 331 * @param defaultProperties the default properties 332 * @param scheme the scheme 333 * @param hostname the hostname 334 * @param numPartitions the num partitions 335 * @param replicationFactor the replication factor 336 * @param topics the topics 337 */ 338 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, String hostname, int numPartitions, short replicationFactor, String... topics ) 339 { 340 super( defaultProperties, scheme, hostname, numPartitions, replicationFactor, topics ); 341 } 342 343 /** 344 * Instantiates a new Committing kafka tap. 345 * 346 * @param defaultProperties the default properties 347 * @param scheme the scheme 348 * @param hostname the hostname 349 * @param topics the topics 350 */ 351 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, String hostname, String... topics ) 352 { 353 super( defaultProperties, scheme, hostname, topics ); 354 } 355 356 /** 357 * Instantiates a new Committing kafka tap. 358 * 359 * @param defaultProperties the default properties 360 * @param scheme the scheme 361 * @param hostname the hostname 362 * @param pollTimeout the poll timeout 363 * @param topics the topics 364 */ 365 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, String hostname, long pollTimeout, String... topics ) 366 { 367 super( defaultProperties, scheme, hostname, pollTimeout, topics ); 368 } 369 370 /** 371 * Instantiates a new Committing kafka tap. 372 * 373 * @param defaultProperties the default properties 374 * @param scheme the scheme 375 * @param hostname the hostname 376 * @param pollTimeout the poll timeout 377 * @param numPartitions the num partitions 378 * @param replicationFactor the replication factor 379 * @param topics the topics 380 */ 381 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, String hostname, long pollTimeout, int numPartitions, short replicationFactor, String... topics ) 382 { 383 super( defaultProperties, scheme, hostname, pollTimeout, numPartitions, replicationFactor, topics ); 384 } 385 386 /** 387 * Instantiates a new Committing kafka tap. 388 * 389 * @param scheme the scheme 390 * @param hostname the hostname 391 * @param clientID the client id 392 * @param topics the topics 393 */ 394 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, String hostname, String clientID, String... topics ) 395 { 396 super( scheme, hostname, clientID, topics ); 397 } 398 399 /** 400 * Instantiates a new Committing kafka tap. 401 * 402 * @param scheme the scheme 403 * @param hostname the hostname 404 * @param clientID the client id 405 * @param pollTimeout the poll timeout 406 * @param topics the topics 407 */ 408 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, String hostname, String clientID, long pollTimeout, String... topics ) 409 { 410 super( scheme, hostname, clientID, pollTimeout, topics ); 411 } 412 413 /** 414 * Instantiates a new Committing kafka tap. 415 * 416 * @param scheme the scheme 417 * @param hostname the hostname 418 * @param clientID the client id 419 * @param pollTimeout the poll timeout 420 * @param numPartitions the num partitions 421 * @param replicationFactor the replication factor 422 * @param topics the topics 423 */ 424 public KafkaCommittingTap( KafkaScheme<K, V, ?, ?> scheme, String hostname, String clientID, long pollTimeout, int numPartitions, short replicationFactor, String... topics ) 425 { 426 super( scheme, hostname, clientID, pollTimeout, numPartitions, replicationFactor, topics ); 427 } 428 429 /** 430 * Instantiates a new Committing kafka tap. 431 * 432 * @param defaultProperties the default properties 433 * @param scheme the scheme 434 * @param hostname the hostname 435 * @param clientID the client id 436 * @param numPartitions the num partitions 437 * @param replicationFactor the replication factor 438 * @param topics the topics 439 */ 440 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, String hostname, String clientID, int numPartitions, short replicationFactor, String... topics ) 441 { 442 super( defaultProperties, scheme, hostname, clientID, numPartitions, replicationFactor, topics ); 443 } 444 445 /** 446 * Instantiates a new Committing kafka tap. 447 * 448 * @param defaultProperties the default properties 449 * @param scheme the scheme 450 * @param hostname the hostname 451 * @param clientID the client id 452 * @param topics the topics 453 */ 454 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, String hostname, String clientID, String... topics ) 455 { 456 super( defaultProperties, scheme, hostname, clientID, topics ); 457 } 458 459 /** 460 * Instantiates a new Committing kafka tap. 461 * 462 * @param defaultProperties the default properties 463 * @param scheme the scheme 464 * @param hostname the hostname 465 * @param clientID the client id 466 * @param pollTimeout the poll timeout 467 * @param topics the topics 468 */ 469 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, String hostname, String clientID, long pollTimeout, String... topics ) 470 { 471 super( defaultProperties, scheme, hostname, clientID, pollTimeout, topics ); 472 } 473 474 /** 475 * Instantiates a new Committing kafka tap. 476 * 477 * @param defaultProperties the default properties 478 * @param scheme the scheme 479 * @param hostname the hostname 480 * @param clientID the client id 481 * @param pollTimeout the poll timeout 482 * @param numPartitions the num partitions 483 * @param replicationFactor the replication factor 484 * @param topics the topics 485 */ 486 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, String hostname, String clientID, long pollTimeout, int numPartitions, short replicationFactor, String... topics ) 487 { 488 super( defaultProperties, scheme, hostname, clientID, pollTimeout, numPartitions, replicationFactor, topics ); 489 } 490 491 /** 492 * Instantiates a new Committing kafka tap. 493 * 494 * @param defaultProperties the default properties 495 * @param scheme the scheme 496 * @param hostname the hostname 497 * @param clientID the client id 498 * @param groupID the group id 499 * @param pollTimeout the poll timeout 500 * @param numPartitions the num partitions 501 * @param replicationFactor the replication factor 502 * @param topics the topics 503 */ 504 public KafkaCommittingTap( Properties defaultProperties, KafkaScheme<K, V, ?, ?> scheme, String hostname, String clientID, String groupID, long pollTimeout, int numPartitions, short replicationFactor, String... topics ) 505 { 506 super( defaultProperties, scheme, hostname, clientID, groupID, pollTimeout, numPartitions, replicationFactor, topics ); 507 } 508 509 @Override 510 protected Consumer<K, V> createKafkaConsumer( Properties properties ) 511 { 512 return new CommittingConsumer<>( properties ); 513 } 514 }