initial commit

This commit is contained in:
jianfei 2021-11-08 12:32:49 +08:00 committed by LIXxiansheng
commit 3470a40947
273 changed files with 42921 additions and 0 deletions

87
.gitignore vendored Normal file
View File

@ -0,0 +1,87 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
# Editor Files #
################
*~
*.swp
# Gradle Files #
################
.gradle
.m2
# Build output directies
target/
/target
*/target
/build
*/build
.repository
#
# # IntelliJ specific files/directories
# IntelliJ specific files/directories
out
.idea
*.ipr
*.iws
*.iml
atlassian-ide-plugin.xml
# Eclipse specific files/directories
.classpath
.project
.settings
.metadata
# NetBeans specific files/directories
.nbattrs
# Backup
bak/
*.bak
# Temporary
null/
tmp/
# Test
coverage-report
coverage.ser
test-output
*.pmd
# Logs
*.log.*

View File

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<!--module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module-->
<module name="TreeWalker">
<property name="cacheFile" value="${checkstyle.cache.file}"/>
<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<!--<module name="AvoidStarImport"/>-->
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
</module>
</module>

View File

@ -0,0 +1,278 @@
<profiles version="11">
<profile kind="CodeFormatterProfile" name="Alipay Convention" version="11">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="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="false"/>
<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="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="18"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="84"/>
<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.5"/>
<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="false"/>
<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="20"/>
<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="true"/>
<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="20"/>
<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.insert_new_line_in_empty_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="100"/>
<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.indentation.size" value="4"/>
<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="18"/>
<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_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="18"/>
<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_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_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<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="true"/>
<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.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.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.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_after_comma_in_superinterfaces" 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_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_after_opening_paren_in_if" 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.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="18"/>
<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.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="20"/>
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.5"/>
<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="20"/>
<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="18"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="18"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
<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.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="18"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
<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="18"/>
<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="18"/>
<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="18"/>
<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.5"/>
<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.insert_new_line_after_annotation_on_member" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
<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="2"/>
<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_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="false"/>
</profile>
</profiles>

View File

@ -0,0 +1,332 @@
<?xml version="1.0"?>
<ruleset name="alipay-pmd" xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<exclude-pattern>.*/test/.*</exclude-pattern>
<exclude-pattern>.*/dal/.*</exclude-pattern>
<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl">
<priority>3</priority>
</rule>
<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE">
<priority>3</priority>
</rule>
<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException">
<priority>3</priority>
</rule>
<rule ref="rulesets/strictexception.xml/AvoidRethrowingException">
<priority>3</priority>
</rule>
<rule ref="rulesets/strictexception.xml/AvoidThrowingNewInstanceOfSameException">
<priority>3</priority>
</rule>
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField">
<priority>2</priority>
</rule>
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable">
<priority>2</priority>
</rule>
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod">
<priority>2</priority>
</rule>
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter">
<priority>2</priority>
</rule>
<rule ref="rulesets/basic.xml/EmptyCatchBlock">
<priority>2</priority>
<properties>
<property name="allowCommentedBlocks"
description="Empty blocks containing comments will be skipped">
<value>true</value>
</property>
</properties>
</rule>
<rule ref="rulesets/braces.xml"/>
<rule ref="rulesets/design.xml/SimplifyBooleanReturns">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/SimplifyBooleanExpressions">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/SwitchDensity">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/CloseResource">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/NonStaticInitializer">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt">
<priority>1</priority>
</rule>
<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/OptimizableToArrayCall">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/BadComparison">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/EqualsNull">
<priority>1</priority>
</rule>
<rule ref="rulesets/design.xml/InstantiationToGetClass">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/IdempotentOperations">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/ImmutableField">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass">
<priority>2</priority>
</rule>
<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/SimplifyConditional">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/NonThreadSafeSingleton">
<priority>1</priority>
</rule>
<rule ref="rulesets/design.xml/AvoidConstantsInterface">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/UnsynchronizedStaticDateFormatter">
<priority>1</priority>
</rule>
<rule ref="rulesets/design.xml/PreserveStackTrace">
<priority>3</priority>
</rule>
<rule ref="rulesets/design.xml/UseCollectionIsEmpty">
<priority>4</priority>
</rule>
<rule
ref="rulesets/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal">
<priority>4</priority>
</rule>
<rule ref="rulesets/design.xml/SingularField">
<priority>3</priority>
</rule>
<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal">
<priority>3</priority>
</rule>
<rule ref="rulesets/logging-java.xml/SystemPrintln">
<priority>1</priority>
</rule>
<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace">
<priority>1</priority>
</rule>
<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging">
<priority>3</priority>
</rule>
<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger">
<priority>3</priority>
</rule>
<rule ref="rulesets/controversial.xml/UnnecessaryConstructor">
<priority>3</priority>
</rule>
<rule ref="rulesets/controversial.xml/NullAssignment">
<priority>3</priority>
</rule>
<rule ref="rulesets/basic.xml/EmptyIfStmt">
<priority>2</priority>
</rule>
<rule ref="rulesets/basic.xml/EmptyWhileStmt">
<priority>2</priority>
</rule>
<rule ref="rulesets/basic.xml/EmptyTryBlock">
<priority>2</priority>
</rule>
<rule ref="rulesets/basic.xml/EmptyFinallyBlock">
<priority>2</priority>
</rule>
<rule ref="rulesets/basic.xml/EmptySwitchStatements">
<priority>2</priority>
</rule>
<rule ref="rulesets/basic.xml/JumbledIncrementer">
<priority>3</priority>
</rule>
<rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop">
<priority>3</priority>
</rule>
<rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary">
<priority>3</priority>
</rule>
<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode">
<priority>3</priority>
</rule>
<rule ref="rulesets/basic.xml/DoubleCheckedLocking">
<priority>4</priority>
</rule>
<rule ref="rulesets/basic.xml/ReturnFromFinallyBlock">
<priority>1</priority>
</rule>
<rule ref="rulesets/basic.xml/EmptySynchronizedBlock">
<priority>2</priority>
</rule>
<rule ref="rulesets/basic.xml/UnnecessaryReturn">
<priority>3</priority>
</rule>
<rule ref="rulesets/basic.xml/EmptyStaticInitializer">
<priority>2</priority>
</rule>
<rule ref="rulesets/basic.xml/UnconditionalIfStatement">
<priority>1</priority>
</rule>
<rule ref="rulesets/basic.xml/EmptyStatementNotInLoop">
<priority>2</priority>
</rule>
<rule ref="rulesets/basic.xml/BooleanInstantiation">
<priority>3</priority>
</rule>
<rule ref="rulesets/basic.xml/UnnecessaryFinalModifier">
<priority>4</priority>
</rule>
<rule ref="rulesets/basic.xml/CollapsibleIfStatements">
<priority>4</priority>
</rule>
<rule ref="rulesets/basic.xml/UselessOverridingMethod">
<priority>4</priority>
</rule>
<rule ref="rulesets/basic.xml/ClassCastExceptionWithToArray">
<priority>1</priority>
</rule>
<rule ref="rulesets/basic.xml/UnusedNullCheckInEquals">
<priority>3</priority>
</rule>
<rule ref="rulesets/basic.xml/BrokenNullCheck">
<priority>1</priority>
</rule>
<rule ref="rulesets/basic.xml/BigIntegerInstantiation">
<priority>3</priority>
</rule>
<rule ref="rulesets/basic.xml/AvoidMultipleUnaryOperators">
<priority>4</priority>
</rule>
<rule ref="rulesets/basic.xml/EmptyInitializer">
<priority>2</priority>
</rule>
<rule ref="rulesets/strings.xml/StringInstantiation">
<priority>3</priority>
</rule>
<rule ref="rulesets/strings.xml/StringToString">
<priority>3</priority>
</rule>
<rule ref="rulesets/strings.xml/InefficientStringBuffering">
<priority>4</priority>
</rule>
<rule ref="rulesets/strings.xml/UnnecessaryCaseChange">
<priority>3</priority>
</rule>
<rule ref="rulesets/strings.xml/UseStringBufferLength">
<priority>4</priority>
</rule>
<rule ref="rulesets/strings.xml/ConsecutiveLiteralAppends">
<priority>3</priority>
</rule>
<rule ref="rulesets/strings.xml/UseIndexOfChar">
<priority>3</priority>
</rule>
<rule ref="rulesets/strings.xml/InefficientEmptyStringCheck">
<priority>3</priority>
</rule>
<rule ref="rulesets/strings.xml/InsufficientStringBufferDeclaration">
<priority>3</priority>
</rule>
<rule ref="rulesets/strings.xml/UselessStringValueOf">
<priority>3</priority>
</rule>
<rule ref="rulesets/strings.xml/UseEqualsToCompareStrings">
<priority>1</priority>
</rule>
<rule ref="rulesets/design.xml/MissingBreakInSwitch">
<priority>3</priority>
</rule>
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties>
<property name="reportLevel" value="10"/>
</properties>
</rule>
<!-- alipay rules -->
<rule ref="rulesets/alipay-ruleset.xml/AvoidLoggerExceptionAsString">
<priority>1</priority>
</rule>
<rule ref="rulesets/alipay-ruleset.xml/DontUsealibabaEnumeration">
<priority>3</priority>
</rule>
<rule ref="rulesets/alipay-ruleset.xml/DontImportSun">
<priority>3</priority>
</rule>
<rule ref="rulesets/alipay-ruleset.xml/AlipayLogRule">
<priority>1</priority>
</rule>
<rule ref="rulesets/alipay-ruleset.xml/AlipayUnusedImportsRule">
<priority>2</priority>
</rule>
<rule ref="rulesets/alipay-ruleset.xml/AlipayHardCodeIPRule">
<priority>3</priority>
</rule>
<rule ref="rulesets/alipay-ruleset.xml/AlipayHardCodeAccountRule">
<priority>3</priority>
</rule>
<rule ref="rulesets/alipay-ruleset.xml/DontImportApacheAntDateUtil">
<priority>2</priority>
</rule>
<rule ref="rulesets/alipay-ruleset.xml/IPayDateUtilRule">
<priority>2</priority>
</rule>
</ruleset>

