fluentd 1.14.4-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.deepsource.toml +13 -0
- data/.drone.yml +35 -0
- data/.github/ISSUE_TEMPLATE/bug_report.yaml +70 -0
- data/.github/ISSUE_TEMPLATE/config.yml +5 -0
- data/.github/ISSUE_TEMPLATE/feature_request.yaml +38 -0
- data/.github/ISSUE_TEMPLATE.md +17 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +14 -0
- data/.github/workflows/issue-auto-closer.yml +12 -0
- data/.github/workflows/linux-test.yaml +36 -0
- data/.github/workflows/macos-test.yaml +30 -0
- data/.github/workflows/stale-actions.yml +22 -0
- data/.github/workflows/windows-test.yaml +46 -0
- data/.gitignore +30 -0
- data/.gitlab-ci.yml +103 -0
- data/ADOPTERS.md +5 -0
- data/AUTHORS +2 -0
- data/CHANGELOG.md +2409 -0
- data/CONTRIBUTING.md +45 -0
- data/GOVERNANCE.md +55 -0
- data/Gemfile +9 -0
- data/GithubWorkflow.md +78 -0
- data/LICENSE +202 -0
- data/MAINTAINERS.md +11 -0
- data/README.md +97 -0
- data/Rakefile +79 -0
- data/SECURITY.md +18 -0
- data/bin/fluent-binlog-reader +7 -0
- data/bin/fluent-ca-generate +6 -0
- data/bin/fluent-cap-ctl +7 -0
- data/bin/fluent-cat +5 -0
- data/bin/fluent-ctl +7 -0
- data/bin/fluent-debug +5 -0
- data/bin/fluent-gem +9 -0
- data/bin/fluent-plugin-config-format +5 -0
- data/bin/fluent-plugin-generate +5 -0
- data/bin/fluentd +15 -0
- data/code-of-conduct.md +3 -0
- data/docs/SECURITY_AUDIT.pdf +0 -0
- data/example/copy_roundrobin.conf +39 -0
- data/example/counter.conf +18 -0
- data/example/filter_stdout.conf +22 -0
- data/example/in_forward.conf +14 -0
- data/example/in_forward_client.conf +37 -0
- data/example/in_forward_shared_key.conf +15 -0
- data/example/in_forward_tls.conf +14 -0
- data/example/in_forward_users.conf +24 -0
- data/example/in_forward_workers.conf +21 -0
- data/example/in_http.conf +16 -0
- data/example/in_out_forward.conf +17 -0
- data/example/in_sample_blocks.conf +17 -0
- data/example/in_sample_with_compression.conf +23 -0
- data/example/in_syslog.conf +15 -0
- data/example/in_tail.conf +14 -0
- data/example/in_tcp.conf +13 -0
- data/example/in_udp.conf +13 -0
- data/example/logevents.conf +25 -0
- data/example/multi_filters.conf +61 -0
- data/example/out_copy.conf +20 -0
- data/example/out_exec_filter.conf +42 -0
- data/example/out_file.conf +13 -0
- data/example/out_forward.conf +35 -0
- data/example/out_forward_buf_file.conf +23 -0
- data/example/out_forward_client.conf +109 -0
- data/example/out_forward_heartbeat_none.conf +16 -0
- data/example/out_forward_sd.conf +17 -0
- data/example/out_forward_shared_key.conf +36 -0
- data/example/out_forward_tls.conf +18 -0
- data/example/out_forward_users.conf +65 -0
- data/example/out_null.conf +36 -0
- data/example/sd.yaml +8 -0
- data/example/secondary_file.conf +42 -0
- data/example/suppress_config_dump.conf +7 -0
- data/example/v0_12_filter.conf +78 -0
- data/example/v1_literal_example.conf +36 -0
- data/example/worker_section.conf +36 -0
- data/fluent.conf +139 -0
- data/fluentd.gemspec +55 -0
- data/lib/fluent/agent.rb +168 -0
- data/lib/fluent/capability.rb +87 -0
- data/lib/fluent/clock.rb +66 -0
- data/lib/fluent/command/binlog_reader.rb +244 -0
- data/lib/fluent/command/bundler_injection.rb +45 -0
- data/lib/fluent/command/ca_generate.rb +184 -0
- data/lib/fluent/command/cap_ctl.rb +174 -0
- data/lib/fluent/command/cat.rb +365 -0
- data/lib/fluent/command/ctl.rb +177 -0
- data/lib/fluent/command/debug.rb +103 -0
- data/lib/fluent/command/fluentd.rb +374 -0
- data/lib/fluent/command/plugin_config_formatter.rb +308 -0
- data/lib/fluent/command/plugin_generator.rb +365 -0
- data/lib/fluent/compat/call_super_mixin.rb +76 -0
- data/lib/fluent/compat/detach_process_mixin.rb +33 -0
- data/lib/fluent/compat/exec_util.rb +129 -0
- data/lib/fluent/compat/file_util.rb +54 -0
- data/lib/fluent/compat/filter.rb +68 -0
- data/lib/fluent/compat/formatter.rb +111 -0
- data/lib/fluent/compat/formatter_utils.rb +85 -0
- data/lib/fluent/compat/handle_tag_and_time_mixin.rb +62 -0
- data/lib/fluent/compat/handle_tag_name_mixin.rb +53 -0
- data/lib/fluent/compat/input.rb +49 -0
- data/lib/fluent/compat/output.rb +721 -0
- data/lib/fluent/compat/output_chain.rb +60 -0
- data/lib/fluent/compat/parser.rb +310 -0
- data/lib/fluent/compat/parser_utils.rb +40 -0
- data/lib/fluent/compat/propagate_default.rb +62 -0
- data/lib/fluent/compat/record_filter_mixin.rb +34 -0
- data/lib/fluent/compat/set_tag_key_mixin.rb +50 -0
- data/lib/fluent/compat/set_time_key_mixin.rb +69 -0
- data/lib/fluent/compat/socket_util.rb +165 -0
- data/lib/fluent/compat/string_util.rb +34 -0
- data/lib/fluent/compat/structured_format_mixin.rb +26 -0
- data/lib/fluent/compat/type_converter.rb +90 -0
- data/lib/fluent/config/basic_parser.rb +123 -0
- data/lib/fluent/config/configure_proxy.rb +424 -0
- data/lib/fluent/config/dsl.rb +152 -0
- data/lib/fluent/config/element.rb +265 -0
- data/lib/fluent/config/error.rb +32 -0
- data/lib/fluent/config/literal_parser.rb +286 -0
- data/lib/fluent/config/parser.rb +107 -0
- data/lib/fluent/config/section.rb +272 -0
- data/lib/fluent/config/types.rb +249 -0
- data/lib/fluent/config/v1_parser.rb +192 -0
- data/lib/fluent/config.rb +76 -0
- data/lib/fluent/configurable.rb +201 -0
- data/lib/fluent/counter/base_socket.rb +44 -0
- data/lib/fluent/counter/client.rb +297 -0
- data/lib/fluent/counter/error.rb +86 -0
- data/lib/fluent/counter/mutex_hash.rb +163 -0
- data/lib/fluent/counter/server.rb +273 -0
- data/lib/fluent/counter/store.rb +205 -0
- data/lib/fluent/counter/validator.rb +145 -0
- data/lib/fluent/counter.rb +23 -0
- data/lib/fluent/daemon.rb +15 -0
- data/lib/fluent/daemonizer.rb +88 -0
- data/lib/fluent/engine.rb +253 -0
- data/lib/fluent/env.rb +40 -0
- data/lib/fluent/error.rb +34 -0
- data/lib/fluent/event.rb +326 -0
- data/lib/fluent/event_router.rb +297 -0
- data/lib/fluent/ext_monitor_require.rb +28 -0
- data/lib/fluent/filter.rb +21 -0
- data/lib/fluent/fluent_log_event_router.rb +141 -0
- data/lib/fluent/formatter.rb +23 -0
- data/lib/fluent/input.rb +21 -0
- data/lib/fluent/label.rb +46 -0
- data/lib/fluent/load.rb +34 -0
- data/lib/fluent/log.rb +713 -0
- data/lib/fluent/match.rb +187 -0
- data/lib/fluent/mixin.rb +31 -0
- data/lib/fluent/msgpack_factory.rb +106 -0
- data/lib/fluent/oj_options.rb +62 -0
- data/lib/fluent/output.rb +29 -0
- data/lib/fluent/output_chain.rb +23 -0
- data/lib/fluent/parser.rb +23 -0
- data/lib/fluent/plugin/bare_output.rb +104 -0
- data/lib/fluent/plugin/base.rb +197 -0
- data/lib/fluent/plugin/buf_file.rb +213 -0
- data/lib/fluent/plugin/buf_file_single.rb +225 -0
- data/lib/fluent/plugin/buf_memory.rb +34 -0
- data/lib/fluent/plugin/buffer/chunk.rb +240 -0
- data/lib/fluent/plugin/buffer/file_chunk.rb +413 -0
- data/lib/fluent/plugin/buffer/file_single_chunk.rb +311 -0
- data/lib/fluent/plugin/buffer/memory_chunk.rb +91 -0
- data/lib/fluent/plugin/buffer.rb +918 -0
- data/lib/fluent/plugin/compressable.rb +96 -0
- data/lib/fluent/plugin/exec_util.rb +22 -0
- data/lib/fluent/plugin/file_util.rb +22 -0
- data/lib/fluent/plugin/file_wrapper.rb +187 -0
- data/lib/fluent/plugin/filter.rb +127 -0
- data/lib/fluent/plugin/filter_grep.rb +189 -0
- data/lib/fluent/plugin/filter_parser.rb +130 -0
- data/lib/fluent/plugin/filter_record_transformer.rb +324 -0
- data/lib/fluent/plugin/filter_stdout.rb +53 -0
- data/lib/fluent/plugin/formatter.rb +75 -0
- data/lib/fluent/plugin/formatter_csv.rb +78 -0
- data/lib/fluent/plugin/formatter_hash.rb +35 -0
- data/lib/fluent/plugin/formatter_json.rb +59 -0
- data/lib/fluent/plugin/formatter_ltsv.rb +44 -0
- data/lib/fluent/plugin/formatter_msgpack.rb +33 -0
- data/lib/fluent/plugin/formatter_out_file.rb +53 -0
- data/lib/fluent/plugin/formatter_single_value.rb +36 -0
- data/lib/fluent/plugin/formatter_stdout.rb +76 -0
- data/lib/fluent/plugin/formatter_tsv.rb +40 -0
- data/lib/fluent/plugin/in_debug_agent.rb +71 -0
- data/lib/fluent/plugin/in_dummy.rb +18 -0
- data/lib/fluent/plugin/in_exec.rb +110 -0
- data/lib/fluent/plugin/in_forward.rb +473 -0
- data/lib/fluent/plugin/in_gc_stat.rb +72 -0
- data/lib/fluent/plugin/in_http.rb +667 -0
- data/lib/fluent/plugin/in_monitor_agent.rb +412 -0
- data/lib/fluent/plugin/in_object_space.rb +93 -0
- data/lib/fluent/plugin/in_sample.rb +141 -0
- data/lib/fluent/plugin/in_syslog.rb +276 -0
- data/lib/fluent/plugin/in_tail/position_file.rb +269 -0
- data/lib/fluent/plugin/in_tail.rb +1228 -0
- data/lib/fluent/plugin/in_tcp.rb +181 -0
- data/lib/fluent/plugin/in_udp.rb +92 -0
- data/lib/fluent/plugin/in_unix.rb +195 -0
- data/lib/fluent/plugin/input.rb +75 -0
- data/lib/fluent/plugin/metrics.rb +119 -0
- data/lib/fluent/plugin/metrics_local.rb +96 -0
- data/lib/fluent/plugin/multi_output.rb +195 -0
- data/lib/fluent/plugin/out_copy.rb +120 -0
- data/lib/fluent/plugin/out_exec.rb +105 -0
- data/lib/fluent/plugin/out_exec_filter.rb +319 -0
- data/lib/fluent/plugin/out_file.rb +334 -0
- data/lib/fluent/plugin/out_forward/ack_handler.rb +161 -0
- data/lib/fluent/plugin/out_forward/connection_manager.rb +113 -0
- data/lib/fluent/plugin/out_forward/error.rb +28 -0
- data/lib/fluent/plugin/out_forward/failure_detector.rb +84 -0
- data/lib/fluent/plugin/out_forward/handshake_protocol.rb +125 -0
- data/lib/fluent/plugin/out_forward/load_balancer.rb +114 -0
- data/lib/fluent/plugin/out_forward/socket_cache.rb +140 -0
- data/lib/fluent/plugin/out_forward.rb +826 -0
- data/lib/fluent/plugin/out_http.rb +275 -0
- data/lib/fluent/plugin/out_null.rb +74 -0
- data/lib/fluent/plugin/out_relabel.rb +32 -0
- data/lib/fluent/plugin/out_roundrobin.rb +84 -0
- data/lib/fluent/plugin/out_secondary_file.rb +131 -0
- data/lib/fluent/plugin/out_stdout.rb +74 -0
- data/lib/fluent/plugin/out_stream.rb +130 -0
- data/lib/fluent/plugin/output.rb +1556 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
- data/lib/fluent/plugin/parser.rb +275 -0
- data/lib/fluent/plugin/parser_apache.rb +28 -0
- data/lib/fluent/plugin/parser_apache2.rb +88 -0
- data/lib/fluent/plugin/parser_apache_error.rb +26 -0
- data/lib/fluent/plugin/parser_csv.rb +114 -0
- data/lib/fluent/plugin/parser_json.rb +96 -0
- data/lib/fluent/plugin/parser_ltsv.rb +51 -0
- data/lib/fluent/plugin/parser_msgpack.rb +50 -0
- data/lib/fluent/plugin/parser_multiline.rb +152 -0
- data/lib/fluent/plugin/parser_nginx.rb +28 -0
- data/lib/fluent/plugin/parser_none.rb +36 -0
- data/lib/fluent/plugin/parser_regexp.rb +68 -0
- data/lib/fluent/plugin/parser_syslog.rb +496 -0
- data/lib/fluent/plugin/parser_tsv.rb +42 -0
- data/lib/fluent/plugin/sd_file.rb +156 -0
- data/lib/fluent/plugin/sd_srv.rb +135 -0
- data/lib/fluent/plugin/sd_static.rb +58 -0
- data/lib/fluent/plugin/service_discovery.rb +65 -0
- data/lib/fluent/plugin/socket_util.rb +22 -0
- data/lib/fluent/plugin/storage.rb +84 -0
- data/lib/fluent/plugin/storage_local.rb +162 -0
- data/lib/fluent/plugin/string_util.rb +22 -0
- data/lib/fluent/plugin.rb +206 -0
- data/lib/fluent/plugin_helper/cert_option.rb +191 -0
- data/lib/fluent/plugin_helper/child_process.rb +366 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +343 -0
- data/lib/fluent/plugin_helper/counter.rb +51 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +100 -0
- data/lib/fluent/plugin_helper/event_loop.rb +170 -0
- data/lib/fluent/plugin_helper/extract.rb +104 -0
- data/lib/fluent/plugin_helper/formatter.rb +147 -0
- data/lib/fluent/plugin_helper/http_server/app.rb +79 -0
- data/lib/fluent/plugin_helper/http_server/compat/server.rb +92 -0
- data/lib/fluent/plugin_helper/http_server/compat/ssl_context_extractor.rb +52 -0
- data/lib/fluent/plugin_helper/http_server/compat/webrick_handler.rb +58 -0
- data/lib/fluent/plugin_helper/http_server/methods.rb +35 -0
- data/lib/fluent/plugin_helper/http_server/request.rb +42 -0
- data/lib/fluent/plugin_helper/http_server/router.rb +54 -0
- data/lib/fluent/plugin_helper/http_server/server.rb +93 -0
- data/lib/fluent/plugin_helper/http_server/ssl_context_builder.rb +41 -0
- data/lib/fluent/plugin_helper/http_server.rb +135 -0
- data/lib/fluent/plugin_helper/inject.rb +154 -0
- data/lib/fluent/plugin_helper/metrics.rb +129 -0
- data/lib/fluent/plugin_helper/parser.rb +147 -0
- data/lib/fluent/plugin_helper/record_accessor.rb +207 -0
- data/lib/fluent/plugin_helper/retry_state.rb +209 -0
- data/lib/fluent/plugin_helper/server.rb +801 -0
- data/lib/fluent/plugin_helper/service_discovery/manager.rb +146 -0
- data/lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb +43 -0
- data/lib/fluent/plugin_helper/service_discovery.rb +125 -0
- data/lib/fluent/plugin_helper/socket.rb +277 -0
- data/lib/fluent/plugin_helper/socket_option.rb +98 -0
- data/lib/fluent/plugin_helper/storage.rb +349 -0
- data/lib/fluent/plugin_helper/thread.rb +180 -0
- data/lib/fluent/plugin_helper/timer.rb +92 -0
- data/lib/fluent/plugin_helper.rb +75 -0
- data/lib/fluent/plugin_id.rb +93 -0
- data/lib/fluent/process.rb +22 -0
- data/lib/fluent/registry.rb +116 -0
- data/lib/fluent/root_agent.rb +372 -0
- data/lib/fluent/rpc.rb +94 -0
- data/lib/fluent/static_config_analysis.rb +194 -0
- data/lib/fluent/supervisor.rb +1054 -0
- data/lib/fluent/system_config.rb +187 -0
- data/lib/fluent/test/base.rb +78 -0
- data/lib/fluent/test/driver/base.rb +225 -0
- data/lib/fluent/test/driver/base_owned.rb +83 -0
- data/lib/fluent/test/driver/base_owner.rb +135 -0
- data/lib/fluent/test/driver/event_feeder.rb +98 -0
- data/lib/fluent/test/driver/filter.rb +57 -0
- data/lib/fluent/test/driver/formatter.rb +30 -0
- data/lib/fluent/test/driver/input.rb +31 -0
- data/lib/fluent/test/driver/multi_output.rb +53 -0
- data/lib/fluent/test/driver/output.rb +102 -0
- data/lib/fluent/test/driver/parser.rb +30 -0
- data/lib/fluent/test/driver/storage.rb +30 -0
- data/lib/fluent/test/driver/test_event_router.rb +45 -0
- data/lib/fluent/test/filter_test.rb +77 -0
- data/lib/fluent/test/formatter_test.rb +65 -0
- data/lib/fluent/test/helpers.rb +134 -0
- data/lib/fluent/test/input_test.rb +174 -0
- data/lib/fluent/test/log.rb +79 -0
- data/lib/fluent/test/output_test.rb +156 -0
- data/lib/fluent/test/parser_test.rb +70 -0
- data/lib/fluent/test/startup_shutdown.rb +46 -0
- data/lib/fluent/test.rb +58 -0
- data/lib/fluent/time.rb +512 -0
- data/lib/fluent/timezone.rb +171 -0
- data/lib/fluent/tls.rb +81 -0
- data/lib/fluent/unique_id.rb +39 -0
- data/lib/fluent/variable_store.rb +40 -0
- data/lib/fluent/version.rb +21 -0
- data/lib/fluent/winsvc.rb +103 -0
- data/templates/new_gem/Gemfile +3 -0
- data/templates/new_gem/README.md.erb +43 -0
- data/templates/new_gem/Rakefile +13 -0
- data/templates/new_gem/fluent-plugin.gemspec.erb +27 -0
- data/templates/new_gem/lib/fluent/plugin/filter.rb.erb +14 -0
- data/templates/new_gem/lib/fluent/plugin/formatter.rb.erb +14 -0
- data/templates/new_gem/lib/fluent/plugin/input.rb.erb +11 -0
- data/templates/new_gem/lib/fluent/plugin/output.rb.erb +11 -0
- data/templates/new_gem/lib/fluent/plugin/parser.rb.erb +15 -0
- data/templates/new_gem/lib/fluent/plugin/storage.rb.erb +40 -0
- data/templates/new_gem/test/helper.rb.erb +8 -0
- data/templates/new_gem/test/plugin/test_filter.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_formatter.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_input.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_output.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_parser.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_storage.rb.erb +18 -0
- data/templates/plugin_config_formatter/param.md-compact.erb +25 -0
- data/templates/plugin_config_formatter/param.md-table.erb +10 -0
- data/templates/plugin_config_formatter/param.md.erb +34 -0
- data/templates/plugin_config_formatter/section.md.erb +12 -0
- data/test/command/test_binlog_reader.rb +362 -0
- data/test/command/test_ca_generate.rb +70 -0
- data/test/command/test_cap_ctl.rb +100 -0
- data/test/command/test_cat.rb +128 -0
- data/test/command/test_ctl.rb +57 -0
- data/test/command/test_fluentd.rb +1106 -0
- data/test/command/test_plugin_config_formatter.rb +398 -0
- data/test/command/test_plugin_generator.rb +109 -0
- data/test/compat/test_calls_super.rb +166 -0
- data/test/compat/test_parser.rb +92 -0
- data/test/config/assertions.rb +42 -0
- data/test/config/test_config_parser.rb +551 -0
- data/test/config/test_configurable.rb +1784 -0
- data/test/config/test_configure_proxy.rb +604 -0
- data/test/config/test_dsl.rb +415 -0
- data/test/config/test_element.rb +518 -0
- data/test/config/test_literal_parser.rb +309 -0
- data/test/config/test_plugin_configuration.rb +56 -0
- data/test/config/test_section.rb +191 -0
- data/test/config/test_system_config.rb +199 -0
- data/test/config/test_types.rb +408 -0
- data/test/counter/test_client.rb +563 -0
- data/test/counter/test_error.rb +44 -0
- data/test/counter/test_mutex_hash.rb +179 -0
- data/test/counter/test_server.rb +589 -0
- data/test/counter/test_store.rb +258 -0
- data/test/counter/test_validator.rb +137 -0
- data/test/helper.rb +155 -0
- data/test/helpers/fuzzy_assert.rb +89 -0
- data/test/helpers/process_extenstion.rb +33 -0
- data/test/plugin/data/2010/01/20100102-030405.log +0 -0
- data/test/plugin/data/2010/01/20100102-030406.log +0 -0
- data/test/plugin/data/2010/01/20100102.log +0 -0
- data/test/plugin/data/log/bar +0 -0
- data/test/plugin/data/log/foo/bar.log +0 -0
- data/test/plugin/data/log/foo/bar2 +0 -0
- data/test/plugin/data/log/test.log +0 -0
- data/test/plugin/data/sd_file/config +11 -0
- data/test/plugin/data/sd_file/config.json +17 -0
- data/test/plugin/data/sd_file/config.yaml +11 -0
- data/test/plugin/data/sd_file/config.yml +11 -0
- data/test/plugin/data/sd_file/invalid_config.yml +7 -0
- data/test/plugin/in_tail/test_fifo.rb +121 -0
- data/test/plugin/in_tail/test_io_handler.rb +140 -0
- data/test/plugin/in_tail/test_position_file.rb +379 -0
- data/test/plugin/out_forward/test_ack_handler.rb +101 -0
- data/test/plugin/out_forward/test_connection_manager.rb +145 -0
- data/test/plugin/out_forward/test_handshake_protocol.rb +112 -0
- data/test/plugin/out_forward/test_load_balancer.rb +106 -0
- data/test/plugin/out_forward/test_socket_cache.rb +149 -0
- data/test/plugin/test_bare_output.rb +131 -0
- data/test/plugin/test_base.rb +115 -0
- data/test/plugin/test_buf_file.rb +1275 -0
- data/test/plugin/test_buf_file_single.rb +833 -0
- data/test/plugin/test_buf_memory.rb +42 -0
- data/test/plugin/test_buffer.rb +1383 -0
- data/test/plugin/test_buffer_chunk.rb +198 -0
- data/test/plugin/test_buffer_file_chunk.rb +871 -0
- data/test/plugin/test_buffer_file_single_chunk.rb +611 -0
- data/test/plugin/test_buffer_memory_chunk.rb +339 -0
- data/test/plugin/test_compressable.rb +87 -0
- data/test/plugin/test_file_util.rb +96 -0
- data/test/plugin/test_file_wrapper.rb +126 -0
- data/test/plugin/test_filter.rb +368 -0
- data/test/plugin/test_filter_grep.rb +697 -0
- data/test/plugin/test_filter_parser.rb +731 -0
- data/test/plugin/test_filter_record_transformer.rb +577 -0
- data/test/plugin/test_filter_stdout.rb +207 -0
- data/test/plugin/test_formatter_csv.rb +136 -0
- data/test/plugin/test_formatter_hash.rb +38 -0
- data/test/plugin/test_formatter_json.rb +61 -0
- data/test/plugin/test_formatter_ltsv.rb +70 -0
- data/test/plugin/test_formatter_msgpack.rb +28 -0
- data/test/plugin/test_formatter_out_file.rb +116 -0
- data/test/plugin/test_formatter_single_value.rb +44 -0
- data/test/plugin/test_formatter_tsv.rb +76 -0
- data/test/plugin/test_in_debug_agent.rb +49 -0
- data/test/plugin/test_in_exec.rb +261 -0
- data/test/plugin/test_in_forward.rb +1180 -0
- data/test/plugin/test_in_gc_stat.rb +62 -0
- data/test/plugin/test_in_http.rb +1080 -0
- data/test/plugin/test_in_monitor_agent.rb +923 -0
- data/test/plugin/test_in_object_space.rb +60 -0
- data/test/plugin/test_in_sample.rb +190 -0
- data/test/plugin/test_in_syslog.rb +505 -0
- data/test/plugin/test_in_tail.rb +2363 -0
- data/test/plugin/test_in_tcp.rb +243 -0
- data/test/plugin/test_in_udp.rb +268 -0
- data/test/plugin/test_in_unix.rb +181 -0
- data/test/plugin/test_input.rb +137 -0
- data/test/plugin/test_metadata.rb +89 -0
- data/test/plugin/test_metrics.rb +294 -0
- data/test/plugin/test_metrics_local.rb +96 -0
- data/test/plugin/test_multi_output.rb +204 -0
- data/test/plugin/test_out_copy.rb +308 -0
- data/test/plugin/test_out_exec.rb +312 -0
- data/test/plugin/test_out_exec_filter.rb +606 -0
- data/test/plugin/test_out_file.rb +1037 -0
- data/test/plugin/test_out_forward.rb +1348 -0
- data/test/plugin/test_out_http.rb +428 -0
- data/test/plugin/test_out_null.rb +105 -0
- data/test/plugin/test_out_relabel.rb +28 -0
- data/test/plugin/test_out_roundrobin.rb +146 -0
- data/test/plugin/test_out_secondary_file.rb +458 -0
- data/test/plugin/test_out_stdout.rb +205 -0
- data/test/plugin/test_out_stream.rb +103 -0
- data/test/plugin/test_output.rb +1065 -0
- data/test/plugin/test_output_as_buffered.rb +2024 -0
- data/test/plugin/test_output_as_buffered_backup.rb +363 -0
- data/test/plugin/test_output_as_buffered_compress.rb +165 -0
- data/test/plugin/test_output_as_buffered_overflow.rb +250 -0
- data/test/plugin/test_output_as_buffered_retries.rb +919 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +882 -0
- data/test/plugin/test_output_as_standard.rb +374 -0
- data/test/plugin/test_owned_by.rb +35 -0
- data/test/plugin/test_parser.rb +399 -0
- data/test/plugin/test_parser_apache.rb +42 -0
- data/test/plugin/test_parser_apache2.rb +47 -0
- data/test/plugin/test_parser_apache_error.rb +45 -0
- data/test/plugin/test_parser_csv.rb +200 -0
- data/test/plugin/test_parser_json.rb +138 -0
- data/test/plugin/test_parser_labeled_tsv.rb +160 -0
- data/test/plugin/test_parser_multiline.rb +111 -0
- data/test/plugin/test_parser_nginx.rb +88 -0
- data/test/plugin/test_parser_none.rb +52 -0
- data/test/plugin/test_parser_regexp.rb +289 -0
- data/test/plugin/test_parser_syslog.rb +650 -0
- data/test/plugin/test_parser_tsv.rb +122 -0
- data/test/plugin/test_sd_file.rb +228 -0
- data/test/plugin/test_sd_srv.rb +230 -0
- data/test/plugin/test_storage.rb +167 -0
- data/test/plugin/test_storage_local.rb +335 -0
- data/test/plugin/test_string_util.rb +26 -0
- data/test/plugin_helper/data/cert/cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/cert-with-CRLF.pem +19 -0
- data/test/plugin_helper/data/cert/cert-with-no-newline.pem +19 -0
- data/test/plugin_helper/data/cert/cert.pem +19 -0
- data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +20 -0
- data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/cert_chains/cert.pem +40 -0
- data/test/plugin_helper/data/cert/empty.pem +0 -0
- data/test/plugin_helper/data/cert/generate_cert.rb +125 -0
- data/test/plugin_helper/data/cert/with_ca/ca-cert-key-pass.pem +30 -0
- data/test/plugin_helper/data/cert/with_ca/ca-cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/with_ca/ca-cert-pass.pem +20 -0
- data/test/plugin_helper/data/cert/with_ca/ca-cert.pem +20 -0
- data/test/plugin_helper/data/cert/with_ca/cert-key-pass.pem +30 -0
- data/test/plugin_helper/data/cert/with_ca/cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/with_ca/cert-pass.pem +21 -0
- data/test/plugin_helper/data/cert/with_ca/cert.pem +21 -0
- data/test/plugin_helper/data/cert/without_ca/cert-key-pass.pem +30 -0
- data/test/plugin_helper/data/cert/without_ca/cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/without_ca/cert-pass.pem +20 -0
- data/test/plugin_helper/data/cert/without_ca/cert.pem +20 -0
- data/test/plugin_helper/http_server/test_app.rb +65 -0
- data/test/plugin_helper/http_server/test_route.rb +32 -0
- data/test/plugin_helper/service_discovery/test_manager.rb +93 -0
- data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +21 -0
- data/test/plugin_helper/test_cert_option.rb +25 -0
- data/test/plugin_helper/test_child_process.rb +840 -0
- data/test/plugin_helper/test_compat_parameters.rb +358 -0
- data/test/plugin_helper/test_event_emitter.rb +80 -0
- data/test/plugin_helper/test_event_loop.rb +52 -0
- data/test/plugin_helper/test_extract.rb +194 -0
- data/test/plugin_helper/test_formatter.rb +255 -0
- data/test/plugin_helper/test_http_server_helper.rb +372 -0
- data/test/plugin_helper/test_inject.rb +561 -0
- data/test/plugin_helper/test_metrics.rb +137 -0
- data/test/plugin_helper/test_parser.rb +264 -0
- data/test/plugin_helper/test_record_accessor.rb +238 -0
- data/test/plugin_helper/test_retry_state.rb +442 -0
- data/test/plugin_helper/test_server.rb +1823 -0
- data/test/plugin_helper/test_service_discovery.rb +165 -0
- data/test/plugin_helper/test_socket.rb +146 -0
- data/test/plugin_helper/test_storage.rb +542 -0
- data/test/plugin_helper/test_thread.rb +164 -0
- data/test/plugin_helper/test_timer.rb +130 -0
- data/test/scripts/exec_script.rb +32 -0
- data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +7 -0
- data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +7 -0
- data/test/scripts/fluent/plugin/formatter_known.rb +8 -0
- data/test/scripts/fluent/plugin/out_test.rb +81 -0
- data/test/scripts/fluent/plugin/out_test2.rb +80 -0
- data/test/scripts/fluent/plugin/parser_known.rb +4 -0
- data/test/test_capability.rb +74 -0
- data/test/test_clock.rb +164 -0
- data/test/test_config.rb +202 -0
- data/test/test_configdsl.rb +148 -0
- data/test/test_daemonizer.rb +91 -0
- data/test/test_engine.rb +203 -0
- data/test/test_event.rb +531 -0
- data/test/test_event_router.rb +331 -0
- data/test/test_event_time.rb +199 -0
- data/test/test_filter.rb +121 -0
- data/test/test_fluent_log_event_router.rb +99 -0
- data/test/test_formatter.rb +366 -0
- data/test/test_input.rb +31 -0
- data/test/test_log.rb +994 -0
- data/test/test_logger_initializer.rb +46 -0
- data/test/test_match.rb +148 -0
- data/test/test_mixin.rb +351 -0
- data/test/test_msgpack_factory.rb +18 -0
- data/test/test_oj_options.rb +55 -0
- data/test/test_output.rb +278 -0
- data/test/test_plugin.rb +251 -0
- data/test/test_plugin_classes.rb +370 -0
- data/test/test_plugin_helper.rb +81 -0
- data/test/test_plugin_id.rb +119 -0
- data/test/test_process.rb +14 -0
- data/test/test_root_agent.rb +951 -0
- data/test/test_static_config_analysis.rb +177 -0
- data/test/test_supervisor.rb +601 -0
- data/test/test_test_drivers.rb +136 -0
- data/test/test_time_formatter.rb +301 -0
- data/test/test_time_parser.rb +362 -0
- data/test/test_tls.rb +65 -0
- data/test/test_unique_id.rb +47 -0
- data/test/test_variable_store.rb +65 -0
- metadata +1261 -0
@@ -0,0 +1,826 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/output'
|
18
|
+
require 'fluent/config/error'
|
19
|
+
require 'fluent/clock'
|
20
|
+
require 'fluent/tls'
|
21
|
+
require 'base64'
|
22
|
+
require 'forwardable'
|
23
|
+
|
24
|
+
require 'fluent/compat/socket_util'
|
25
|
+
require 'fluent/plugin/out_forward/handshake_protocol'
|
26
|
+
require 'fluent/plugin/out_forward/load_balancer'
|
27
|
+
require 'fluent/plugin/out_forward/socket_cache'
|
28
|
+
require 'fluent/plugin/out_forward/failure_detector'
|
29
|
+
require 'fluent/plugin/out_forward/error'
|
30
|
+
require 'fluent/plugin/out_forward/connection_manager'
|
31
|
+
require 'fluent/plugin/out_forward/ack_handler'
|
32
|
+
|
33
|
+
module Fluent::Plugin
|
34
|
+
class ForwardOutput < Output
|
35
|
+
Fluent::Plugin.register_output('forward', self)
|
36
|
+
|
37
|
+
helpers :socket, :server, :timer, :thread, :compat_parameters, :service_discovery
|
38
|
+
|
39
|
+
LISTEN_PORT = 24224
|
40
|
+
|
41
|
+
desc 'The transport protocol.'
|
42
|
+
config_param :transport, :enum, list: [:tcp, :tls], default: :tcp
|
43
|
+
# TODO: TLS session cache/tickets
|
44
|
+
|
45
|
+
desc 'The timeout time when sending event logs.'
|
46
|
+
config_param :send_timeout, :time, default: 60
|
47
|
+
desc 'The timeout time for socket connect'
|
48
|
+
config_param :connect_timeout, :time, default: nil
|
49
|
+
# TODO: add linger_timeout, recv_timeout
|
50
|
+
|
51
|
+
desc 'The protocol to use for heartbeats (default is the same with "transport").'
|
52
|
+
config_param :heartbeat_type, :enum, list: [:transport, :tcp, :udp, :none], default: :transport
|
53
|
+
desc 'The interval of the heartbeat packer.'
|
54
|
+
config_param :heartbeat_interval, :time, default: 1
|
55
|
+
desc 'The wait time before accepting a server fault recovery.'
|
56
|
+
config_param :recover_wait, :time, default: 10
|
57
|
+
desc 'The hard timeout used to detect server failure.'
|
58
|
+
config_param :hard_timeout, :time, default: 60
|
59
|
+
desc 'The threshold parameter used to detect server faults.'
|
60
|
+
config_param :phi_threshold, :integer, default: 16
|
61
|
+
desc 'Use the "Phi accrual failure detector" to detect server failure.'
|
62
|
+
config_param :phi_failure_detector, :bool, default: true
|
63
|
+
|
64
|
+
desc 'Change the protocol to at-least-once.'
|
65
|
+
config_param :require_ack_response, :bool, default: false # require in_forward to respond with ack
|
66
|
+
|
67
|
+
## The reason of default value of :ack_response_timeout:
|
68
|
+
# Linux default tcp_syn_retries is 5 (in many environment)
|
69
|
+
# 3 + 6 + 12 + 24 + 48 + 96 -> 189 (sec)
|
70
|
+
desc 'This option is used when require_ack_response is true.'
|
71
|
+
config_param :ack_response_timeout, :time, default: 190
|
72
|
+
|
73
|
+
desc 'The interval while reading data from server'
|
74
|
+
config_param :read_interval_msec, :integer, default: 50 # 50ms
|
75
|
+
desc 'Reading data size from server'
|
76
|
+
config_param :read_length, :size, default: 512 # 512bytes
|
77
|
+
|
78
|
+
desc 'Set TTL to expire DNS cache in seconds.'
|
79
|
+
config_param :expire_dns_cache, :time, default: nil # 0 means disable cache
|
80
|
+
desc 'Enable client-side DNS round robin.'
|
81
|
+
config_param :dns_round_robin, :bool, default: false # heartbeat_type 'udp' is not available for this
|
82
|
+
|
83
|
+
desc 'Ignore DNS resolution and errors at startup time.'
|
84
|
+
config_param :ignore_network_errors_at_startup, :bool, default: false
|
85
|
+
|
86
|
+
desc 'Verify that a connection can be made with one of out_forward nodes at the time of startup.'
|
87
|
+
config_param :verify_connection_at_startup, :bool, default: false
|
88
|
+
|
89
|
+
desc 'Compress buffered data.'
|
90
|
+
config_param :compress, :enum, list: [:text, :gzip], default: :text
|
91
|
+
|
92
|
+
desc 'The default version of TLS transport.'
|
93
|
+
config_param :tls_version, :enum, list: Fluent::TLS::SUPPORTED_VERSIONS, default: Fluent::TLS::DEFAULT_VERSION
|
94
|
+
desc 'The cipher configuration of TLS transport.'
|
95
|
+
config_param :tls_ciphers, :string, default: Fluent::TLS::CIPHERS_DEFAULT
|
96
|
+
desc 'Skip all verification of certificates or not.'
|
97
|
+
config_param :tls_insecure_mode, :bool, default: false
|
98
|
+
desc 'Allow self signed certificates or not.'
|
99
|
+
config_param :tls_allow_self_signed_cert, :bool, default: false
|
100
|
+
desc 'Verify hostname of servers and certificates or not in TLS transport.'
|
101
|
+
config_param :tls_verify_hostname, :bool, default: true
|
102
|
+
desc 'The additional CA certificate path for TLS.'
|
103
|
+
config_param :tls_ca_cert_path, :array, value_type: :string, default: nil
|
104
|
+
desc 'The additional certificate path for TLS.'
|
105
|
+
config_param :tls_cert_path, :array, value_type: :string, default: nil
|
106
|
+
desc 'The client certificate path for TLS.'
|
107
|
+
config_param :tls_client_cert_path, :string, default: nil
|
108
|
+
desc 'The client private key path for TLS.'
|
109
|
+
config_param :tls_client_private_key_path, :string, default: nil
|
110
|
+
desc 'The client private key passphrase for TLS.'
|
111
|
+
config_param :tls_client_private_key_passphrase, :string, default: nil, secret: true
|
112
|
+
desc 'The certificate thumbprint for searching from Windows system certstore.'
|
113
|
+
config_param :tls_cert_thumbprint, :string, default: nil, secret: true
|
114
|
+
desc 'The certificate logical store name on Windows system certstore.'
|
115
|
+
config_param :tls_cert_logical_store_name, :string, default: nil
|
116
|
+
desc 'Enable to use certificate enterprise store on Windows system certstore.'
|
117
|
+
config_param :tls_cert_use_enterprise_store, :bool, default: true
|
118
|
+
desc "Enable keepalive connection."
|
119
|
+
config_param :keepalive, :bool, default: false
|
120
|
+
desc "Expired time of keepalive. Default value is nil, which means to keep connection as long as possible"
|
121
|
+
config_param :keepalive_timeout, :time, default: nil
|
122
|
+
|
123
|
+
config_section :security, required: false, multi: false do
|
124
|
+
desc 'The hostname'
|
125
|
+
config_param :self_hostname, :string
|
126
|
+
desc 'Shared key for authentication'
|
127
|
+
config_param :shared_key, :string, secret: true
|
128
|
+
end
|
129
|
+
|
130
|
+
config_section :server, param_name: :servers do
|
131
|
+
desc "The IP address or host name of the server."
|
132
|
+
config_param :host, :string
|
133
|
+
desc "The name of the server. Used for logging and certificate verification in TLS transport (when host is address)."
|
134
|
+
config_param :name, :string, default: nil
|
135
|
+
desc "The port number of the host."
|
136
|
+
config_param :port, :integer, default: LISTEN_PORT
|
137
|
+
desc "The shared key per server."
|
138
|
+
config_param :shared_key, :string, default: nil, secret: true
|
139
|
+
desc "The username for authentication."
|
140
|
+
config_param :username, :string, default: ''
|
141
|
+
desc "The password for authentication."
|
142
|
+
config_param :password, :string, default: '', secret: true
|
143
|
+
desc "Marks a node as the standby node for an Active-Standby model between Fluentd nodes."
|
144
|
+
config_param :standby, :bool, default: false
|
145
|
+
desc "The load balancing weight."
|
146
|
+
config_param :weight, :integer, default: 60
|
147
|
+
end
|
148
|
+
|
149
|
+
attr_reader :nodes
|
150
|
+
|
151
|
+
config_param :port, :integer, default: LISTEN_PORT, obsoleted: "User <server> section instead."
|
152
|
+
config_param :host, :string, default: nil, obsoleted: "Use <server> section instead."
|
153
|
+
|
154
|
+
config_section :buffer do
|
155
|
+
config_set_default :chunk_keys, ["tag"]
|
156
|
+
end
|
157
|
+
|
158
|
+
attr_reader :read_interval, :recover_sample_size
|
159
|
+
|
160
|
+
def initialize
|
161
|
+
super
|
162
|
+
|
163
|
+
@nodes = [] #=> [Node]
|
164
|
+
@loop = nil
|
165
|
+
@thread = nil
|
166
|
+
|
167
|
+
@usock = nil
|
168
|
+
@keep_alive_watcher_interval = 5 # TODO
|
169
|
+
@suspend_flush = false
|
170
|
+
@healthy_nodes_count_metrics = nil
|
171
|
+
@registered_nodes_count_metrics = nil
|
172
|
+
end
|
173
|
+
|
174
|
+
def configure(conf)
|
175
|
+
compat_parameters_convert(conf, :buffer, default_chunk_key: 'tag')
|
176
|
+
|
177
|
+
super
|
178
|
+
|
179
|
+
unless @chunk_key_tag
|
180
|
+
raise Fluent::ConfigError, "buffer chunk key must include 'tag' for forward output"
|
181
|
+
end
|
182
|
+
|
183
|
+
@read_interval = @read_interval_msec / 1000.0
|
184
|
+
@recover_sample_size = @recover_wait / @heartbeat_interval
|
185
|
+
|
186
|
+
if @heartbeat_type == :tcp
|
187
|
+
log.warn "'heartbeat_type tcp' is deprecated. use 'transport' instead."
|
188
|
+
@heartbeat_type = :transport
|
189
|
+
end
|
190
|
+
|
191
|
+
if @dns_round_robin && @heartbeat_type == :udp
|
192
|
+
raise Fluent::ConfigError, "forward output heartbeat type must be 'transport' or 'none' to use dns_round_robin option"
|
193
|
+
end
|
194
|
+
|
195
|
+
if @transport == :tls
|
196
|
+
# socket helper adds CA cert or signed certificate to same cert store internally so unify it in this place.
|
197
|
+
if @tls_cert_path && !@tls_cert_path.empty?
|
198
|
+
@tls_ca_cert_path = @tls_cert_path
|
199
|
+
end
|
200
|
+
if @tls_ca_cert_path && !@tls_ca_cert_path.empty?
|
201
|
+
@tls_ca_cert_path.each do |path|
|
202
|
+
raise Fluent::ConfigError, "specified cert path does not exist:#{path}" unless File.exist?(path)
|
203
|
+
raise Fluent::ConfigError, "specified cert path is not readable:#{path}" unless File.readable?(path)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
if @tls_insecure_mode
|
208
|
+
log.warn "TLS transport is configured in insecure way"
|
209
|
+
@tls_verify_hostname = false
|
210
|
+
@tls_allow_self_signed_cert = true
|
211
|
+
end
|
212
|
+
|
213
|
+
if Fluent.windows?
|
214
|
+
if (@tls_cert_path || @tls_ca_cert_path) && @tls_cert_logical_store_name
|
215
|
+
raise Fluent::ConfigError, "specified both cert path and tls_cert_logical_store_name is not permitted"
|
216
|
+
end
|
217
|
+
else
|
218
|
+
raise Fluent::ConfigError, "This parameter is for only Windows" if @tls_cert_logical_store_name
|
219
|
+
raise Fluent::ConfigError, "This parameter is for only Windows" if @tls_cert_thumbprint
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
@ack_handler = @require_ack_response ? AckHandler.new(timeout: @ack_response_timeout, log: @log, read_length: @read_length) : nil
|
224
|
+
socket_cache = @keepalive ? SocketCache.new(@keepalive_timeout, @log) : nil
|
225
|
+
@connection_manager = ConnectionManager.new(
|
226
|
+
log: @log,
|
227
|
+
secure: !!@security,
|
228
|
+
connection_factory: method(:create_transfer_socket),
|
229
|
+
socket_cache: socket_cache,
|
230
|
+
)
|
231
|
+
|
232
|
+
service_discovery_configure(
|
233
|
+
:out_forward_service_discovery_watcher,
|
234
|
+
static_default_service_directive: 'server',
|
235
|
+
load_balancer: LoadBalancer.new(log),
|
236
|
+
custom_build_method: method(:build_node),
|
237
|
+
)
|
238
|
+
|
239
|
+
service_discovery_services.each do |server|
|
240
|
+
# it's only for test
|
241
|
+
@nodes << server
|
242
|
+
unless @heartbeat_type == :none
|
243
|
+
begin
|
244
|
+
server.validate_host_resolution!
|
245
|
+
rescue => e
|
246
|
+
raise unless @ignore_network_errors_at_startup
|
247
|
+
log.warn "failed to resolve node name when configured", server: (server.name || server.host), error: e
|
248
|
+
server.disable!
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
unless @as_secondary
|
254
|
+
if @compress == :gzip && @buffer.compress == :text
|
255
|
+
@buffer.compress = :gzip
|
256
|
+
elsif @compress == :text && @buffer.compress == :gzip
|
257
|
+
log.info "buffer is compressed. If you also want to save the bandwidth of a network, Add `compress` configuration in <match>"
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
if service_discovery_services.empty?
|
262
|
+
raise Fluent::ConfigError, "forward output plugin requires at least one node is required. Add <server> or <service_discovery>"
|
263
|
+
end
|
264
|
+
|
265
|
+
if !@keepalive && @keepalive_timeout
|
266
|
+
log.warn('The value of keepalive_timeout is ignored. if you want to use keepalive, please add `keepalive true` to your conf.')
|
267
|
+
end
|
268
|
+
|
269
|
+
raise Fluent::ConfigError, "ack_response_timeout must be a positive integer" if @ack_response_timeout < 1
|
270
|
+
@healthy_nodes_count_metrics = metrics_create(namespace: "fluentd", subsystem: "output", name: "healthy_nodes_count", help_text: "Number of count healthy nodes", prefer_gauge: true)
|
271
|
+
@registered_nodes_count_metrics = metrics_create(namespace: "fluentd", subsystem: "output", name: "registered_nodes_count", help_text: "Number of count registered nodes", prefer_gauge: true)
|
272
|
+
|
273
|
+
end
|
274
|
+
|
275
|
+
def multi_workers_ready?
|
276
|
+
true
|
277
|
+
end
|
278
|
+
|
279
|
+
def prefer_delayed_commit
|
280
|
+
@require_ack_response
|
281
|
+
end
|
282
|
+
|
283
|
+
def overwrite_delayed_commit_timeout
|
284
|
+
# Output#start sets @delayed_commit_timeout by @buffer_config.delayed_commit_timeout
|
285
|
+
# But it should be overwritten by ack_response_timeout to rollback chunks after timeout
|
286
|
+
if @delayed_commit_timeout != @ack_response_timeout
|
287
|
+
log.info "delayed_commit_timeout is overwritten by ack_response_timeout"
|
288
|
+
@delayed_commit_timeout = @ack_response_timeout + 2 # minimum ack_reader IO.select interval is 1s
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def start
|
293
|
+
super
|
294
|
+
|
295
|
+
unless @heartbeat_type == :none
|
296
|
+
if @heartbeat_type == :udp
|
297
|
+
@usock = socket_create_udp(service_discovery_services.first.host, service_discovery_services.first.port, nonblock: true)
|
298
|
+
server_create_udp(:out_forward_heartbeat_receiver, 0, socket: @usock, max_bytes: @read_length, &method(:on_udp_heatbeat_response_recv))
|
299
|
+
end
|
300
|
+
timer_execute(:out_forward_heartbeat_request, @heartbeat_interval, &method(:on_heartbeat_timer))
|
301
|
+
end
|
302
|
+
|
303
|
+
if @require_ack_response
|
304
|
+
overwrite_delayed_commit_timeout
|
305
|
+
thread_create(:out_forward_receiving_ack, &method(:ack_reader))
|
306
|
+
end
|
307
|
+
|
308
|
+
if @verify_connection_at_startup
|
309
|
+
service_discovery_services.each do |node|
|
310
|
+
begin
|
311
|
+
node.verify_connection
|
312
|
+
rescue StandardError => e
|
313
|
+
log.fatal "forward's connection setting error: #{e.message}"
|
314
|
+
raise Fluent::UnrecoverableError, e.message
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
if @keepalive
|
320
|
+
timer_execute(:out_forward_keep_alived_socket_watcher, @keep_alive_watcher_interval, &method(:on_purge_obsolete_socks))
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
def close
|
325
|
+
if @usock
|
326
|
+
# close socket and ignore errors: this socket will not be used anyway.
|
327
|
+
@usock.close rescue nil
|
328
|
+
end
|
329
|
+
|
330
|
+
super
|
331
|
+
end
|
332
|
+
|
333
|
+
def stop
|
334
|
+
super
|
335
|
+
|
336
|
+
if @keepalive
|
337
|
+
@connection_manager.stop
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
def before_shutdown
|
342
|
+
super
|
343
|
+
@suspend_flush = true
|
344
|
+
end
|
345
|
+
|
346
|
+
def after_shutdown
|
347
|
+
last_ack if @require_ack_response
|
348
|
+
super
|
349
|
+
end
|
350
|
+
|
351
|
+
def try_flush
|
352
|
+
return if @require_ack_response && @suspend_flush
|
353
|
+
super
|
354
|
+
end
|
355
|
+
|
356
|
+
def last_ack
|
357
|
+
overwrite_delayed_commit_timeout
|
358
|
+
ack_check(ack_select_interval)
|
359
|
+
end
|
360
|
+
|
361
|
+
def write(chunk)
|
362
|
+
return if chunk.empty?
|
363
|
+
tag = chunk.metadata.tag
|
364
|
+
|
365
|
+
service_discovery_select_service { |node| node.send_data(tag, chunk) }
|
366
|
+
end
|
367
|
+
|
368
|
+
def try_write(chunk)
|
369
|
+
log.trace "writing a chunk to destination", chunk_id: dump_unique_id_hex(chunk.unique_id)
|
370
|
+
if chunk.empty?
|
371
|
+
commit_write(chunk.unique_id)
|
372
|
+
return
|
373
|
+
end
|
374
|
+
tag = chunk.metadata.tag
|
375
|
+
service_discovery_select_service { |node| node.send_data(tag, chunk) }
|
376
|
+
last_ack if @require_ack_response && @suspend_flush
|
377
|
+
end
|
378
|
+
|
379
|
+
def create_transfer_socket(host, port, hostname, &block)
|
380
|
+
case @transport
|
381
|
+
when :tls
|
382
|
+
socket_create_tls(
|
383
|
+
host, port,
|
384
|
+
version: @tls_version,
|
385
|
+
ciphers: @tls_ciphers,
|
386
|
+
insecure: @tls_insecure_mode,
|
387
|
+
verify_fqdn: @tls_verify_hostname,
|
388
|
+
fqdn: hostname,
|
389
|
+
allow_self_signed_cert: @tls_allow_self_signed_cert,
|
390
|
+
cert_paths: @tls_ca_cert_path,
|
391
|
+
cert_path: @tls_client_cert_path,
|
392
|
+
private_key_path: @tls_client_private_key_path,
|
393
|
+
private_key_passphrase: @tls_client_private_key_passphrase,
|
394
|
+
cert_thumbprint: @tls_cert_thumbprint,
|
395
|
+
cert_logical_store_name: @tls_cert_logical_store_name,
|
396
|
+
cert_use_enterprise_store: @tls_cert_use_enterprise_store,
|
397
|
+
|
398
|
+
# Enabling SO_LINGER causes tcp port exhaustion on Windows.
|
399
|
+
# This is because dynamic ports are only 16384 (from 49152 to 65535) and
|
400
|
+
# expiring SO_LINGER enabled ports should wait 4 minutes
|
401
|
+
# where set by TcpTimeDelay. Its default value is 4 minutes.
|
402
|
+
# So, we should disable SO_LINGER on Windows to prevent flood of waiting ports.
|
403
|
+
linger_timeout: Fluent.windows? ? nil : @send_timeout,
|
404
|
+
send_timeout: @send_timeout,
|
405
|
+
recv_timeout: @ack_response_timeout,
|
406
|
+
connect_timeout: @connect_timeout,
|
407
|
+
&block
|
408
|
+
)
|
409
|
+
when :tcp
|
410
|
+
socket_create_tcp(
|
411
|
+
host, port,
|
412
|
+
linger_timeout: @send_timeout,
|
413
|
+
send_timeout: @send_timeout,
|
414
|
+
recv_timeout: @ack_response_timeout,
|
415
|
+
connect_timeout: @connect_timeout,
|
416
|
+
&block
|
417
|
+
)
|
418
|
+
else
|
419
|
+
raise "BUG: unknown transport protocol #{@transport}"
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
def statistics
|
424
|
+
stats = super
|
425
|
+
services = service_discovery_services
|
426
|
+
@healthy_nodes_count_metrics.set(0)
|
427
|
+
@registered_nodes_count_metrics.set(services.size)
|
428
|
+
services.each do |s|
|
429
|
+
if s.available?
|
430
|
+
@healthy_nodes_count_metrics.inc
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
stats = {
|
435
|
+
'output' => stats["output"].merge({
|
436
|
+
'healthy_nodes_count' => @healthy_nodes_count_metrics.get,
|
437
|
+
'registered_nodes_count' => @registered_nodes_count_metrics.get,
|
438
|
+
})
|
439
|
+
}
|
440
|
+
stats
|
441
|
+
end
|
442
|
+
|
443
|
+
# MessagePack FixArray length is 3
|
444
|
+
FORWARD_HEADER = [0x93].pack('C').freeze
|
445
|
+
def forward_header
|
446
|
+
FORWARD_HEADER
|
447
|
+
end
|
448
|
+
|
449
|
+
private
|
450
|
+
|
451
|
+
def build_node(server)
|
452
|
+
name = server.name || "#{server.host}:#{server.port}"
|
453
|
+
log.info "adding forwarding server '#{name}'", host: server.host, port: server.port, weight: server.weight, plugin_id: plugin_id
|
454
|
+
|
455
|
+
failure = FailureDetector.new(@heartbeat_interval, @hard_timeout, Time.now.to_i.to_f)
|
456
|
+
if @heartbeat_type == :none
|
457
|
+
NoneHeartbeatNode.new(self, server, failure: failure, connection_manager: @connection_manager, ack_handler: @ack_handler)
|
458
|
+
else
|
459
|
+
Node.new(self, server, failure: failure, connection_manager: @connection_manager, ack_handler: @ack_handler)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
def on_heartbeat_timer
|
464
|
+
need_rebuild = false
|
465
|
+
service_discovery_services.each do |n|
|
466
|
+
begin
|
467
|
+
log.trace "sending heartbeat", host: n.host, port: n.port, heartbeat_type: @heartbeat_type
|
468
|
+
n.usock = @usock if @usock
|
469
|
+
need_rebuild = n.send_heartbeat || need_rebuild
|
470
|
+
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINTR, Errno::ECONNREFUSED, Errno::ETIMEDOUT => e
|
471
|
+
log.debug "failed to send heartbeat packet", host: n.host, port: n.port, heartbeat_type: @heartbeat_type, error: e
|
472
|
+
rescue => e
|
473
|
+
log.debug "unexpected error happen during heartbeat", host: n.host, port: n.port, heartbeat_type: @heartbeat_type, error: e
|
474
|
+
end
|
475
|
+
|
476
|
+
need_rebuild = n.tick || need_rebuild
|
477
|
+
end
|
478
|
+
|
479
|
+
if need_rebuild
|
480
|
+
service_discovery_rebalance
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
484
|
+
def on_udp_heatbeat_response_recv(data, sock)
|
485
|
+
sockaddr = Socket.pack_sockaddr_in(sock.remote_port, sock.remote_host)
|
486
|
+
if node = service_discovery_services.find { |n| n.sockaddr == sockaddr }
|
487
|
+
# log.trace "heartbeat arrived", name: node.name, host: node.host, port: node.port
|
488
|
+
if node.heartbeat
|
489
|
+
service_discovery_rebalance
|
490
|
+
end
|
491
|
+
else
|
492
|
+
log.warn("Unknown heartbeat response received from #{sock.remote_host}:#{sock.remote_port}. It may service out")
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
def on_purge_obsolete_socks
|
497
|
+
@connection_manager.purge_obsolete_socks
|
498
|
+
end
|
499
|
+
|
500
|
+
def ack_select_interval
|
501
|
+
if @delayed_commit_timeout > 3
|
502
|
+
1
|
503
|
+
else
|
504
|
+
@delayed_commit_timeout / 3.0
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
508
|
+
def ack_reader
|
509
|
+
select_interval = ack_select_interval
|
510
|
+
|
511
|
+
while thread_current_running?
|
512
|
+
ack_check(select_interval)
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
def ack_check(select_interval)
|
517
|
+
@ack_handler.collect_response(select_interval) do |chunk_id, node, sock, result|
|
518
|
+
@connection_manager.close(sock)
|
519
|
+
|
520
|
+
case result
|
521
|
+
when AckHandler::Result::SUCCESS
|
522
|
+
commit_write(chunk_id)
|
523
|
+
when AckHandler::Result::FAILED
|
524
|
+
node.disable!
|
525
|
+
rollback_write(chunk_id, update_retry: false)
|
526
|
+
when AckHandler::Result::CHUNKID_UNMATCHED
|
527
|
+
rollback_write(chunk_id, update_retry: false)
|
528
|
+
else
|
529
|
+
log.warn("BUG: invalid status #{result} #{chunk_id}")
|
530
|
+
|
531
|
+
if chunk_id
|
532
|
+
rollback_write(chunk_id, update_retry: false)
|
533
|
+
end
|
534
|
+
end
|
535
|
+
end
|
536
|
+
end
|
537
|
+
|
538
|
+
class Node
|
539
|
+
extend Forwardable
|
540
|
+
def_delegators :@server, :discovery_id, :host, :port, :name, :weight, :standby
|
541
|
+
|
542
|
+
# @param connection_manager [Fluent::Plugin::ForwardOutput::ConnectionManager]
|
543
|
+
# @param ack_handler [Fluent::Plugin::ForwardOutput::AckHandler]
|
544
|
+
def initialize(sender, server, failure:, connection_manager:, ack_handler:)
|
545
|
+
@sender = sender
|
546
|
+
@log = sender.log
|
547
|
+
@compress = sender.compress
|
548
|
+
@server = server
|
549
|
+
|
550
|
+
@name = server.name
|
551
|
+
@host = server.host
|
552
|
+
@port = server.port
|
553
|
+
@weight = server.weight
|
554
|
+
@standby = server.standby
|
555
|
+
@failure = failure
|
556
|
+
@available = true
|
557
|
+
|
558
|
+
# @hostname is used for certificate verification & TLS SNI
|
559
|
+
host_is_hostname = !(IPAddr.new(@host) rescue false)
|
560
|
+
@hostname = case
|
561
|
+
when host_is_hostname then @host
|
562
|
+
when @name then @name
|
563
|
+
else nil
|
564
|
+
end
|
565
|
+
|
566
|
+
@usock = nil
|
567
|
+
|
568
|
+
@handshake = HandshakeProtocol.new(
|
569
|
+
log: @log,
|
570
|
+
hostname: sender.security && sender.security.self_hostname,
|
571
|
+
shared_key: server.shared_key || (sender.security && sender.security.shared_key) || '',
|
572
|
+
password: server.password || '',
|
573
|
+
username: server.username || '',
|
574
|
+
)
|
575
|
+
|
576
|
+
@resolved_host = nil
|
577
|
+
@resolved_time = 0
|
578
|
+
@resolved_once = false
|
579
|
+
|
580
|
+
@connection_manager = connection_manager
|
581
|
+
@ack_handler = ack_handler
|
582
|
+
end
|
583
|
+
|
584
|
+
attr_accessor :usock
|
585
|
+
|
586
|
+
attr_reader :state
|
587
|
+
attr_reader :sockaddr # used by on_udp_heatbeat_response_recv
|
588
|
+
attr_reader :failure # for test
|
589
|
+
|
590
|
+
def validate_host_resolution!
|
591
|
+
resolved_host
|
592
|
+
end
|
593
|
+
|
594
|
+
def available?
|
595
|
+
@available
|
596
|
+
end
|
597
|
+
|
598
|
+
def disable!
|
599
|
+
@available = false
|
600
|
+
end
|
601
|
+
|
602
|
+
def standby?
|
603
|
+
@standby
|
604
|
+
end
|
605
|
+
|
606
|
+
def verify_connection
|
607
|
+
connect do |sock, ri|
|
608
|
+
ensure_established_connection(sock, ri)
|
609
|
+
end
|
610
|
+
end
|
611
|
+
|
612
|
+
def establish_connection(sock, ri)
|
613
|
+
while ri.state != :established
|
614
|
+
begin
|
615
|
+
# TODO: On Ruby 2.2 or earlier, read_nonblock doesn't work expectedly.
|
616
|
+
# We need rewrite around here using new socket/server plugin helper.
|
617
|
+
buf = sock.read_nonblock(@sender.read_length)
|
618
|
+
if buf.empty?
|
619
|
+
sleep @sender.read_interval
|
620
|
+
next
|
621
|
+
end
|
622
|
+
Fluent::MessagePackFactory.msgpack_unpacker.feed_each(buf) do |data|
|
623
|
+
if @handshake.invoke(sock, ri, data) == :established
|
624
|
+
@log.debug "connection established", host: @host, port: @port
|
625
|
+
end
|
626
|
+
end
|
627
|
+
rescue IO::WaitReadable
|
628
|
+
# If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, it is extended by IO::WaitReadable.
|
629
|
+
# So IO::WaitReadable can be used to rescue the exceptions for retrying read_nonblock.
|
630
|
+
# https//docs.ruby-lang.org/en/2.3.0/IO.html#method-i-read_nonblock
|
631
|
+
sleep @sender.read_interval unless ri.state == :established
|
632
|
+
rescue SystemCallError => e
|
633
|
+
@log.warn "disconnected by error", host: @host, port: @port, error: e
|
634
|
+
disable!
|
635
|
+
break
|
636
|
+
rescue EOFError
|
637
|
+
@log.warn "disconnected", host: @host, port: @port
|
638
|
+
disable!
|
639
|
+
break
|
640
|
+
rescue HeloError => e
|
641
|
+
@log.warn "received invalid helo message from #{@name}"
|
642
|
+
disable!
|
643
|
+
break
|
644
|
+
rescue PingpongError => e
|
645
|
+
@log.warn "connection refused to #{@name || @host}: #{e.message}"
|
646
|
+
disable!
|
647
|
+
break
|
648
|
+
end
|
649
|
+
end
|
650
|
+
end
|
651
|
+
|
652
|
+
def send_data_actual(sock, tag, chunk)
|
653
|
+
option = { 'size' => chunk.size, 'compressed' => @compress }
|
654
|
+
option['chunk'] = Base64.encode64(chunk.unique_id) if @ack_handler
|
655
|
+
|
656
|
+
# https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v1#packedforward-mode
|
657
|
+
# out_forward always uses str32 type for entries.
|
658
|
+
# str16 can store only 64kbytes, and it should be much smaller than buffer chunk size.
|
659
|
+
|
660
|
+
tag = tag.dup.force_encoding(Encoding::UTF_8)
|
661
|
+
|
662
|
+
sock.write @sender.forward_header # array, size=3
|
663
|
+
sock.write tag.to_msgpack # 1. tag: String (str)
|
664
|
+
chunk.open(compressed: @compress) do |chunk_io|
|
665
|
+
entries = [0xdb, chunk_io.size].pack('CN')
|
666
|
+
sock.write entries.force_encoding(Encoding::UTF_8) # 2. entries: String (str32)
|
667
|
+
IO.copy_stream(chunk_io, sock) # writeRawBody(packed_es)
|
668
|
+
end
|
669
|
+
sock.write option.to_msgpack # 3. option: Hash(map)
|
670
|
+
|
671
|
+
# TODO: use bin32 for non-utf8 content(entries) when old msgpack-ruby (0.5.x or earlier) not supported
|
672
|
+
end
|
673
|
+
|
674
|
+
def send_data(tag, chunk)
|
675
|
+
ack = @ack_handler && @ack_handler.create_ack(chunk.unique_id, self)
|
676
|
+
connect(nil, ack: ack) do |sock, ri|
|
677
|
+
ensure_established_connection(sock, ri)
|
678
|
+
send_data_actual(sock, tag, chunk)
|
679
|
+
end
|
680
|
+
|
681
|
+
heartbeat(false)
|
682
|
+
nil
|
683
|
+
end
|
684
|
+
|
685
|
+
# FORWARD_TCP_HEARTBEAT_DATA = FORWARD_HEADER + ''.to_msgpack + [].to_msgpack
|
686
|
+
#
|
687
|
+
# @return [Boolean] return true if it needs to rebuild nodes
|
688
|
+
def send_heartbeat
|
689
|
+
begin
|
690
|
+
dest_addr = resolved_host
|
691
|
+
@resolved_once = true
|
692
|
+
rescue ::SocketError => e
|
693
|
+
if !@resolved_once && @sender.ignore_network_errors_at_startup
|
694
|
+
@log.warn "failed to resolve node name in heartbeating", server: @name || @host, error: e
|
695
|
+
return false
|
696
|
+
end
|
697
|
+
raise
|
698
|
+
end
|
699
|
+
|
700
|
+
case @sender.heartbeat_type
|
701
|
+
when :transport
|
702
|
+
connect(dest_addr) do |sock, ri|
|
703
|
+
ensure_established_connection(sock, ri)
|
704
|
+
|
705
|
+
## don't send any data to not cause a compatibility problem
|
706
|
+
# sock.write FORWARD_TCP_HEARTBEAT_DATA
|
707
|
+
|
708
|
+
# successful tcp connection establishment is considered as valid heartbeat.
|
709
|
+
# When heartbeat is succeeded after detached, return true. It rebuilds weight array.
|
710
|
+
heartbeat(true)
|
711
|
+
end
|
712
|
+
when :udp
|
713
|
+
@usock.send "\0", 0, Socket.pack_sockaddr_in(@port, dest_addr)
|
714
|
+
# response is going to receive at on_udp_heatbeat_response_recv
|
715
|
+
false
|
716
|
+
when :none # :none doesn't use this class
|
717
|
+
raise "BUG: heartbeat_type none must not use Node"
|
718
|
+
else
|
719
|
+
raise "BUG: unknown heartbeat_type '#{@sender.heartbeat_type}'"
|
720
|
+
end
|
721
|
+
end
|
722
|
+
|
723
|
+
def resolved_host
|
724
|
+
case @sender.expire_dns_cache
|
725
|
+
when 0
|
726
|
+
# cache is disabled
|
727
|
+
resolve_dns!
|
728
|
+
|
729
|
+
when nil
|
730
|
+
# persistent cache
|
731
|
+
@resolved_host ||= resolve_dns!
|
732
|
+
|
733
|
+
else
|
734
|
+
now = Fluent::EventTime.now
|
735
|
+
rh = @resolved_host
|
736
|
+
if !rh || now - @resolved_time >= @sender.expire_dns_cache
|
737
|
+
rh = @resolved_host = resolve_dns!
|
738
|
+
@resolved_time = now
|
739
|
+
end
|
740
|
+
rh
|
741
|
+
end
|
742
|
+
end
|
743
|
+
|
744
|
+
def resolve_dns!
|
745
|
+
addrinfo_list = Socket.getaddrinfo(@host, @port, nil, Socket::SOCK_STREAM)
|
746
|
+
addrinfo = @sender.dns_round_robin ? addrinfo_list.sample : addrinfo_list.first
|
747
|
+
@sockaddr = Socket.pack_sockaddr_in(addrinfo[1], addrinfo[3]) # used by on_udp_heatbeat_response_recv
|
748
|
+
addrinfo[3]
|
749
|
+
end
|
750
|
+
private :resolve_dns!
|
751
|
+
|
752
|
+
def tick
|
753
|
+
now = Time.now.to_f
|
754
|
+
unless available?
|
755
|
+
if @failure.hard_timeout?(now)
|
756
|
+
@failure.clear
|
757
|
+
end
|
758
|
+
return nil
|
759
|
+
end
|
760
|
+
|
761
|
+
if @failure.hard_timeout?(now)
|
762
|
+
@log.warn "detached forwarding server '#{@name}'", host: @host, port: @port, hard_timeout: true
|
763
|
+
disable!
|
764
|
+
@resolved_host = nil # expire cached host
|
765
|
+
@failure.clear
|
766
|
+
return true
|
767
|
+
end
|
768
|
+
|
769
|
+
if @sender.phi_failure_detector
|
770
|
+
phi = @failure.phi(now)
|
771
|
+
if phi > @sender.phi_threshold
|
772
|
+
@log.warn "detached forwarding server '#{@name}'", host: @host, port: @port, phi: phi, phi_threshold: @sender.phi_threshold
|
773
|
+
disable!
|
774
|
+
@resolved_host = nil # expire cached host
|
775
|
+
@failure.clear
|
776
|
+
return true
|
777
|
+
end
|
778
|
+
end
|
779
|
+
false
|
780
|
+
end
|
781
|
+
|
782
|
+
def heartbeat(detect=true)
|
783
|
+
now = Time.now.to_f
|
784
|
+
@failure.add(now)
|
785
|
+
if detect && !available? && @failure.sample_size > @sender.recover_sample_size
|
786
|
+
@available = true
|
787
|
+
@log.warn "recovered forwarding server '#{@name}'", host: @host, port: @port
|
788
|
+
true
|
789
|
+
else
|
790
|
+
nil
|
791
|
+
end
|
792
|
+
end
|
793
|
+
|
794
|
+
private
|
795
|
+
|
796
|
+
def ensure_established_connection(sock, request_info)
|
797
|
+
if request_info.state != :established
|
798
|
+
establish_connection(sock, request_info)
|
799
|
+
|
800
|
+
if request_info.state != :established
|
801
|
+
raise ConnectionClosedError, "failed to establish connection with node #{@name}"
|
802
|
+
end
|
803
|
+
end
|
804
|
+
end
|
805
|
+
|
806
|
+
def connect(host = nil, ack: false, &block)
|
807
|
+
@connection_manager.connect(host: host || resolved_host, port: port, hostname: @hostname, ack: ack, &block)
|
808
|
+
end
|
809
|
+
end
|
810
|
+
|
811
|
+
# Override Node to disable heartbeat
|
812
|
+
class NoneHeartbeatNode < Node
|
813
|
+
def available?
|
814
|
+
true
|
815
|
+
end
|
816
|
+
|
817
|
+
def tick
|
818
|
+
false
|
819
|
+
end
|
820
|
+
|
821
|
+
def heartbeat(detect=true)
|
822
|
+
true
|
823
|
+
end
|
824
|
+
end
|
825
|
+
end
|
826
|
+
end
|