diff --git a/.editorconfig b/.editorconfig new file mode 100755 index 00000000..a263bb34 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,627 @@ +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = false +max_line_length = 120 +tab_width = 2 +ij_continuation_indent_size = 2 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = false +ij_smart_tabs = false +ij_visual_guides = none +ij_wrap_on_typing = false + +[*.java] +ij_java_align_consecutive_assignments = false +ij_java_align_consecutive_variable_declarations = false +ij_java_align_group_field_declarations = false +ij_java_align_multiline_annotation_parameters = false +ij_java_align_multiline_array_initializer_expression = false +ij_java_align_multiline_assignment = false +ij_java_align_multiline_binary_operation = false +ij_java_align_multiline_chained_methods = false +ij_java_align_multiline_extends_list = false +ij_java_align_multiline_for = true +ij_java_align_multiline_method_parentheses = false +ij_java_align_multiline_parameters = true +ij_java_align_multiline_parameters_in_calls = false +ij_java_align_multiline_parenthesized_expression = false +ij_java_align_multiline_records = true +ij_java_align_multiline_resources = true +ij_java_align_multiline_ternary_operation = false +ij_java_align_multiline_text_blocks = false +ij_java_align_multiline_throws_list = false +ij_java_align_subsequent_simple_methods = false +ij_java_align_throws_keyword = false +ij_java_annotation_parameter_wrap = off +ij_java_array_initializer_new_line_after_left_brace = false +ij_java_array_initializer_right_brace_on_new_line = false +ij_java_array_initializer_wrap = off +ij_java_assert_statement_colon_on_next_line = false +ij_java_assert_statement_wrap = off +ij_java_assignment_wrap = off +ij_java_binary_operation_sign_on_next_line = false +ij_java_binary_operation_wrap = off +ij_java_blank_lines_after_anonymous_class_header = 0 +ij_java_blank_lines_after_class_header = 0 +ij_java_blank_lines_after_imports = 1 +ij_java_blank_lines_after_package = 1 +ij_java_blank_lines_around_class = 1 +ij_java_blank_lines_around_field = 0 +ij_java_blank_lines_around_field_in_interface = 0 +ij_java_blank_lines_around_initializer = 1 +ij_java_blank_lines_around_method = 1 +ij_java_blank_lines_around_method_in_interface = 1 +ij_java_blank_lines_before_class_end = 0 +ij_java_blank_lines_before_imports = 1 +ij_java_blank_lines_before_method_body = 0 +ij_java_blank_lines_before_package = 0 +ij_java_block_brace_style = end_of_line +ij_java_block_comment_add_space = false +ij_java_block_comment_at_first_column = true +ij_java_builder_methods = none +ij_java_call_parameters_new_line_after_left_paren = false +ij_java_call_parameters_right_paren_on_new_line = false +ij_java_call_parameters_wrap = off +ij_java_case_statement_on_separate_line = true +ij_java_catch_on_new_line = false +ij_java_class_annotation_wrap = split_into_lines +ij_java_class_brace_style = end_of_line +ij_java_class_count_to_use_import_on_demand = 999 +ij_java_class_names_in_javadoc = 1 +ij_java_do_not_indent_top_level_class_members = false +ij_java_do_not_wrap_after_single_annotation = false +ij_java_do_while_brace_force = never +ij_java_doc_add_blank_line_after_description = true +ij_java_doc_add_blank_line_after_param_comments = false +ij_java_doc_add_blank_line_after_return = false +ij_java_doc_add_p_tag_on_empty_lines = true +ij_java_doc_align_exception_comments = true +ij_java_doc_align_param_comments = true +ij_java_doc_do_not_wrap_if_one_line = false +ij_java_doc_enable_formatting = true +ij_java_doc_enable_leading_asterisks = true +ij_java_doc_indent_on_continuation = false +ij_java_doc_keep_empty_lines = true +ij_java_doc_keep_empty_parameter_tag = true +ij_java_doc_keep_empty_return_tag = true +ij_java_doc_keep_empty_throws_tag = true +ij_java_doc_keep_invalid_tags = true +ij_java_doc_param_description_on_new_line = false +ij_java_doc_preserve_line_breaks = false +ij_java_doc_use_throws_not_exception_tag = true +ij_java_else_on_new_line = false +ij_java_enum_constants_wrap = off +ij_java_extends_keyword_wrap = off +ij_java_extends_list_wrap = off +ij_java_field_annotation_wrap = split_into_lines +ij_java_finally_on_new_line = false +ij_java_for_brace_force = never +ij_java_for_statement_new_line_after_left_paren = false +ij_java_for_statement_right_paren_on_new_line = false +ij_java_for_statement_wrap = off +ij_java_generate_final_locals = false +ij_java_generate_final_parameters = false +ij_java_if_brace_force = never +ij_java_imports_layout = *, |, javax.**, java.**, |, $* +ij_java_indent_case_from_switch = true +ij_java_insert_inner_class_imports = false +ij_java_insert_override_annotation = true +ij_java_keep_blank_lines_before_right_brace = 2 +ij_java_keep_blank_lines_between_package_declaration_and_header = 2 +ij_java_keep_blank_lines_in_code = 2 +ij_java_keep_blank_lines_in_declarations = 2 +ij_java_keep_builder_methods_indents = false +ij_java_keep_control_statement_in_one_line = true +ij_java_keep_first_column_comment = true +ij_java_keep_indents_on_empty_lines = false +ij_java_keep_line_breaks = true +ij_java_keep_multiple_expressions_in_one_line = false +ij_java_keep_simple_blocks_in_one_line = false +ij_java_keep_simple_classes_in_one_line = false +ij_java_keep_simple_lambdas_in_one_line = false +ij_java_keep_simple_methods_in_one_line = false +ij_java_label_indent_absolute = false +ij_java_label_indent_size = 0 +ij_java_lambda_brace_style = end_of_line +ij_java_layout_static_imports_separately = true +ij_java_line_comment_add_space = false +ij_java_line_comment_at_first_column = true +ij_java_method_annotation_wrap = split_into_lines +ij_java_method_brace_style = end_of_line +ij_java_method_call_chain_wrap = off +ij_java_method_parameters_new_line_after_left_paren = false +ij_java_method_parameters_right_paren_on_new_line = false +ij_java_method_parameters_wrap = off +ij_java_modifier_list_wrap = false +ij_java_names_count_to_use_import_on_demand = 999 +ij_java_new_line_after_lparen_in_record_header = false +ij_java_packages_to_use_import_on_demand = java.awt.*, javax.swing.* +ij_java_parameter_annotation_wrap = off +ij_java_parentheses_expression_new_line_after_left_paren = false +ij_java_parentheses_expression_right_paren_on_new_line = false +ij_java_place_assignment_sign_on_next_line = false +ij_java_prefer_longer_names = true +ij_java_prefer_parameters_wrap = false +ij_java_record_components_wrap = normal +ij_java_repeat_synchronized = true +ij_java_replace_instanceof_and_cast = false +ij_java_replace_null_check = true +ij_java_replace_sum_lambda_with_method_ref = true +ij_java_resource_list_new_line_after_left_paren = false +ij_java_resource_list_right_paren_on_new_line = false +ij_java_resource_list_wrap = off +ij_java_rparen_on_new_line_in_record_header = false +ij_java_space_after_closing_angle_bracket_in_type_argument = false +ij_java_space_after_colon = true +ij_java_space_after_comma = true +ij_java_space_after_comma_in_type_arguments = true +ij_java_space_after_for_semicolon = true +ij_java_space_after_quest = true +ij_java_space_after_type_cast = true +ij_java_space_before_annotation_array_initializer_left_brace = false +ij_java_space_before_annotation_parameter_list = false +ij_java_space_before_array_initializer_left_brace = false +ij_java_space_before_catch_keyword = true +ij_java_space_before_catch_left_brace = true +ij_java_space_before_catch_parentheses = true +ij_java_space_before_class_left_brace = true +ij_java_space_before_colon = true +ij_java_space_before_colon_in_foreach = true +ij_java_space_before_comma = false +ij_java_space_before_do_left_brace = true +ij_java_space_before_else_keyword = true +ij_java_space_before_else_left_brace = true +ij_java_space_before_finally_keyword = true +ij_java_space_before_finally_left_brace = true +ij_java_space_before_for_left_brace = true +ij_java_space_before_for_parentheses = true +ij_java_space_before_for_semicolon = false +ij_java_space_before_if_left_brace = true +ij_java_space_before_if_parentheses = true +ij_java_space_before_method_call_parentheses = false +ij_java_space_before_method_left_brace = true +ij_java_space_before_method_parentheses = false +ij_java_space_before_opening_angle_bracket_in_type_parameter = false +ij_java_space_before_quest = true +ij_java_space_before_switch_left_brace = true +ij_java_space_before_switch_parentheses = true +ij_java_space_before_synchronized_left_brace = true +ij_java_space_before_synchronized_parentheses = true +ij_java_space_before_try_left_brace = true +ij_java_space_before_try_parentheses = true +ij_java_space_before_type_parameter_list = false +ij_java_space_before_while_keyword = true +ij_java_space_before_while_left_brace = true +ij_java_space_before_while_parentheses = true +ij_java_space_inside_one_line_enum_braces = false +ij_java_space_within_empty_array_initializer_braces = false +ij_java_space_within_empty_method_call_parentheses = false +ij_java_space_within_empty_method_parentheses = false +ij_java_spaces_around_additive_operators = true +ij_java_spaces_around_assignment_operators = true +ij_java_spaces_around_bitwise_operators = true +ij_java_spaces_around_equality_operators = true +ij_java_spaces_around_lambda_arrow = true +ij_java_spaces_around_logical_operators = true +ij_java_spaces_around_method_ref_dbl_colon = false +ij_java_spaces_around_multiplicative_operators = true +ij_java_spaces_around_relational_operators = true +ij_java_spaces_around_shift_operators = true +ij_java_spaces_around_type_bounds_in_type_parameters = true +ij_java_spaces_around_unary_operator = false +ij_java_spaces_within_angle_brackets = false +ij_java_spaces_within_annotation_parentheses = false +ij_java_spaces_within_array_initializer_braces = false +ij_java_spaces_within_braces = false +ij_java_spaces_within_brackets = false +ij_java_spaces_within_cast_parentheses = false +ij_java_spaces_within_catch_parentheses = false +ij_java_spaces_within_for_parentheses = false +ij_java_spaces_within_if_parentheses = false +ij_java_spaces_within_method_call_parentheses = false +ij_java_spaces_within_method_parentheses = false +ij_java_spaces_within_parentheses = false +ij_java_spaces_within_record_header = false +ij_java_spaces_within_switch_parentheses = false +ij_java_spaces_within_synchronized_parentheses = false +ij_java_spaces_within_try_parentheses = false +ij_java_spaces_within_while_parentheses = false +ij_java_special_else_if_treatment = true +ij_java_subclass_name_suffix = Impl +ij_java_ternary_operation_signs_on_next_line = false +ij_java_ternary_operation_wrap = off +ij_java_test_name_suffix = Test +ij_java_throws_keyword_wrap = off +ij_java_throws_list_wrap = off +ij_java_use_external_annotations = false +ij_java_use_fq_class_names = false +ij_java_use_relative_indents = false +ij_java_use_single_class_imports = true +ij_java_variable_annotation_wrap = off +ij_java_visibility = public +ij_java_while_brace_force = never +ij_java_while_on_new_line = false +ij_java_wrap_comments = false +ij_java_wrap_first_method_in_call_chain = false +ij_java_wrap_long_lines = false + +[*.properties] +ij_properties_align_group_field_declarations = false +ij_properties_keep_blank_lines = false +ij_properties_key_value_delimiter = equals +ij_properties_spaces_around_key_value_delimiter = false + +[.editorconfig] +ij_editorconfig_align_group_field_declarations = false +ij_editorconfig_space_after_colon = false +ij_editorconfig_space_after_comma = true +ij_editorconfig_space_before_colon = false +ij_editorconfig_space_before_comma = false +ij_editorconfig_spaces_around_assignment_operators = true + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.jspx,*.pom,*.rng,*.tagx,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] +ij_xml_align_attributes = true +ij_xml_align_text = false +ij_xml_attribute_wrap = normal +ij_xml_block_comment_add_space = false +ij_xml_block_comment_at_first_column = true +ij_xml_keep_blank_lines = 2 +ij_xml_keep_indents_on_empty_lines = false +ij_xml_keep_line_breaks = true +ij_xml_keep_line_breaks_in_text = true +ij_xml_keep_whitespaces = false +ij_xml_keep_whitespaces_around_cdata = preserve +ij_xml_keep_whitespaces_inside_cdata = false +ij_xml_line_comment_at_first_column = true +ij_xml_space_after_tag_name = false +ij_xml_space_around_equals_in_attribute = false +ij_xml_space_inside_empty_tag = false +ij_xml_text_wrap = normal +ij_xml_use_custom_settings = false + +[{*.bash,*.sh,*.zsh}] +indent_size = 2 +tab_width = 2 +ij_shell_binary_ops_start_line = false +ij_shell_keep_column_alignment_padding = false +ij_shell_minify_program = false +ij_shell_redirect_followed_by_space = false +ij_shell_switch_cases_indented = false +ij_shell_use_unix_line_separator = true + +[{*.gant,*.groovy,*.gy}] +ij_groovy_align_group_field_declarations = false +ij_groovy_align_multiline_array_initializer_expression = false +ij_groovy_align_multiline_assignment = false +ij_groovy_align_multiline_binary_operation = false +ij_groovy_align_multiline_chained_methods = false +ij_groovy_align_multiline_extends_list = false +ij_groovy_align_multiline_for = true +ij_groovy_align_multiline_list_or_map = true +ij_groovy_align_multiline_method_parentheses = false +ij_groovy_align_multiline_parameters = true +ij_groovy_align_multiline_parameters_in_calls = false +ij_groovy_align_multiline_resources = true +ij_groovy_align_multiline_ternary_operation = false +ij_groovy_align_multiline_throws_list = false +ij_groovy_align_named_args_in_map = true +ij_groovy_align_throws_keyword = false +ij_groovy_array_initializer_new_line_after_left_brace = false +ij_groovy_array_initializer_right_brace_on_new_line = false +ij_groovy_array_initializer_wrap = off +ij_groovy_assert_statement_wrap = off +ij_groovy_assignment_wrap = off +ij_groovy_binary_operation_wrap = off +ij_groovy_blank_lines_after_class_header = 0 +ij_groovy_blank_lines_after_imports = 1 +ij_groovy_blank_lines_after_package = 1 +ij_groovy_blank_lines_around_class = 1 +ij_groovy_blank_lines_around_field = 0 +ij_groovy_blank_lines_around_field_in_interface = 0 +ij_groovy_blank_lines_around_method = 1 +ij_groovy_blank_lines_around_method_in_interface = 1 +ij_groovy_blank_lines_before_imports = 1 +ij_groovy_blank_lines_before_method_body = 0 +ij_groovy_blank_lines_before_package = 0 +ij_groovy_block_brace_style = end_of_line +ij_groovy_block_comment_add_space = false +ij_groovy_block_comment_at_first_column = true +ij_groovy_call_parameters_new_line_after_left_paren = false +ij_groovy_call_parameters_right_paren_on_new_line = false +ij_groovy_call_parameters_wrap = off +ij_groovy_catch_on_new_line = false +ij_groovy_class_annotation_wrap = split_into_lines +ij_groovy_class_brace_style = end_of_line +ij_groovy_class_count_to_use_import_on_demand = 5 +ij_groovy_do_while_brace_force = never +ij_groovy_else_on_new_line = false +ij_groovy_enum_constants_wrap = off +ij_groovy_extends_keyword_wrap = off +ij_groovy_extends_list_wrap = off +ij_groovy_field_annotation_wrap = split_into_lines +ij_groovy_finally_on_new_line = false +ij_groovy_for_brace_force = never +ij_groovy_for_statement_new_line_after_left_paren = false +ij_groovy_for_statement_right_paren_on_new_line = false +ij_groovy_for_statement_wrap = off +ij_groovy_if_brace_force = never +ij_groovy_import_annotation_wrap = 2 +ij_groovy_imports_layout = *, |, javax.**, java.**, |, $* +ij_groovy_indent_case_from_switch = true +ij_groovy_indent_label_blocks = true +ij_groovy_insert_inner_class_imports = false +ij_groovy_keep_blank_lines_before_right_brace = 2 +ij_groovy_keep_blank_lines_in_code = 2 +ij_groovy_keep_blank_lines_in_declarations = 2 +ij_groovy_keep_control_statement_in_one_line = true +ij_groovy_keep_first_column_comment = true +ij_groovy_keep_indents_on_empty_lines = false +ij_groovy_keep_line_breaks = true +ij_groovy_keep_multiple_expressions_in_one_line = false +ij_groovy_keep_simple_blocks_in_one_line = false +ij_groovy_keep_simple_classes_in_one_line = true +ij_groovy_keep_simple_lambdas_in_one_line = true +ij_groovy_keep_simple_methods_in_one_line = true +ij_groovy_label_indent_absolute = false +ij_groovy_label_indent_size = 0 +ij_groovy_lambda_brace_style = end_of_line +ij_groovy_layout_static_imports_separately = true +ij_groovy_line_comment_add_space = false +ij_groovy_line_comment_at_first_column = true +ij_groovy_method_annotation_wrap = split_into_lines +ij_groovy_method_brace_style = end_of_line +ij_groovy_method_call_chain_wrap = off +ij_groovy_method_parameters_new_line_after_left_paren = false +ij_groovy_method_parameters_right_paren_on_new_line = false +ij_groovy_method_parameters_wrap = off +ij_groovy_modifier_list_wrap = false +ij_groovy_names_count_to_use_import_on_demand = 3 +ij_groovy_packages_to_use_import_on_demand = java.awt.*, javax.swing.* +ij_groovy_parameter_annotation_wrap = off +ij_groovy_parentheses_expression_new_line_after_left_paren = false +ij_groovy_parentheses_expression_right_paren_on_new_line = false +ij_groovy_prefer_parameters_wrap = false +ij_groovy_resource_list_new_line_after_left_paren = false +ij_groovy_resource_list_right_paren_on_new_line = false +ij_groovy_resource_list_wrap = off +ij_groovy_space_after_assert_separator = true +ij_groovy_space_after_colon = true +ij_groovy_space_after_comma = true +ij_groovy_space_after_comma_in_type_arguments = true +ij_groovy_space_after_for_semicolon = true +ij_groovy_space_after_quest = true +ij_groovy_space_after_type_cast = true +ij_groovy_space_before_annotation_parameter_list = false +ij_groovy_space_before_array_initializer_left_brace = false +ij_groovy_space_before_assert_separator = false +ij_groovy_space_before_catch_keyword = true +ij_groovy_space_before_catch_left_brace = true +ij_groovy_space_before_catch_parentheses = true +ij_groovy_space_before_class_left_brace = true +ij_groovy_space_before_closure_left_brace = true +ij_groovy_space_before_colon = true +ij_groovy_space_before_comma = false +ij_groovy_space_before_do_left_brace = true +ij_groovy_space_before_else_keyword = true +ij_groovy_space_before_else_left_brace = true +ij_groovy_space_before_finally_keyword = true +ij_groovy_space_before_finally_left_brace = true +ij_groovy_space_before_for_left_brace = true +ij_groovy_space_before_for_parentheses = true +ij_groovy_space_before_for_semicolon = false +ij_groovy_space_before_if_left_brace = true +ij_groovy_space_before_if_parentheses = true +ij_groovy_space_before_method_call_parentheses = false +ij_groovy_space_before_method_left_brace = true +ij_groovy_space_before_method_parentheses = false +ij_groovy_space_before_quest = true +ij_groovy_space_before_record_parentheses = false +ij_groovy_space_before_switch_left_brace = true +ij_groovy_space_before_switch_parentheses = true +ij_groovy_space_before_synchronized_left_brace = true +ij_groovy_space_before_synchronized_parentheses = true +ij_groovy_space_before_try_left_brace = true +ij_groovy_space_before_try_parentheses = true +ij_groovy_space_before_while_keyword = true +ij_groovy_space_before_while_left_brace = true +ij_groovy_space_before_while_parentheses = true +ij_groovy_space_in_named_argument = true +ij_groovy_space_in_named_argument_before_colon = false +ij_groovy_space_within_empty_array_initializer_braces = false +ij_groovy_space_within_empty_method_call_parentheses = false +ij_groovy_spaces_around_additive_operators = true +ij_groovy_spaces_around_assignment_operators = true +ij_groovy_spaces_around_bitwise_operators = true +ij_groovy_spaces_around_equality_operators = true +ij_groovy_spaces_around_lambda_arrow = true +ij_groovy_spaces_around_logical_operators = true +ij_groovy_spaces_around_multiplicative_operators = true +ij_groovy_spaces_around_regex_operators = true +ij_groovy_spaces_around_relational_operators = true +ij_groovy_spaces_around_shift_operators = true +ij_groovy_spaces_within_annotation_parentheses = false +ij_groovy_spaces_within_array_initializer_braces = false +ij_groovy_spaces_within_braces = true +ij_groovy_spaces_within_brackets = false +ij_groovy_spaces_within_cast_parentheses = false +ij_groovy_spaces_within_catch_parentheses = false +ij_groovy_spaces_within_for_parentheses = false +ij_groovy_spaces_within_gstring_injection_braces = false +ij_groovy_spaces_within_if_parentheses = false +ij_groovy_spaces_within_list_or_map = false +ij_groovy_spaces_within_method_call_parentheses = false +ij_groovy_spaces_within_method_parentheses = false +ij_groovy_spaces_within_parentheses = false +ij_groovy_spaces_within_switch_parentheses = false +ij_groovy_spaces_within_synchronized_parentheses = false +ij_groovy_spaces_within_try_parentheses = false +ij_groovy_spaces_within_tuple_expression = false +ij_groovy_spaces_within_while_parentheses = false +ij_groovy_special_else_if_treatment = true +ij_groovy_ternary_operation_wrap = off +ij_groovy_throws_keyword_wrap = off +ij_groovy_throws_list_wrap = off +ij_groovy_use_flying_geese_braces = false +ij_groovy_use_fq_class_names = false +ij_groovy_use_fq_class_names_in_javadoc = true +ij_groovy_use_relative_indents = false +ij_groovy_use_single_class_imports = true +ij_groovy_variable_annotation_wrap = off +ij_groovy_while_brace_force = never +ij_groovy_while_on_new_line = false +ij_groovy_wrap_chain_calls_after_dot = false +ij_groovy_wrap_long_lines = false + +[{*.har,*.json}] +indent_size = 2 +ij_json_keep_blank_lines_in_code = 0 +ij_json_keep_indents_on_empty_lines = false +ij_json_keep_line_breaks = true +ij_json_space_after_colon = true +ij_json_space_after_comma = true +ij_json_space_before_colon = true +ij_json_space_before_comma = false +ij_json_spaces_within_braces = false +ij_json_spaces_within_brackets = false +ij_json_wrap_long_lines = false + +[{*.htm,*.html,*.sht,*.shtm,*.shtml}] +ij_html_add_new_line_before_tags = body, div, p, form, h1, h2, h3 +ij_html_align_attributes = true +ij_html_align_text = false +ij_html_attribute_wrap = normal +ij_html_block_comment_add_space = false +ij_html_block_comment_at_first_column = true +ij_html_do_not_align_children_of_min_lines = 0 +ij_html_do_not_break_if_inline_tags = title, h1, h2, h3, h4, h5, h6, p +ij_html_do_not_indent_children_of_tags = html, body, thead, tbody, tfoot +ij_html_enforce_quotes = false +ij_html_inline_tags = a, abbr, acronym, b, basefont, bdo, big, br, cite, cite, code, dfn, em, font, i, img, input, kbd, label, q, s, samp, select, small, span, strike, strong, sub, sup, textarea, tt, u, var +ij_html_keep_blank_lines = 2 +ij_html_keep_indents_on_empty_lines = false +ij_html_keep_line_breaks = true +ij_html_keep_line_breaks_in_text = true +ij_html_keep_whitespaces = false +ij_html_keep_whitespaces_inside = span, pre, textarea +ij_html_line_comment_at_first_column = true +ij_html_new_line_after_last_attribute = never +ij_html_new_line_before_first_attribute = never +ij_html_quote_style = double +ij_html_remove_new_line_before_tags = br +ij_html_space_after_tag_name = false +ij_html_space_around_equality_in_attribute = false +ij_html_space_inside_empty_tag = false +ij_html_text_wrap = normal + +[{*.kt,*.kts}] +ij_kotlin_align_in_columns_case_branch = false +ij_kotlin_align_multiline_binary_operation = false +ij_kotlin_align_multiline_extends_list = false +ij_kotlin_align_multiline_method_parentheses = false +ij_kotlin_align_multiline_parameters = true +ij_kotlin_align_multiline_parameters_in_calls = false +ij_kotlin_allow_trailing_comma = false +ij_kotlin_allow_trailing_comma_on_call_site = false +ij_kotlin_assignment_wrap = off +ij_kotlin_blank_lines_after_class_header = 0 +ij_kotlin_blank_lines_around_block_when_branches = 0 +ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1 +ij_kotlin_block_comment_add_space = false +ij_kotlin_block_comment_at_first_column = true +ij_kotlin_call_parameters_new_line_after_left_paren = false +ij_kotlin_call_parameters_right_paren_on_new_line = false +ij_kotlin_call_parameters_wrap = off +ij_kotlin_catch_on_new_line = false +ij_kotlin_class_annotation_wrap = split_into_lines +ij_kotlin_continuation_indent_for_chained_calls = true +ij_kotlin_continuation_indent_for_expression_bodies = true +ij_kotlin_continuation_indent_in_argument_lists = true +ij_kotlin_continuation_indent_in_elvis = true +ij_kotlin_continuation_indent_in_if_conditions = true +ij_kotlin_continuation_indent_in_parameter_lists = true +ij_kotlin_continuation_indent_in_supertype_lists = true +ij_kotlin_else_on_new_line = false +ij_kotlin_enum_constants_wrap = off +ij_kotlin_extends_list_wrap = off +ij_kotlin_field_annotation_wrap = split_into_lines +ij_kotlin_finally_on_new_line = false +ij_kotlin_if_rparen_on_new_line = false +ij_kotlin_import_nested_classes = false +ij_kotlin_imports_layout = *, java.**, javax.**, kotlin.**, ^ +ij_kotlin_insert_whitespaces_in_simple_one_line_method = true +ij_kotlin_keep_blank_lines_before_right_brace = 2 +ij_kotlin_keep_blank_lines_in_code = 2 +ij_kotlin_keep_blank_lines_in_declarations = 2 +ij_kotlin_keep_first_column_comment = true +ij_kotlin_keep_indents_on_empty_lines = false +ij_kotlin_keep_line_breaks = true +ij_kotlin_lbrace_on_next_line = false +ij_kotlin_line_comment_add_space = false +ij_kotlin_line_comment_at_first_column = true +ij_kotlin_method_annotation_wrap = split_into_lines +ij_kotlin_method_call_chain_wrap = off +ij_kotlin_method_parameters_new_line_after_left_paren = false +ij_kotlin_method_parameters_right_paren_on_new_line = false +ij_kotlin_method_parameters_wrap = off +ij_kotlin_name_count_to_use_star_import = 5 +ij_kotlin_name_count_to_use_star_import_for_members = 3 +ij_kotlin_packages_to_use_import_on_demand = java.util.*, kotlinx.android.synthetic.**, io.ktor.** +ij_kotlin_parameter_annotation_wrap = off +ij_kotlin_space_after_comma = true +ij_kotlin_space_after_extend_colon = true +ij_kotlin_space_after_type_colon = true +ij_kotlin_space_before_catch_parentheses = true +ij_kotlin_space_before_comma = false +ij_kotlin_space_before_extend_colon = true +ij_kotlin_space_before_for_parentheses = true +ij_kotlin_space_before_if_parentheses = true +ij_kotlin_space_before_lambda_arrow = true +ij_kotlin_space_before_type_colon = false +ij_kotlin_space_before_when_parentheses = true +ij_kotlin_space_before_while_parentheses = true +ij_kotlin_spaces_around_additive_operators = true +ij_kotlin_spaces_around_assignment_operators = true +ij_kotlin_spaces_around_equality_operators = true +ij_kotlin_spaces_around_function_type_arrow = true +ij_kotlin_spaces_around_logical_operators = true +ij_kotlin_spaces_around_multiplicative_operators = true +ij_kotlin_spaces_around_range = false +ij_kotlin_spaces_around_relational_operators = true +ij_kotlin_spaces_around_unary_operator = false +ij_kotlin_spaces_around_when_arrow = true +ij_kotlin_variable_annotation_wrap = off +ij_kotlin_while_on_new_line = false +ij_kotlin_wrap_elvis_expressions = 1 +ij_kotlin_wrap_expression_body_functions = 0 +ij_kotlin_wrap_first_method_in_call_chain = false + +[{*.markdown,*.md}] +ij_markdown_force_one_space_after_blockquote_symbol = true +ij_markdown_force_one_space_after_header_symbol = true +ij_markdown_force_one_space_after_list_bullet = true +ij_markdown_force_one_space_between_words = true +ij_markdown_keep_indents_on_empty_lines = false +ij_markdown_max_lines_around_block_elements = 1 +ij_markdown_max_lines_around_header = 1 +ij_markdown_max_lines_between_paragraphs = 1 +ij_markdown_min_lines_around_block_elements = 1 +ij_markdown_min_lines_around_header = 1 +ij_markdown_min_lines_between_paragraphs = 1 + +[{*.yaml,*.yml}] +indent_size = 2 +ij_yaml_align_values_properties = do_not_align +ij_yaml_autoinsert_sequence_marker = true +ij_yaml_block_mapping_on_new_line = false +ij_yaml_indent_sequence_value = true +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true +ij_yaml_sequence_on_new_line = false +ij_yaml_space_before_colon = false +ij_yaml_spaces_within_braces = false +ij_yaml_spaces_within_brackets = true + diff --git a/src/main/java/kafdrop/Kafdrop.java b/src/main/java/kafdrop/Kafdrop.java index b510ab49..c9ea05c9 100644 --- a/src/main/java/kafdrop/Kafdrop.java +++ b/src/main/java/kafdrop/Kafdrop.java @@ -18,30 +18,38 @@ package kafdrop; -import com.google.common.base.*; -import io.undertow.server.*; +import com.google.common.base.Strings; +import io.undertow.server.DefaultByteBufferPool; +import io.undertow.server.HandlerWrapper; +import io.undertow.server.HttpHandler; import io.undertow.server.handlers.DisallowedMethodsHandler; import io.undertow.util.HttpString; -import io.undertow.websockets.jsr.*; -import kafdrop.config.ini.*; -import org.slf4j.*; +import io.undertow.websockets.jsr.WebSocketDeploymentInfo; +import kafdrop.config.ini.IniFilePropertySource; +import kafdrop.config.ini.IniFileReader; import org.slf4j.Logger; -import org.springframework.boot.Banner.*; -import org.springframework.boot.autoconfigure.*; -import org.springframework.boot.builder.*; -import org.springframework.boot.context.event.*; -import org.springframework.boot.web.embedded.undertow.*; -import org.springframework.boot.web.server.*; -import org.springframework.context.*; -import org.springframework.context.annotation.*; -import org.springframework.core.*; -import org.springframework.core.env.*; -import org.springframework.web.servlet.config.annotation.*; - -import java.io.*; -import java.nio.charset.*; +import org.slf4j.LoggerFactory; +import org.springframework.boot.Banner.Mode; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; +import org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer; +import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; +import org.springframework.boot.web.server.WebServerFactoryCustomizer; +import org.springframework.context.ApplicationListener; +import org.springframework.context.annotation.Bean; +import org.springframework.core.Ordered; +import org.springframework.core.env.Environment; +import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.Objects; -import java.util.stream.*; +import java.util.stream.Stream; @SpringBootApplication public class Kafdrop { @@ -56,7 +64,7 @@ public static SpringApplicationBuilder createApplicationBuilder() { return new SpringApplicationBuilder(Kafdrop.class) .bannerMode(Mode.OFF) .listeners(new EnvironmentSetupListener(), - new LoggingConfigurationListener()); + new LoggingConfigurationListener()); } @Bean @@ -116,7 +124,7 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { } } if (environment.containsProperty("debug") && - !"false".equalsIgnoreCase(environment.getProperty("debug", String.class))) { + !"false".equalsIgnoreCase(environment.getProperty("debug", String.class))) { System.setProperty(PROP_SPRING_BOOT_LOG_LEVEL, "DEBUG"); } } @@ -154,10 +162,10 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { if (environment.containsProperty(SM_CONFIG_DIR)) { Stream.of("kafdrop", "global") - .map(name -> readProperties(environment, name)) - .filter(Objects::nonNull) - .forEach(iniPropSource -> environment.getPropertySources() - .addBefore("applicationConfigurationProperties", iniPropSource)); + .map(name -> readProperties(environment, name)) + .filter(Objects::nonNull) + .forEach(iniPropSource -> environment.getPropertySources() + .addBefore("applicationConfigurationProperties", iniPropSource)); } } diff --git a/src/main/java/kafdrop/config/CorsConfiguration.java b/src/main/java/kafdrop/config/CorsConfiguration.java index e2d25989..f65a540c 100644 --- a/src/main/java/kafdrop/config/CorsConfiguration.java +++ b/src/main/java/kafdrop/config/CorsConfiguration.java @@ -18,16 +18,24 @@ package kafdrop.config; -import org.springframework.beans.factory.annotation.*; -import org.springframework.boot.autoconfigure.condition.*; -import org.springframework.context.annotation.*; -import org.springframework.core.*; -import org.springframework.core.annotation.*; -import org.springframework.http.*; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; -import jakarta.servlet.*; -import jakarta.servlet.http.*; -import java.io.*; +import java.io.IOException; /** * Auto configuration for enabling CORS support. Can override behavior with diff --git a/src/main/java/kafdrop/config/HealthCheckConfiguration.java b/src/main/java/kafdrop/config/HealthCheckConfiguration.java index efea1a95..ebe011b8 100644 --- a/src/main/java/kafdrop/config/HealthCheckConfiguration.java +++ b/src/main/java/kafdrop/config/HealthCheckConfiguration.java @@ -18,13 +18,17 @@ package kafdrop.config; -import org.springframework.boot.actuate.health.*; -import org.springframework.context.annotation.*; -import org.springframework.jmx.export.annotation.*; -import org.springframework.stereotype.*; +import org.springframework.boot.actuate.health.Health; +import org.springframework.boot.actuate.health.HealthEndpoint; +import org.springframework.boot.actuate.health.Status; +import org.springframework.context.annotation.Configuration; +import org.springframework.jmx.export.annotation.ManagedAttribute; +import org.springframework.jmx.export.annotation.ManagedResource; +import org.springframework.stereotype.Component; -import java.util.*; -import java.util.stream.*; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.stream.Collectors; @Configuration public class HealthCheckConfiguration { @@ -48,15 +52,15 @@ public Map getHealth() { private Map getDetails(Map details) { return details.entrySet().stream() - .collect(Collectors.toMap(Map.Entry::getKey, - e -> { - final var health = (Health) e.getValue(); - final var detail = new LinkedHashMap(); - final var healthy = Status.UP.equals(health.getStatus()); - detail.put("healthy", healthy); - detail.put("message", health.getDetails().toString()); - return detail; - })); + .collect(Collectors.toMap(Map.Entry::getKey, + e -> { + final var health = (Health) e.getValue(); + final var detail = new LinkedHashMap(); + final var healthy = Status.UP.equals(health.getStatus()); + detail.put("healthy", healthy); + detail.put("message", health.getDetails().toString()); + return detail; + })); } private String getStatus(Health health) { diff --git a/src/main/java/kafdrop/config/InterceptorConfiguration.java b/src/main/java/kafdrop/config/InterceptorConfiguration.java index 765ee423..5140738a 100644 --- a/src/main/java/kafdrop/config/InterceptorConfiguration.java +++ b/src/main/java/kafdrop/config/InterceptorConfiguration.java @@ -18,12 +18,14 @@ package kafdrop.config; -import org.springframework.core.env.*; -import org.springframework.stereotype.*; -import org.springframework.web.servlet.*; -import org.springframework.web.servlet.config.annotation.*; - -import jakarta.servlet.http.*; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.AsyncHandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Component public class InterceptorConfiguration implements WebMvcConfigurer { diff --git a/src/main/java/kafdrop/config/KafkaConfiguration.java b/src/main/java/kafdrop/config/KafkaConfiguration.java index cd34f497..a445470c 100644 --- a/src/main/java/kafdrop/config/KafkaConfiguration.java +++ b/src/main/java/kafdrop/config/KafkaConfiguration.java @@ -1,13 +1,18 @@ package kafdrop.config; -import java.io.*; -import java.util.*; -import lombok.*; -import org.apache.kafka.clients.*; -import org.apache.kafka.common.config.*; -import org.slf4j.*; -import org.springframework.boot.context.properties.*; -import org.springframework.stereotype.*; +import lombok.Data; +import org.apache.kafka.clients.CommonClientConfigs; +import org.apache.kafka.common.config.SaslConfigs; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.Properties; @Component @@ -31,7 +36,7 @@ public void applyCommon(Properties properties) { properties.put(SaslConfigs.SASL_MECHANISM, saslMechanism); } - if(isSecured || securityProtocol.equals("SSL")) { + if (isSecured || securityProtocol.equals("SSL")) { properties.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, securityProtocol); } diff --git a/src/main/java/kafdrop/config/MessageFormatConfiguration.java b/src/main/java/kafdrop/config/MessageFormatConfiguration.java index 89745ff8..7c505c9f 100644 --- a/src/main/java/kafdrop/config/MessageFormatConfiguration.java +++ b/src/main/java/kafdrop/config/MessageFormatConfiguration.java @@ -1,11 +1,10 @@ package kafdrop.config; -import kafdrop.util.*; -import org.springframework.boot.context.properties.*; -import org.springframework.context.annotation.*; -import org.springframework.stereotype.*; - -import jakarta.annotation.*; +import jakarta.annotation.PostConstruct; +import kafdrop.util.MessageFormat; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; @Configuration diff --git a/src/main/java/kafdrop/config/OASConfiguration.java b/src/main/java/kafdrop/config/OASConfiguration.java index 45bfef1c..977cb1ec 100644 --- a/src/main/java/kafdrop/config/OASConfiguration.java +++ b/src/main/java/kafdrop/config/OASConfiguration.java @@ -24,8 +24,8 @@ import org.springframework.context.annotation.Configuration; /** - * Autoconfiguration for OpenAPI Specification (OAS). - * Can be disabled by setting {@code springdoc.api-docs.enabled=false}. + * Autoconfiguration for OpenAPI Specification (OAS). + * Can be disabled by setting {@code springdoc.api-docs.enabled=false}. */ @Configuration public class OASConfiguration { @@ -33,7 +33,7 @@ public class OASConfiguration { @Bean public OpenAPI httpApi() { return new OpenAPI().info(new Info() - .title("Kafdrop API") - .description("JSON APIs for Kafdrop")); + .title("Kafdrop API") + .description("JSON APIs for Kafdrop")); } } diff --git a/src/main/java/kafdrop/config/ProtobufDescriptorConfiguration.java b/src/main/java/kafdrop/config/ProtobufDescriptorConfiguration.java index 47c32760..24b53ebd 100644 --- a/src/main/java/kafdrop/config/ProtobufDescriptorConfiguration.java +++ b/src/main/java/kafdrop/config/ProtobufDescriptorConfiguration.java @@ -1,5 +1,11 @@ package kafdrop.config; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + import java.io.File; import java.io.FilenameFilter; import java.nio.file.Files; @@ -9,12 +15,6 @@ import java.util.List; import java.util.Objects; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; - @Configuration public class ProtobufDescriptorConfiguration { @Component diff --git a/src/main/java/kafdrop/config/SchemaRegistryConfiguration.java b/src/main/java/kafdrop/config/SchemaRegistryConfiguration.java index f45ce0ec..dd305f96 100644 --- a/src/main/java/kafdrop/config/SchemaRegistryConfiguration.java +++ b/src/main/java/kafdrop/config/SchemaRegistryConfiguration.java @@ -1,12 +1,12 @@ package kafdrop.config; -import org.springframework.boot.context.properties.*; -import org.springframework.context.annotation.*; -import org.springframework.stereotype.*; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; -import java.util.*; -import java.util.regex.*; -import java.util.stream.*; +import java.util.List; +import java.util.regex.Pattern; +import java.util.stream.Collectors; @Configuration @@ -27,15 +27,19 @@ public void setConnect(String connect) { this.connect = connect; } - public String getAuth() { return auth; } + public String getAuth() { + return auth; + } - public void setAuth(String auth) { this.auth = auth; } + public void setAuth(String auth) { + this.auth = auth; + } public List getConnectList() { return CONNECT_SEPARATOR.splitAsStream(this.connect) - .map(String::trim) - .filter(s -> s.length() > 0) - .collect(Collectors.toList()); + .map(String::trim) + .filter(s -> s.length() > 0) + .collect(Collectors.toList()); } } } diff --git a/src/main/java/kafdrop/config/ini/IniFileProperties.java b/src/main/java/kafdrop/config/ini/IniFileProperties.java index 0df087da..cea170fc 100644 --- a/src/main/java/kafdrop/config/ini/IniFileProperties.java +++ b/src/main/java/kafdrop/config/ini/IniFileProperties.java @@ -18,9 +18,11 @@ package kafdrop.config.ini; -import com.google.common.collect.*; +import com.google.common.collect.Maps; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; public final class IniFileProperties { private Map> sectionProperties = Maps.newLinkedHashMap(); diff --git a/src/main/java/kafdrop/config/ini/IniFilePropertySource.java b/src/main/java/kafdrop/config/ini/IniFilePropertySource.java index 648caf77..40cd30ce 100644 --- a/src/main/java/kafdrop/config/ini/IniFilePropertySource.java +++ b/src/main/java/kafdrop/config/ini/IniFilePropertySource.java @@ -18,10 +18,10 @@ package kafdrop.config.ini; -import com.google.common.collect.*; -import org.springframework.core.env.*; +import com.google.common.collect.Maps; +import org.springframework.core.env.MapPropertySource; -import java.util.*; +import java.util.Map; public class IniFilePropertySource extends MapPropertySource { public IniFilePropertySource(String name, IniFileProperties source, String[] activeProfiles) { diff --git a/src/main/java/kafdrop/config/ini/IniFileReader.java b/src/main/java/kafdrop/config/ini/IniFileReader.java index fba9749c..997d8c42 100644 --- a/src/main/java/kafdrop/config/ini/IniFileReader.java +++ b/src/main/java/kafdrop/config/ini/IniFileReader.java @@ -18,9 +18,11 @@ package kafdrop.config.ini; -import org.apache.commons.lang3.*; +import org.apache.commons.lang3.StringUtils; -import java.io.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; public class IniFileReader { private static final String COMMENT_CHARS = "#;"; diff --git a/src/main/java/kafdrop/controller/BasicErrorController.java b/src/main/java/kafdrop/controller/BasicErrorController.java index cd68fcae..3e163041 100644 --- a/src/main/java/kafdrop/controller/BasicErrorController.java +++ b/src/main/java/kafdrop/controller/BasicErrorController.java @@ -1,16 +1,16 @@ package kafdrop.controller; +import jakarta.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.boot.autoconfigure.web.servlet.error.*; +import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController; import org.springframework.boot.web.error.ErrorAttributeOptions; -import org.springframework.boot.web.servlet.error.*; -import org.springframework.stereotype.*; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.*; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; -import jakarta.servlet.http.*; -import java.util.*; +import java.util.Map; @Controller public final class BasicErrorController extends AbstractErrorController { @@ -28,7 +28,7 @@ public ModelAndView handleError(HttpServletRequest request) { final var error = getErrorAttributes(request, errorAttributeOptions); LOG.info("errorAtts: {}", error); - + error.putIfAbsent("message", ""); final var model = Map.of("error", error); diff --git a/src/main/java/kafdrop/controller/BrokerController.java b/src/main/java/kafdrop/controller/BrokerController.java index f417a012..9f56a6d3 100644 --- a/src/main/java/kafdrop/controller/BrokerController.java +++ b/src/main/java/kafdrop/controller/BrokerController.java @@ -47,15 +47,15 @@ public BrokerController(KafkaMonitor kafkaMonitor) { @RequestMapping("/broker/{id}") public String brokerDetails(@PathVariable("id") int brokerId, Model model) { model.addAttribute("broker", kafkaMonitor.getBroker(brokerId) - .orElseThrow(() -> new BrokerNotFoundException("No such broker " + brokerId))); + .orElseThrow(() -> new BrokerNotFoundException("No such broker " + brokerId))); model.addAttribute("topics", kafkaMonitor.getTopics()); return "broker-detail"; } @Operation(summary = "getBroker", description = "Get details for a specific Kafka broker") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Success"), - @ApiResponse(responseCode = "404", description = "Invalid Broker ID") + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "404", description = "Invalid Broker ID") }) @GetMapping(path = "/broker/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody BrokerVO brokerDetailsJson(@PathVariable("id") int brokerId) { @@ -64,7 +64,7 @@ public String brokerDetails(@PathVariable("id") int brokerId, Model model) { @Operation(summary = "getAllBrokers", description = "Get details for all known Kafka brokers") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Success") + @ApiResponse(responseCode = "200", description = "Success") }) @GetMapping(path = "/broker", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List brokerDetailsJson() { diff --git a/src/main/java/kafdrop/controller/ClusterController.java b/src/main/java/kafdrop/controller/ClusterController.java index fd1673f0..c2922bc1 100644 --- a/src/main/java/kafdrop/controller/ClusterController.java +++ b/src/main/java/kafdrop/controller/ClusterController.java @@ -36,7 +36,12 @@ import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; import java.util.Collections; import java.util.List; @@ -55,13 +60,13 @@ public final class ClusterController { private final boolean topicCreateEnabled; public ClusterController(KafkaConfiguration kafkaConfiguration, KafkaMonitor kafkaMonitor, ObjectProvider buildInfoProvider, - @Value("${topic.createEnabled:true}") Boolean topicCreateEnabled) { + @Value("${topic.createEnabled:true}") Boolean topicCreateEnabled) { this.kafkaConfiguration = kafkaConfiguration; this.kafkaMonitor = kafkaMonitor; this.buildProperties = buildInfoProvider.stream() - .map(BuildInfo::getBuildProperties) - .findAny() - .orElseGet(ClusterController::blankBuildProperties); + .map(BuildInfo::getBuildProperties) + .findAny() + .orElseGet(ClusterController::blankBuildProperties); this.topicCreateEnabled = topicCreateEnabled; } @@ -83,8 +88,8 @@ public String clusterInfo(Model model, final var clusterSummary = kafkaMonitor.getClusterSummary(topics); final var missingBrokerIds = clusterSummary.getExpectedBrokerIds().stream() - .filter(brokerId -> brokers.stream().noneMatch(b -> b.getId() == brokerId)) - .collect(Collectors.toList()); + .filter(brokerId -> brokers.stream().noneMatch(b -> b.getId() == brokerId)) + .collect(Collectors.toList()); model.addAttribute("brokers", brokers); model.addAttribute("missingBrokerIds", missingBrokerIds); @@ -101,7 +106,7 @@ public String clusterInfo(Model model, @Operation(summary = "getCluster", description = "Get high level broker, topic, and partition data for the Kafka cluster") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Success") + @ApiResponse(responseCode = "200", description = "Success") }) @GetMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ClusterInfoVO getCluster() { @@ -132,6 +137,7 @@ public static final class ClusterInfoVO { ClusterSummaryVO summary; List brokers; List topics; + public ClusterSummaryVO getSummary() { return summary; } diff --git a/src/main/java/kafdrop/controller/ConsumerController.java b/src/main/java/kafdrop/controller/ConsumerController.java index 49c13bd4..c1011eee 100644 --- a/src/main/java/kafdrop/controller/ConsumerController.java +++ b/src/main/java/kafdrop/controller/ConsumerController.java @@ -52,8 +52,8 @@ public String consumerDetail(@PathVariable("groupId") String groupId, Model mode @Operation(summary = "getConsumer", description = "Get topic and partition details for a consumer group") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Success"), - @ApiResponse(responseCode = "404", description = "Invalid consumer group") + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "404", description = "Invalid consumer group") }) @GetMapping(path = "/{groupId:.+}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConsumerVO getConsumer(@PathVariable("groupId") String groupId) throws ConsumerNotFoundException { diff --git a/src/main/java/kafdrop/controller/KafkaExceptionHandler.java b/src/main/java/kafdrop/controller/KafkaExceptionHandler.java index f95c37c0..fd55ff14 100644 --- a/src/main/java/kafdrop/controller/KafkaExceptionHandler.java +++ b/src/main/java/kafdrop/controller/KafkaExceptionHandler.java @@ -18,8 +18,9 @@ package kafdrop.controller; -import kafdrop.service.*; -import org.springframework.web.bind.annotation.*; +import kafdrop.service.NotInitializedException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; @ControllerAdvice public final class KafkaExceptionHandler { diff --git a/src/main/java/kafdrop/controller/MessageController.java b/src/main/java/kafdrop/controller/MessageController.java index e0581a82..e87d0ca0 100644 --- a/src/main/java/kafdrop/controller/MessageController.java +++ b/src/main/java/kafdrop/controller/MessageController.java @@ -37,12 +37,24 @@ import kafdrop.service.KafkaMonitor; import kafdrop.service.MessageInspector; import kafdrop.service.TopicNotFoundException; -import kafdrop.util.*; +import kafdrop.util.AvroMessageDeserializer; +import kafdrop.util.DefaultMessageDeserializer; +import kafdrop.util.Deserializers; +import kafdrop.util.KeyFormat; +import kafdrop.util.MessageDeserializer; +import kafdrop.util.MessageFormat; +import kafdrop.util.MsgPackMessageDeserializer; +import kafdrop.util.ProtobufMessageDeserializer; +import kafdrop.util.ProtobufSchemaRegistryMessageDeserializer; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; import java.io.File; import java.util.ArrayList; @@ -67,11 +79,12 @@ public MessageController(KafkaMonitor kafkaMonitor, MessageInspector messageInsp this.messageInspector = messageInspector; this.messageFormatProperties = messageFormatProperties; this.schemaRegistryProperties = schemaRegistryProperties; - this.protobufProperties = protobufProperties; + this.protobufProperties = protobufProperties; } /** * Human friendly view of reading all topic messages sorted by timestamp. + * * @param topicName Name of topic * @param model * @return View for seeing all messages in a topic sorted by timestamp. @@ -79,11 +92,11 @@ public MessageController(KafkaMonitor kafkaMonitor, MessageInspector messageInsp @GetMapping("/topic/{name:.+}/allmessages") public String viewAllMessages(@PathVariable("name") String topicName, Model model, @RequestParam(name = "count", required = false) Integer count) { - final int size = (count != null? count : 100); + final int size = (count != null ? count : 100); final MessageFormat defaultFormat = messageFormatProperties.getFormat(); final MessageFormat defaultKeyFormat = messageFormatProperties.getKeyFormat(); final TopicVO topic = kafkaMonitor.getTopic(topicName) - .orElseThrow(() -> new TopicNotFoundException(topicName)); + .orElseThrow(() -> new TopicNotFoundException(topicName)); model.addAttribute("topic", topic); model.addAttribute("defaultFormat", defaultFormat); @@ -93,17 +106,17 @@ public String viewAllMessages(@PathVariable("name") String topicName, model.addAttribute("descFiles", protobufProperties.getDescFilesList()); final var deserializers = new Deserializers( - getDeserializer(topicName, defaultKeyFormat, "", "", protobufProperties.getParseAnyProto()), - getDeserializer(topicName, defaultFormat, "", "", protobufProperties.getParseAnyProto())); + getDeserializer(topicName, defaultKeyFormat, "", "", protobufProperties.getParseAnyProto()), + getDeserializer(topicName, defaultFormat, "", "", protobufProperties.getParseAnyProto())); final List messages = messageInspector.getMessages(topicName, size, deserializers); for (TopicPartitionVO partition : topic.getPartitions()) { messages.addAll(messageInspector.getMessages(topicName, - partition.getId(), - partition.getFirstOffset(), - size, - deserializers)); + partition.getId(), + partition.getFirstOffset(), + size, + deserializers)); } messages.sort(Comparator.comparing(MessageVO::getTimestamp)); @@ -114,7 +127,8 @@ public String viewAllMessages(@PathVariable("name") String topicName, /** * Human friendly view of reading messages. - * @param topicName Name of topic + * + * @param topicName Name of topic * @param messageForm Message form for submitting requests to view messages. * @param errors * @param model @@ -142,11 +156,11 @@ public String viewMessageForm(@PathVariable("name") String topicName, } final TopicVO topic = kafkaMonitor.getTopic(topicName) - .orElseThrow(() -> new TopicNotFoundException(topicName)); + .orElseThrow(() -> new TopicNotFoundException(topicName)); model.addAttribute("topic", topic); // pre-select a descriptor file for a specific topic if available model.addAttribute("defaultDescFile", protobufProperties.getDescFilesList().stream() - .filter(descFile -> descFile.replace(".desc", "").equals(topicName)).findFirst().orElse("")); + .filter(descFile -> descFile.replace(".desc", "").equals(topicName)).findFirst().orElse("")); model.addAttribute("defaultFormat", defaultFormat); model.addAttribute("messageFormats", MessageFormat.values()); @@ -158,16 +172,16 @@ public String viewMessageForm(@PathVariable("name") String topicName, if (!messageForm.isEmpty() && !errors.hasErrors()) { final var deserializers = new Deserializers( - getDeserializer(topicName, messageForm.getKeyFormat(), messageForm.getDescFile(),messageForm.getMsgTypeName(), messageForm.getIsAnyProto()), - getDeserializer(topicName, messageForm.getFormat(), messageForm.getDescFile(), messageForm.getMsgTypeName(), messageForm.getIsAnyProto()) + getDeserializer(topicName, messageForm.getKeyFormat(), messageForm.getDescFile(), messageForm.getMsgTypeName(), messageForm.getIsAnyProto()), + getDeserializer(topicName, messageForm.getFormat(), messageForm.getDescFile(), messageForm.getMsgTypeName(), messageForm.getIsAnyProto()) ); model.addAttribute("messages", - messageInspector.getMessages(topicName, - messageForm.getPartition(), - messageForm.getOffset(), - messageForm.getCount().intValue(), - deserializers)); + messageInspector.getMessages(topicName, + messageForm.getPartition(), + messageForm.getOffset(), + messageForm.getCount().intValue(), + deserializers)); } @@ -178,6 +192,7 @@ public String viewMessageForm(@PathVariable("name") String topicName, /** * Returns the selected nessagr format based on the * form submission + * * @param format String representation of format name * @return */ @@ -186,7 +201,7 @@ private MessageFormat getSelectedMessageFormat(String format) { return MessageFormat.AVRO; } else if ("PROTOBUF".equalsIgnoreCase(format)) { return MessageFormat.PROTOBUF; - } else if ("MSGPACK".equalsIgnoreCase(format)){ + } else if ("MSGPACK".equalsIgnoreCase(format)) { return MessageFormat.MSGPACK; } else { return MessageFormat.DEFAULT; @@ -194,36 +209,36 @@ private MessageFormat getSelectedMessageFormat(String format) { } - /** * Return a JSON list of all partition offset info for the given topic. If specific partition * and offset parameters are given, then this returns actual kafka messages from that partition * (if the offsets are valid; if invalid offsets are passed then the message list is empty). + * * @param topicName Name of topic. * @return Offset or message data. */ @Operation(summary = "getPartitionOrMessages" - , description = "Get offset or message data for a topic. Without query params returns all partitions with offset data. With query params, returns actual messages (if valid offsets are provided).") + , description = "Get offset or message data for a topic. Without query params returns all partitions with offset data. With query params, returns actual messages (if valid offsets are provided).") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Success"), - @ApiResponse(responseCode = "404", description = "Invalid topic name") + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "404", description = "Invalid topic name") }) @GetMapping(value = "/topic/{name:.+}/messages", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List getPartitionOrMessages( - @PathVariable("name") String topicName, - @RequestParam(name = "partition", required = false) Integer partition, - @RequestParam(name = "offset", required = false) Long offset, - @RequestParam(name = "count", required = false) Integer count, - @RequestParam(name = "format", required = false) String format, - @RequestParam(name = "keyFormat", required = false) String keyFormat, - @RequestParam(name = "descFile", required = false) String descFile, - @RequestParam(name = "msgTypeName", required = false) String msgTypeName, - @RequestParam(name = "isAnyProto", required = false) Boolean isAnyProto + @PathVariable("name") String topicName, + @RequestParam(name = "partition", required = false) Integer partition, + @RequestParam(name = "offset", required = false) Long offset, + @RequestParam(name = "count", required = false) Integer count, + @RequestParam(name = "format", required = false) String format, + @RequestParam(name = "keyFormat", required = false) String keyFormat, + @RequestParam(name = "descFile", required = false) String descFile, + @RequestParam(name = "msgTypeName", required = false) String msgTypeName, + @RequestParam(name = "isAnyProto", required = false) Boolean isAnyProto ) { if (partition == null || offset == null || count == null) { final TopicVO topic = kafkaMonitor.getTopic(topicName) - .orElseThrow(() -> new TopicNotFoundException(topicName)); + .orElseThrow(() -> new TopicNotFoundException(topicName)); List partitionList = new ArrayList<>(); topic.getPartitions().forEach(vo -> partitionList.add(new PartitionOffsetInfo(vo.getId(), vo.getFirstOffset(), vo.getSize()))); @@ -232,16 +247,16 @@ List getPartitionOrMessages( } else { final var deserializers = new Deserializers( - getDeserializer(topicName, getSelectedMessageFormat(keyFormat), descFile, msgTypeName, isAnyProto), - getDeserializer(topicName, getSelectedMessageFormat(format), descFile, msgTypeName, isAnyProto)); + getDeserializer(topicName, getSelectedMessageFormat(keyFormat), descFile, msgTypeName, isAnyProto), + getDeserializer(topicName, getSelectedMessageFormat(format), descFile, msgTypeName, isAnyProto)); List messages = new ArrayList<>(); List vos = messageInspector.getMessages( - topicName, - partition, - offset, - count, - deserializers); + topicName, + partition, + offset, + count, + deserializers); if (vos != null) { messages.addAll(vos); @@ -263,8 +278,8 @@ private MessageDeserializer getDeserializer(String topicName, MessageFormat form // filter the input file name final var descFileName = descFile.replace(".desc", "") - .replace(".", "") - .replace("/", ""); + .replace(".", "") + .replace("/", ""); final var fullDescFile = protobufProperties.getDirectory() + File.separator + descFileName + ".desc"; deserializer = new ProtobufMessageDeserializer(fullDescFile, msgTypeName, isAnyProto); } else if (format == MessageFormat.PROTOBUF) { @@ -313,9 +328,9 @@ public static class PartitionOffsetInfo { private MessageFormat format; private MessageFormat keyFormat; - + private String descFile; - + private String msgTypeName; private Boolean isAnyProto = Boolean.FALSE; @@ -368,7 +383,9 @@ public MessageFormat getKeyFormat() { return keyFormat; } - public void setKeyFormat(MessageFormat keyFormat) { this.keyFormat = keyFormat; } + public void setKeyFormat(MessageFormat keyFormat) { + this.keyFormat = keyFormat; + } public MessageFormat getFormat() { return format; diff --git a/src/main/java/kafdrop/controller/TopicController.java b/src/main/java/kafdrop/controller/TopicController.java index d9f6e8ff..91ed718e 100644 --- a/src/main/java/kafdrop/controller/TopicController.java +++ b/src/main/java/kafdrop/controller/TopicController.java @@ -19,23 +19,28 @@ package kafdrop.controller; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import kafdrop.config.MessageFormatConfiguration; -import kafdrop.model.*; -import kafdrop.service.*; +import kafdrop.model.ConsumerVO; +import kafdrop.model.CreateTopicVO; +import kafdrop.model.TopicVO; +import kafdrop.service.KafkaMonitor; +import kafdrop.service.TopicNotFoundException; import kafdrop.util.MessageFormat; import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.*; -import org.springframework.stereotype.*; -import org.springframework.ui.*; -import org.springframework.web.bind.annotation.*; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; -import java.util.*; +import java.util.Collections; +import java.util.List; /** * Handles requests for the topic page. @@ -65,7 +70,7 @@ public String topicDetails(@PathVariable("name") String topicName, Model model) final MessageFormat defaultKeyFormat = messageFormatProperties.getKeyFormat(); final var topic = kafkaMonitor.getTopic(topicName) - .orElseThrow(() -> new TopicNotFoundException(topicName)); + .orElseThrow(() -> new TopicNotFoundException(topicName)); model.addAttribute("topic", topic); model.addAttribute("consumers", kafkaMonitor.getConsumersByTopics(Collections.singleton(topic))); model.addAttribute("topicDeleteEnabled", topicDeleteEnabled); @@ -93,6 +98,7 @@ public String deleteTopic(@PathVariable("name") String topicName, Model model) { /** * Topic create page + * * @param model * @return creation page */ @@ -105,13 +111,13 @@ public String createTopicPage(Model model) { @Operation(summary = "getTopic", description = "Get details for a topic") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Success"), - @ApiResponse(responseCode = "404", description = "Invalid topic name") + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "404", description = "Invalid topic name") }) @GetMapping(path = "/{name:.+}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody TopicVO getTopic(@PathVariable("name") String topicName) { return kafkaMonitor.getTopic(topicName) - .orElseThrow(() -> new TopicNotFoundException(topicName)); + .orElseThrow(() -> new TopicNotFoundException(topicName)); } @Operation(summary = "getAllTopics", description = "Get list of all topics") @@ -123,18 +129,19 @@ public String createTopicPage(Model model) { @Operation(summary = "getConsumers", description = "Get consumers for a topic") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Success"), - @ApiResponse(responseCode = "404", description = "Invalid topic name") + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "404", description = "Invalid topic name") }) @GetMapping(path = "/{name:.+}/consumers", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List getConsumers(@PathVariable("name") String topicName) { final var topic = kafkaMonitor.getTopic(topicName) - .orElseThrow(() -> new TopicNotFoundException(topicName)); + .orElseThrow(() -> new TopicNotFoundException(topicName)); return kafkaMonitor.getConsumersByTopics(Collections.singleton(topic)); } /** * API for topic creation + * * @param createTopicVO request */ @Operation(summary = "createTopic", description = "Create topic") @@ -148,7 +155,7 @@ public String createTopic(CreateTopicVO createTopicVO, Model model) { return createTopicPage(model); } try { - kafkaMonitor.createTopic(createTopicVO); + kafkaMonitor.createTopic(createTopicVO); } catch (Exception ex) { model.addAttribute("errorMessage", ex.getMessage()); } diff --git a/src/main/java/kafdrop/model/AclVO.java b/src/main/java/kafdrop/model/AclVO.java index a1333576..f2b918f0 100644 --- a/src/main/java/kafdrop/model/AclVO.java +++ b/src/main/java/kafdrop/model/AclVO.java @@ -20,67 +20,69 @@ import java.util.Objects; -public final class AclVO implements Comparable{ - private final String name; - private final String resourceType; - private final String patternType; +public final class AclVO implements Comparable { + private final String name; + private final String resourceType; + private final String patternType; - private final String principal; - private final String host; - private final String operation; - private final String permissionType; + private final String principal; + private final String host; + private final String operation; + private final String permissionType; - public AclVO(String resourceType, String name, String patternType, String principal, String host, String operation, String permissionType) { - this.resourceType = resourceType; - this.name = name; - this.patternType = patternType; - this.principal = principal; - this.host = host; - this.operation = operation; - this.permissionType = permissionType; - } + public AclVO(String resourceType, String name, String patternType, String principal, String host, String operation, String permissionType) { + this.resourceType = resourceType; + this.name = name; + this.patternType = patternType; + this.principal = principal; + this.host = host; + this.operation = operation; + this.permissionType = permissionType; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public String getResourceType() { - return resourceType; - } + public String getResourceType() { + return resourceType; + } - public String getPatternType() { - return patternType; - } + public String getPatternType() { + return patternType; + } - public String getPrincipal() { - return principal; - } + public String getPrincipal() { + return principal; + } - public String getHost() { - return host; - } + public String getHost() { + return host; + } - public String getOperation() { - return operation; - } + public String getOperation() { + return operation; + } - public String getPermissionType() { - return permissionType; - } + public String getPermissionType() { + return permissionType; + } - @Override - public int compareTo(AclVO that) { return this.name.compareTo(that.name) ; } + @Override + public int compareTo(AclVO that) { + return this.name.compareTo(that.name); + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - AclVO aclVO = (AclVO) o; - return name.equals(aclVO.name); - } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + AclVO aclVO = (AclVO) o; + return name.equals(aclVO.name); + } - @Override - public int hashCode() { - return Objects.hash(name); - } + @Override + public int hashCode() { + return Objects.hash(name); + } } diff --git a/src/main/java/kafdrop/model/ClusterSummaryVO.java b/src/main/java/kafdrop/model/ClusterSummaryVO.java index 3427f8ff..c7a3b2fc 100644 --- a/src/main/java/kafdrop/model/ClusterSummaryVO.java +++ b/src/main/java/kafdrop/model/ClusterSummaryVO.java @@ -18,7 +18,9 @@ package kafdrop.model; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; public final class ClusterSummaryVO { private int topicCount; diff --git a/src/main/java/kafdrop/model/ConsumerPartitionVO.java b/src/main/java/kafdrop/model/ConsumerPartitionVO.java index b1520d76..15af2ce0 100644 --- a/src/main/java/kafdrop/model/ConsumerPartitionVO.java +++ b/src/main/java/kafdrop/model/ConsumerPartitionVO.java @@ -77,7 +77,7 @@ public void setOffset(long offset) { @Override public String toString() { return ConsumerPartitionVO.class.getSimpleName() + " [groupId=" + groupId + - ", topic=" + topic + ", partitionId=" + partitionId + ", offset=" + offset + - ", size=" + size + ", firstOffset=" + firstOffset + "]"; + ", topic=" + topic + ", partitionId=" + partitionId + ", offset=" + offset + + ", size=" + size + ", firstOffset=" + firstOffset + "]"; } } diff --git a/src/main/java/kafdrop/model/ConsumerTopicVO.java b/src/main/java/kafdrop/model/ConsumerTopicVO.java index cde882cc..95c8317d 100644 --- a/src/main/java/kafdrop/model/ConsumerTopicVO.java +++ b/src/main/java/kafdrop/model/ConsumerTopicVO.java @@ -18,7 +18,9 @@ package kafdrop.model; -import java.util.*; +import java.util.Collection; +import java.util.Map; +import java.util.TreeMap; public final class ConsumerTopicVO { private final String topic; @@ -38,9 +40,9 @@ public void addOffset(ConsumerPartitionVO offset) { public long getLag() { return offsets.values().stream() - .map(ConsumerPartitionVO::getLag) - .filter(lag -> lag >= 0) - .reduce(0L, Long::sum); + .map(ConsumerPartitionVO::getLag) + .filter(lag -> lag >= 0) + .reduce(0L, Long::sum); } public Collection getPartitions() { diff --git a/src/main/java/kafdrop/model/ConsumerVO.java b/src/main/java/kafdrop/model/ConsumerVO.java index 61164be3..df28fffe 100644 --- a/src/main/java/kafdrop/model/ConsumerVO.java +++ b/src/main/java/kafdrop/model/ConsumerVO.java @@ -18,9 +18,12 @@ package kafdrop.model; -import org.apache.commons.lang3.*; +import org.apache.commons.lang3.Validate; -import java.util.*; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.TreeMap; public final class ConsumerVO implements Comparable { private final String groupId; diff --git a/src/main/java/kafdrop/model/MessageVO.java b/src/main/java/kafdrop/model/MessageVO.java index e0cd80d0..be7f9436 100644 --- a/src/main/java/kafdrop/model/MessageVO.java +++ b/src/main/java/kafdrop/model/MessageVO.java @@ -18,8 +18,9 @@ package kafdrop.model; -import java.util.*; -import java.util.stream.*; +import java.util.Date; +import java.util.Map; +import java.util.stream.Collectors; public final class MessageVO { private int partition; @@ -29,11 +30,21 @@ public final class MessageVO { private Map headers; private Date timestamp; - public int getPartition() { return partition; } - public void setPartition(int partition) { this.partition = partition; } + public int getPartition() { + return partition; + } + + public void setPartition(int partition) { + this.partition = partition; + } - public long getOffset() { return offset; } - public void setOffset(long offset) { this.offset = offset; } + public long getOffset() { + return offset; + } + + public void setOffset(long offset) { + this.offset = offset; + } public String getMessage() { return message; @@ -64,8 +75,8 @@ public String getHeadersFormatted() { return "empty"; } else { return headers.entrySet().stream() - .map(e -> e.getKey() + ": " + e.getValue()) - .collect(Collectors.joining(", ")); + .map(e -> e.getKey() + ": " + e.getValue()) + .collect(Collectors.joining(", ")); } } diff --git a/src/main/java/kafdrop/model/TopicPartitionVO.java b/src/main/java/kafdrop/model/TopicPartitionVO.java index 13774e27..69e3ecdc 100644 --- a/src/main/java/kafdrop/model/TopicPartitionVO.java +++ b/src/main/java/kafdrop/model/TopicPartitionVO.java @@ -18,8 +18,14 @@ package kafdrop.model; -import java.util.*; -import java.util.stream.*; +import java.util.Collection; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; public final class TopicPartitionVO { private final int id; @@ -65,24 +71,24 @@ public boolean isLeaderPreferred() { public List getInSyncReplicas() { return inSyncReplicaStream() - .sorted(Comparator.comparingInt(PartitionReplica::getId)) - .collect(Collectors.toList()); + .sorted(Comparator.comparingInt(PartitionReplica::getId)) + .collect(Collectors.toList()); } private Stream inSyncReplicaStream() { return replicas.values().stream() - .filter(PartitionReplica::isInSync); + .filter(PartitionReplica::isInSync); } public List getOfflineReplicas() { return offlineReplicasStream() - .sorted(Comparator.comparingInt(PartitionReplica::getId)) - .collect(Collectors.toList()); + .sorted(Comparator.comparingInt(PartitionReplica::getId)) + .collect(Collectors.toList()); } private Stream offlineReplicasStream() { return replicas.values().stream() - .filter(PartitionReplica::isOffline); + .filter(PartitionReplica::isOffline); } public boolean isUnderReplicated() { @@ -137,6 +143,6 @@ boolean isOffline() { @Override public String toString() { - return TopicPartitionVO.class.getSimpleName() + " [id=" + id +", firstOffset=" + firstOffset + ", size=" + size + "]"; + return TopicPartitionVO.class.getSimpleName() + " [id=" + id + ", firstOffset=" + firstOffset + ", size=" + size + "]"; } } diff --git a/src/main/java/kafdrop/model/TopicVO.java b/src/main/java/kafdrop/model/TopicVO.java index 3055d9f0..b0c5fd71 100644 --- a/src/main/java/kafdrop/model/TopicVO.java +++ b/src/main/java/kafdrop/model/TopicVO.java @@ -18,8 +18,13 @@ package kafdrop.model; -import java.util.*; -import java.util.stream.*; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.TreeMap; +import java.util.stream.Collectors; public final class TopicVO implements Comparable { private final String name; @@ -58,34 +63,36 @@ public Optional getPartition(int partitionId) { public Collection getLeaderPartitions(int brokerId) { return partitions.values().stream() - .filter(tp -> tp.getLeader() != null && tp.getLeader().getId() == brokerId) - .collect(Collectors.toList()); + .filter(tp -> tp.getLeader() != null && tp.getLeader().getId() == brokerId) + .collect(Collectors.toList()); } public Collection getUnderReplicatedPartitions() { return partitions.values().stream() - .filter(TopicPartitionVO::isUnderReplicated) - .collect(Collectors.toList()); + .filter(TopicPartitionVO::isUnderReplicated) + .collect(Collectors.toList()); } /** * Returns the total number of messages published to the topic, ever + * * @return */ public long getTotalSize() { return partitions.values().stream() - .map(TopicPartitionVO::getSize) - .reduce(0L, Long::sum); + .map(TopicPartitionVO::getSize) + .reduce(0L, Long::sum); } /** * Returns the total number of messages available to consume from the topic. + * * @return */ public long getAvailableSize() { return partitions.values().stream() - .map(p -> p.getSize() - p.getFirstOffset()) - .reduce(0L, Long::sum); + .map(p -> p.getSize() - p.getFirstOffset()) + .reduce(0L, Long::sum); } public double getPreferredReplicaPercent() { @@ -93,8 +100,8 @@ public double getPreferredReplicaPercent() { return 0; } else { final var preferredLeaderCount = partitions.values().stream() - .filter(TopicPartitionVO::isLeaderPreferred) - .count(); + .filter(TopicPartitionVO::isLeaderPreferred) + .count(); return ((double) preferredLeaderCount) / ((double) partitions.size()); } } @@ -123,6 +130,6 @@ public int hashCode() { @Override public String toString() { - return TopicVO.class.getSimpleName() + " [name=" + name +", partitions=" + partitions + "]"; + return TopicVO.class.getSimpleName() + " [name=" + name + ", partitions=" + partitions + "]"; } } diff --git a/src/main/java/kafdrop/service/BrokerNotFoundException.java b/src/main/java/kafdrop/service/BrokerNotFoundException.java index d9f30750..da9496c3 100644 --- a/src/main/java/kafdrop/service/BrokerNotFoundException.java +++ b/src/main/java/kafdrop/service/BrokerNotFoundException.java @@ -18,8 +18,8 @@ package kafdrop.service; -import org.springframework.http.*; -import org.springframework.web.bind.annotation.*; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(HttpStatus.NOT_FOUND) public final class BrokerNotFoundException extends RuntimeException { diff --git a/src/main/java/kafdrop/service/BuildInfo.java b/src/main/java/kafdrop/service/BuildInfo.java index 0b557310..327d0d47 100644 --- a/src/main/java/kafdrop/service/BuildInfo.java +++ b/src/main/java/kafdrop/service/BuildInfo.java @@ -1,12 +1,12 @@ package kafdrop.service; -import org.slf4j.*; -import org.springframework.boot.autoconfigure.condition.*; -import org.springframework.boot.info.*; -import org.springframework.stereotype.*; +import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnResource; +import org.springframework.boot.info.BuildProperties; +import org.springframework.stereotype.Service; @Service -@ConditionalOnResource(resources="${spring.info.build.location:classpath:META-INF/build-info.properties}") +@ConditionalOnResource(resources = "${spring.info.build.location:classpath:META-INF/build-info.properties}") public final class BuildInfo { private final BuildProperties buildProperties; diff --git a/src/main/java/kafdrop/service/KafkaHighLevelAdminClient.java b/src/main/java/kafdrop/service/KafkaHighLevelAdminClient.java index 8704040f..58a3868a 100644 --- a/src/main/java/kafdrop/service/KafkaHighLevelAdminClient.java +++ b/src/main/java/kafdrop/service/KafkaHighLevelAdminClient.java @@ -1,25 +1,39 @@ package kafdrop.service; -import kafdrop.config.*; -import org.apache.kafka.clients.admin.*; +import jakarta.annotation.PostConstruct; +import kafdrop.config.KafkaConfiguration; +import org.apache.kafka.clients.admin.AdminClient; import org.apache.kafka.clients.admin.Config; -import org.apache.kafka.clients.consumer.*; -import org.apache.kafka.common.*; +import org.apache.kafka.clients.admin.ConsumerGroupListing; +import org.apache.kafka.clients.admin.DeleteTopicsOptions; +import org.apache.kafka.clients.admin.NewTopic; +import org.apache.kafka.clients.consumer.ConsumerConfig; +import org.apache.kafka.clients.consumer.OffsetAndMetadata; +import org.apache.kafka.common.Node; +import org.apache.kafka.common.TopicPartition; import org.apache.kafka.common.acl.AccessControlEntryFilter; import org.apache.kafka.common.acl.AclBinding; import org.apache.kafka.common.acl.AclBindingFilter; -import org.apache.kafka.common.config.*; -import org.apache.kafka.common.config.ConfigResource.*; -import org.apache.kafka.common.errors.*; +import org.apache.kafka.common.config.ConfigResource; +import org.apache.kafka.common.config.ConfigResource.Type; +import org.apache.kafka.common.errors.GroupAuthorizationException; +import org.apache.kafka.common.errors.SecurityDisabledException; +import org.apache.kafka.common.errors.TopicAuthorizationException; +import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.resource.ResourcePatternFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.stereotype.*; - -import jakarta.annotation.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.stream.*; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; @Service public final class KafkaHighLevelAdminClient { @@ -95,8 +109,8 @@ Map listConsumerGroupOffsetsIfAuthorized(Stri Map describeTopicConfigs(Set topicNames) { final var resources = topicNames.stream() - .map(topic -> new ConfigResource(Type.TOPIC, topic)) - .collect(Collectors.toList()); + .map(topic -> new ConfigResource(Type.TOPIC, topic)) + .collect(Collectors.toList()); final var result = adminClient.describeConfigs(resources); final Map configsByTopic; try { @@ -157,7 +171,7 @@ Collection listAcls() { final Collection aclsBindings; try { aclsBindings = adminClient.describeAcls(new AclBindingFilter(ResourcePatternFilter.ANY, AccessControlEntryFilter.ANY)) - .values().get(); + .values().get(); } catch (InterruptedException | ExecutionException e) { if (e.getCause() instanceof SecurityDisabledException) { return Collections.emptyList(); diff --git a/src/main/java/kafdrop/service/KafkaHighLevelConsumer.java b/src/main/java/kafdrop/service/KafkaHighLevelConsumer.java index d76f3780..577c0ce4 100644 --- a/src/main/java/kafdrop/service/KafkaHighLevelConsumer.java +++ b/src/main/java/kafdrop/service/KafkaHighLevelConsumer.java @@ -1,20 +1,34 @@ package kafdrop.service; -import kafdrop.config.*; -import kafdrop.model.*; -import kafdrop.util.*; +import jakarta.annotation.PostConstruct; +import kafdrop.config.KafkaConfiguration; +import kafdrop.model.TopicPartitionVO; +import kafdrop.model.TopicVO; +import kafdrop.util.Deserializers; +import kafdrop.util.MessageDeserializer; import org.apache.commons.lang3.tuple.Pair; -import org.apache.kafka.clients.consumer.*; +import org.apache.kafka.clients.consumer.ConsumerConfig; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.KafkaConsumer; import org.apache.kafka.common.Node; -import org.apache.kafka.common.*; -import org.apache.kafka.common.serialization.*; -import org.slf4j.*; -import org.springframework.stereotype.*; +import org.apache.kafka.common.PartitionInfo; +import org.apache.kafka.common.TopicPartition; +import org.apache.kafka.common.serialization.ByteArrayDeserializer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; -import jakarta.annotation.PostConstruct; import java.nio.ByteBuffer; import java.time.Duration; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; +import java.util.TreeMap; import java.util.stream.Collectors; @Service @@ -83,9 +97,10 @@ synchronized void setTopicPartitionSizes(List topics) { /** * Retrieves latest records from the given offset. - * @param partition Topic partition - * @param offset Offset to seek from - * @param count Maximum number of records returned + * + * @param partition Topic partition + * @param offset Offset to seek from + * @param count Maximum number of records returned * @param deserializers Key and Value deserialiser * @return Latest records */ @@ -108,7 +123,7 @@ synchronized List> getLatestRecords(TopicPartitio while (rawRecords.size() < count && currentOffset < latestOffset) { final var polled = kafkaConsumer.poll(Duration.ofMillis(POLL_TIMEOUT_MS)).records(partition); - if (! polled.isEmpty()) { + if (!polled.isEmpty()) { rawRecords.addAll(polled); currentOffset = polled.get(polled.size() - 1).offset(); emptyPolls = 0; @@ -118,25 +133,26 @@ synchronized List> getLatestRecords(TopicPartitio } return rawRecords - .subList(0, Math.min(count, rawRecords.size())) - .stream() - .map(rec -> new ConsumerRecord<>(rec.topic(), - rec.partition(), - rec.offset(), - rec.timestamp(), - rec.timestampType(), - rec.serializedKeySize(), - rec.serializedValueSize(), - deserialize(deserializers.getKeyDeserializer(),rec.key()), - deserialize(deserializers.getValueDeserializer(), rec.value()), - rec.headers(), - rec.leaderEpoch())) - .collect(Collectors.toList()); + .subList(0, Math.min(count, rawRecords.size())) + .stream() + .map(rec -> new ConsumerRecord<>(rec.topic(), + rec.partition(), + rec.offset(), + rec.timestamp(), + rec.timestampType(), + rec.serializedKeySize(), + rec.serializedValueSize(), + deserialize(deserializers.getKeyDeserializer(), rec.key()), + deserialize(deserializers.getValueDeserializer(), rec.value()), + rec.headers(), + rec.leaderEpoch())) + .collect(Collectors.toList()); } /** * Gets records from all partitions of a given topic. - * @param count The maximum number of records getting back. + * + * @param count The maximum number of records getting back. * @param deserializers Key and Value deserializers * @return A list of consumer records for a given topic. */ @@ -146,9 +162,9 @@ synchronized List> getLatestRecords(String topic, initializeClient(); final var partitionInfoSet = kafkaConsumer.partitionsFor(topic); final var partitions = partitionInfoSet.stream() - .map(partitionInfo -> new TopicPartition(partitionInfo.topic(), - partitionInfo.partition())) - .collect(Collectors.toList()); + .map(partitionInfo -> new TopicPartition(partitionInfo.topic(), + partitionInfo.partition())) + .collect(Collectors.toList()); kafkaConsumer.assign(partitions); final var latestOffsets = kafkaConsumer.endOffsets(partitions); @@ -159,7 +175,7 @@ synchronized List> getLatestRecords(String topic, final var totalCount = count * partitions.size(); final Map>> rawRecords - = partitions.stream().collect(Collectors.toMap(p -> p , p -> new ArrayList<>(count))); + = partitions.stream().collect(Collectors.toMap(p -> p, p -> new ArrayList<>(count))); var moreRecords = true; while (rawRecords.size() < totalCount && moreRecords) { @@ -176,21 +192,21 @@ synchronized List> getLatestRecords(String topic, } return rawRecords - .values() - .stream() - .flatMap(Collection::stream) - .map(rec -> new ConsumerRecord<>(rec.topic(), - rec.partition(), - rec.offset(), - rec.timestamp(), - rec.timestampType(), - rec.serializedKeySize(), - rec.serializedValueSize(), - deserialize(deserializers.getKeyDeserializer(), rec.key()), - deserialize(deserializers.getValueDeserializer(), rec.value()), - rec.headers(), - rec.leaderEpoch())) - .collect(Collectors.toList()); + .values() + .stream() + .flatMap(Collection::stream) + .map(rec -> new ConsumerRecord<>(rec.topic(), + rec.partition(), + rec.offset(), + rec.timestamp(), + rec.timestampType(), + rec.serializedKeySize(), + rec.serializedValueSize(), + deserialize(deserializers.getKeyDeserializer(), rec.key()), + deserialize(deserializers.getValueDeserializer(), rec.value()), + rec.headers(), + rec.leaderEpoch())) + .collect(Collectors.toList()); } private static String deserialize(MessageDeserializer deserializer, byte[] bytes) { @@ -215,7 +231,7 @@ synchronized Map getTopicInfos(Map> .filter(topicSet::contains) .map(topic -> Pair.of(topic, getTopicInfo(topic, allTopicsMap.get(topic)))) .collect(Collectors.toMap(Pair::getKey, Pair::getValue)); - } + } private TopicVO getTopicInfo(String topic, List partitionInfoList) { final var topicVo = new TopicVO(topic); diff --git a/src/main/java/kafdrop/service/KafkaMonitor.java b/src/main/java/kafdrop/service/KafkaMonitor.java index 137ac4f3..ad7e9274 100644 --- a/src/main/java/kafdrop/service/KafkaMonitor.java +++ b/src/main/java/kafdrop/service/KafkaMonitor.java @@ -18,11 +18,19 @@ package kafdrop.service; -import kafdrop.model.*; -import kafdrop.util.*; -import org.apache.kafka.common.*; +import kafdrop.model.AclVO; +import kafdrop.model.BrokerVO; +import kafdrop.model.ClusterSummaryVO; +import kafdrop.model.ConsumerVO; +import kafdrop.model.CreateTopicVO; +import kafdrop.model.MessageVO; +import kafdrop.model.TopicVO; +import kafdrop.util.Deserializers; +import org.apache.kafka.common.TopicPartition; -import java.util.*; +import java.util.Collection; +import java.util.List; +import java.util.Optional; public interface KafkaMonitor { List getBrokers(); @@ -50,12 +58,14 @@ List getMessages(TopicPartition topicPartition, long offset, int coun /** * Create topic + * * @param createTopicDto topic params */ void createTopic(CreateTopicVO createTopicDto); /** * Delete the given topic + * * @param topic name of the topic to delete */ void deleteTopic(String topic); diff --git a/src/main/java/kafdrop/service/KafkaMonitorImpl.java b/src/main/java/kafdrop/service/KafkaMonitorImpl.java index f33fd917..d2d99c95 100644 --- a/src/main/java/kafdrop/service/KafkaMonitorImpl.java +++ b/src/main/java/kafdrop/service/KafkaMonitorImpl.java @@ -18,20 +18,40 @@ package kafdrop.service; -import kafdrop.model.*; -import kafdrop.util.*; -import org.apache.kafka.clients.admin.*; -import org.apache.kafka.clients.admin.ConfigEntry.*; -import org.apache.kafka.clients.consumer.*; -import org.apache.kafka.common.*; -import org.apache.kafka.common.header.*; -import org.slf4j.*; -import org.springframework.stereotype.*; - -import java.util.*; -import java.util.Map.*; -import java.util.function.*; -import java.util.stream.*; +import kafdrop.model.AclVO; +import kafdrop.model.BrokerVO; +import kafdrop.model.ClusterSummaryVO; +import kafdrop.model.ConsumerPartitionVO; +import kafdrop.model.ConsumerTopicVO; +import kafdrop.model.ConsumerVO; +import kafdrop.model.CreateTopicVO; +import kafdrop.model.MessageVO; +import kafdrop.model.TopicPartitionVO; +import kafdrop.model.TopicVO; +import kafdrop.util.Deserializers; +import org.apache.kafka.clients.admin.ConfigEntry.ConfigSource; +import org.apache.kafka.clients.admin.NewTopic; +import org.apache.kafka.clients.consumer.OffsetAndMetadata; +import org.apache.kafka.common.PartitionInfo; +import org.apache.kafka.common.TopicPartition; +import org.apache.kafka.common.header.Headers; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; +import java.util.TreeMap; +import java.util.function.Function; +import java.util.stream.Collectors; import static java.util.function.Predicate.not; @@ -67,31 +87,31 @@ public Optional getBroker(int id) { @Override public ClusterSummaryVO getClusterSummary(Collection topics) { final var topicSummary = topics.stream() - .map(topic -> { - final var summary = new ClusterSummaryVO(); - summary.setPartitionCount(topic.getPartitions().size()); - summary.setUnderReplicatedCount(topic.getUnderReplicatedPartitions().size()); - summary.setPreferredReplicaPercent(topic.getPreferredReplicaPercent()); - topic.getPartitions() - .forEach(partition -> { - if (partition.getLeader() != null) { - summary.addBrokerLeaderPartition(partition.getLeader().getId()); - } - if (partition.getPreferredLeader() != null) { - summary.addBrokerPreferredLeaderPartition(partition.getPreferredLeader().getId()); - } - }); - return summary; - }) - .reduce((s1, s2) -> { - s1.setPartitionCount(s1.getPartitionCount() + s2.getPartitionCount()); - s1.setUnderReplicatedCount(s1.getUnderReplicatedCount() + s2.getUnderReplicatedCount()); - s1.setPreferredReplicaPercent(s1.getPreferredReplicaPercent() + s2.getPreferredReplicaPercent()); - s2.getBrokerLeaderPartitionCount().forEach(s1::addBrokerLeaderPartition); - s2.getBrokerPreferredLeaderPartitionCount().forEach(s1::addBrokerPreferredLeaderPartition); - return s1; - }) - .orElseGet(ClusterSummaryVO::new); + .map(topic -> { + final var summary = new ClusterSummaryVO(); + summary.setPartitionCount(topic.getPartitions().size()); + summary.setUnderReplicatedCount(topic.getUnderReplicatedPartitions().size()); + summary.setPreferredReplicaPercent(topic.getPreferredReplicaPercent()); + topic.getPartitions() + .forEach(partition -> { + if (partition.getLeader() != null) { + summary.addBrokerLeaderPartition(partition.getLeader().getId()); + } + if (partition.getPreferredLeader() != null) { + summary.addBrokerPreferredLeaderPartition(partition.getPreferredLeader().getId()); + } + }); + return summary; + }) + .reduce((s1, s2) -> { + s1.setPartitionCount(s1.getPartitionCount() + s2.getPartitionCount()); + s1.setUnderReplicatedCount(s1.getUnderReplicatedCount() + s2.getUnderReplicatedCount()); + s1.setPreferredReplicaPercent(s1.getPreferredReplicaPercent() + s2.getPreferredReplicaPercent()); + s2.getBrokerLeaderPartitionCount().forEach(s1::addBrokerLeaderPartition); + s2.getBrokerPreferredLeaderPartitionCount().forEach(s1::addBrokerPreferredLeaderPartition); + return s1; + }) + .orElseGet(ClusterSummaryVO::new); topicSummary.setTopicCount(topics.size()); topicSummary.setPreferredReplicaPercent(topics.isEmpty() ? 0 : topicSummary.getPreferredReplicaPercent() / topics.size()); return topicSummary; @@ -100,8 +120,8 @@ public ClusterSummaryVO getClusterSummary(Collection topics) { @Override public List getTopics() { return getTopicMetadata(highLevelConsumer.getAllTopics()).values().stream() - .sorted(Comparator.comparing(TopicVO::getName)) - .collect(Collectors.toList()); + .sorted(Comparator.comparing(TopicVO::getName)) + .collect(Collectors.toList()); } public List getTopics(String[] topics) { @@ -115,7 +135,7 @@ public List getTopics(String[] topics) { @Override public Optional getTopic(String topic) { - String[] topics = { topic }; + String[] topics = {topic}; return getTopics(topics).stream().findAny(); } @@ -131,7 +151,7 @@ private Map getTopicMetadata(Map> a final var configMap = new TreeMap(); for (var configEntry : config.entries()) { if (configEntry.source() != ConfigSource.DEFAULT_CONFIG && - configEntry.source() != ConfigSource.STATIC_BROKER_CONFIG) { + configEntry.source() != ConfigSource.STATIC_BROKER_CONFIG) { configMap.put(configEntry.name(), configEntry.value()); } } @@ -206,7 +226,7 @@ public List getConsumersByGroup(String groupId) { String[] uniqueTopicNames = consumerGroupOffsets.stream() .flatMap(consumerGroupOffset -> consumerGroupOffset.offsets.keySet() - .stream().map(TopicPartition::topic)) + .stream().map(TopicPartition::topic)) .distinct() .toArray(String[]::new); @@ -229,7 +249,7 @@ public List getConsumersByTopics(Collection topicVos) { @Override public void createTopic(CreateTopicVO createTopicDto) { var newTopic = new NewTopic( - createTopicDto.getName(), createTopicDto.getPartitionsNumber(), (short) createTopicDto.getReplicationFactor() + createTopicDto.getName(), createTopicDto.getPartitionsNumber(), (short) createTopicDto.getReplicationFactor() ); highLevelAdminClient.createTopic(newTopic); } @@ -245,9 +265,9 @@ public List getAcls() { final var aclVos = new ArrayList(acls.size()); for (var acl : acls) { aclVos.add(new AclVO(acl.pattern().resourceType().toString(), acl.pattern().name(), - acl.pattern().patternType().toString(), acl.entry().principal(), - acl.entry().host(), acl.entry().operation().toString(), - acl.entry().permissionType().toString())); + acl.pattern().patternType().toString(), acl.entry().principal(), + acl.entry().host(), acl.entry().operation().toString(), + acl.entry().permissionType().toString())); } Collections.sort(aclVos); return aclVos; @@ -265,9 +285,9 @@ private static List convert(List consumerGroup final var partition = topicPartitionOffset.getKey().partition(); final var offset = topicPartitionOffset.getValue().offset(); groupTopicPartitionOffsetMap - .computeIfAbsent(groupId, unused -> new TreeMap<>()) - .computeIfAbsent(topic, unused -> new TreeMap<>()) - .put(partition, offset); + .computeIfAbsent(groupId, unused -> new TreeMap<>()) + .computeIfAbsent(topic, unused -> new TreeMap<>()) + .put(partition, offset); } } @@ -314,9 +334,9 @@ boolean isEmpty() { ConsumerGroupOffsets forTopics(Set topics) { final var filteredOffsets = offsets.entrySet().stream() - .filter(e -> e.getValue() != null) - .filter(e -> topics.contains(e.getKey().topic())) - .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); + .filter(e -> e.getValue() != null) + .filter(e -> topics.contains(e.getKey().topic())) + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); return new ConsumerGroupOffsets(groupId, filteredOffsets); } @@ -337,9 +357,9 @@ private List getConsumerOffsets(String groupId) { private List getConsumerOffsets(Set topics) { final var consumerGroups = highLevelAdminClient.listConsumerGroups(); return consumerGroups.stream() - .map(this::resolveOffsets) - .map(offsets -> offsets.forTopics(topics)) - .filter(not(ConsumerGroupOffsets::isEmpty)) - .collect(Collectors.toList()); + .map(this::resolveOffsets) + .map(offsets -> offsets.forTopics(topics)) + .filter(not(ConsumerGroupOffsets::isEmpty)) + .collect(Collectors.toList()); } } diff --git a/src/main/java/kafdrop/service/MessageInspector.java b/src/main/java/kafdrop/service/MessageInspector.java index b677dfe1..8b3cb9e9 100644 --- a/src/main/java/kafdrop/service/MessageInspector.java +++ b/src/main/java/kafdrop/service/MessageInspector.java @@ -18,12 +18,12 @@ package kafdrop.service; -import kafdrop.model.*; -import kafdrop.util.*; -import org.apache.kafka.common.*; -import org.springframework.stereotype.*; +import kafdrop.model.MessageVO; +import kafdrop.util.Deserializers; +import org.apache.kafka.common.TopicPartition; +import org.springframework.stereotype.Service; -import java.util.*; +import java.util.List; @Service public final class MessageInspector { diff --git a/src/main/java/kafdrop/service/NotInitializedException.java b/src/main/java/kafdrop/service/NotInitializedException.java index 908b2316..c4d0eb8d 100644 --- a/src/main/java/kafdrop/service/NotInitializedException.java +++ b/src/main/java/kafdrop/service/NotInitializedException.java @@ -19,5 +19,6 @@ package kafdrop.service; public final class NotInitializedException extends RuntimeException { - NotInitializedException() {} + NotInitializedException() { + } } diff --git a/src/main/java/kafdrop/service/TopicNotFoundException.java b/src/main/java/kafdrop/service/TopicNotFoundException.java index b8134d84..32222221 100644 --- a/src/main/java/kafdrop/service/TopicNotFoundException.java +++ b/src/main/java/kafdrop/service/TopicNotFoundException.java @@ -18,8 +18,8 @@ package kafdrop.service; -import org.springframework.http.*; -import org.springframework.web.bind.annotation.*; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(HttpStatus.NOT_FOUND) public class TopicNotFoundException extends RuntimeException { diff --git a/src/main/java/kafdrop/util/AvroMessageDeserializer.java b/src/main/java/kafdrop/util/AvroMessageDeserializer.java index b01ea072..41bc08d0 100644 --- a/src/main/java/kafdrop/util/AvroMessageDeserializer.java +++ b/src/main/java/kafdrop/util/AvroMessageDeserializer.java @@ -1,9 +1,10 @@ package kafdrop.util; -import io.confluent.kafka.serializers.*; +import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig; +import io.confluent.kafka.serializers.KafkaAvroDeserializer; -import java.nio.*; -import java.util.*; +import java.nio.ByteBuffer; +import java.util.HashMap; public final class AvroMessageDeserializer implements MessageDeserializer { diff --git a/src/main/java/kafdrop/util/ByteUtils.java b/src/main/java/kafdrop/util/ByteUtils.java index 71f58062..6239832f 100644 --- a/src/main/java/kafdrop/util/ByteUtils.java +++ b/src/main/java/kafdrop/util/ByteUtils.java @@ -1,12 +1,13 @@ package kafdrop.util; -import java.nio.*; -import java.nio.charset.*; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; final class ByteUtils { private ByteUtils() { // no instance allowed, static utility class } + static String readString(ByteBuffer buffer) { return new String(readBytes(buffer), StandardCharsets.UTF_8); } diff --git a/src/main/java/kafdrop/util/DefaultMessageDeserializer.java b/src/main/java/kafdrop/util/DefaultMessageDeserializer.java index c7fb0d0d..4e148e8c 100644 --- a/src/main/java/kafdrop/util/DefaultMessageDeserializer.java +++ b/src/main/java/kafdrop/util/DefaultMessageDeserializer.java @@ -1,6 +1,6 @@ package kafdrop.util; -import java.nio.*; +import java.nio.ByteBuffer; public class DefaultMessageDeserializer implements MessageDeserializer { @Override diff --git a/src/main/java/kafdrop/util/DeserializationException.java b/src/main/java/kafdrop/util/DeserializationException.java index f17dbb5c..7cce3fca 100644 --- a/src/main/java/kafdrop/util/DeserializationException.java +++ b/src/main/java/kafdrop/util/DeserializationException.java @@ -1,12 +1,12 @@ package kafdrop.util; public class DeserializationException extends RuntimeException { - /** - * - */ - private static final long serialVersionUID = -2575341690419824332L; + /** + * + */ + private static final long serialVersionUID = -2575341690419824332L; - public DeserializationException(String msg) { - super(msg); - } + public DeserializationException(String msg) { + super(msg); + } } diff --git a/src/main/java/kafdrop/util/Deserializers.java b/src/main/java/kafdrop/util/Deserializers.java index 09fe3089..fa0e3b51 100644 --- a/src/main/java/kafdrop/util/Deserializers.java +++ b/src/main/java/kafdrop/util/Deserializers.java @@ -2,20 +2,20 @@ public class Deserializers { - private final MessageDeserializer keyDeserializer; - private final MessageDeserializer valueDeserializer; + private final MessageDeserializer keyDeserializer; + private final MessageDeserializer valueDeserializer; - public Deserializers(MessageDeserializer keyDeserializer, MessageDeserializer valueDeserializer) { - this.keyDeserializer = keyDeserializer; - this.valueDeserializer = valueDeserializer; - } + public Deserializers(MessageDeserializer keyDeserializer, MessageDeserializer valueDeserializer) { + this.keyDeserializer = keyDeserializer; + this.valueDeserializer = valueDeserializer; + } - public MessageDeserializer getKeyDeserializer() { - return keyDeserializer; - } + public MessageDeserializer getKeyDeserializer() { + return keyDeserializer; + } - public MessageDeserializer getValueDeserializer() { - return valueDeserializer; - } + public MessageDeserializer getValueDeserializer() { + return valueDeserializer; + } } diff --git a/src/main/java/kafdrop/util/KeyFormat.java b/src/main/java/kafdrop/util/KeyFormat.java index 50d274e6..a389734b 100644 --- a/src/main/java/kafdrop/util/KeyFormat.java +++ b/src/main/java/kafdrop/util/KeyFormat.java @@ -1,5 +1,5 @@ package kafdrop.util; public enum KeyFormat { - DEFAULT, AVRO + DEFAULT, AVRO } \ No newline at end of file diff --git a/src/main/java/kafdrop/util/MessageDeserializer.java b/src/main/java/kafdrop/util/MessageDeserializer.java index eeed1135..6f9117b8 100644 --- a/src/main/java/kafdrop/util/MessageDeserializer.java +++ b/src/main/java/kafdrop/util/MessageDeserializer.java @@ -1,6 +1,6 @@ package kafdrop.util; -import java.nio.*; +import java.nio.ByteBuffer; @FunctionalInterface public interface MessageDeserializer { diff --git a/src/main/java/kafdrop/util/MsgPackMessageDeserializer.java b/src/main/java/kafdrop/util/MsgPackMessageDeserializer.java index e3ce01e1..a1133aa9 100644 --- a/src/main/java/kafdrop/util/MsgPackMessageDeserializer.java +++ b/src/main/java/kafdrop/util/MsgPackMessageDeserializer.java @@ -1,13 +1,12 @@ package kafdrop.util; -import java.io.IOException; -import java.nio.ByteBuffer; - +import org.msgpack.core.MessagePack; +import org.msgpack.core.MessageUnpacker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.msgpack.core.MessagePack; -import org.msgpack.core.MessageUnpacker; +import java.io.IOException; +import java.nio.ByteBuffer; public class MsgPackMessageDeserializer implements MessageDeserializer { diff --git a/src/main/java/kafdrop/util/ProtobufMessageDeserializer.java b/src/main/java/kafdrop/util/ProtobufMessageDeserializer.java index 66f906a3..33353f8d 100644 --- a/src/main/java/kafdrop/util/ProtobufMessageDeserializer.java +++ b/src/main/java/kafdrop/util/ProtobufMessageDeserializer.java @@ -1,18 +1,5 @@ package kafdrop.util; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.google.protobuf.Any; import com.google.protobuf.CodedInputStream; import com.google.protobuf.DescriptorProtos.FileDescriptorProto; @@ -23,6 +10,18 @@ import com.google.protobuf.DynamicMessage; import com.google.protobuf.util.JsonFormat; import com.google.protobuf.util.JsonFormat.Printer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; public class ProtobufMessageDeserializer implements MessageDeserializer { @@ -48,8 +47,8 @@ public String deserializeMessage(ByteBuffer buffer) { List descs = new ArrayList<>(); for (FileDescriptorProto ffdp : set.getFileList()) { FileDescriptor fd = Descriptors.FileDescriptor.buildFrom( - ffdp, - descs.toArray(new FileDescriptor[0])); + ffdp, + descs.toArray(new FileDescriptor[0])); descs.add(fd); } @@ -57,9 +56,9 @@ public String deserializeMessage(ByteBuffer buffer) { // automatically detect the message type name if the proto is "Any" and no message type name is given if (isAnyProto && msgTypeName.isBlank()) { String typeUrl = Any.parseFrom(buffer).getTypeUrl(); - String[] splittedTypeUrl = typeUrl.split("/"); - // the last part in the type url is always the FQCN for this proto - msgTypeNameRef.set(splittedTypeUrl[splittedTypeUrl.length - 1]); + String[] splittedTypeUrl = typeUrl.split("/"); + // the last part in the type url is always the FQCN for this proto + msgTypeNameRef.set(splittedTypeUrl[splittedTypeUrl.length - 1]); } // check for full name too if the proto is "Any" final var messageDescriptor = descriptors.stream().filter(desc -> msgTypeNameRef.get().equals(desc.getName()) || msgTypeNameRef.get().equals(desc.getFullName())).findFirst(); diff --git a/src/main/java/kafdrop/util/ProtobufSchemaRegistryMessageDeserializer.java b/src/main/java/kafdrop/util/ProtobufSchemaRegistryMessageDeserializer.java index a8b1449b..1f6a4c87 100644 --- a/src/main/java/kafdrop/util/ProtobufSchemaRegistryMessageDeserializer.java +++ b/src/main/java/kafdrop/util/ProtobufSchemaRegistryMessageDeserializer.java @@ -1,10 +1,11 @@ package kafdrop.util; -import java.nio.ByteBuffer; -import java.util.HashMap; import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig; import io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer; +import java.nio.ByteBuffer; +import java.util.HashMap; + public class ProtobufSchemaRegistryMessageDeserializer implements MessageDeserializer { private final String topicName; diff --git a/src/test/java/kafdrop/AbstractIntegrationTest.java b/src/test/java/kafdrop/AbstractIntegrationTest.java index 021ad282..33e2bdbb 100644 --- a/src/test/java/kafdrop/AbstractIntegrationTest.java +++ b/src/test/java/kafdrop/AbstractIntegrationTest.java @@ -15,20 +15,20 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ContextConfiguration(initializers = AbstractIntegrationTest.Initializer.class) abstract class AbstractIntegrationTest { - static class Initializer implements ApplicationContextInitializer { - static KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka").withTag("5.4.3")); + static class Initializer implements ApplicationContextInitializer { + static KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka").withTag("5.4.3")); - public static Map getProperties() { - Startables.deepStart(List.of(kafka)).join(); - return Map.of("kafka.brokerConnect", kafka.getBootstrapServers(), "protobufdesc.directory","./src/test/resources", "protobufdesc.parseAnyProto", true); - } + public static Map getProperties() { + Startables.deepStart(List.of(kafka)).join(); + return Map.of("kafka.brokerConnect", kafka.getBootstrapServers(), "protobufdesc.directory", "./src/test/resources", "protobufdesc.parseAnyProto", true); + } - @Override - public void initialize(ConfigurableApplicationContext context) { - var env = context.getEnvironment(); - env.getPropertySources().addFirst(new MapPropertySource( - "testcontainers", getProperties() - )); - } + @Override + public void initialize(ConfigurableApplicationContext context) { + var env = context.getEnvironment(); + env.getPropertySources().addFirst(new MapPropertySource( + "testcontainers", getProperties() + )); } + } } diff --git a/src/test/java/kafdrop/KafdropIT.java b/src/test/java/kafdrop/KafdropIT.java index 73304628..0d0a1eaa 100644 --- a/src/test/java/kafdrop/KafdropIT.java +++ b/src/test/java/kafdrop/KafdropIT.java @@ -5,8 +5,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; class KafdropIT extends AbstractIntegrationTest { - @Test - void contextTest(){ - assertTrue(Initializer.kafka.isRunning()); - } + @Test + void contextTest() { + assertTrue(Initializer.kafka.isRunning()); + } } diff --git a/src/test/java/kafdrop/KafdropTest.java b/src/test/java/kafdrop/KafdropTest.java index 800f4dc4..c0388ee8 100644 --- a/src/test/java/kafdrop/KafdropTest.java +++ b/src/test/java/kafdrop/KafdropTest.java @@ -1,11 +1,5 @@ package kafdrop; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.http.HttpMethod.TRACE; -import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED; -import static org.springframework.http.HttpStatus.OK; - import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; @@ -13,10 +7,15 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit.jupiter.SpringExtension; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.springframework.http.HttpMethod.TRACE; +import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED; +import static org.springframework.http.HttpStatus.OK; + @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class KafdropTest extends AbstractIntegrationTest { @@ -38,7 +37,7 @@ public void contextLoads() throws Exception { @Test public void getReturnsExpectedGutHubStarText() throws Exception { ResponseEntity responseEntity = restTemplate - .getForEntity("http://localhost:" + port + "/", String.class); + .getForEntity("http://localhost:" + port + "/", String.class); assertEquals(OK, responseEntity.getStatusCode()); assertThat(responseEntity.getBody().contains("Star Kafdrop on GitHub")); } @@ -46,7 +45,7 @@ public void getReturnsExpectedGutHubStarText() throws Exception { @Test public void traceMethodExpectedDisallowedReturnCode() throws Exception { ResponseEntity response = restTemplate - .exchange("http://localhost:" + port + "/", TRACE, null, String.class); - assertEquals(METHOD_NOT_ALLOWED, response.getStatusCode()); + .exchange("http://localhost:" + port + "/", TRACE, null, String.class); + assertEquals(METHOD_NOT_ALLOWED, response.getStatusCode()); } } diff --git a/src/test/java/kafdrop/LocalRunner.java b/src/test/java/kafdrop/LocalRunner.java index ef0f2479..a77a90d6 100644 --- a/src/test/java/kafdrop/LocalRunner.java +++ b/src/test/java/kafdrop/LocalRunner.java @@ -5,9 +5,9 @@ * It will run local kafka in docker with test containers. */ public class LocalRunner { - public static void main(String[] args) { - Kafdrop.createApplicationBuilder() - .initializers(new AbstractIntegrationTest.Initializer()) - .run(args); - } + public static void main(String[] args) { + Kafdrop.createApplicationBuilder() + .initializers(new AbstractIntegrationTest.Initializer()) + .run(args); + } } diff --git a/src/test/java/kafdrop/SendKafkaProtoPayload.java b/src/test/java/kafdrop/SendKafkaProtoPayload.java index 44032bbb..88008052 100644 --- a/src/test/java/kafdrop/SendKafkaProtoPayload.java +++ b/src/test/java/kafdrop/SendKafkaProtoPayload.java @@ -1,39 +1,37 @@ package kafdrop; -import java.util.List; -import java.util.UUID; - +import com.google.protobuf.Any; +import kafdrop.kafka.KafkaTestConfiguration; +import kafdrop.protos.Person; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.test.context.TestComponent; import org.springframework.context.ApplicationListener; import org.springframework.kafka.core.KafkaTemplate; -import com.google.protobuf.Any; - -import kafdrop.kafka.KafkaTestConfiguration; -import kafdrop.protos.Person; +import java.util.List; +import java.util.UUID; @TestComponent public class SendKafkaProtoPayload implements ApplicationListener { - @Autowired - private KafkaTemplate kafkaTemplate; - - @Override - public void onApplicationEvent(ApplicationReadyEvent event) { - if (!AbstractIntegrationTest.Initializer.kafka.isRunning()) { - throw new IllegalStateException("Kafka container not started"); - } - - Person person = Person.newBuilder() - .setName("Max Mustermann") - .setId(1) - .setEmail("max.mustermann@example.com") - .setContact(Person.Contact.MOBILE) - .addAllData(List.of("This", "is", "a", "test")) - .build(); - byte[] payload = Any.pack(person).toByteArray(); - kafkaTemplate.send(KafkaTestConfiguration.TEST_TOPIC_NAME, UUID.randomUUID().toString(), payload); - } + @Autowired + private KafkaTemplate kafkaTemplate; + + @Override + public void onApplicationEvent(ApplicationReadyEvent event) { + if (!AbstractIntegrationTest.Initializer.kafka.isRunning()) { + throw new IllegalStateException("Kafka container not started"); + } + + Person person = Person.newBuilder() + .setName("Max Mustermann") + .setId(1) + .setEmail("max.mustermann@example.com") + .setContact(Person.Contact.MOBILE) + .addAllData(List.of("This", "is", "a", "test")) + .build(); + byte[] payload = Any.pack(person).toByteArray(); + kafkaTemplate.send(KafkaTestConfiguration.TEST_TOPIC_NAME, UUID.randomUUID().toString(), payload); + } } diff --git a/src/test/java/kafdrop/kafka/KafkaTestConfiguration.java b/src/test/java/kafdrop/kafka/KafkaTestConfiguration.java index 21d8b0b4..0cab4e27 100644 --- a/src/test/java/kafdrop/kafka/KafkaTestConfiguration.java +++ b/src/test/java/kafdrop/kafka/KafkaTestConfiguration.java @@ -1,8 +1,5 @@ package kafdrop.kafka; -import java.util.HashMap; -import java.util.Map; - import org.apache.kafka.clients.admin.AdminClientConfig; import org.apache.kafka.clients.admin.NewTopic; import org.apache.kafka.clients.producer.ProducerConfig; @@ -17,37 +14,40 @@ import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.ProducerFactory; +import java.util.HashMap; +import java.util.Map; + @TestConfiguration public class KafkaTestConfiguration { - @Value("${kafka.brokerConnect}") - private String brokerConnect; - - public static final String TEST_TOPIC_NAME = "kafdrop-test"; - - @Bean - public ProducerFactory producerFactory() { - Map config = new HashMap<>(); - config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerConnect); - config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); - config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class); - return new DefaultKafkaProducerFactory<>(config); - } - - @Bean - public KafkaTemplate kafkaTemplate() { - return new KafkaTemplate<>(producerFactory()); - } - - @Bean - public KafkaAdmin kafkaAdmin() { - Map config = new HashMap<>(); - config.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, brokerConnect); - return new KafkaAdmin(config); - } - - @Bean - public NewTopic topic() { - return TopicBuilder.name(TEST_TOPIC_NAME).build(); - } + @Value("${kafka.brokerConnect}") + private String brokerConnect; + + public static final String TEST_TOPIC_NAME = "kafdrop-test"; + + @Bean + public ProducerFactory producerFactory() { + Map config = new HashMap<>(); + config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerConnect); + config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class); + return new DefaultKafkaProducerFactory<>(config); + } + + @Bean + public KafkaTemplate kafkaTemplate() { + return new KafkaTemplate<>(producerFactory()); + } + + @Bean + public KafkaAdmin kafkaAdmin() { + Map config = new HashMap<>(); + config.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, brokerConnect); + return new KafkaAdmin(config); + } + + @Bean + public NewTopic topic() { + return TopicBuilder.name(TEST_TOPIC_NAME).build(); + } } diff --git a/src/test/java/kafdrop/model/ConsumerPartitionVOTest.java b/src/test/java/kafdrop/model/ConsumerPartitionVOTest.java index 9574f3da..e607baf4 100644 --- a/src/test/java/kafdrop/model/ConsumerPartitionVOTest.java +++ b/src/test/java/kafdrop/model/ConsumerPartitionVOTest.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; final class ConsumerPartitionVOTest { private void doLagTest(long first, long last, long offset, long expectedLag) { diff --git a/src/test/java/kafdrop/protos/Person.java b/src/test/java/kafdrop/protos/Person.java index 425d3ce3..13e3fa95 100644 --- a/src/test/java/kafdrop/protos/Person.java +++ b/src/test/java/kafdrop/protos/Person.java @@ -7,14 +7,16 @@ * Protobuf type {@code kafdrop.Person} */ public final class Person extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:kafdrop.Person) - PersonOrBuilder { -private static final long serialVersionUID = 0L; + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:kafdrop.Person) + PersonOrBuilder { + private static final long serialVersionUID = 0L; + // Use Person.newBuilder() to construct. private Person(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } + private Person() { name_ = ""; email_ = ""; @@ -25,7 +27,7 @@ private Person() { @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { + UnusedPrivateParameter unused) { return new Person(); } @@ -34,17 +36,18 @@ protected java.lang.Object newInstance( getUnknownFields() { return this.unknownFields; } + private Person( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { this(); if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); + com.google.protobuf.UnknownFieldSet.newBuilder(); try { boolean done = false; while (!done) { @@ -87,7 +90,7 @@ private Person( } default: { if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { + input, unknownFields, extensionRegistry, tag)) { done = true; } break; @@ -98,7 +101,7 @@ private Person( throw e.setUnfinishedMessage(this); } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); + e).setUnfinishedMessage(this); } finally { if (((mutable_bitField0_ & 0x00000001) != 0)) { data_ = data_.getUnmodifiableView(); @@ -107,24 +110,25 @@ private Person( makeExtensionsImmutable(); } } + public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { + getDescriptor() { return kafdrop.protos.PersonProto.internal_static_kafdrop_Person_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { + internalGetFieldAccessorTable() { return kafdrop.protos.PersonProto.internal_static_kafdrop_Person_fieldAccessorTable - .ensureFieldAccessorsInitialized( - kafdrop.protos.Person.class, kafdrop.protos.Person.Builder.class); + .ensureFieldAccessorsInitialized( + kafdrop.protos.Person.class, kafdrop.protos.Person.Builder.class); } /** * Protobuf enum {@code kafdrop.Person.Contact} */ public enum Contact - implements com.google.protobuf.ProtocolMessageEnum { + implements com.google.protobuf.ProtocolMessageEnum { /** * TELEPHONE = 0; */ @@ -149,7 +153,7 @@ public enum Contact public final int getNumber() { if (this == UNRECOGNIZED) { throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); + "Can't get the number of an unknown enum value."); } return value; } @@ -170,45 +174,51 @@ public static Contact valueOf(int value) { */ public static Contact forNumber(int value) { switch (value) { - case 0: return TELEPHONE; - case 1: return MOBILE; - default: return null; + case 0: + return TELEPHONE; + case 1: + return MOBILE; + default: + return null; } } public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { + internalGetValueMap() { return internalValueMap; } + private static final com.google.protobuf.Internal.EnumLiteMap< - Contact> internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public Contact findValueByNumber(int number) { - return Contact.forNumber(number); - } - }; + Contact> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Contact findValueByNumber(int number) { + return Contact.forNumber(number); + } + }; public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { + getValueDescriptor() { if (this == UNRECOGNIZED) { throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); + "Can't get the descriptor of an unrecognized enum value."); } return getDescriptor().getValues().get(ordinal()); } + public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { + getDescriptorForType() { return getDescriptor(); } + public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { + getDescriptor() { return kafdrop.protos.Person.getDescriptor().getEnumTypes().get(0); } private static final Contact[] VALUES = values(); public static Contact valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { if (desc.getType() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "EnumValueDescriptor is not for this type."); @@ -230,8 +240,10 @@ private Contact(int value) { public static final int NAME_FIELD_NUMBER = 1; private volatile java.lang.Object name_; + /** * string name = 1; + * * @return The name. */ @java.lang.Override @@ -240,25 +252,27 @@ public java.lang.String getName() { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); name_ = s; return s; } } + /** * string name = 1; + * * @return The bytes for name. */ @java.lang.Override public com.google.protobuf.ByteString - getNameBytes() { + getNameBytes() { java.lang.Object ref = name_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); name_ = b; return b; } else { @@ -268,8 +282,10 @@ public java.lang.String getName() { public static final int ID_FIELD_NUMBER = 2; private int id_; + /** * int32 id = 2; + * * @return The id. */ @java.lang.Override @@ -279,8 +295,10 @@ public int getId() { public static final int EMAIL_FIELD_NUMBER = 3; private volatile java.lang.Object email_; + /** * string email = 3; + * * @return The email. */ @java.lang.Override @@ -289,25 +307,27 @@ public java.lang.String getEmail() { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); email_ = s; return s; } } + /** * string email = 3; + * * @return The bytes for email. */ @java.lang.Override public com.google.protobuf.ByteString - getEmailBytes() { + getEmailBytes() { java.lang.Object ref = email_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); email_ = b; return b; } else { @@ -317,18 +337,24 @@ public java.lang.String getEmail() { public static final int CONTACT_FIELD_NUMBER = 4; private int contact_; + /** * .kafdrop.Person.Contact contact = 4; + * * @return The enum numeric value on the wire for contact. */ - @java.lang.Override public int getContactValue() { + @java.lang.Override + public int getContactValue() { return contact_; } + /** * .kafdrop.Person.Contact contact = 4; + * * @return The contact. */ - @java.lang.Override public kafdrop.protos.Person.Contact getContact() { + @java.lang.Override + public kafdrop.protos.Person.Contact getContact() { @SuppressWarnings("deprecation") kafdrop.protos.Person.Contact result = kafdrop.protos.Person.Contact.valueOf(contact_); return result == null ? kafdrop.protos.Person.Contact.UNRECOGNIZED : result; @@ -336,40 +362,49 @@ public java.lang.String getEmail() { public static final int DATA_FIELD_NUMBER = 5; private com.google.protobuf.LazyStringList data_; + /** * repeated string data = 5; + * * @return A list containing the data. */ public com.google.protobuf.ProtocolStringList - getDataList() { + getDataList() { return data_; } + /** * repeated string data = 5; + * * @return The count of data. */ public int getDataCount() { return data_.size(); } + /** * repeated string data = 5; + * * @param index The index of the element to return. * @return The data at the given index. */ public java.lang.String getData(int index) { return data_.get(index); } + /** * repeated string data = 5; + * * @param index The index of the value to return. * @return The bytes of the data at the given index. */ public com.google.protobuf.ByteString - getDataBytes(int index) { + getDataBytes(int index) { return data_.getByteString(index); } private byte memoizedIsInitialized = -1; + @java.lang.Override public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; @@ -382,7 +417,7 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { + throws java.io.IOException { if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); } @@ -437,7 +472,7 @@ public int getSerializedSize() { @java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { - return true; + return true; } if (!(obj instanceof kafdrop.protos.Person)) { return super.equals(obj); @@ -445,14 +480,14 @@ public boolean equals(final java.lang.Object obj) { kafdrop.protos.Person other = (kafdrop.protos.Person) obj; if (!getName() - .equals(other.getName())) return false; + .equals(other.getName())) return false; if (getId() - != other.getId()) return false; + != other.getId()) return false; if (!getEmail() - .equals(other.getEmail())) return false; + .equals(other.getEmail())) return false; if (contact_ != other.contact_) return false; if (!getDataList() - .equals(other.getDataList())) return false; + .equals(other.getDataList())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -482,113 +517,130 @@ public int hashCode() { } public static kafdrop.protos.Person parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } + public static kafdrop.protos.Person parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } + public static kafdrop.protos.Person parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } + public static kafdrop.protos.Person parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } + public static kafdrop.protos.Person parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { + throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } + public static kafdrop.protos.Person parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } + public static kafdrop.protos.Person parseFrom(java.io.InputStream input) - throws java.io.IOException { + throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + .parseWithIOException(PARSER, input); } + public static kafdrop.protos.Person parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + .parseWithIOException(PARSER, input, extensionRegistry); } + public static kafdrop.protos.Person parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { + throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + .parseDelimitedWithIOException(PARSER, input); } + public static kafdrop.protos.Person parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } + public static kafdrop.protos.Person parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + .parseWithIOException(PARSER, input); } + public static kafdrop.protos.Person parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + .parseWithIOException(PARSER, input, extensionRegistry); } @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } + public Builder newBuilderForType() { + return newBuilder(); + } + public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } + public static Builder newBuilder(kafdrop.protos.Person prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } + @java.lang.Override public Builder toBuilder() { return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + ? new Builder() : new Builder().mergeFrom(this); } @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } + /** * Protobuf type {@code kafdrop.Person} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:kafdrop.Person) - kafdrop.protos.PersonOrBuilder { + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:kafdrop.Person) + kafdrop.protos.PersonOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { + getDescriptor() { return kafdrop.protos.PersonProto.internal_static_kafdrop_Person_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { + internalGetFieldAccessorTable() { return kafdrop.protos.PersonProto.internal_static_kafdrop_Person_fieldAccessorTable - .ensureFieldAccessorsInitialized( - kafdrop.protos.Person.class, kafdrop.protos.Person.Builder.class); + .ensureFieldAccessorsInitialized( + kafdrop.protos.Person.class, kafdrop.protos.Person.Builder.class); } // Construct using kafdrop.protos.Person.newBuilder() @@ -597,15 +649,17 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); } + private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { + .alwaysUseFieldBuilders) { } } + @java.lang.Override public Builder clear() { super.clear(); @@ -624,7 +678,7 @@ public Builder clear() { @java.lang.Override public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { + getDescriptorForType() { return kafdrop.protos.PersonProto.internal_static_kafdrop_Person_descriptor; } @@ -663,38 +717,44 @@ public kafdrop.protos.Person buildPartial() { public Builder clone() { return super.clone(); } + @java.lang.Override public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { return super.setField(field, value); } + @java.lang.Override public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { + com.google.protobuf.Descriptors.FieldDescriptor field) { return super.clearField(field); } + @java.lang.Override public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { + com.google.protobuf.Descriptors.OneofDescriptor oneof) { return super.clearOneof(oneof); } + @java.lang.Override public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { return super.setRepeatedField(field, index, value); } + @java.lang.Override public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { return super.addRepeatedField(field, value); } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof kafdrop.protos.Person) { - return mergeFrom((kafdrop.protos.Person)other); + return mergeFrom((kafdrop.protos.Person) other); } else { super.mergeFrom(other); return this; @@ -739,9 +799,9 @@ public final boolean isInitialized() { @java.lang.Override public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { kafdrop.protos.Person parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); @@ -755,18 +815,21 @@ public Builder mergeFrom( } return this; } + private int bitField0_; private java.lang.Object name_ = ""; + /** * string name = 1; + * * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; + (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); name_ = s; return s; @@ -774,106 +837,122 @@ public java.lang.String getName() { return (java.lang.String) ref; } } + /** * string name = 1; + * * @return The bytes for name. */ public com.google.protobuf.ByteString - getNameBytes() { + getNameBytes() { java.lang.Object ref = name_; if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); name_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } + /** * string name = 1; + * * @param value The name to set. * @return This builder for chaining. */ public Builder setName( - java.lang.String value) { + java.lang.String value) { if (value == null) { - throw new NullPointerException(); - } - + throw new NullPointerException(); + } + name_ = value; onChanged(); return this; } + /** * string name = 1; + * * @return This builder for chaining. */ public Builder clearName() { - + name_ = getDefaultInstance().getName(); onChanged(); return this; } + /** * string name = 1; + * * @param value The bytes for name to set. * @return This builder for chaining. */ public Builder setNameBytes( - com.google.protobuf.ByteString value) { + com.google.protobuf.ByteString value) { if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; onChanged(); return this; } - private int id_ ; + private int id_; + /** * int32 id = 2; + * * @return The id. */ @java.lang.Override public int getId() { return id_; } + /** * int32 id = 2; + * * @param value The id to set. * @return This builder for chaining. */ public Builder setId(int value) { - + id_ = value; onChanged(); return this; } + /** * int32 id = 2; + * * @return This builder for chaining. */ public Builder clearId() { - + id_ = 0; onChanged(); return this; } private java.lang.Object email_ = ""; + /** * string email = 3; + * * @return The email. */ public java.lang.String getEmail() { java.lang.Object ref = email_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; + (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); email_ = s; return s; @@ -881,86 +960,101 @@ public java.lang.String getEmail() { return (java.lang.String) ref; } } + /** * string email = 3; + * * @return The bytes for email. */ public com.google.protobuf.ByteString - getEmailBytes() { + getEmailBytes() { java.lang.Object ref = email_; if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); email_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } + /** * string email = 3; + * * @param value The email to set. * @return This builder for chaining. */ public Builder setEmail( - java.lang.String value) { + java.lang.String value) { if (value == null) { - throw new NullPointerException(); - } - + throw new NullPointerException(); + } + email_ = value; onChanged(); return this; } + /** * string email = 3; + * * @return This builder for chaining. */ public Builder clearEmail() { - + email_ = getDefaultInstance().getEmail(); onChanged(); return this; } + /** * string email = 3; + * * @param value The bytes for email to set. * @return This builder for chaining. */ public Builder setEmailBytes( - com.google.protobuf.ByteString value) { + com.google.protobuf.ByteString value) { if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + email_ = value; onChanged(); return this; } private int contact_ = 0; + /** * .kafdrop.Person.Contact contact = 4; + * * @return The enum numeric value on the wire for contact. */ - @java.lang.Override public int getContactValue() { + @java.lang.Override + public int getContactValue() { return contact_; } + /** * .kafdrop.Person.Contact contact = 4; + * * @param value The enum numeric value on the wire for contact to set. * @return This builder for chaining. */ public Builder setContactValue(int value) { - + contact_ = value; onChanged(); return this; } + /** * .kafdrop.Person.Contact contact = 4; + * * @return The contact. */ @java.lang.Override @@ -969,8 +1063,10 @@ public kafdrop.protos.Person.Contact getContact() { kafdrop.protos.Person.Contact result = kafdrop.protos.Person.Contact.valueOf(contact_); return result == null ? kafdrop.protos.Person.Contact.UNRECOGNIZED : result; } + /** * .kafdrop.Person.Contact contact = 4; + * * @param value The contact to set. * @return This builder for chaining. */ @@ -978,107 +1074,126 @@ public Builder setContact(kafdrop.protos.Person.Contact value) { if (value == null) { throw new NullPointerException(); } - + contact_ = value.getNumber(); onChanged(); return this; } + /** * .kafdrop.Person.Contact contact = 4; + * * @return This builder for chaining. */ public Builder clearContact() { - + contact_ = 0; onChanged(); return this; } private com.google.protobuf.LazyStringList data_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureDataIsMutable() { if (!((bitField0_ & 0x00000001) != 0)) { data_ = new com.google.protobuf.LazyStringArrayList(data_); bitField0_ |= 0x00000001; - } + } } + /** * repeated string data = 5; + * * @return A list containing the data. */ public com.google.protobuf.ProtocolStringList - getDataList() { + getDataList() { return data_.getUnmodifiableView(); } + /** * repeated string data = 5; + * * @return The count of data. */ public int getDataCount() { return data_.size(); } + /** * repeated string data = 5; + * * @param index The index of the element to return. * @return The data at the given index. */ public java.lang.String getData(int index) { return data_.get(index); } + /** * repeated string data = 5; + * * @param index The index of the value to return. * @return The bytes of the data at the given index. */ public com.google.protobuf.ByteString - getDataBytes(int index) { + getDataBytes(int index) { return data_.getByteString(index); } + /** * repeated string data = 5; + * * @param index The index to set the value at. * @param value The data to set. * @return This builder for chaining. */ public Builder setData( - int index, java.lang.String value) { + int index, java.lang.String value) { if (value == null) { - throw new NullPointerException(); - } - ensureDataIsMutable(); + throw new NullPointerException(); + } + ensureDataIsMutable(); data_.set(index, value); onChanged(); return this; } + /** * repeated string data = 5; + * * @param value The data to add. * @return This builder for chaining. */ public Builder addData( - java.lang.String value) { + java.lang.String value) { if (value == null) { - throw new NullPointerException(); - } - ensureDataIsMutable(); + throw new NullPointerException(); + } + ensureDataIsMutable(); data_.add(value); onChanged(); return this; } + /** * repeated string data = 5; + * * @param values The data to add. * @return This builder for chaining. */ public Builder addAllData( - java.lang.Iterable values) { + java.lang.Iterable values) { ensureDataIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, data_); + values, data_); onChanged(); return this; } + /** * repeated string data = 5; + * * @return This builder for chaining. */ public Builder clearData() { @@ -1087,31 +1202,34 @@ public Builder clearData() { onChanged(); return this; } + /** * repeated string data = 5; + * * @param value The bytes of the data to add. * @return This builder for chaining. */ public Builder addDataBytes( - com.google.protobuf.ByteString value) { + com.google.protobuf.ByteString value) { if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); ensureDataIsMutable(); data_.add(value); onChanged(); return this; } + @java.lang.Override public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { + final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); } @java.lang.Override public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { + final com.google.protobuf.UnknownFieldSet unknownFields) { return super.mergeUnknownFields(unknownFields); } @@ -1121,6 +1239,7 @@ public final Builder mergeUnknownFields( // @@protoc_insertion_point(class_scope:kafdrop.Person) private static final kafdrop.protos.Person DEFAULT_INSTANCE; + static { DEFAULT_INSTANCE = new kafdrop.protos.Person(); } @@ -1130,12 +1249,12 @@ public static kafdrop.protos.Person getDefaultInstance() { } private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { + PARSER = new com.google.protobuf.AbstractParser() { @java.lang.Override public Person parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { return new Person(input, extensionRegistry); } }; diff --git a/src/test/java/kafdrop/protos/PersonOrBuilder.java b/src/test/java/kafdrop/protos/PersonOrBuilder.java index 13c693ea..aba5090e 100644 --- a/src/test/java/kafdrop/protos/PersonOrBuilder.java +++ b/src/test/java/kafdrop/protos/PersonOrBuilder.java @@ -4,72 +4,89 @@ package kafdrop.protos; public interface PersonOrBuilder extends - // @@protoc_insertion_point(interface_extends:kafdrop.Person) - com.google.protobuf.MessageOrBuilder { + // @@protoc_insertion_point(interface_extends:kafdrop.Person) + com.google.protobuf.MessageOrBuilder { /** * string name = 1; + * * @return The name. */ java.lang.String getName(); + /** * string name = 1; + * * @return The bytes for name. */ com.google.protobuf.ByteString - getNameBytes(); + getNameBytes(); /** * int32 id = 2; + * * @return The id. */ int getId(); /** * string email = 3; + * * @return The email. */ java.lang.String getEmail(); + /** * string email = 3; + * * @return The bytes for email. */ com.google.protobuf.ByteString - getEmailBytes(); + getEmailBytes(); /** * .kafdrop.Person.Contact contact = 4; + * * @return The enum numeric value on the wire for contact. */ int getContactValue(); + /** * .kafdrop.Person.Contact contact = 4; + * * @return The contact. */ kafdrop.protos.Person.Contact getContact(); /** * repeated string data = 5; + * * @return A list containing the data. */ java.util.List - getDataList(); + getDataList(); + /** * repeated string data = 5; + * * @return The count of data. */ int getDataCount(); + /** * repeated string data = 5; + * * @param index The index of the element to return. * @return The data at the given index. */ java.lang.String getData(int index); + /** * repeated string data = 5; + * * @param index The index of the value to return. * @return The bytes of the data at the given index. */ com.google.protobuf.ByteString - getDataBytes(int index); + getDataBytes(int index); } diff --git a/src/test/java/kafdrop/protos/PersonProto.java b/src/test/java/kafdrop/protos/PersonProto.java index e83d0a35..3154fd37 100644 --- a/src/test/java/kafdrop/protos/PersonProto.java +++ b/src/test/java/kafdrop/protos/PersonProto.java @@ -4,47 +4,52 @@ package kafdrop.protos; public final class PersonProto { - private PersonProto() {} + private PersonProto() { + } + public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { + com.google.protobuf.ExtensionRegistryLite registry) { } public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { + com.google.protobuf.ExtensionRegistry registry) { registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); + (com.google.protobuf.ExtensionRegistryLite) registry); } + static final com.google.protobuf.Descriptors.Descriptor internal_static_kafdrop_Person_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_kafdrop_Person_fieldAccessorTable; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_kafdrop_Person_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { + getDescriptor() { return descriptor; } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; + + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { java.lang.String[] descriptorData = { "\n\021PATH/person.proto\022\007kafdrop\"\217\001\n\006Person\022" + - "\014\n\004name\030\001 \001(\t\022\n\n\002id\030\002 \001(\005\022\r\n\005email\030\003 \001(\t" + - "\022(\n\007contact\030\004 \001(\0162\027.kafdrop.Person.Conta" + - "ct\022\014\n\004data\030\005 \003(\t\"$\n\007Contact\022\r\n\tTELEPHONE" + - "\020\000\022\n\n\006MOBILE\020\001B\037\n\016kafdrop.protosB\013Person" + - "ProtoP\001b\006proto3" + "\014\n\004name\030\001 \001(\t\022\n\n\002id\030\002 \001(\005\022\r\n\005email\030\003 \001(\t" + + "\022(\n\007contact\030\004 \001(\0162\027.kafdrop.Person.Conta" + + "ct\022\014\n\004data\030\005 \003(\t\"$\n\007Contact\022\r\n\tTELEPHONE" + + "\020\000\022\n\n\006MOBILE\020\001B\037\n\016kafdrop.protosB\013Person" + + "ProtoP\001b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { + new com.google.protobuf.Descriptors.FileDescriptor[]{ }); internal_static_kafdrop_Person_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_kafdrop_Person_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_kafdrop_Person_descriptor, - new java.lang.String[] { "Name", "Id", "Email", "Contact", "Data", }); + internal_static_kafdrop_Person_descriptor, + new java.lang.String[]{"Name", "Id", "Email", "Contact", "Data",}); } // @@protoc_insertion_point(outer_class_scope)