45
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,45 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity, and expression, level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at info@oceanbase.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality about the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4.
For answers to common questions about this code of conduct, see [FAQ](https://www.contributor-covenant.org/faq).

94
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,94 @@
# How to contribute
OBKV Table Client is a community-driven open source project and we welcome all the contributors. Contributions to the ODP project are expected to adhere to our [Code of Conduct](CODE_OF_CONDUCT.md).
## Before you contribute
Before you contribute, please click the **Sign in with Gitub to agree button** to sign the CLA. You can find an example [here](link TODO).
What is [CLA](https://en.wikipedia.org/wiki/Contributor_License_Agreement)?
## Contribution guide
Please follow these steps to create your Pull Request to this repository.
> **Note:**
>
> This section takes creating a PR to the `master` branch as an example. The steps of creating PRs for other branches are similar.
### Step 1: Fork the repository
1. Visit the project (link TODO)
2. Click the **Fork** button to establish an online fork.
### Step 2: Clone your fork to local
```bash
# Define your working directory
working_dir=$HOME/Workspace
# Configure GitHub
user={your Github profile name}
# Create your clone
mkdir -p $working_dir
cd $working_dir
git clone link TODO
# Add upstream
git remote add upstream link TODO
# Set no push for the upstream master
git remote set-url --push upstream no_push
# Confirm your remote setting
git remote -v
```
### Step 3: Create a new branch
1. Get your local master up-to-date with the upstream/master.
```bash
cd $working_dir/docs
git fetch upstream
git checkout master
git rebase upstream/master
```
2. Create a new branch based on the master branch.
```bash
git checkout -b new-branch-name
```
### Step 4: Develop
Edit some file(s) on the `new-branch-name` branch and save your changes.
### Step 5: Commit your changes
```bash
git status # Checks the local status
git add <file> ... # Adds the file(s) you want to commit. If you want to commit all changes, you can directly use `git add.`
git commit -m "commit-message: update the xx"
```
### Step 6: Keep your branch in sync with upstream/master
```bash
# While on your new branch
git fetch upstream
git rebase upstream/master
```
### Step 7: Push your changes to the remote
```bash
git push -u origin new-branch-name # "-u" is used to track the remote branch from the origin
```
### Step 8: Create a pull request
1. Visit your fork at <https://github.com/$user/docs> (replace `$user` with your GitHub account).
2. Click the `Compare & pull request` button next to your `new-branch-name` branch to create your PR.

7
LEGAL.md Normal file
View File

@ -0,0 +1,7 @@
Legal Disclaimer
Within this source code, the comments in Chinese shall be the original, governing version. Any comment in other languages are for reference only. In the event of any conflict between the Chinese language version comments and other language version comments, the Chinese language version shall prevail.
法律免责声明
关于代码注释部分,中文注释为官方版本,其它语言注释仅做参考。中文注释可能与其它语言注释存在不一致,当中文注释与其它语言注释存在不一致时,请以中文注释为准。

87
LICENSE Normal file
View File

@ -0,0 +1,87 @@
木兰宽松许可证, 第2版
2020年1月 http://license.coscl.org.cn/MulanPSL2
您对“软件”的复制、使用、修改及分发受木兰宽松许可证第2版“本许可证”的如下条款的约束
0. 定义
“软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
“贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
“贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
“法人实体” 是指提交贡献的机构及其“关联实体”。
“关联实体” 是指对“本许可证”下的行为方而言控制、受控制或与其共同受控制的机构此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
1. 授予版权许可
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
2. 授予专利许可
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
3. 无商标许可
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可但您为满足第4条规定的声明义务而必须使用除外。
4. 分发限制
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
5. 免责声明与责任限制
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
6. 语言
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
条款结束
Mulan Permissive Software LicenseVersion 2 (Mulan PSL v2)
January 2020 http://license.coscl.org.cn/MulanPSL2
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
0. Definition
Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
Contribution means the copyrightable work licensed by a particular Contributor under this License.
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
Legal Entity means the entity making a Contribution and all its Affiliates.
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, control means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
1. Grant of Copyright License
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
2. Grant of Patent License
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
3. No Trademark License
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4.
4. Distribution Restriction
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
5. Disclaimer of Warranty and Limitation of Liability
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW ITS CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
6. Language
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
END OF THE TERMS AND CONDITIONS

79
README.md Normal file
View File

@ -0,0 +1,79 @@
# OBKV Table Client
OBKV Table Client is Java Library that can be used to access table data from [OceanBase](https://github.com/oceanbase/oceanbase) storage layer. Its access method is different from JDBC, it skips the SQL parsing layer, so it has significant performance advantage.
## Quick start
Create table in the OceanBase database:
``` sql
CREATE TABLE IF NOT EXISTS `test_varchar_table` (
`c1` varchar(20) NOT NULL,
`c2` varchar(20) DEFAULT NULL,
PRIMARY KEY (`c1`)
);
```
Import the dependency for your maven project:
``` xml
<dependency>
<groupId>com.oceanbase</groupId>
<artifactId>obkv-table-client</artifactId>
<version>0.1.0</version>
</dependency>
```
The code demo:
``` java
// 1. initail ObTableClient
ObTableClient obTableClient = new ObTableClient();
obTableClient.setFullUserName("full_user_name");
obTableClient.setParamURL("param_url");
obTableClient.setPassword("password");
obTableClient.setSysUserName("sys_user_name");
obTableClient.setEncSysPassword("sys_sys_password");
client.init();
// 2. single execute
// return affectedRows
client.insert("test_varchar_table", "foo", new String[] { "c2" }, new String[] { "bar" });
// return Map<String, Object>
client.get("test_varchar_table", "foo", new String[] { "c2" });
// return affectedRows
client.delete("test_varchar_table", "foo");
// 3. batch execute
TableBatchOps batchOps = client.batch("test_varchar_table");
batchOps.insert("foo", new String[] { "c2" }, new String[] { "bar" });
batchOps.get("foo", new String[] { "c2" });
batchOps.delete("foo");
List<Object> results = batchOps.execute();
// the results include 3 item: 1. affectedRows; 2. Map; 3. affectedRows.
```
**NOTE:**
param_url is generated by ConfigServer (link TODO).
## Documentation
- English [link TODO]
- Simplified Chinese (简体中文) [link TODO]
## Licencing
OBKV Table Client is under [MulanPSL - 2.0](http://license.coscl.org.cn/MulanPSL2) licence. You can freely copy and use the source code. When you modify or distribute the source code, please obey the MulanPSL - 2.0 licence.
## Contributing
Contributions are warmly welcomed and greatly appreciated. Here are a few ways you can contribute:
- Raise us an issue [link TODO].
- Submit Pull Requests. For details, see [How to contribute](CONTRIBUTING.md).
## Support
In case you have any problems when using OceanBase Database, welcome reach out for help:
- GitHub Issue [link TODO]
- Official forum [link TODO]
- Knowledge base [link TODO]

BIN
core-0.12.0.jar Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
mulan_psl2=mulan_psl2

View File

@ -0,0 +1,8 @@
OBKV Table Client Framework is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.

File diff suppressed because one or more lines are too long

283
pom.xml Normal file
View File

@ -0,0 +1,283 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.oceanbase</groupId>
<artifactId>obkv-table-client</artifactId>
<version>0.1.0</version>
<name>OBKV Table Client Framework</name>
<properties>
<java.source.version>1.6</java.source.version>
<java.target.version>1.6</java.target.version>
<project.build.sourceEncoding>${project.encoding}</project.build.sourceEncoding>
<project.encoding>UTF-8</project.encoding>
</properties>
<dependencies>
<dependency>
<groupId>com.alipay.sofa.common</groupId>
<artifactId>sofa-common-tools</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>bolt</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.13.Final</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1.1-jre</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.4.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.4.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.69_sec12</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.30</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.yahoo.ycsb</groupId>
<artifactId>core</artifactId>
<version>0.12.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/core-0.12.0.jar</systemPath>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.9</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>${user.dir}/license-common/mulan_psl2</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<id>first</id>
<phase>process-sources</phase>
<goals>
<goal>update-file-header</goal>
</goals>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<excludes>
<exclude>*.png</exclude>
<exclude>*.txt</exclude>
<exclude>*Test.java</exclude>
<exclude>*.property</exclude>
<exclude>*.properties</exclude>
<exclude>*.xsd</exclude>
<exclude>*Test.java</exclude>
<exclude>SR*.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
<configuration>
<organizationName>OceanBase</organizationName>
<inceptionYear>2021</inceptionYear>
<licenseName>mulan_psl2</licenseName>
<licenseResolver>file:///${user.dir}/license-common</licenseResolver>
<encoding>${project.encoding}</encoding>
<addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
<emptyLineAfterHeader>true</emptyLineAfterHeader>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<fork>true</fork>
<source>${java.source.version}</source>
<target>${java.target.version}</target>
<encoding>${project.encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<argLine>${argLine} -server -Xms2048m -Xmx2048m -Xmn768m -Xss256k -XX:MaxDirectMemorySize=1024M</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
<configuration>
<attach>true</attach>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<addMavenDescriptor>true</addMavenDescriptor>
<index>true</index>
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>com.googlecode.maven-java-formatter-plugin</groupId>
<artifactId>maven-java-formatter-plugin</artifactId>
<version>0.4</version>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
<configuration>
<configFile>${user.dir}/.oceanbase-common/AlipayFormatter.xml</configFile>
<encoding>${project.encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<id>sort-pom</id>
<phase>prepare-package</phase>
<goals>
<goal>sort</goal>
</goals>
</execution>
</executions>
<configuration>
<nrOfIndentSpace>4</nrOfIndentSpace>
<keepBlankLines>true</keepBlankLines>
<sortProperties>true</sortProperties>
<encoding>${project.encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>coverage</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,107 @@
/*-
* #%L
* OceanBase Table Hbase Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc;
public interface Lifecycle {
/**
* initialize this resource, building any underlying resources.
*
* <p>While this interface method is declared to throw {@code
* Exception}, implementers are <em>strongly</em> encouraged to
* declare concrete implementations of the {@code init} method to
* throw more specific exceptions, or to throw no exception at all
* if the initialize operation cannot fail.
*
* <p> Cases where the initialize operation may fail require careful
* attention by implementers. It is strongly advised to building
* the underlying resources and to internally <em>mark</em> the
* resource as initialized, prior to throwing the exception. The {@code
* close} method is unlikely to be invoked more than once and so
* this ensures that the resources are released in a timely manner.
* Furthermore it reduces problems that could arise when the resource
* wraps, or is wrapped, by another resource.
*
* <p><em>Implementers of this interface are also strongly advised
* to not have the {@code close} method throw {@link
* InterruptedException}.</em>
*
* This exception interacts with a thread's interrupted status,
* and runtime misbehavior is likely to occur if an {@code
* InterruptedException} is {@linkplain Throwable#addSuppressed
* suppressed}.
*
* More generally, if it would cause problems for an
* exception to be suppressed, the {@code init}
* method should not throw it.
*
* <p>Note that this {@code init} method is <em>not</em> required
* to be idempotent. In other words,calling this {@code close} method
* more than once may have some visible side effect.
*
* However, implementers of this interface are strongly encouraged
* to make their {@code init} methods idempotent.
*
* @throws Exception if this resource cannot be init
*/
void init() throws Exception;
/**
* Closes this resource, relinquishing any underlying resources.
*
* <p>While this interface method is declared to throw {@code
* Exception}, implementers are <em>strongly</em> encouraged to
* declare concrete implementations of the {@code close} method to
* throw more specific exceptions, or to throw no exception at all
* if the close operation cannot fail.
*
* <p> Cases where the close operation may fail require careful
* attention by implementers. It is strongly advised to relinquish
* the underlying resources and to internally <em>mark</em> the
* resource as closed, prior to throwing the exception. The {@code
* close} method is unlikely to be invoked more than once and so
* this ensures that the resources are released in a timely manner.
* Furthermore it reduces problems that could arise when the resource
* wraps, or is wrapped, by another resource.
*
* <p><em>Implementers of this interface are also strongly advised
* to not have the {@code close} method throw {@link
* InterruptedException}.</em>
*
* This exception interacts with a thread's interrupted status,
* and runtime misbehavior is likely to occur if an {@code
* InterruptedException} is {@linkplain Throwable#addSuppressed
* suppressed}.
*
* More generally, if it would cause problems for an
* exception to be suppressed, the {@code AutoCloseable.close}
* method should not throw it.
*
* <p>Note that unlike the {@link java.io.Closeable#close close}
* method of {@link java.io.Closeable}, this {@code close} method
* is <em>not</em> required to be idempotent. In other words,
* calling this {@code close} method more than once may have some
* visible side effect, unlike {@code Closeable.close} which is
* required to have no effect if called more than once.
*
* However, implementers of this interface are strongly encouraged
* to make their {@code close} methods idempotent.
*
* @throws Exception if this resource cannot be closed
*/
void close() throws Exception;
}

View File

@ -0,0 +1,162 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableBatchOperation;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableBatchOperationResult;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableEntityType;
import com.alipay.oceanbase.rpc.table.AbstractTableBatchOps;
import com.alipay.oceanbase.rpc.table.ObTableClientBatchOpsImpl;
import java.util.List;
import java.util.concurrent.ExecutorService;
// TODO rename it
public class ObClusterTableBatchOps extends AbstractTableBatchOps {
private final ObTableClientBatchOpsImpl tableBatchOps;
ObClusterTableBatchOps(ObTableClientBatchOpsImpl tableBatchOps) {
this.tableBatchOps = tableBatchOps;
}
ObClusterTableBatchOps(ExecutorService executorService, ObTableClientBatchOpsImpl tableBatchOps) {
this.tableBatchOps = tableBatchOps;
this.tableBatchOps.setExecutorService(executorService);
}
/**
* Get.
*/
@Override
public void get(Object[] rowkeys, String[] columns) {
tableBatchOps.get(rowkeys, columns);
}
/**
* Update.
*/
@Override
public void update(Object[] rowkeys, String[] columns, Object[] values) {
tableBatchOps.update(rowkeys, columns, values);
}
/**
* Delete.
*/
@Override
public void delete(Object[] rowkeys) {
tableBatchOps.delete(rowkeys);
}
/**
* Insert.
*/
@Override
public void insert(Object[] rowkeys, String[] columns, Object[] values) {
tableBatchOps.insert(rowkeys, columns, values);
}
/**
* Replace.
*/
@Override
public void replace(Object[] rowkeys, String[] columns, Object[] values) {
tableBatchOps.replace(rowkeys, columns, values);
}
/**
* Insert or update.
*/
@Override
public void insertOrUpdate(Object[] rowkeys, String[] columns, Object[] values) {
tableBatchOps.insertOrUpdate(rowkeys, columns, values);
}
/**
* Increment.
*/
@Override
public void increment(Object[] rowkeys, String[] columns, Object[] values, boolean withResult) {
tableBatchOps.increment(rowkeys, columns, values, withResult);
}
/**
* Append.
*/
@Override
public void append(Object[] rowkeys, String[] columns, Object[] values, boolean withResult) {
tableBatchOps.append(rowkeys, columns, values, withResult);
}
/**
* Execute.
*/
@Override
public List<Object> execute() throws Exception {
return tableBatchOps.execute();
}
/**
* Execute internal.
*/
public ObTableBatchOperationResult executeInternal() throws Exception {
return tableBatchOps.executeInternal();
}
/**
* clear batch operations
*/
public void clear() {
tableBatchOps.clear();
}
/**
* Get ob table batch operation.
*/
@Override
public ObTableBatchOperation getObTableBatchOperation() {
return tableBatchOps.getObTableBatchOperation();
}
/**
* Get table name.
*/
@Override
public String getTableName() {
return tableBatchOps.getTableName();
}
/**
* Set entity type.
*/
@Override
public void setEntityType(ObTableEntityType entityType) {
super.setEntityType(entityType);
tableBatchOps.setEntityType(entityType);
}
/**
* Set atomic operation.
*/
@Override
public void setAtomicOperation(boolean atomicOperation) {
super.setAtomicOperation(atomicOperation);
tableBatchOps.setAtomicOperation(atomicOperation);
}
}

View File

@ -0,0 +1,183 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableEntityType;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObHTableFilter;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObTableQuery;
import com.alipay.oceanbase.rpc.stream.ObTableClientQueryStreamResult;
import com.alipay.oceanbase.rpc.stream.QueryResultSet;
import com.alipay.oceanbase.rpc.table.AbstractTableQuery;
import com.alipay.oceanbase.rpc.table.ObTableClientQueryImpl;
import com.alipay.oceanbase.rpc.table.api.TableQuery;
public class ObClusterTableQuery extends AbstractTableQuery {
private final ObTableClientQueryImpl tableClientQuery;
ObClusterTableQuery(ObTableClientQueryImpl tableQuery) {
this.tableClientQuery = tableQuery;
}
/**
* Get table name.
*/
@Override
public String getTableName() {
return tableClientQuery.getTableName();
}
/**
* Get ob table query.
*/
@Override
public ObTableQuery getObTableQuery() {
return tableClientQuery.getObTableQuery();
}
/**
* Execute.
*/
@Override
public QueryResultSet execute() throws Exception {
return tableClientQuery.execute();
}
/**
* Execute internal.
*/
public ObTableClientQueryStreamResult executeInternal() throws Exception {
return tableClientQuery.executeInternal();
}
/**
* Select.
*/
@Override
public TableQuery select(String... columns) {
tableClientQuery.select(columns);
return this;
}
/**
* 只有 limit query 需要其他不需要
* @param keys
* @return
*/
@Override
public TableQuery setKeys(String... keys) {
throw new IllegalArgumentException("Not needed");
}
/**
* Limit.
*/
@Override
public TableQuery limit(int offset, int limit) {
tableClientQuery.limit(offset, limit);
return this;
}
/**
* Add scan range.
*/
@Override
public TableQuery addScanRange(Object[] start, boolean startEquals, Object[] end,
boolean endEquals) {
tableClientQuery.addScanRange(start, startEquals, end, endEquals);
return this;
}
/**
* Add scan range starts with.
*/
@Override
public TableQuery addScanRangeStartsWith(Object[] start, boolean startEquals) {
tableClientQuery.addScanRangeStartsWith(start, startEquals);
return this;
}
/**
* Add scan range ends with.
*/
@Override
public TableQuery addScanRangeEndsWith(Object[] end, boolean endEquals) {
tableClientQuery.addScanRangeEndsWith(end, endEquals);
return this;
}
/**
* Scan order.
*/
@Override
public TableQuery scanOrder(boolean forward) {
tableClientQuery.scanOrder(forward);
return this;
}
/**
* Index name.
*/
@Override
public TableQuery indexName(String indexName) {
tableClientQuery.indexName(indexName);
return this;
}
/**
* Filter string.
*/
@Override
public TableQuery filterString(String filterString) {
tableClientQuery.filterString(filterString);
return this;
}
/**
* Set h table filter.
*/
@Override
public TableQuery setHTableFilter(ObHTableFilter obHTableFilter) {
return tableClientQuery.setHTableFilter(obHTableFilter);
}
/**
* Set batch size.
*/
@Override
public TableQuery setBatchSize(int batchSize) {
return tableClientQuery.setBatchSize(batchSize);
}
/**
* Clear.
*/
@Override
public void clear() {
tableClientQuery.clear();
}
/**
* Set entity type.
*/
@Override
public void setEntityType(ObTableEntityType entityType) {
super.setEntityType(entityType);
tableClientQuery.setEntityType(entityType);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,259 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.batch;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableEntityType;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObHTableFilter;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObTableQuery;
import com.alipay.oceanbase.rpc.stream.QueryResultSet;
import com.alipay.oceanbase.rpc.table.api.TableQuery;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class QueryByBatch implements TableQuery {
private final TableQuery tableQuery;
private Object[] start, end;
private boolean endEquals;
private String[] keys = new String[0];
private String[] select = new String[0];
public QueryByBatch(TableQuery tableQuery) {
this.tableQuery = tableQuery;
}
@Override
public ObTableQuery getObTableQuery() {
return this.tableQuery.getObTableQuery();
}
@Override
public String getTableName() {
return this.tableQuery.getTableName();
}
@Override
public void setEntityType(ObTableEntityType entityType) {
this.tableQuery.setEntityType(entityType);
}
@Override
public ObTableEntityType getEntityType() {
return this.tableQuery.getEntityType();
}
@Override
public QueryResultSet execute() {
return new QueryResultSet(new QueryByBatchResultSet(this));
}
public TableQuery addScanRange(Object start, Object end) {
addScanRange(start, true, end, true);
return this;
}
@Override
public TableQuery addScanRange(Object[] start, Object[] end) {
return addScanRange(start, true, end, true);
}
public TableQuery addScanRange(Object start, boolean startEquals, Object end, boolean endEquals) {
addScanRange(new Object[] { start }, startEquals, new Object[] { end }, endEquals);
return this;
}
public TableQuery addScanRange(Object[] start, boolean startEquals, Object[] end,
boolean endEquals) {
this.start = start;
this.end = end;
this.endEquals = endEquals;
this.tableQuery.addScanRange(start, startEquals, end, endEquals);
return this;
}
@Override
public TableQuery addScanRangeStartsWith(Object start) {
addScanRangeStartsWith(new Object[] { start });
return this;
}
@Override
public TableQuery addScanRangeStartsWith(Object[] start) {
addScanRangeStartsWith(start, true);
return this;
}
@Override
public TableQuery addScanRangeStartsWith(Object[] start, boolean startEquals) {
this.start = start;
this.tableQuery.addScanRangeStartsWith(start, startEquals);
return this;
}
@Override
public TableQuery addScanRangeEndsWith(Object end) {
addScanRangeEndsWith(new Object[] { end });
return this;
}
@Override
public TableQuery addScanRangeEndsWith(Object[] end) {
addScanRangeEndsWith(end, true);
return this;
}
@Override
public TableQuery addScanRangeEndsWith(Object[] end, boolean endEquals) {
this.end = end;
this.endEquals = endEquals;
this.tableQuery.addScanRangeEndsWith(end, endEquals);
return this;
}
@Override
public TableQuery scanOrder(boolean forward) {
throw new IllegalArgumentException("not support scanOrder for QueryByBatch");
}
@Override
public TableQuery indexName(String indexName) {
throw new IllegalArgumentException("not support indexName for QueryByBatch");
}
@Override
public TableQuery primaryIndex() {
throw new IllegalArgumentException("not support primaryIndex for QueryByBatch");
}
@Override
public TableQuery filterString(String filterString) {
throw new IllegalArgumentException("not support filterString for QueryByBatch");
}
@Override
public TableQuery setHTableFilter(ObHTableFilter obHTableFilter) {
throw new IllegalArgumentException("not support setHTableFilter for QueryByBatch");
}
/**
* 这边取名为 batch size, 实际转化到查询就是stream的limit
* 保证它的查询只是单次的所以在observer不会转化成stream query
* @param batchSize
* @return
*/
public QueryByBatch setBatchSize(int batchSize) {
this.tableQuery.limit(batchSize);
return this;
}
@Override
public TableQuery setOperationTimeout(long operationTimeout) {
this.tableQuery.setOperationTimeout(operationTimeout);
return this;
}
@Override
public void clear() {
this.tableQuery.clear();
}
public TableQuery getTableQuery() {
return tableQuery;
}
/**
* 必须显式的设置一下 scan keys
* 因为目前 observer 没有返回 primary key 或者其他 index 的信息
* 所以拆分查询时必须手动指定 key
* 需要和 select key 合并
* @param keys
* @return
*/
@Override
public TableQuery setKeys(String... keys) {
this.keys = keys;
mergeSelect();
return this;
}
@Override
public TableQuery limit(int limit) {
throw new IllegalArgumentException("not support limit for QueryByBatch");
}
@Override
public TableQuery limit(int offset, int limit) {
throw new IllegalArgumentException("not support limit for QueryByBatch");
}
/**
* 需要和 select key 合并
* @param columns
* @return
*/
@Override
public QueryByBatch select(String... columns) {
this.select = columns;
mergeSelect();
return this;
}
/**
* 只支持两种方式的合并
* 1. keys: ["a"], select: ["b"], 合并为 ["a", "b"]即不包含关系
* 2. keys: ["a"], select: ["a", "b"] 合并为 ["a", "b"] 即包含关系
* 其他情况返回不支持
*/
private void mergeSelect() {
Set<String> keySet = new HashSet<String>(Arrays.asList(this.keys));
Set<String> selectSet = new HashSet<String>(Arrays.asList(this.select));
if (keySet.size() != this.keys.length || selectSet.size() != this.select.length) {
throw new IllegalArgumentException("key duplicate in (keys or select)");
}
Set<String> mix = new HashSet<String>();
mix.addAll(keySet);
mix.addAll(selectSet);
if (mix.size() == keySet.size() + selectSet.size()) {
String[] mixSelect = new String[this.keys.length + this.select.length];
System.arraycopy(this.keys, 0, mixSelect, 0, this.keys.length);
System.arraycopy(this.select, 0, mixSelect, this.keys.length, this.select.length);
this.tableQuery.select(mixSelect);
} else if (mix.size() == selectSet.size()) {
this.tableQuery.select(this.select);
} else {
throw new IllegalArgumentException("key duplicate in (keys and select)");
}
}
public String[] getKeys() {
return keys;
}
public Object[] getStart() {
return start;
}
public Object[] getEnd() {
return end;
}
public boolean isEndEquals() {
return endEquals;
}
}

View File

@ -0,0 +1,120 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.batch;
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObObj;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.QueryStreamResult;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObNewRange;
import com.alipay.oceanbase.rpc.stream.QueryResultSet;
import com.alipay.oceanbase.rpc.table.api.TableQuery;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class QueryByBatchResultSet implements QueryStreamResult {
private final QueryByBatch queryByBatch;
private QueryResultSet resultSet = null;
private int resultSize;
public QueryByBatchResultSet(QueryByBatch queryByBatch) {
this.queryByBatch = queryByBatch;
}
@Override
public boolean next() throws Exception {
// 如果是 null 就说明它是第一次查询直接使用老得接口 execute
if (resultSet == null) {
resultSet = this.queryByBatch.getTableQuery().execute();
resultSize = resultSet.cacheSize();
}
boolean res = resultSet.next();
if (!res) {
// 防止出现 [0,0) 情况
if (resultSize > 0) {
// 如果没有 next getrow 获取的是上一个存在的值
Map<String, Object> row = resultSet.getRow();
updateQuery(row, this.queryByBatch.getTableQuery());
refreshExecute();
res = resultSet.next();
}
}
return res;
}
@Override
public List<ObObj> getRow() {
return resultSet.getQueryStreamResult().getRow();
}
/**
* 通过当前的最后一条数据与之前的查询条件融合
* 例如上次查询为 limit["a","z"), 最后一条数据为 "bbb"
* 则此次查询改造为 limit("bbb", "z")
* @param row
* @param tableQuery
*/
private void updateQuery(Map<String, Object> row, TableQuery tableQuery) {
List<ObNewRange> ranges = tableQuery.getObTableQuery().getKeyRanges();
ranges.clear();
int keyLen = this.queryByBatch.getEnd().length;
Object[] newBegin = new Object[keyLen];
for (int i = 0; i < keyLen; i++) {
newBegin[i] = row.get(this.queryByBatch.getKeys()[i]);
}
// 这边 startEquals 永远都是 false 因为 begin 这条数据已经取过了
tableQuery.addScanRange(newBegin, false, this.queryByBatch.getEnd(),
this.queryByBatch.isEndEquals());
}
/**
* 在更新完 query 以后重新获取一下结果
*/
private void refreshExecute() throws Exception {
resultSet = this.queryByBatch.getTableQuery().execute();
resultSize = resultSet.cacheSize();
}
@Override
public int getRowIndex() {
return resultSet.getQueryStreamResult().getRowIndex();
}
@Override
public LinkedList<List<ObObj>> getCacheRows() {
if (resultSet == null) {
return new LinkedList<List<ObObj>>();
}
return resultSet.getQueryStreamResult().getCacheRows();
}
@Override
public List<String> getCacheProperties() {
return resultSet.getQueryStreamResult().getCacheProperties();
}
@Override
public void init() throws Exception {
resultSet.getQueryStreamResult().init();
}
@Override
public void close() throws Exception {
resultSet.getQueryStreamResult().close();
}
}

View File

@ -0,0 +1,266 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.protocol;
import com.alipay.oceanbase.rpc.protocol.packet.ObRpcPacketHeader;
import com.alipay.remoting.CommandCode;
import com.alipay.remoting.InvokeContext;
import com.alipay.remoting.ProtocolCode;
import com.alipay.remoting.RemotingCommand;
import com.alipay.remoting.config.switches.ProtocolSwitch;
import com.alipay.remoting.exception.DeserializationException;
import com.alipay.remoting.exception.SerializationException;
import io.netty.buffer.ByteBuf;
public class ObTablePacket implements RemotingCommand {
private static ProtocolCode OB_RPC_MAGIC_CODE = ProtocolCode
.fromBytes(ObTableProtocol.MAGIC_HEADER_FLAG);
private CommandCode commandCode;
// channel id
private int id;
private byte[] packetContent;
private ByteBuf packetContentBuf;
private ObRpcPacketHeader header;
private int transportCode;
private String message;
private Throwable cause;
/**
* Decode packet header.
*/
public void decodePacketHeader() {
header = new ObRpcPacketHeader();
header.decode(packetContentBuf);
this.setCmdCode(ObTablePacketCode.valueOf((short) header.getPcode()));
}
/**
* Create transport error packet.
*/
public static ObTablePacket createTransportErrorPacket(int transportCode, String message,
Throwable cause) {
ObTablePacket tablePacket = new ObTablePacket();
tablePacket.transportCode = transportCode;
tablePacket.message = message;
tablePacket.cause = cause;
return tablePacket;
}
/**
* Get protocol code.
*/
@Override
public ProtocolCode getProtocolCode() {
return OB_RPC_MAGIC_CODE;
}
/**
* Get cmd code.
*/
@Override
public CommandCode getCmdCode() {
return commandCode;
}
/**
* Set cmd code.
*/
public void setCmdCode(CommandCode cmdCode) {
this.commandCode = cmdCode;
}
/**
* Get id.
*/
@Override
public int getId() {
return id;
}
/**
* Set id.
*/
public void setId(int id) {
this.id = id;
}
/**
* Get packet content.
*/
public byte[] getPacketContent() {
return packetContent;
}
/**
* Set packet content.
*/
public void setPacketContent(byte[] packetContent) {
this.packetContent = packetContent;
}
/**
* Set packet content buf.
*/
public void setPacketContentBuf(ByteBuf packetContent) {
this.packetContentBuf = packetContent;
}
/**
* Get packet content buf.
*/
public ByteBuf getPacketContentBuf() {
return packetContentBuf;
}
/**
* Release byte buf.
*/
public void releaseByteBuf() {
// http://netty.io/wiki/reference-counted-objects.html
if (packetContentBuf != null) {
packetContentBuf.release();
}
}
/**
* Get header.
*/
public ObRpcPacketHeader getHeader() {
return header;
}
/**
* Set header.
*/
public void setHeader(ObRpcPacketHeader header) {
this.header = header;
}
/**
* Is success.
*/
public boolean isSuccess() {
return transportCode == 0;
}
/**
* Get transport code.
*/
public int getTransportCode() {
return transportCode;
}
/**
* Set transport code.
*/
public void setTransportCode(int transportCode) {
this.transportCode = transportCode;
}
/**
* Get message.
*/
public String getMessage() {
return message;
}
/**
* Set message.
*/
public void setMessage(String message) {
this.message = message;
}
/**
* Get cause.
*/
public Throwable getCause() {
return cause;
}
/**
* Set cause.
*/
public void setCause(Throwable cause) {
this.cause = cause;
}
// TODO useless for now
/**
* Get invoke context.
*/
@Override
public InvokeContext getInvokeContext() {
return null;
}
/**
* Get serializer.
*/
@Override
public byte getSerializer() {
return 0;
}
/**
* Get protocol switch.
*/
@Override
public ProtocolSwitch getProtocolSwitch() {
return null;
}
/**
* Serialize.
*/
@Override
public void serialize() throws SerializationException {
}
/**
* Deserialize.
*/
@Override
public void deserialize() throws DeserializationException {
}
/**
* Serialize content.
*/
@Override
public void serializeContent(InvokeContext invokeContext) throws SerializationException {
}
/**
* Deserialize content.
*/
@Override
public void deserializeContent(InvokeContext invokeContext) throws DeserializationException {
}
}

View File

@ -0,0 +1,125 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.protocol;
import com.alipay.oceanbase.rpc.protocol.packet.ObRpcPacketHeader;
import com.alipay.oceanbase.rpc.protocol.payload.ObPayload;
import com.alipay.oceanbase.rpc.protocol.payload.Pcodes;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableBatchOperationResult;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableOperationResult;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.mutate.ObTableQueryAndMutateResult;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObTableQueryResult;
import com.alipay.oceanbase.rpc.protocol.payload.impl.login.ObTableLoginResult;
import com.alipay.remoting.CommandCode;
public enum ObTablePacketCode implements CommandCode {
OB_TABLE_API_LOGIN(Pcodes.OB_TABLE_API_LOGIN) {
/**
* New payload.
*/
@Override
public ObPayload newPayload(ObRpcPacketHeader header) {
return new ObTableLoginResult();
}
}, //
OB_TABLE_API_EXECUTE(Pcodes.OB_TABLE_API_EXECUTE) {
/**
* New payload.
*/
@Override
public ObPayload newPayload(ObRpcPacketHeader header) {
return new ObTableOperationResult();
}
}, //
OB_TABLE_API_BATCH_EXECUTE(Pcodes.OB_TABLE_API_BATCH_EXECUTE) {
/**
* New payload.
*/
@Override
public ObPayload newPayload(ObRpcPacketHeader header) {
return new ObTableBatchOperationResult();
}
}, //
OB_TABLE_API_EXECUTE_QUERY(Pcodes.OB_TABLE_API_EXECUTE_QUERY) {
/**
* New payload.
*/
@Override
public ObPayload newPayload(ObRpcPacketHeader header) {
return new ObTableQueryResult(header);
}
}, //
OB_TABLE_API_QUERY_AND_MUTATE(Pcodes.OB_TABLE_API_QUERY_AND_MUTATE) {
/**
* New payload.
*/
@Override
public ObPayload newPayload(ObRpcPacketHeader header) {
return new ObTableQueryAndMutateResult();
}
}, //
// INVALID REQUEST PCODE, no such rpc
OB_ERROR_PACKET(Pcodes.OB_ERROR_PACKET) {
/**
* New payload.
*/
@Override
public ObPayload newPayload(ObRpcPacketHeader header) {
throw new IllegalArgumentException("OB_ERROR_PACKET has no payload implementation");
}
};
private short value;
ObTablePacketCode(int value) {
this.value = (short) value;
}
/**
* Value.
*/
public short value() {
return this.value;
}
/**
* Value of.
*/
public static ObTablePacketCode valueOf(short value) {
switch (value) {
case Pcodes.OB_TABLE_API_LOGIN:
return OB_TABLE_API_LOGIN;
case Pcodes.OB_TABLE_API_EXECUTE:
return OB_TABLE_API_EXECUTE;
case Pcodes.OB_TABLE_API_BATCH_EXECUTE:
return OB_TABLE_API_BATCH_EXECUTE;
case Pcodes.OB_TABLE_API_EXECUTE_QUERY:
return OB_TABLE_API_EXECUTE_QUERY;
case Pcodes.OB_TABLE_API_QUERY_AND_MUTATE:
return OB_TABLE_API_QUERY_AND_MUTATE;
case Pcodes.OB_ERROR_PACKET:
return OB_ERROR_PACKET;
}
throw new IllegalArgumentException("Unknown Rpc command code value ," + value);
}
public abstract ObPayload newPayload(ObRpcPacketHeader header);
}

View File

@ -0,0 +1,86 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.protocol;
import com.alipay.oceanbase.rpc.util.Serialization;
import com.alipay.remoting.CommandDecoder;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import java.util.List;
public class ObTablePacketDecoder implements CommandDecoder {
/**
* Decode.
*/
@Override
public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
// the less length between response header and request header
if (in.readableBytes() > ObTableProtocol.HEADER_LENGTH) {
in.markReaderIndex();
/*
* 4bytes 4bytes 4bytes 4bytes
* -----------------------------------
* | flag | dlen | chid | reserved |
* -----------------------------------
*/
// 1. decode header
byte b;
if ((b = in.readByte()) != ObTableProtocol.MAGIC_HEADER_FLAG[0]) {
throw new RuntimeException("magic header wrong, 0 expect: "
+ ObTableProtocol.MAGIC_HEADER_FLAG[0] + ", but: " + b);
} else if ((b = in.readByte()) != ObTableProtocol.MAGIC_HEADER_FLAG[1]) {
throw new RuntimeException("magic header wrong, 2 expect: "
+ ObTableProtocol.MAGIC_HEADER_FLAG[1] + ", but: " + b);
} else if ((b = in.readByte()) != ObTableProtocol.MAGIC_HEADER_FLAG[2]) {
throw new RuntimeException("magic header wrong, 2 expect: "
+ ObTableProtocol.MAGIC_HEADER_FLAG[2] + ", but: " + b);
} else if ((b = in.readByte()) != ObTableProtocol.MAGIC_HEADER_FLAG[3]) {
throw new RuntimeException("magic header wrong, 3 expect: "
+ ObTableProtocol.MAGIC_HEADER_FLAG[3] + ", but: " + b);
}
byte[] dlen = new byte[4];
in.readBytes(dlen);
int dataLen = Serialization.decodeI32(dlen);
byte[] chid = new byte[4];
in.readBytes(chid);
int channelId = Serialization.decodeI32(chid);
in.readByte(); // reserved
in.readByte(); // reserved
in.readByte(); // reserved
in.readByte(); // reserved
// 2. try decode packet
if (in.readableBytes() >= dataLen) {
ObTablePacket obCommand = new ObTablePacket();
obCommand.setId(channelId);
ByteBuf rpcPacketByteBuf = in.readBytes(dataLen);
obCommand.setPacketContentBuf(rpcPacketByteBuf);
out.add(obCommand);
} else {
in.resetReaderIndex();
}
}
}
}

View File

@ -0,0 +1,72 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.protocol;
import com.alipay.oceanbase.rpc.util.Serialization;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import com.alipay.remoting.CommandEncoder;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import java.io.Serializable;
import static com.alipay.oceanbase.rpc.util.TableClientLoggerFactory.LCD;
public class ObTablePacketEncoder implements CommandEncoder {
private static final Logger logger = TableClientLoggerFactory
.getLogger(ObTablePacketEncoder.class);
/**
* Encode.
*/
@Override
public void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception {
try {
if (msg instanceof ObTablePacket) {
/*
* 4bytes 4bytes 4bytes 4bytes
* -----------------------------------
* | flag | dlen | chid | reserved |
* -----------------------------------
*/
ObTablePacket cmd = (ObTablePacket) msg;
// 1. header
out.writeBytes(ObTableProtocol.MAGIC_HEADER_FLAG);
out.writeBytes(Serialization.encodeI32(cmd.getPacketContent().length));
out.writeBytes(Serialization.encodeI32(cmd.getId()));
out.writeBytes(ObTableProtocol.RESERVED);
// 2. payload
out.writeBytes(cmd.getPacketContent());
} else {
String warnMsg = "msg type [" + msg.getClass() + "] is not subclass of ObCommand";
logger.warn(warnMsg);
}
} catch (Exception e) {
logger.error(LCD.convert("01-00003"), e);
throw e;
}
}
}

View File

@ -0,0 +1,98 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.protocol;
import com.alipay.oceanbase.rpc.bolt.transport.ObTablePacketHandler;
import com.alipay.remoting.*;
public class ObTableProtocol implements Protocol {
public final static byte API_VERSION = 1;
public final static int HEADER_LENGTH = 16;
/**
* ob_rpc_net_handler.cpp
* Magic Header 4 bytes
* <p>
* const uint8_t ObRpcNetHandler::MAGIC_HEADER_FLAG[4] =
* { ObRpcNetHandler::API_VERSION, 0xDB, 0xDB, 0xCE };
*/
public final static byte[] MAGIC_HEADER_FLAG = new byte[] { API_VERSION, (byte) 0xDB,
(byte) 0xDB, (byte) 0xCE };
public final static byte[] RESERVED = new byte[4];
private CommandEncoder commandEncoder;
private CommandDecoder commandDecoder;
private CommandHandler commandHandler;
static {
ProtocolManager.registerProtocol(new ObTableProtocol(), MAGIC_HEADER_FLAG);
}
/**
* Ob table protocol.
*/
public ObTableProtocol() {
this.commandEncoder = new ObTablePacketEncoder();
this.commandDecoder = new ObTablePacketDecoder();
this.commandHandler = new ObTablePacketHandler();
}
/**
* Get encoder.
*/
@Override
public CommandEncoder getEncoder() {
return commandEncoder;
}
/**
* Get decoder.
*/
@Override
public CommandDecoder getDecoder() {
return commandDecoder;
}
/**
* Get command handler.
*/
@Override
public CommandHandler getCommandHandler() {
return commandHandler;
}
/**
* Get heartbeat trigger.
*/
@Override
public HeartbeatTrigger getHeartbeatTrigger() {
return null;
}
/**
* Get command factory.
*/
@Override
public CommandFactory getCommandFactory() {
return null;
}
}

View File

@ -0,0 +1,186 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.transport;
import com.alipay.oceanbase.rpc.bolt.protocol.ObTablePacket;
import com.alipay.remoting.InvokeCallback;
import com.alipay.remoting.InvokeContext;
import com.alipay.remoting.InvokeFuture;
import com.alipay.remoting.RemotingCommand;
import io.netty.util.Timeout;
import java.net.InetSocketAddress;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class ObClientFuture implements InvokeFuture {
private CountDownLatch waiter = new CountDownLatch(1);
private RemotingCommand response;
private int channelId;
/**
* Ob client future.
*/
public ObClientFuture(int channelId) {
this.channelId = channelId;
}
/**
* Wait response.
*/
@Override
public RemotingCommand waitResponse(long timeoutMillis) throws InterruptedException {
if (waiter.await(timeoutMillis, TimeUnit.MILLISECONDS)) {
return response;
} else {
return ObTablePacket.createTransportErrorPacket(TransportCodes.BOLT_TIMEOUT,
"wait timeout: " + timeoutMillis, null);
}
}
/**
* Wait response.
*/
@Override
public RemotingCommand waitResponse() throws InterruptedException {
waiter.await();
return response;
}
/**
* Put response.
*/
@Override
public void putResponse(RemotingCommand response) {
this.response = response;
waiter.countDown();
}
/**
* Invoke id.
*/
@Override
public int invokeId() {
return channelId;
}
/**
* Is done.
*/
@Override
public boolean isDone() {
return this.waiter.getCount() == 0;
}
/**
* Create connection closed response.
*/
@Override
public RemotingCommand createConnectionClosedResponse(InetSocketAddress responseHost) {
return null;
}
/**
* Execute invoke callback.
*/
@Override
public void executeInvokeCallback() {
}
/**
* Try async execute invoke callback abnormally.
*/
@Override
public void tryAsyncExecuteInvokeCallbackAbnormally() {
}
/**
* Set cause.
*/
@Override
public void setCause(Throwable cause) {
}
/**
* Get cause.
*/
@Override
public Throwable getCause() {
return null;
}
/**
* Get invoke callback.
*/
@Override
public InvokeCallback getInvokeCallback() {
return null;
}
/**
* Add timeout.
*/
@Override
public void addTimeout(Timeout timeout) {
}
/**
* Cancel timeout.
*/
@Override
public void cancelTimeout() {
}
/**
* Get app class loader.
*/
@Override
public ClassLoader getAppClassLoader() {
return null;
}
/**
* Get protocol code.
*/
@Override
public byte getProtocolCode() {
return 0;
}
/**
* Set invoke context.
*/
@Override
public void setInvokeContext(InvokeContext invokeContext) {
}
/**
* Get invoke context.
*/
@Override
public InvokeContext getInvokeContext() {
return null;
}
}

View File

@ -0,0 +1,30 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.transport;
import com.alipay.remoting.config.AbstractConfigurableInstance;
import com.alipay.remoting.config.configs.ConfigType;
public class ObConfigurableInstance extends AbstractConfigurableInstance {
/**
* Ob configurable instance.
*/
public ObConfigurableInstance() {
super(ConfigType.CLIENT_SIDE);
}
}

View File

@ -0,0 +1,243 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.transport;
import com.alipay.oceanbase.rpc.bolt.protocol.ObTableProtocol;
import com.alipay.remoting.*;
import com.alipay.remoting.codec.Codec;
import com.alipay.remoting.config.ConfigManager;
import com.alipay.remoting.config.ConfigurableInstance;
import com.alipay.remoting.connection.AbstractConnectionFactory;
import com.alipay.remoting.connection.ConnectionFactory;
import com.alipay.remoting.log.BoltLoggerFactory;
import com.alipay.remoting.rpc.RpcHandler;
import com.alipay.remoting.rpc.protocol.UserProcessor;
import com.alipay.remoting.util.NettyEventLoopUtil;
import com.alipay.remoting.util.StringUtils;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.channel.*;
import io.netty.channel.socket.SocketChannel;
import org.slf4j.Logger;
import java.net.InetSocketAddress;
import java.util.concurrent.ConcurrentHashMap;
public class ObConnectionFactory implements ConnectionFactory {
private static final Logger logger = BoltLoggerFactory
.getLogger(AbstractConnectionFactory.class);
private static final EventLoopGroup workerGroup = NettyEventLoopUtil.newEventLoopGroup(Runtime
.getRuntime().availableProcessors() + 1,
new NamedThreadFactory(
"Rpc-netty-client-worker", true));
private final ConfigurableInstance confInstance;
private final Codec codec;
private final ChannelHandler handler;
protected Bootstrap bootstrap;
private ObConnectionFactory(Codec codec, ChannelHandler handler,
ConfigurableInstance confInstance) {
if (codec == null) {
throw new IllegalArgumentException("null codec");
}
if (handler == null) {
throw new IllegalArgumentException("null handler");
}
this.confInstance = confInstance;
this.codec = codec;
this.handler = handler;
}
/**
* Init.
*/
@Override
public void init(final ConnectionEventHandler connectionEventHandler) {
bootstrap = new Bootstrap();
bootstrap.group(workerGroup).channel(NettyEventLoopUtil.getClientSocketChannelClass())
.option(ChannelOption.TCP_NODELAY, ConfigManager.tcp_nodelay())
.option(ChannelOption.SO_REUSEADDR, ConfigManager.tcp_so_reuseaddr())
.option(ChannelOption.SO_KEEPALIVE, ConfigManager.tcp_so_keepalive());
// init netty write buffer water mark
initWriteBufferWaterMark();
// init byte buf allocator
if (ConfigManager.netty_buffer_pooled()) {
this.bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
} else {
this.bootstrap.option(ChannelOption.ALLOCATOR, UnpooledByteBufAllocator.DEFAULT);
}
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel channel) {
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast("decoder", codec.newDecoder());
pipeline.addLast("encoder", codec.newEncoder());
pipeline.addLast("connectionEventHandler", connectionEventHandler);
pipeline.addLast("handler", handler);
}
});
}
/**
* Create connection.
*/
@Override
public Connection createConnection(Url url) throws Exception {
throw new IllegalArgumentException("not support yet");
}
/**
* @see com.alipay.remoting.connection.ConnectionFactory#createConnection(java.lang.String, int, int)
*/
@Override
public Connection createConnection(String targetIP, int targetPort, int connectTimeout)
throws Exception {
Channel channel = doCreateConnection(targetIP, targetPort, connectTimeout);
Connection conn = new Connection(channel,
ProtocolCode.fromBytes(ObTableProtocol.MAGIC_HEADER_FLAG), ObTableProtocol.API_VERSION,
new Url(targetIP, targetPort));
channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT);
return conn;
}
/**
* Create connection.
*/
@Override
public Connection createConnection(String targetIP, int targetPort, byte version,
int connectTimeout) throws Exception {
throw new IllegalArgumentException("not support yet");
}
protected Channel doCreateConnection(String targetIP, int targetPort, int connectTimeout)
throws Exception {
// prevent unreasonable value, at least 1000
connectTimeout = Math.max(connectTimeout, 1000);
String address = targetIP + ":" + targetPort;
if (logger.isDebugEnabled()) {
logger.debug("connectTimeout of address [{}] is [{}].", address, connectTimeout);
}
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout);
ChannelFuture future = bootstrap.connect(new InetSocketAddress(targetIP, targetPort));
if (!future.await(connectTimeout + 10)) {
String errMsg = "Create connection to " + address + " future await timeout!";
logger.warn(errMsg);
boolean isCanceled = future.cancel(false);
logger.warn("Create connection future canceled: {}", isCanceled);
throw new Exception(errMsg, future.cause());
}
if (!future.isDone()) {
String errMsg = "Create connection to " + address + " timeout!";
logger.warn(errMsg);
throw new Exception(errMsg);
}
if (future.isCancelled()) {
String errMsg = "Create connection to " + address + " cancelled by user!";
logger.warn(errMsg);
throw new Exception(errMsg);
}
if (!future.isSuccess()) {
String errMsg = "Create connection to " + address + " error!";
logger.warn(errMsg);
throw new Exception(errMsg, future.cause());
}
return future.channel();
}
/**
* init netty write buffer water mark
*/
private void initWriteBufferWaterMark() {
int lowWaterMark = this.confInstance.netty_buffer_low_watermark();
int highWaterMark = this.confInstance.netty_buffer_high_watermark();
if (lowWaterMark > highWaterMark) {
throw new IllegalArgumentException(
String
.format(
"[client side] bolt netty high water mark {%s} should not be smaller than low water mark {%s} bytes)",
highWaterMark, lowWaterMark));
} else {
logger.warn(
"[client side] bolt netty low water mark is {} bytes, high water mark is {} bytes",
lowWaterMark, highWaterMark);
}
this.bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(
lowWaterMark, highWaterMark));
}
/**
* New builder.
*/
public static ObConnectionFactoryBuilder newBuilder() {
return new ObConnectionFactoryBuilder();
}
public static class ObConnectionFactoryBuilder {
private Codec codec = new ObPacketCodec();
private ConcurrentHashMap<String, UserProcessor<?>> userProcessors = new ConcurrentHashMap<String, UserProcessor<?>>(
4);
private ChannelHandler rpcHandler = new RpcHandler(
userProcessors);
private ConfigurableInstance configurableInstance = new ObConfigurableInstance();
/**
* Register user processor.
*/
public ObConnectionFactoryBuilder registerUserProcessor(UserProcessor<?> processor) {
if (processor == null || StringUtils.isBlank(processor.interest())) {
throw new RuntimeException(
"User processor or processor interest should not be blank!");
}
UserProcessor<?> preProcessor = this.userProcessors.putIfAbsent(processor.interest(),
processor);
if (preProcessor != null) {
String errMsg = "Processor with interest key ["
+ processor.interest()
+ "] has already been registered to rpc client, can not register again!";
throw new RuntimeException(errMsg);
}
return this;
}
/**
* Config write buffer water mark.
*/
public ObConnectionFactoryBuilder configWriteBufferWaterMark(int low, int high) {
configurableInstance.initWriteBufferWaterMark(low, high);
return this;
}
/**
* Build.
*/
public ObConnectionFactory build() {
return new ObConnectionFactory(codec, rpcHandler, configurableInstance);
}
}
}

View File

@ -0,0 +1,44 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.transport;
import com.alipay.oceanbase.rpc.bolt.protocol.ObTableProtocol;
import com.alipay.remoting.ProtocolCode;
import com.alipay.remoting.codec.Codec;
import com.alipay.remoting.codec.ProtocolCodeBasedEncoder;
import com.alipay.remoting.rpc.protocol.RpcProtocolDecoder;
import io.netty.channel.ChannelHandler;
public class ObPacketCodec implements Codec {
/**
* New encoder.
*/
@Override
public ChannelHandler newEncoder() {
return new ProtocolCodeBasedEncoder(
ProtocolCode.fromBytes(ObTableProtocol.MAGIC_HEADER_FLAG));
}
/**
* New decoder.
*/
@Override
public ChannelHandler newDecoder() {
return new RpcProtocolDecoder(ObTableProtocol.MAGIC_HEADER_FLAG.length);
}
}

View File

@ -0,0 +1,153 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.transport;
import com.alipay.oceanbase.rpc.bolt.protocol.ObTablePacket;
import com.alipay.oceanbase.rpc.bolt.protocol.ObTablePacketCode;
import com.alipay.oceanbase.rpc.protocol.packet.ObRpcPacket;
import com.alipay.oceanbase.rpc.protocol.packet.ObRpcPacketHeader;
import com.alipay.oceanbase.rpc.protocol.payload.ObPayload;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableStreamRequest;
import com.alipay.oceanbase.rpc.threadlocal.ThreadLocalMap;
import com.alipay.oceanbase.rpc.util.ObPureCrc32C;
import com.alipay.remoting.CommandFactory;
import com.alipay.remoting.RemotingCommand;
import com.alipay.remoting.ResponseStatus;
import java.net.InetSocketAddress;
public class ObPacketFactory implements CommandFactory {
/**
* Create request command.
*/
@Override
public ObTablePacket createRequestCommand(Object requestObject) {
if (requestObject instanceof ObPayload) {
ObPayload request = (ObPayload) requestObject;
ObTablePacket obRequest = new ObTablePacket();
obRequest.setCmdCode(ObTablePacketCode.valueOf((short) request.getPcode()));
obRequest.setId(request.getChannelId());
obRequest.setPacketContent(encodePayload(request));
return obRequest;
}
return null;
}
private byte[] encodePayload(ObPayload payload) {
// serialize payload & header
// 1. encode payload
byte[] payloadContent = payload.encode();
/*
* NetPacket -> RpcPacket(HeaderPacket + Payload)
*/
// 2. assemble rpc packet header
ObRpcPacketHeader rpcHeaderPacket = new ObRpcPacketHeader();
rpcHeaderPacket.setPcode(payload.getPcode());
// us
rpcHeaderPacket.setTimeout(payload.getTimeout() * 1000);
rpcHeaderPacket.setTenantId(payload.getTenantId());
// trace
rpcHeaderPacket.setTraceId0(payload.getSequence());
rpcHeaderPacket.setTraceId1(payload.getUniqueId());
if (payload instanceof ObTableStreamRequest) {
rpcHeaderPacket.setSessionId(((ObTableStreamRequest) payload).getSessionId());
rpcHeaderPacket.setFlag(((ObTableStreamRequest) payload).getFlag());
}
rpcHeaderPacket.setPriority(ThreadLocalMap.getProcessPriority());
// compute checksum
rpcHeaderPacket.setChecksum(ObPureCrc32C.calculate(payloadContent));
// 3. assemble and encode rpc packet
ObRpcPacket rpcPacket = new ObRpcPacket();
rpcPacket.setRpcPacketHeader(rpcHeaderPacket);
rpcPacket.setPayloadContent(payloadContent);
return rpcPacket.encode();
}
/**
* Create timeout response.
*/
@Override
public ObTablePacket createTimeoutResponse(InetSocketAddress address) {
return ObTablePacket.createTransportErrorPacket(TransportCodes.BOLT_TIMEOUT,
"connection {" + address.toString() + "} timeout", null);
}
/**
* Create send failed response.
*/
@Override
public ObTablePacket createSendFailedResponse(InetSocketAddress address, Throwable throwable) {
return ObTablePacket.createTransportErrorPacket(TransportCodes.BOLT_SEND_FAILED,
"connection {" + address.toString() + "} send failed", throwable);
}
/**
* TODO tell client this connection has been closed
*/
// TODO for server processor
@Override
public ObTablePacket createExceptionResponse(int id, Throwable t, String errMsg) {
return null;
}
/**
* Create exception response.
*/
@Override
public ObTablePacket createExceptionResponse(int id, ResponseStatus status) {
return null;
}
/**
* Create exception response.
*/
@Override
public ObTablePacket createExceptionResponse(int id, String errMsg) {
return null;
}
/**
* Create response.
*/
@Override
public ObTablePacket createResponse(Object responseObject, RemotingCommand requestCmd) {
return null;
}
/**
* Create exception response.
*/
@Override
public ObTablePacket createExceptionResponse(int id, ResponseStatus status, Throwable t) {
return null;
}
/**
* Create connection closed response.
*/
@Override
public ObTablePacket createConnectionClosedResponse(InetSocketAddress address, String message) {
return null;
}
}

View File

@ -0,0 +1,254 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.transport;
import com.alipay.oceanbase.rpc.exception.*;
import com.alipay.oceanbase.rpc.protocol.payload.impl.login.ObTableLoginRequest;
import com.alipay.oceanbase.rpc.protocol.payload.impl.login.ObTableLoginResult;
import com.alipay.oceanbase.rpc.table.ObTable;
import com.alipay.oceanbase.rpc.util.ObBytesString;
import com.alipay.oceanbase.rpc.util.Security;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import com.alipay.oceanbase.rpc.util.TraceUtil;
import com.alipay.remoting.Connection;
import org.slf4j.Logger;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
public class ObTableConnection {
private static final Logger LOGGER = TableClientLoggerFactory
.getLogger(ObTableConnection.class);
private ObBytesString credential;
private long tenantId = 1; //默认值切勿不要随意改动
private Connection connection;
private final ObTable obTable;
private long uniqueId;
private AtomicLong sequence;
/**
* Ob table connection.
*/
public ObTableConnection(ObTable obTable) {
this.obTable = obTable;
}
/**
* Init.
*/
public void init() throws Exception {
uniqueId = UUID.randomUUID().getMostSignificantBits();
sequence = new AtomicLong();
connect();
}
private synchronized boolean connect() throws Exception {
if (checkAvailable()) { // double check status available
return false;
}
Exception cause = null;
int tries = 0;
int maxTryTimes = obTable.getObTableConnectTryTimes();
for (; tries < maxTryTimes; tries++) {
try {
connection = obTable.getConnectionFactory().createConnection(obTable.getIp(),
obTable.getPort(), obTable.getObTableConnectTimeout());
break;
} catch (Exception e) {
cause = e;
LOGGER.warn(
"connect failed at " + tries + " try " + TraceUtil.formatIpPort(obTable), e);
}
}
if (tries >= maxTryTimes) {
throw new ObTableServerConnectException("connect failed after max " + maxTryTimes
+ " tries " + TraceUtil.formatIpPort(obTable),
cause);
}
// login the server. If login failed, close the raw connection to make the connection creation atomic.
try {
login();
} catch (Exception e) {
close();
throw e;
}
return true;
}
private synchronized void login() throws Exception {
ObTableLoginRequest request = new ObTableLoginRequest();
request.setTenantName(obTable.getTenantName());
request.setUserName(obTable.getUserName());
request.setDatabaseName(obTable.getDatabase());
generatePassSecret(request);
ObTableLoginResult result;
Exception cause = null;
int tries = 0;
int maxTryTimes = obTable.getObTableLoginTryTimes();
for (; tries < maxTryTimes; tries++) {
try {
result = (ObTableLoginResult) obTable.getRealClient().invokeSync(this, request,
obTable.getObTableLoginTimeout());
if (result != null && result.getCredential() != null
&& result.getCredential().length() > 0) {
credential = result.getCredential();
tenantId = result.getTenantId();
break;
}
} catch (Exception e) {
cause = e;
String errMessage = "login failed at " + tries + " try "
+ TraceUtil.formatIpPort(obTable);
LOGGER.warn(errMessage, e);
// no need to retry when the username or password is wrong.
if (e instanceof ObTableAuthException) {
throw new ObTableLoginException(errMessage, e);
}
}
}
if (tries >= maxTryTimes) {
throw new ObTableServerConnectException("login failed after max " + maxTryTimes
+ " tries " + TraceUtil.formatIpPort(obTable),
cause);
}
}
/**
* Close.
*/
public void close() {
if (connection != null) {
connection.close();
connection = null;
credential = null;
}
}
/**
* Check status.
*/
public void checkStatus() throws Exception {
if (connection == null) {
reconnect("Check connection is null");
}
if (connection.getChannel() == null || !connection.getChannel().isActive()) {
reconnect("Check connection failed for address: " + connection.getUrl());
}
if (!connection.getChannel().isWritable()) {
LOGGER.warn("The connection might be write overflow : " + connection.getUrl());
// Wait some interval for the case when a big package is blocking the buffer but server is ok.
// Don't bother to call flush() here as we invoke writeAndFlush() when send request.
Thread.sleep(obTable.getNettyBlockingWaitInterval());
if (!connection.getChannel().isWritable()) {
throw new ObTableConnectionUnWritableException(
"Check connection failed for address: " + connection.getUrl()
+ ", maybe write overflow!");
}
}
}
private void reconnect(String msg) throws Exception {
if (connect()) {
LOGGER.warn("reconnect success. reconnect reason: [{}]", msg);
} else {
LOGGER.warn("connection maybe reconnect by other thread. reconnect reason: [{}]", msg);
}
}
/**
* Get credential.
*/
public ObBytesString getCredential() {
return credential;
}
/**
* Set credential.
*/
public void setCredential(ObBytesString credential) {
this.credential = credential;
}
/**
* Get tenant id.
*/
public long getTenantId() {
return tenantId;
}
/**
* Set tenant id.
*/
public void setTenantId(long tenantId) {
this.tenantId = tenantId;
}
/**
* Get connection.
*/
public Connection getConnection() {
return connection;
}
/**
* Get ob table.
*/
public ObTable getObTable() {
return obTable;
}
private boolean checkAvailable() {
if (connection == null) {
return false;
}
if (connection.getChannel() == null || !connection.getChannel().isActive()) {
return false;
}
if (credential == null) {
return false;
}
return true;
}
private void generatePassSecret(ObTableLoginRequest request) {
ObBytesString scramble = Security.getPasswordScramble(20);
request.setPassSecret(Security.scramblePassword(obTable.getPassword().getBytes(),
scramble.bytes));
request.setPassScramble(scramble);
}
/**
* Get unique id.
*/
public long getUniqueId() {
return uniqueId;
}
/**
* Get next sequence.
*/
public long getNextSequence() {
return sequence.incrementAndGet();
}
}

View File

@ -0,0 +1,114 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.transport;
import com.alipay.oceanbase.rpc.bolt.protocol.ObTablePacket;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import com.alipay.remoting.CommandCode;
import com.alipay.remoting.CommandHandler;
import com.alipay.remoting.RemotingContext;
import com.alipay.remoting.RemotingProcessor;
import com.alipay.remoting.rpc.RpcCommand;
import org.slf4j.Logger;
import java.util.List;
import java.util.concurrent.ExecutorService;
import static com.alipay.oceanbase.rpc.util.TableClientLoggerFactory.LCD;
public class ObTablePacketHandler implements CommandHandler {
private static final Logger logger = TableClientLoggerFactory
.getLogger(ObTablePacketHandler.class);
/**
* Unlike {@link com.alipay.remoting.rpc.protocol.RpcCommandHandler}, ObTable client only decodes ObNetPacket, it only has 16 bytes,
* and all content will decode it in biz thread by {@link ObTableRemoting}.
* So this class has no ProcessorManager logic
*/
private final ObTablePacketProcessor processor;
/**
* Ob table packet handler.
*/
public ObTablePacketHandler() {
this.processor = new ObTablePacketProcessor();
}
/**
* Handle command.
*/
@Override
public void handleCommand(final RemotingContext ctx, final Object msg) {
try {
if (msg instanceof List) {
if (logger.isDebugEnabled()) {
logger.debug("Batch message! size={}", ((List<?>) msg).size());
}
for (Object m : (List<?>) msg) {
processor.process(ctx, (ObTablePacket) m, null);
}
} else {
processor.process(ctx, (ObTablePacket) msg, null);
}
} catch (Throwable e) {
processException(msg, e);
}
}
private void processException(Object msg, Throwable t) {
if (msg instanceof List) {
for (Object m : (List<?>) msg) {
processExceptionForSingleCommand(m, t);
}
} else {
processExceptionForSingleCommand(msg, t);
}
}
private void processExceptionForSingleCommand(Object msg, Throwable t) {
final int id = ((RpcCommand) msg).getId();
logger.error(LCD.convert("01-00021"), id, t);
}
/**
* Register processor.
*/
@Override
public void registerProcessor(CommandCode cmd, RemotingProcessor<?> processor) {
throw new IllegalArgumentException("not support yet");
}
/**
* Register default executor.
*/
@Override
public void registerDefaultExecutor(ExecutorService executor) {
throw new IllegalArgumentException("not support yet");
}
/**
* Get default executor.
*/
@Override
public ExecutorService getDefaultExecutor() {
throw new IllegalArgumentException("not support yet");
}
}

View File

@ -0,0 +1,90 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.transport;
import com.alipay.oceanbase.rpc.bolt.protocol.ObTablePacket;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import com.alipay.remoting.Connection;
import com.alipay.remoting.InvokeFuture;
import com.alipay.remoting.RemotingContext;
import com.alipay.remoting.RemotingProcessor;
import com.alipay.remoting.util.RemotingUtil;
import org.slf4j.Logger;
import java.util.concurrent.ExecutorService;
import static com.alipay.oceanbase.rpc.util.TableClientLoggerFactory.LCD;
public class ObTablePacketProcessor implements RemotingProcessor<ObTablePacket> {
private static final Logger logger = TableClientLoggerFactory
.getLogger(ObTablePacketProcessor.class);
/**
* Process.
*/
@Override
public void process(RemotingContext ctx, ObTablePacket msg, ExecutorService defaultExecutor) {
Connection conn = ctx.getChannelContext().channel().attr(Connection.CONNECTION).get();
InvokeFuture future = conn.removeInvokeFuture(msg.getId());
ClassLoader oldClassLoader = null;
try {
if (future != null) {
if (future.getAppClassLoader() != null) {
oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(future.getAppClassLoader());
}
future.putResponse(msg);
future.cancelTimeout();
try {
future.executeInvokeCallback();
} catch (Exception e) {
logger.error(LCD.convert("01-00022"), msg.getId(), e);
}
} else {
logger
.warn("Cannot find InvokeFuture, maybe already timeout, id={}, from={} ",
msg.getId(),
RemotingUtil.parseRemoteAddress(ctx.getChannelContext().channel()));
}
} finally {
if (null != oldClassLoader) {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
}
}
/**
* Get executor.
*/
@Override
public ExecutorService getExecutor() {
return null;
}
/**
* Set executor.
*/
@Override
public void setExecutor(ExecutorService executor) {
}
}

View File

@ -0,0 +1,156 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.transport;
import com.alipay.oceanbase.rpc.bolt.protocol.ObTablePacket;
import com.alipay.oceanbase.rpc.bolt.protocol.ObTablePacketCode;
import com.alipay.oceanbase.rpc.exception.ExceptionUtil;
import com.alipay.oceanbase.rpc.exception.ObTableRoutingWrongException;
import com.alipay.oceanbase.rpc.exception.ObTableUnexpectedException;
import com.alipay.oceanbase.rpc.protocol.payload.AbstractPayload;
import com.alipay.oceanbase.rpc.protocol.payload.Credentialable;
import com.alipay.oceanbase.rpc.protocol.payload.ObPayload;
import com.alipay.oceanbase.rpc.protocol.payload.ObRpcResultCode;
import com.alipay.oceanbase.rpc.util.ObPureCrc32C;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import com.alipay.oceanbase.rpc.util.TraceUtil;
import com.alipay.remoting.*;
import com.alipay.remoting.exception.RemotingException;
import io.netty.buffer.ByteBuf;
import org.slf4j.Logger;
public class ObTableRemoting extends BaseRemoting {
private static final Logger logger = TableClientLoggerFactory.getLogger(ObTableRemoting.class);
/**
* Ob table remoting.
*/
public ObTableRemoting(CommandFactory commandFactory) {
super(commandFactory);
}
/**
* Invoke sync.
*/
public ObPayload invokeSync(final ObTableConnection conn, final ObPayload request,
final int timeoutMillis) throws RemotingException,
InterruptedException {
request.setSequence(conn.getNextSequence());
request.setUniqueId(conn.getUniqueId());
if (request instanceof Credentialable) {
((Credentialable) request).setCredential(conn.getCredential());
}
if (request instanceof AbstractPayload) {
((AbstractPayload) request).setTenantId(conn.getTenantId());
}
ObTablePacket obRequest = this.getCommandFactory().createRequestCommand(request);
ObTablePacket response = (ObTablePacket) super.invokeSync(conn.getConnection(), obRequest,
timeoutMillis);
if (response == null) {
String errMessage = TraceUtil.formatTraceMessage(conn, request, "get null response");
logger.warn(errMessage);
ExceptionUtil.throwObTableTransportException(errMessage,
TransportCodes.BOLT_RESPONSE_NULL);
return null;
} else if (!response.isSuccess()) {
String errMessage = TraceUtil.formatTraceMessage(conn, request,
"get an error response: " + response.getMessage());
logger.warn(errMessage);
ExceptionUtil.throwObTableTransportException(errMessage, response.getTransportCode());
return null;
}
try {
// decode packet header first
response.decodePacketHeader();
ByteBuf buf = response.getPacketContentBuf();
// If response indicates the request is routed to wrong server, we should refresh the routing meta.
if (response.getHeader().isRoutingWrong()) {
String errMessage = TraceUtil.formatTraceMessage(conn, request,
"routed to the wrong server: " + response.getMessage());
logger.warn(errMessage);
throw new ObTableRoutingWrongException(errMessage);
}
// verify checksum
long expected_checksum = response.getHeader().getChecksum();
byte[] content = new byte[buf.readableBytes()];
buf.getBytes(buf.readerIndex(), content);
if (ObPureCrc32C.calculate(content) != expected_checksum) {
String errMessage = TraceUtil.formatTraceMessage(conn, request,
"get response with checksum error: " + response.getMessage());
logger.warn(errMessage);
ExceptionUtil.throwObTableTransportException(errMessage,
TransportCodes.BOLT_CHECKSUM_ERR);
return null;
}
// decode ResultCode for response packet
ObRpcResultCode resultCode = new ObRpcResultCode();
resultCode.decode(buf);
if (resultCode.getRcode() != 0) {
ExceptionUtil.throwObTableException(conn.getObTable().getIp(), conn.getObTable()
.getPort(), response.getHeader().getTraceId0(), response.getHeader()
.getTraceId1(), resultCode.getRcode());
return null;
}
// decode payload itself
ObPayload payload;
if (response.getCmdCode() instanceof ObTablePacketCode) {
payload = ((ObTablePacketCode) response.getCmdCode()).newPayload(response
.getHeader());
payload.setSequence(response.getHeader().getTraceId0());
payload.setUniqueId(response.getHeader().getTraceId1());
} else {
String errMessage = TraceUtil.formatTraceMessage(conn, response,
"receive unexpected command code: " + response.getCmdCode().value());
throw new ObTableUnexpectedException(errMessage);
}
payload.decode(buf);
return payload;
} finally {
// Very important to release ByteBuf memory
response.releaseByteBuf();
}
}
@Override
protected InvokeFuture createInvokeFuture(RemotingCommand request, InvokeContext invokeContext) {
return new ObClientFuture(request.getId());
}
@Override
protected InvokeFuture createInvokeFuture(Connection conn, RemotingCommand request,
InvokeContext invokeContext,
InvokeCallback invokeCallback) {
return new ObClientFuture(request.getId());
}
}

View File

@ -0,0 +1,28 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.bolt.transport;
public interface TransportCodes {
int BOLT_TIMEOUT = -20002;
int BOLT_SEND_FAILED = -20003;
int BOLT_RESPONSE_NULL = -20001;
int BOLT_CHECKSUM_ERR = -20004;
}

View File

@ -0,0 +1,35 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.constant;
public interface Constants {
String OB_TABLE_CLIENT_PREFIX = "ob.table.client.";
String EMPTY_STRING = "";
String SYS_TENANT = "sys";
String PASSWORD = "password";
String DATABASE = "database";
String PROXY_SYS_USER_NAME = "proxyro@sys";
String OCEANBASE_DATABASE = "oceanbase";
String ALL_DUMMY_TABLE = "__all_dummy";
String READ_CONSISTENCY = "read_consistency";
String OB_ROUTE_POLICY = "ob_route_policy";
String OCP_ROOT_SERVICE_ACTION = "ObRootServiceInfo";
String OCP_IDC_REGION_ACTION = "ObIDCRegionInfo";
}

View File

@ -0,0 +1,167 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
import com.alipay.oceanbase.rpc.bolt.transport.TransportCodes;
import com.alipay.oceanbase.rpc.protocol.payload.ResultCodes;
import static com.alipay.oceanbase.rpc.protocol.payload.ResultCodes.OB_DESERIALIZE_ERROR;
public class ExceptionUtil {
/**
* throw ObTableException based on error code
* TODO 错误信息这里应该要加上表名/字段等但是报错的地方没有表名上下文比较麻烦
*
* @param errorCode error code return from Ob Server
*/
public static void throwObTableException(int errorCode) {
ResultCodes resultCodes = ResultCodes.valueOf(errorCode);
if (resultCodes != ResultCodes.OB_SUCCESS) {
throw convertToObTableException("", 0, 0, 0, resultCodes);
}
}
/**
* throw ObTableException based on error code
* TODO 错误信息这里应该要加上表名/字段等但是报错的地方没有表名上下文比较麻烦
*
* @param errorCode error code return from Ob Server
*/
public static void throwObTableException(String host, int port, long sequence, long uniqueId,
int errorCode) {
ResultCodes resultCodes = ResultCodes.valueOf(errorCode);
if (resultCodes != ResultCodes.OB_SUCCESS) {
throw convertToObTableException(host, port, sequence, uniqueId, resultCodes);
}
}
/**
* throw ObTableException based on error code
* TODO 错误信息这里应该要加上表名/字段等但是报错的地方没有表名上下文比较麻烦
*
* @param resultCodes error code return from Ob Server
*/
public static ObTableException convertToObTableException(String host, int port, long sequence,
long uniqueId, ResultCodes resultCodes) {
String trace = String.format("Y%X-%016X", sequence, uniqueId);
String server = host + ":" + port;
switch (resultCodes) {
case OB_ERR_PRIMARY_KEY_DUPLICATE:
return new ObTableDuplicateKeyException("[" + trace + "] [" + resultCodes.name()
+ "] server [" + server + "] ",
resultCodes.errorCode);
case OB_ERR_UNKNOWN_TABLE:
return new ObTableNotExistException("[" + trace
+ "] [OB_ERR_UNKNOWN_TABLE] server [" + server
+ "]table not exist", resultCodes.errorCode);
case OB_ERR_COLUMN_NOT_FOUND:
return new ObTableException("[" + trace + "] [OB_ERR_COLUMN_NOT_FOUND] server ["
+ server + "]column not found", resultCodes.errorCode);
case OB_OBJ_TYPE_ERROR:
return new ObTableException("[" + trace + "] [OB_OBJ_TYPE_ERROR] server [" + server
+ "]rowkey/column type not match",
resultCodes.errorCode);
case OB_BAD_NULL_ERROR:
return new ObTableException("[" + trace + "] [OB_BAD_NULL_ERROR] server [" + server
+ "]column doesn't have a default value",
resultCodes.errorCode);
case OB_INVALID_ARGUMENT:
return new ObTableException("[" + trace + "] [OB_INVALID_ARGUMENT] server ["
+ server + "]ob table arguments invalid",
resultCodes.errorCode);
case OB_DESERIALIZE_ERROR: // 用户名错误是这个异常码
return new ObTableAuthException("[" + trace + "] [OB_DESERIALIZE_ERROR] server ["
+ server + "]maybe invalid username, errorCode: "
+ OB_DESERIALIZE_ERROR, resultCodes.errorCode);
case OB_PASSWORD_WRONG:
return new ObTableAuthException("[" + trace + "] [OB_PASSWORD_WRONG] server ["
+ server + "]access deny", resultCodes.errorCode);
case OB_LOCATION_LEADER_NOT_EXIST:
case OB_NOT_MASTER:
case OB_RS_NOT_MASTER:
case OB_RS_SHUTDOWN:
return new ObTableMasterChangeException("[" + trace + "] [" + resultCodes.name()
+ "] server [" + server + "]",
resultCodes.errorCode);
case OB_RPC_CONNECT_ERROR:
return new ObTableServerDownException("[" + trace + "] [" + resultCodes.name()
+ "] server [" + server + "]",
resultCodes.errorCode);
case OB_PARTITION_NOT_EXIST:
case OB_PARTITION_IS_STOPPED:
case OB_LOCATION_NOT_EXIST:
return new ObTablePartitionChangeException("[" + trace + "] [" + resultCodes.name()
+ "] server [" + server + "]",
resultCodes.errorCode);
case OB_SERVER_IS_INIT:
case OB_SERVER_IS_STOPPING:
return new ObTableServerStatusChangeException("[" + trace + "] ["
+ resultCodes.name() + "] server ["
+ server + "]", resultCodes.errorCode);
case OB_TENANT_NOT_IN_SERVER:
return new ObTableUnitMigrateException("[" + trace + "] [" + resultCodes.name()
+ "] server [" + server + "]",
resultCodes.errorCode);
case OB_TRANS_RPC_TIMEOUT:
return new ObTableTransactionRpcTimeout("[" + trace + "] [" + resultCodes.name()
+ "] server [" + server + "]",
resultCodes.errorCode);
case OB_NO_READABLE_REPLICA:
return new ObTableNoReadableReplicaException("[" + trace + "] ["
+ resultCodes.name() + "] server ["
+ server + "]", resultCodes.errorCode);
case OB_REPLICA_NOT_READABLE:
return new ObTableReplicaNotReadableException("[" + trace + "] ["
+ resultCodes.name() + "] server ["
+ server + "]", resultCodes.errorCode);
case OB_TIMEOUT:
case OB_TRANS_TIMEOUT:
case OB_WAITQUEUE_TIMEOUT:
return new ObTableServerTimeoutException("[" + trace + "] [" + resultCodes.name()
+ "] server [" + server + "]",
resultCodes.errorCode);
default:
return new ObTableUnexpectedException("[" + trace + "] [" + resultCodes.name()
+ "] server [" + server + "]",
resultCodes.errorCode);
}
}
/**
* throw ObTableTransportException based on transport error code
* TODO 错误信息这里应该要加上表名/字段等但是报错的地方没有表名上下文比较麻烦
*
* @param errorCode transport error code return from BOLT framework
*/
public static void throwObTableTransportException(String message, int errorCode) {
switch (errorCode) {
case 0:
return;
case TransportCodes.BOLT_TIMEOUT:
case TransportCodes.BOLT_SEND_FAILED:
case TransportCodes.BOLT_RESPONSE_NULL:
case TransportCodes.BOLT_CHECKSUM_ERR:
throw new ObTableTransportException(message, errorCode);
default:
throw new ObTableTransportException("unexpected transport exception: " + errorCode,
errorCode);
}
}
}

View File

@ -0,0 +1,73 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class FeatureNotSupportedException extends RuntimeException {
private int errorCode;
/**
* Feature not supported exception.
*/
public FeatureNotSupportedException() {
}
/**
* Feature not supported exception.
*/
public FeatureNotSupportedException(int errorCode) {
this("error code: " + errorCode, errorCode);
}
/**
* Feature not supported exception.
*/
public FeatureNotSupportedException(String message, int errorCode) {
this(message);
this.errorCode = errorCode;
}
/**
* Feature not supported exception.
*/
public FeatureNotSupportedException(String message) {
super(message);
}
/**
* Feature not supported exception.
*/
public FeatureNotSupportedException(String message, Throwable cause) {
super(message, cause);
}
/**
* Feature not supported exception.
*/
public FeatureNotSupportedException(Throwable cause) {
super(cause);
}
/**
* Get error code.
*/
public int getErrorCode() {
return errorCode;
}
}

View File

@ -0,0 +1,73 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class GenerateColumnParseException extends RuntimeException {
private int errorCode;
/**
* Generate column parse exception.
*/
public GenerateColumnParseException() {
}
/**
* Generate column parse exception.
*/
public GenerateColumnParseException(int errorCode) {
this("error code: " + errorCode, errorCode);
}
/**
* Generate column parse exception.
*/
public GenerateColumnParseException(String message, int errorCode) {
this(message);
this.errorCode = errorCode;
}
/**
* Generate column parse exception.
*/
public GenerateColumnParseException(String message) {
super(message);
}
/**
* Generate column parse exception.
*/
public GenerateColumnParseException(String message, Throwable cause) {
super(message, cause);
}
/**
* Generate column parse exception.
*/
public GenerateColumnParseException(Throwable cause) {
super(cause);
}
/**
* Get error code.
*/
public int getErrorCode() {
return errorCode;
}
}

View File

@ -0,0 +1,73 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObShardTableException extends RuntimeException {
private int errorCode;
/**
* Ob shard table exception.
*/
public ObShardTableException() {
}
/**
* Ob shard table exception.
*/
public ObShardTableException(int errorCode) {
this("error code: " + errorCode, errorCode);
}
/**
* Ob shard table exception.
*/
public ObShardTableException(String message, int errorCode) {
this(message);
this.errorCode = errorCode;
}
/**
* Ob shard table exception.
*/
public ObShardTableException(String message) {
super(message);
}
/**
* Ob shard table exception.
*/
public ObShardTableException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob shard table exception.
*/
public ObShardTableException(Throwable cause) {
super(cause);
}
/**
* Get error code.
*/
public int getErrorCode() {
return errorCode;
}
}

View File

@ -0,0 +1,63 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableAuthException extends ObTableException {
/**
* Ob table auth exception.
*/
public ObTableAuthException() {
}
/**
* Ob table auth exception.
*/
public ObTableAuthException(int errorCode) {
super(errorCode);
}
/**
* Ob table auth exception.
*/
public ObTableAuthException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table auth exception.
*/
public ObTableAuthException(String message) {
super(message);
}
/**
* Ob table auth exception.
*/
public ObTableAuthException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table auth exception.
*/
public ObTableAuthException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,62 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableCloseException extends ObTableException {
/**
* Ob table close exception.
*/
public ObTableCloseException() {
}
/**
* Ob table close exception.
*/
public ObTableCloseException(int errorCode) {
super(errorCode);
}
/**
* Ob table close exception.
*/
public ObTableCloseException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table close exception.
*/
public ObTableCloseException(String message) {
super(message);
}
/**
* Ob table close exception.
*/
public ObTableCloseException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table close exception.
*/
public ObTableCloseException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,61 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableConnectionStatusException extends ObTableException {
/**
* Ob table connection status exception.
*/
public ObTableConnectionStatusException() {
}
/**
* Ob table connection status exception with error code.
*/
public ObTableConnectionStatusException(int errorCode) {
super(errorCode);
}
/**
* Ob table connection status exception with message and error code.
*/
public ObTableConnectionStatusException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table connection status exception with message.
*/
public ObTableConnectionStatusException(String message) {
super(message);
}
/**
* Ob table connection status exception with message and cause.
*/
public ObTableConnectionStatusException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table connection status exception with cause.
*/
public ObTableConnectionStatusException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,61 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableConnectionUnWritableException extends ObTableException {
/**
* Ob table connection un-writable exception.
*/
public ObTableConnectionUnWritableException() {
}
/**
* Ob table connection un-writable exception with error code
*/
public ObTableConnectionUnWritableException(int errorCode) {
super(errorCode);
}
/**
* Ob table connection un-writable exception with message and error code.
*/
public ObTableConnectionUnWritableException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table connection un-writable exception with message.
*/
public ObTableConnectionUnWritableException(String message) {
super(message);
}
/**
* Ob table connection un-writable exception with message and cause.
*/
public ObTableConnectionUnWritableException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table connection un-writable exception with cause.
*/
public ObTableConnectionUnWritableException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,64 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableDuplicateKeyException extends ObTableException {
/**
* Ob table duplicate key exception.
*/
public ObTableDuplicateKeyException() {
}
/**
* Ob table duplicate key exception.
*/
public ObTableDuplicateKeyException(int errorCode) {
super(errorCode);
}
/**
* Ob table duplicate key exception.
*/
public ObTableDuplicateKeyException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table duplicate key exception.
*/
public ObTableDuplicateKeyException(String message) {
super(message);
}
/**
* Ob table duplicate key exception.
*/
public ObTableDuplicateKeyException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table duplicate key exception.
*/
public ObTableDuplicateKeyException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,70 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableEntryRefreshException extends ObTableException {
/**
* Ob table entry refresh exception.
*/
public ObTableEntryRefreshException() {
}
/**
* Ob table entry refresh exception.
*/
public ObTableEntryRefreshException(int errorCode) {
super(errorCode);
}
/**
* Ob table entry refresh exception.
*/
public ObTableEntryRefreshException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table entry refresh exception.
*/
public ObTableEntryRefreshException(String message) {
super(message);
}
/**
* Ob table entry refresh exception.
*/
public ObTableEntryRefreshException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table entry refresh exception.
*/
public ObTableEntryRefreshException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
@Override
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,85 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableException extends RuntimeException {
private int errorCode;
private boolean needRefreshTableEntry;
/**
* Ob table exception.
*/
public ObTableException() {
}
/**
* Ob table exception.
*/
public ObTableException(int errorCode) {
this("error code: " + errorCode, errorCode);
}
/**
* Ob table exception.
*/
public ObTableException(String message, int errorCode) {
this(message);
this.errorCode = errorCode;
}
/**
* Ob table exception.
*/
public ObTableException(String message) {
super(message);
}
/**
* Ob table exception.
*/
public ObTableException(String message, Throwable cause) {
super(message, cause);
if (cause instanceof ObTableException) {
errorCode = ((ObTableException) cause).getErrorCode();
needRefreshTableEntry = ((ObTableException) cause).isNeedRefreshTableEntry();
}
}
/**
* Ob table exception.
*/
public ObTableException(Throwable cause) {
super(cause);
}
/**
* Get error code.
*/
public int getErrorCode() {
return errorCode;
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return needRefreshTableEntry;
}
}

View File

@ -0,0 +1,63 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableGetException extends ObTableException {
/**
* Ob table get exception.
*/
public ObTableGetException() {
}
/**
* Ob table get exception.
*/
public ObTableGetException(int errorCode) {
super(errorCode);
}
/**
* Ob table get exception.
*/
public ObTableGetException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table get exception.
*/
public ObTableGetException(String message) {
super(message);
}
/**
* Ob table get exception.
*/
public ObTableGetException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table get exception.
*/
public ObTableGetException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,63 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableLoginException extends ObTableException {
/**
* Ob table login exception.
*/
public ObTableLoginException() {
}
/**
* Ob table login exception.
*/
public ObTableLoginException(int errorCode) {
super(errorCode);
}
/**
* Ob table login exception.
*/
public ObTableLoginException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table login exception.
*/
public ObTableLoginException(String message) {
super(message);
}
/**
* Ob table login exception.
*/
public ObTableLoginException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table login exception.
*/
public ObTableLoginException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,69 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableMasterChangeException extends ObTableException {
/**
* Ob table master change exception.
*/
public ObTableMasterChangeException() {
}
/**
* Ob table master change exception.
*/
public ObTableMasterChangeException(int errorCode) {
super(errorCode);
}
/**
* Ob table master change exception.
*/
public ObTableMasterChangeException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table master change exception.
*/
public ObTableMasterChangeException(String message) {
super(message);
}
/**
* Ob table master change exception.
*/
public ObTableMasterChangeException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table master change exception.
*/
public ObTableMasterChangeException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,63 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableNoMasterException extends ObTableException {
/**
* Ob table no master exception.
*/
public ObTableNoMasterException() {
}
/**
* Ob table no master exception.
*/
public ObTableNoMasterException(int errorCode) {
super(errorCode);
}
/**
* Ob table no master exception.
*/
public ObTableNoMasterException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table no master exception.
*/
public ObTableNoMasterException(String message) {
super(message);
}
/**
* Ob table no master exception.
*/
public ObTableNoMasterException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table no master exception.
*/
public ObTableNoMasterException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,69 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableNoReadableReplicaException extends ObTableException {
/**
* Ob table no readable replica exception.
*/
public ObTableNoReadableReplicaException() {
}
/**
* Ob table no readable replica exception.
*/
public ObTableNoReadableReplicaException(int errorCode) {
super(errorCode);
}
/**
* Ob table no readable replica exception.
*/
public ObTableNoReadableReplicaException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table no readable replica exception.
*/
public ObTableNoReadableReplicaException(String message) {
super(message);
}
/**
* Ob table no readable replica exception.
*/
public ObTableNoReadableReplicaException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table no readable replica exception.
*/
public ObTableNoReadableReplicaException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,62 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableNotExistException extends ObTableEntryRefreshException {
/**
* Ob table not exist exception.
*/
public ObTableNotExistException() {
}
/**
* Ob table not exist exception.
*/
public ObTableNotExistException(int errorCode) {
super(errorCode);
}
/**
* Ob table not exist exception.
*/
public ObTableNotExistException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table not exist exception.
*/
public ObTableNotExistException(String message) {
super(message);
}
/**
* Ob table not exist exception.
*/
public ObTableNotExistException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table not exist exception.
*/
public ObTableNotExistException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,70 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTablePartitionChangeException extends ObTableException {
/**
* Ob table partition change exception.
*/
public ObTablePartitionChangeException() {
}
/**
* Ob table partition change exception.
*/
public ObTablePartitionChangeException(int errorCode) {
super(errorCode);
}
/**
* Ob table partition change exception.
*/
public ObTablePartitionChangeException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table partition change exception.
*/
public ObTablePartitionChangeException(String message) {
super(message);
}
/**
* Ob table partition change exception.
*/
public ObTablePartitionChangeException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table partition change exception.
*/
public ObTablePartitionChangeException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,73 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTablePartitionConsistentException extends RuntimeException {
private int errorCode;
/**
* Ob table partition consistent exception.
*/
public ObTablePartitionConsistentException() {
}
/**
* Ob table partition consistent exception.
*/
public ObTablePartitionConsistentException(int errorCode) {
this("error code: " + errorCode, errorCode);
}
/**
* Ob table partition consistent exception.
*/
public ObTablePartitionConsistentException(String message, int errorCode) {
this(message);
this.errorCode = errorCode;
}
/**
* Ob table partition consistent exception.
*/
public ObTablePartitionConsistentException(String message) {
super(message);
}
/**
* Ob table partition consistent exception.
*/
public ObTablePartitionConsistentException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table partition consistent exception.
*/
public ObTablePartitionConsistentException(Throwable cause) {
super(cause);
}
/**
* Get error code.
*/
public int getErrorCode() {
return errorCode;
}
}

View File

@ -0,0 +1,61 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTablePartitionInfoRefreshException extends ObTableEntryRefreshException {
/**
* Ob table partition info refresh exception.
*/
public ObTablePartitionInfoRefreshException() {
}
/**
* Ob table partition info refresh exception.
*/
public ObTablePartitionInfoRefreshException(int errorCode) {
super(errorCode);
}
/**
* Ob table partition info refresh exception.
*/
public ObTablePartitionInfoRefreshException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table partition info refresh exception.
*/
public ObTablePartitionInfoRefreshException(String message) {
super(message);
}
/**
* Ob table partition info refresh exception.
*/
public ObTablePartitionInfoRefreshException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table partition info refresh exception.
*/
public ObTablePartitionInfoRefreshException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,70 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTablePartitionLocationRefreshException extends ObTableException {
/**
* Ob table partition location refresh exception.
*/
public ObTablePartitionLocationRefreshException() {
}
/**
* Ob table partition location refresh exception.
*/
public ObTablePartitionLocationRefreshException(int errorCode) {
super(errorCode);
}
/**
* Ob table partition location refresh exception.
*/
public ObTablePartitionLocationRefreshException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table partition location refresh exception.
*/
public ObTablePartitionLocationRefreshException(String message) {
super(message);
}
/**
* Ob table partition location refresh exception.
*/
public ObTablePartitionLocationRefreshException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table partition location refresh exception.
*/
public ObTablePartitionLocationRefreshException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
@Override
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,68 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTablePartitionNoMasterException extends ObTablePartitionLocationRefreshException {
/**
* Ob table partition no master exception.
*/
public ObTablePartitionNoMasterException() {
}
/**
* Ob table partition no master exception.
*/
public ObTablePartitionNoMasterException(int errorCode) {
super(errorCode);
}
/**
* Ob table partition no master exception.
*/
public ObTablePartitionNoMasterException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table partition no master exception.
*/
public ObTablePartitionNoMasterException(String message) {
super(message);
}
/**
* Ob table partition no master exception.
*/
public ObTablePartitionNoMasterException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table partition no master exception.
*/
public ObTablePartitionNoMasterException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,61 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTablePartitionNotExistException extends ObTablePartitionLocationRefreshException {
/**
* Ob table partition not exist exception.
*/
public ObTablePartitionNotExistException() {
}
/**
* Ob table partition not exist exception.
*/
public ObTablePartitionNotExistException(int errorCode) {
super(errorCode);
}
/**
* Ob table partition not exist exception.
*/
public ObTablePartitionNotExistException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table partition not exist exception.
*/
public ObTablePartitionNotExistException(String message) {
super(message);
}
/**
* Ob table partition not exist exception.
*/
public ObTablePartitionNotExistException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table partition not exist exception.
*/
public ObTablePartitionNotExistException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,69 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableReplicaNotReadableException extends ObTableException {
/**
* Ob replica not readable exception.
*/
public ObTableReplicaNotReadableException() {
}
/**
* Ob replica not readable exception.
*/
public ObTableReplicaNotReadableException(int errorCode) {
super(errorCode);
}
/**
* Ob replica not readable exception.
*/
public ObTableReplicaNotReadableException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob replica not readable exception.
*/
public ObTableReplicaNotReadableException(String message) {
super(message);
}
/**
* Ob replica not readable exception.
*/
public ObTableReplicaNotReadableException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob replica not readable exception.
*/
public ObTableReplicaNotReadableException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return false;
}
}

View File

@ -0,0 +1,61 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableRetryExhaustedException extends ObTableException {
/**
* Ob table retry exhausted exception.
*/
public ObTableRetryExhaustedException() {
}
/**
* Ob table retry exhausted exception.
*/
public ObTableRetryExhaustedException(int errorCode) {
super(errorCode);
}
/**
* Ob table retry exhausted exception.
*/
public ObTableRetryExhaustedException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table retry exhausted exception.
*/
public ObTableRetryExhaustedException(String message) {
super(message);
}
/**
* Ob table retry exhausted exception.
*/
public ObTableRetryExhaustedException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table retry exhausted exception.
*/
public ObTableRetryExhaustedException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,68 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableRoutingWrongException extends ObTableException {
/**
* Ob table routing wrong exception.
*/
public ObTableRoutingWrongException() {
}
/**
* Ob table routing wrong exception with error code.
*/
public ObTableRoutingWrongException(int errorCode) {
super(errorCode);
}
/**
* Ob table routing wrong exception with message and error code.
*/
public ObTableRoutingWrongException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table routing wrong exception with message.
*/
public ObTableRoutingWrongException(String message) {
super(message);
}
/**
* Ob table routing wrong exception with message and cause.
*/
public ObTableRoutingWrongException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table routing wrong exception with cause.
*/
public ObTableRoutingWrongException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,68 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableServerCacheExpiredException extends ObTableException {
/**
* Ob table server cache expired exception.
*/
public ObTableServerCacheExpiredException() {
}
/**
* Ob table server cache expired exception with error code.
*/
public ObTableServerCacheExpiredException(int errorCode) {
super(errorCode);
}
/**
* Ob table server cache expired exception with message and error code.
*/
public ObTableServerCacheExpiredException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table server cache expired exception with message.
*/
public ObTableServerCacheExpiredException(String message) {
super(message);
}
/**
* Ob table server cache expired exception with message and cause.
*/
public ObTableServerCacheExpiredException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table server cache expired exception with cause.
*/
public ObTableServerCacheExpiredException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,69 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableServerConnectException extends ObTableException {
/**
* Ob table server connect exception.
*/
public ObTableServerConnectException() {
}
/**
* Ob table server connect exception.
*/
public ObTableServerConnectException(int errorCode) {
super(errorCode);
}
/**
* Ob table server connect exception.
*/
public ObTableServerConnectException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table server connect exception.
*/
public ObTableServerConnectException(String message) {
super(message);
}
/**
* Ob table server connect exception.
*/
public ObTableServerConnectException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table server connect exception.
*/
public ObTableServerConnectException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,69 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableServerDownException extends ObTableException {
/**
* Ob table server down exception.
*/
public ObTableServerDownException() {
}
/**
* Ob table server down exception.
*/
public ObTableServerDownException(int errorCode) {
super(errorCode);
}
/**
* Ob table server down exception.
*/
public ObTableServerDownException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table server down exception.
*/
public ObTableServerDownException(String message) {
super(message);
}
/**
* Ob table server down exception.
*/
public ObTableServerDownException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table server down exception.
*/
public ObTableServerDownException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,69 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableServerStatusChangeException extends ObTableException {
/**
* Ob table server status change exception.
*/
public ObTableServerStatusChangeException() {
}
/**
* Ob table server status change exception.
*/
public ObTableServerStatusChangeException(int errorCode) {
super(errorCode);
}
/**
* Ob table server status change exception.
*/
public ObTableServerStatusChangeException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table server status change exception.
*/
public ObTableServerStatusChangeException(String message) {
super(message);
}
/**
* Ob table server status change exception.
*/
public ObTableServerStatusChangeException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table server status change exception.
*/
public ObTableServerStatusChangeException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,63 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableServerTimeoutException extends ObTableException {
/**
* Ob table server timeout exception.
*/
public ObTableServerTimeoutException() {
}
/**
* Ob table server timeout exception.
*/
public ObTableServerTimeoutException(int errorCode) {
super(errorCode);
}
/**
* Ob table server timeout exception.
*/
public ObTableServerTimeoutException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table server timeout exception.
*/
public ObTableServerTimeoutException(String message) {
super(message);
}
/**
* Ob table server timeout exception.
*/
public ObTableServerTimeoutException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table server timeout exception.
*/
public ObTableServerTimeoutException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,61 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableTimeoutExcetion extends ObTableException {
/**
* Ob table timeout excetion.
*/
public ObTableTimeoutExcetion() {
}
/**
* Ob table timeout excetion.
*/
public ObTableTimeoutExcetion(int errorCode) {
super(errorCode);
}
/**
* Ob table timeout excetion.
*/
public ObTableTimeoutExcetion(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table timeout excetion.
*/
public ObTableTimeoutExcetion(String message) {
super(message);
}
/**
* Ob table timeout excetion.
*/
public ObTableTimeoutExcetion(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table timeout excetion.
*/
public ObTableTimeoutExcetion(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,69 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableTransactionRpcTimeout extends ObTableException {
/**
* Ob table transaction rpc timeout.
*/
public ObTableTransactionRpcTimeout() {
}
/**
* Ob table transaction rpc timeout.
*/
public ObTableTransactionRpcTimeout(int errorCode) {
super(errorCode);
}
/**
* Ob table transaction rpc timeout.
*/
public ObTableTransactionRpcTimeout(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table transaction rpc timeout.
*/
public ObTableTransactionRpcTimeout(String message) {
super(message);
}
/**
* Ob table transaction rpc timeout.
*/
public ObTableTransactionRpcTimeout(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table transaction rpc timeout.
*/
public ObTableTransactionRpcTimeout(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

View File

@ -0,0 +1,73 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
import com.alipay.oceanbase.rpc.bolt.transport.TransportCodes;
public class ObTableTransportException extends ObTableException {
/**
* Ob table transport exception.
*/
public ObTableTransportException() {
}
/**
* Ob table transport exception.
*/
public ObTableTransportException(int errorCode) {
super(errorCode);
}
/**
* Ob table transport exception.
*/
public ObTableTransportException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table transport exception.
*/
public ObTableTransportException(String message) {
super(message);
}
/**
* Ob table transport exception.
*/
public ObTableTransportException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table transport exception.
*/
public ObTableTransportException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
@Override
public boolean isNeedRefreshTableEntry() {
// send failed should refresh table entry
return getErrorCode() == TransportCodes.BOLT_SEND_FAILED;
}
}

View File

@ -0,0 +1,64 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableUnexpectedException extends ObTableException {
/**
* Ob table unexpected exception.
*/
public ObTableUnexpectedException() {
}
/**
* Ob table unexpected exception.
*/
public ObTableUnexpectedException(int errorCode) {
super(errorCode);
}
/**
* Ob table unexpected exception.
*/
public ObTableUnexpectedException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table unexpected exception.
*/
public ObTableUnexpectedException(String message) {
super(message);
}
/**
* Ob table unexpected exception.
*/
public ObTableUnexpectedException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table unexpected exception.
*/
public ObTableUnexpectedException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,69 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.exception;
public class ObTableUnitMigrateException extends ObTableException {
/**
* Ob table unit migrate exception.
*/
public ObTableUnitMigrateException() {
}
/**
* Ob table unit migrate exception.
*/
public ObTableUnitMigrateException(int errorCode) {
super(errorCode);
}
/**
* Ob table unit migrate exception.
*/
public ObTableUnitMigrateException(String message, int errorCode) {
super(message, errorCode);
}
/**
* Ob table unit migrate exception.
*/
public ObTableUnitMigrateException(String message) {
super(message);
}
/**
* Ob table unit migrate exception.
*/
public ObTableUnitMigrateException(String message, Throwable cause) {
super(message, cause);
}
/**
* Ob table unit migrate exception.
*/
public ObTableUnitMigrateException(Throwable cause) {
super(cause);
}
/**
* Is need refresh table entry.
*/
public boolean isNeedRefreshTableEntry() {
return true;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,100 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class SecureIdentityLoginModule {
private static byte[] ENC_KEY_BYTES_PROD = "gQzLk5tTcGYlQ47GG29xQxfbHIURCheJ".getBytes();
/**
* Decode.
*/
public static String decode(String secret) throws NoSuchPaddingException,
NoSuchAlgorithmException, InvalidKeyException,
BadPaddingException, IllegalBlockSizeException {
return decode(null, secret);
}
/**
* Decode.
*/
public static String decode(String encKey, String secret) throws NoSuchPaddingException,
NoSuchAlgorithmException,
InvalidKeyException,
BadPaddingException,
IllegalBlockSizeException {
byte[] kbytes = ENC_KEY_BYTES_PROD;
if (isNotBlank(encKey)) {
kbytes = encKey.getBytes();
}
return iniDecode(kbytes, secret);
}
static final String iniDecode(byte[] kbytes, String secret) throws NoSuchPaddingException,
NoSuchAlgorithmException,
InvalidKeyException,
BadPaddingException,
IllegalBlockSizeException {
SecretKeySpec key = new SecretKeySpec(kbytes, "Blowfish");
BigInteger n = new BigInteger(secret, 16);
byte[] encoding = n.toByteArray();
// SECURITY-344: fix leading zeros
if (encoding.length % 8 != 0) {
int length = encoding.length;
int newLength = ((length / 8) + 1) * 8;
int pad = newLength - length; //number of leading zeros
byte[] old = encoding;
encoding = new byte[newLength];
for (int i = old.length - 1; i >= 0; i--) {
encoding[i + pad] = old[i];
}
encoding[0] = (byte) n.signum();
}
Cipher cipher = Cipher.getInstance("Blowfish");
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] decode = cipher.doFinal(encoding);
return new String(decode);
}
static final boolean isNotBlank(String str) {
return !isBlank(str);
}
static final boolean isBlank(String str) {
int strLen = 0;
if (str == null || (strLen = str.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if ((Character.isWhitespace(str.charAt(i)) == false)) {
return false;
}
}
return true;
}
}

View File

@ -0,0 +1,100 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableConsistencyLevel;
import java.util.HashMap;
import java.util.Map;
public enum ObReadConsistency {
STRONG(0), WEAK(1);
private int value;
private static Map<Integer, ObReadConsistency> map = new HashMap<Integer, ObReadConsistency>();
ObReadConsistency(int value) {
this.value = value;
}
static {
for (ObReadConsistency type : ObReadConsistency.values()) {
map.put(type.value, type);
}
}
/**
* Value of.
*/
public static ObReadConsistency valueOf(int value) {
return map.get(value);
}
/**
* Get value.
*/
public int getValue() {
return value;
}
/**
* Get byte value.
*/
public byte getByteValue() {
return (byte) value;
}
/**
* Get ObReadConsistency by string value, return "STRONG" by default.
*/
static public ObReadConsistency getByName(String consistency) {
if (consistency.equalsIgnoreCase("weak")) {
return ObReadConsistency.WEAK;
}
return ObReadConsistency.STRONG;
}
/**
* Is Strong consistency or not.
*
* @return
*/
public boolean isStrong() {
return this.value == STRONG.value;
}
/**
* Is weak consistency or not.
*
* @return
*/
public boolean isWeak() {
return this.value == WEAK.value;
}
/**
* Convert to ObTableConsistencyLevel.
*/
public ObTableConsistencyLevel toObTableConsistencyLevel() {
if (isWeak()) {
return ObTableConsistencyLevel.EVENTUAL;
}
return ObTableConsistencyLevel.STRONG;
}
}

View File

@ -0,0 +1,96 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
/**
* ObReplicaType(副本类型)
*
*/
public enum ObReplicaType {
// 全能型副本是paxos成员有ssstore有memstore
REPLICA_TYPE_FULL("FULL", 0),
// 备份型副本是paxos成员有ssstore没有memstore
// REPLICA_TYPE_BACKUP("BACKUP", 1),
// 日志型副本: 是paxos成员没有ssstore没有memstore
REPLICA_TYPE_LOGONLY("LOGONLY", 5),
// 只读型副本不是paxos成员有ssstore有memstore
REPLICA_TYPE_READONLY("READONLY", 16),
// 增量型副本不是paxos成员没有ssstore有memstore
// REPLICA_TYPE_MEMONLY("MEMONLY", 20),
// invalid value
REPLICA_TYPE_INVALID("INVALID", Integer.MAX_VALUE);
private String name;
private int index;
/**
* Constructor.
*
* @param name
* @param index
*/
ObReplicaType(String name, int index) {
this.name = name;
this.index = index;
}
/**
* Get ReplicaType by idx.
*
* @param idx
* @return
*/
static public ObReplicaType getReplicaType(int idx) {
if (REPLICA_TYPE_FULL.index == idx) {
return REPLICA_TYPE_FULL;
} else if (REPLICA_TYPE_LOGONLY.index == idx) {
return REPLICA_TYPE_LOGONLY;
} else if (REPLICA_TYPE_READONLY.index == idx) {
return REPLICA_TYPE_READONLY;
} else {
return REPLICA_TYPE_INVALID;
}
}
/**
* whether the replica is readable.
*/
public boolean isReadable() {
return this.index == REPLICA_TYPE_FULL.index || this.index == REPLICA_TYPE_READONLY.index;
}
/**
* whether the replica is readonly.
*/
public boolean isReadonly() {
return this.index == REPLICA_TYPE_READONLY.index;
}
/**
* To string.
*/
@Override
public String toString() {
return this.name;
}
}

View File

@ -0,0 +1,79 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import java.util.HashMap;
import java.util.Map;
/**
* There are PRIMARY(P), FOLLOWER(F) and READONLY(R) follower types.
* ObRoutePolicy defines the weak read routing policy.
*
*/
public enum ObRoutePolicy {
// read order: same IDC -> same region -> other region
IDC_ORDER(0)
// read order: F+R -> P
, FOLLOWER_FIRST(1)
// read order: R -> F -> P
// , READONLY_FIRST(2)
// read from: R
// , ONLY_READONLY(3)
// read from: P + F
// , ONLY_READWRITE(4)
;
private int value;
private static Map<Integer, ObRoutePolicy> map = new HashMap<Integer, ObRoutePolicy>();
/**
* Constructor.
*
* @param value
*/
ObRoutePolicy(int value) {
this.value = value;
}
static {
for (ObRoutePolicy type : ObRoutePolicy.values()) {
map.put(type.value, type);
}
}
/**
* Get ObRoutePolicy name, return "IDC_ORDER" by default.
*/
static public ObRoutePolicy getByName(String routePolicy) {
if (routePolicy != null) {
if (routePolicy.equalsIgnoreCase("idc_order")) {
return ObRoutePolicy.IDC_ORDER;
} else if (routePolicy.equalsIgnoreCase("follower_first")) {
return ObRoutePolicy.FOLLOWER_FIRST;
} /*else if (routePolicy.equalsIgnoreCase("readonly_first")) {
return ObRoutePolicy.READONLY_FIRST;
} else if (routePolicy.equalsIgnoreCase("only_readonly")) {
return ObRoutePolicy.ONLY_READONLY;
} else if (routePolicy.equalsIgnoreCase("only_readwrite")) {
return ObRoutePolicy.ONLY_READWRITE;
}*/
}
return ObRoutePolicy.IDC_ORDER;
}
}

View File

@ -0,0 +1,163 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import java.util.concurrent.atomic.AtomicInteger;
public class ObServerAddr implements Comparable<ObServerAddr> {
private String ip;
private int sqlPort;
private int svrPort;
private final AtomicInteger priority = new AtomicInteger(0);
private volatile long grantPriorityTime = 0;
private volatile long lastAccessTime = System.currentTimeMillis();
/**
* Whether the addr is expired given the timeout.
*/
public boolean isExpired(long cachingTimeout) {
return System.currentTimeMillis() - lastAccessTime > cachingTimeout;
}
/**
* Record the access time.
*/
public void recordAccess() {
lastAccessTime = System.currentTimeMillis();
}
/**
* Get ip.
*/
public String getIp() {
return ip;
}
/**
* Set ip.
*/
public void setIp(String ip) {
this.ip = ip;
}
/**
* Set address.
*/
public void setAddress(String address) {
if (address.contains(":")) {
this.ip = address.split(":")[0];
this.svrPort = Integer.parseInt(address.split(":")[1]);
} else {
this.ip = address;
}
}
/**
* Get sql port.
*/
public int getSqlPort() {
return sqlPort;
}
/**
* Set sql port.
*/
public void setSqlPort(int sqlPort) {
this.sqlPort = sqlPort;
}
/**
* Get svr port.
*/
public int getSvrPort() {
return svrPort;
}
/**
* Set svr port.
*/
public void setSvrPort(int svrPort) {
this.svrPort = svrPort;
}
/**
* Get priority.
*/
public AtomicInteger getPriority() {
return priority;
}
/**
* Get grant priority time.
*/
public long getGrantPriorityTime() {
return grantPriorityTime;
}
/**
* Set grant priority time.
*/
public void setGrantPriorityTime(long grantPriorityTime) {
this.grantPriorityTime = grantPriorityTime;
}
public long getLastAccessTime() {
return lastAccessTime;
}
/**
* Equals.
*/
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
ObServerAddr that = (ObServerAddr) o;
return sqlPort == that.sqlPort && svrPort == that.svrPort && ip.equals(that.ip);
}
/**
* Hash code.
*/
@Override
public int hashCode() {
return ip.hashCode() + sqlPort + svrPort;
}
/**
* To string.
*/
@Override
public String toString() {
return "ObServerAddr{" + "ip='" + ip + '\'' + ", sqlPort=" + sqlPort + ", svrPort="
+ svrPort + '}';
}
/**
* Compare to.
*/
@Override
public int compareTo(ObServerAddr that) {
int thisValue = this.priority.get();
int thatValue = that.priority.get();
return thisValue < thatValue ? 1 : (thisValue == thatValue) ? 0 : -1;
}
}

View File

@ -0,0 +1,67 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
public class ObServerInfo {
private long stopTime;
private String status; // ACTIVE / INACTIVE / DELETING
/**
* Get status.
*/
public String getStatus() {
return status;
}
/**
* Set status.
*/
public void setStatus(String status) {
this.status = status;
}
/**
* Get stop time.
*/
public long getStopTime() {
return stopTime;
}
/**
* Set stop time.
*/
public void setStopTime(long stopTime) {
this.stopTime = stopTime;
}
/**
* Is active.
*/
public boolean isActive() {
return stopTime == 0 && "active".equalsIgnoreCase(status);
}
/**
* To string.
*/
@Override
public String toString() {
return "ObServerInfo{" + "stopTime=" + stopTime + ", status='" + status + '\'' + '}';
}
}

View File

@ -0,0 +1,81 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
/**
* ObServerLdcItem defines the LDC information for server, including idc, zone and region.
*
*/
public class ObServerLdcItem {
private String ip;
private String zone; // concept of OceanBase
private String idc; // physical idc
private String region; // city
/**
* Constructor.
*
* @param ip
* @param zone
* @param idc
* @param region
*/
public ObServerLdcItem(String ip, String zone, String idc, String region) {
this.ip = ip;
this.zone = zone;
this.idc = idc;
this.region = region;
}
/**
* Get IP of the server.
*/
public String getIp() {
return ip;
}
/**
* Get Zone of the server.
*/
public String getZone() {
return zone;
}
/**
* Get IDC of the server.
*/
public String getIdc() {
return idc;
}
/**
* Get region of the server.
*/
public String getRegion() {
return region;
}
/**
* To String.
*/
@Override
public String toString() {
return "ObServerLdcItem{" + "ip='" + ip + '\'' + ", zone='" + zone + '\'' + ", idc='" + idc
+ '\'' + ", region='" + region + '\'' + '}';
}
}

View File

@ -0,0 +1,160 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import com.alipay.oceanbase.rpc.util.StringUtil;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* ObServerLdcLocation organizes server by IDC->Region order.
*
*/
public class ObServerLdcLocation {
enum RegionMatchType {
MATCHED_BY_IDC, MATCHED_BY_ZONE_PREFIX, MATCHED_BY_URL
}
private String currentIDC;
// 在某些OB部署场景一个 IDC 可能归属到多个 Region.
private Set<String> regionNames = new HashSet<String>();
private RegionMatchType matchType;
private boolean isLdcUsed;
private List<ObServerLdcItem> allServers;
private HashMap<String, ObServerLdcItem> sameIDC = new HashMap<String, ObServerLdcItem>();
private HashMap<String, ObServerLdcItem> sameRegion = new HashMap<String, ObServerLdcItem>();
private HashMap<String, ObServerLdcItem> otherRegion = new HashMap<String, ObServerLdcItem>();
/**
* 构造 ObServerLdcLocation根据当前 IDC RegionMap 将服务器按 IDC->Region->OtherRegion的分类整理
*
* @param allServers
* @param currentIDC
* @param regionFromOcp
*/
public static ObServerLdcLocation buildLdcLocation(List<ObServerLdcItem> allServers,
String currentIDC, String regionFromOcp) {
ObServerLdcLocation loc = new ObServerLdcLocation();
loc.allServers = allServers;
loc.currentIDC = currentIDC;
if (StringUtil.isEmpty(currentIDC)) {
loc.isLdcUsed = false;
} else {
// get Region names, refer to odp: ObLDCLocation::get_region_name
// 1. 首先看 server idc 是否匹配
for (ObServerLdcItem ss : allServers) {
if (ss.getIdc().equalsIgnoreCase(currentIDC)) {
loc.regionNames.add(ss.getRegion());
loc.matchType = RegionMatchType.MATCHED_BY_IDC;
}
}
// 2. 若从 server idc 没匹配则根据 zone 的前缀来匹配: case sensitive
if (loc.regionNames.isEmpty()) {
for (ObServerLdcItem ss : allServers) {
if (ss.getZone().startsWith(currentIDC)) {
loc.regionNames.add(ss.getRegion());
loc.matchType = RegionMatchType.MATCHED_BY_ZONE_PREFIX;
}
}
}
// 3. 再次从 ocp idc-> region 映射
if (loc.regionNames.isEmpty() && StringUtil.isNotEmpty(regionFromOcp)) {
loc.regionNames.add(regionFromOcp);
loc.matchType = RegionMatchType.MATCHED_BY_URL;
}
if (!loc.regionNames.isEmpty()) {
loc.isLdcUsed = true;
}
}
if (loc.isLdcUsed) {
// classify by idc->region->other
for (ObServerLdcItem it : allServers) {
if (it.getIdc().equalsIgnoreCase(currentIDC)) {
loc.sameIDC.put(it.getIp(), it);
} else if (loc.regionNames.contains(it.getRegion())) {
loc.sameRegion.put(it.getIp(), it);
} else {
loc.otherRegion.put(it.getIp(), it);
}
}
}
return loc;
}
/**
* Whether the server in the same IDC.
*/
public boolean inSameIDC(String svr_ip) {
return sameIDC.containsKey(svr_ip);
}
/**
* Whether the server in the same region.
*/
public boolean inSameRegion(String ip) {
return sameRegion.containsKey(ip);
}
/**
* Whether the server in other region.
*/
public boolean inOtherRegion(String ip) {
return otherRegion.containsKey(ip);
}
/**
* Whether the LDC routing is enabled.
*/
public boolean isLdcUsed() {
return isLdcUsed;
}
/**
* Get current IDC.
*/
public String getCurrentIDC() {
return currentIDC;
}
/**
* Get Region Match Type.
*/
public RegionMatchType getMatchType() {
return matchType;
}
/**
* To String
*
* @return
*/
@Override
public String toString() {
return "ObServerLdcLocation{" + "currentIDC='" + currentIDC + '\'' + ", isLdcUsed="
+ isLdcUsed + ", regionNames=" + regionNames + ", matchType=" + matchType
+ ", allServers=" + allServers + ", sameIDC=" + sameIDC + ", sameRegion="
+ sameRegion + ", otherRegion=" + otherRegion + '}';
}
}

View File

@ -0,0 +1,64 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
public enum ObServerRole {
INVALID_ROLE("INVALID_ROLE", 0), LEADER("LEADER", 1), FOLLOWER("FOLLOWER", 2);
private String name;
private int index;
private ObServerRole(String name, int index) {
this.name = name;
this.index = index;
}
static public ObServerRole getRole(int idx) {
if (LEADER.index == idx) {
return LEADER;
} else if (FOLLOWER.index == idx) {
return FOLLOWER;
} else {
return INVALID_ROLE;
}
}
static public ObServerRole getRole(String role) {
if (role.equalsIgnoreCase(LEADER.name)) {
return LEADER;
} else if (role.equalsIgnoreCase(FOLLOWER.name)) {
return FOLLOWER;
} else {
return INVALID_ROLE;
}
}
/**
* Get name.
*/
public String getName() {
return name;
}
/**
* Get index.
*/
public int getIndex() {
return index;
}
}

View File

@ -0,0 +1,105 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import java.util.HashSet;
import java.util.Set;
/**
* ObServerRoute defines the route policy and server LDC for table operation request.
* It also keeps the black list of servers which failed to access.
*
*/
public class ObServerRoute {
// default route for strong read.
public static ObServerRoute STRONG_READ = new ObServerRoute(ObReadConsistency.STRONG);
private ObReadConsistency readConsistency;
private ObRoutePolicy readRoutePolicy;
private boolean isLdcUsed;
// black ip list
private Set<String> blackIpList = new HashSet<String>();
/**
* Construct OB Server Route.
*/
private ObServerRoute(ObReadConsistency readConsistency) {
this(readConsistency, ObRoutePolicy.IDC_ORDER, false);
}
/**
* Construct OB Server Route.
*/
public ObServerRoute(ObReadConsistency readConsistency, ObRoutePolicy readRoutePolicy,
boolean isLdcUsed) {
this.readConsistency = readConsistency;
this.readRoutePolicy = readRoutePolicy;
this.isLdcUsed = isLdcUsed;
}
/**
* Get Consistency Level.
*/
public ObReadConsistency getReadConsistency() {
return readConsistency;
}
/**
* Get read route policy.
*/
public ObRoutePolicy getReadRoutePolicy() {
return readRoutePolicy;
}
/**
* Check whether LDC enabled.
*/
public boolean isLdcEnabled() {
return isLdcUsed;
}
/**
* Reset route, which will clean the black ip list.
*/
public void reset() {
blackIpList.clear();
}
/**
* Check whether ip is in black list.
*/
public boolean isInBlackList(String ip) {
return blackIpList.contains(ip);
}
/**
* Add ip into black list.
*/
public void addToBlackList(String ip) {
blackIpList.add(ip);
}
/**
* set blackIpList.
*/
public void setBlackList(Set<String> blackIpList) {
if (blackIpList != null) {
this.blackIpList = blackIpList;
}
}
}

View File

@ -0,0 +1,93 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import com.alipay.oceanbase.rpc.location.SecureIdentityLoginModule;
import com.google.common.base.Strings;
/**
* OceanBase User Authentication.
*
*/
public class ObUserAuth {
private String userName;
private String password;
private String encPassword; // encrypted password, set by user.
/**
* Default constructor.
*/
public ObUserAuth() {
}
/**
* Constructor with user/password.
*/
public ObUserAuth(String userName, String password) {
this.userName = userName;
this.password = password;
}
/**
* Set User Name
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* Set password
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Set encrypted password. Decrypt it and set the password.
*/
public void setEncPassword(String encPassword) throws Exception {
this.encPassword = encPassword;
if (!Strings.isNullOrEmpty(encPassword)) {
this.password = SecureIdentityLoginModule.decode(encPassword);
}
}
/**
* Get password.
*/
public String getPassword() {
return password;
}
/**
* Get user name.
*/
public String getUserName() {
return userName;
}
/**
* Get encrypted password set by user.
* <p>
* Attention: you won't get encrypted password if you haven't set it, even if you have set a password.
*/
public String getEncPassword() {
return encPassword;
}
}

View File

@ -0,0 +1,78 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import java.util.HashMap;
import java.util.List;
public class OcpModel {
private List<ObServerAddr> obServerAddrs;
private long clusterId = -1;
private HashMap<String, String> idc2Region = new HashMap<String, String>();
/**
* Get ob server addrs.
*/
public List<ObServerAddr> getObServerAddrs() {
return obServerAddrs;
}
/**
* Set ob server addrs.
*/
public void setObServerAddrs(List<ObServerAddr> obServerAddrs) {
this.obServerAddrs = obServerAddrs;
}
/**
* Get cluster id.
*/
public long getClusterId() {
return clusterId;
}
/**
* Set cluster id.
*/
public void setClusterId(long clusterId) {
this.clusterId = clusterId;
}
/**
* Get Region by IDC.
*/
public String getIdc2Region(String idc) {
return idc2Region.get(idc);
}
/**
* Add Idc-Region pair.
*/
public void addIdc2Region(String idc, String region) {
idc2Region.put(idc, region);
}
/**
* To string.
*/
@Override
public String toString() {
return "OcpModel{" + "obServerAddrs=" + obServerAddrs + ", idc2Region=" + idc2Region + '}';
}
}

View File

@ -0,0 +1,97 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
public class OcpResponse {
private int Code;
private String Message;
private boolean Success;
private OcpResponseData Data;
/**
* Get code.
*/
public int getCode() {
return Code;
}
/**
* Set code.
*/
public void setCode(int code) {
Code = code;
}
/**
* Get message.
*/
public String getMessage() {
return Message;
}
/**
* Set message.
*/
public void setMessage(String message) {
Message = message;
}
/**
* Is success.
*/
public boolean isSuccess() {
return Success;
}
/**
* Set success.
*/
public void setSuccess(boolean success) {
Success = success;
}
/**
* Get data.
*/
public OcpResponseData getData() {
return Data;
}
/**
* Validate.
*/
public boolean validate() {
return isSuccess() && getCode() == 200 && Data != null && Data.validate();
}
/**
* Set data.
*/
public void setData(OcpResponseData data) {
Data = data;
}
/**
* To string.
*/
@Override
public String toString() {
return "OcpResponse{" + "Code=" + Code + ", Message='" + Message + '\'' + ", Success="
+ Success + ", Data=" + Data + '}';
}
}

View File

@ -0,0 +1,99 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import java.util.List;
public class OcpResponseData {
private String ObRegion;
private long ObRegionId = -1;
private List<OcpResponseDataRs> RsList;
private List<OcpResponseDataIDC> IDCList;
/**
* Get ob region.
*/
public String getObRegion() {
return ObRegion;
}
/**
* Set ob region.
*/
public void setObRegion(String obRegion) {
ObRegion = obRegion;
}
/**
* Get ob region id.
*/
public long getObRegionId() {
return ObRegionId;
}
/**
* Set ob region id.
*/
public void setObRegionId(long obRegionId) {
ObRegionId = obRegionId;
}
/**
* Get rs list.
*/
public List<OcpResponseDataRs> getRsList() {
return RsList;
}
/**
* Set rs list.
*/
public void setRsList(List<OcpResponseDataRs> rsList) {
RsList = rsList;
}
/**
* Get IDC list.
*/
public List<OcpResponseDataIDC> getIDCList() {
return IDCList;
}
/**
* Set IDC list.
*/
public void setIDCList(List<OcpResponseDataIDC> IDCList) {
this.IDCList = IDCList;
}
/**
* Validate.
*/
public boolean validate() {
return RsList != null && RsList.size() > 0;
}
/**
* To string.
*/
@Override
public String toString() {
return "OcpResponseData{" + "ObRegion='" + ObRegion + '\'' + ", ObRegionId=" + ObRegionId
+ ", RsList=" + RsList + ", IDCList=" + IDCList + '}';
}
}

View File

@ -0,0 +1,61 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
/**
* Idc->Region mapping defined in OCP.
*
*/
public class OcpResponseDataIDC {
private String idc;
private String region;
/**
* Get idc.
*/
public String getIdc() {
return idc;
}
/**
* Set idc.
*/
public void setIdc(String idc) {
this.idc = idc;
}
/**
* Get region.
*/
public String getRegion() {
return region;
}
/**
* Set region.
*/
public void setRegion(String region) {
this.region = region;
}
@Override
public String toString() {
return "OcpResponseDataIDC{" + "idc='" + idc + '\'' + ", region='" + region + '\'' + '}';
}
}

View File

@ -0,0 +1,75 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
public class OcpResponseDataRs {
private String address;
private String role;
private int sql_port;
/**
* Get address.
*/
public String getAddress() {
return address;
}
/**
* Set address.
*/
public void setAddress(String address) {
this.address = address;
}
/**
* Get role.
*/
public String getRole() {
return role;
}
/**
* Set role.
*/
public void setRole(String role) {
this.role = role;
}
/**
* Get sql_port.
*/
public int getSql_port() {
return sql_port;
}
/**
* Set sql_port.
*/
public void setSql_port(int sql_port) {
this.sql_port = sql_port;
}
/**
* To string.
*/
@Override
public String toString() {
return "OcpResponseDataRs{" + "address='" + address + '\'' + ", role='" + role + '\''
+ ", sql_port=" + sql_port + '}';
}
}

View File

@ -0,0 +1,127 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
public class ReplicaLocation {
private ObServerAddr addr;
private ObServerInfo info;
private ObServerRole role;
private ObReplicaType replicaType;
/**
* Is valid.
*/
public boolean isValid() {
return (null != addr) && (ObServerRole.INVALID_ROLE != this.role) && (null != info)
&& (info.isActive());
}
/**
* Get addr.
*/
public ObServerAddr getAddr() {
return addr;
}
/**
* Set addr.
*/
public void setAddr(ObServerAddr addr) {
this.addr = addr;
}
/**
* Get role.
*/
public ObServerRole getRole() {
return role;
}
/**
* Set role.
*/
public void setRole(ObServerRole role) {
this.role = role;
}
/**
* Is leader.
*/
public boolean isLeader() {
return ObServerRole.LEADER.equals(role);
}
/**
* Get info.
*/
public ObServerInfo getInfo() {
return info;
}
/**
* Set info.
*/
public void setInfo(ObServerInfo info) {
this.info = info;
}
/**
* Get replicaType.
*/
public ObReplicaType getReplicaType() {
return replicaType;
}
/**
* Set replicaType.
*/
public void setReplicaType(ObReplicaType replicaType) {
this.replicaType = replicaType;
}
/**
* The replica is readable.
*/
public boolean isReadable() {
return replicaType.isReadable();
}
/**
* The replica is readonly.
*/
public boolean isReadonly() {
return replicaType.isReadonly();
}
/**
* Get Ip of the replica.
*/
public String getIp() {
return addr.getIp();
}
/**
* To string.
*/
@Override
public String toString() {
return "ReplicaLocation{" + "addr=" + addr + ", info=" + info + ", role=" + role
+ ", replicaType=" + replicaType + '}';
}
}

View File

@ -0,0 +1,180 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import com.alipay.oceanbase.rpc.exception.ObTableServerCacheExpiredException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static com.alipay.oceanbase.rpc.util.RandomUtil.getRandomNum;
public class ServerRoster {
private AtomicInteger maxPriority = new AtomicInteger(0);
private AtomicReference<List<ObServerAddr>> roster = new AtomicReference<List<ObServerAddr>>(
new ArrayList<ObServerAddr>());
private AtomicReference<ObServerLdcLocation> serverLdc = new AtomicReference<ObServerLdcLocation>();
/**
* Reset.
*/
public void reset(List<ObServerAddr> members) {
this.maxPriority.set(0);
this.roster.set(members);
}
/**
* Reset Server LDC.
*/
public void resetServerLdc(ObServerLdcLocation serverLdc) {
this.serverLdc.set(serverLdc);
}
/**
* Upgrade max priority.
*/
public void upgradeMaxPriority(long priority) {
if (maxPriority.get() >= priority) {
return;
}
if (priority == 0) {
this.maxPriority.set(0);
return;
}
resetMaxPriority();
}
/**
* Downgrade max priority.
*/
public void downgradeMaxPriority(long priority) {
if (maxPriority.get() <= priority) {
return;
}
resetMaxPriority();
}
/**
* Reset max priority.
*/
public void resetMaxPriority() {
if (roster.get().size() == 0) {
this.maxPriority.set(0);
}
int priority = Integer.MIN_VALUE;
for (ObServerAddr obServerAddr : roster.get()) {
if (obServerAddr.getPriority().get() > priority) { //priority below maxPriority)
priority = obServerAddr.getPriority().get();
}
}
this.maxPriority.set(priority);
}
/**
* Get max priority.
*/
public int getMaxPriority() {
return maxPriority.get();
}
/**
* Get members.
*/
public List<ObServerAddr> getMembers() {
return roster.get();
}
/**
* Get ServerLdcLocation.
*/
public ObServerLdcLocation getServerLdcLocation() {
return serverLdc.get();
}
/**
* Choose a server by random.
*
* @param priorityTimeout
* @param cachingTimeout
* @return
*/
public ObServerAddr getServer(long priorityTimeout, long cachingTimeout) {
long gradeTime = System.currentTimeMillis();
List<ObServerAddr> randomList = new ArrayList<ObServerAddr>();
int maxPriority = getMaxPriority();
for (ObServerAddr obServerAddr : getMembers()) {
if (obServerAddr.getPriority().get() == maxPriority || //max priority
gradeTime - obServerAddr.getGrantPriorityTime() > priorityTimeout) { //last grant priority timeout
randomList.add(obServerAddr);
}
}
ObServerAddr addr = randomList.get(getRandomNum(0, randomList.size()));
if (addr.isExpired(cachingTimeout)) {
throw new ObTableServerCacheExpiredException("server addr is expired : " + addr);
}
addr.recordAccess();
return addr;
}
/**
* Reset priority and upgrade priority.
*
* @param addr
*/
public void resetPriority(ObServerAddr addr) {
if (addr.getPriority().get() != 0) {
long grantPriorityTime = System.currentTimeMillis();
addr.setGrantPriorityTime(grantPriorityTime);
// reset the priority
addr.getPriority().set(0);
// has no effect on the order of server roster
this.upgradeMaxPriority(0);
}
}
/**
* Down grade priority and reorder the servers.
*
* @param addr
*/
public void downgradePriority(ObServerAddr addr) {
// must reorder the serverRoster when priority change
long grantPriorityTime = System.currentTimeMillis();
addr.setGrantPriorityTime(grantPriorityTime);
this.downgradeMaxPriority(addr.getPriority().decrementAndGet());
}
/**
* To String.
*/
@Override
public String toString() {
return "ServerRoster{" + "maxPriority=" + maxPriority + ", roster=" + roster
+ ", serverLdc=" + serverLdc + '}';
}
}

View File

@ -0,0 +1,229 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import com.alipay.oceanbase.rpc.location.model.partition.ObPartitionEntry;
import com.alipay.oceanbase.rpc.location.model.partition.ObPartitionInfo;
import com.alipay.oceanbase.rpc.protocol.payload.Constants;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.base.Preconditions.checkArgument;
public class TableEntry {
public static final Map<String, Integer> HBASE_ROW_KEY_ELEMENT = new HashMap<String, Integer>() {
{
put("K", 0);
put("Q", 1);
put("T", 2);
}
};
// schema info
private Long tableId = Constants.OB_INVALID_ID;
private Long partitionNum = Constants.OB_INVALID_ID; //for dummy entry, it is one
private Long replicaNum = Constants.OB_INVALID_ID;
private ObPartitionInfo partitionInfo = null;
private volatile long refreshTimeMills;
private Map<String, Integer> rowKeyElement = null;
// table location
private TableLocation tableLocation = null;
// partition location
private TableEntryKey tableEntryKey = null;
private volatile ObPartitionEntry partitionEntry = null;
/**
* Is valid.
*/
public boolean isValid() {
return this.partitionNum > 0 && this.replicaNum > 0 && tableId > 0
&& ((null != tableLocation) && (tableLocation.getReplicaLocations().size() > 0)); // tableLocation.getReplicaLocations().size() 不一定等于 replicaNum多个 partition 就有多个 replicaNum
}
/**
* Get table id.
*/
public Long getTableId() {
return tableId;
}
/**
* Set table id.
*/
public void setTableId(Long tableId) {
this.tableId = tableId;
}
/**
* Get partition num.
*/
public Long getPartitionNum() {
return partitionNum;
}
/**
* Set partition num.
*/
public void setPartitionNum(Long partitionNum) {
this.partitionNum = partitionNum;
}
/**
* Get replica num.
*/
public Long getReplicaNum() {
return replicaNum;
}
/**
* Is partition table.
*/
public boolean isPartitionTable() {
return this.partitionNum > 1;
}
/**
* Set replica num.
*/
public void setReplicaNum(Long replicaNum) {
this.replicaNum = replicaNum;
}
/**
* Get table location.
*/
public TableLocation getTableLocation() {
return tableLocation;
}
/**
* Set table location.
*/
public void setTableLocation(TableLocation tableLocation) {
this.tableLocation = tableLocation;
}
/**
* Get partition info.
*/
public ObPartitionInfo getPartitionInfo() {
return partitionInfo;
}
/**
* Set partition info.
*/
public void setPartitionInfo(ObPartitionInfo partitionInfo) {
this.partitionInfo = partitionInfo;
}
/**
* Get refresh time mills.
*/
public long getRefreshTimeMills() {
return refreshTimeMills;
}
/**
* Set refresh time mills.
*/
public void setRefreshTimeMills(long refreshTimeMills) {
this.refreshTimeMills = refreshTimeMills;
}
public Map<String, Integer> getRowKeyElement() {
return rowKeyElement;
}
/**
* Set row key element.
*/
public void setRowKeyElement(Map<String, Integer> rowKeyElement) {
this.rowKeyElement = rowKeyElement;
if (partitionInfo != null) {
partitionInfo.setRowKeyElement(rowKeyElement);
}
}
/**
* Get table entry key.
*/
public TableEntryKey getTableEntryKey() {
return tableEntryKey;
}
/**
* Set table entry key.
*/
public void setTableEntryKey(TableEntryKey tableEntryKey) {
this.tableEntryKey = tableEntryKey;
}
/**
* Get partition entry.
*/
public ObPartitionEntry getPartitionEntry() {
return partitionEntry;
}
/**
* Set partition entry.
*/
public void setPartitionEntry(ObPartitionEntry partitionEntry) {
this.partitionEntry = partitionEntry;
}
/**
* Prepare.
*/
public void prepare() throws IllegalArgumentException {
if (isPartitionTable()) {
checkArgument(partitionInfo != null, "partition table partition info is not ready. key"
+ tableEntryKey);
partitionInfo.prepare();
checkArgument(partitionEntry != null,
"partition table partition entry is not ready. key" + tableEntryKey);
}
}
/**
* Prepare for weak read.
* @param ldcLocation
*/
public void prepareForWeakRead(ObServerLdcLocation ldcLocation) {
if (partitionEntry != null) {
partitionEntry.prepareForWeakRead(ldcLocation);
}
}
/**
* To string.
*/
@Override
public String toString() {
return "TableEntry{" + "tableId=" + tableId + ", partitionNum=" + partitionNum
+ ", replicaNum=" + replicaNum + ", partitionInfo=" + partitionInfo
+ ", refreshTimeMills=" + refreshTimeMills + ", rowKeyElement=" + rowKeyElement
+ ", tableLocation=" + tableLocation + ", tableEntryKey=" + tableEntryKey
+ ", partitionEntry=" + partitionEntry + '}';
}
}

View File

@ -0,0 +1,201 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import com.alipay.oceanbase.rpc.constant.Constants;
import com.alipay.oceanbase.rpc.util.StringUtil;
public class TableEntryKey {
private String clusterName = Constants.EMPTY_STRING;
private String tenantName = Constants.EMPTY_STRING;
private String databaseName = Constants.EMPTY_STRING;
private String tableName = Constants.EMPTY_STRING;
/**
* Table entry key.
*/
public TableEntryKey() {
}
/**
* Table entry key.
*/
public TableEntryKey(String clusterName, String tenantName, String databaseName,
String tableName) {
super();
this.clusterName = clusterName;
this.tenantName = tenantName;
this.databaseName = databaseName;
this.tableName = tableName;
}
/**
* Get dummy entry key.
*/
public static TableEntryKey getDummyEntryKey(String clusterName, String tenantName) {
TableEntryKey dummyKey = new TableEntryKey(clusterName, tenantName,
Constants.OCEANBASE_DATABASE, Constants.ALL_DUMMY_TABLE);
return dummyKey;
}
/**
* Get sys dummy entry key.
*/
public static TableEntryKey getSysDummyEntryKey(String clusterName) {
return getDummyEntryKey(clusterName, Constants.SYS_TENANT);
}
/**
* Is sys all dummy.
*/
public boolean isSysAllDummy() {
return this.tenantName.equals(Constants.SYS_TENANT) && this.isAllDummy();
}
/**
* Is all dummy.
*/
public boolean isAllDummy() {
return this.databaseName.equals(Constants.OCEANBASE_DATABASE)
&& this.tableName.equals(Constants.ALL_DUMMY_TABLE);
}
/**
* Is valid.
*/
public boolean isValid() {
return StringUtil.isNotEmpty(this.clusterName) && StringUtil.isNotEmpty(this.tenantName)
&& StringUtil.isNotEmpty(this.databaseName) && StringUtil.isNotEmpty(this.tableName);
}
/**
* To string.
*/
@Override
public String toString() {
return "TableEntryKey [clusterName=" + clusterName + ", tenantName=" + tenantName
+ ", databaseName=" + databaseName + ", tableName=" + tableName + "]";
}
/**
* Hash code.
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((clusterName == null) ? 0 : clusterName.hashCode());
result = prime * result + ((databaseName == null) ? 0 : databaseName.hashCode());
result = prime * result + ((tableName == null) ? 0 : tableName.hashCode());
result = prime * result + ((tenantName == null) ? 0 : tenantName.hashCode());
return result;
}
/**
* Equals.
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TableEntryKey other = (TableEntryKey) obj;
if (clusterName == null) {
if (other.clusterName != null)
return false;
} else if (!clusterName.equals(other.clusterName))
return false;
if (databaseName == null) {
if (other.databaseName != null)
return false;
} else if (!databaseName.equals(other.databaseName))
return false;
if (tableName == null) {
if (other.tableName != null)
return false;
} else if (!tableName.equals(other.tableName))
return false;
if (tenantName == null) {
if (other.tenantName != null)
return false;
} else if (!tenantName.equals(other.tenantName))
return false;
return true;
}
/**
* Get cluster name.
*/
public String getClusterName() {
return clusterName;
}
/**
* Set cluster name.
*/
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}
/**
* Get tenant name.
*/
public String getTenantName() {
return tenantName;
}
/**
* Set tenant name.
*/
public void setTenantName(String tenantName) {
this.tenantName = tenantName;
}
/**
* Get database name.
*/
public String getDatabaseName() {
return databaseName;
}
/**
* Set database name.
*/
public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
}
/**
* Get table name.
*/
public String getTableName() {
return tableName;
}
/**
* Set table name.
*/
public void setTableName(String tableName) {
this.tableName = tableName;
}
}

View File

@ -0,0 +1,46 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model;
import java.util.List;
public class TableLocation {
private List<ReplicaLocation> replicaLocations;
/**
* Get replica locations.
*/
public List<ReplicaLocation> getReplicaLocations() {
return replicaLocations;
}
/**
* Set replica locations.
*/
public void setReplicaLocations(List<ReplicaLocation> replicaLocations) {
this.replicaLocations = replicaLocations;
}
/**
* To string.
*/
@Override
public String toString() {
return "TableLocation{" + "replicaLocations=" + replicaLocations + '}';
}
}

View File

@ -0,0 +1,49 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model.partition;
import org.apache.commons.lang.builder.ToStringBuilder;
public class ObComparableKV<A extends Comparable<A>, B> implements Comparable<ObComparableKV<A, B>> {
public final A key;
public final B value;
/**
* Ob comparable k v.
*/
public ObComparableKV(A key, B value) {
this.key = key;
this.value = value;
}
/**
* To string.
*/
@Override
public String toString() {
return new ToStringBuilder(this).append("key", key).append("value", value).toString();
}
/**
* Compare to.
*/
@Override
public int compareTo(ObComparableKV<A, B> o) {
return this.key.compareTo(o.key);
}
}

View File

@ -0,0 +1,211 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model.partition;
import com.alipay.oceanbase.rpc.exception.ObTablePartitionConsistentException;
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObObjType;
import com.alipay.oceanbase.rpc.util.RandomUtil;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static com.alipay.oceanbase.rpc.util.TableClientLoggerFactory.LCD;
/*
* ------4----|----------28------------
* part space | part id
*/
public class ObHashPartDesc extends ObPartDesc {
private static final Logger logger = TableClientLoggerFactory
.getLogger(ObHashPartDesc.class);
private List<Long> completeWorks;
private int partSpace = 0;
private int partNum = 0;
/**
* Ob hash part desc.
*/
public ObHashPartDesc() {
setPartFuncType(ObPartFuncType.HASH);
}
/**
* Get part space.
*/
public int getPartSpace() {
return partSpace;
}
/**
* Set part space.
*/
public void setPartSpace(int partSpace) {
this.partSpace = partSpace;
}
/**
* Get part num.
*/
public int getPartNum() {
return this.partNum;
}
/**
* Set part num.
*/
public void setPartNum(int partNum) {
this.partNum = partNum;
List<Long> partIds = new ArrayList<Long>();
for (long i = 0; i < partNum; i++) {
partIds.add(i);
}
completeWorks = Collections.unmodifiableList(partIds);
}
/**
* Prepare.
*/
@Override
public void prepare() {
//hash no prepare things
super.prepare();
}
/**
* Get part ids.
*/
@Override
public List<Long> getPartIds(Object[] start, boolean startInclusive, Object[] end,
boolean endInclusive) {
// close set
try {
List<Object> startValues = evalRowKeyValues(start);
Object startValue = startValues.get(0);
List<Object> endValues = evalRowKeyValues(end);
Object endValue = endValues.get(0);
Long startLongValue = ObObjType.parseToLongOrNull(startValue);
Long endLongValue = ObObjType.parseToLongOrNull(endValue);
if (startLongValue == null || endLongValue == null) {
throw new NumberFormatException("can not parseToComparable start value ["
+ startValue + "] or end value [" + endValue
+ "] to long");
}
long startHashValue = startLongValue - (startInclusive ? 0 : -1);
long endHashValue = endLongValue - (endInclusive ? 0 : 1);
if (endHashValue - startHashValue + 1 >= partNum) {
return completeWorks;
} else {
List<Long> partIds = new ArrayList<Long>();
for (long i = startHashValue; i <= endHashValue; i++) {
partIds.add(innerHash(i));
}
return partIds;
}
} catch (IllegalArgumentException e) {
logger.error(LCD.convert("01-00002"), e);
throw new IllegalArgumentException(
"ObHashPartDesc get part id come across illegal params", e);
}
}
/**
* Get random part id.
*/
@Override
public Long getRandomPartId() {
return ((this.partNum > 0) ? (long) RandomUtil.getRandomNum(0, this.partNum) : null);
}
/**
* Get part id.
*/
@Override
public Long getPartId(Object... rowKey) {
List<Object[]> rowKeys = new ArrayList<Object[]>();
rowKeys.add(rowKey);
return this.getPartId(rowKeys, false);
}
/**
* Get part id.
*/
@Override
public Long getPartId(List<Object[]> rowKeys, boolean consistency) {
if (rowKeys == null || rowKeys.size() == 0) {
throw new IllegalArgumentException("invalid row keys :" + rowKeys);
}
Long partId = null;
try {
for (Object[] rowKey : rowKeys) {
List<Object> evalValues = evalRowKeyValues(rowKey);
Object value = evalValues.get(0);// the partition type of hash has one param at most
Long longValue = ObObjType.parseToLongOrNull(value);
if (longValue == null) {
throw new IllegalArgumentException("can not parseToComparable value [" + value
+ "] to long");
}
long currentPartId = innerHash(longValue);
if (partId == null) {
partId = currentPartId;
}
if (!consistency) {
break;
}
if (!partId.equals(currentPartId)) {
throw new ObTablePartitionConsistentException(
"across partition operation may cause consistent problem " + rowKeys);
}
}
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"ObHashPartDesc get part id come across illegal params", e);
}
return partId;
}
private Long innerHash(long hashValue) {
hashValue = Math.abs(hashValue);
return (partSpace << ObPartConstants.PART_ID_BITNUM) | (hashValue % partNum);
}
/**
* To string.
*/
@Override
public String toString() {
return new ToStringBuilder(this).append("partSpace", partSpace).append("partNum", partNum)
.append("partFuncType", this.getPartFuncType()).append("partExpr", this.getPartExpr())
.toString();
}
}

View File

@ -0,0 +1,198 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model.partition;
import com.alipay.oceanbase.rpc.exception.ObTablePartitionConsistentException;
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObCollationType;
import com.alipay.oceanbase.rpc.util.ObHashUtils;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.alipay.oceanbase.rpc.util.RandomUtil.getRandomNum;
import static com.alipay.oceanbase.rpc.util.TableClientLoggerFactory.LCD;
/*
* ------4----|----------28------------
* part space | part id
*/
public class ObKeyPartDesc extends ObPartDesc {
private static final Logger logger = TableClientLoggerFactory.getLogger(ObKeyPartDesc.class);
private int partSpace = 0;
private int partNum = 0;
/**
* Ob key part desc.
*/
public ObKeyPartDesc() {
setPartFuncType(ObPartFuncType.KEY);
}
/**
* Get part space.
*/
public int getPartSpace() {
return partSpace;
}
/**
* Set part space.
*/
public void setPartSpace(int partSpace) {
this.partSpace = partSpace;
}
/**
* Get part num.
*/
public int getPartNum() {
return this.partNum;
}
/**
* Set part num.
*/
public void setPartNum(int partNum) {
this.partNum = partNum;
}
/**
* Get part ids.
*/
@Override
public List<Long> getPartIds(Object[] start, boolean startInclusive, Object[] end,
boolean endInclusive) {
List<Object[]> rowKeys = new ArrayList<Object[]>();
rowKeys.add(start);
rowKeys.add(end);
List<Long> partIds = new ArrayList<Long>();
partIds.add(getPartId(rowKeys, true));
return partIds;
}
/**
* Get random part id.
*/
@Override
public Long getRandomPartId() {
return (this.partNum > 0 ? (long) getRandomNum(0, this.partNum) : null);
}
/**
* Get part id.
*/
@Override
public Long getPartId(Object... rowKey) throws IllegalArgumentException {
List<Object[]> rowKeys = new ArrayList<Object[]>();
rowKeys.add(rowKey);
return getPartId(rowKeys, false);
}
/**
* Get part id.
*/
@Override
public Long getPartId(List<Object[]> rowKeys, boolean consistency) {
if (rowKeys == null || rowKeys.size() == 0) {
throw new IllegalArgumentException("invalid row keys :" + rowKeys);
}
try {
int partRefColumnSize = orderedPartRefColumnRowKeyRelations.size();
List<Object> evalValues = null;
for (Object[] rowKey : rowKeys) {
List<Object> currentRowKeyEvalValues = evalRowKeyValues(rowKey);
if (evalValues == null) {
evalValues = currentRowKeyEvalValues;
}
if (!consistency) {
break;
}
if (evalValues == currentRowKeyEvalValues) {
continue;
}
for (int i = 0; i < evalValues.size(); i++) {
if (!equalsWithCollationType(orderedPartRefColumnRowKeyRelations.get(i)
.getLeft().getObCollationType(), evalValues.get(i),
currentRowKeyEvalValues.get(i))) {
throw new ObTablePartitionConsistentException(
"across partition operation may cause consistent problem " + rowKeys);
}
}
}
Long hashValue = 0L;
for (int i = 0; i < partRefColumnSize; i++) {
hashValue = ObHashUtils.toHashcode(evalValues.get(i),
orderedPartRefColumnRowKeyRelations.get(i).getLeft(), hashValue);
}
hashValue = (hashValue > 0 ? hashValue : -hashValue);
return (partSpace << ObPartConstants.PART_ID_BITNUM) | (hashValue % this.partNum);
} catch (IllegalArgumentException e) {
logger.error(LCD.convert("01-00023"), e);
throw new IllegalArgumentException(
"ObKeyPartDesc get part id come across illegal params", e);
}
}
private boolean equalsWithCollationType(ObCollationType collationType, Object s, Object t)
throws IllegalArgumentException {
if (collationType == ObCollationType.CS_TYPE_UTF8MB4_GENERAL_CI) {
if (!(s instanceof String && t instanceof String)) {
throw new IllegalArgumentException(
"CS_TYPE_UTF8MB4_GENERAL_CI only allow string equal");
}
return ((String) s).equalsIgnoreCase((String) t);
} else {
return s.equals(t);
}
}
/**
* Set row key element.
*/
@Override
public void setRowKeyElement(Map<String, Integer> rowKeyElement) {
if (rowKeyElement == null || rowKeyElement.size() == 0) {
throw new IllegalArgumentException("ObKeyPartDesc rowKeyElement is empty");
}
super.setRowKeyElement(rowKeyElement);
}
/**
* To string.
*/
@Override
public String toString() {
return new ToStringBuilder(this).append("partSpace", partSpace).append("partNum", partNum)
.append("partFuncType", this.getPartFuncType()).append("partExpr", this.getPartExpr())
.toString();
}
}

View File

@ -0,0 +1,177 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model.partition;
import com.alipay.oceanbase.rpc.exception.ObTablePartitionConsistentException;
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObColumn;
import com.alipay.oceanbase.rpc.util.RandomUtil;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.alipay.oceanbase.rpc.util.TableClientLoggerFactory.LCD;
public class ObListPartDesc extends ObPartDesc {
private static final Logger logger = TableClientLoggerFactory
.getLogger(ObListPartDesc.class);
private List<ObColumn> orderCompareColumns = null;
private Map<ObPartitionKey, Long> sets = null;
/**
* Ob list part desc.
*/
public ObListPartDesc() {
this.setPartFuncType(ObPartFuncType.LIST);
}
/**
* Get order compare columns.
*/
public List<ObColumn> getOrderCompareColumns() {
return this.orderCompareColumns;
}
/**
* Set order compare columns.
*/
public void setOrderCompareColumns(List<ObColumn> columns) {
this.orderCompareColumns = columns;
}
/**
* Set sets.
*/
public void setSets(Map<ObPartitionKey, Long> sets) {
this.sets = sets;
}
public Map<ObPartitionKey, Long> getSets() {
return this.sets;
}
/**
* Get random part id.
*/
@Override
public Long getRandomPartId() {
if (null == this.sets) {
return null;
}
int randomIndex = RandomUtil.getRandomNum(0, this.sets.size());
return (Long) this.sets.values().toArray()[randomIndex];
}
/**
* Prepare.
*/
@Override
public void prepare() throws IllegalArgumentException {
if (sets == null || sets.size() == 0) {
throw new IllegalArgumentException(
"prepare ObListPartDesc failed . partition set is empty " + sets);
}
if (orderCompareColumns == null || orderCompareColumns.size() == 0) {
throw new IllegalArgumentException(
"prepare ObListPartDesc failed . orderCompareColumns set is empty "
+ orderCompareColumns);
}
super.prepare();
}
/**
* Get part ids.
*/
@Override
public List<Long> getPartIds(Object[] start, boolean startInclusive, Object[] end,
boolean endInclusive) {
List<Object[]> rowKeys = new ArrayList<Object[]>();
rowKeys.add(start);
rowKeys.add(end);
Long partId = getPartId(rowKeys, true);
List<Long> partIds = new ArrayList<Long>();
partIds.add(partId);
return partIds;
}
/**
* Get part id.
*/
@Override
public Long getPartId(Object... rowKey) {
List<Object[]> rowKeys = new ArrayList<Object[]>();
rowKeys.add(rowKey);
return getPartId(rowKeys, false);
}
/**
* Get part id.
*/
@Override
public Long getPartId(List<Object[]> rowKeys, boolean consistency) {
if (rowKeys == null || rowKeys.size() == 0) {
throw new IllegalArgumentException("invalid row keys :" + rowKeys);
}
try {
Long partId = null;
for (Object[] rowKey : rowKeys) {
List<Object> currentRowKeyEvalValues = evalRowKeyValues(rowKey);
List<Comparable> values = super.initComparableElementByTypes(
currentRowKeyEvalValues, this.orderCompareColumns);
ObPartitionKey searchKey = ObPartitionKey.getInstance(orderCompareColumns, values);
long currentPartId = this.sets.get(searchKey);
if (partId == null) {
partId = currentPartId;
}
if (!consistency) {
break;
}
if (partId != currentPartId) {
throw new ObTablePartitionConsistentException(
"across partition operation may cause consistent problem " + rowKeys);
}
}
return partId;
} catch (IllegalArgumentException e) {
logger.error(LCD.convert("01-00001"), e);
throw new IllegalArgumentException(
"ObListPartDesc get part id come across illegal params", e);
}
}
/**
* To string.
*/
@Override
public String toString() {
return new ToStringBuilder(this).append("orderCompareColumns", this.orderCompareColumns)
.append("sets", this.sets).append("partFuncType", this.getPartFuncType())
.append("partExpr", this.getPartExpr()).toString();
}
}

View File

@ -0,0 +1,45 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model.partition;
public class ObPair<L, R> {
private final L left;
private final R right;
/**
* Ob pair.
*/
public ObPair(L left, R right) {
this.left = left;
this.right = right;
}
/**
* Get left.
*/
public L getLeft() {
return left;
}
/**
* Get right.
*/
public R getRight() {
return right;
}
}

View File

@ -0,0 +1,23 @@
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc.location.model.partition;
public interface ObPartConstants {
int PART_ID_BITNUM = 28;
int PART_ID_SHIFT = 32;
}

Some files were not shown because too many files have changed in this diff Show More