http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-build-tools/src/main/resources/ide/eclipse/DL_formatter.xml ---------------------------------------------------------------------- diff --git a/distributedlog-build-tools/src/main/resources/ide/eclipse/DL_formatter.xml b/distributedlog-build-tools/src/main/resources/ide/eclipse/DL_formatter.xml new file mode 100644 index 0000000..a73e7c4 --- /dev/null +++ b/distributedlog-build-tools/src/main/resources/ide/eclipse/DL_formatter.xml @@ -0,0 +1,310 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> + <!-- +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<profiles version="1"> +<profile kind="CodeFormatterProfile" name="'DL'" version="1"> +<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="20"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/> +<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/> +<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="2"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/> +<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/> +<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/> +<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/> +<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/> +<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/> +<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> +<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="100"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/> +<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/> +<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="true"/> +</profile> +</profiles>
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/pom.xml ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/pom.xml b/distributedlog-protocol/pom.xml index 4417d14..3adae05 100644 --- a/distributedlog-protocol/pom.xml +++ b/distributedlog-protocol/pom.xml @@ -113,6 +113,39 @@ <excludeFilterFile>${basedir}/src/main/resources/findbugsExclude.xml</excludeFilterFile> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>2.17</version> + <dependencies> + <dependency> + <groupId>com.puppycrawl.tools</groupId> + <artifactId>checkstyle</artifactId> + <version>6.19</version> + </dependency> + <dependency> + <groupId>com.twitter</groupId> + <artifactId>distributedlog-build-tools</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <configuration> + <configLocation>distributedlog/checkstyle.xml</configLocation> + <suppressionsLocation>distributedlog/suppressions.xml</suppressionsLocation> + <consoleOutput>true</consoleOutput> + <failOnViolation>true</failOnViolation> + <includeResources>false</includeResources> + <includeTestSourceDirectory>true</includeTestSourceDirectory> + </configuration> + <executions> + <execution> + <phase>test-compile</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> </project> http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/DLSN.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/DLSN.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/DLSN.java index 9e3b76c..57cc0ef 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/DLSN.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/DLSN.java @@ -17,12 +17,13 @@ */ package com.twitter.distributedlog; +import static com.google.common.base.Preconditions.checkArgument; + import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; +import java.nio.ByteBuffer; import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Hex; -import java.nio.ByteBuffer; /** * DistributedLog Sequence Number (DLSN) is the system generated sequence number for log record. @@ -46,7 +47,7 @@ public class DLSN implements Comparable<DLSN> { // The non-inclusive lower bound DLSN public static final DLSN NonInclusiveLowerBound = new DLSN(1, 0 , -1); // Invalid DLSN - public static final DLSN InvalidDLSN = new DLSN(0,-1,-1); + public static final DLSN InvalidDLSN = new DLSN(0, -1, -1); static final byte CUR_VERSION = VERSION1; static final int VERSION0_LEN = Long.SIZE * 3 + Byte.SIZE; @@ -72,14 +73,6 @@ public class DLSN implements Comparable<DLSN> { } /** - * use {@link #getLogSegmentSequenceNo()} instead - */ - @Deprecated - long getLedgerSequenceNo() { - return logSegmentSequenceNo; - } - - /** * Return the entry id of the batch that the record is written to. * * @return entry id of the batch that the record is written to. @@ -100,11 +93,11 @@ public class DLSN implements Comparable<DLSN> { @Override public int compareTo(DLSN that) { if (this.logSegmentSequenceNo != that.logSegmentSequenceNo) { - return (this.logSegmentSequenceNo < that.logSegmentSequenceNo)? -1 : 1; + return (this.logSegmentSequenceNo < that.logSegmentSequenceNo) ? -1 : 1; } else if (this.entryId != that.entryId) { - return (this.entryId < that.entryId)? -1 : 1; + return (this.entryId < that.entryId) ? -1 : 1; } else { - return (this.slotId < that.slotId)? -1 : (this.slotId == that.slotId)? 0 : 1; + return (this.slotId < that.slotId) ? -1 : (this.slotId == that.slotId) ? 0 : 1; } } @@ -125,7 +118,7 @@ public class DLSN implements Comparable<DLSN> { * @return the serialized bytes */ public byte[] serializeBytes(byte version) { - Preconditions.checkArgument(version <= CUR_VERSION && version >= VERSION0); + checkArgument(version <= CUR_VERSION && version >= VERSION0); byte[] data = new byte[CUR_VERSION == version ? VERSION1_LEN : VERSION0_LEN]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(version); @@ -208,23 +201,33 @@ public class DLSN implements Comparable<DLSN> { @Override public String toString() { - return "DLSN{" + - "logSegmentSequenceNo=" + logSegmentSequenceNo + - ", entryId=" + entryId + - ", slotId=" + slotId + - '}'; + return "DLSN{" + + "logSegmentSequenceNo=" + logSegmentSequenceNo + + ", entryId=" + entryId + + ", slotId=" + slotId + + '}'; } @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof DLSN)) return false; + if (this == o) { + return true; + } + if (!(o instanceof DLSN)) { + return false; + } DLSN dlsn = (DLSN) o; - if (entryId != dlsn.entryId) return false; - if (logSegmentSequenceNo != dlsn.logSegmentSequenceNo) return false; - if (slotId != dlsn.slotId) return false; + if (entryId != dlsn.entryId) { + return false; + } + if (logSegmentSequenceNo != dlsn.logSegmentSequenceNo) { + return false; + } + if (slotId != dlsn.slotId) { + return false; + } return true; } @@ -238,9 +241,10 @@ public class DLSN implements Comparable<DLSN> { } /** - * Positions to a DLSN greater than the current value - this may not - * correspond to an actual LogRecord, its just used by the positioning logic - * to position the reader + * Positions to a DLSN greater than the current value. + * + * <p>This may not correspond to an actual LogRecord, its just used by the positioning logic + * to position the reader. * * @return the next DLSN */ @@ -249,9 +253,10 @@ public class DLSN implements Comparable<DLSN> { } /** - * Positions to a DLSN greater than the current value - this may not - * correspond to an actual LogRecord, its just used by the positioning logic - * to position the reader + * Positions to next log segment than the current value. + * + * <p>this may not correspond to an actual LogRecord, its just used by the positioning logic + * to position the reader. * * @return the next DLSN */ http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/EnvelopedRecordSetReader.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/EnvelopedRecordSetReader.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/EnvelopedRecordSetReader.java index d3f7a99..dae8403 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/EnvelopedRecordSetReader.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/EnvelopedRecordSetReader.java @@ -17,15 +17,19 @@ */ package com.twitter.distributedlog; +import static com.twitter.distributedlog.LogRecordSet.COMPRESSION_CODEC_LZ4; +import static com.twitter.distributedlog.LogRecordSet.METADATA_COMPRESSION_MASK; +import static com.twitter.distributedlog.LogRecordSet.METADATA_VERSION_MASK; +import static com.twitter.distributedlog.LogRecordSet.NULL_OP_STATS_LOGGER; +import static com.twitter.distributedlog.LogRecordSet.VERSION; + import com.twitter.distributedlog.io.CompressionCodec; import com.twitter.distributedlog.io.CompressionUtils; - import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; -import static com.twitter.distributedlog.LogRecordSet.*; /** * Record reader to read records from an enveloped entry buffer. @@ -63,8 +67,8 @@ class EnvelopedRecordSetReader implements LogRecordSet.Reader { int metadata = src.readInt(); int version = metadata & METADATA_VERSION_MASK; if (version != VERSION) { - throw new IOException(String.format("Version mismatch while reading. Received: %d," + - " Required: %d", version, VERSION)); + throw new IOException(String.format("Version mismatch while reading. Received: %d," + + " Required: %d", version, VERSION)); } int codecCode = metadata & METADATA_COMPRESSION_MASK; this.numRecords = src.readInt(); @@ -76,7 +80,7 @@ class EnvelopedRecordSetReader implements LogRecordSet.Reader { if (COMPRESSION_CODEC_LZ4 == codecCode) { CompressionCodec codec = CompressionUtils.getCompressionCodec(CompressionCodec.Type.LZ4); byte[] decompressedData = codec.decompress(compressedData, 0, actualDataLen, - originDataLen, NullOpStatsLogger); + originDataLen, NULL_OP_STATS_LOGGER); this.reader = ByteBuffer.wrap(decompressedData); } else { if (originDataLen != actualDataLen) { http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/EnvelopedRecordSetWriter.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/EnvelopedRecordSetWriter.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/EnvelopedRecordSetWriter.java index 32b3cf4..7f64a6d 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/EnvelopedRecordSetWriter.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/EnvelopedRecordSetWriter.java @@ -17,15 +17,21 @@ */ package com.twitter.distributedlog; +import static com.twitter.distributedlog.LogRecord.MAX_LOGRECORD_SIZE; +import static com.twitter.distributedlog.LogRecordSet.COMPRESSION_CODEC_LZ4; +import static com.twitter.distributedlog.LogRecordSet.COMPRESSION_CODEC_NONE; +import static com.twitter.distributedlog.LogRecordSet.HEADER_LEN; +import static com.twitter.distributedlog.LogRecordSet.METADATA_COMPRESSION_MASK; +import static com.twitter.distributedlog.LogRecordSet.METADATA_VERSION_MASK; +import static com.twitter.distributedlog.LogRecordSet.NULL_OP_STATS_LOGGER; +import static com.twitter.distributedlog.LogRecordSet.VERSION; + +import com.twitter.distributedlog.exceptions.LogRecordTooLongException; +import com.twitter.distributedlog.exceptions.WriteException; import com.twitter.distributedlog.io.Buffer; import com.twitter.distributedlog.io.CompressionCodec; import com.twitter.distributedlog.io.CompressionUtils; -import com.twitter.distributedlog.exceptions.LogRecordTooLongException; -import com.twitter.distributedlog.exceptions.WriteException; import com.twitter.util.Promise; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.DataOutputStream; import java.io.IOException; import java.nio.ByteBuffer; @@ -33,16 +39,15 @@ import java.nio.channels.Channels; import java.nio.channels.WritableByteChannel; import java.util.LinkedList; import java.util.List; - -import static com.twitter.distributedlog.LogRecord.MAX_LOGRECORD_SIZE; -import static com.twitter.distributedlog.LogRecordSet.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * {@link Buffer} based log record set writer. */ class EnvelopedRecordSetWriter implements LogRecordSet.Writer { - static final Logger logger = LoggerFactory.getLogger(EnvelopedRecordSetWriter.class); + private static final Logger logger = LoggerFactory.getLogger(EnvelopedRecordSetWriter.class); private final Buffer buffer; private final DataOutputStream writer; @@ -158,7 +163,7 @@ class EnvelopedRecordSetWriter implements LogRecordSet.Writer { CompressionCodec compressor = CompressionUtils.getCompressionCodec(codec); byte[] compressed = - compressor.compress(data, dataOffset, dataLen, NullOpStatsLogger); + compressor.compress(data, dataOffset, dataLen, NULL_OP_STATS_LOGGER); ByteBuffer recordSetBuffer; if (compressed.length > dataLen) { http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecord.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecord.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecord.java index c104212..74df400 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecord.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecord.java @@ -17,14 +17,13 @@ */ package com.twitter.distributedlog; +import com.google.common.annotations.VisibleForTesting; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; - -import com.google.common.annotations.VisibleForTesting; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,38 +40,39 @@ import org.slf4j.LoggerFactory; * * <h3>User Record</h3> * - * User records are the records written by applications and read by applications. They + * <p>User records are the records written by applications and read by applications. They * are constructed via {@link #LogRecord(long, byte[])} by applications and appended to * logs by writers. And they would be deserialized from bytes by the readers and return * to applications. * * <h3>Control Record</h3> * - * Control records are special records that written by distributedlog. They are invisible + * <p>Control records are special records that written by distributedlog. They are invisible * to applications. They could be treated as <i>commit requests</i> as what people could find * in distributed consensus algorithms, since they are usually written by distributedlog to * commit application written records. <i>Commit</i> means making application written records * visible to readers to achieve consistent views among them. - * <p> - * They are named as 'Control Records' for controlling visibility of application written records. - * <p> - * The transaction id of 'Control Records' are assigned by distributedlog by inheriting from last + * + * <p>They are named as 'Control Records' for controlling visibility of application written records. + * + * <p>The transaction id of 'Control Records' are assigned by distributedlog by inheriting from last * written user records. So we could indicate what user records that a control record is committing * by looking at its transaction id. * * <h4>EndOfStream Record</h4> * - * <code>EoS</code>(EndOfStream) is a special control record that would be written by a writer + * <p><code>EoS</code>(EndOfStream) is a special control record that would be written by a writer * to seal a log. After a <i>EoS</i> record is written to a log, no writers could append any record * after that and readers will get {@link com.twitter.distributedlog.exceptions.EndOfStreamException} * when they reach EoS. + * * <p>TransactionID of EoS is <code>Long.MAX_VALUE</code>. * * <h3>Serialization & Deserialization</h3> * - * Data type in brackets. Interpretation should be on the basis of data types and not individual + * <p>Data type in brackets. Interpretation should be on the basis of data types and not individual * bytes to honor Endianness. - * <p> + * * <pre> * LogRecord structure: * ------------------- @@ -98,13 +98,14 @@ import org.slf4j.LoggerFactory; * * <h3>Sequence Numbers</h3> * - * A record is associated with three types of sequence numbers. They are generated + * <p>A record is associated with three types of sequence numbers. They are generated * and used for different purposes. Check {@link LogRecordWithDLSN} for more details. * * @see LogRecordWithDLSN */ public class LogRecord { - static final Logger LOG = LoggerFactory.getLogger(LogRecord.class); + + private static final Logger LOG = LoggerFactory.getLogger(LogRecord.class); // Allow 4K overhead for metadata within the max transmission size public static final int MAX_LOGRECORD_SIZE = 1024 * 1024 - 8 * 1024; //1MB - 8KB @@ -131,8 +132,8 @@ public class LogRecord { /** * Construct an uninitialized log record. - * <p> - * NOTE: only deserializer should call this constructor. + * + * <p>NOTE: only deserializer should call this constructor. */ protected LogRecord() { this.txid = 0; @@ -141,6 +142,7 @@ public class LogRecord { /** * Construct a log record with <i>TransactionId</i> and payload. + * * <p>Usually writer would construct the log record for writing. * * @param txid @@ -223,8 +225,8 @@ public class LogRecord { */ void setPositionWithinLogSegment(int positionWithinLogSegment) { assert(positionWithinLogSegment >= 0); - metadata = (metadata & LOGRECORD_METADATA_POSITION_UMASK) | - (((long) positionWithinLogSegment) << LOGRECORD_METADATA_POSITION_SHIFT); + metadata = (metadata & LOGRECORD_METADATA_POSITION_UMASK) + | (((long) positionWithinLogSegment) << LOGRECORD_METADATA_POSITION_SHIFT); } /** @@ -243,6 +245,7 @@ public class LogRecord { /** * Get the last position of this record in the log segment. + * * <p>If the record isn't record set, it would be same as {@link #getPositionWithinLogSegment()}, * otherwise, it would be {@link #getPositionWithinLogSegment()} + numRecords - 1. If the record set * version is unknown, it would be same as {@link #getPositionWithinLogSegment()}. @@ -264,6 +267,7 @@ public class LogRecord { /** * Set the record to represent a set of records. + * * <p>The bytes in this record is the serialized format of {@link LogRecordSet}. */ public void setRecordSet() { @@ -319,6 +323,7 @@ public class LogRecord { /** * Check if the record is a <code>EoS</code> mark. + * * <p><code>EoS</code> mark is a special record that writer would * add to seal a log. after <code>Eos</code> mark is written, * writers can't write any more records and readers will get @@ -356,8 +361,9 @@ public class LogRecord { } /** - * The size of the serialized log record, this is used to estimate how much will - * be be appended to the in-memory buffer + * The size of the serialized log record. + * + * <p>This is used to estimate how much will be be appended to the in-memory buffer. * * @return serialized size */ @@ -367,7 +373,7 @@ public class LogRecord { } /** - * Class for writing log records + * Writer class to write log records into an output {@code stream}. */ public static class Writer { private final DataOutputStream buf; @@ -377,7 +383,7 @@ public class LogRecord { } /** - * Write an operation to the output stream + * Write an operation to the output stream. * * @param record The operation to write * @throws IOException if an error occurs during writing. @@ -392,8 +398,7 @@ public class LogRecord { } /** - * This class is a package private class for reading log records - * from the persistent + * Reader class to read log records from an input {@code stream}. */ public static class Reader { private final RecordStream recordStream; @@ -405,9 +410,11 @@ public class LogRecord { private LogRecordWithDLSN lastRecordSkipTo = null; /** - * Construct the reader + * Construct the reader. * + * @param recordStream the record stream for generating {@code DLSN}s. * @param in The stream to read from. + * @param startSequenceId the start sequence id. */ public Reader(RecordStream recordStream, DataInputStream in, @@ -426,9 +433,9 @@ public class LogRecord { } /** - * Read an operation from the input stream. - * <p/> - * Note that the objects returned from this method may be re-used by future + * Read an log record from the input stream. + * + * <p/> Note that the objects returned from this method may be re-used by future * calls to the same method. * * @return the operation read from the stream, or null at the end of the file @@ -466,9 +473,11 @@ public class LogRecord { nextRecordInStream.readPayload(in); if (LOG.isTraceEnabled()) { if (nextRecordInStream.isControl()) { - LOG.trace("Reading {} Control DLSN {}", recordStream.getName(), nextRecordInStream.getDlsn()); + LOG.trace("Reading {} Control DLSN {}", + recordStream.getName(), nextRecordInStream.getDlsn()); } else { - LOG.trace("Reading {} Valid DLSN {}", recordStream.getName(), nextRecordInStream.getDlsn()); + LOG.trace("Reading {} Valid DLSN {}", + recordStream.getName(), nextRecordInStream.getDlsn()); } } @@ -525,7 +534,7 @@ public class LogRecord { currTxId = lastRecordSkipTo.getTransactionId(); } - if ((null != dlsn) && (recordStream.getCurrentPosition().compareTo(dlsn) >=0)) { + if ((null != dlsn) && (recordStream.getCurrentPosition().compareTo(dlsn) >= 0)) { if (LOG.isTraceEnabled()) { LOG.trace("Found position {} beyond {}", recordStream.getCurrentPosition(), dlsn); } @@ -556,7 +565,8 @@ public class LogRecord { // get the num of records to skip if (isRecordSet(flags)) { // read record set - LogRecordWithDLSN record = new LogRecordWithDLSN(recordStream.getCurrentPosition(), startSequenceId); + LogRecordWithDLSN record = + new LogRecordWithDLSN(recordStream.getCurrentPosition(), startSequenceId); record.setMetadata(flags); record.setTransactionId(currTxId); record.readPayload(in); @@ -580,7 +590,8 @@ public class LogRecord { read += bytesToRead; } if (LOG.isTraceEnabled()) { - LOG.trace("Skipped Record with TxId {} DLSN {}", currTxId, recordStream.getCurrentPosition()); + LOG.trace("Skipped Record with TxId {} DLSN {}", + currTxId, recordStream.getCurrentPosition()); } recordStream.advance(1); } http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecordSet.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecordSet.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecordSet.java index dad8e3e..52970c7 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecordSet.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecordSet.java @@ -17,20 +17,21 @@ */ package com.twitter.distributedlog; -import com.google.common.base.Preconditions; +import static com.google.common.base.Preconditions.checkArgument; + import com.twitter.distributedlog.exceptions.LogRecordTooLongException; import com.twitter.distributedlog.exceptions.WriteException; import com.twitter.distributedlog.io.CompressionCodec; import com.twitter.util.Promise; -import org.apache.bookkeeper.stats.NullStatsLogger; -import org.apache.bookkeeper.stats.OpStatsLogger; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.ByteBuffer; +import org.apache.bookkeeper.stats.NullStatsLogger; +import org.apache.bookkeeper.stats.OpStatsLogger; /** * A set of {@link LogRecord}s. + * * <pre> * Structure: * Bytes 0 - 4 : Metadata (version + flags) @@ -56,7 +57,7 @@ import java.nio.ByteBuffer; */ public class LogRecordSet { - static final OpStatsLogger NullOpStatsLogger = + static final OpStatsLogger NULL_OP_STATS_LOGGER = NullStatsLogger.INSTANCE.getOpStatsLogger(""); public static final int HEADER_LEN = @@ -77,7 +78,7 @@ public class LogRecordSet { static final int COMPRESSION_CODEC_LZ4 = 0X1; public static int numRecords(LogRecord record) throws IOException { - Preconditions.checkArgument(record.isRecordSet(), + checkArgument(record.isRecordSet(), "record is not a recordset"); byte[] data = record.getPayload(); return numRecords(data); @@ -88,8 +89,8 @@ public class LogRecordSet { int metadata = buffer.getInt(); int version = (metadata & METADATA_VERSION_MASK); if (version != VERSION) { - throw new IOException(String.format("Version mismatch while reading. Received: %d," + - " Required: %d", version, VERSION)); + throw new IOException(String.format("Version mismatch while reading. Received: %d," + + " Required: %d", version, VERSION)); } return buffer.getInt(); } @@ -100,7 +101,7 @@ public class LogRecordSet { } public static Reader of(LogRecordWithDLSN record) throws IOException { - Preconditions.checkArgument(record.isRecordSet(), + checkArgument(record.isRecordSet(), "record is not a recordset"); byte[] data = record.getPayload(); DLSN dlsn = record.getDlsn(); @@ -120,7 +121,7 @@ public class LogRecordSet { /** * Writer to append {@link LogRecord}s to {@link LogRecordSet}. */ - public static interface Writer extends LogRecordSetBuffer { + public interface Writer extends LogRecordSetBuffer { /** * Write a {@link LogRecord} to this record set. @@ -140,7 +141,7 @@ public class LogRecordSet { /** * Reader to read {@link LogRecord}s from this record set. */ - public static interface Reader { + public interface Reader { /** * Read next log record from this record set. http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecordWithDLSN.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecordWithDLSN.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecordWithDLSN.java index 521e452..14c8e76 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecordWithDLSN.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/LogRecordWithDLSN.java @@ -24,7 +24,7 @@ import com.google.common.annotations.VisibleForTesting; * * <h3>Sequence Numbers</h3> * - * A log record will be assigned with an unique system generated sequence number {@link DLSN} when it is + * <p>A log record will be assigned with an unique system generated sequence number {@link DLSN} when it is * written to a log. At the mean time, a 64-bits long number is assigned to the record indicates its position * within a log, which is called <code>SequenceId</code>. Besides {@link DLSN} and <code>SequenceID</code>, * application can assign its own sequence number (called <code>TransactionID</code>) to the log record while @@ -32,7 +32,7 @@ import com.google.common.annotations.VisibleForTesting; * * <h4>Transaction ID</h4> * - * Transaction ID is a positive 64-bits long number that is assigned by the application. It is a very helpful + * <p>Transaction ID is a positive 64-bits long number that is assigned by the application. It is a very helpful * field when application wants to organize the records and position the readers using their own sequencing method. * A typical use case of <code>TransactionID</code> is DistributedLog Write Proxy. It assigns the non-decreasing * timestamps to log records, which the timestamps could be used as `physical time` to implement `TTL` in a strong @@ -40,14 +40,14 @@ import com.google.common.annotations.VisibleForTesting; * * <h4>DLSN</h4> * - * DistributedLog Sequence Number (<i>DLSN</i>) is the sequence number generated during written time. It is comparable - * and could be used to figure out the order between records. The DLSN is comprised with 3 components. They are - * <i>Log Segment Sequence Number</i>, <i>Entry Id</i> and <i>Slot Id</i>. (See {@link DLSN} for more details). + * <p>DistributedLog Sequence Number (<i>DLSN</i>) is the sequence number generated during written time. + * It is comparable and could be used to figure out the order between records. The DLSN is comprised with 3 components. + * They are <i>Log Segment Sequence Number</i>, <i>Entry Id</i> and <i>Slot Id</i>. (See {@link DLSN} for more details). * The DLSN is usually used for comparison, positioning and truncation. * * <h4>Sequence ID</h4> * - * Sequence ID is introduced to address the drawback of <code>DLSN</code>, in favor of answering questions like + * <p>Sequence ID is introduced to address the drawback of <code>DLSN</code>, in favor of answering questions like * `how many records written between two DLSNs`. It is a 64-bits monotonic increasing number (starting from zero). * Sequence ids are only accessible by readers. That means writers don't know the sequence ids of records after they * wrote them. @@ -96,12 +96,12 @@ public class LogRecordWithDLSN extends LogRecord { @Override public String toString() { - return "LogRecordWithDLSN{" + - "dlsn=" + dlsn + - ", txid=" + getTransactionId() + - ", position=" + getPositionWithinLogSegment() + - ", isControl=" + isControl() + - ", isEndOfStream=" + isEndOfStream() + - '}'; + return "LogRecordWithDLSN{" + + "dlsn=" + dlsn + + ", txid=" + getTransactionId() + + ", position=" + getPositionWithinLogSegment() + + ", isControl=" + isControl() + + ", isEndOfStream=" + isEndOfStream() + + '}'; } } http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/RecordStream.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/RecordStream.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/RecordStream.java index a2b5537..d920ea1 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/RecordStream.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/RecordStream.java @@ -18,7 +18,7 @@ package com.twitter.distributedlog; /** - * Stream of records + * A iterator to iterate records in the stream. */ public interface RecordStream { /** @@ -27,14 +27,14 @@ public interface RecordStream { void advance(int numRecords); /** - * Get postion of current record in the stream + * Get position of current record in the stream. * * @return position of current record */ DLSN getCurrentPosition(); /** - * Get the name of the stream + * Get the name of the stream. * * @return the name of the stream */ http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/annotations/DistributedLogAnnotations.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/annotations/DistributedLogAnnotations.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/annotations/DistributedLogAnnotations.java index d2d19b2..2859008 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/annotations/DistributedLogAnnotations.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/annotations/DistributedLogAnnotations.java @@ -17,6 +17,9 @@ */ package com.twitter.distributedlog.annotations; +/** + * Common annotation types. + */ public class DistributedLogAnnotations { /** * Annotation to identify flaky tests in DistributedLog. http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/annotations/package-info.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/annotations/package-info.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/annotations/package-info.java new file mode 100644 index 0000000..24bb36b --- /dev/null +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/annotations/package-info.java @@ -0,0 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines annotations used across distributedlog project. + */ +package com.twitter.distributedlog.annotations; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/AlreadyClosedException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/AlreadyClosedException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/AlreadyClosedException.java index f8bb7b8..abbce5f 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/AlreadyClosedException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/AlreadyClosedException.java @@ -17,12 +17,12 @@ */ package com.twitter.distributedlog.exceptions; -import com.twitter.distributedlog.exceptions.DLException; import com.twitter.distributedlog.thrift.service.StatusCode; /** - * Thrown when the distributed log manager has already been closed - * (connections have been torn down) + * Thrown when any distributedlog resources have already been closed. + * + * <p>For example, it might be thrown when the connections have been torn down. */ public class AlreadyClosedException extends DLException { http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/AlreadyTruncatedTransactionException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/AlreadyTruncatedTransactionException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/AlreadyTruncatedTransactionException.java index fa3fb4b..788b4d8 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/AlreadyTruncatedTransactionException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/AlreadyTruncatedTransactionException.java @@ -17,12 +17,10 @@ */ package com.twitter.distributedlog.exceptions; -import com.twitter.distributedlog.exceptions.DLException; import com.twitter.distributedlog.thrift.service.StatusCode; /** - * Thrown when the transaction Id specified in the API is in the range that has already been - * truncated + * Thrown when the transaction Id specified in the API is in the range that has already been truncated. */ public class AlreadyTruncatedTransactionException extends DLException { http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/BKTransmitException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/BKTransmitException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/BKTransmitException.java index 158ce31..8f29628 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/BKTransmitException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/BKTransmitException.java @@ -17,12 +17,12 @@ */ package com.twitter.distributedlog.exceptions; -import com.twitter.distributedlog.exceptions.DLException; import com.twitter.distributedlog.thrift.service.StatusCode; /** - * Thrown when the send to bookkeeper fails - * This is thrown by the next attempt to write, send or flush + * Thrown when the send to bookkeeper fails. + * + * <p>This is thrown by the next attempt to write, send or flush */ public class BKTransmitException extends DLException { http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/ChecksumFailedException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/ChecksumFailedException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/ChecksumFailedException.java index 111dff6..4b67299 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/ChecksumFailedException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/ChecksumFailedException.java @@ -19,6 +19,9 @@ package com.twitter.distributedlog.exceptions; import com.twitter.distributedlog.thrift.service.StatusCode; +/** + * Exception thrown when checksum failures occurred. + */ public class ChecksumFailedException extends DLException { private static final long serialVersionUID = 288438128880378812L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLClientClosedException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLClientClosedException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLClientClosedException.java index 6c947c2..2f506ba 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLClientClosedException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLClientClosedException.java @@ -19,6 +19,9 @@ package com.twitter.distributedlog.exceptions; import com.twitter.distributedlog.thrift.service.StatusCode; +/** + * Exceptions thrown when a distributedlog client is closed. + */ public class DLClientClosedException extends DLException { private static final long serialVersionUID = -8876218750540927584L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLException.java index 1e654bf..23af0c5 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLException.java @@ -19,9 +19,11 @@ package com.twitter.distributedlog.exceptions; import com.twitter.distributedlog.thrift.service.ResponseHeader; import com.twitter.distributedlog.thrift.service.StatusCode; - import java.io.IOException; +/** + * The basic exception of all distributedlog exceptions. + */ public class DLException extends IOException { private static final long serialVersionUID = -4485775468586114393L; protected final StatusCode code; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLIllegalStateException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLIllegalStateException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLIllegalStateException.java index 78e5e9c..c80b9db 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLIllegalStateException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/DLIllegalStateException.java @@ -19,6 +19,9 @@ package com.twitter.distributedlog.exceptions; import com.twitter.distributedlog.thrift.service.StatusCode; +/** + * Signals that a method has been invoked at an illegal or inappropriate time. + */ public class DLIllegalStateException extends DLException { private static final long serialVersionUID = -6721471104777747420L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/EndOfStreamException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/EndOfStreamException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/EndOfStreamException.java index 663b18b..a62e629 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/EndOfStreamException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/EndOfStreamException.java @@ -19,6 +19,9 @@ package com.twitter.distributedlog.exceptions; import com.twitter.distributedlog.thrift.service.StatusCode; +/** + * Exception thrown when a reader reaches end of a sealed log stream. + */ public class EndOfStreamException extends DLException { private static final long serialVersionUID = -6398949401860680263L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/FlushException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/FlushException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/FlushException.java index 331de00..f984b6c 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/FlushException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/FlushException.java @@ -17,9 +17,11 @@ */ package com.twitter.distributedlog.exceptions; -import com.twitter.distributedlog.exceptions.DLException; import com.twitter.distributedlog.thrift.service.StatusCode; +/** + * Exception indicates that errors occurred on flushing data. + */ public class FlushException extends DLException { private final long lastTxIdWritten; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/IdleReaderException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/IdleReaderException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/IdleReaderException.java index 475606f..1f6923a 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/IdleReaderException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/IdleReaderException.java @@ -19,6 +19,11 @@ package com.twitter.distributedlog.exceptions; import java.io.IOException; +/** + * An exception is thrown when a log reader becomes idle. + * + * <p>A log reader can become idle when there is no records written to the stream. + */ public class IdleReaderException extends IOException { private static final long serialVersionUID = 4882278671396434834L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InternalServerException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InternalServerException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InternalServerException.java index 4b46396..2aea152 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InternalServerException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InternalServerException.java @@ -19,6 +19,9 @@ package com.twitter.distributedlog.exceptions; import com.twitter.distributedlog.thrift.service.StatusCode; +/** + * Exception indicates that there is an internal error at distributedlog service side. + */ public class InternalServerException extends DLException { private static final long serialVersionUID = 288438028880978802L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InvalidEnvelopedEntryException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InvalidEnvelopedEntryException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InvalidEnvelopedEntryException.java index fdc50c1..09e146c 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InvalidEnvelopedEntryException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InvalidEnvelopedEntryException.java @@ -20,7 +20,7 @@ package com.twitter.distributedlog.exceptions; import com.twitter.distributedlog.thrift.service.StatusCode; /** - * Exception thrown when encounter invalid enveloped entry + * Exception thrown when encounter invalid enveloped entry. */ public class InvalidEnvelopedEntryException extends DLException { http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InvalidStreamNameException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InvalidStreamNameException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InvalidStreamNameException.java index a7d9202..1e8f445 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InvalidStreamNameException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/InvalidStreamNameException.java @@ -19,6 +19,9 @@ package com.twitter.distributedlog.exceptions; import com.twitter.distributedlog.thrift.service.StatusCode; +/** + * Exception is thrown when encountered invalid log stream. + */ public class InvalidStreamNameException extends DLException { private static final long serialVersionUID = 6393315766140568100L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LockCancelledException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LockCancelledException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LockCancelledException.java index 65e8692..98131ee 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LockCancelledException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LockCancelledException.java @@ -17,6 +17,9 @@ */ package com.twitter.distributedlog.exceptions; +/** + * A lock is cancelled when waiting for locking a stream. + */ public class LockCancelledException extends LockingException { private static final long serialVersionUID = -148795017092861106L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LockingException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LockingException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LockingException.java index 92ff8d6..326a1cd 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LockingException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LockingException.java @@ -17,9 +17,11 @@ */ package com.twitter.distributedlog.exceptions; -import com.twitter.distributedlog.exceptions.DLException; import com.twitter.distributedlog.thrift.service.StatusCode; +/** + * Exception when a log writer attempts to acquire a lock to write data to the stream. + */ public class LockingException extends DLException { private static final long serialVersionUID = -4960278188448464473L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogEmptyException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogEmptyException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogEmptyException.java index 84813c1..7dcd644 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogEmptyException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogEmptyException.java @@ -17,9 +17,11 @@ */ package com.twitter.distributedlog.exceptions; -import com.twitter.distributedlog.exceptions.DLException; import com.twitter.distributedlog.thrift.service.StatusCode; +/** + * Exceptions are thrown when attempt to read a log stream that doesn't have any records. + */ public class LogEmptyException extends DLException { private static final long serialVersionUID = -1106184127178002282L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogExistsException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogExistsException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogExistsException.java index 84ac10e..e7a0d6d 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogExistsException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogExistsException.java @@ -20,7 +20,7 @@ package com.twitter.distributedlog.exceptions; import com.twitter.distributedlog.thrift.service.StatusCode; /** - * Log Already Exists + * Exception thrown on creating a log stream but the log stream already exists. */ public class LogExistsException extends DLException { private static final long serialVersionUID = 1794053581673506784L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogNotFoundException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogNotFoundException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogNotFoundException.java index 5fc8438..e2c93e8 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogNotFoundException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogNotFoundException.java @@ -17,9 +17,11 @@ */ package com.twitter.distributedlog.exceptions; -import com.twitter.distributedlog.exceptions.DLException; import com.twitter.distributedlog.thrift.service.StatusCode; +/** + * Exception is thrown when a reader attempts to read a log stream that doesn't exist. + */ public class LogNotFoundException extends DLException { private static final long serialVersionUID = 871435700699403164L; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/3bd16202/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogReadException.java ---------------------------------------------------------------------- diff --git a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogReadException.java b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogReadException.java index a4c346b..6b08f53 100644 --- a/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogReadException.java +++ b/distributedlog-protocol/src/main/java/com/twitter/distributedlog/exceptions/LogReadException.java @@ -17,7 +17,6 @@ */ package com.twitter.distributedlog.exceptions; -import com.twitter.distributedlog.exceptions.DLException; import com.twitter.distributedlog.thrift.service.StatusCode; /**
