{"id":375648,"date":"2024-05-21T06:29:48","date_gmt":"2024-05-21T06:29:48","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=375648"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T06:29:48","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=375648","title":{"rendered":"<span>Unit-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Flink-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, Job: Flink MiniCluster<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u0421 \u0432\u0430\u043c\u0438 \u0432\u043d\u043e\u0432\u044c \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0411\u043e\u0431\u0440\u044f\u043a\u043e\u0432, \u0442\u0435\u0445\u043b\u0438\u0434 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u041c\u0422\u0421 \u0410\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438. \u0418 \u044f \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0451\u0439 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Apache Flink.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/801693\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439<\/a> \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c stateless- \u0438 stateful-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b Flink \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 TestHarness-\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 Flink. <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b \u043d\u0430 \u0432\u0441\u044e \u0434\u0436\u043e\u0431\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Flink \u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <a href=\"https:\/\/www.baeldung.com\/junit-5-extensions\">JUnit Extension<\/a>. \u0415\u0449\u0451 \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/eaf\/b72\/b88\/eafb72b880140877f06a701028232ceb.jpg\" width=\"1280\" height=\"717\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eaf\/b72\/b88\/eafb72b880140877f06a701028232ceb.jpg\" data-blurred=\"true\"\/><\/figure>\n<details class=\"spoiler\">\n<summary>\u0421\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u043f\u0440\u043e Flink<\/summary>\n<div class=\"spoiler__content\">\n<ol>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/772898\/\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 Apache Flink: \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/775970\/\">\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0434 Apache Flink: \u0441 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u0442\u044c?<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/786012\/\">Apache Flink. \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 Kafka-to-Kafka?<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/798667\/\">\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u043e\u043f\u0438\u043a\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/801693\/\">\u041a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 unit-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Flink-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432: Test Harness<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/812905\/\"><strong>Unit-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Flink-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, Job: Flink MiniCluster<\/strong><\/a><\/p>\n<\/li>\n<li>\n<p>TBD (\u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438)<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/details>\n<p>\u0412\u0435\u0441\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/AlexanderBobryakov\/flink-spring\">AlexanderBobryakov\/flink-spring<\/a>. \u0412 master-\u0432\u0435\u0442\u043a\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u0432\u0441\u0435\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u0435\u043b\u0438\u0437\u043d\u043e\u0439 \u0432\u0435\u0442\u043a\u0435 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/github.com\/AlexanderBobryakov\/flink-spring\/tree\/release\/5_flinkcluster_job_deduplicator_test\">release\/5_flinkcluster_job_deduplicator_test<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438<\/summary>\n<div class=\"spoiler__content\">\n<ol>\n<li>\n<p><a href=\"#1\">Flink MiniCluster<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#2\">\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0434\u043b\u044f Sink \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 Flink MiniCluster<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#3\">\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Flink MiniCluster<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#4\">\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 Job \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Flink MiniCluster<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#5\">\u0412\u044b\u0432\u043e\u0434<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/details>\n<p><a class=\"anchor\" name=\"1\" id=\"1\"><\/a><\/p>\n<h2>Flink MiniCluster<\/h2>\n<p>\u0412 <a href=\"https:\/\/nightlies.apache.org\/flink\/flink-docs-master\/docs\/dev\/datastream\/testing\/#testing-flink-jobs\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e Flink \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 MiniClusterWithClientResource \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u043d\u0438\u0439. \u042d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u0443 Flink \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 Unit-\u0442\u0435\u0441\u0442\u0430\u0445 (\u0434\u0430\u0436\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e TestHarness), \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b. \u041d\u043e \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0442\u0430\u043a\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u0451\u0442. <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0442\u0430\u0440\u0442\u0430 \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f StreamExecutionEnvironment.getExecutionEnvironment() \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043a \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443, \u0438 \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0451\u043c. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">public class ExampleIntegrationTest {      @ClassRule     public static MiniClusterWithClientResource flinkCluster =             new MiniClusterWithClientResource(                     new MiniClusterResourceConfiguration.Builder()                             .setNumberSlotsPerTaskManager(2)                             .setNumberTaskManagers(1)                             .build());      @Test     public void some\u0422est() throws Exception {         StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();         \/\/ ...     } }<\/code><\/pre>\n<p>\u041d\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c @ClassRule \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445. \u042f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0439, \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a\u0438\u0435 \u0443 \u043d\u0430\u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438?<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0435 \u0442\u044f\u043d\u0443\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u0442\u0435\u0441\u0442\u044b \u0441 Flink.<\/p>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0443 \u043d\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0432 \u043b\u044e\u0431\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0432\u0441\u0435\u043c\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0438 \u0443\u0431\u0438\u0432\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. <\/p>\n<p>\u041a\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435? \u041d\u0430 \u0443\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 @WithFlinkCluster, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c Flink \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430-\u0442\u0435\u0441\u0442\u0430, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u043d\u0430 \u0432\u0438\u0441\u0438\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0430\u043c\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"java\">@Retention(RUNTIME) @Inherited @ExtendWith({FlinkClusterExtension.class}) public @interface WithFlinkCluster { }<\/code><\/pre>\n<p>\u041d\u0438\u0447\u0435\u0433\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043d\u0435\u0439 \u043d\u0435\u0442. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0438\u0448\u043a\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 FlinkClusterExtension. \u042d\u0442\u043e JUnit Extension. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0445 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0435\u0433\u043e FlinkClusterExtension \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@Slf4j @SuppressWarnings({\"PMD.AvoidUsingVolatile\"}) public class FlinkClusterExtension implements BeforeAllCallback, ExtensionContext.Store.CloseableResource {    private static final MiniClusterWithClientResource FLINK_CLUSTER;    private static final Lock LOCK = new ReentrantLock();    private static volatile boolean started;     static {        final var configuration = new Configuration();        configuration.set(CoreOptions.DEFAULT_PARALLELISM, 2);        FLINK_CLUSTER = new MiniClusterWithClientResource(            new MiniClusterResourceConfiguration.Builder()                .setConfiguration(configuration)                .setNumberSlotsPerTaskManager(2)                .setNumberTaskManagers(1)                .build());    }     @Override    public void beforeAll(ExtensionContext context) throws Exception {        LOCK.lock();        try {            if (!started) {                log.info(\"Start Flink MiniCluster\");                started = true;                FLINK_CLUSTER.before();                context.getRoot().getStore(GLOBAL).put(\"Flink Cluster\", this);            }        } finally {            LOCK.unlock();        }    }     @Override    public void close() {        log.info(\"Close Flink MiniCluster\");        FLINK_CLUSTER.after();        started = false;    } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0434\u0432\u0443\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432: BeforeAllCallback, ExtensionContext.Store.CloseableResource. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 beforeAll \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0430\u0440\u0442\u043e\u043c \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0438\u0441\u0438\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f @ExtendWith({FlinkClusterExtension.class}). \u0410 \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u043a\u043e\u043b\u043b\u0431\u044d\u043a \u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0412 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0431\u043b\u043e\u043a\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c Flink \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0435\u043c\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043b\u043e\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>TaskManager<\/p>\n<\/li>\n<li>\n<p>\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u2014 \u0435\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c >1, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0431\u0430\u0433\u0438 \u0432 \u0432\u0430\u0448\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 beforeAll \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 before(). \u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 FlinkClusterExtension \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044a\u0435\u043a\u0442 ReentrantLock, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041c\u0435\u0442\u043e\u0434 close \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 JUnit Extension.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442, \u0433\u0434\u0435 \u043d\u0443\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 Flink, \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@WithFlinkCluster class DeduplicatorUnitTest_byFlinkCluster {    @Test     void test()  {         final var env = StreamExecutionEnvironment.getExecutionEnvironment();         \/\/ ...     } }<\/code><\/pre>\n<p><a class=\"anchor\" name=\"2\" id=\"2\"><\/a><\/p>\n<h2>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0434\u043b\u044f Sink \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 Flink MiniCluster<\/h2>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u0430, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c: \u0430 \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430\u0448\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f? \u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u2014 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430 \u0435\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0435. <\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 TaskManager \u0432 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0432\u043e\u0435\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0435\u0441\u043b\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c TM \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u043e\u0442). \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Sink-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u0410 \u043d\u0430\u043c \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0438\u0445 \u0432\u043e\u0435\u0434\u0438\u043d\u043e. <\/p>\n<p>\u041e\u0431 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0432 <a href=\"https:\/\/nightlies.apache.org\/flink\/flink-docs-release-1.17\/docs\/dev\/datastream\/testing\/#junit-rule-miniclusterwithclientresource\">\u0431\u043b\u043e\u043a\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0439<\/a>, \u0433\u0434\u0435 \u0430\u0432\u0442\u043e\u0440\u044b \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 CollectSink. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e, \u043d\u0430\u043c \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u2014 \u0442\u0435\u0441\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e, \u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0435\u0439 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u0432\u0435\u0434\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437 \u0432\u0441\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u043b\u0438\u044f\u0442\u044c \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430. <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 Flink \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d-\u043a\u043b\u0430\u0441\u0441 org.apache.flink.test.streaming.runtime.util.TestListWrapper, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442:<\/p>\n<pre><code class=\"java\">private List&lt;List&lt;? extends Comparable>> lists;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 TestListWrapper \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 List \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 lists \u0432\u044b\u0448\u0435. ID \u044d\u0442\u043e\u0433\u043e \u043b\u0438\u0441\u0442\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 Writer, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u0442 List, \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044f \u0435\u0433\u043e \u043f\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u043c\u0443 id \u0443 \u0441\u0430\u043c\u043e\u0433\u043e TestListWrapper. \u0417\u0432\u0443\u0447\u0438\u0442 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043a\u043e\u0434 \u0438\u0434\u0435\u0438:<\/p>\n<pre><code class=\"java\">@SuppressWarnings(\"PMD.TestClassWithoutTestCases\") public class TestListSink&lt;T> implements Sink&lt;T> {    private static final long serialVersionUID = 1L;     private final ListWriter writer = new ListWriter();    private final int resultListId;     public TestListSink() {        this.resultListId = TestListWrapper.getInstance().createList();    }     @Override    public SinkWriter&lt;T> createWriter(InitContext context) {        return writer;    }     public List&lt;T> getHandledEvents() {        return new ArrayList&lt;>(resultList());    }     @SuppressWarnings(\"unchecked\")    private List&lt;T> resultList() {        synchronized (TestListWrapper.getInstance()) {            return (List&lt;T>) TestListWrapper.getInstance().getList(resultListId);        }    }     private class ListWriter implements SinkWriter&lt;T>, Serializable {        private static final long serialVersionUID = 1L;         @Override        public void write(T element, Context context) {            resultList().add(element);        }         @Override        public void flush(boolean endOfInput) {            \/\/ no op        }         @Override        public void close() {            \/\/ no op        }    } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u043e\u0435\u0433\u043e TestListSink (\u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0442\u0435\u0441\u0442\u0435) \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 List \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e id: TestListWrapper.getInstance().createList(). \u0422\u0430\u043a\u0436\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f SinkWriter, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 write \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 List \u043f\u043e id \u043b\u0438\u0441\u0442\u0430. \u0422\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0435\u0434\u0438\u043d\u044b\u0439 List, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 getHandledEvents, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0451\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 sink-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430.<\/p>\n<p><a class=\"anchor\" name=\"3\" id=\"3\"><\/a><\/p>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Flink MiniCluster<\/h2>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0442\u0435\u0441\u0442 \u043d\u0430 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0442\u043e\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 TestHarness. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0442\u0435\u0441\u0442 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b:<\/p>\n<ol>\n<li>\n<p>\u041d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0432\u0435\u0441\u0438\u043c \u043d\u0430\u0448\u0443 \u043d\u043e\u0432\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u0441\u0430\u043c \u0442\u0435\u0441\u0442, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0442\u043e\u0440\u0430. <\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0432 \u043d\u043e\u0432\u043e\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435: <\/p>\n<pre><code class=\"java\">@WithFlinkCluster public class DeduplicatorUnitTest_byFlinkCluster {    private final Time TTL = Time.milliseconds(100);     @SneakyThrows    @ParameterizedTest    @MethodSource(\"provideUniqueEvents\")    void shouldDeduplicateMessagesByTtl(List&lt;String> events) {        final var sourceEvents = new ArrayList&lt;String>();        sourceEvents.addAll(events);        sourceEvents.addAll(events);        final var env = StreamExecutionEnvironment.getExecutionEnvironment();        final var sink = new TestListSink&lt;String>();        env.fromCollection(sourceEvents)            .keyBy(value -> value)            .flatMap(new Deduplicator&lt;>(TTL))            .sinkTo(sink);         env.execute();         final var outputEvents = sink.getHandledEvents();        assertEquals(events.size(), outputEvents.size(),            format(\"Unexpected number of events after deduplication. Output events: %s\", outputEvents));        assertEquals(events, new ArrayList&lt;>(outputEvents), \"Unexpected events after deduplication\");    }     private static Stream&lt;Arguments> provideUniqueEvents() {        return Stream.of(arguments(List.of(\"key_1\", \"key_2\")));    } }<\/code><\/pre>\n<p>\u041f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438 \u0442\u0435\u0441\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435: \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e String-\u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 fromCollection(), \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0432 \u043d\u0435\u0433\u043e \u0434\u0432\u0430\u0436\u0434\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u043e\u0442\u043e\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u0430\u043c \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0442\u043e\u0440 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 Sink \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430\u0448\u0435\u0433\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e TestListSink. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u043c Sink \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0436\u0435, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u043b\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 MiniCluster. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 StreamExecutionEnvironment.getExecutionEnvironment(). \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448 FlinkClusterExtension \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u0430, \u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435, \u0430 \u043c\u0435\u0442\u043e\u0434 getExecutionEnvironment() \u0435\u0433\u043e \u0443\u0432\u0438\u0434\u0438\u0442 \u0438 \u043f\u043e\u0434\u0442\u044f\u043d\u0435\u0442.<\/p>\n<p><a class=\"anchor\" name=\"4\" id=\"4\"><\/a><\/p>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 Job \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Flink MiniCluster<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0442\u0435\u0441\u0442\u0443 \u0432\u0441\u0435\u0433\u043e Flink-\u0437\u0430\u0434\u0430\u043d\u0438\u044f. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u0434\u0436\u043e\u0431\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a ClickMessage, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u0438\u043f\u043e\u043c \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b WEB \u0438 APP. \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f APP \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u044f APP \u0438 WEB \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u043f\u0438\u043a Kafka, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437 \u043f\u043e\u043b\u044f ClickMessage.productTopic. <\/p>\n<p>\u041f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dd3\/a50\/ecd\/dd3a50ecd7a89fc4bf94b5f369260358.png\" width=\"1410\" height=\"175\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dd3\/a50\/ecd\/dd3a50ecd7a89fc4bf94b5f369260358.png\"\/><\/figure>\n<p>\u0412 \u0442\u0435\u0441\u0442\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0435 Spring-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Flink Job:<\/p>\n<pre><code class=\"java\">@Retention(RUNTIME) @SpringBootTest(    webEnvironment = NONE,    classes = {        PropertiesConfig.class,        FlinkConfig.class,    }) @ActiveProfiles({\"test\"}) @WithFlinkCluster public @interface FlinkJobTest { }<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0432\u0435\u0441\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0442\u043e \u0437\u0430\u0434\u0430\u0451\u043c \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 @SpringBootTest \u043b\u0438\u0448\u044c \u0434\u0432\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438: <\/p>\n<ol>\n<li>\n<p>PropertyConfig, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435 \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438-\u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0438\u043d\u0434\u044f\u0442\u0441\u044f \u0441 application.yml. <\/p>\n<\/li>\n<li>\n<p>FlinkConfig, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0438\u043d StreamExecutionEnvironment.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e @FlinkJobTest \u0434\u043b\u044f \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u044f \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<p>\u041c\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u0430\u043c\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u0436\u043e\u0431\u044b, \u0430 \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0431\u0443\u0434\u0443\u0442 source \u0438 sink, \u043d\u0435\u0432\u0430\u0436\u043d\u043e. \u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 (Kafka) \u043c\u044b \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u04152\u0415-\u0442\u0435\u0441\u0442\u0430\u0445. <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u0447\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f APP \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u0446\u0438\u0440\u0443\u044e\u0442\u0441\u044f:<\/p>\n<pre><code class=\"java\">@FlinkJobTest @SuppressWarnings(\"PMD.DataflowAnomalyAnalysis\") class ClickToProductJobUnitTest {    @Autowired    private StreamExecutionEnvironment environment;    @Autowired    private ClickToProductJobProperties properties;     @ParameterizedTest    @EnumSource(value = Platform.Enum.class, names = {\"APP\"})    @SneakyThrows    void shouldDeduplicateClickMessages(Platform platform) {        final var message = aClickMessage().withPlatform(platform).build();        final var sink = new TestListSink&lt;WrappedSinkMessage&lt;ProductMessage>>();        final var job = new ClickToProductJob(            properties,            env -> env.fromElements(message, message, message).uid(\"test_source\"),            () -> sink        );         job.registerJob(environment);        environment.execute();         final var out = sink.getHandledEvents();        assertEquals(1, out.size(), format(\"Unexpected message count in sink: %s\", out));    }     \/\/ ... }<\/code><\/pre>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043a\u043e\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e @FlinkJobTest. \u0412 \u0441\u0430\u043c\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0438\u043d\u0436\u0435\u043a\u0442\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0431\u0438\u043d\u044b: <\/p>\n<ol>\n<li>\n<p>StreamExecutionEnvironment, \u043d\u0430\u0446\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u043f\u043e\u0434\u043d\u044f\u0442\u044b\u0439 \u0432 FlinkClusterExtension \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440.<\/p>\n<\/li>\n<li>\n<p>ClickToProductJobProperties, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u043c\u0435\u0435\u043c \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0432 application-test.yml \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u043c ClickMessage \u2014 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b APP, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0439 \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430. \u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0433\u043b\u0430\u0432\u0430\u0445 Sink TestListSink \u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0434\u0436\u043e\u0431\u0443 ClickToProductJob. \u0412 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u0436\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438, \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a. <\/p>\n<p><strong>! \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0440\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0436\u043e\u0431\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c. <\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0434\u0436\u043e\u0431\u044b \u0432 environment \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a. \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 fromCollection \u0438\u043c\u0435\u0435\u0442 \u0442\u0440\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0442\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0436\u043e\u0431\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Kafka) \u0434\u0436\u043e\u0431\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u0435\u0447\u043d\u043e, \u043f\u043e\u043a\u0430 \u043c\u044b \u0435\u0451 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043c. \u0414\u043b\u044f \u0432\u0435\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e Sink \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c. <\/p>\n<p>\u0422\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f WEB \u043d\u0435 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u0446\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f, \u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u043e\u043e\u0431\u0449\u0435. \u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u0441\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cda\/48c\/eee\/cda48ceee25cd450d1c9fa9808155a9e.png\" width=\"507\" height=\"596\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cda\/48c\/eee\/cda48ceee25cd450d1c9fa9808155a9e.png\"\/><\/figure>\n<p><a class=\"anchor\" name=\"5\" id=\"5\"><\/a><\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434<\/h2>\n<p>\u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Unit-\u0442\u0435\u0441\u0442\u0430 \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0434\u0436\u043e\u0431\u0443 Flink \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 stateful-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u0435\u0440\u0435\u0434 \u0432\u0441\u0435\u043c\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u043d\u0443\u0436\u0434\u0430\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0432 \u043d\u0451\u043c. \u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044f \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. <\/p>\n<p>\u0417\u0430 \u043a\u0430\u0434\u0440\u043e\u043c \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c Kafka, \u0432\u0435\u0434\u044c \u043d\u0430\u0448\u0430 \u0434\u0436\u043e\u0431\u0430 \u0447\u0438\u0442\u0430\u0435\u0442 \u0438 \u043f\u0438\u0448\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0435\u0451 \u0442\u043e\u043f\u0438\u043a\u0438. \u041a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c E2E-\u0442\u0435\u0441\u0442 \u043d\u0430 \u043f\u043e\u043b\u043d\u0443\u044e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e Kafka + Flink Job, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/812905\/\"> https:\/\/habr.com\/ru\/articles\/812905\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u0421 \u0432\u0430\u043c\u0438 \u0432\u043d\u043e\u0432\u044c \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0411\u043e\u0431\u0440\u044f\u043a\u043e\u0432, \u0442\u0435\u0445\u043b\u0438\u0434 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u041c\u0422\u0421 \u0410\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438. \u0418 \u044f \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0451\u0439 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Apache Flink.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/801693\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439<\/a> \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c stateless- \u0438 stateful-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b Flink \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 TestHarness-\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 Flink. <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b \u043d\u0430 \u0432\u0441\u044e \u0434\u0436\u043e\u0431\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Flink \u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <a href=\"https:\/\/www.baeldung.com\/junit-5-extensions\">JUnit Extension<\/a>. \u0415\u0449\u0451 \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435.<\/p>\n<figure class=\"full-width\"><\/figure>\n<details class=\"spoiler\">\n<summary>\u0421\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u043f\u0440\u043e Flink<\/summary>\n<div class=\"spoiler__content\">\n<ol>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/772898\/\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 Apache Flink: \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/775970\/\">\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0434 Apache Flink: \u0441 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u0442\u044c?<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/786012\/\">Apache Flink. \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 Kafka-to-Kafka?<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/798667\/\">\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u043e\u043f\u0438\u043a\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/801693\/\">\u041a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 unit-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Flink-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432: Test Harness<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/812905\/\"><strong>Unit-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Flink-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, Job: Flink MiniCluster<\/strong><\/a><\/p>\n<\/li>\n<li>\n<p>TBD (\u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438)<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/details>\n<p>\u0412\u0435\u0441\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/AlexanderBobryakov\/flink-spring\">AlexanderBobryakov\/flink-spring<\/a>. \u0412 master-\u0432\u0435\u0442\u043a\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u0432\u0441\u0435\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u0435\u043b\u0438\u0437\u043d\u043e\u0439 \u0432\u0435\u0442\u043a\u0435 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/github.com\/AlexanderBobryakov\/flink-spring\/tree\/release\/5_flinkcluster_job_deduplicator_test\">release\/5_flinkcluster_job_deduplicator_test<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438<\/summary>\n<div class=\"spoiler__content\">\n<ol>\n<li>\n<p><a href=\"#1\">Flink MiniCluster<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#2\">\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0434\u043b\u044f Sink \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 Flink MiniCluster<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#3\">\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Flink MiniCluster<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#4\">\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 Job \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Flink MiniCluster<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#5\">\u0412\u044b\u0432\u043e\u0434<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/details>\n<p><a class=\"anchor\" name=\"1\" id=\"1\"><\/a><\/p>\n<h2>Flink MiniCluster<\/h2>\n<p>\u0412 <a href=\"https:\/\/nightlies.apache.org\/flink\/flink-docs-master\/docs\/dev\/datastream\/testing\/#testing-flink-jobs\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e Flink \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 MiniClusterWithClientResource \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u043d\u0438\u0439. \u042d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u0443 Flink \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 Unit-\u0442\u0435\u0441\u0442\u0430\u0445 (\u0434\u0430\u0436\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e TestHarness), \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b. \u041d\u043e \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0442\u0430\u043a\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u0451\u0442. <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0442\u0430\u0440\u0442\u0430 \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f StreamExecutionEnvironment.getExecutionEnvironment() \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043a \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443, \u0438 \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0451\u043c. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">public class ExampleIntegrationTest {      @ClassRule     public static MiniClusterWithClientResource flinkCluster =             new MiniClusterWithClientResource(                     new MiniClusterResourceConfiguration.Builder()                             .setNumberSlotsPerTaskManager(2)                             .setNumberTaskManagers(1)                             .build());      @Test     public void some\u0422est() throws Exception {         StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();         \/\/ ...     } }<\/code><\/pre>\n<p>\u041d\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c @ClassRule \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445. \u042f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0439, \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a\u0438\u0435 \u0443 \u043d\u0430\u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438?<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0435 \u0442\u044f\u043d\u0443\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u0442\u0435\u0441\u0442\u044b \u0441 Flink.<\/p>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0443 \u043d\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0432 \u043b\u044e\u0431\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0432\u0441\u0435\u043c\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0438 \u0443\u0431\u0438\u0432\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. <\/p>\n<p>\u041a\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435? \u041d\u0430 \u0443\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 @WithFlinkCluster, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c Flink \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430-\u0442\u0435\u0441\u0442\u0430, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u043d\u0430 \u0432\u0438\u0441\u0438\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0430\u043c\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"java\">@Retention(RUNTIME) @Inherited @ExtendWith({FlinkClusterExtension.class}) public @interface WithFlinkCluster { }<\/code><\/pre>\n<p>\u041d\u0438\u0447\u0435\u0433\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043d\u0435\u0439 \u043d\u0435\u0442. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0438\u0448\u043a\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 FlinkClusterExtension. \u042d\u0442\u043e JUnit Extension. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0445 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0435\u0433\u043e FlinkClusterExtension \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@Slf4j @SuppressWarnings({\"PMD.AvoidUsingVolatile\"}) public class FlinkClusterExtension implements BeforeAllCallback, ExtensionContext.Store.CloseableResource {    private static final MiniClusterWithClientResource FLINK_CLUSTER;    private static final Lock LOCK = new ReentrantLock();    private static volatile boolean started;     static {        final var configuration = new Configuration();        configuration.set(CoreOptions.DEFAULT_PARALLELISM, 2);        FLINK_CLUSTER = new MiniClusterWithClientResource(            new MiniClusterResourceConfiguration.Builder()                .setConfiguration(configuration)                .setNumberSlotsPerTaskManager(2)                .setNumberTaskManagers(1)                .build());    }     @Override    public void beforeAll(ExtensionContext context) throws Exception {        LOCK.lock();        try {            if (!started) {                log.info(\"Start Flink MiniCluster\");                started = true;                FLINK_CLUSTER.before();                context.getRoot().getStore(GLOBAL).put(\"Flink Cluster\", this);            }        } finally {            LOCK.unlock();        }    }     @Override    public void close() {        log.info(\"Close Flink MiniCluster\");        FLINK_CLUSTER.after();        started = false;    } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0434\u0432\u0443\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432: BeforeAllCallback, ExtensionContext.Store.CloseableResource. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 beforeAll \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0430\u0440\u0442\u043e\u043c \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0438\u0441\u0438\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f @ExtendWith({FlinkClusterExtension.class}). \u0410 \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u043a\u043e\u043b\u043b\u0431\u044d\u043a \u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0412 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0431\u043b\u043e\u043a\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c Flink \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0435\u043c\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043b\u043e\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>TaskManager<\/p>\n<\/li>\n<li>\n<p>\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u2014 \u0435\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c >1, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0431\u0430\u0433\u0438 \u0432 \u0432\u0430\u0448\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 beforeAll \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 before(). \u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 FlinkClusterExtension \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044a\u0435\u043a\u0442 ReentrantLock, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041c\u0435\u0442\u043e\u0434 close \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 JUnit Extension.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442, \u0433\u0434\u0435 \u043d\u0443\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 Flink, \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@WithFlinkCluster class DeduplicatorUnitTest_byFlinkCluster {    @Test     void test()  {         final var env = StreamExecutionEnvironment.getExecutionEnvironment();         \/\/ ...     } }<\/code><\/pre>\n<p><a class=\"anchor\" name=\"2\" id=\"2\"><\/a><\/p>\n<h2>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0434\u043b\u044f Sink \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 Flink MiniCluster<\/h2>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u0430, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c: \u0430 \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430\u0448\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f? \u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u2014 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430 \u0435\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0435. <\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 TaskManager \u0432 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0432\u043e\u0435\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0435\u0441\u043b\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c TM \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u043e\u0442). \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Sink-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u0410 \u043d\u0430\u043c \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0438\u0445 \u0432\u043e\u0435\u0434\u0438\u043d\u043e. <\/p>\n<p>\u041e\u0431 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0432 <a href=\"https:\/\/nightlies.apache.org\/flink\/flink-docs-release-1.17\/docs\/dev\/datastream\/testing\/#junit-rule-miniclusterwithclientresource\">\u0431\u043b\u043e\u043a\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0439<\/a>, \u0433\u0434\u0435 \u0430\u0432\u0442\u043e\u0440\u044b \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 CollectSink. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e, \u043d\u0430\u043c \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u2014 \u0442\u0435\u0441\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e, \u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0435\u0439 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u0432\u0435\u0434\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437 \u0432\u0441\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u043b\u0438\u044f\u0442\u044c \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430. <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 Flink \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d-\u043a\u043b\u0430\u0441\u0441 org.apache.flink.test.streaming.runtime.util.TestListWrapper, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442:<\/p>\n<pre><code class=\"java\">private List&lt;List&lt;? extends Comparable>> lists;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 TestListWrapper \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 List \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 lists \u0432\u044b\u0448\u0435. ID \u044d\u0442\u043e\u0433\u043e \u043b\u0438\u0441\u0442\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 Writer, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u0442 List, \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044f \u0435\u0433\u043e \u043f\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u043c\u0443 id \u0443 \u0441\u0430\u043c\u043e\u0433\u043e TestListWrapper. \u0417\u0432\u0443\u0447\u0438\u0442 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043a\u043e\u0434 \u0438\u0434\u0435\u0438:<\/p>\n<pre><code class=\"java\">@SuppressWarnings(\"PMD.TestClassWithoutTestCases\") public class TestListSink&lt;T> implements Sink&lt;T> {    private static final long serialVersionUID = 1L;     private final ListWriter writer = new ListWriter();    private final int resultListId;     public TestListSink() {        this.resultListId = TestListWrapper.getInstance().createList();    }     @Override    public SinkWriter&lt;T> createWriter(InitContext context) {        return writer;    }     public List&lt;T> getHandledEvents() {        return new ArrayList&lt;>(resultList());    }     @SuppressWarnings(\"unchecked\")    private List&lt;T> resultList() {        synchronized (TestListWrapper.getInstance()) {            return (List&lt;T>) TestListWrapper.getInstance().getList(resultListId);        }    }     private class ListWriter implements SinkWriter&lt;T>, Serializable {        private static final long serialVersionUID = 1L;         @Override        public void write(T element, Context context) {            resultList().add(element);        }         @Override        public void flush(boolean endOfInput) {            \/\/ no op        }         @Override        public void close() {            \/\/ no op        }    } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u043e\u0435\u0433\u043e TestListSink (\u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0442\u0435\u0441\u0442\u0435) \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 List \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e id: TestListWrapper.getInstance().createList(). \u0422\u0430\u043a\u0436\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f SinkWriter, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 write \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 List \u043f\u043e id \u043b\u0438\u0441\u0442\u0430. \u0422\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0435\u0434\u0438\u043d\u044b\u0439 List, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 getHandledEvents, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0451\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 sink-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430.<\/p>\n<p><a class=\"anchor\" name=\"3\" id=\"3\"><\/a><\/p>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Flink MiniCluster<\/h2>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0442\u0435\u0441\u0442 \u043d\u0430 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0442\u043e\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 TestHarness. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0442\u0435\u0441\u0442 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0438\u043d\u0438-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b:<\/p>\n<ol>\n<li>\n<p>\u041d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0432\u0435\u0441\u0438\u043c \u043d\u0430\u0448\u0443 \u043d\u043e\u0432\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u0441\u0430\u043c \u0442\u0435\u0441\u0442, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-375648","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/375648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=375648"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/375648\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=375648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=375648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=375648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}