@point3/node-rdkafka 3.6.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +20 -0
- package/README.md +636 -0
- package/binding.gyp +154 -0
- package/deps/librdkafka/.clang-format +136 -0
- package/deps/librdkafka/.clang-format-cpp +103 -0
- package/deps/librdkafka/.dir-locals.el +10 -0
- package/deps/librdkafka/.formatignore +33 -0
- package/deps/librdkafka/.gdbmacros +19 -0
- package/deps/librdkafka/.github/CODEOWNERS +1 -0
- package/deps/librdkafka/.github/ISSUE_TEMPLATE +34 -0
- package/deps/librdkafka/.semaphore/run-all-tests.yml +77 -0
- package/deps/librdkafka/.semaphore/semaphore-integration.yml +250 -0
- package/deps/librdkafka/.semaphore/semaphore.yml +378 -0
- package/deps/librdkafka/.semaphore/verify-linux-packages.yml +41 -0
- package/deps/librdkafka/CHANGELOG.md +2208 -0
- package/deps/librdkafka/CMakeLists.txt +291 -0
- package/deps/librdkafka/CODE_OF_CONDUCT.md +46 -0
- package/deps/librdkafka/CONFIGURATION.md +209 -0
- package/deps/librdkafka/CONTRIBUTING.md +431 -0
- package/deps/librdkafka/Doxyfile +2375 -0
- package/deps/librdkafka/INTRODUCTION.md +2481 -0
- package/deps/librdkafka/LICENSE +26 -0
- package/deps/librdkafka/LICENSE.cjson +22 -0
- package/deps/librdkafka/LICENSE.crc32c +28 -0
- package/deps/librdkafka/LICENSE.fnv1a +18 -0
- package/deps/librdkafka/LICENSE.hdrhistogram +27 -0
- package/deps/librdkafka/LICENSE.lz4 +26 -0
- package/deps/librdkafka/LICENSE.murmur2 +25 -0
- package/deps/librdkafka/LICENSE.nanopb +22 -0
- package/deps/librdkafka/LICENSE.opentelemetry +203 -0
- package/deps/librdkafka/LICENSE.pycrc +23 -0
- package/deps/librdkafka/LICENSE.queue +31 -0
- package/deps/librdkafka/LICENSE.regexp +5 -0
- package/deps/librdkafka/LICENSE.snappy +36 -0
- package/deps/librdkafka/LICENSE.tinycthread +26 -0
- package/deps/librdkafka/LICENSE.wingetopt +49 -0
- package/deps/librdkafka/LICENSES.txt +625 -0
- package/deps/librdkafka/Makefile +125 -0
- package/deps/librdkafka/README.md +199 -0
- package/deps/librdkafka/README.win32 +26 -0
- package/deps/librdkafka/STATISTICS.md +624 -0
- package/deps/librdkafka/configure +214 -0
- package/deps/librdkafka/configure.self +331 -0
- package/deps/librdkafka/debian/changelog +111 -0
- package/deps/librdkafka/debian/compat +1 -0
- package/deps/librdkafka/debian/control +71 -0
- package/deps/librdkafka/debian/copyright +99 -0
- package/deps/librdkafka/debian/gbp.conf +9 -0
- package/deps/librdkafka/debian/librdkafka++1.install +1 -0
- package/deps/librdkafka/debian/librdkafka-dev.examples +2 -0
- package/deps/librdkafka/debian/librdkafka-dev.install +9 -0
- package/deps/librdkafka/debian/librdkafka1.docs +5 -0
- package/deps/librdkafka/debian/librdkafka1.install +1 -0
- package/deps/librdkafka/debian/librdkafka1.symbols +135 -0
- package/deps/librdkafka/debian/rules +19 -0
- package/deps/librdkafka/debian/source/format +1 -0
- package/deps/librdkafka/debian/watch +2 -0
- package/deps/librdkafka/dev-conf.sh +123 -0
- package/deps/librdkafka/examples/CMakeLists.txt +79 -0
- package/deps/librdkafka/examples/Makefile +167 -0
- package/deps/librdkafka/examples/README.md +42 -0
- package/deps/librdkafka/examples/alter_consumer_group_offsets.c +338 -0
- package/deps/librdkafka/examples/consumer.c +271 -0
- package/deps/librdkafka/examples/delete_records.c +233 -0
- package/deps/librdkafka/examples/describe_cluster.c +322 -0
- package/deps/librdkafka/examples/describe_consumer_groups.c +455 -0
- package/deps/librdkafka/examples/describe_topics.c +427 -0
- package/deps/librdkafka/examples/elect_leaders.c +317 -0
- package/deps/librdkafka/examples/globals.json +11 -0
- package/deps/librdkafka/examples/idempotent_producer.c +344 -0
- package/deps/librdkafka/examples/incremental_alter_configs.c +347 -0
- package/deps/librdkafka/examples/kafkatest_verifiable_client.cpp +945 -0
- package/deps/librdkafka/examples/list_consumer_group_offsets.c +359 -0
- package/deps/librdkafka/examples/list_consumer_groups.c +365 -0
- package/deps/librdkafka/examples/list_offsets.c +327 -0
- package/deps/librdkafka/examples/misc.c +287 -0
- package/deps/librdkafka/examples/openssl_engine_example.cpp +248 -0
- package/deps/librdkafka/examples/producer.c +251 -0
- package/deps/librdkafka/examples/producer.cpp +228 -0
- package/deps/librdkafka/examples/rdkafka_complex_consumer_example.c +617 -0
- package/deps/librdkafka/examples/rdkafka_complex_consumer_example.cpp +467 -0
- package/deps/librdkafka/examples/rdkafka_consume_batch.cpp +264 -0
- package/deps/librdkafka/examples/rdkafka_example.c +853 -0
- package/deps/librdkafka/examples/rdkafka_example.cpp +679 -0
- package/deps/librdkafka/examples/rdkafka_performance.c +1781 -0
- package/deps/librdkafka/examples/transactions-older-broker.c +668 -0
- package/deps/librdkafka/examples/transactions.c +665 -0
- package/deps/librdkafka/examples/user_scram.c +491 -0
- package/deps/librdkafka/examples/win_ssl_cert_store.cpp +396 -0
- package/deps/librdkafka/lds-gen.py +73 -0
- package/deps/librdkafka/mainpage.doxy +40 -0
- package/deps/librdkafka/mklove/Makefile.base +329 -0
- package/deps/librdkafka/mklove/modules/configure.atomics +144 -0
- package/deps/librdkafka/mklove/modules/configure.base +2484 -0
- package/deps/librdkafka/mklove/modules/configure.builtin +70 -0
- package/deps/librdkafka/mklove/modules/configure.cc +186 -0
- package/deps/librdkafka/mklove/modules/configure.cxx +8 -0
- package/deps/librdkafka/mklove/modules/configure.fileversion +65 -0
- package/deps/librdkafka/mklove/modules/configure.gitversion +29 -0
- package/deps/librdkafka/mklove/modules/configure.good_cflags +18 -0
- package/deps/librdkafka/mklove/modules/configure.host +132 -0
- package/deps/librdkafka/mklove/modules/configure.lib +49 -0
- package/deps/librdkafka/mklove/modules/configure.libcurl +99 -0
- package/deps/librdkafka/mklove/modules/configure.libsasl2 +36 -0
- package/deps/librdkafka/mklove/modules/configure.libssl +147 -0
- package/deps/librdkafka/mklove/modules/configure.libzstd +58 -0
- package/deps/librdkafka/mklove/modules/configure.parseversion +95 -0
- package/deps/librdkafka/mklove/modules/configure.pic +16 -0
- package/deps/librdkafka/mklove/modules/configure.socket +20 -0
- package/deps/librdkafka/mklove/modules/configure.zlib +61 -0
- package/deps/librdkafka/mklove/modules/patches/README.md +8 -0
- package/deps/librdkafka/mklove/modules/patches/libcurl.0000-no-runtime-linking-check.patch +11 -0
- package/deps/librdkafka/mklove/modules/patches/libssl.0000-osx-rand-include-fix-OpenSSL-PR16409.patch +56 -0
- package/deps/librdkafka/packaging/RELEASE.md +319 -0
- package/deps/librdkafka/packaging/alpine/build-alpine.sh +38 -0
- package/deps/librdkafka/packaging/archlinux/PKGBUILD +30 -0
- package/deps/librdkafka/packaging/cmake/Config.cmake.in +37 -0
- package/deps/librdkafka/packaging/cmake/Modules/FindLZ4.cmake +38 -0
- package/deps/librdkafka/packaging/cmake/Modules/FindZSTD.cmake +27 -0
- package/deps/librdkafka/packaging/cmake/Modules/LICENSE.FindZstd +178 -0
- package/deps/librdkafka/packaging/cmake/README.md +38 -0
- package/deps/librdkafka/packaging/cmake/config.h.in +52 -0
- package/deps/librdkafka/packaging/cmake/parseversion.cmake +60 -0
- package/deps/librdkafka/packaging/cmake/rdkafka.pc.in +12 -0
- package/deps/librdkafka/packaging/cmake/try_compile/atomic_32_test.c +8 -0
- package/deps/librdkafka/packaging/cmake/try_compile/atomic_64_test.c +8 -0
- package/deps/librdkafka/packaging/cmake/try_compile/c11threads_test.c +14 -0
- package/deps/librdkafka/packaging/cmake/try_compile/crc32c_hw_test.c +27 -0
- package/deps/librdkafka/packaging/cmake/try_compile/dlopen_test.c +11 -0
- package/deps/librdkafka/packaging/cmake/try_compile/libsasl2_test.c +7 -0
- package/deps/librdkafka/packaging/cmake/try_compile/pthread_setname_darwin_test.c +6 -0
- package/deps/librdkafka/packaging/cmake/try_compile/pthread_setname_freebsd_test.c +7 -0
- package/deps/librdkafka/packaging/cmake/try_compile/pthread_setname_gnu_test.c +5 -0
- package/deps/librdkafka/packaging/cmake/try_compile/rand_r_test.c +7 -0
- package/deps/librdkafka/packaging/cmake/try_compile/rdkafka_setup.cmake +122 -0
- package/deps/librdkafka/packaging/cmake/try_compile/regex_test.c +10 -0
- package/deps/librdkafka/packaging/cmake/try_compile/strndup_test.c +5 -0
- package/deps/librdkafka/packaging/cmake/try_compile/sync_32_test.c +8 -0
- package/deps/librdkafka/packaging/cmake/try_compile/sync_64_test.c +8 -0
- package/deps/librdkafka/packaging/cp/README.md +16 -0
- package/deps/librdkafka/packaging/cp/check_features.c +72 -0
- package/deps/librdkafka/packaging/cp/verify-deb.sh +33 -0
- package/deps/librdkafka/packaging/cp/verify-packages.sh +69 -0
- package/deps/librdkafka/packaging/cp/verify-rpm.sh +32 -0
- package/deps/librdkafka/packaging/debian/changelog +66 -0
- package/deps/librdkafka/packaging/debian/compat +1 -0
- package/deps/librdkafka/packaging/debian/control +49 -0
- package/deps/librdkafka/packaging/debian/copyright +84 -0
- package/deps/librdkafka/packaging/debian/docs +5 -0
- package/deps/librdkafka/packaging/debian/gbp.conf +9 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.dirs +2 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.examples +2 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.install +6 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.substvars +1 -0
- package/deps/librdkafka/packaging/debian/librdkafka.dsc +16 -0
- package/deps/librdkafka/packaging/debian/librdkafka1-dbg.substvars +1 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.dirs +1 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.install +2 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.postinst.debhelper +5 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.postrm.debhelper +5 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.symbols +64 -0
- package/deps/librdkafka/packaging/debian/rules +19 -0
- package/deps/librdkafka/packaging/debian/source/format +1 -0
- package/deps/librdkafka/packaging/debian/watch +2 -0
- package/deps/librdkafka/packaging/get_version.py +21 -0
- package/deps/librdkafka/packaging/homebrew/README.md +15 -0
- package/deps/librdkafka/packaging/homebrew/brew-update-pr.sh +31 -0
- package/deps/librdkafka/packaging/mingw-w64/configure-build-msys2-mingw-static.sh +52 -0
- package/deps/librdkafka/packaging/mingw-w64/configure-build-msys2-mingw.sh +21 -0
- package/deps/librdkafka/packaging/mingw-w64/export-variables.sh +13 -0
- package/deps/librdkafka/packaging/mingw-w64/run-tests.sh +6 -0
- package/deps/librdkafka/packaging/mingw-w64/semaphoreci-build.sh +38 -0
- package/deps/librdkafka/packaging/nuget/README.md +84 -0
- package/deps/librdkafka/packaging/nuget/artifact.py +177 -0
- package/deps/librdkafka/packaging/nuget/cleanup-s3.py +143 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-win32__bldtype-Release/msvcr120.zip +0 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-win32__bldtype-Release/msvcr140.zip +0 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-x64__bldtype-Release/msvcr120.zip +0 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-x64__bldtype-Release/msvcr140.zip +0 -0
- package/deps/librdkafka/packaging/nuget/nuget.sh +21 -0
- package/deps/librdkafka/packaging/nuget/nugetpackage.py +278 -0
- package/deps/librdkafka/packaging/nuget/packaging.py +448 -0
- package/deps/librdkafka/packaging/nuget/push-to-nuget.sh +21 -0
- package/deps/librdkafka/packaging/nuget/release.py +167 -0
- package/deps/librdkafka/packaging/nuget/requirements.txt +3 -0
- package/deps/librdkafka/packaging/nuget/staticpackage.py +178 -0
- package/deps/librdkafka/packaging/nuget/templates/librdkafka.redist.nuspec +21 -0
- package/deps/librdkafka/packaging/nuget/templates/librdkafka.redist.props +18 -0
- package/deps/librdkafka/packaging/nuget/templates/librdkafka.redist.targets +19 -0
- package/deps/librdkafka/packaging/nuget/zfile/__init__.py +0 -0
- package/deps/librdkafka/packaging/nuget/zfile/zfile.py +98 -0
- package/deps/librdkafka/packaging/rpm/Makefile +92 -0
- package/deps/librdkafka/packaging/rpm/README.md +23 -0
- package/deps/librdkafka/packaging/rpm/el7-x86_64.cfg +40 -0
- package/deps/librdkafka/packaging/rpm/librdkafka.spec +118 -0
- package/deps/librdkafka/packaging/rpm/mock-on-docker.sh +96 -0
- package/deps/librdkafka/packaging/rpm/tests/Makefile +25 -0
- package/deps/librdkafka/packaging/rpm/tests/README.md +8 -0
- package/deps/librdkafka/packaging/rpm/tests/run-test.sh +42 -0
- package/deps/librdkafka/packaging/rpm/tests/test-on-docker.sh +56 -0
- package/deps/librdkafka/packaging/rpm/tests/test.c +77 -0
- package/deps/librdkafka/packaging/rpm/tests/test.cpp +34 -0
- package/deps/librdkafka/packaging/tools/Dockerfile +31 -0
- package/deps/librdkafka/packaging/tools/build-configurations-checks.sh +12 -0
- package/deps/librdkafka/packaging/tools/build-deb-package.sh +64 -0
- package/deps/librdkafka/packaging/tools/build-debian.sh +65 -0
- package/deps/librdkafka/packaging/tools/build-manylinux.sh +68 -0
- package/deps/librdkafka/packaging/tools/build-release-artifacts.sh +139 -0
- package/deps/librdkafka/packaging/tools/distro-build.sh +38 -0
- package/deps/librdkafka/packaging/tools/gh-release-checksums.py +39 -0
- package/deps/librdkafka/packaging/tools/rdutcoverage.sh +25 -0
- package/deps/librdkafka/packaging/tools/requirements.txt +2 -0
- package/deps/librdkafka/packaging/tools/run-in-docker.sh +28 -0
- package/deps/librdkafka/packaging/tools/run-integration-tests.sh +31 -0
- package/deps/librdkafka/packaging/tools/run-style-check.sh +4 -0
- package/deps/librdkafka/packaging/tools/style-format.sh +149 -0
- package/deps/librdkafka/packaging/tools/update_rpcs_max_versions.py +100 -0
- package/deps/librdkafka/service.yml +172 -0
- package/deps/librdkafka/src/CMakeLists.txt +374 -0
- package/deps/librdkafka/src/Makefile +103 -0
- package/deps/librdkafka/src/README.lz4.md +30 -0
- package/deps/librdkafka/src/cJSON.c +2834 -0
- package/deps/librdkafka/src/cJSON.h +398 -0
- package/deps/librdkafka/src/crc32c.c +430 -0
- package/deps/librdkafka/src/crc32c.h +38 -0
- package/deps/librdkafka/src/generate_proto.sh +66 -0
- package/deps/librdkafka/src/librdkafka_cgrp_synch.png +0 -0
- package/deps/librdkafka/src/lz4.c +2727 -0
- package/deps/librdkafka/src/lz4.h +842 -0
- package/deps/librdkafka/src/lz4frame.c +2078 -0
- package/deps/librdkafka/src/lz4frame.h +692 -0
- package/deps/librdkafka/src/lz4frame_static.h +47 -0
- package/deps/librdkafka/src/lz4hc.c +1631 -0
- package/deps/librdkafka/src/lz4hc.h +413 -0
- package/deps/librdkafka/src/nanopb/pb.h +917 -0
- package/deps/librdkafka/src/nanopb/pb_common.c +388 -0
- package/deps/librdkafka/src/nanopb/pb_common.h +49 -0
- package/deps/librdkafka/src/nanopb/pb_decode.c +1727 -0
- package/deps/librdkafka/src/nanopb/pb_decode.h +193 -0
- package/deps/librdkafka/src/nanopb/pb_encode.c +1000 -0
- package/deps/librdkafka/src/nanopb/pb_encode.h +185 -0
- package/deps/librdkafka/src/opentelemetry/common.pb.c +32 -0
- package/deps/librdkafka/src/opentelemetry/common.pb.h +170 -0
- package/deps/librdkafka/src/opentelemetry/metrics.options +2 -0
- package/deps/librdkafka/src/opentelemetry/metrics.pb.c +67 -0
- package/deps/librdkafka/src/opentelemetry/metrics.pb.h +966 -0
- package/deps/librdkafka/src/opentelemetry/resource.pb.c +12 -0
- package/deps/librdkafka/src/opentelemetry/resource.pb.h +58 -0
- package/deps/librdkafka/src/queue.h +850 -0
- package/deps/librdkafka/src/rd.h +584 -0
- package/deps/librdkafka/src/rdaddr.c +255 -0
- package/deps/librdkafka/src/rdaddr.h +202 -0
- package/deps/librdkafka/src/rdatomic.h +230 -0
- package/deps/librdkafka/src/rdavg.h +260 -0
- package/deps/librdkafka/src/rdavl.c +210 -0
- package/deps/librdkafka/src/rdavl.h +250 -0
- package/deps/librdkafka/src/rdbase64.c +200 -0
- package/deps/librdkafka/src/rdbase64.h +43 -0
- package/deps/librdkafka/src/rdbuf.c +1884 -0
- package/deps/librdkafka/src/rdbuf.h +375 -0
- package/deps/librdkafka/src/rdcrc32.c +114 -0
- package/deps/librdkafka/src/rdcrc32.h +170 -0
- package/deps/librdkafka/src/rddl.c +179 -0
- package/deps/librdkafka/src/rddl.h +43 -0
- package/deps/librdkafka/src/rdendian.h +175 -0
- package/deps/librdkafka/src/rdfloat.h +67 -0
- package/deps/librdkafka/src/rdfnv1a.c +113 -0
- package/deps/librdkafka/src/rdfnv1a.h +35 -0
- package/deps/librdkafka/src/rdgz.c +120 -0
- package/deps/librdkafka/src/rdgz.h +46 -0
- package/deps/librdkafka/src/rdhdrhistogram.c +721 -0
- package/deps/librdkafka/src/rdhdrhistogram.h +87 -0
- package/deps/librdkafka/src/rdhttp.c +830 -0
- package/deps/librdkafka/src/rdhttp.h +101 -0
- package/deps/librdkafka/src/rdinterval.h +177 -0
- package/deps/librdkafka/src/rdkafka.c +5505 -0
- package/deps/librdkafka/src/rdkafka.h +10686 -0
- package/deps/librdkafka/src/rdkafka_admin.c +9794 -0
- package/deps/librdkafka/src/rdkafka_admin.h +661 -0
- package/deps/librdkafka/src/rdkafka_assignment.c +1010 -0
- package/deps/librdkafka/src/rdkafka_assignment.h +73 -0
- package/deps/librdkafka/src/rdkafka_assignor.c +1786 -0
- package/deps/librdkafka/src/rdkafka_assignor.h +402 -0
- package/deps/librdkafka/src/rdkafka_aux.c +409 -0
- package/deps/librdkafka/src/rdkafka_aux.h +174 -0
- package/deps/librdkafka/src/rdkafka_background.c +221 -0
- package/deps/librdkafka/src/rdkafka_broker.c +6337 -0
- package/deps/librdkafka/src/rdkafka_broker.h +744 -0
- package/deps/librdkafka/src/rdkafka_buf.c +543 -0
- package/deps/librdkafka/src/rdkafka_buf.h +1525 -0
- package/deps/librdkafka/src/rdkafka_cert.c +576 -0
- package/deps/librdkafka/src/rdkafka_cert.h +62 -0
- package/deps/librdkafka/src/rdkafka_cgrp.c +7587 -0
- package/deps/librdkafka/src/rdkafka_cgrp.h +477 -0
- package/deps/librdkafka/src/rdkafka_conf.c +4880 -0
- package/deps/librdkafka/src/rdkafka_conf.h +732 -0
- package/deps/librdkafka/src/rdkafka_confval.h +97 -0
- package/deps/librdkafka/src/rdkafka_coord.c +623 -0
- package/deps/librdkafka/src/rdkafka_coord.h +132 -0
- package/deps/librdkafka/src/rdkafka_error.c +228 -0
- package/deps/librdkafka/src/rdkafka_error.h +80 -0
- package/deps/librdkafka/src/rdkafka_event.c +502 -0
- package/deps/librdkafka/src/rdkafka_event.h +126 -0
- package/deps/librdkafka/src/rdkafka_feature.c +898 -0
- package/deps/librdkafka/src/rdkafka_feature.h +104 -0
- package/deps/librdkafka/src/rdkafka_fetcher.c +1422 -0
- package/deps/librdkafka/src/rdkafka_fetcher.h +44 -0
- package/deps/librdkafka/src/rdkafka_header.c +220 -0
- package/deps/librdkafka/src/rdkafka_header.h +76 -0
- package/deps/librdkafka/src/rdkafka_idempotence.c +807 -0
- package/deps/librdkafka/src/rdkafka_idempotence.h +144 -0
- package/deps/librdkafka/src/rdkafka_int.h +1260 -0
- package/deps/librdkafka/src/rdkafka_interceptor.c +819 -0
- package/deps/librdkafka/src/rdkafka_interceptor.h +104 -0
- package/deps/librdkafka/src/rdkafka_lz4.c +450 -0
- package/deps/librdkafka/src/rdkafka_lz4.h +49 -0
- package/deps/librdkafka/src/rdkafka_metadata.c +2209 -0
- package/deps/librdkafka/src/rdkafka_metadata.h +345 -0
- package/deps/librdkafka/src/rdkafka_metadata_cache.c +1183 -0
- package/deps/librdkafka/src/rdkafka_mock.c +3661 -0
- package/deps/librdkafka/src/rdkafka_mock.h +610 -0
- package/deps/librdkafka/src/rdkafka_mock_cgrp.c +1876 -0
- package/deps/librdkafka/src/rdkafka_mock_handlers.c +3113 -0
- package/deps/librdkafka/src/rdkafka_mock_int.h +710 -0
- package/deps/librdkafka/src/rdkafka_msg.c +2589 -0
- package/deps/librdkafka/src/rdkafka_msg.h +614 -0
- package/deps/librdkafka/src/rdkafka_msgbatch.h +62 -0
- package/deps/librdkafka/src/rdkafka_msgset.h +98 -0
- package/deps/librdkafka/src/rdkafka_msgset_reader.c +1806 -0
- package/deps/librdkafka/src/rdkafka_msgset_writer.c +1474 -0
- package/deps/librdkafka/src/rdkafka_offset.c +1565 -0
- package/deps/librdkafka/src/rdkafka_offset.h +150 -0
- package/deps/librdkafka/src/rdkafka_op.c +997 -0
- package/deps/librdkafka/src/rdkafka_op.h +858 -0
- package/deps/librdkafka/src/rdkafka_partition.c +4896 -0
- package/deps/librdkafka/src/rdkafka_partition.h +1182 -0
- package/deps/librdkafka/src/rdkafka_pattern.c +228 -0
- package/deps/librdkafka/src/rdkafka_pattern.h +70 -0
- package/deps/librdkafka/src/rdkafka_plugin.c +213 -0
- package/deps/librdkafka/src/rdkafka_plugin.h +41 -0
- package/deps/librdkafka/src/rdkafka_proto.h +736 -0
- package/deps/librdkafka/src/rdkafka_protocol.h +128 -0
- package/deps/librdkafka/src/rdkafka_queue.c +1230 -0
- package/deps/librdkafka/src/rdkafka_queue.h +1220 -0
- package/deps/librdkafka/src/rdkafka_range_assignor.c +1748 -0
- package/deps/librdkafka/src/rdkafka_request.c +7089 -0
- package/deps/librdkafka/src/rdkafka_request.h +732 -0
- package/deps/librdkafka/src/rdkafka_roundrobin_assignor.c +123 -0
- package/deps/librdkafka/src/rdkafka_sasl.c +530 -0
- package/deps/librdkafka/src/rdkafka_sasl.h +63 -0
- package/deps/librdkafka/src/rdkafka_sasl_cyrus.c +722 -0
- package/deps/librdkafka/src/rdkafka_sasl_int.h +89 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.c +1833 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.h +52 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.c +1666 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.h +47 -0
- package/deps/librdkafka/src/rdkafka_sasl_plain.c +142 -0
- package/deps/librdkafka/src/rdkafka_sasl_scram.c +858 -0
- package/deps/librdkafka/src/rdkafka_sasl_win32.c +550 -0
- package/deps/librdkafka/src/rdkafka_ssl.c +2129 -0
- package/deps/librdkafka/src/rdkafka_ssl.h +86 -0
- package/deps/librdkafka/src/rdkafka_sticky_assignor.c +4785 -0
- package/deps/librdkafka/src/rdkafka_subscription.c +278 -0
- package/deps/librdkafka/src/rdkafka_telemetry.c +760 -0
- package/deps/librdkafka/src/rdkafka_telemetry.h +52 -0
- package/deps/librdkafka/src/rdkafka_telemetry_decode.c +1053 -0
- package/deps/librdkafka/src/rdkafka_telemetry_decode.h +59 -0
- package/deps/librdkafka/src/rdkafka_telemetry_encode.c +997 -0
- package/deps/librdkafka/src/rdkafka_telemetry_encode.h +301 -0
- package/deps/librdkafka/src/rdkafka_timer.c +402 -0
- package/deps/librdkafka/src/rdkafka_timer.h +117 -0
- package/deps/librdkafka/src/rdkafka_topic.c +2161 -0
- package/deps/librdkafka/src/rdkafka_topic.h +334 -0
- package/deps/librdkafka/src/rdkafka_transport.c +1309 -0
- package/deps/librdkafka/src/rdkafka_transport.h +99 -0
- package/deps/librdkafka/src/rdkafka_transport_int.h +100 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.c +3256 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.h +171 -0
- package/deps/librdkafka/src/rdkafka_zstd.c +226 -0
- package/deps/librdkafka/src/rdkafka_zstd.h +57 -0
- package/deps/librdkafka/src/rdlist.c +576 -0
- package/deps/librdkafka/src/rdlist.h +434 -0
- package/deps/librdkafka/src/rdlog.c +89 -0
- package/deps/librdkafka/src/rdlog.h +41 -0
- package/deps/librdkafka/src/rdmap.c +508 -0
- package/deps/librdkafka/src/rdmap.h +492 -0
- package/deps/librdkafka/src/rdmurmur2.c +167 -0
- package/deps/librdkafka/src/rdmurmur2.h +35 -0
- package/deps/librdkafka/src/rdports.c +61 -0
- package/deps/librdkafka/src/rdports.h +38 -0
- package/deps/librdkafka/src/rdposix.h +250 -0
- package/deps/librdkafka/src/rdrand.c +80 -0
- package/deps/librdkafka/src/rdrand.h +43 -0
- package/deps/librdkafka/src/rdregex.c +156 -0
- package/deps/librdkafka/src/rdregex.h +43 -0
- package/deps/librdkafka/src/rdsignal.h +57 -0
- package/deps/librdkafka/src/rdstring.c +645 -0
- package/deps/librdkafka/src/rdstring.h +98 -0
- package/deps/librdkafka/src/rdsysqueue.h +404 -0
- package/deps/librdkafka/src/rdtime.h +356 -0
- package/deps/librdkafka/src/rdtypes.h +86 -0
- package/deps/librdkafka/src/rdunittest.c +549 -0
- package/deps/librdkafka/src/rdunittest.h +232 -0
- package/deps/librdkafka/src/rdvarint.c +134 -0
- package/deps/librdkafka/src/rdvarint.h +165 -0
- package/deps/librdkafka/src/rdwin32.h +382 -0
- package/deps/librdkafka/src/rdxxhash.c +1030 -0
- package/deps/librdkafka/src/rdxxhash.h +328 -0
- package/deps/librdkafka/src/regexp.c +1352 -0
- package/deps/librdkafka/src/regexp.h +41 -0
- package/deps/librdkafka/src/snappy.c +1866 -0
- package/deps/librdkafka/src/snappy.h +62 -0
- package/deps/librdkafka/src/snappy_compat.h +138 -0
- package/deps/librdkafka/src/statistics_schema.json +444 -0
- package/deps/librdkafka/src/tinycthread.c +932 -0
- package/deps/librdkafka/src/tinycthread.h +503 -0
- package/deps/librdkafka/src/tinycthread_extra.c +199 -0
- package/deps/librdkafka/src/tinycthread_extra.h +212 -0
- package/deps/librdkafka/src/win32_config.h +58 -0
- package/deps/librdkafka/src-cpp/CMakeLists.txt +90 -0
- package/deps/librdkafka/src-cpp/ConfImpl.cpp +84 -0
- package/deps/librdkafka/src-cpp/ConsumerImpl.cpp +244 -0
- package/deps/librdkafka/src-cpp/HandleImpl.cpp +436 -0
- package/deps/librdkafka/src-cpp/HeadersImpl.cpp +48 -0
- package/deps/librdkafka/src-cpp/KafkaConsumerImpl.cpp +296 -0
- package/deps/librdkafka/src-cpp/Makefile +55 -0
- package/deps/librdkafka/src-cpp/MessageImpl.cpp +38 -0
- package/deps/librdkafka/src-cpp/MetadataImpl.cpp +170 -0
- package/deps/librdkafka/src-cpp/ProducerImpl.cpp +197 -0
- package/deps/librdkafka/src-cpp/QueueImpl.cpp +70 -0
- package/deps/librdkafka/src-cpp/README.md +16 -0
- package/deps/librdkafka/src-cpp/RdKafka.cpp +59 -0
- package/deps/librdkafka/src-cpp/TopicImpl.cpp +124 -0
- package/deps/librdkafka/src-cpp/TopicPartitionImpl.cpp +57 -0
- package/deps/librdkafka/src-cpp/rdkafkacpp.h +3797 -0
- package/deps/librdkafka/src-cpp/rdkafkacpp_int.h +1641 -0
- package/deps/librdkafka/tests/0000-unittests.c +72 -0
- package/deps/librdkafka/tests/0001-multiobj.c +102 -0
- package/deps/librdkafka/tests/0002-unkpart.c +244 -0
- package/deps/librdkafka/tests/0003-msgmaxsize.c +173 -0
- package/deps/librdkafka/tests/0004-conf.c +934 -0
- package/deps/librdkafka/tests/0005-order.c +133 -0
- package/deps/librdkafka/tests/0006-symbols.c +163 -0
- package/deps/librdkafka/tests/0007-autotopic.c +136 -0
- package/deps/librdkafka/tests/0008-reqacks.c +179 -0
- package/deps/librdkafka/tests/0009-mock_cluster.c +97 -0
- package/deps/librdkafka/tests/0011-produce_batch.c +753 -0
- package/deps/librdkafka/tests/0012-produce_consume.c +537 -0
- package/deps/librdkafka/tests/0013-null-msgs.c +473 -0
- package/deps/librdkafka/tests/0014-reconsume-191.c +512 -0
- package/deps/librdkafka/tests/0015-offset_seeks.c +172 -0
- package/deps/librdkafka/tests/0016-client_swname.c +181 -0
- package/deps/librdkafka/tests/0017-compression.c +140 -0
- package/deps/librdkafka/tests/0018-cgrp_term.c +338 -0
- package/deps/librdkafka/tests/0019-list_groups.c +289 -0
- package/deps/librdkafka/tests/0020-destroy_hang.c +162 -0
- package/deps/librdkafka/tests/0021-rkt_destroy.c +72 -0
- package/deps/librdkafka/tests/0022-consume_batch.c +279 -0
- package/deps/librdkafka/tests/0025-timers.c +147 -0
- package/deps/librdkafka/tests/0026-consume_pause.c +547 -0
- package/deps/librdkafka/tests/0028-long_topicnames.c +79 -0
- package/deps/librdkafka/tests/0029-assign_offset.c +202 -0
- package/deps/librdkafka/tests/0030-offset_commit.c +589 -0
- package/deps/librdkafka/tests/0031-get_offsets.c +235 -0
- package/deps/librdkafka/tests/0033-regex_subscribe.c +536 -0
- package/deps/librdkafka/tests/0034-offset_reset.c +398 -0
- package/deps/librdkafka/tests/0035-api_version.c +73 -0
- package/deps/librdkafka/tests/0036-partial_fetch.c +87 -0
- package/deps/librdkafka/tests/0037-destroy_hang_local.c +85 -0
- package/deps/librdkafka/tests/0038-performance.c +121 -0
- package/deps/librdkafka/tests/0039-event.c +284 -0
- package/deps/librdkafka/tests/0040-io_event.c +257 -0
- package/deps/librdkafka/tests/0041-fetch_max_bytes.c +97 -0
- package/deps/librdkafka/tests/0042-many_topics.c +252 -0
- package/deps/librdkafka/tests/0043-no_connection.c +77 -0
- package/deps/librdkafka/tests/0044-partition_cnt.c +94 -0
- package/deps/librdkafka/tests/0045-subscribe_update.c +1010 -0
- package/deps/librdkafka/tests/0046-rkt_cache.c +65 -0
- package/deps/librdkafka/tests/0047-partial_buf_tmout.c +98 -0
- package/deps/librdkafka/tests/0048-partitioner.c +283 -0
- package/deps/librdkafka/tests/0049-consume_conn_close.c +162 -0
- package/deps/librdkafka/tests/0050-subscribe_adds.c +145 -0
- package/deps/librdkafka/tests/0051-assign_adds.c +126 -0
- package/deps/librdkafka/tests/0052-msg_timestamps.c +238 -0
- package/deps/librdkafka/tests/0053-stats_cb.cpp +527 -0
- package/deps/librdkafka/tests/0054-offset_time.cpp +236 -0
- package/deps/librdkafka/tests/0055-producer_latency.c +539 -0
- package/deps/librdkafka/tests/0056-balanced_group_mt.c +315 -0
- package/deps/librdkafka/tests/0057-invalid_topic.cpp +112 -0
- package/deps/librdkafka/tests/0058-log.cpp +123 -0
- package/deps/librdkafka/tests/0059-bsearch.cpp +241 -0
- package/deps/librdkafka/tests/0060-op_prio.cpp +163 -0
- package/deps/librdkafka/tests/0061-consumer_lag.cpp +295 -0
- package/deps/librdkafka/tests/0062-stats_event.c +126 -0
- package/deps/librdkafka/tests/0063-clusterid.cpp +180 -0
- package/deps/librdkafka/tests/0064-interceptors.c +481 -0
- package/deps/librdkafka/tests/0065-yield.cpp +140 -0
- package/deps/librdkafka/tests/0066-plugins.cpp +129 -0
- package/deps/librdkafka/tests/0067-empty_topic.cpp +151 -0
- package/deps/librdkafka/tests/0068-produce_timeout.c +136 -0
- package/deps/librdkafka/tests/0069-consumer_add_parts.c +119 -0
- package/deps/librdkafka/tests/0070-null_empty.cpp +197 -0
- package/deps/librdkafka/tests/0072-headers_ut.c +448 -0
- package/deps/librdkafka/tests/0073-headers.c +381 -0
- package/deps/librdkafka/tests/0074-producev.c +87 -0
- package/deps/librdkafka/tests/0075-retry.c +290 -0
- package/deps/librdkafka/tests/0076-produce_retry.c +452 -0
- package/deps/librdkafka/tests/0077-compaction.c +363 -0
- package/deps/librdkafka/tests/0078-c_from_cpp.cpp +96 -0
- package/deps/librdkafka/tests/0079-fork.c +93 -0
- package/deps/librdkafka/tests/0080-admin_ut.c +3095 -0
- package/deps/librdkafka/tests/0081-admin.c +5633 -0
- package/deps/librdkafka/tests/0082-fetch_max_bytes.cpp +137 -0
- package/deps/librdkafka/tests/0083-cb_event.c +233 -0
- package/deps/librdkafka/tests/0084-destroy_flags.c +208 -0
- package/deps/librdkafka/tests/0085-headers.cpp +392 -0
- package/deps/librdkafka/tests/0086-purge.c +368 -0
- package/deps/librdkafka/tests/0088-produce_metadata_timeout.c +162 -0
- package/deps/librdkafka/tests/0089-max_poll_interval.c +511 -0
- package/deps/librdkafka/tests/0090-idempotence.c +171 -0
- package/deps/librdkafka/tests/0091-max_poll_interval_timeout.c +295 -0
- package/deps/librdkafka/tests/0092-mixed_msgver.c +103 -0
- package/deps/librdkafka/tests/0093-holb.c +200 -0
- package/deps/librdkafka/tests/0094-idempotence_msg_timeout.c +231 -0
- package/deps/librdkafka/tests/0095-all_brokers_down.cpp +122 -0
- package/deps/librdkafka/tests/0097-ssl_verify.cpp +658 -0
- package/deps/librdkafka/tests/0098-consumer-txn.cpp +1218 -0
- package/deps/librdkafka/tests/0099-commit_metadata.c +194 -0
- package/deps/librdkafka/tests/0100-thread_interceptors.cpp +195 -0
- package/deps/librdkafka/tests/0101-fetch-from-follower.cpp +446 -0
- package/deps/librdkafka/tests/0102-static_group_rebalance.c +836 -0
- package/deps/librdkafka/tests/0103-transactions.c +1383 -0
- package/deps/librdkafka/tests/0104-fetch_from_follower_mock.c +625 -0
- package/deps/librdkafka/tests/0105-transactions_mock.c +3930 -0
- package/deps/librdkafka/tests/0106-cgrp_sess_timeout.c +318 -0
- package/deps/librdkafka/tests/0107-topic_recreate.c +259 -0
- package/deps/librdkafka/tests/0109-auto_create_topics.cpp +278 -0
- package/deps/librdkafka/tests/0110-batch_size.cpp +182 -0
- package/deps/librdkafka/tests/0111-delay_create_topics.cpp +127 -0
- package/deps/librdkafka/tests/0112-assign_unknown_part.c +87 -0
- package/deps/librdkafka/tests/0113-cooperative_rebalance.cpp +3473 -0
- package/deps/librdkafka/tests/0114-sticky_partitioning.cpp +176 -0
- package/deps/librdkafka/tests/0115-producer_auth.cpp +182 -0
- package/deps/librdkafka/tests/0116-kafkaconsumer_close.cpp +216 -0
- package/deps/librdkafka/tests/0117-mock_errors.c +331 -0
- package/deps/librdkafka/tests/0118-commit_rebalance.c +154 -0
- package/deps/librdkafka/tests/0119-consumer_auth.cpp +167 -0
- package/deps/librdkafka/tests/0120-asymmetric_subscription.c +185 -0
- package/deps/librdkafka/tests/0121-clusterid.c +115 -0
- package/deps/librdkafka/tests/0122-buffer_cleaning_after_rebalance.c +227 -0
- package/deps/librdkafka/tests/0123-connections_max_idle.c +98 -0
- package/deps/librdkafka/tests/0124-openssl_invalid_engine.c +69 -0
- package/deps/librdkafka/tests/0125-immediate_flush.c +144 -0
- package/deps/librdkafka/tests/0126-oauthbearer_oidc.c +528 -0
- package/deps/librdkafka/tests/0127-fetch_queue_backoff.cpp +165 -0
- package/deps/librdkafka/tests/0128-sasl_callback_queue.cpp +125 -0
- package/deps/librdkafka/tests/0129-fetch_aborted_msgs.c +79 -0
- package/deps/librdkafka/tests/0130-store_offsets.c +178 -0
- package/deps/librdkafka/tests/0131-connect_timeout.c +81 -0
- package/deps/librdkafka/tests/0132-strategy_ordering.c +179 -0
- package/deps/librdkafka/tests/0133-ssl_keys.c +150 -0
- package/deps/librdkafka/tests/0134-ssl_provider.c +92 -0
- package/deps/librdkafka/tests/0135-sasl_credentials.cpp +143 -0
- package/deps/librdkafka/tests/0136-resolve_cb.c +181 -0
- package/deps/librdkafka/tests/0137-barrier_batch_consume.c +619 -0
- package/deps/librdkafka/tests/0138-admin_mock.c +281 -0
- package/deps/librdkafka/tests/0139-offset_validation_mock.c +950 -0
- package/deps/librdkafka/tests/0140-commit_metadata.cpp +108 -0
- package/deps/librdkafka/tests/0142-reauthentication.c +515 -0
- package/deps/librdkafka/tests/0143-exponential_backoff_mock.c +552 -0
- package/deps/librdkafka/tests/0144-idempotence_mock.c +373 -0
- package/deps/librdkafka/tests/0145-pause_resume_mock.c +119 -0
- package/deps/librdkafka/tests/0146-metadata_mock.c +505 -0
- package/deps/librdkafka/tests/0147-consumer_group_consumer_mock.c +952 -0
- package/deps/librdkafka/tests/0148-offset_fetch_commit_error_mock.c +563 -0
- package/deps/librdkafka/tests/0149-broker-same-host-port.c +140 -0
- package/deps/librdkafka/tests/0150-telemetry_mock.c +651 -0
- package/deps/librdkafka/tests/0151-purge-brokers.c +566 -0
- package/deps/librdkafka/tests/0152-rebootstrap.c +59 -0
- package/deps/librdkafka/tests/0153-memberid.c +128 -0
- package/deps/librdkafka/tests/1000-unktopic.c +164 -0
- package/deps/librdkafka/tests/8000-idle.cpp +60 -0
- package/deps/librdkafka/tests/8001-fetch_from_follower_mock_manual.c +113 -0
- package/deps/librdkafka/tests/CMakeLists.txt +170 -0
- package/deps/librdkafka/tests/LibrdkafkaTestApp.py +291 -0
- package/deps/librdkafka/tests/Makefile +182 -0
- package/deps/librdkafka/tests/README.md +509 -0
- package/deps/librdkafka/tests/autotest.sh +33 -0
- package/deps/librdkafka/tests/backtrace.gdb +30 -0
- package/deps/librdkafka/tests/broker_version_tests.py +315 -0
- package/deps/librdkafka/tests/buildbox.sh +17 -0
- package/deps/librdkafka/tests/cleanup-checker-tests.sh +20 -0
- package/deps/librdkafka/tests/cluster_testing.py +191 -0
- package/deps/librdkafka/tests/delete-test-topics.sh +56 -0
- package/deps/librdkafka/tests/fixtures/oauthbearer/jwt_assertion_template.json +10 -0
- package/deps/librdkafka/tests/fixtures/ssl/Makefile +8 -0
- package/deps/librdkafka/tests/fixtures/ssl/README.md +13 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.intermediate.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.intermediate.pem +72 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.pem +50 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.intermediate.key +46 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.key +46 -0
- package/deps/librdkafka/tests/fixtures/ssl/create_keys.sh +168 -0
- package/deps/librdkafka/tests/fuzzers/Makefile +12 -0
- package/deps/librdkafka/tests/fuzzers/README.md +31 -0
- package/deps/librdkafka/tests/fuzzers/fuzz_regex.c +74 -0
- package/deps/librdkafka/tests/fuzzers/helpers.h +90 -0
- package/deps/librdkafka/tests/gen-ssl-certs.sh +165 -0
- package/deps/librdkafka/tests/interactive_broker_version.py +170 -0
- package/deps/librdkafka/tests/interceptor_test/CMakeLists.txt +16 -0
- package/deps/librdkafka/tests/interceptor_test/Makefile +22 -0
- package/deps/librdkafka/tests/interceptor_test/interceptor_test.c +314 -0
- package/deps/librdkafka/tests/interceptor_test/interceptor_test.h +54 -0
- package/deps/librdkafka/tests/java/IncrementalRebalanceCli.java +97 -0
- package/deps/librdkafka/tests/java/Makefile +13 -0
- package/deps/librdkafka/tests/java/Murmur2Cli.java +46 -0
- package/deps/librdkafka/tests/java/README.md +14 -0
- package/deps/librdkafka/tests/java/TransactionProducerCli.java +162 -0
- package/deps/librdkafka/tests/java/run-class.sh +11 -0
- package/deps/librdkafka/tests/librdkafka.suppressions +483 -0
- package/deps/librdkafka/tests/lz4_manual_test.sh +59 -0
- package/deps/librdkafka/tests/multi-broker-version-test.sh +50 -0
- package/deps/librdkafka/tests/parse-refcnt.sh +43 -0
- package/deps/librdkafka/tests/performance_plot.py +115 -0
- package/deps/librdkafka/tests/plugin_test/Makefile +19 -0
- package/deps/librdkafka/tests/plugin_test/plugin_test.c +58 -0
- package/deps/librdkafka/tests/requirements.txt +2 -0
- package/deps/librdkafka/tests/run-all-tests.sh +79 -0
- package/deps/librdkafka/tests/run-consumer-tests.sh +16 -0
- package/deps/librdkafka/tests/run-producer-tests.sh +16 -0
- package/deps/librdkafka/tests/run-test-batches.py +157 -0
- package/deps/librdkafka/tests/run-test.sh +140 -0
- package/deps/librdkafka/tests/rusage.c +249 -0
- package/deps/librdkafka/tests/sasl_test.py +289 -0
- package/deps/librdkafka/tests/scenarios/README.md +6 -0
- package/deps/librdkafka/tests/scenarios/ak23.json +6 -0
- package/deps/librdkafka/tests/scenarios/default.json +5 -0
- package/deps/librdkafka/tests/scenarios/noautocreate.json +5 -0
- package/deps/librdkafka/tests/sockem.c +801 -0
- package/deps/librdkafka/tests/sockem.h +85 -0
- package/deps/librdkafka/tests/sockem_ctrl.c +145 -0
- package/deps/librdkafka/tests/sockem_ctrl.h +61 -0
- package/deps/librdkafka/tests/test.c +7778 -0
- package/deps/librdkafka/tests/test.conf.example +27 -0
- package/deps/librdkafka/tests/test.h +1028 -0
- package/deps/librdkafka/tests/testcpp.cpp +131 -0
- package/deps/librdkafka/tests/testcpp.h +388 -0
- package/deps/librdkafka/tests/testshared.h +416 -0
- package/deps/librdkafka/tests/tools/README.md +4 -0
- package/deps/librdkafka/tests/tools/stats/README.md +21 -0
- package/deps/librdkafka/tests/tools/stats/filter.jq +42 -0
- package/deps/librdkafka/tests/tools/stats/graph.py +150 -0
- package/deps/librdkafka/tests/tools/stats/requirements.txt +3 -0
- package/deps/librdkafka/tests/tools/stats/to_csv.py +124 -0
- package/deps/librdkafka/tests/trivup/trivup-0.14.0.tar.gz +0 -0
- package/deps/librdkafka/tests/until-fail.sh +87 -0
- package/deps/librdkafka/tests/xxxx-assign_partition.c +122 -0
- package/deps/librdkafka/tests/xxxx-metadata.cpp +159 -0
- package/deps/librdkafka/vcpkg.json +23 -0
- package/deps/librdkafka/win32/README.md +5 -0
- package/deps/librdkafka/win32/build-package.bat +3 -0
- package/deps/librdkafka/win32/build.bat +19 -0
- package/deps/librdkafka/win32/common.vcxproj +84 -0
- package/deps/librdkafka/win32/interceptor_test/interceptor_test.vcxproj +87 -0
- package/deps/librdkafka/win32/librdkafka.autopkg.template +54 -0
- package/deps/librdkafka/win32/librdkafka.master.testing.targets +13 -0
- package/deps/librdkafka/win32/librdkafka.sln +226 -0
- package/deps/librdkafka/win32/librdkafka.vcxproj +276 -0
- package/deps/librdkafka/win32/librdkafkacpp/librdkafkacpp.vcxproj +104 -0
- package/deps/librdkafka/win32/msbuild.ps1 +15 -0
- package/deps/librdkafka/win32/openssl_engine_example/openssl_engine_example.vcxproj +132 -0
- package/deps/librdkafka/win32/package-zip.ps1 +46 -0
- package/deps/librdkafka/win32/packages/repositories.config +4 -0
- package/deps/librdkafka/win32/push-package.bat +4 -0
- package/deps/librdkafka/win32/rdkafka_complex_consumer_example_cpp/rdkafka_complex_consumer_example_cpp.vcxproj +67 -0
- package/deps/librdkafka/win32/rdkafka_example/rdkafka_example.vcxproj +97 -0
- package/deps/librdkafka/win32/rdkafka_performance/rdkafka_performance.vcxproj +97 -0
- package/deps/librdkafka/win32/setup-msys2.ps1 +47 -0
- package/deps/librdkafka/win32/setup-vcpkg.ps1 +34 -0
- package/deps/librdkafka/win32/tests/test.conf.example +25 -0
- package/deps/librdkafka/win32/tests/tests.vcxproj +253 -0
- package/deps/librdkafka/win32/win_ssl_cert_store/win_ssl_cert_store.vcxproj +132 -0
- package/deps/librdkafka/win32/wingetopt.c +564 -0
- package/deps/librdkafka/win32/wingetopt.h +101 -0
- package/deps/librdkafka/win32/wintime.h +33 -0
- package/deps/librdkafka.gyp +62 -0
- package/lib/admin.js +233 -0
- package/lib/client.js +573 -0
- package/lib/error.js +500 -0
- package/lib/index.js +34 -0
- package/lib/kafka-consumer-stream.js +397 -0
- package/lib/kafka-consumer.js +698 -0
- package/lib/producer/high-level-producer.js +323 -0
- package/lib/producer-stream.js +307 -0
- package/lib/producer.js +375 -0
- package/lib/tools/ref-counter.js +52 -0
- package/lib/topic-partition.js +88 -0
- package/lib/topic.js +42 -0
- package/lib/util.js +29 -0
- package/package.json +61 -0
- package/prebuilds/darwin-arm64/@point3+node-rdkafka.node +0 -0
- package/prebuilds/linux-x64/@point3+node-rdkafka.node +0 -0
- package/util/configure.js +30 -0
- package/util/get-env.js +6 -0
- package/util/test-compile.js +11 -0
- package/util/test-producer-delivery.js +100 -0
|
@@ -0,0 +1,2209 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* librdkafka - Apache Kafka C library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2012-2022, Magnus Edenhill
|
|
5
|
+
* 2023, Confluent Inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions are met:
|
|
10
|
+
*
|
|
11
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
|
12
|
+
* this list of conditions and the following disclaimer.
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
* and/or other materials provided with the distribution.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
18
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
19
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
20
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
21
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
#include "rd.h"
|
|
32
|
+
#include "rdkafka_int.h"
|
|
33
|
+
#include "rdkafka_topic.h"
|
|
34
|
+
#include "rdkafka_broker.h"
|
|
35
|
+
#include "rdkafka_request.h"
|
|
36
|
+
#include "rdkafka_idempotence.h"
|
|
37
|
+
#include "rdkafka_metadata.h"
|
|
38
|
+
|
|
39
|
+
#include <string.h>
|
|
40
|
+
#include <stdarg.h>
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @brief Id comparator for rd_kafka_metadata_broker_internal_t
|
|
44
|
+
*/
|
|
45
|
+
int rd_kafka_metadata_broker_internal_cmp(const void *_a, const void *_b) {
|
|
46
|
+
const rd_kafka_metadata_broker_internal_t *a = _a;
|
|
47
|
+
const rd_kafka_metadata_broker_internal_t *b = _b;
|
|
48
|
+
return RD_CMP(a->id, b->id);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @brief Id comparator for struct rd_kafka_metadata_broker*
|
|
54
|
+
*/
|
|
55
|
+
int rd_kafka_metadata_broker_cmp(const void *_a, const void *_b) {
|
|
56
|
+
const struct rd_kafka_metadata_broker *a = _a;
|
|
57
|
+
const struct rd_kafka_metadata_broker *b = _b;
|
|
58
|
+
return RD_CMP(a->id, b->id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @brief Id comparator for rd_kafka_metadata_partition_internal_t
|
|
64
|
+
*/
|
|
65
|
+
static int rd_kafka_metadata_partition_internal_cmp(const void *_a,
|
|
66
|
+
const void *_b) {
|
|
67
|
+
const rd_kafka_metadata_partition_internal_t *a = _a;
|
|
68
|
+
const rd_kafka_metadata_partition_internal_t *b = _b;
|
|
69
|
+
return RD_CMP(a->id, b->id);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @brief Helper function to clear a rd_kafka_metadata_partition.
|
|
74
|
+
*
|
|
75
|
+
* @note Does not deallocate the rd_kafka_metadata_partition itself.
|
|
76
|
+
* @note Should not be used if there is an metadata struct allocated with
|
|
77
|
+
* tmpabuf in which rd_kafka_metadata_partition is contained.
|
|
78
|
+
*/
|
|
79
|
+
void rd_kafka_metadata_partition_clear(
|
|
80
|
+
struct rd_kafka_metadata_partition *rkmp) {
|
|
81
|
+
RD_IF_FREE(rkmp->isrs, rd_free);
|
|
82
|
+
RD_IF_FREE(rkmp->replicas, rd_free);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
rd_kafka_resp_err_t
|
|
87
|
+
rd_kafka_metadata(rd_kafka_t *rk,
|
|
88
|
+
int all_topics,
|
|
89
|
+
rd_kafka_topic_t *only_rkt,
|
|
90
|
+
const struct rd_kafka_metadata **metadatap,
|
|
91
|
+
int timeout_ms) {
|
|
92
|
+
rd_kafka_q_t *rkq;
|
|
93
|
+
rd_kafka_broker_t *rkb;
|
|
94
|
+
rd_kafka_op_t *rko;
|
|
95
|
+
rd_kafka_resp_err_t err;
|
|
96
|
+
rd_ts_t ts_end = rd_timeout_init(timeout_ms);
|
|
97
|
+
rd_list_t topics;
|
|
98
|
+
rd_bool_t allow_auto_create_topics =
|
|
99
|
+
rk->rk_conf.allow_auto_create_topics;
|
|
100
|
+
|
|
101
|
+
do {
|
|
102
|
+
/* Query any broker that is up, and if none are up pick the
|
|
103
|
+
* first one, if we're lucky it will be up before the timeout.
|
|
104
|
+
* Previous decommissioning brokers won't be returned by the
|
|
105
|
+
* function after receiving the _DESTROY_BROKER error
|
|
106
|
+
* below. */
|
|
107
|
+
rkb =
|
|
108
|
+
rd_kafka_broker_any_usable(rk, timeout_ms, RD_DO_LOCK, 0,
|
|
109
|
+
"application metadata request");
|
|
110
|
+
if (!rkb)
|
|
111
|
+
return RD_KAFKA_RESP_ERR__TRANSPORT;
|
|
112
|
+
|
|
113
|
+
rkq = rd_kafka_q_new(rk);
|
|
114
|
+
|
|
115
|
+
rd_list_init(&topics, 0, rd_free);
|
|
116
|
+
if (!all_topics) {
|
|
117
|
+
if (only_rkt)
|
|
118
|
+
rd_list_add(
|
|
119
|
+
&topics,
|
|
120
|
+
rd_strdup(rd_kafka_topic_name(only_rkt)));
|
|
121
|
+
else {
|
|
122
|
+
int cache_cnt;
|
|
123
|
+
rd_kafka_local_topics_to_list(
|
|
124
|
+
rkb->rkb_rk, &topics, &cache_cnt);
|
|
125
|
+
/* Don't trigger auto-create
|
|
126
|
+
* for cached topics */
|
|
127
|
+
if (rd_list_cnt(&topics) == cache_cnt)
|
|
128
|
+
allow_auto_create_topics = rd_true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* Async: request metadata */
|
|
133
|
+
rko = rd_kafka_op_new(RD_KAFKA_OP_METADATA);
|
|
134
|
+
rd_kafka_op_set_replyq(rko, rkq, 0);
|
|
135
|
+
rko->rko_u.metadata.force =
|
|
136
|
+
1; /* Force metadata request regardless
|
|
137
|
+
* of outstanding metadata requests. */
|
|
138
|
+
rd_kafka_MetadataRequest(
|
|
139
|
+
rkb, &topics, NULL, "application requested",
|
|
140
|
+
allow_auto_create_topics,
|
|
141
|
+
/* cgrp_update:
|
|
142
|
+
* Only update consumer group state
|
|
143
|
+
* on response if this lists all
|
|
144
|
+
* topics in the cluster, since a
|
|
145
|
+
* partial request may make it seem
|
|
146
|
+
* like some subscribed topics are missing. */
|
|
147
|
+
all_topics ? rd_true : rd_false,
|
|
148
|
+
-1 /* same subscription version */,
|
|
149
|
+
rd_false /* force_racks */, rko);
|
|
150
|
+
|
|
151
|
+
rd_list_destroy(&topics);
|
|
152
|
+
rd_kafka_broker_destroy(rkb);
|
|
153
|
+
|
|
154
|
+
/* Wait for reply (or timeout) */
|
|
155
|
+
rko = rd_kafka_q_pop(rkq, rd_timeout_remains_us(ts_end), 0);
|
|
156
|
+
|
|
157
|
+
rd_kafka_q_destroy_owner(rkq);
|
|
158
|
+
|
|
159
|
+
/* Timeout */
|
|
160
|
+
if (!rko)
|
|
161
|
+
return RD_KAFKA_RESP_ERR__TIMED_OUT;
|
|
162
|
+
|
|
163
|
+
/* Error */
|
|
164
|
+
err = rko->rko_err;
|
|
165
|
+
if (err) {
|
|
166
|
+
rd_kafka_op_destroy(rko);
|
|
167
|
+
if (err != RD_KAFKA_RESP_ERR__DESTROY_BROKER)
|
|
168
|
+
return err;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* In case selected broker was decommissioned,
|
|
172
|
+
* try again with a different broker. */
|
|
173
|
+
} while (err == RD_KAFKA_RESP_ERR__DESTROY_BROKER);
|
|
174
|
+
|
|
175
|
+
/* Reply: pass metadata pointer to application who now owns it*/
|
|
176
|
+
rd_kafka_assert(rk, rko->rko_u.metadata.md);
|
|
177
|
+
*metadatap = rko->rko_u.metadata.md;
|
|
178
|
+
rko->rko_u.metadata.md = NULL;
|
|
179
|
+
rko->rko_u.metadata.mdi = NULL;
|
|
180
|
+
rd_kafka_op_destroy(rko);
|
|
181
|
+
|
|
182
|
+
return RD_KAFKA_RESP_ERR_NO_ERROR;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
void rd_kafka_metadata_destroy(const struct rd_kafka_metadata *metadata) {
|
|
188
|
+
rd_free((void *)metadata);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
static rd_kafka_metadata_internal_t *rd_kafka_metadata_copy_internal(
|
|
193
|
+
const rd_kafka_metadata_internal_t *src_internal,
|
|
194
|
+
size_t size,
|
|
195
|
+
rd_bool_t populate_racks) {
|
|
196
|
+
struct rd_kafka_metadata *md;
|
|
197
|
+
rd_kafka_metadata_internal_t *mdi;
|
|
198
|
+
const struct rd_kafka_metadata *src = &src_internal->metadata;
|
|
199
|
+
rd_tmpabuf_t tbuf;
|
|
200
|
+
int i;
|
|
201
|
+
|
|
202
|
+
/* metadata is stored in one contigious buffer where structs and
|
|
203
|
+
* and pointed-to fields are layed out in a memory aligned fashion.
|
|
204
|
+
* rd_tmpabuf_t provides the infrastructure to do this.
|
|
205
|
+
* Because of this we copy all the structs verbatim but
|
|
206
|
+
* any pointer fields needs to be copied explicitly to update
|
|
207
|
+
* the pointer address. */
|
|
208
|
+
rd_tmpabuf_new(&tbuf, size, rd_true /*assert on fail*/);
|
|
209
|
+
rd_tmpabuf_finalize(&tbuf);
|
|
210
|
+
mdi = rd_tmpabuf_write(&tbuf, src, sizeof(*mdi));
|
|
211
|
+
md = &mdi->metadata;
|
|
212
|
+
|
|
213
|
+
rd_tmpabuf_write_str(&tbuf, src->orig_broker_name);
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
/* Copy Brokers */
|
|
217
|
+
md->brokers = rd_tmpabuf_write(&tbuf, src->brokers,
|
|
218
|
+
src->broker_cnt * sizeof(*src->brokers));
|
|
219
|
+
/* Copy internal Brokers */
|
|
220
|
+
mdi->brokers =
|
|
221
|
+
rd_tmpabuf_write(&tbuf, src_internal->brokers,
|
|
222
|
+
src->broker_cnt * sizeof(*src_internal->brokers));
|
|
223
|
+
|
|
224
|
+
for (i = 0; i < md->broker_cnt; i++) {
|
|
225
|
+
md->brokers[i].host =
|
|
226
|
+
rd_tmpabuf_write_str(&tbuf, src->brokers[i].host);
|
|
227
|
+
if (src_internal->brokers[i].rack_id) {
|
|
228
|
+
mdi->brokers[i].rack_id = rd_tmpabuf_write_str(
|
|
229
|
+
&tbuf, src_internal->brokers[i].rack_id);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
/* Copy TopicMetadata */
|
|
235
|
+
md->topics = rd_tmpabuf_write(&tbuf, src->topics,
|
|
236
|
+
md->topic_cnt * sizeof(*md->topics));
|
|
237
|
+
/* Copy internal TopicMetadata */
|
|
238
|
+
mdi->topics =
|
|
239
|
+
rd_tmpabuf_write(&tbuf, src_internal->topics,
|
|
240
|
+
md->topic_cnt * sizeof(*src_internal->topics));
|
|
241
|
+
|
|
242
|
+
for (i = 0; i < md->topic_cnt; i++) {
|
|
243
|
+
int j;
|
|
244
|
+
|
|
245
|
+
md->topics[i].topic =
|
|
246
|
+
rd_tmpabuf_write_str(&tbuf, src->topics[i].topic);
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
/* Copy partitions */
|
|
250
|
+
md->topics[i].partitions =
|
|
251
|
+
rd_tmpabuf_write(&tbuf, src->topics[i].partitions,
|
|
252
|
+
md->topics[i].partition_cnt *
|
|
253
|
+
sizeof(*md->topics[i].partitions));
|
|
254
|
+
/* Copy internal partitions */
|
|
255
|
+
mdi->topics[i].partitions = rd_tmpabuf_write(
|
|
256
|
+
&tbuf, src_internal->topics[i].partitions,
|
|
257
|
+
md->topics[i].partition_cnt *
|
|
258
|
+
sizeof(*src_internal->topics[i].partitions));
|
|
259
|
+
|
|
260
|
+
for (j = 0; j < md->topics[i].partition_cnt; j++) {
|
|
261
|
+
int k;
|
|
262
|
+
char *rack;
|
|
263
|
+
rd_list_t *curr_list;
|
|
264
|
+
|
|
265
|
+
/* Copy replicas and ISRs */
|
|
266
|
+
md->topics[i].partitions[j].replicas = rd_tmpabuf_write(
|
|
267
|
+
&tbuf, src->topics[i].partitions[j].replicas,
|
|
268
|
+
md->topics[i].partitions[j].replica_cnt *
|
|
269
|
+
sizeof(*md->topics[i].partitions[j].replicas));
|
|
270
|
+
|
|
271
|
+
md->topics[i].partitions[j].isrs = rd_tmpabuf_write(
|
|
272
|
+
&tbuf, src->topics[i].partitions[j].isrs,
|
|
273
|
+
md->topics[i].partitions[j].isr_cnt *
|
|
274
|
+
sizeof(*md->topics[i].partitions[j].isrs));
|
|
275
|
+
|
|
276
|
+
mdi->topics[i].partitions[j].racks_cnt = 0;
|
|
277
|
+
mdi->topics[i].partitions[j].racks = NULL;
|
|
278
|
+
|
|
279
|
+
/* Iterate through replicas and populate racks, if
|
|
280
|
+
* needed. */
|
|
281
|
+
if (!populate_racks)
|
|
282
|
+
continue;
|
|
283
|
+
|
|
284
|
+
/* This is quite possibly a recomputation, because we've
|
|
285
|
+
* already done this for the src_internal. However,
|
|
286
|
+
* since the racks need to point inside the tmpbuf, we
|
|
287
|
+
* make this calculation again. Since this is done only
|
|
288
|
+
* in a case of a full metadata refresh, this will be
|
|
289
|
+
* fairly rare. */
|
|
290
|
+
curr_list = rd_list_new(0, NULL);
|
|
291
|
+
for (k = 0; k < md->topics[i].partitions[j].replica_cnt;
|
|
292
|
+
k++) {
|
|
293
|
+
rd_kafka_metadata_broker_internal_t key = {
|
|
294
|
+
.id = md->topics[i]
|
|
295
|
+
.partitions[j]
|
|
296
|
+
.replicas[k]};
|
|
297
|
+
rd_kafka_metadata_broker_internal_t *found =
|
|
298
|
+
bsearch(
|
|
299
|
+
&key, mdi->brokers, md->broker_cnt,
|
|
300
|
+
sizeof(
|
|
301
|
+
rd_kafka_metadata_broker_internal_t),
|
|
302
|
+
rd_kafka_metadata_broker_internal_cmp);
|
|
303
|
+
if (!found || !found->rack_id)
|
|
304
|
+
continue;
|
|
305
|
+
rd_list_add(curr_list, found->rack_id);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (!rd_list_cnt(curr_list)) {
|
|
309
|
+
rd_list_destroy(curr_list);
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
rd_list_deduplicate(&curr_list, rd_strcmp2);
|
|
314
|
+
|
|
315
|
+
mdi->topics[i].partitions[j].racks_cnt =
|
|
316
|
+
rd_list_cnt(curr_list);
|
|
317
|
+
mdi->topics[i].partitions[j].racks = rd_tmpabuf_alloc(
|
|
318
|
+
&tbuf, sizeof(char *) * rd_list_cnt(curr_list));
|
|
319
|
+
RD_LIST_FOREACH(rack, curr_list, k) {
|
|
320
|
+
/* We don't copy here,`rack` points to memory
|
|
321
|
+
* inside `mdi` already, and it's allocated
|
|
322
|
+
* within a tmpabuf. So, the lifetime of
|
|
323
|
+
* mdi->topics[i].partitions[j].racks[k] is the
|
|
324
|
+
* same as the lifetime of the outer `mdi`. */
|
|
325
|
+
mdi->topics[i].partitions[j].racks[k] = rack;
|
|
326
|
+
}
|
|
327
|
+
rd_list_destroy(curr_list);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/* Check for tmpabuf errors */
|
|
332
|
+
if (rd_tmpabuf_failed(&tbuf))
|
|
333
|
+
rd_kafka_assert(NULL, !*"metadata copy failed");
|
|
334
|
+
|
|
335
|
+
/* Deliberately not destroying the tmpabuf since we return
|
|
336
|
+
* its allocated memory. */
|
|
337
|
+
|
|
338
|
+
return mdi;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* @returns a newly allocated copy of metadata \p src of size \p size
|
|
344
|
+
*/
|
|
345
|
+
rd_kafka_metadata_internal_t *
|
|
346
|
+
rd_kafka_metadata_copy(const rd_kafka_metadata_internal_t *src_internal,
|
|
347
|
+
size_t size) {
|
|
348
|
+
return rd_kafka_metadata_copy_internal(src_internal, size, rd_false);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* @returns a newly allocated copy of metadata \p src of size \p size, with
|
|
354
|
+
* partition racks included.
|
|
355
|
+
*/
|
|
356
|
+
rd_kafka_metadata_internal_t *rd_kafka_metadata_copy_add_racks(
|
|
357
|
+
const rd_kafka_metadata_internal_t *src_internal,
|
|
358
|
+
size_t size) {
|
|
359
|
+
return rd_kafka_metadata_copy_internal(src_internal, size, rd_true);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* @brief Update topic state and information based on topic metadata.
|
|
364
|
+
*
|
|
365
|
+
* @param mdt Topic metadata.
|
|
366
|
+
* @param mdit Topic internal metadata.
|
|
367
|
+
*
|
|
368
|
+
* @locality rdkafka main thread
|
|
369
|
+
* @locks_acquired rd_kafka_wrlock(rk)
|
|
370
|
+
*/
|
|
371
|
+
static void rd_kafka_parse_Metadata_update_topic(
|
|
372
|
+
rd_kafka_broker_t *rkb,
|
|
373
|
+
const rd_kafka_metadata_topic_t *mdt,
|
|
374
|
+
const rd_kafka_metadata_topic_internal_t *mdit) {
|
|
375
|
+
|
|
376
|
+
rd_rkb_dbg(rkb, METADATA, "METADATA",
|
|
377
|
+
/* The indent below is intentional */
|
|
378
|
+
" Topic %s with %i partitions%s%s", mdt->topic,
|
|
379
|
+
mdt->partition_cnt, mdt->err ? ": " : "",
|
|
380
|
+
mdt->err ? rd_kafka_err2str(mdt->err) : "");
|
|
381
|
+
|
|
382
|
+
/* Ignore metadata completely for temporary errors. (issue #513)
|
|
383
|
+
* LEADER_NOT_AVAILABLE: Broker is rebalancing
|
|
384
|
+
*/
|
|
385
|
+
if (mdt->err == RD_KAFKA_RESP_ERR_LEADER_NOT_AVAILABLE &&
|
|
386
|
+
mdt->partition_cnt == 0) {
|
|
387
|
+
rd_rkb_dbg(rkb, TOPIC, "METADATA",
|
|
388
|
+
"Temporary error in metadata reply for "
|
|
389
|
+
"topic %s (PartCnt %i): %s: ignoring",
|
|
390
|
+
mdt->topic, mdt->partition_cnt,
|
|
391
|
+
rd_kafka_err2str(mdt->err));
|
|
392
|
+
} else {
|
|
393
|
+
/* Update local topic & partition state based
|
|
394
|
+
* on metadata */
|
|
395
|
+
rd_kafka_topic_metadata_update2(rkb, mdt, mdit);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* @brief Only brokers with Metadata version >= 9 have reliable leader
|
|
401
|
+
* epochs. Before that version, leader epoch must be treated
|
|
402
|
+
* as missing (-1).
|
|
403
|
+
*
|
|
404
|
+
* @param rkb The broker
|
|
405
|
+
* @return Is this a broker version with reliable leader epochs?
|
|
406
|
+
*
|
|
407
|
+
* @locality rdkafka main thread
|
|
408
|
+
*/
|
|
409
|
+
rd_bool_t rd_kafka_has_reliable_leader_epochs(rd_kafka_broker_t *rkb) {
|
|
410
|
+
return rd_kafka_broker_ApiVersion_at_least(rkb, RD_KAFKAP_Metadata, 9);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/* Populates the topic partition to rack mapping for the the topic given by
|
|
414
|
+
* `topic_idx` in the `mdi`. It's assumed that the internal broker metadata is
|
|
415
|
+
* already populated. */
|
|
416
|
+
static void
|
|
417
|
+
rd_kafka_populate_metadata_topic_racks(rd_tmpabuf_t *tbuf,
|
|
418
|
+
size_t topic_idx,
|
|
419
|
+
rd_kafka_metadata_internal_t *mdi) {
|
|
420
|
+
rd_kafka_metadata_broker_internal_t *brokers_internal;
|
|
421
|
+
size_t broker_cnt;
|
|
422
|
+
int i;
|
|
423
|
+
rd_kafka_metadata_topic_t *mdt;
|
|
424
|
+
rd_kafka_metadata_topic_internal_t *mdti;
|
|
425
|
+
|
|
426
|
+
rd_dassert(mdi->brokers);
|
|
427
|
+
rd_dassert(mdi->metadata.topic_cnt > (int)topic_idx);
|
|
428
|
+
|
|
429
|
+
brokers_internal = mdi->brokers;
|
|
430
|
+
broker_cnt = mdi->metadata.broker_cnt;
|
|
431
|
+
|
|
432
|
+
mdt = &mdi->metadata.topics[topic_idx];
|
|
433
|
+
mdti = &mdi->topics[topic_idx];
|
|
434
|
+
|
|
435
|
+
for (i = 0; i < mdt->partition_cnt; i++) {
|
|
436
|
+
int j;
|
|
437
|
+
rd_kafka_metadata_partition_t *mdp = &mdt->partitions[i];
|
|
438
|
+
rd_kafka_metadata_partition_internal_t *mdpi =
|
|
439
|
+
&mdti->partitions[i];
|
|
440
|
+
|
|
441
|
+
rd_list_t *curr_list;
|
|
442
|
+
char *rack;
|
|
443
|
+
|
|
444
|
+
if (mdp->replica_cnt == 0)
|
|
445
|
+
continue;
|
|
446
|
+
|
|
447
|
+
curr_list =
|
|
448
|
+
rd_list_new(0, NULL); /* use a list for de-duplication */
|
|
449
|
+
for (j = 0; j < mdp->replica_cnt; j++) {
|
|
450
|
+
rd_kafka_metadata_broker_internal_t key = {
|
|
451
|
+
.id = mdp->replicas[j]};
|
|
452
|
+
rd_kafka_metadata_broker_internal_t *broker =
|
|
453
|
+
bsearch(&key, brokers_internal, broker_cnt,
|
|
454
|
+
sizeof(rd_kafka_metadata_broker_internal_t),
|
|
455
|
+
rd_kafka_metadata_broker_internal_cmp);
|
|
456
|
+
if (!broker || !broker->rack_id)
|
|
457
|
+
continue;
|
|
458
|
+
rd_list_add(curr_list, broker->rack_id);
|
|
459
|
+
}
|
|
460
|
+
rd_list_deduplicate(&curr_list, rd_strcmp2);
|
|
461
|
+
|
|
462
|
+
mdpi->racks_cnt = rd_list_cnt(curr_list);
|
|
463
|
+
mdpi->racks =
|
|
464
|
+
rd_tmpabuf_alloc(tbuf, sizeof(char *) * mdpi->racks_cnt);
|
|
465
|
+
RD_LIST_FOREACH(rack, curr_list, j) {
|
|
466
|
+
mdpi->racks[j] = rack; /* Don't copy, rack points inside
|
|
467
|
+
tbuf already*/
|
|
468
|
+
}
|
|
469
|
+
rd_list_destroy(curr_list);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* @brief Decommission brokers that are not in the metadata.
|
|
475
|
+
*/
|
|
476
|
+
static void rd_kafka_metadata_decommission_unavailable_brokers(
|
|
477
|
+
rd_kafka_t *rk,
|
|
478
|
+
rd_kafka_metadata_t *md,
|
|
479
|
+
rd_kafka_broker_t *rkb_current) {
|
|
480
|
+
rd_kafka_broker_t *rkb;
|
|
481
|
+
rd_bool_t has_learned_brokers = rd_false;
|
|
482
|
+
rd_list_t brokers_to_decommission;
|
|
483
|
+
int i;
|
|
484
|
+
|
|
485
|
+
rd_kafka_wrlock(rk);
|
|
486
|
+
TAILQ_FOREACH(rkb, &rk->rk_brokers, rkb_link) {
|
|
487
|
+
if (rkb->rkb_source == RD_KAFKA_LEARNED) {
|
|
488
|
+
has_learned_brokers = rd_true;
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (!has_learned_brokers) {
|
|
493
|
+
rd_kafka_wrunlock(rk);
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
rd_list_init(&brokers_to_decommission,
|
|
498
|
+
rd_atomic32_get(&rk->rk_broker_cnt), NULL);
|
|
499
|
+
TAILQ_FOREACH(rkb, &rk->rk_brokers, rkb_link) {
|
|
500
|
+
rd_bool_t purge_broker;
|
|
501
|
+
|
|
502
|
+
if (rkb->rkb_source == RD_KAFKA_LOGICAL)
|
|
503
|
+
continue;
|
|
504
|
+
|
|
505
|
+
purge_broker = rd_true;
|
|
506
|
+
if (rkb->rkb_source == RD_KAFKA_LEARNED) {
|
|
507
|
+
/* Don't purge the broker if it's available in
|
|
508
|
+
* metadata. */
|
|
509
|
+
for (i = 0; i < md->broker_cnt; i++) {
|
|
510
|
+
if (md->brokers[i].id == rkb->rkb_nodeid) {
|
|
511
|
+
purge_broker = rd_false;
|
|
512
|
+
break;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (!purge_broker)
|
|
518
|
+
continue;
|
|
519
|
+
|
|
520
|
+
/* Don't try to decommission already decommissioning brokers
|
|
521
|
+
* otherwise they could be already destroyed when
|
|
522
|
+
* `rd_kafka_broker_decommission` is called below. */
|
|
523
|
+
if (rd_list_find(&rk->wait_decommissioned_brokers, rkb,
|
|
524
|
+
rd_list_cmp_ptr) != NULL)
|
|
525
|
+
continue;
|
|
526
|
+
|
|
527
|
+
rd_list_add(&brokers_to_decommission, rkb);
|
|
528
|
+
}
|
|
529
|
+
RD_LIST_FOREACH(rkb, &brokers_to_decommission, i) {
|
|
530
|
+
rd_kafka_broker_decommission(rk, rkb,
|
|
531
|
+
&rk->wait_decommissioned_thrds);
|
|
532
|
+
rd_list_add(&rk->wait_decommissioned_brokers, rkb);
|
|
533
|
+
}
|
|
534
|
+
rd_list_destroy(&brokers_to_decommission);
|
|
535
|
+
rd_kafka_wrunlock(rk);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/* Internal implementation for parsing Metadata. */
|
|
539
|
+
static rd_kafka_resp_err_t
|
|
540
|
+
rd_kafka_parse_Metadata0(rd_kafka_broker_t *rkb,
|
|
541
|
+
rd_kafka_buf_t *request,
|
|
542
|
+
rd_kafka_buf_t *rkbuf,
|
|
543
|
+
rd_kafka_metadata_internal_t **mdip,
|
|
544
|
+
rd_list_t *request_topics,
|
|
545
|
+
const char *reason) {
|
|
546
|
+
rd_kafka_t *rk = rkb->rkb_rk;
|
|
547
|
+
int i, j, k;
|
|
548
|
+
rd_tmpabuf_t tbuf;
|
|
549
|
+
rd_kafka_metadata_internal_t *mdi = NULL;
|
|
550
|
+
rd_kafka_metadata_t *md = NULL;
|
|
551
|
+
size_t rkb_namelen;
|
|
552
|
+
const int log_decode_errors = LOG_ERR;
|
|
553
|
+
rd_list_t *missing_topics = NULL;
|
|
554
|
+
rd_list_t *missing_topic_ids = NULL;
|
|
555
|
+
|
|
556
|
+
const rd_list_t *requested_topics = request_topics;
|
|
557
|
+
const rd_list_t *requested_topic_ids = NULL;
|
|
558
|
+
rd_bool_t all_topics = rd_false;
|
|
559
|
+
rd_bool_t cgrp_update = rd_false;
|
|
560
|
+
rd_bool_t has_reliable_leader_epochs =
|
|
561
|
+
rd_kafka_has_reliable_leader_epochs(rkb);
|
|
562
|
+
int ApiVersion = rkbuf->rkbuf_reqhdr.ApiVersion;
|
|
563
|
+
rd_kafkap_str_t cluster_id = RD_ZERO_INIT;
|
|
564
|
+
int32_t controller_id = -1;
|
|
565
|
+
rd_kafka_resp_err_t err = RD_KAFKA_RESP_ERR_NO_ERROR;
|
|
566
|
+
int broker_changes = 0;
|
|
567
|
+
int cache_changes = 0;
|
|
568
|
+
int cgrp_subscription_version = -1;
|
|
569
|
+
int16_t ErrorCode = 0;
|
|
570
|
+
|
|
571
|
+
/* If client rack is present, the metadata cache (topic or full) needs
|
|
572
|
+
* to contain the partition to rack map. */
|
|
573
|
+
rd_bool_t has_client_rack = rk->rk_conf.client_rack &&
|
|
574
|
+
RD_KAFKAP_STR_LEN(rk->rk_conf.client_rack);
|
|
575
|
+
rd_bool_t compute_racks = has_client_rack;
|
|
576
|
+
|
|
577
|
+
if (request) {
|
|
578
|
+
requested_topics = request->rkbuf_u.Metadata.topics;
|
|
579
|
+
requested_topic_ids = request->rkbuf_u.Metadata.topic_ids;
|
|
580
|
+
all_topics = request->rkbuf_u.Metadata.all_topics;
|
|
581
|
+
cgrp_update =
|
|
582
|
+
request->rkbuf_u.Metadata.cgrp_update && rk->rk_cgrp;
|
|
583
|
+
compute_racks |= request->rkbuf_u.Metadata.force_racks;
|
|
584
|
+
cgrp_subscription_version =
|
|
585
|
+
request->rkbuf_u.Metadata.cgrp_subscription_version;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/* If there's reason is NULL, set it to a human-readable string. */
|
|
589
|
+
if (!reason)
|
|
590
|
+
reason = "(no reason)";
|
|
591
|
+
|
|
592
|
+
/* Ignore metadata updates when terminating */
|
|
593
|
+
if (rd_kafka_terminating(rkb->rkb_rk)) {
|
|
594
|
+
err = RD_KAFKA_RESP_ERR__DESTROY;
|
|
595
|
+
goto done;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
rd_kafka_assert(NULL, thrd_is_current(rk->rk_thread));
|
|
599
|
+
|
|
600
|
+
/* Remove topics from missing_topics as they are seen in Metadata. */
|
|
601
|
+
if (requested_topics)
|
|
602
|
+
missing_topics =
|
|
603
|
+
rd_list_copy(requested_topics, rd_list_string_copy, NULL);
|
|
604
|
+
if (requested_topic_ids)
|
|
605
|
+
missing_topic_ids =
|
|
606
|
+
rd_list_copy(requested_topic_ids, rd_list_Uuid_copy, NULL);
|
|
607
|
+
|
|
608
|
+
rd_kafka_broker_lock(rkb);
|
|
609
|
+
rkb_namelen = strlen(rkb->rkb_name) + 1;
|
|
610
|
+
/* We assume that the marshalled representation is
|
|
611
|
+
* no more than 4 times larger than the wire representation.
|
|
612
|
+
* This is increased to 5 times in case if we want to compute partition
|
|
613
|
+
* to rack mapping. */
|
|
614
|
+
rd_tmpabuf_new(&tbuf, 0, rd_false /*dont assert on fail*/);
|
|
615
|
+
rd_tmpabuf_add_alloc(&tbuf, sizeof(*mdi));
|
|
616
|
+
rd_tmpabuf_add_alloc(&tbuf, rkb_namelen);
|
|
617
|
+
rd_tmpabuf_add_alloc(&tbuf, rkbuf->rkbuf_totlen *
|
|
618
|
+
(4 + (compute_racks ? 1 : 0)));
|
|
619
|
+
|
|
620
|
+
rd_tmpabuf_finalize(&tbuf);
|
|
621
|
+
|
|
622
|
+
if (!(mdi = rd_tmpabuf_alloc(&tbuf, sizeof(*mdi)))) {
|
|
623
|
+
rd_kafka_broker_unlock(rkb);
|
|
624
|
+
err = RD_KAFKA_RESP_ERR__CRIT_SYS_RESOURCE;
|
|
625
|
+
goto err;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
md = &mdi->metadata;
|
|
629
|
+
md->orig_broker_id = rkb->rkb_nodeid;
|
|
630
|
+
md->orig_broker_name =
|
|
631
|
+
rd_tmpabuf_write(&tbuf, rkb->rkb_name, rkb_namelen);
|
|
632
|
+
rd_kafka_broker_unlock(rkb);
|
|
633
|
+
|
|
634
|
+
if (ApiVersion >= 3)
|
|
635
|
+
rd_kafka_buf_read_throttle_time(rkbuf);
|
|
636
|
+
|
|
637
|
+
/* Read Brokers */
|
|
638
|
+
rd_kafka_buf_read_arraycnt(rkbuf, &md->broker_cnt,
|
|
639
|
+
RD_KAFKAP_BROKERS_MAX);
|
|
640
|
+
|
|
641
|
+
if (!(md->brokers = rd_tmpabuf_alloc(&tbuf, md->broker_cnt *
|
|
642
|
+
sizeof(*md->brokers))))
|
|
643
|
+
rd_kafka_buf_parse_fail(rkbuf,
|
|
644
|
+
"%d brokers: tmpabuf memory shortage",
|
|
645
|
+
md->broker_cnt);
|
|
646
|
+
|
|
647
|
+
if (!(mdi->brokers = rd_tmpabuf_alloc(
|
|
648
|
+
&tbuf, md->broker_cnt * sizeof(*mdi->brokers))))
|
|
649
|
+
rd_kafka_buf_parse_fail(
|
|
650
|
+
rkbuf, "%d internal brokers: tmpabuf memory shortage",
|
|
651
|
+
md->broker_cnt);
|
|
652
|
+
|
|
653
|
+
if (!(mdi->brokers_sorted = rd_tmpabuf_alloc(
|
|
654
|
+
&tbuf, md->broker_cnt * sizeof(*mdi->brokers_sorted))))
|
|
655
|
+
rd_kafka_buf_parse_fail(
|
|
656
|
+
rkbuf, "%d sorted brokers: tmpabuf memory shortage",
|
|
657
|
+
md->broker_cnt);
|
|
658
|
+
|
|
659
|
+
for (i = 0; i < md->broker_cnt; i++) {
|
|
660
|
+
rd_kafka_buf_read_i32a(rkbuf, md->brokers[i].id);
|
|
661
|
+
rd_kafka_buf_read_str_tmpabuf(rkbuf, &tbuf,
|
|
662
|
+
md->brokers[i].host);
|
|
663
|
+
rd_kafka_buf_read_i32a(rkbuf, md->brokers[i].port);
|
|
664
|
+
|
|
665
|
+
mdi->brokers[i].id = md->brokers[i].id;
|
|
666
|
+
if (ApiVersion >= 1) {
|
|
667
|
+
rd_kafka_buf_read_str_tmpabuf(rkbuf, &tbuf,
|
|
668
|
+
mdi->brokers[i].rack_id);
|
|
669
|
+
} else {
|
|
670
|
+
mdi->brokers[i].rack_id = NULL;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
rd_kafka_buf_skip_tags(rkbuf);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
mdi->cluster_id = NULL;
|
|
677
|
+
if (ApiVersion >= 2) {
|
|
678
|
+
rd_kafka_buf_read_str(rkbuf, &cluster_id);
|
|
679
|
+
if (cluster_id.str)
|
|
680
|
+
mdi->cluster_id =
|
|
681
|
+
rd_tmpabuf_write_str(&tbuf, cluster_id.str);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
mdi->controller_id = -1;
|
|
685
|
+
if (ApiVersion >= 1) {
|
|
686
|
+
rd_kafka_buf_read_i32(rkbuf, &controller_id);
|
|
687
|
+
mdi->controller_id = controller_id;
|
|
688
|
+
rd_rkb_dbg(rkb, METADATA, "METADATA",
|
|
689
|
+
"ClusterId: %.*s, ControllerId: %" PRId32,
|
|
690
|
+
RD_KAFKAP_STR_PR(&cluster_id), controller_id);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
qsort(mdi->brokers, md->broker_cnt, sizeof(mdi->brokers[i]),
|
|
694
|
+
rd_kafka_metadata_broker_internal_cmp);
|
|
695
|
+
memcpy(mdi->brokers_sorted, md->brokers,
|
|
696
|
+
sizeof(*mdi->brokers_sorted) * md->broker_cnt);
|
|
697
|
+
qsort(mdi->brokers_sorted, md->broker_cnt, sizeof(*mdi->brokers_sorted),
|
|
698
|
+
rd_kafka_metadata_broker_cmp);
|
|
699
|
+
|
|
700
|
+
/* Read TopicMetadata */
|
|
701
|
+
rd_kafka_buf_read_arraycnt(rkbuf, &md->topic_cnt, RD_KAFKAP_TOPICS_MAX);
|
|
702
|
+
rd_rkb_dbg(rkb, METADATA, "METADATA", "%i brokers, %i topics",
|
|
703
|
+
md->broker_cnt, md->topic_cnt);
|
|
704
|
+
|
|
705
|
+
if (!(md->topics =
|
|
706
|
+
rd_tmpabuf_alloc(&tbuf, md->topic_cnt * sizeof(*md->topics))))
|
|
707
|
+
rd_kafka_buf_parse_fail(
|
|
708
|
+
rkbuf, "%d topics: tmpabuf memory shortage", md->topic_cnt);
|
|
709
|
+
|
|
710
|
+
if (!(mdi->topics = rd_tmpabuf_alloc(&tbuf, md->topic_cnt *
|
|
711
|
+
sizeof(*mdi->topics))))
|
|
712
|
+
rd_kafka_buf_parse_fail(
|
|
713
|
+
rkbuf, "%d internal topics: tmpabuf memory shortage",
|
|
714
|
+
md->topic_cnt);
|
|
715
|
+
|
|
716
|
+
for (i = 0; i < md->topic_cnt; i++) {
|
|
717
|
+
rd_kafka_buf_read_i16a(rkbuf, md->topics[i].err);
|
|
718
|
+
rd_kafka_buf_read_str_tmpabuf(rkbuf, &tbuf,
|
|
719
|
+
md->topics[i].topic);
|
|
720
|
+
|
|
721
|
+
if (ApiVersion >= 10) {
|
|
722
|
+
rd_kafka_buf_read_uuid(rkbuf, &mdi->topics[i].topic_id);
|
|
723
|
+
} else {
|
|
724
|
+
mdi->topics[i].topic_id = RD_KAFKA_UUID_ZERO;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (ApiVersion >= 1)
|
|
728
|
+
rd_kafka_buf_read_bool(rkbuf,
|
|
729
|
+
&mdi->topics[i].is_internal);
|
|
730
|
+
|
|
731
|
+
/* PartitionMetadata */
|
|
732
|
+
rd_kafka_buf_read_arraycnt(rkbuf, &md->topics[i].partition_cnt,
|
|
733
|
+
RD_KAFKAP_PARTITIONS_MAX);
|
|
734
|
+
|
|
735
|
+
if (!(md->topics[i].partitions = rd_tmpabuf_alloc(
|
|
736
|
+
&tbuf, md->topics[i].partition_cnt *
|
|
737
|
+
sizeof(*md->topics[i].partitions))))
|
|
738
|
+
rd_kafka_buf_parse_fail(rkbuf,
|
|
739
|
+
"%s: %d partitions: "
|
|
740
|
+
"tmpabuf memory shortage",
|
|
741
|
+
md->topics[i].topic,
|
|
742
|
+
md->topics[i].partition_cnt);
|
|
743
|
+
|
|
744
|
+
if (!(mdi->topics[i].partitions = rd_tmpabuf_alloc(
|
|
745
|
+
&tbuf, md->topics[i].partition_cnt *
|
|
746
|
+
sizeof(*mdi->topics[i].partitions))))
|
|
747
|
+
rd_kafka_buf_parse_fail(rkbuf,
|
|
748
|
+
"%s: %d internal partitions: "
|
|
749
|
+
"tmpabuf memory shortage",
|
|
750
|
+
md->topics[i].topic,
|
|
751
|
+
md->topics[i].partition_cnt);
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
for (j = 0; j < md->topics[i].partition_cnt; j++) {
|
|
755
|
+
rd_kafka_buf_read_i16a(rkbuf,
|
|
756
|
+
md->topics[i].partitions[j].err);
|
|
757
|
+
rd_kafka_buf_read_i32a(rkbuf,
|
|
758
|
+
md->topics[i].partitions[j].id);
|
|
759
|
+
rd_kafka_buf_read_i32a(
|
|
760
|
+
rkbuf, md->topics[i].partitions[j].leader);
|
|
761
|
+
|
|
762
|
+
mdi->topics[i].partitions[j].id =
|
|
763
|
+
md->topics[i].partitions[j].id;
|
|
764
|
+
if (ApiVersion >= 7) {
|
|
765
|
+
rd_kafka_buf_read_i32(
|
|
766
|
+
rkbuf,
|
|
767
|
+
&mdi->topics[i].partitions[j].leader_epoch);
|
|
768
|
+
if (!has_reliable_leader_epochs)
|
|
769
|
+
mdi->topics[i]
|
|
770
|
+
.partitions[j]
|
|
771
|
+
.leader_epoch = -1;
|
|
772
|
+
} else {
|
|
773
|
+
mdi->topics[i].partitions[j].leader_epoch = -1;
|
|
774
|
+
}
|
|
775
|
+
mdi->topics[i].partitions[j].racks_cnt = 0;
|
|
776
|
+
mdi->topics[i].partitions[j].racks = NULL;
|
|
777
|
+
|
|
778
|
+
/* Replicas */
|
|
779
|
+
rd_kafka_buf_read_arraycnt(
|
|
780
|
+
rkbuf, &md->topics[i].partitions[j].replica_cnt,
|
|
781
|
+
RD_KAFKAP_BROKERS_MAX);
|
|
782
|
+
|
|
783
|
+
if (!(md->topics[i].partitions[j].replicas =
|
|
784
|
+
rd_tmpabuf_alloc(
|
|
785
|
+
&tbuf,
|
|
786
|
+
md->topics[i].partitions[j].replica_cnt *
|
|
787
|
+
sizeof(*md->topics[i]
|
|
788
|
+
.partitions[j]
|
|
789
|
+
.replicas))))
|
|
790
|
+
rd_kafka_buf_parse_fail(
|
|
791
|
+
rkbuf,
|
|
792
|
+
"%s [%" PRId32
|
|
793
|
+
"]: %d replicas: "
|
|
794
|
+
"tmpabuf memory shortage",
|
|
795
|
+
md->topics[i].topic,
|
|
796
|
+
md->topics[i].partitions[j].id,
|
|
797
|
+
md->topics[i].partitions[j].replica_cnt);
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
for (k = 0; k < md->topics[i].partitions[j].replica_cnt;
|
|
801
|
+
k++)
|
|
802
|
+
rd_kafka_buf_read_i32a(
|
|
803
|
+
rkbuf,
|
|
804
|
+
md->topics[i].partitions[j].replicas[k]);
|
|
805
|
+
|
|
806
|
+
/* Isrs */
|
|
807
|
+
rd_kafka_buf_read_arraycnt(
|
|
808
|
+
rkbuf, &md->topics[i].partitions[j].isr_cnt,
|
|
809
|
+
RD_KAFKAP_BROKERS_MAX);
|
|
810
|
+
|
|
811
|
+
if (!(md->topics[i]
|
|
812
|
+
.partitions[j]
|
|
813
|
+
.isrs = rd_tmpabuf_alloc(
|
|
814
|
+
&tbuf,
|
|
815
|
+
md->topics[i].partitions[j].isr_cnt *
|
|
816
|
+
sizeof(
|
|
817
|
+
*md->topics[i].partitions[j].isrs))))
|
|
818
|
+
rd_kafka_buf_parse_fail(
|
|
819
|
+
rkbuf,
|
|
820
|
+
"%s [%" PRId32
|
|
821
|
+
"]: %d isrs: "
|
|
822
|
+
"tmpabuf memory shortage",
|
|
823
|
+
md->topics[i].topic,
|
|
824
|
+
md->topics[i].partitions[j].id,
|
|
825
|
+
md->topics[i].partitions[j].isr_cnt);
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
for (k = 0; k < md->topics[i].partitions[j].isr_cnt;
|
|
829
|
+
k++)
|
|
830
|
+
rd_kafka_buf_read_i32a(
|
|
831
|
+
rkbuf, md->topics[i].partitions[j].isrs[k]);
|
|
832
|
+
|
|
833
|
+
if (ApiVersion >= 5) {
|
|
834
|
+
/* OfflineReplicas int32 array (ignored) */
|
|
835
|
+
int32_t offline_replicas_cnt;
|
|
836
|
+
|
|
837
|
+
/* #OfflineReplicas */
|
|
838
|
+
rd_kafka_buf_read_arraycnt(
|
|
839
|
+
rkbuf, &offline_replicas_cnt,
|
|
840
|
+
RD_KAFKAP_BROKERS_MAX);
|
|
841
|
+
rd_kafka_buf_skip(rkbuf, offline_replicas_cnt *
|
|
842
|
+
sizeof(int32_t));
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
rd_kafka_buf_skip_tags(rkbuf);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
mdi->topics[i].topic_authorized_operations = -1;
|
|
849
|
+
if (ApiVersion >= 8) {
|
|
850
|
+
int32_t TopicAuthorizedOperations;
|
|
851
|
+
/* TopicAuthorizedOperations */
|
|
852
|
+
rd_kafka_buf_read_i32(rkbuf,
|
|
853
|
+
&TopicAuthorizedOperations);
|
|
854
|
+
mdi->topics[i].topic_authorized_operations =
|
|
855
|
+
TopicAuthorizedOperations;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
rd_kafka_buf_skip_tags(rkbuf);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
mdi->cluster_authorized_operations = -1;
|
|
862
|
+
if (ApiVersion >= 8 && ApiVersion <= 10) {
|
|
863
|
+
int32_t ClusterAuthorizedOperations;
|
|
864
|
+
/* ClusterAuthorizedOperations */
|
|
865
|
+
rd_kafka_buf_read_i32(rkbuf, &ClusterAuthorizedOperations);
|
|
866
|
+
mdi->cluster_authorized_operations =
|
|
867
|
+
ClusterAuthorizedOperations;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
if (ApiVersion >= 13) {
|
|
871
|
+
rd_kafka_buf_read_i16(rkbuf, &ErrorCode);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
rd_kafka_buf_skip_tags(rkbuf);
|
|
875
|
+
|
|
876
|
+
if (ErrorCode) {
|
|
877
|
+
rd_rkb_dbg(rkb, METADATA, "METADATA",
|
|
878
|
+
"Metadata response: received top level "
|
|
879
|
+
"error code %" PRId16 ": %s",
|
|
880
|
+
ErrorCode, rd_kafka_err2str(ErrorCode));
|
|
881
|
+
err = ErrorCode;
|
|
882
|
+
goto err;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/* Entire Metadata response now parsed without errors:
|
|
886
|
+
* update our internal state according to the response. */
|
|
887
|
+
|
|
888
|
+
if (md->broker_cnt == 0 && md->topic_cnt == 0) {
|
|
889
|
+
rd_rkb_dbg(rkb, METADATA, "METADATA",
|
|
890
|
+
"No brokers or topics in metadata: should retry");
|
|
891
|
+
err = RD_KAFKA_RESP_ERR__PARTIAL;
|
|
892
|
+
goto err;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/* Update our list of brokers. */
|
|
896
|
+
for (i = 0; i < md->broker_cnt; i++) {
|
|
897
|
+
rd_rkb_dbg(rkb, METADATA, "METADATA",
|
|
898
|
+
" Broker #%i/%i: %s:%i NodeId %" PRId32, i,
|
|
899
|
+
md->broker_cnt, md->brokers[i].host,
|
|
900
|
+
md->brokers[i].port, md->brokers[i].id);
|
|
901
|
+
rd_kafka_broker_update(rkb->rkb_rk, rkb->rkb_proto,
|
|
902
|
+
&md->brokers[i], NULL);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
rd_kafka_metadata_decommission_unavailable_brokers(rk, md, rkb);
|
|
906
|
+
|
|
907
|
+
for (i = 0; i < md->topic_cnt; i++) {
|
|
908
|
+
|
|
909
|
+
/* Ignore topics in blacklist */
|
|
910
|
+
if (rkb->rkb_rk->rk_conf.topic_blacklist &&
|
|
911
|
+
rd_kafka_pattern_match(rkb->rkb_rk->rk_conf.topic_blacklist,
|
|
912
|
+
md->topics[i].topic)) {
|
|
913
|
+
rd_rkb_dbg(rkb, TOPIC | RD_KAFKA_DBG_METADATA,
|
|
914
|
+
"BLACKLIST",
|
|
915
|
+
"Ignoring blacklisted topic \"%s\" "
|
|
916
|
+
"in metadata",
|
|
917
|
+
md->topics[i].topic);
|
|
918
|
+
continue;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/* Sort partitions by partition id */
|
|
922
|
+
qsort(md->topics[i].partitions, md->topics[i].partition_cnt,
|
|
923
|
+
sizeof(*md->topics[i].partitions),
|
|
924
|
+
rd_kafka_metadata_partition_id_cmp);
|
|
925
|
+
qsort(mdi->topics[i].partitions, md->topics[i].partition_cnt,
|
|
926
|
+
sizeof(*mdi->topics[i].partitions),
|
|
927
|
+
rd_kafka_metadata_partition_internal_cmp);
|
|
928
|
+
|
|
929
|
+
if (compute_racks)
|
|
930
|
+
rd_kafka_populate_metadata_topic_racks(&tbuf, i, mdi);
|
|
931
|
+
|
|
932
|
+
/* Update topic state based on the topic metadata */
|
|
933
|
+
rd_kafka_parse_Metadata_update_topic(rkb, &md->topics[i],
|
|
934
|
+
&mdi->topics[i]);
|
|
935
|
+
|
|
936
|
+
if (requested_topics)
|
|
937
|
+
rd_list_free_cb(missing_topics,
|
|
938
|
+
rd_list_remove_cmp(missing_topics,
|
|
939
|
+
md->topics[i].topic,
|
|
940
|
+
(void *)strcmp));
|
|
941
|
+
if (requested_topic_ids)
|
|
942
|
+
rd_list_free_cb(
|
|
943
|
+
missing_topic_ids,
|
|
944
|
+
rd_list_remove_cmp(missing_topic_ids,
|
|
945
|
+
&mdi->topics[i].topic_id,
|
|
946
|
+
(void *)rd_kafka_Uuid_ptr_cmp));
|
|
947
|
+
/* Only update cache when not asking
|
|
948
|
+
* for all topics or cache entry
|
|
949
|
+
* already exists. */
|
|
950
|
+
rd_kafka_wrlock(rk);
|
|
951
|
+
cache_changes += rd_kafka_metadata_cache_topic_update(
|
|
952
|
+
rk, &md->topics[i], &mdi->topics[i],
|
|
953
|
+
rd_false /*propagate later*/,
|
|
954
|
+
/* use has_client_rack rather than
|
|
955
|
+
compute_racks. We need cached rack ids
|
|
956
|
+
only in case we need to rejoin the group
|
|
957
|
+
if they change and client.rack is set
|
|
958
|
+
(KIP-881). */
|
|
959
|
+
has_client_rack, rd_kafka_has_reliable_leader_epochs(rkb));
|
|
960
|
+
rd_kafka_wrunlock(rk);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
/* Requested topics not seen in metadata? Propogate to topic code. */
|
|
964
|
+
if (missing_topics) {
|
|
965
|
+
char *topic;
|
|
966
|
+
rd_rkb_dbg(rkb, TOPIC, "METADATA",
|
|
967
|
+
"%d/%d requested topic(s) seen in metadata"
|
|
968
|
+
" (lookup by name)",
|
|
969
|
+
rd_list_cnt(requested_topics) -
|
|
970
|
+
rd_list_cnt(missing_topics),
|
|
971
|
+
rd_list_cnt(requested_topics));
|
|
972
|
+
for (i = 0; i < rd_list_cnt(missing_topics); i++)
|
|
973
|
+
rd_rkb_dbg(rkb, TOPIC, "METADATA", "wanted %s",
|
|
974
|
+
(char *)(missing_topics->rl_elems[i]));
|
|
975
|
+
RD_LIST_FOREACH(topic, missing_topics, i) {
|
|
976
|
+
rd_kafka_topic_t *rkt;
|
|
977
|
+
|
|
978
|
+
rkt =
|
|
979
|
+
rd_kafka_topic_find(rkb->rkb_rk, topic, 1 /*lock*/);
|
|
980
|
+
if (rkt) {
|
|
981
|
+
/* Received metadata response contained no
|
|
982
|
+
* information about topic 'rkt' and thus
|
|
983
|
+
* indicates the topic is not available in the
|
|
984
|
+
* cluster.
|
|
985
|
+
* Mark the topic as non-existent */
|
|
986
|
+
rd_kafka_topic_wrlock(rkt);
|
|
987
|
+
rd_kafka_topic_set_notexists(
|
|
988
|
+
rkt, RD_KAFKA_RESP_ERR__UNKNOWN_TOPIC);
|
|
989
|
+
rd_kafka_topic_wrunlock(rkt);
|
|
990
|
+
|
|
991
|
+
rd_kafka_topic_destroy0(rkt);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
if (missing_topic_ids) {
|
|
996
|
+
rd_kafka_Uuid_t *topic_id;
|
|
997
|
+
rd_rkb_dbg(rkb, TOPIC, "METADATA",
|
|
998
|
+
"%d/%d requested topic(s) seen in metadata"
|
|
999
|
+
" (lookup by id)",
|
|
1000
|
+
rd_list_cnt(requested_topic_ids) -
|
|
1001
|
+
rd_list_cnt(missing_topic_ids),
|
|
1002
|
+
rd_list_cnt(requested_topic_ids));
|
|
1003
|
+
for (i = 0; i < rd_list_cnt(missing_topic_ids); i++) {
|
|
1004
|
+
rd_kafka_Uuid_t *missing_topic_id =
|
|
1005
|
+
missing_topic_ids->rl_elems[i];
|
|
1006
|
+
rd_rkb_dbg(rkb, TOPIC, "METADATA", "wanted %s",
|
|
1007
|
+
rd_kafka_Uuid_base64str(missing_topic_id));
|
|
1008
|
+
}
|
|
1009
|
+
RD_LIST_FOREACH(topic_id, missing_topic_ids, i) {
|
|
1010
|
+
rd_kafka_topic_t *rkt;
|
|
1011
|
+
|
|
1012
|
+
rd_kafka_rdlock(rk);
|
|
1013
|
+
rkt = rd_kafka_topic_find_by_topic_id(rkb->rkb_rk,
|
|
1014
|
+
*topic_id);
|
|
1015
|
+
rd_kafka_rdunlock(rk);
|
|
1016
|
+
if (rkt) {
|
|
1017
|
+
/* Received metadata response contained no
|
|
1018
|
+
* information about topic 'rkt' and thus
|
|
1019
|
+
* indicates the topic is not available in the
|
|
1020
|
+
* cluster.
|
|
1021
|
+
* Mark the topic as non-existent */
|
|
1022
|
+
rd_kafka_topic_wrlock(rkt);
|
|
1023
|
+
rd_kafka_topic_set_notexists(
|
|
1024
|
+
rkt, RD_KAFKA_RESP_ERR__UNKNOWN_TOPIC);
|
|
1025
|
+
rd_kafka_topic_wrunlock(rkt);
|
|
1026
|
+
|
|
1027
|
+
rd_kafka_topic_destroy0(rkt);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
rd_kafka_wrlock(rkb->rkb_rk);
|
|
1034
|
+
|
|
1035
|
+
rkb->rkb_rk->rk_ts_metadata = rd_clock();
|
|
1036
|
+
|
|
1037
|
+
/* Update cached cluster id. */
|
|
1038
|
+
if (RD_KAFKAP_STR_LEN(&cluster_id) > 0 &&
|
|
1039
|
+
(!rk->rk_clusterid ||
|
|
1040
|
+
rd_kafkap_str_cmp_str(&cluster_id, rk->rk_clusterid))) {
|
|
1041
|
+
rd_rkb_dbg(rkb, BROKER | RD_KAFKA_DBG_GENERIC, "CLUSTERID",
|
|
1042
|
+
"ClusterId update \"%s\" -> \"%.*s\"",
|
|
1043
|
+
rk->rk_clusterid ? rk->rk_clusterid : "",
|
|
1044
|
+
RD_KAFKAP_STR_PR(&cluster_id));
|
|
1045
|
+
if (rk->rk_clusterid) {
|
|
1046
|
+
rd_kafka_log(rk, LOG_WARNING, "CLUSTERID",
|
|
1047
|
+
"Broker %s reports different ClusterId "
|
|
1048
|
+
"\"%.*s\" than previously known \"%s\": "
|
|
1049
|
+
"a client must not be simultaneously "
|
|
1050
|
+
"connected to multiple clusters",
|
|
1051
|
+
rd_kafka_broker_name(rkb),
|
|
1052
|
+
RD_KAFKAP_STR_PR(&cluster_id),
|
|
1053
|
+
rk->rk_clusterid);
|
|
1054
|
+
rd_free(rk->rk_clusterid);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
rk->rk_clusterid = RD_KAFKAP_STR_DUP(&cluster_id);
|
|
1058
|
+
/* rd_kafka_clusterid() waits for a cache update even though
|
|
1059
|
+
* the clusterid is not in the cache itself. (#3620) */
|
|
1060
|
+
cache_changes++;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/* Update controller id. */
|
|
1064
|
+
if (rkb->rkb_rk->rk_controllerid != controller_id) {
|
|
1065
|
+
rd_rkb_dbg(rkb, BROKER, "CONTROLLERID",
|
|
1066
|
+
"ControllerId update %" PRId32 " -> %" PRId32,
|
|
1067
|
+
rkb->rkb_rk->rk_controllerid, controller_id);
|
|
1068
|
+
rkb->rkb_rk->rk_controllerid = controller_id;
|
|
1069
|
+
broker_changes++;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
if (all_topics) {
|
|
1073
|
+
rkb->rkb_rk->rk_ts_full_metadata = rkb->rkb_rk->rk_ts_metadata;
|
|
1074
|
+
rd_rkb_dbg(rkb, METADATA, "METADATA",
|
|
1075
|
+
"Cached full metadata with "
|
|
1076
|
+
" %d topic(s): %s",
|
|
1077
|
+
md->topic_cnt, reason);
|
|
1078
|
+
}
|
|
1079
|
+
/* Remove cache hints for the originally requested topics. */
|
|
1080
|
+
if (requested_topics)
|
|
1081
|
+
rd_kafka_metadata_cache_purge_hints(rk, requested_topics);
|
|
1082
|
+
if (requested_topic_ids)
|
|
1083
|
+
rd_kafka_metadata_cache_purge_hints_by_id(rk,
|
|
1084
|
+
requested_topic_ids);
|
|
1085
|
+
|
|
1086
|
+
if (cache_changes) {
|
|
1087
|
+
rd_kafka_metadata_cache_propagate_changes(rk);
|
|
1088
|
+
rd_kafka_metadata_cache_expiry_start(rk);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
rd_kafka_wrunlock(rkb->rkb_rk);
|
|
1092
|
+
|
|
1093
|
+
if (broker_changes) {
|
|
1094
|
+
/* Broadcast broker metadata changes to listeners. */
|
|
1095
|
+
rd_kafka_brokers_broadcast_state_change(rkb->rkb_rk);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/* Check if cgrp effective subscription is affected by
|
|
1099
|
+
* new topic metadata.
|
|
1100
|
+
* Ignore if this was a broker-only refresh (no topics), or
|
|
1101
|
+
* the request was from the partition assignor (!cgrp_update)
|
|
1102
|
+
* which may contain only a sub-set of the subscribed topics (namely
|
|
1103
|
+
* the effective subscription of available topics) as to not
|
|
1104
|
+
* propagate non-included topics as non-existent. */
|
|
1105
|
+
if (cgrp_update &&
|
|
1106
|
+
(all_topics ||
|
|
1107
|
+
((requested_topics || requested_topic_ids) &&
|
|
1108
|
+
rd_kafka_cgrp_same_subscription_version(
|
|
1109
|
+
rkb->rkb_rk->rk_cgrp, cgrp_subscription_version))))
|
|
1110
|
+
rd_kafka_cgrp_metadata_update_check(rkb->rkb_rk->rk_cgrp,
|
|
1111
|
+
rd_true /*do join*/);
|
|
1112
|
+
|
|
1113
|
+
if (rk->rk_type == RD_KAFKA_CONSUMER && rk->rk_cgrp &&
|
|
1114
|
+
rk->rk_cgrp->rkcg_group_protocol == RD_KAFKA_GROUP_PROTOCOL_CLASSIC)
|
|
1115
|
+
rd_interval_reset(&rk->rk_cgrp->rkcg_join_intvl);
|
|
1116
|
+
|
|
1117
|
+
/* Try to acquire a Producer ID from this broker if we
|
|
1118
|
+
* don't have one. */
|
|
1119
|
+
if (rd_kafka_is_idempotent(rkb->rkb_rk)) {
|
|
1120
|
+
rd_kafka_wrlock(rkb->rkb_rk);
|
|
1121
|
+
rd_kafka_idemp_pid_fsm(rkb->rkb_rk);
|
|
1122
|
+
rd_kafka_wrunlock(rkb->rkb_rk);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
done:
|
|
1126
|
+
if (missing_topics)
|
|
1127
|
+
rd_list_destroy(missing_topics);
|
|
1128
|
+
if (missing_topic_ids)
|
|
1129
|
+
rd_list_destroy(missing_topic_ids);
|
|
1130
|
+
|
|
1131
|
+
/* This metadata request was triggered by someone wanting
|
|
1132
|
+
* the metadata information back as a reply, so send that reply now.
|
|
1133
|
+
* In this case we must not rd_free the metadata memory here,
|
|
1134
|
+
* the requestee will do.
|
|
1135
|
+
* The tbuf is explicitly not destroyed as we return its memory
|
|
1136
|
+
* to the caller. */
|
|
1137
|
+
*mdip = mdi;
|
|
1138
|
+
|
|
1139
|
+
return RD_KAFKA_RESP_ERR_NO_ERROR;
|
|
1140
|
+
|
|
1141
|
+
err_parse:
|
|
1142
|
+
err = rkbuf->rkbuf_err;
|
|
1143
|
+
err:
|
|
1144
|
+
if (requested_topics) {
|
|
1145
|
+
/* Failed requests shall purge cache hints for
|
|
1146
|
+
* the requested topics. */
|
|
1147
|
+
rd_kafka_wrlock(rkb->rkb_rk);
|
|
1148
|
+
rd_kafka_metadata_cache_purge_hints(rk, requested_topics);
|
|
1149
|
+
rd_kafka_wrunlock(rkb->rkb_rk);
|
|
1150
|
+
}
|
|
1151
|
+
if (requested_topic_ids) {
|
|
1152
|
+
/* Failed requests shall purge cache hints for
|
|
1153
|
+
* the requested topics. */
|
|
1154
|
+
rd_kafka_wrlock(rkb->rkb_rk);
|
|
1155
|
+
rd_kafka_metadata_cache_purge_hints_by_id(rk,
|
|
1156
|
+
requested_topic_ids);
|
|
1157
|
+
rd_kafka_wrunlock(rkb->rkb_rk);
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
if (missing_topics)
|
|
1161
|
+
rd_list_destroy(missing_topics);
|
|
1162
|
+
if (missing_topic_ids)
|
|
1163
|
+
rd_list_destroy(missing_topic_ids);
|
|
1164
|
+
rd_tmpabuf_destroy(&tbuf);
|
|
1165
|
+
|
|
1166
|
+
return err;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* @brief Handle a Metadata response message.
|
|
1172
|
+
*
|
|
1173
|
+
* @param request Initial Metadata request, containing the topic information.
|
|
1174
|
+
* Must not be NULL.
|
|
1175
|
+
* We require the topic information while parsing to make sure
|
|
1176
|
+
* that there are no missing topics.
|
|
1177
|
+
* @param mdip A pointer to (rd_kafka_metadata_internal_t *) into which the
|
|
1178
|
+
* metadata will be marshalled (set to NULL on error.)
|
|
1179
|
+
*
|
|
1180
|
+
* @returns an error code on parse failure, else NO_ERROR.
|
|
1181
|
+
*
|
|
1182
|
+
* @locality rdkafka main thread
|
|
1183
|
+
*/
|
|
1184
|
+
rd_kafka_resp_err_t
|
|
1185
|
+
rd_kafka_parse_Metadata(rd_kafka_broker_t *rkb,
|
|
1186
|
+
rd_kafka_buf_t *request,
|
|
1187
|
+
rd_kafka_buf_t *rkbuf,
|
|
1188
|
+
rd_kafka_metadata_internal_t **mdip) {
|
|
1189
|
+
const char *reason = request->rkbuf_u.Metadata.reason;
|
|
1190
|
+
return rd_kafka_parse_Metadata0(rkb, request, rkbuf, mdip, NULL,
|
|
1191
|
+
reason);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* @brief Handle a Metadata response message for admin requests.
|
|
1196
|
+
*
|
|
1197
|
+
* @param request_topics List containing topics in Metadata request. Must not
|
|
1198
|
+
* be NULL. It is more convenient in the Admin flow to
|
|
1199
|
+
* preserve the topic names rather than the initial
|
|
1200
|
+
* Metadata request.
|
|
1201
|
+
* We require the topic information while parsing to make
|
|
1202
|
+
* sure that there are no missing topics.
|
|
1203
|
+
* @param mdip A pointer to (rd_kafka_metadata_internal_t *) into which the
|
|
1204
|
+
* metadata will be marshalled (set to NULL on error.)
|
|
1205
|
+
*
|
|
1206
|
+
* @returns an error code on parse failure, else NO_ERROR.
|
|
1207
|
+
*
|
|
1208
|
+
* @locality rdkafka main thread
|
|
1209
|
+
*/
|
|
1210
|
+
rd_kafka_resp_err_t
|
|
1211
|
+
rd_kafka_parse_Metadata_admin(rd_kafka_broker_t *rkb,
|
|
1212
|
+
rd_kafka_buf_t *rkbuf,
|
|
1213
|
+
rd_list_t *request_topics,
|
|
1214
|
+
rd_kafka_metadata_internal_t **mdip) {
|
|
1215
|
+
return rd_kafka_parse_Metadata0(rkb, NULL, rkbuf, mdip, request_topics,
|
|
1216
|
+
"(admin request)");
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* @brief Add all topics in current cached full metadata
|
|
1222
|
+
* that matches the topics in \p match
|
|
1223
|
+
* to \p tinfos (rd_kafka_topic_info_t *).
|
|
1224
|
+
*
|
|
1225
|
+
* @param errored Any topic or wildcard pattern that did not match
|
|
1226
|
+
* an available topic will be added to this list with
|
|
1227
|
+
* the appropriate error set.
|
|
1228
|
+
*
|
|
1229
|
+
* @returns the number of topics matched and added to \p list
|
|
1230
|
+
*
|
|
1231
|
+
* @locks none
|
|
1232
|
+
* @locality any
|
|
1233
|
+
*/
|
|
1234
|
+
size_t
|
|
1235
|
+
rd_kafka_metadata_topic_match(rd_kafka_t *rk,
|
|
1236
|
+
rd_list_t *tinfos,
|
|
1237
|
+
const rd_kafka_topic_partition_list_t *match,
|
|
1238
|
+
rd_kafka_topic_partition_list_t *errored) {
|
|
1239
|
+
int ti, i;
|
|
1240
|
+
size_t cnt = 0;
|
|
1241
|
+
rd_kafka_topic_partition_list_t *unmatched;
|
|
1242
|
+
rd_list_t cached_topics;
|
|
1243
|
+
const char *topic;
|
|
1244
|
+
|
|
1245
|
+
rd_kafka_rdlock(rk);
|
|
1246
|
+
/* To keep track of which patterns and topics in `match` that
|
|
1247
|
+
* did not match any topic (or matched an errored topic), we
|
|
1248
|
+
* create a set of all topics to match in `unmatched` and then
|
|
1249
|
+
* remove from this set as a match is found.
|
|
1250
|
+
* Whatever remains in `unmatched` after all matching is performed
|
|
1251
|
+
* are the topics and patterns that did not match a topic. */
|
|
1252
|
+
unmatched = rd_kafka_topic_partition_list_copy(match);
|
|
1253
|
+
|
|
1254
|
+
/* For each topic in the cluster, scan through the match list
|
|
1255
|
+
* to find matching topic. */
|
|
1256
|
+
rd_list_init(&cached_topics, rk->rk_metadata_cache.rkmc_cnt, rd_free);
|
|
1257
|
+
rd_kafka_metadata_cache_topics_to_list(rk, &cached_topics, rd_false);
|
|
1258
|
+
RD_LIST_FOREACH(topic, &cached_topics, ti) {
|
|
1259
|
+
const rd_kafka_metadata_topic_internal_t *mdti;
|
|
1260
|
+
const rd_kafka_metadata_topic_t *mdt =
|
|
1261
|
+
rd_kafka_metadata_cache_topic_get(rk, topic, &mdti,
|
|
1262
|
+
rd_true /* valid */);
|
|
1263
|
+
if (!mdt)
|
|
1264
|
+
continue;
|
|
1265
|
+
|
|
1266
|
+
/* Ignore topics in blacklist */
|
|
1267
|
+
if (rk->rk_conf.topic_blacklist &&
|
|
1268
|
+
rd_kafka_pattern_match(rk->rk_conf.topic_blacklist, topic))
|
|
1269
|
+
continue;
|
|
1270
|
+
|
|
1271
|
+
/* Scan for matches */
|
|
1272
|
+
for (i = 0; i < match->cnt; i++) {
|
|
1273
|
+
if (!rd_kafka_topic_match(rk, match->elems[i].topic,
|
|
1274
|
+
topic))
|
|
1275
|
+
continue;
|
|
1276
|
+
|
|
1277
|
+
/* Remove from unmatched */
|
|
1278
|
+
rd_kafka_topic_partition_list_del(
|
|
1279
|
+
unmatched, match->elems[i].topic,
|
|
1280
|
+
RD_KAFKA_PARTITION_UA);
|
|
1281
|
+
|
|
1282
|
+
if (mdt->err) {
|
|
1283
|
+
rd_kafka_topic_partition_list_add(
|
|
1284
|
+
errored, topic, RD_KAFKA_PARTITION_UA)
|
|
1285
|
+
->err = mdt->err;
|
|
1286
|
+
continue; /* Skip errored topics */
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
rd_list_add(tinfos, rd_kafka_topic_info_new_with_rack(
|
|
1290
|
+
topic, mdt->partition_cnt,
|
|
1291
|
+
mdti->partitions));
|
|
1292
|
+
|
|
1293
|
+
cnt++;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
rd_kafka_rdunlock(rk);
|
|
1297
|
+
|
|
1298
|
+
/* Any topics/patterns still in unmatched did not match any
|
|
1299
|
+
* existing topics, add them to `errored`. */
|
|
1300
|
+
for (i = 0; i < unmatched->cnt; i++) {
|
|
1301
|
+
rd_kafka_topic_partition_t *elem = &unmatched->elems[i];
|
|
1302
|
+
|
|
1303
|
+
rd_kafka_topic_partition_list_add(errored, elem->topic,
|
|
1304
|
+
RD_KAFKA_PARTITION_UA)
|
|
1305
|
+
->err = RD_KAFKA_RESP_ERR__UNKNOWN_TOPIC;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
rd_kafka_topic_partition_list_destroy(unmatched);
|
|
1309
|
+
rd_list_destroy(&cached_topics);
|
|
1310
|
+
|
|
1311
|
+
return cnt;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* @brief Add all topics in \p match that matches cached metadata.
|
|
1317
|
+
* @remark MUST NOT be used with wildcard topics,
|
|
1318
|
+
* see rd_kafka_metadata_topic_match() for that.
|
|
1319
|
+
*
|
|
1320
|
+
* @param errored Non-existent and unauthorized topics are added to this
|
|
1321
|
+
* list with the appropriate error code.
|
|
1322
|
+
*
|
|
1323
|
+
* @returns the number of topics matched and added to \p tinfos
|
|
1324
|
+
* @locks none
|
|
1325
|
+
*/
|
|
1326
|
+
size_t
|
|
1327
|
+
rd_kafka_metadata_topic_filter(rd_kafka_t *rk,
|
|
1328
|
+
rd_list_t *tinfos,
|
|
1329
|
+
const rd_kafka_topic_partition_list_t *match,
|
|
1330
|
+
rd_kafka_topic_partition_list_t *errored) {
|
|
1331
|
+
int i;
|
|
1332
|
+
size_t cnt = 0;
|
|
1333
|
+
|
|
1334
|
+
rd_kafka_rdlock(rk);
|
|
1335
|
+
/* For each topic in match, look up the topic in the cache. */
|
|
1336
|
+
for (i = 0; i < match->cnt; i++) {
|
|
1337
|
+
const char *topic = match->elems[i].topic;
|
|
1338
|
+
const rd_kafka_metadata_topic_t *mtopic = NULL;
|
|
1339
|
+
|
|
1340
|
+
/* Ignore topics in blacklist */
|
|
1341
|
+
if (rk->rk_conf.topic_blacklist &&
|
|
1342
|
+
rd_kafka_pattern_match(rk->rk_conf.topic_blacklist, topic))
|
|
1343
|
+
continue;
|
|
1344
|
+
|
|
1345
|
+
struct rd_kafka_metadata_cache_entry *rkmce =
|
|
1346
|
+
rd_kafka_metadata_cache_find(rk, topic, 1 /* valid */);
|
|
1347
|
+
if (rkmce)
|
|
1348
|
+
mtopic = &rkmce->rkmce_mtopic;
|
|
1349
|
+
|
|
1350
|
+
if (!mtopic)
|
|
1351
|
+
rd_kafka_topic_partition_list_add(errored, topic,
|
|
1352
|
+
RD_KAFKA_PARTITION_UA)
|
|
1353
|
+
->err = RD_KAFKA_RESP_ERR__UNKNOWN_TOPIC;
|
|
1354
|
+
else if (mtopic->err)
|
|
1355
|
+
rd_kafka_topic_partition_list_add(errored, topic,
|
|
1356
|
+
RD_KAFKA_PARTITION_UA)
|
|
1357
|
+
->err = mtopic->err;
|
|
1358
|
+
else {
|
|
1359
|
+
rd_list_add(tinfos,
|
|
1360
|
+
rd_kafka_topic_info_new_with_rack(
|
|
1361
|
+
topic, mtopic->partition_cnt,
|
|
1362
|
+
rkmce->rkmce_metadata_internal_topic
|
|
1363
|
+
.partitions));
|
|
1364
|
+
|
|
1365
|
+
cnt++;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
rd_kafka_rdunlock(rk);
|
|
1369
|
+
|
|
1370
|
+
return cnt;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
void rd_kafka_metadata_log(rd_kafka_t *rk,
|
|
1375
|
+
const char *fac,
|
|
1376
|
+
const struct rd_kafka_metadata *md) {
|
|
1377
|
+
int i;
|
|
1378
|
+
|
|
1379
|
+
rd_kafka_dbg(rk, METADATA, fac,
|
|
1380
|
+
"Metadata with %d broker(s) and %d topic(s):",
|
|
1381
|
+
md->broker_cnt, md->topic_cnt);
|
|
1382
|
+
|
|
1383
|
+
for (i = 0; i < md->broker_cnt; i++) {
|
|
1384
|
+
rd_kafka_dbg(rk, METADATA, fac,
|
|
1385
|
+
" Broker #%i/%i: %s:%i NodeId %" PRId32, i,
|
|
1386
|
+
md->broker_cnt, md->brokers[i].host,
|
|
1387
|
+
md->brokers[i].port, md->brokers[i].id);
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
for (i = 0; i < md->topic_cnt; i++) {
|
|
1391
|
+
rd_kafka_dbg(
|
|
1392
|
+
rk, METADATA, fac,
|
|
1393
|
+
" Topic #%i/%i: %s with %i partitions%s%s", i,
|
|
1394
|
+
md->topic_cnt, md->topics[i].topic,
|
|
1395
|
+
md->topics[i].partition_cnt, md->topics[i].err ? ": " : "",
|
|
1396
|
+
md->topics[i].err ? rd_kafka_err2str(md->topics[i].err)
|
|
1397
|
+
: "");
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
|
|
1402
|
+
|
|
1403
|
+
/**
|
|
1404
|
+
* @brief Refresh metadata for \p topics
|
|
1405
|
+
*
|
|
1406
|
+
* @param rk: used to look up usable broker if \p rkb is NULL.
|
|
1407
|
+
* @param rkb: use this broker, unless NULL then any usable broker from \p rk
|
|
1408
|
+
* @param force: force refresh even if topics are up-to-date in cache
|
|
1409
|
+
* @param allow_auto_create: Enable/disable auto creation of topics
|
|
1410
|
+
* (through MetadataRequest). Requires a modern
|
|
1411
|
+
* broker version.
|
|
1412
|
+
* Takes precedence over allow.auto.create.topics.
|
|
1413
|
+
* @param cgrp_update: Allow consumer group state update on response.
|
|
1414
|
+
*
|
|
1415
|
+
* @returns an error code
|
|
1416
|
+
*
|
|
1417
|
+
* @locality any
|
|
1418
|
+
* @locks none
|
|
1419
|
+
*/
|
|
1420
|
+
rd_kafka_resp_err_t
|
|
1421
|
+
rd_kafka_metadata_refresh_topics(rd_kafka_t *rk,
|
|
1422
|
+
rd_kafka_broker_t *rkb,
|
|
1423
|
+
const rd_list_t *topics,
|
|
1424
|
+
rd_bool_t force,
|
|
1425
|
+
rd_bool_t allow_auto_create,
|
|
1426
|
+
rd_bool_t cgrp_update,
|
|
1427
|
+
int32_t cgrp_subscription_version,
|
|
1428
|
+
const char *reason) {
|
|
1429
|
+
rd_list_t q_topics;
|
|
1430
|
+
int destroy_rkb = 0;
|
|
1431
|
+
|
|
1432
|
+
if (!rk) {
|
|
1433
|
+
rd_assert(rkb);
|
|
1434
|
+
rk = rkb->rkb_rk;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
rd_kafka_wrlock(rk);
|
|
1438
|
+
|
|
1439
|
+
if (!rkb) {
|
|
1440
|
+
if (!(rkb = rd_kafka_broker_any_usable(
|
|
1441
|
+
rk, RD_POLL_NOWAIT, RD_DONT_LOCK, 0, reason))) {
|
|
1442
|
+
/* Hint cache that something is interested in
|
|
1443
|
+
* these topics so that they will be included in
|
|
1444
|
+
* a future all known_topics query. */
|
|
1445
|
+
rd_kafka_metadata_cache_hint(rk, topics, NULL,
|
|
1446
|
+
RD_KAFKA_RESP_ERR__NOENT);
|
|
1447
|
+
|
|
1448
|
+
rd_kafka_wrunlock(rk);
|
|
1449
|
+
rd_kafka_dbg(rk, METADATA, "METADATA",
|
|
1450
|
+
"Skipping metadata refresh of %d topic(s):"
|
|
1451
|
+
" %s: no usable brokers",
|
|
1452
|
+
rd_list_cnt(topics), reason);
|
|
1453
|
+
|
|
1454
|
+
return RD_KAFKA_RESP_ERR__TRANSPORT;
|
|
1455
|
+
}
|
|
1456
|
+
destroy_rkb = 1;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
rd_list_init(&q_topics, rd_list_cnt(topics), rd_free);
|
|
1460
|
+
|
|
1461
|
+
if (!force) {
|
|
1462
|
+
|
|
1463
|
+
/* Hint cache of upcoming MetadataRequest and filter
|
|
1464
|
+
* out any topics that are already being requested.
|
|
1465
|
+
* q_topics will contain remaining topics to query. */
|
|
1466
|
+
rd_kafka_metadata_cache_hint(rk, topics, &q_topics,
|
|
1467
|
+
RD_KAFKA_RESP_ERR__WAIT_CACHE);
|
|
1468
|
+
rd_kafka_wrunlock(rk);
|
|
1469
|
+
|
|
1470
|
+
if (rd_list_cnt(&q_topics) == 0) {
|
|
1471
|
+
/* No topics need new query. */
|
|
1472
|
+
rd_kafka_dbg(rk, METADATA, "METADATA",
|
|
1473
|
+
"Skipping metadata refresh of "
|
|
1474
|
+
"%d topic(s): %s: "
|
|
1475
|
+
"already being requested",
|
|
1476
|
+
rd_list_cnt(topics), reason);
|
|
1477
|
+
rd_list_destroy(&q_topics);
|
|
1478
|
+
if (destroy_rkb)
|
|
1479
|
+
rd_kafka_broker_destroy(rkb);
|
|
1480
|
+
return RD_KAFKA_RESP_ERR_NO_ERROR;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
} else {
|
|
1484
|
+
rd_kafka_wrunlock(rk);
|
|
1485
|
+
rd_list_copy_to(&q_topics, topics, rd_list_string_copy, NULL);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
rd_kafka_dbg(rk, METADATA, "METADATA",
|
|
1489
|
+
"Requesting metadata for %d/%d topics: %s",
|
|
1490
|
+
rd_list_cnt(&q_topics), rd_list_cnt(topics), reason);
|
|
1491
|
+
|
|
1492
|
+
rd_kafka_MetadataRequest(
|
|
1493
|
+
rkb, &q_topics, NULL, reason, allow_auto_create, cgrp_update,
|
|
1494
|
+
cgrp_subscription_version, rd_false /* force_racks */, NULL);
|
|
1495
|
+
|
|
1496
|
+
rd_list_destroy(&q_topics);
|
|
1497
|
+
|
|
1498
|
+
if (destroy_rkb)
|
|
1499
|
+
rd_kafka_broker_destroy(rkb);
|
|
1500
|
+
|
|
1501
|
+
return RD_KAFKA_RESP_ERR_NO_ERROR;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* @brief Refresh metadata for known topics
|
|
1507
|
+
*
|
|
1508
|
+
* @param rk: used to look up usable broker if \p rkb is NULL.
|
|
1509
|
+
* @param rkb: use this broker, unless NULL then any usable broker from \p rk
|
|
1510
|
+
* @param force: refresh even if cache is up-to-date
|
|
1511
|
+
*
|
|
1512
|
+
* @returns an error code (__UNKNOWN_TOPIC if there are no local topics)
|
|
1513
|
+
*
|
|
1514
|
+
* @locality any
|
|
1515
|
+
* @locks none
|
|
1516
|
+
*/
|
|
1517
|
+
rd_kafka_resp_err_t
|
|
1518
|
+
rd_kafka_metadata_refresh_known_topics(rd_kafka_t *rk,
|
|
1519
|
+
rd_kafka_broker_t *rkb,
|
|
1520
|
+
rd_bool_t force,
|
|
1521
|
+
const char *reason) {
|
|
1522
|
+
rd_list_t topics;
|
|
1523
|
+
rd_kafka_resp_err_t err;
|
|
1524
|
+
int cache_cnt = 0;
|
|
1525
|
+
rd_bool_t allow_auto_create_topics;
|
|
1526
|
+
|
|
1527
|
+
if (!rk)
|
|
1528
|
+
rk = rkb->rkb_rk;
|
|
1529
|
+
|
|
1530
|
+
rd_list_init(&topics, 8, rd_free);
|
|
1531
|
+
rd_kafka_local_topics_to_list(rk, &topics, &cache_cnt);
|
|
1532
|
+
|
|
1533
|
+
/* Allow topic auto creation if there are locally known topics (rkt)
|
|
1534
|
+
* and not just cached (to be queried) topics. */
|
|
1535
|
+
allow_auto_create_topics = rk->rk_conf.allow_auto_create_topics &&
|
|
1536
|
+
rd_list_cnt(&topics) > cache_cnt;
|
|
1537
|
+
|
|
1538
|
+
if (rd_list_cnt(&topics) == 0)
|
|
1539
|
+
err = RD_KAFKA_RESP_ERR__UNKNOWN_TOPIC;
|
|
1540
|
+
else
|
|
1541
|
+
err = rd_kafka_metadata_refresh_topics(
|
|
1542
|
+
rk, rkb, &topics, force, allow_auto_create_topics,
|
|
1543
|
+
rd_false /*!cgrp_update*/, -1, reason);
|
|
1544
|
+
|
|
1545
|
+
rd_list_destroy(&topics);
|
|
1546
|
+
|
|
1547
|
+
return err;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
|
|
1551
|
+
/**
|
|
1552
|
+
* @brief Refresh metadata for known and subscribed topics.
|
|
1553
|
+
*
|
|
1554
|
+
* @param rk used to look up usable broker if \p rkb is NULL..
|
|
1555
|
+
* @param rkb use this broker, unless NULL then any usable broker from \p rk.
|
|
1556
|
+
* @param reason reason of refresh, used in debug logs.
|
|
1557
|
+
*
|
|
1558
|
+
* @returns an error code (ERR__UNKNOWN_TOPIC if no topics are desired).
|
|
1559
|
+
*
|
|
1560
|
+
* @locality rdkafka main thread
|
|
1561
|
+
* @locks_required none
|
|
1562
|
+
* @locks_acquired rk(read)
|
|
1563
|
+
*/
|
|
1564
|
+
rd_kafka_resp_err_t
|
|
1565
|
+
rd_kafka_metadata_refresh_consumer_topics(rd_kafka_t *rk,
|
|
1566
|
+
rd_kafka_broker_t *rkb,
|
|
1567
|
+
const char *reason) {
|
|
1568
|
+
rd_list_t topics;
|
|
1569
|
+
rd_kafka_resp_err_t err;
|
|
1570
|
+
rd_kafka_cgrp_t *rkcg;
|
|
1571
|
+
rd_bool_t allow_auto_create_topics =
|
|
1572
|
+
rk->rk_conf.allow_auto_create_topics;
|
|
1573
|
+
int cache_cnt = 0;
|
|
1574
|
+
|
|
1575
|
+
if (!rk) {
|
|
1576
|
+
rd_assert(rkb);
|
|
1577
|
+
rk = rkb->rkb_rk;
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
rkcg = rk->rk_cgrp;
|
|
1581
|
+
rd_assert(rkcg != NULL);
|
|
1582
|
+
|
|
1583
|
+
if (rkcg->rkcg_group_protocol == RD_KAFKA_GROUP_PROTOCOL_CLASSIC &&
|
|
1584
|
+
rkcg->rkcg_flags & RD_KAFKA_CGRP_F_WILDCARD_SUBSCRIPTION) {
|
|
1585
|
+
/* If there is a wildcard subscription we need to request
|
|
1586
|
+
* all topics in the cluster so that we can perform
|
|
1587
|
+
* regexp matching. */
|
|
1588
|
+
return rd_kafka_metadata_refresh_all(rk, rkb, reason);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
rd_list_init(&topics, 8, rd_free);
|
|
1592
|
+
|
|
1593
|
+
/* Add locally known topics, i.e., those that are currently
|
|
1594
|
+
* being consumed or otherwise referenced through topic_t objects. */
|
|
1595
|
+
rd_kafka_local_topics_to_list(rk, &topics, &cache_cnt);
|
|
1596
|
+
if (rd_list_cnt(&topics) == cache_cnt)
|
|
1597
|
+
allow_auto_create_topics = rd_false;
|
|
1598
|
+
|
|
1599
|
+
/* Add subscribed (non-wildcard) topics, if any. */
|
|
1600
|
+
if (rkcg->rkcg_subscription)
|
|
1601
|
+
rd_kafka_topic_partition_list_get_topic_names(
|
|
1602
|
+
rkcg->rkcg_subscription, &topics,
|
|
1603
|
+
rd_false /*no wildcards*/);
|
|
1604
|
+
|
|
1605
|
+
if (rd_list_cnt(&topics) == 0)
|
|
1606
|
+
err = RD_KAFKA_RESP_ERR__UNKNOWN_TOPIC;
|
|
1607
|
+
else
|
|
1608
|
+
err = rd_kafka_metadata_refresh_topics(
|
|
1609
|
+
rk, rkb, &topics, rd_true /*force*/,
|
|
1610
|
+
allow_auto_create_topics, rd_true /*cgrp_update*/,
|
|
1611
|
+
rd_atomic32_get(&rkcg->rkcg_subscription_version), reason);
|
|
1612
|
+
|
|
1613
|
+
rd_list_destroy(&topics);
|
|
1614
|
+
|
|
1615
|
+
return err;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
/**
|
|
1620
|
+
* @brief Refresh broker list by metadata.
|
|
1621
|
+
*
|
|
1622
|
+
* Attempts to use sparse metadata request if possible, else falls back
|
|
1623
|
+
* on a full metadata request. (NOTE: sparse not implemented, KIP-4)
|
|
1624
|
+
*
|
|
1625
|
+
* @param rk: used to look up usable broker if \p rkb is NULL.
|
|
1626
|
+
* @param rkb: use this broker, unless NULL then any usable broker from \p rk
|
|
1627
|
+
*
|
|
1628
|
+
* @returns an error code
|
|
1629
|
+
*
|
|
1630
|
+
* @locality any
|
|
1631
|
+
* @locks none
|
|
1632
|
+
*/
|
|
1633
|
+
rd_kafka_resp_err_t rd_kafka_metadata_refresh_brokers(rd_kafka_t *rk,
|
|
1634
|
+
rd_kafka_broker_t *rkb,
|
|
1635
|
+
const char *reason) {
|
|
1636
|
+
return rd_kafka_metadata_request(rk, rkb, NULL /*brokers only*/,
|
|
1637
|
+
rd_false /*!allow auto create topics*/,
|
|
1638
|
+
rd_false /*no cgrp update */,
|
|
1639
|
+
-1 /* same subscription version */,
|
|
1640
|
+
reason, NULL);
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
|
|
1644
|
+
|
|
1645
|
+
/**
|
|
1646
|
+
* @brief Refresh metadata for all topics in cluster.
|
|
1647
|
+
* This is a full metadata request which might be taxing on the
|
|
1648
|
+
* broker if the cluster has many topics.
|
|
1649
|
+
*
|
|
1650
|
+
* @locality any
|
|
1651
|
+
* @locks none
|
|
1652
|
+
*/
|
|
1653
|
+
rd_kafka_resp_err_t rd_kafka_metadata_refresh_all(rd_kafka_t *rk,
|
|
1654
|
+
rd_kafka_broker_t *rkb,
|
|
1655
|
+
const char *reason) {
|
|
1656
|
+
int destroy_rkb = 0;
|
|
1657
|
+
rd_list_t topics;
|
|
1658
|
+
|
|
1659
|
+
if (!rk) {
|
|
1660
|
+
rd_assert(rkb);
|
|
1661
|
+
rk = rkb->rkb_rk;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
if (!rkb) {
|
|
1665
|
+
if (!(rkb = rd_kafka_broker_any_usable(rk, RD_POLL_NOWAIT,
|
|
1666
|
+
RD_DO_LOCK, 0, reason)))
|
|
1667
|
+
return RD_KAFKA_RESP_ERR__TRANSPORT;
|
|
1668
|
+
destroy_rkb = 1;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
rd_list_init(&topics, 0, NULL); /* empty list = all topics */
|
|
1672
|
+
rd_kafka_MetadataRequest(
|
|
1673
|
+
rkb, &topics, NULL, reason, rd_false /*no auto create*/,
|
|
1674
|
+
rd_true /*cgrp update*/, -1 /* same subscription version */,
|
|
1675
|
+
rd_false /* force_rack */, NULL);
|
|
1676
|
+
rd_list_destroy(&topics);
|
|
1677
|
+
|
|
1678
|
+
if (destroy_rkb)
|
|
1679
|
+
rd_kafka_broker_destroy(rkb);
|
|
1680
|
+
|
|
1681
|
+
return RD_KAFKA_RESP_ERR_NO_ERROR;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
|
|
1687
|
+
* @brief Lower-level Metadata request that takes a callback (with replyq set)
|
|
1688
|
+
* which will be triggered after parsing is complete.
|
|
1689
|
+
*
|
|
1690
|
+
* @param cgrp_update Allow consumer group updates from the response.
|
|
1691
|
+
*
|
|
1692
|
+
* @locks none
|
|
1693
|
+
* @locality any
|
|
1694
|
+
*/
|
|
1695
|
+
rd_kafka_resp_err_t
|
|
1696
|
+
rd_kafka_metadata_request(rd_kafka_t *rk,
|
|
1697
|
+
rd_kafka_broker_t *rkb,
|
|
1698
|
+
const rd_list_t *topics,
|
|
1699
|
+
rd_bool_t allow_auto_create_topics,
|
|
1700
|
+
rd_bool_t cgrp_update,
|
|
1701
|
+
int32_t cgrp_subscription_version,
|
|
1702
|
+
const char *reason,
|
|
1703
|
+
rd_kafka_op_t *rko) {
|
|
1704
|
+
int destroy_rkb = 0;
|
|
1705
|
+
|
|
1706
|
+
if (!rkb) {
|
|
1707
|
+
if (!(rkb = rd_kafka_broker_any_usable(rk, RD_POLL_NOWAIT,
|
|
1708
|
+
RD_DO_LOCK, 0, reason)))
|
|
1709
|
+
return RD_KAFKA_RESP_ERR__TRANSPORT;
|
|
1710
|
+
destroy_rkb = 1;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
rd_kafka_MetadataRequest(
|
|
1714
|
+
rkb, topics, NULL, reason, allow_auto_create_topics, cgrp_update,
|
|
1715
|
+
cgrp_subscription_version, rd_false /* force racks */, rko);
|
|
1716
|
+
|
|
1717
|
+
if (destroy_rkb)
|
|
1718
|
+
rd_kafka_broker_destroy(rkb);
|
|
1719
|
+
|
|
1720
|
+
return RD_KAFKA_RESP_ERR_NO_ERROR;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
|
|
1724
|
+
/**
|
|
1725
|
+
* @brief Query timer callback to trigger refresh for topics
|
|
1726
|
+
* that have partitions missing their leaders.
|
|
1727
|
+
*
|
|
1728
|
+
* @locks none
|
|
1729
|
+
* @locality rdkafka main thread
|
|
1730
|
+
*/
|
|
1731
|
+
static void rd_kafka_metadata_leader_query_tmr_cb(rd_kafka_timers_t *rkts,
|
|
1732
|
+
void *arg) {
|
|
1733
|
+
rd_kafka_t *rk = rkts->rkts_rk;
|
|
1734
|
+
rd_kafka_timer_t *rtmr = &rk->rk_metadata_cache.rkmc_query_tmr;
|
|
1735
|
+
rd_kafka_topic_t *rkt;
|
|
1736
|
+
rd_list_t topics;
|
|
1737
|
+
|
|
1738
|
+
rd_kafka_wrlock(rk);
|
|
1739
|
+
rd_list_init(&topics, rk->rk_topic_cnt, rd_free);
|
|
1740
|
+
|
|
1741
|
+
TAILQ_FOREACH(rkt, &rk->rk_topics, rkt_link) {
|
|
1742
|
+
int i, require_metadata;
|
|
1743
|
+
rd_kafka_topic_rdlock(rkt);
|
|
1744
|
+
|
|
1745
|
+
if (rkt->rkt_state == RD_KAFKA_TOPIC_S_NOTEXISTS) {
|
|
1746
|
+
/* Skip topics that are known to not exist. */
|
|
1747
|
+
rd_kafka_topic_rdunlock(rkt);
|
|
1748
|
+
continue;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
require_metadata =
|
|
1752
|
+
rkt->rkt_flags & RD_KAFKA_TOPIC_F_LEADER_UNAVAIL;
|
|
1753
|
+
|
|
1754
|
+
/* Check if any partitions are missing brokers. */
|
|
1755
|
+
for (i = 0; !require_metadata && i < rkt->rkt_partition_cnt;
|
|
1756
|
+
i++) {
|
|
1757
|
+
rd_kafka_toppar_t *rktp = rkt->rkt_p[i];
|
|
1758
|
+
rd_kafka_toppar_lock(rktp);
|
|
1759
|
+
require_metadata =
|
|
1760
|
+
!rktp->rktp_broker && !rktp->rktp_next_broker;
|
|
1761
|
+
rd_kafka_toppar_unlock(rktp);
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
if (require_metadata || rkt->rkt_partition_cnt == 0)
|
|
1765
|
+
rd_list_add(&topics, rd_strdup(rkt->rkt_topic->str));
|
|
1766
|
+
|
|
1767
|
+
rd_kafka_topic_rdunlock(rkt);
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
rd_kafka_wrunlock(rk);
|
|
1771
|
+
|
|
1772
|
+
if (rd_list_cnt(&topics) == 0) {
|
|
1773
|
+
/* No leader-less topics+partitions, stop the timer. */
|
|
1774
|
+
rd_kafka_timer_stop(rkts, rtmr, 1 /*lock*/);
|
|
1775
|
+
} else {
|
|
1776
|
+
rd_kafka_metadata_refresh_topics(
|
|
1777
|
+
rk, NULL, &topics, rd_true /*force*/,
|
|
1778
|
+
rk->rk_conf.allow_auto_create_topics,
|
|
1779
|
+
rd_false /*!cgrp_update*/, -1, "partition leader query");
|
|
1780
|
+
|
|
1781
|
+
/* Back off next query exponentially till we reach
|
|
1782
|
+
* the retry backoff max ms */
|
|
1783
|
+
rd_kafka_timer_exp_backoff(
|
|
1784
|
+
rkts, rtmr, rk->rk_conf.retry_backoff_ms * 1000,
|
|
1785
|
+
rk->rk_conf.retry_backoff_max_ms * 1000,
|
|
1786
|
+
RD_KAFKA_RETRY_JITTER_PERCENT);
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
rd_list_destroy(&topics);
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
|
|
1793
|
+
|
|
1794
|
+
/**
|
|
1795
|
+
* @brief Trigger fast leader query to quickly pick up on leader changes.
|
|
1796
|
+
* The fast leader query is a quick query followed by later queries at
|
|
1797
|
+
* exponentially increased intervals until no topics are missing
|
|
1798
|
+
* leaders.
|
|
1799
|
+
*
|
|
1800
|
+
* @param force If true, run the query immediately without waiting for the
|
|
1801
|
+
* interval.
|
|
1802
|
+
*
|
|
1803
|
+
* @locks none
|
|
1804
|
+
* @locality any
|
|
1805
|
+
*/
|
|
1806
|
+
void rd_kafka_metadata_fast_leader_query(rd_kafka_t *rk, rd_bool_t force) {
|
|
1807
|
+
rd_ts_t next;
|
|
1808
|
+
|
|
1809
|
+
/* Restart the timer if it will speed things up, or if forced. */
|
|
1810
|
+
next = rd_kafka_timer_next(
|
|
1811
|
+
&rk->rk_timers, &rk->rk_metadata_cache.rkmc_query_tmr, 1 /*lock*/);
|
|
1812
|
+
if (force || next == -1 /* not started */ ||
|
|
1813
|
+
next >
|
|
1814
|
+
(rd_ts_t)rk->rk_conf.metadata_refresh_fast_interval_ms * 1000) {
|
|
1815
|
+
rd_kafka_dbg(rk, METADATA | RD_KAFKA_DBG_TOPIC, "FASTQUERY",
|
|
1816
|
+
"Starting fast leader query");
|
|
1817
|
+
rd_kafka_timer_start(
|
|
1818
|
+
&rk->rk_timers, &rk->rk_metadata_cache.rkmc_query_tmr,
|
|
1819
|
+
0 /* First request should be tried immediately */,
|
|
1820
|
+
rd_kafka_metadata_leader_query_tmr_cb, NULL);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
* @brief Create mock Metadata (for testing) based on the provided topics.
|
|
1828
|
+
*
|
|
1829
|
+
* @param topics elements are checked for .topic and .partition_cnt
|
|
1830
|
+
* @param topic_cnt is the number of topic elements in \p topics.
|
|
1831
|
+
* @param replication_factor is the number of replicas of each partition (set to
|
|
1832
|
+
* -1 to ignore).
|
|
1833
|
+
* @param num_brokers is the number of brokers in the cluster.
|
|
1834
|
+
*
|
|
1835
|
+
* @returns a newly allocated metadata object that must be freed with
|
|
1836
|
+
* rd_kafka_metadata_destroy().
|
|
1837
|
+
*
|
|
1838
|
+
* @note \p replication_factor and \p num_brokers must be used together for
|
|
1839
|
+
* setting replicas of each partition.
|
|
1840
|
+
*
|
|
1841
|
+
* @sa rd_kafka_metadata_copy()
|
|
1842
|
+
*/
|
|
1843
|
+
rd_kafka_metadata_t *
|
|
1844
|
+
rd_kafka_metadata_new_topic_mock(const rd_kafka_metadata_topic_t *topics,
|
|
1845
|
+
size_t topic_cnt,
|
|
1846
|
+
int replication_factor,
|
|
1847
|
+
int num_brokers) {
|
|
1848
|
+
rd_kafka_metadata_internal_t *mdi;
|
|
1849
|
+
rd_kafka_metadata_t *md;
|
|
1850
|
+
rd_tmpabuf_t tbuf;
|
|
1851
|
+
size_t i;
|
|
1852
|
+
int curr_broker = 0;
|
|
1853
|
+
|
|
1854
|
+
/* If the replication factor is given, num_brokers must also be given */
|
|
1855
|
+
rd_assert(replication_factor <= 0 || num_brokers > 0);
|
|
1856
|
+
|
|
1857
|
+
/* Allocate contiguous buffer which will back all the memory
|
|
1858
|
+
* needed by the final metadata_t object */
|
|
1859
|
+
rd_tmpabuf_new(&tbuf, sizeof(*mdi), rd_true /*assert on fail*/);
|
|
1860
|
+
|
|
1861
|
+
rd_tmpabuf_add_alloc(&tbuf, topic_cnt * sizeof(*md->topics));
|
|
1862
|
+
rd_tmpabuf_add_alloc(&tbuf, topic_cnt * sizeof(*mdi->topics));
|
|
1863
|
+
rd_tmpabuf_add_alloc(&tbuf, num_brokers * sizeof(*md->brokers));
|
|
1864
|
+
|
|
1865
|
+
/* Calculate total partition count and topic names size before
|
|
1866
|
+
* allocating memory. */
|
|
1867
|
+
for (i = 0; i < topic_cnt; i++) {
|
|
1868
|
+
rd_tmpabuf_add_alloc(&tbuf, 1 + strlen(topics[i].topic));
|
|
1869
|
+
rd_tmpabuf_add_alloc(&tbuf,
|
|
1870
|
+
topics[i].partition_cnt *
|
|
1871
|
+
sizeof(*md->topics[i].partitions));
|
|
1872
|
+
rd_tmpabuf_add_alloc(&tbuf,
|
|
1873
|
+
topics[i].partition_cnt *
|
|
1874
|
+
sizeof(*mdi->topics[i].partitions));
|
|
1875
|
+
if (replication_factor > 0)
|
|
1876
|
+
rd_tmpabuf_add_alloc_times(
|
|
1877
|
+
&tbuf, replication_factor * sizeof(int),
|
|
1878
|
+
topics[i].partition_cnt);
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
rd_tmpabuf_finalize(&tbuf);
|
|
1882
|
+
|
|
1883
|
+
mdi = rd_tmpabuf_alloc(&tbuf, sizeof(*mdi));
|
|
1884
|
+
memset(mdi, 0, sizeof(*mdi));
|
|
1885
|
+
md = &mdi->metadata;
|
|
1886
|
+
|
|
1887
|
+
md->topic_cnt = (int)topic_cnt;
|
|
1888
|
+
md->topics =
|
|
1889
|
+
rd_tmpabuf_alloc(&tbuf, md->topic_cnt * sizeof(*md->topics));
|
|
1890
|
+
mdi->topics =
|
|
1891
|
+
rd_tmpabuf_alloc(&tbuf, md->topic_cnt * sizeof(*mdi->topics));
|
|
1892
|
+
|
|
1893
|
+
md->broker_cnt = num_brokers;
|
|
1894
|
+
mdi->brokers =
|
|
1895
|
+
rd_tmpabuf_alloc(&tbuf, md->broker_cnt * sizeof(*mdi->brokers));
|
|
1896
|
+
|
|
1897
|
+
for (i = 0; i < (size_t)md->topic_cnt; i++) {
|
|
1898
|
+
int j;
|
|
1899
|
+
|
|
1900
|
+
md->topics[i].topic =
|
|
1901
|
+
rd_tmpabuf_write_str(&tbuf, topics[i].topic);
|
|
1902
|
+
md->topics[i].partition_cnt = topics[i].partition_cnt;
|
|
1903
|
+
md->topics[i].err = RD_KAFKA_RESP_ERR_NO_ERROR;
|
|
1904
|
+
|
|
1905
|
+
md->topics[i].partitions = rd_tmpabuf_alloc(
|
|
1906
|
+
&tbuf, md->topics[i].partition_cnt *
|
|
1907
|
+
sizeof(*md->topics[i].partitions));
|
|
1908
|
+
mdi->topics[i].partitions = rd_tmpabuf_alloc(
|
|
1909
|
+
&tbuf, md->topics[i].partition_cnt *
|
|
1910
|
+
sizeof(*mdi->topics[i].partitions));
|
|
1911
|
+
|
|
1912
|
+
for (j = 0; j < md->topics[i].partition_cnt; j++) {
|
|
1913
|
+
int k;
|
|
1914
|
+
memset(&md->topics[i].partitions[j], 0,
|
|
1915
|
+
sizeof(md->topics[i].partitions[j]));
|
|
1916
|
+
memset(&mdi->topics[i].partitions[j], 0,
|
|
1917
|
+
sizeof(mdi->topics[i].partitions[j]));
|
|
1918
|
+
md->topics[i].partitions[j].id = j;
|
|
1919
|
+
mdi->topics[i].partitions[j].id = j;
|
|
1920
|
+
mdi->topics[i].partitions[j].leader_epoch = -1;
|
|
1921
|
+
mdi->topics[i].partitions[j].racks_cnt = 0;
|
|
1922
|
+
mdi->topics[i].partitions[j].racks = NULL;
|
|
1923
|
+
md->topics[i].partitions[j].id = j;
|
|
1924
|
+
|
|
1925
|
+
/* In case replication_factor is not given, don't set
|
|
1926
|
+
* replicas. */
|
|
1927
|
+
if (replication_factor <= 0)
|
|
1928
|
+
continue;
|
|
1929
|
+
|
|
1930
|
+
md->topics[i].partitions[j].replicas = rd_tmpabuf_alloc(
|
|
1931
|
+
&tbuf, replication_factor * sizeof(int));
|
|
1932
|
+
md->topics[i].partitions[j].leader = curr_broker;
|
|
1933
|
+
md->topics[i].partitions[j].replica_cnt =
|
|
1934
|
+
replication_factor;
|
|
1935
|
+
for (k = 0; k < replication_factor; k++) {
|
|
1936
|
+
md->topics[i].partitions[j].replicas[k] =
|
|
1937
|
+
(j + k + curr_broker) % num_brokers;
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
if (num_brokers > 0)
|
|
1941
|
+
curr_broker =
|
|
1942
|
+
(curr_broker + md->topics[i].partition_cnt) %
|
|
1943
|
+
num_brokers;
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
/* Check for tmpabuf errors */
|
|
1947
|
+
if (rd_tmpabuf_failed(&tbuf))
|
|
1948
|
+
rd_assert(!*"metadata mock failed");
|
|
1949
|
+
|
|
1950
|
+
/* Not destroying the tmpabuf since we return
|
|
1951
|
+
* its allocated memory. */
|
|
1952
|
+
return md;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
/* Implementation for rd_kafka_metadata_new_topic*mockv() */
|
|
1956
|
+
static rd_kafka_metadata_t *
|
|
1957
|
+
rd_kafka_metadata_new_topic_mockv_internal(size_t topic_cnt,
|
|
1958
|
+
int replication_factor,
|
|
1959
|
+
int num_brokers,
|
|
1960
|
+
va_list args) {
|
|
1961
|
+
rd_kafka_metadata_topic_t *topics;
|
|
1962
|
+
size_t i;
|
|
1963
|
+
|
|
1964
|
+
topics = rd_alloca(sizeof(*topics) * topic_cnt);
|
|
1965
|
+
for (i = 0; i < topic_cnt; i++) {
|
|
1966
|
+
topics[i].topic = va_arg(args, char *);
|
|
1967
|
+
topics[i].partition_cnt = va_arg(args, int);
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
return rd_kafka_metadata_new_topic_mock(
|
|
1971
|
+
topics, topic_cnt, replication_factor, num_brokers);
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
/**
|
|
1975
|
+
* @brief Create mock Metadata (for testing) based on the
|
|
1976
|
+
* var-arg tuples of (const char *topic, int partition_cnt).
|
|
1977
|
+
*
|
|
1978
|
+
* @param topic_cnt is the number of topic,partition_cnt tuples.
|
|
1979
|
+
*
|
|
1980
|
+
* @returns a newly allocated metadata object that must be freed with
|
|
1981
|
+
* rd_kafka_metadata_destroy().
|
|
1982
|
+
*
|
|
1983
|
+
* @sa rd_kafka_metadata_new_topic_mock()
|
|
1984
|
+
*/
|
|
1985
|
+
rd_kafka_metadata_t *rd_kafka_metadata_new_topic_mockv(size_t topic_cnt, ...) {
|
|
1986
|
+
rd_kafka_metadata_t *metadata;
|
|
1987
|
+
va_list ap;
|
|
1988
|
+
|
|
1989
|
+
va_start(ap, topic_cnt);
|
|
1990
|
+
metadata =
|
|
1991
|
+
rd_kafka_metadata_new_topic_mockv_internal(topic_cnt, -1, 0, ap);
|
|
1992
|
+
va_end(ap);
|
|
1993
|
+
|
|
1994
|
+
return metadata;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
/**
|
|
1998
|
+
* @brief Create mock Metadata (for testing) based on the
|
|
1999
|
+
* var-arg tuples of (const char *topic, int partition_cnt).
|
|
2000
|
+
*
|
|
2001
|
+
* @param replication_factor is the number of replicas of each partition.
|
|
2002
|
+
* @param num_brokers is the number of brokers in the cluster.
|
|
2003
|
+
* @param topic_cnt is the number of topic,partition_cnt tuples.
|
|
2004
|
+
*
|
|
2005
|
+
* @returns a newly allocated metadata object that must be freed with
|
|
2006
|
+
* rd_kafka_metadata_destroy().
|
|
2007
|
+
*
|
|
2008
|
+
* @sa rd_kafka_metadata_new_topic_mock()
|
|
2009
|
+
*/
|
|
2010
|
+
rd_kafka_metadata_t *rd_kafka_metadata_new_topic_with_partition_replicas_mockv(
|
|
2011
|
+
int replication_factor,
|
|
2012
|
+
int num_brokers,
|
|
2013
|
+
size_t topic_cnt,
|
|
2014
|
+
...) {
|
|
2015
|
+
rd_kafka_metadata_t *metadata;
|
|
2016
|
+
va_list ap;
|
|
2017
|
+
|
|
2018
|
+
va_start(ap, topic_cnt);
|
|
2019
|
+
metadata = rd_kafka_metadata_new_topic_mockv_internal(
|
|
2020
|
+
topic_cnt, replication_factor, num_brokers, ap);
|
|
2021
|
+
va_end(ap);
|
|
2022
|
+
|
|
2023
|
+
return metadata;
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
/**
|
|
2027
|
+
* @brief Create mock Metadata (for testing) based on arrays topic_names and
|
|
2028
|
+
* partition_cnts.
|
|
2029
|
+
*
|
|
2030
|
+
* @param replication_factor is the number of replicas of each partition.
|
|
2031
|
+
* @param num_brokers is the number of brokers in the cluster.
|
|
2032
|
+
* @param topic_names names of topics.
|
|
2033
|
+
* @param partition_cnts number of partitions in each topic.
|
|
2034
|
+
* @param topic_cnt number of topics.
|
|
2035
|
+
*
|
|
2036
|
+
* @return rd_kafka_metadata_t*
|
|
2037
|
+
*
|
|
2038
|
+
* @sa rd_kafka_metadata_new_topic_mock()
|
|
2039
|
+
*/
|
|
2040
|
+
rd_kafka_metadata_t *
|
|
2041
|
+
rd_kafka_metadata_new_topic_with_partition_replicas_mock(int replication_factor,
|
|
2042
|
+
int num_brokers,
|
|
2043
|
+
char *topic_names[],
|
|
2044
|
+
int *partition_cnts,
|
|
2045
|
+
size_t topic_cnt) {
|
|
2046
|
+
rd_kafka_metadata_topic_t *topics;
|
|
2047
|
+
size_t i;
|
|
2048
|
+
|
|
2049
|
+
topics = rd_alloca(sizeof(*topics) * topic_cnt);
|
|
2050
|
+
for (i = 0; i < topic_cnt; i++) {
|
|
2051
|
+
topics[i].topic = topic_names[i];
|
|
2052
|
+
topics[i].partition_cnt = partition_cnts[i];
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
return rd_kafka_metadata_new_topic_mock(
|
|
2056
|
+
topics, topic_cnt, replication_factor, num_brokers);
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
/**
|
|
2060
|
+
* @brief Handle update of metadata received in the produce or fetch tags.
|
|
2061
|
+
*
|
|
2062
|
+
* @param rk Client instance.
|
|
2063
|
+
* @param rko Metadata update operation.
|
|
2064
|
+
*
|
|
2065
|
+
* @locality main thread
|
|
2066
|
+
* @locks none
|
|
2067
|
+
*
|
|
2068
|
+
* @return always RD_KAFKA_OP_RES_HANDLED
|
|
2069
|
+
*/
|
|
2070
|
+
rd_kafka_op_res_t
|
|
2071
|
+
rd_kafka_metadata_update_op(rd_kafka_t *rk, rd_kafka_metadata_internal_t *mdi) {
|
|
2072
|
+
int i, j;
|
|
2073
|
+
rd_kafka_metadata_t *md = &mdi->metadata;
|
|
2074
|
+
rd_bool_t cache_updated = rd_false;
|
|
2075
|
+
rd_kafka_secproto_t rkb_proto = rk->rk_conf.security_protocol;
|
|
2076
|
+
|
|
2077
|
+
|
|
2078
|
+
for (i = 0; i < md->broker_cnt; i++) {
|
|
2079
|
+
rd_kafka_broker_update(rk, rkb_proto, &md->brokers[i], NULL);
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
for (i = 0; i < md->topic_cnt; i++) {
|
|
2083
|
+
struct rd_kafka_metadata_cache_entry *rkmce;
|
|
2084
|
+
int32_t partition_cache_changes = 0;
|
|
2085
|
+
rd_bool_t by_id =
|
|
2086
|
+
!RD_KAFKA_UUID_IS_ZERO(mdi->topics[i].topic_id);
|
|
2087
|
+
rd_kafka_Uuid_t topic_id = RD_KAFKA_UUID_ZERO;
|
|
2088
|
+
char *topic = NULL;
|
|
2089
|
+
|
|
2090
|
+
if (by_id) {
|
|
2091
|
+
rkmce = rd_kafka_metadata_cache_find_by_id(
|
|
2092
|
+
rk, mdi->topics[i].topic_id, 1);
|
|
2093
|
+
topic_id = mdi->topics[i].topic_id;
|
|
2094
|
+
} else {
|
|
2095
|
+
rkmce = rd_kafka_metadata_cache_find(
|
|
2096
|
+
rk, md->topics[i].topic, 1);
|
|
2097
|
+
topic = md->topics[i].topic;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
if (!rkmce) {
|
|
2101
|
+
if (by_id) {
|
|
2102
|
+
rd_kafka_log(
|
|
2103
|
+
rk, LOG_WARNING, "METADATAUPDATE",
|
|
2104
|
+
"Topic id %s not found in cache",
|
|
2105
|
+
rd_kafka_Uuid_base64str(&topic_id));
|
|
2106
|
+
} else {
|
|
2107
|
+
rd_kafka_log(rk, LOG_WARNING, "METADATAUPDATE",
|
|
2108
|
+
"Topic %s not found in cache",
|
|
2109
|
+
topic);
|
|
2110
|
+
}
|
|
2111
|
+
continue;
|
|
2112
|
+
}
|
|
2113
|
+
topic = rkmce->rkmce_mtopic.topic;
|
|
2114
|
+
topic_id = rkmce->rkmce_metadata_internal_topic.topic_id;
|
|
2115
|
+
|
|
2116
|
+
for (j = 0; j < md->topics[i].partition_cnt; j++) {
|
|
2117
|
+
rd_kafka_broker_t *rkb;
|
|
2118
|
+
rd_kafka_metadata_partition_t *mdp =
|
|
2119
|
+
&md->topics[i].partitions[j];
|
|
2120
|
+
;
|
|
2121
|
+
rd_kafka_metadata_partition_internal_t *mdpi =
|
|
2122
|
+
&mdi->topics[i].partitions[j];
|
|
2123
|
+
int32_t part = mdp->id, current_leader_epoch;
|
|
2124
|
+
|
|
2125
|
+
if (part >= rkmce->rkmce_mtopic.partition_cnt) {
|
|
2126
|
+
rd_kafka_log(rk, LOG_WARNING, "METADATAUPDATE",
|
|
2127
|
+
"Partition %s(%s)[%" PRId32
|
|
2128
|
+
"]: not found "
|
|
2129
|
+
"in cache",
|
|
2130
|
+
topic,
|
|
2131
|
+
rd_kafka_Uuid_base64str(&topic_id),
|
|
2132
|
+
part);
|
|
2133
|
+
|
|
2134
|
+
continue;
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
rkb = rd_kafka_broker_find_by_nodeid(rk, mdp->leader);
|
|
2138
|
+
if (!rkb) {
|
|
2139
|
+
rd_kafka_log(rk, LOG_WARNING, "METADATAUPDATE",
|
|
2140
|
+
"Partition %s(%s)[%" PRId32
|
|
2141
|
+
"]: new leader"
|
|
2142
|
+
"%" PRId32 " not found in cache",
|
|
2143
|
+
topic,
|
|
2144
|
+
rd_kafka_Uuid_base64str(&topic_id),
|
|
2145
|
+
part, mdp->leader);
|
|
2146
|
+
continue;
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
current_leader_epoch =
|
|
2150
|
+
rkmce->rkmce_metadata_internal_topic
|
|
2151
|
+
.partitions[part]
|
|
2152
|
+
.leader_epoch;
|
|
2153
|
+
|
|
2154
|
+
if (mdpi->leader_epoch != -1 &&
|
|
2155
|
+
current_leader_epoch > mdpi->leader_epoch) {
|
|
2156
|
+
rd_kafka_broker_destroy(rkb);
|
|
2157
|
+
rd_kafka_dbg(
|
|
2158
|
+
rk, METADATA, "METADATAUPDATE",
|
|
2159
|
+
"Partition %s(%s)[%" PRId32
|
|
2160
|
+
"]: leader epoch "
|
|
2161
|
+
"is "
|
|
2162
|
+
"not newer %" PRId32 " >= %" PRId32,
|
|
2163
|
+
topic, rd_kafka_Uuid_base64str(&topic_id),
|
|
2164
|
+
part, current_leader_epoch,
|
|
2165
|
+
mdpi->leader_epoch);
|
|
2166
|
+
continue;
|
|
2167
|
+
}
|
|
2168
|
+
partition_cache_changes++;
|
|
2169
|
+
|
|
2170
|
+
/* Need to acquire the write lock to avoid dirty reads
|
|
2171
|
+
* from other threads acquiring read locks. */
|
|
2172
|
+
rd_kafka_wrlock(rk);
|
|
2173
|
+
rkmce->rkmce_metadata_internal_topic.partitions[part]
|
|
2174
|
+
.leader_epoch = mdpi->leader_epoch;
|
|
2175
|
+
rkmce->rkmce_mtopic.partitions[part].leader =
|
|
2176
|
+
mdp->leader;
|
|
2177
|
+
rd_kafka_wrunlock(rk);
|
|
2178
|
+
rd_kafka_broker_destroy(rkb);
|
|
2179
|
+
|
|
2180
|
+
rd_kafka_dbg(rk, METADATA, "METADATAUPDATE",
|
|
2181
|
+
"Partition %s(%s)[%" PRId32
|
|
2182
|
+
"]:"
|
|
2183
|
+
" updated with leader %" PRId32
|
|
2184
|
+
" and epoch %" PRId32,
|
|
2185
|
+
topic, rd_kafka_Uuid_base64str(&topic_id),
|
|
2186
|
+
part, mdp->leader, mdpi->leader_epoch);
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
if (partition_cache_changes > 0) {
|
|
2190
|
+
cache_updated = rd_true;
|
|
2191
|
+
rd_kafka_topic_metadata_update2(
|
|
2192
|
+
rk->rk_internal_rkb, &rkmce->rkmce_mtopic,
|
|
2193
|
+
&rkmce->rkmce_metadata_internal_topic);
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
if (!cache_updated) {
|
|
2198
|
+
rd_kafka_dbg(rk, METADATA, "METADATAUPDATE",
|
|
2199
|
+
"Cache was not updated");
|
|
2200
|
+
return RD_KAFKA_OP_RES_HANDLED;
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
rd_kafka_dbg(rk, METADATA, "METADATAUPDATE",
|
|
2204
|
+
"Metadata cache updated, propagating changes");
|
|
2205
|
+
rd_kafka_metadata_cache_propagate_changes(rk);
|
|
2206
|
+
rd_kafka_metadata_cache_expiry_start(rk);
|
|
2207
|
+
|
|
2208
|
+
return RD_KAFKA_OP_RES_HANDLED;
|
|
2209
|
+
}
|