You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ni...@apache.org on 2023/08/16 10:31:08 UTC
[hbase-operator-tools] branch master updated: HBASE-27977 Add spotless plugin to hbase-operator-tools (#132)
This is an automated email from the ASF dual-hosted git repository.
nihaljain pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase-operator-tools.git
The following commit(s) were added to refs/heads/master by this push:
new ca3b96f HBASE-27977 Add spotless plugin to hbase-operator-tools (#132)
ca3b96f is described below
commit ca3b96f35a62566c443d4e07bf1ff98a7a4d1aa0
Author: Nihal Jain <ni...@gmail.com>
AuthorDate: Wed Aug 16 16:01:03 2023 +0530
HBASE-27977 Add spotless plugin to hbase-operator-tools (#132)
- Add spotless plugin to the repo
- Run mvn spotless:apply on code base
Signed-off-by: Peter Somogyi <ps...@apache.org>
---
CHANGES.md | 2 -
NOTICE.txt | 2 +-
RELEASENOTES.md | 3 -
build-support/checkstyle-suppressions.xml | 2 +-
dev-support/create-release/release-tag.sh | 1 -
dev-support/eclipse.importorder | 19 +
dev-support/hbase_eclipse_formatter.xml | 418 +++++
dev-support/jenkins/Jenkinsfile | 2 +-
.../jenkins/jenkins_precommit_github_yetus.sh | 2 +-
.../license-header | 24 -
dev-support/testingtool/hbck2_test.sh | 2 +-
dev-support/testingtool/run_hbck2_test.sh | 2 +-
.../testingtool/scripts/deleteRegionInMeta.sh | 2 +-
hbase-hbck2/README.md | 2 +-
hbase-hbck2/pom.xml | 185 ++-
.../main/java/org/apache/hbase/FileSystemFsck.java | 23 +-
.../org/apache/hbase/FsRegionsMetaRecoverer.java | 124 +-
.../src/main/java/org/apache/hbase/HBCK2.java | 387 ++---
.../apache/hbase/HBCKAbstractFileStatusFilter.java | 23 +-
.../main/java/org/apache/hbase/HBCKActions.java | 17 +-
.../org/apache/hbase/HBCKFileStatusFilter.java | 15 +-
.../org/apache/hbase/HBCKFsTableDescriptors.java | 200 +--
.../main/java/org/apache/hbase/HBCKFsUtils.java | 165 +-
.../main/java/org/apache/hbase/HBCKMetaEntry.java | 4 +-
.../org/apache/hbase/HBCKMetaTableAccessor.java | 354 ++--
.../main/java/org/apache/hbase/HBCKRegionInfo.java | 69 +-
.../hbase/MissingTableDescriptorGenerator.java | 66 +-
.../org/apache/hbase/RegionInfoMismatchTool.java | 90 +-
.../java/org/apache/hbase/ReplicationFsck.java | 3 +-
.../src/main/java/org/apache/hbase/Version.java | 42 +-
.../java/org/apache/hbase/hbck1/HBaseFsck.java | 1738 +++++++++-----------
.../org/apache/hbase/hbck1/HBaseFsckRepair.java | 85 +-
.../apache/hbase/hbck1/HFileCorruptionChecker.java | 144 +-
.../org/apache/hbase/hbck1/OfflineMetaRepair.java | 42 +-
.../org/apache/hbase/hbck1/ReplicationChecker.java | 24 +-
.../hbase/hbck1/TableIntegrityErrorHandler.java | 52 +-
.../apache/hbase/TestFsRegionsMetaRecoverer.java | 125 +-
.../src/test/java/org/apache/hbase/TestHBCK2.java | 267 ++-
.../apache/hbase/TestHBCKCommandLineParsing.java | 79 +-
.../TestHBCKFsTableDescriptorForceCreation.java | 17 +-
.../apache/hbase/TestHBCKFsTableDescriptors.java | 43 +-
.../apache/hbase/TestHBCKMetaTableAccessor.java | 16 +-
.../hbase/TestMissingTableDescriptorGenerator.java | 33 +-
.../java/org/apache/hbase/TestRecoverUnknown.java | 2 -
.../apache/hbase/TestRegionInfoMismatchTool.java | 64 +-
.../org/apache/hbase/TestSchedulingRecoveries.java | 4 +-
.../test/java/org/apache/hbase/TestVersion.java | 1 +
.../java/org/apache/hbase/hbck1/TestHBaseFsck.java | 24 +-
.../hbase/hbck1/TestHFileCorruptionChecker.java | 20 +-
hbase-operator-tools-assembly/pom.xml | 39 +-
.../src/main/assembly/bin.xml | 1 -
hbase-table-reporter/README.md | 2 +-
hbase-table-reporter/pom.xml | 68 +-
.../org/apache/hbase/reporter/TableReporter.java | 178 +-
.../apache/hbase/reporter/TestTableReporter.java | 38 +-
hbase-tools/README.md | 4 +-
hbase-tools/pom.xml | 341 ++--
.../apache/hbase/MissingRegionDirsRepairTool.java | 22 +-
.../main/java/org/apache/hbase/RegionsMerger.java | 103 +-
.../hbase/RegionsOnUnknownServersRecoverer.java | 28 +-
.../hbase/TestMissingRegionDirsRepairTool.java | 23 +-
.../java/org/apache/hbase/TestRegionsMerger.java | 49 +-
pom.xml | 258 ++-
63 files changed, 3087 insertions(+), 3097 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 4358833..6dafde2 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -218,5 +218,3 @@
| [HBASE-22906](https://issues.apache.org/jira/browse/HBASE-22906) | Clean up checkstyle complaints in hbase-operator-tools | Trivial | hbase-operator-tools |
| [HBASE-22675](https://issues.apache.org/jira/browse/HBASE-22675) | Use commons-cli from hbase-thirdparty | Major | hbase-operator-tools |
| [HBASE-21433](https://issues.apache.org/jira/browse/HBASE-21433) | [hbase-operator-tools] Add Apache Yetus integration for hbase-operator-tools repository | Major | build, hbase-operator-tools |
-
-
diff --git a/NOTICE.txt b/NOTICE.txt
index 0a81cd5..19633c8 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -2,4 +2,4 @@ Apache HBase Operator Tools
Copyright 2007-2020 The Apache Software Foundation
This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index f42119a..74e34bb 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -335,6 +335,3 @@ Commands:
$ HBCK2 unassign 1588230740 de00010733901a05f5a2a3a382e27dd4
Returns the pid of the created UnassignProcedure or -1 if none.
{code}
-
-
-
diff --git a/build-support/checkstyle-suppressions.xml b/build-support/checkstyle-suppressions.xml
index 4b5f94f..9ca9b4f 100644
--- a/build-support/checkstyle-suppressions.xml
+++ b/build-support/checkstyle-suppressions.xml
@@ -33,4 +33,4 @@
<suppressions>
<suppress checks="IllegalImport" message="org\.apache\.commons\.cli"/>
<suppress checks="ImportOrder" message="Extra separation in import group before"/>
-</suppressions>
\ No newline at end of file
+</suppressions>
diff --git a/dev-support/create-release/release-tag.sh b/dev-support/create-release/release-tag.sh
index 98be22f..c108bd1 100755
--- a/dev-support/create-release/release-tag.sh
+++ b/dev-support/create-release/release-tag.sh
@@ -110,4 +110,3 @@ else
mv ${PROJECT} ${PROJECT}.tag
echo "Clone with version changes and tag available as ${PROJECT}.tag in the output directory."
fi
-
diff --git a/dev-support/eclipse.importorder b/dev-support/eclipse.importorder
new file mode 100644
index 0000000..68f4e8b
--- /dev/null
+++ b/dev-support/eclipse.importorder
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#Organize Import Order
+3=org.apache.hadoop.hbase.shaded
+2=org.apache.hbase.thirdparty
+1=
+0=\#
diff --git a/dev-support/hbase_eclipse_formatter.xml b/dev-support/hbase_eclipse_formatter.xml
new file mode 100644
index 0000000..99000a6
--- /dev/null
+++ b/dev-support/hbase_eclipse_formatter.xml
@@ -0,0 +1,418 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<profiles version="22">
+ <profile kind="CodeFormatterProfile" name="'HBase Apache Current'" version="22">
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" 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.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
+ <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_space_before_closing_paren_in_while" value="do not insert"/>
+ <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.comment.format_javadoc_comments" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.indentation.size" value="2"/>
+ <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
+ <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not 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_multiple_local_declarations" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="20"/>
+ <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.comment.indent_root_tags" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="20"/>
+ <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.wrap_before_multiplicative_operator" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="true"/>
+ <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_after_prefix_operator" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" 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_new_line_after_annotation_on_method" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="20"/>
+ <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.keep_annotation_declaration_on_one_line" value="one_line_never"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="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_space_after_assignment_operator" value="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_opening_paren_in_for" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="1"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
+ <setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
+ <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.alignment_for_union_type_in_multicatch" value="20"/>
+ <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.keep_else_statement_on_same_line" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
+ <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_before_comma_in_array_initializer" value="do not 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.alignment_for_arguments_in_explicit_constructor_call" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_never"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
+ <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
+ <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.wrap_before_switch_case_arrow_operator" value="false"/>
+ <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_unary_operator" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="0"/>
+ <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_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
+ <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_between_empty_parens_in_method_declaration" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/>
+ <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
+ <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.format_guardian_clause_on_one_line" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types" value="do not 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.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="52"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator" value="true"/>
+ <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.alignment_for_method_declaration" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="20"/>
+ <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_space_before_colon_in_for" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" 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_comma_in_allocation_expression" value="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_brace_in_array_initializer" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="20"/>
+ <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_after_not_operator" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" 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.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
+ <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.parentheses_positions_in_method_delcaration" value="common_lines"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="20"/>
+ <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_before_opening_paren_in_enum_constant" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="16"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="49"/>
+ <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
+ <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_before_assignment_operator" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" 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_closing_paren_in_cast" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="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.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
+ <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_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" 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.wrap_before_bitwise_operator" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="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.comment.indent_tag_description" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="end_of_line"/>
+ <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_between_brackets_in_array_type_reference" value="do not 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.alignment_for_string_concatenation" value="20"/>
+ <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_bracket_in_array_allocation_expression" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
+ <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_before_prefix_operator" 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_before_shift_operator" value="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.insert_space_after_comma_in_type_parameters" value="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_after_shift_operator" 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_before_comma_in_multiple_local_declarations" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
+ <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.insert_space_before_comma_in_record_components" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
+ <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_before_opening_paren_in_synchronized" value="insert"/>
+ <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.alignment_for_expressions_in_for_loop_header" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
+ <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.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" 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.blank_lines_between_import_groups" value="1"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
+ <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
+ <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.parentheses_positions_in_switch_statement" value="common_lines"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" 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.insert_space_after_comma_in_type_arguments" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
+ <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.disabling_tag" value="@formatter:off"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="49"/>
+ <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
+ <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="separate_lines_if_wrapped"/>
+ <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_parenthesized_expression_in_return" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line" value="one_line_never"/>
+ <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_after_opening_paren_in_catch" value="do not insert"/>
+ <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_before_opening_brace_in_anonymous_type_declaration" 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_after_comma_in_for_inits" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
+ <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_question_in_wildcard" value="do not 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_before_comma_in_method_invocation_arguments" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="100"/>
+ <setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/>
+ <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.keep_loop_body_block_on_one_line" value="one_line_never"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
+ <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.alignment_for_additive_operator" value="20"/>
+ <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_opening_brace_in_record_constructor" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_never"/>
+ <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_after_question_in_conditional" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
+ <setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" 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_type_parameters" 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_paren_in_method_invocation" value="do not 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.alignment_for_arguments_in_method_invocation" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="20"/>
+ <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_try" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="16"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="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.insert_space_before_comma_in_type_arguments" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="end_of_line"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line" value="one_line_never"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="52"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="49"/>
+ <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_annotations_on_local_variable" value="49"/>
+ <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_arrow_in_switch_default" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="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_opening_paren_in_while" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
+ <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.alignment_for_annotations_on_field" value="49"/>
+ <setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
+ <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_closing_paren_in_synchronized" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="16"/>
+ <setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_never"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="2"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="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_colon_in_conditional" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
+ <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.brace_position_for_switch" value="end_of_line"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not 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.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_never"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="49"/>
+ <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.keep_record_constructor_on_one_line" value="one_line_never"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_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.alignment_for_assertion_message" value="20"/>
+ <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.blank_lines_before_new_chunk" value="1"/>
+ <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_after_opening_paren_in_constructor_declaration" value="do not 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_before_closing_angle_bracket_in_type_arguments" 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.blank_lines_before_member_type" value="1"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration" value="20"/>
+ <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_semicolon" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="20"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
+ <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.parentheses_positions_in_lambda_declaration" value="common_lines"/>
+ <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_comma_in_permitted_types" 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.keep_enum_declaration_on_one_line" value="one_line_never"/>
+ <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.brace_position_for_enum_constant" value="end_of_line"/>
+ <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_multiplicative_operator" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
+ <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_before_comma_in_for_increments" value="do not insert"/>
+ <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.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not 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.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
+ <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="0"/>
+ <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.tabulation.char" value="space"/>
+ <setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="100"/>
+ <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.insert_space_before_opening_paren_in_switch" value="insert"/>
+ </profile>
+</profiles>
diff --git a/dev-support/jenkins/Jenkinsfile b/dev-support/jenkins/Jenkinsfile
index e7c9773..8258fa0 100644
--- a/dev-support/jenkins/Jenkinsfile
+++ b/dev-support/jenkins/Jenkinsfile
@@ -138,4 +138,4 @@ pipeline {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/dev-support/jenkins/jenkins_precommit_github_yetus.sh b/dev-support/jenkins/jenkins_precommit_github_yetus.sh
index 2cede2f..81a015d 100755
--- a/dev-support/jenkins/jenkins_precommit_github_yetus.sh
+++ b/dev-support/jenkins/jenkins_precommit_github_yetus.sh
@@ -127,4 +127,4 @@ YETUS_ARGS+=("--proclimit=5000")
echo "Launching yetus with command line:"
echo "${TESTPATCHBIN} ${YETUS_ARGS[*]}"
-/usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}"
\ No newline at end of file
+/usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}"
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaEntry.java b/dev-support/license-header
similarity index 59%
copy from hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaEntry.java
copy to dev-support/license-header
index 2c60139..2379dda 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaEntry.java
+++ b/dev-support/license-header
@@ -15,27 +15,3 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hbase;
-
-/**
- * A conveninent representation of a row in meta, composing the encoded name and the related
- * rowkey (region name).
- */
-public class HBCKMetaEntry {
-
- private String encodedRegionName;
- private byte[] regionName;
-
- public HBCKMetaEntry(byte[] regionName, String encodedRegionName) {
- this.regionName = regionName;
- this.encodedRegionName = encodedRegionName;
- }
-
- public byte[] getRegionName() {
- return regionName;
- }
-
- public String getEncodedRegionName() {
- return encodedRegionName;
- }
-}
diff --git a/dev-support/testingtool/hbck2_test.sh b/dev-support/testingtool/hbck2_test.sh
index 3f8a62a..276d478 100755
--- a/dev-support/testingtool/hbck2_test.sh
+++ b/dev-support/testingtool/hbck2_test.sh
@@ -358,4 +358,4 @@ echo "Invoking deleteRegionFromMeta.sh..."
"$SELF/scripts/deleteRegionInMeta.sh" "${hbase_client}" "${working_dir}" "${component_install}" "${hbck2_jar_path}" "${hadoop_jars}" "${hbase_version}" default:testtable
echo "SUCCESS: hbck2 testing succeeded."
-)
\ No newline at end of file
+)
diff --git a/dev-support/testingtool/run_hbck2_test.sh b/dev-support/testingtool/run_hbck2_test.sh
index e910461..1175676 100755
--- a/dev-support/testingtool/run_hbck2_test.sh
+++ b/dev-support/testingtool/run_hbck2_test.sh
@@ -43,4 +43,4 @@ hbase_hbck2_jar=$(ls hbase-hbck2/*target/hbase-hbck2-*)
/path/to/hadoop-x.x.x/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-x.x.x-tests.jar \
/path/to/hadoop-x.x.x/bin/mapred \
"${SELF}/../../${hbase_hbck2_jar}"
-)
\ No newline at end of file
+)
diff --git a/dev-support/testingtool/scripts/deleteRegionInMeta.sh b/dev-support/testingtool/scripts/deleteRegionInMeta.sh
index d68df15..92eb37e 100755
--- a/dev-support/testingtool/scripts/deleteRegionInMeta.sh
+++ b/dev-support/testingtool/scripts/deleteRegionInMeta.sh
@@ -119,4 +119,4 @@ if [ ! "${assign_rowcount}" -eq 1000 ]; then
exit 2
else
echo "SUCCESS: deleteRegionInMeta recovery process succeeded"
-fi
\ No newline at end of file
+fi
diff --git a/hbase-hbck2/README.md b/hbase-hbck2/README.md
index 89f813b..891d851 100644
--- a/hbase-hbck2/README.md
+++ b/hbase-hbck2/README.md
@@ -497,7 +497,7 @@ fetches and the _-t 6000000_ tells the Canary run for ~two hours
maximum. When done, check out _/tmp/canary.log_. Grep for
_ERROR_ lines to find problematic Region assigns.
-You can do a probe like the Canary's in the hbase shell.
+You can do a probe like the Canary's in the hbase shell.
For example, given a Region that has a start row of _d1dddd0c_
belonging to the table _testtable_, do as follows:
diff --git a/hbase-hbck2/pom.xml b/hbase-hbck2/pom.xml
index 629704e..3876dad 100644
--- a/hbase-hbck2/pom.xml
+++ b/hbase-hbck2/pom.xml
@@ -1,6 +1,5 @@
-<?xml version="1.0"?>
-<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
@@ -30,12 +29,92 @@
<artifactId>hbase-hbck2</artifactId>
<name>Apache HBase - HBCK2</name>
<description>HBCK for HBase 2+</description>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <!--This is Log4j2!-->
+ <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${log4j2.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>${log4j2.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <version>${log4j2.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hbase.thirdparty</groupId>
+ <artifactId>hbase-shaded-miscellaneous</artifactId>
+ <version>${hbase-thirdparty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!--We want to use the shaded client but for testing, we need to rely on hbase-server.
+ HBASE-15666 is about how shaded-client and hbase-server won't work together.
+ TODO: Fix.-->
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-server</artifactId>
+ <version>${hbase.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-server</artifactId>
+ <version>${hbase.version}</version>
+ <type>test-jar</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-zookeeper</artifactId>
+ <version>${hbase.version}</version>
+ <type>test-jar</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-common</artifactId>
+ <version>${hbase.version}</version>
+ <type>test-jar</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-testing-util</artifactId>
+ <version>${hbase.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>2.1.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.github.stephenc.findbugs</groupId>
+ <artifactId>findbugs-annotations</artifactId>
+ <version>${findbugs-annotations.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
<build>
<resources>
<resource>
- <directory>src/main/resources</directory>
<filtering>true</filtering>
+ <directory>src/main/resources</directory>
<includes>
<include>**/hbck2.properties</include>
<include>**/log4j2.xml</include>
@@ -44,12 +123,12 @@
</resources>
<testResources>
<testResource>
- <directory>src/test/resources/META-INF/</directory>
<targetPath>META-INF/</targetPath>
+ <filtering>true</filtering>
+ <directory>src/test/resources/META-INF/</directory>
<includes>
<include>NOTICE</include>
</includes>
- <filtering>true</filtering>
</testResource>
</testResources>
<plugins>
@@ -83,10 +162,10 @@
<version>3.2.0</version>
<executions>
<execution>
- <phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
+ <phase>package</phase>
<configuration>
<artifactSet>
<excludes>
@@ -106,6 +185,11 @@
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.5</version>
+ <configuration>
+ <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
+ <commitIdGenerationMode>flat</commitIdGenerationMode>
+ <failOnNoGitDirectory>false</failOnNoGitDirectory>
+ </configuration>
<executions>
<execution>
<id>get-the-git-infos</id>
@@ -126,11 +210,6 @@
<phase>package</phase>
</execution>
</executions>
- <configuration>
- <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
- <commitIdGenerationMode>flat</commitIdGenerationMode>
- <failOnNoGitDirectory>false</failOnNoGitDirectory>
- </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -158,86 +237,6 @@
</plugin>
</plugins>
</build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- <!--This is Log4j2!-->
- <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <version>${log4j2.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <version>${log4j2.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <version>${log4j2.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.hbase.thirdparty</groupId>
- <artifactId>hbase-shaded-miscellaneous</artifactId>
- <version>${hbase-thirdparty.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <!--We want to use the shaded client but for testing, we need to rely on hbase-server.
- HBASE-15666 is about how shaded-client and hbase-server won't work together.
- TODO: Fix.-->
- <dependency>
- <groupId>org.apache.hbase</groupId>
- <artifactId>hbase-server</artifactId>
- <version>${hbase.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.hbase</groupId>
- <artifactId>hbase-server</artifactId>
- <version>${hbase.version}</version>
- <scope>provided</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.hbase</groupId>
- <artifactId>hbase-zookeeper</artifactId>
- <version>${hbase.version}</version>
- <scope>provided</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.hbase</groupId>
- <artifactId>hbase-common</artifactId>
- <version>${hbase.version}</version>
- <scope>provided</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.hbase</groupId>
- <artifactId>hbase-testing-util</artifactId>
- <version>${hbase.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>2.1.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.github.stephenc.findbugs</groupId>
- <artifactId>findbugs-annotations</artifactId>
- <version>${findbugs-annotations.version}</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
<profiles>
<!-- Needs to make the profile in apache parent pom -->
@@ -251,10 +250,10 @@
<executions>
<execution>
<id>license-javadocs</id>
- <phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
+ <phase>prepare-package</phase>
<configuration>
<outputDirectory>${project.build.directory}/apidocs</outputDirectory>
<resources>
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java b/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
index f97995c..d2f63f9 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
@@ -22,7 +22,6 @@ import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -62,10 +61,10 @@ public class FileSystemFsck implements Closeable {
// Check hfiles.
HFileCorruptionChecker hfcc = hbaseFsck.createHFileCorruptionChecker(fix);
hbaseFsck.setHFileCorruptionChecker(hfcc);
- Collection<Path> tableDirs = tables.isEmpty()?
- FSUtils.getTableDirs(this.fs, this.rootDir):
- tables.stream().map(t -> CommonFSUtils.getTableDir(this.rootDir, TableName.valueOf(t))).
- collect(Collectors.toList());
+ Collection<Path> tableDirs = tables.isEmpty()
+ ? FSUtils.getTableDirs(this.fs, this.rootDir)
+ : tables.stream().map(t -> CommonFSUtils.getTableDir(this.rootDir, TableName.valueOf(t)))
+ .collect(Collectors.toList());
hfcc.checkTables(tableDirs);
hfcc.report(hbaseFsck.getErrors());
// Now check links.
@@ -73,15 +72,11 @@ public class FileSystemFsck implements Closeable {
hbaseFsck.setFixHFileLinks(fix);
hbaseFsck.setCheckHdfs(true);
/*
- The below are too radical for hbck2. They are filesystem changes only.
- Need to connect them to hbase:meta and master; master should repair
- holes and overlaps and adopt regions.
-
- hbaseFsck.setFixHdfsOrphans(fix);
- hbaseFsck.setFixHdfsHoles(fix);
- hbaseFsck.setFixHdfsOverlaps(fix);
- hbaseFsck.setFixTableOrphans(fix);
- */
+ * The below are too radical for hbck2. They are filesystem changes only. Need to connect them
+ * to hbase:meta and master; master should repair holes and overlaps and adopt regions.
+ * hbaseFsck.setFixHdfsOrphans(fix); hbaseFsck.setFixHdfsHoles(fix);
+ * hbaseFsck.setFixHdfsOverlaps(fix); hbaseFsck.setFixTableOrphans(fix);
+ */
hbaseFsck.offlineHbck();
} catch (ClassNotFoundException | InterruptedException e) {
throw new IOException(e);
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java b/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java
index cbd2456..1722533 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java
@@ -31,7 +31,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.function.Function;
import java.util.stream.Collectors;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -43,17 +42,16 @@ import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.regionserver.HRegionFileSystem;
import org.apache.hadoop.hbase.util.FSUtils;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class implements the inner works required for checking and recovering regions that wrongly
- * went missing in META, or are left present in META but with no equivalent FS dir.
- * Normally HBCK2 fix options rely on Master self-contained information to recover/fix
- * inconsistencies, but this an exception case where META table is in a broken state.
- * So, it assumes HDFS state as the source of truth, in other words, methods provided here consider
- * meta information found on HDFS region dirs as the valid ones.
+ * went missing in META, or are left present in META but with no equivalent FS dir. Normally HBCK2
+ * fix options rely on Master self-contained information to recover/fix inconsistencies, but this an
+ * exception case where META table is in a broken state. So, it assumes HDFS state as the source of
+ * truth, in other words, methods provided here consider meta information found on HDFS region dirs
+ * as the valid ones.
*/
public class FsRegionsMetaRecoverer implements Closeable {
private static final Logger LOG = LoggerFactory.getLogger(FsRegionsMetaRecoverer.class);
@@ -67,8 +65,9 @@ public class FsRegionsMetaRecoverer implements Closeable {
this.conn = ConnectionFactory.createConnection(configuration);
}
- /*Initially defined for test only purposes */
- FsRegionsMetaRecoverer(Configuration configuration, Connection connection, FileSystem fileSystem){
+ /* Initially defined for test only purposes */
+ FsRegionsMetaRecoverer(Configuration configuration, Connection connection,
+ FileSystem fileSystem) {
this.config = configuration;
this.conn = connection;
this.fs = fileSystem;
@@ -80,14 +79,14 @@ public class FsRegionsMetaRecoverer implements Closeable {
return FSUtils.getRegionDirs(fs, tableDir);
}
- public Map<TableName,List<Path>> reportTablesMissingRegions(final List<String> namespacesOrTables)
- throws IOException {
+ public Map<TableName, List<Path>>
+ reportTablesMissingRegions(final List<String> namespacesOrTables) throws IOException {
InternalMetaChecker<Path> missingChecker = new InternalMetaChecker<>();
return missingChecker.reportTablesRegions(namespacesOrTables, this::findMissingRegionsInMETA);
}
- public Map<TableName,List<HBCKMetaEntry>>
- reportTablesExtraRegions(final List<String> namespacesOrTables) throws IOException {
+ public Map<TableName, List<HBCKMetaEntry>>
+ reportTablesExtraRegions(final List<String> namespacesOrTables) throws IOException {
InternalMetaChecker<HBCKMetaEntry> extraChecker = new InternalMetaChecker<>();
return extraChecker.reportTablesRegions(namespacesOrTables, this::findExtraRegionsInMETA);
}
@@ -102,7 +101,7 @@ public class FsRegionsMetaRecoverer implements Closeable {
List<HBCKMetaEntry> findExtraRegionsInMETA(String table) throws IOException {
InternalMetaChecker<HBCKMetaEntry> extraChecker = new InternalMetaChecker<>();
- return extraChecker.checkRegionsInMETA(table, (regions,dirs) -> {
+ return extraChecker.checkRegionsInMETA(table, (regions, dirs) -> {
ListUtils<HBCKMetaEntry, Path> utils = new ListUtils<>();
return utils.complement(regions, dirs, r -> r.getEncodedRegionName(), d -> d.getName());
});
@@ -115,23 +114,23 @@ public class FsRegionsMetaRecoverer implements Closeable {
List<String> addMissingRegionsInMeta(List<Path> regionsPath) throws IOException {
List<String> reAddedRegionsEncodedNames = new ArrayList<>();
- for(Path regionPath : regionsPath){
+ for (Path regionPath : regionsPath) {
this.putRegionInfoFromHdfsInMeta(regionPath);
reAddedRegionsEncodedNames.add(regionPath.getName());
}
return reAddedRegionsEncodedNames;
}
- public List<Future<List<String>>> addMissingRegionsInMetaForTables(
- List<String> nameSpaceOrTable) throws IOException {
+ public List<Future<List<String>>> addMissingRegionsInMetaForTables(List<String> nameSpaceOrTable)
+ throws IOException {
InternalMetaChecker<Path> missingChecker = new InternalMetaChecker<>();
return missingChecker.processRegionsMetaCleanup(this::reportTablesMissingRegions,
this::addMissingRegionsInMeta, nameSpaceOrTable);
}
- public List<Future<List<String>>> removeExtraRegionsFromMetaForTables(
- List<String> nameSpaceOrTable) throws IOException {
- if(nameSpaceOrTable.size()>0) {
+ public List<Future<List<String>>>
+ removeExtraRegionsFromMetaForTables(List<String> nameSpaceOrTable) throws IOException {
+ if (nameSpaceOrTable.size() > 0) {
InternalMetaChecker<HBCKMetaEntry> extraChecker = new InternalMetaChecker<>();
return extraChecker.processRegionsMetaCleanup(this::reportTablesExtraRegions,
this::deleteAllRegions, nameSpaceOrTable);
@@ -141,7 +140,7 @@ public class FsRegionsMetaRecoverer implements Closeable {
private List<String> deleteAllRegions(List<HBCKMetaEntry> regions) throws IOException {
List<String> resulting = new ArrayList<>();
- for(HBCKMetaEntry r : regions){
+ for (HBCKMetaEntry r : regions) {
HBCKMetaTableAccessor.deleteRegion(conn, r);
resulting.add(r.getEncodedRegionName());
}
@@ -156,30 +155,30 @@ public class FsRegionsMetaRecoverer implements Closeable {
private class InternalMetaChecker<T> {
List<T> checkRegionsInMETA(String table,
- CheckingFunction<List<HBCKMetaEntry>, List<Path>, T> checkingFunction) throws IOException {
+ CheckingFunction<List<HBCKMetaEntry>, List<Path>, T> checkingFunction) throws IOException {
final List<Path> regionsDirs = getTableRegionsDirs(table);
TableName tableName = TableName.valueOf(table);
- List<HBCKMetaEntry> regions = HBCKMetaTableAccessor.
- getTableRegionsAsMetaEntries(FsRegionsMetaRecoverer.this.conn, tableName);
+ List<HBCKMetaEntry> regions = HBCKMetaTableAccessor
+ .getTableRegionsAsMetaEntries(FsRegionsMetaRecoverer.this.conn, tableName);
return checkingFunction.check(regions, regionsDirs);
}
- Map<TableName,List<T>> reportTablesRegions(final List<String> namespacesOrTables,
+ Map<TableName, List<T>> reportTablesRegions(final List<String> namespacesOrTables,
ExecFunction<List<T>, String> checkingFunction) throws IOException {
- final Map<TableName,List<T>> result = new HashMap<>();
- List<TableName> tableNames = HBCKMetaTableAccessor.
- getTables(FsRegionsMetaRecoverer.this.conn).stream()
- .filter(tableName -> {
- if(namespacesOrTables==null || namespacesOrTables.isEmpty()){
- return true;
- } else {
- Optional<String> findings = namespacesOrTables.stream().filter(
- name -> (name.indexOf(":") > 0) ?
- tableName.equals(TableName.valueOf(name)) :
- tableName.getNamespaceAsString().equals(name)).findFirst();
- return findings.isPresent();
- }
- }).collect(Collectors.toList());
+ final Map<TableName, List<T>> result = new HashMap<>();
+ List<TableName> tableNames = HBCKMetaTableAccessor.getTables(FsRegionsMetaRecoverer.this.conn)
+ .stream().filter(tableName -> {
+ if (namespacesOrTables == null || namespacesOrTables.isEmpty()) {
+ return true;
+ } else {
+ Optional<String> findings = namespacesOrTables.stream()
+ .filter(name -> (name.indexOf(":") > 0)
+ ? tableName.equals(TableName.valueOf(name))
+ : tableName.getNamespaceAsString().equals(name))
+ .findFirst();
+ return findings.isPresent();
+ }
+ }).collect(Collectors.toList());
tableNames.stream().forEach(tableName -> {
try {
result.put(tableName,
@@ -192,28 +191,27 @@ public class FsRegionsMetaRecoverer implements Closeable {
}
List<Future<List<String>>> processRegionsMetaCleanup(
- ExecFunction<Map<TableName, List<T>>, List<String>> reportFunction,
- ExecFunction<List<String>, List<T>> execFunction,
- List<String> nameSpaceOrTable) throws IOException {
- ExecutorService executorService = Executors.newFixedThreadPool(
- (nameSpaceOrTable == null ||
- nameSpaceOrTable.size() > Runtime.getRuntime().availableProcessors()) ?
- Runtime.getRuntime().availableProcessors() :
- nameSpaceOrTable.size());
+ ExecFunction<Map<TableName, List<T>>, List<String>> reportFunction,
+ ExecFunction<List<String>, List<T>> execFunction, List<String> nameSpaceOrTable)
+ throws IOException {
+ ExecutorService executorService = Executors.newFixedThreadPool((nameSpaceOrTable == null
+ || nameSpaceOrTable.size() > Runtime.getRuntime().availableProcessors())
+ ? Runtime.getRuntime().availableProcessors()
+ : nameSpaceOrTable.size());
List<Future<List<String>>> futures =
new ArrayList<>(nameSpaceOrTable == null ? 1 : nameSpaceOrTable.size());
try {
- try(final Admin admin = conn.getAdmin()) {
- Map<TableName,List<T>> report = reportFunction.execute(nameSpaceOrTable);
- if(report.size() < 1) {
- LOG.info("\nNo mismatches found in meta. Worth using related reporting function " +
- "first.\nYou are likely passing non-existent " +
- "namespace or table. Note that table names should include the namespace " +
- "portion even for tables in the default namespace. " +
- "See also the command usage.\n");
+ try (final Admin admin = conn.getAdmin()) {
+ Map<TableName, List<T>> report = reportFunction.execute(nameSpaceOrTable);
+ if (report.size() < 1) {
+ LOG.info("\nNo mismatches found in meta. Worth using related reporting function "
+ + "first.\nYou are likely passing non-existent "
+ + "namespace or table. Note that table names should include the namespace "
+ + "portion even for tables in the default namespace. "
+ + "See also the command usage.\n");
}
for (TableName tableName : report.keySet()) {
- if(admin.tableExists(tableName)) {
+ if (admin.tableExists(tableName)) {
futures.add(executorService.submit(new Callable<List<String>>() {
@Override
public List<String> call() throws Exception {
@@ -232,7 +230,7 @@ public class FsRegionsMetaRecoverer implements Closeable {
for (Future<List<String>> f : futures) {
allDone &= f.isDone();
}
- } while(!allDone);
+ } while (!allDone);
}
} finally {
executorService.shutdown();
@@ -242,7 +240,7 @@ public class FsRegionsMetaRecoverer implements Closeable {
}
@FunctionalInterface
- interface CheckingFunction <RegionsList, DirList, T> {
+ interface CheckingFunction<RegionsList, DirList, T> {
List<T> check(RegionsList regions, DirList dirs) throws IOException;
}
@@ -252,13 +250,13 @@ public class FsRegionsMetaRecoverer implements Closeable {
}
public class ListUtils<T1, T2> {
- public List<T1> complement(List<T1> list1, List<T2> list2,
- Function<T1, String> convertT1, Function<T2, String> convertT2) {
+ public List<T1> complement(List<T1> list1, List<T2> list2, Function<T1, String> convertT1,
+ Function<T2, String> convertT2) {
final List<T1> extraRegions = new ArrayList<>();
- HashSet<String> baseSet = list2.stream().map(info ->
- convertT2.apply(info)).collect(Collectors.toCollection(HashSet::new));
+ HashSet<String> baseSet = list2.stream().map(info -> convertT2.apply(info))
+ .collect(Collectors.toCollection(HashSet::new));
list1.forEach(region -> {
- if(!baseSet.contains(convertT1.apply(region))) {
+ if (!baseSet.contains(convertT1.apply(region))) {
extraRegions.add(region);
}
});
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
index 1e63d1d..5918583 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
@@ -37,10 +37,8 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Function;
import java.util.stream.Collectors;
-
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.LineIterator;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
@@ -63,7 +61,6 @@ import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.filter.RowFilter;
import org.apache.hadoop.hbase.filter.SubstringComparator;
import org.apache.hadoop.hbase.master.RegionState;
-
import org.apache.hadoop.hbase.util.Pair;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
@@ -77,11 +74,11 @@ import org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.hbase.thirdparty.org.apache.commons.cli.Option;
import org.apache.hbase.thirdparty.org.apache.commons.cli.Options;
import org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException;
+
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
/**
- * HBase fixup tool version 2, for hbase-2.0.0+ clusters.
- * Supercedes hbck1.
+ * HBase fixup tool version 2, for hbase-2.0.0+ clusters. Supercedes hbck1.
*/
// TODO:
// + On assign, can we look to see if existing assign and if so fail until cancelled?
@@ -110,24 +107,25 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
private static final String FIX_META = "fixMeta";
private static final String REGIONINFO_MISMATCH = "regionInfoMismatch";
// TODO update this map in case of the name of a method changes in Hbck interface
- // in org.apache.hadoop.hbase.client package. Or a new command is added and the hbck command
- // does not equals to the method name in Hbck interface.
- private static final Map<String, List<String> > FUNCTION_NAME_MAP =
- Collections.unmodifiableMap(new HashMap<String, List<String>>() {{
- put(SET_TABLE_STATE, Arrays.asList("setTableStateInMeta"));
- put(BYPASS, Arrays.asList("bypassProcedure"));
- put(SCHEDULE_RECOVERIES, Arrays.asList("scheduleServerCrashProcedure",
- "scheduleServerCrashProcedures"));
- put(RECOVER_UNKNOWN, Arrays.asList("scheduleSCPsForUnknownServers"));
- }});
-
- private static final String ADD_MISSING_REGIONS_IN_META_FOR_TABLES =
- "addFsRegionsMissingInMeta";
+ // in org.apache.hadoop.hbase.client package. Or a new command is added and the hbck command
+ // does not equals to the method name in Hbck interface.
+ private static final Map<String, List<String>> FUNCTION_NAME_MAP =
+ Collections.unmodifiableMap(new HashMap<String, List<String>>() {
+ {
+ put(SET_TABLE_STATE, Arrays.asList("setTableStateInMeta"));
+ put(BYPASS, Arrays.asList("bypassProcedure"));
+ put(SCHEDULE_RECOVERIES,
+ Arrays.asList("scheduleServerCrashProcedure", "scheduleServerCrashProcedures"));
+ put(RECOVER_UNKNOWN, Arrays.asList("scheduleSCPsForUnknownServers"));
+ }
+ });
+
+ private static final String ADD_MISSING_REGIONS_IN_META_FOR_TABLES = "addFsRegionsMissingInMeta";
private static final String REPORT_MISSING_REGIONS_IN_META = "reportMissingRegionsInMeta";
private static final String EXTRA_REGIONS_IN_META = "extraRegionsInMeta";
private Configuration conf;
- static final String [] MINIMUM_HBCK2_VERSION = {"2.0.3", "2.1.1", "2.2.0", "3.0.0"};
+ static final String[] MINIMUM_HBCK2_VERSION = { "2.0.3", "2.1.1", "2.2.0", "3.0.0" };
private boolean skipCheck = false;
/**
@@ -136,26 +134,26 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
private static final long DEFAULT_LOCK_WAIT = 1;
/**
- * Check for HBCK support.
- * Expects created connection.
+ * Check for HBCK support. Expects created connection.
* @param supportedVersions list of zero or more supported versions.
*/
- void checkHBCKSupport(ClusterConnection connection, String cmd, String ... supportedVersions)
- throws IOException {
+ void checkHBCKSupport(ClusterConnection connection, String cmd, String... supportedVersions)
+ throws IOException {
if (skipCheck) {
LOG.info("Skipped {} command version check; 'skip' set", cmd);
return;
}
try (Admin admin = connection.getAdmin()) {
- String serverVersion = admin.
- getClusterMetrics(EnumSet.of(ClusterMetrics.Option.HBASE_VERSION)).getHBaseVersion();
- String [] thresholdVersions = supportedVersions == null || supportedVersions.length == 0?
- MINIMUM_HBCK2_VERSION: supportedVersions;
+ String serverVersion =
+ admin.getClusterMetrics(EnumSet.of(ClusterMetrics.Option.HBASE_VERSION)).getHBaseVersion();
+ String[] thresholdVersions = supportedVersions == null || supportedVersions.length == 0
+ ? MINIMUM_HBCK2_VERSION
+ : supportedVersions;
boolean supported = Version.check(serverVersion, thresholdVersions);
if (!supported) {
- throw new UnsupportedOperationException(cmd + " not supported on server version=" +
- serverVersion + "; needs at least a server that matches or exceeds " +
- Arrays.toString(thresholdVersions));
+ throw new UnsupportedOperationException(cmd + " not supported on server version="
+ + serverVersion + "; needs at least a server that matches or exceeds "
+ + Arrays.toString(thresholdVersions));
}
}
}
@@ -167,19 +165,20 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
}
List<Method> methods = Arrays.asList(connection.getHbck().getClass().getDeclaredMethods());
List<String> finalCmds = FUNCTION_NAME_MAP.getOrDefault(cmd, Collections.singletonList(cmd));
- boolean supported = methods.stream().anyMatch(method -> finalCmds.contains(method.getName()));
+ boolean supported = methods.stream().anyMatch(method -> finalCmds.contains(method.getName()));
if (!supported) {
- throw new UnsupportedOperationException("This HBase cluster does not support command: "
- + cmd);
+ throw new UnsupportedOperationException(
+ "This HBase cluster does not support command: " + cmd);
}
}
public static byte[] getRegionStateColumn(int replicaId) {
try {
- return replicaId == 0 ? HConstants.STATE_QUALIFIER
- : (HConstants.STATE_QUALIFIER_STR + META_REPLICA_ID_DELIMITER
- + String.format(RegionInfo.REPLICA_ID_FORMAT,
- replicaId)).getBytes(StandardCharsets.UTF_8.name());
+ return replicaId == 0
+ ? HConstants.STATE_QUALIFIER
+ : (HConstants.STATE_QUALIFIER_STR + META_REPLICA_ID_DELIMITER
+ + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId))
+ .getBytes(StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
// should never happen!
throw new IllegalArgumentException("UTF8 decoding is not supported", e);
@@ -195,7 +194,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
return;
}
String[] argList = commandLine.getArgs();
- if(!commandLine.hasOption(inputFile.getOpt())) {
+ if (!commandLine.hasOption(inputFile.getOpt())) {
System.out.println(setTableStateByArgs(hbck, argList));
} else {
List<String> inputList = getFromArgsOrFiles(stringArrayToList(argList), true);
@@ -208,23 +207,21 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
TableState setTableStateByArgs(Hbck hbck, String[] args) throws IOException {
if (args == null || args.length < 2) {
- showErrorMessage(SET_TABLE_STATE +
- " takes tablename and state arguments: e.g. user ENABLED, you entered: " +
- Arrays.toString(args));
+ showErrorMessage(
+ SET_TABLE_STATE + " takes tablename and state arguments: e.g. user ENABLED, you entered: "
+ + Arrays.toString(args));
return null;
}
- return setTableState(hbck, TableName.valueOf(args[0]),
- TableState.State.valueOf(args[1]));
+ return setTableState(hbck, TableName.valueOf(args[0]), TableState.State.valueOf(args[1]));
}
TableState setTableState(Hbck hbck, TableName tableName, TableState.State state)
- throws IOException {
+ throws IOException {
return hbck.setTableStateInMeta(new TableState(tableName, state));
}
- int setRegionState(ClusterConnection connection, String region,
- RegionState.State newState)
- throws IOException {
+ int setRegionState(ClusterConnection connection, String region, RegionState.State newState)
+ throws IOException {
return setRegionState(connection, region, 0, newState);
}
@@ -241,7 +238,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
return EXIT_FAILURE;
}
- if(!commandLine.hasOption(inputFile.getOpt())) {
+ if (!commandLine.hasOption(inputFile.getOpt())) {
String[] params = formatSetRegionStateCommand(argList);
return setRegionStateByArgs(connection, params);
} else {
@@ -266,8 +263,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
}
int setRegionState(ClusterConnection connection, String region, int replicaId,
- RegionState.State newState)
- throws IOException {
+ RegionState.State newState) throws IOException {
if (newState == null) {
throw new IllegalArgumentException("State can't be null.");
}
@@ -278,26 +274,25 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
scan.setFilter(filter);
Result result = table.getScanner(scan).next();
if (result != null) {
- byte[] currentStateValue = result.getValue(HConstants.CATALOG_FAMILY,
- getRegionStateColumn(replicaId));
+ byte[] currentStateValue =
+ result.getValue(HConstants.CATALOG_FAMILY, getRegionStateColumn(replicaId));
if (currentStateValue == null) {
System.out.println("WARN: Region state info on meta was NULL");
} else {
- currentState = RegionState.State.valueOf(
- org.apache.hadoop.hbase.util.Bytes.toString(currentStateValue));
+ currentState =
+ RegionState.State.valueOf(org.apache.hadoop.hbase.util.Bytes.toString(currentStateValue));
}
Put put = new Put(result.getRow());
put.addColumn(HConstants.CATALOG_FAMILY, getRegionStateColumn(replicaId),
- org.apache.hadoop.hbase.util.Bytes.toBytes(newState.name()));
+ org.apache.hadoop.hbase.util.Bytes.toBytes(newState.name()));
table.put(put);
if (replicaId == 0) {
- System.out.println("Changed region " + region + " STATE from "
- + currentState + " to " + newState);
+ System.out
+ .println("Changed region " + region + " STATE from " + currentState + " to " + newState);
} else {
- System.out.println("Changed STATE for replica reigon " + replicaId +
- " of primary region " + region +
- "from " + currentState + " to " + newState);
+ System.out.println("Changed STATE for replica reigon " + replicaId + " of primary region "
+ + region + "from " + currentState + " to " + newState);
}
return EXIT_SUCCESS;
@@ -307,25 +302,23 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
return EXIT_FAILURE;
}
- Map<TableName,List<Path>> reportTablesWithMissingRegionsInMeta(String... args)
- throws IOException {
- Map<TableName,List<Path>> report;
- try (final FsRegionsMetaRecoverer fsRegionsMetaRecoverer =
- new FsRegionsMetaRecoverer(this.conf)) {
- report = fsRegionsMetaRecoverer.reportTablesMissingRegions(
- (getInputList(args)));
+ Map<TableName, List<Path>> reportTablesWithMissingRegionsInMeta(String... args)
+ throws IOException {
+ Map<TableName, List<Path>> report;
+ try (
+ final FsRegionsMetaRecoverer fsRegionsMetaRecoverer = new FsRegionsMetaRecoverer(this.conf)) {
+ report = fsRegionsMetaRecoverer.reportTablesMissingRegions((getInputList(args)));
} catch (IOException e) {
LOG.error("Error reporting missing regions: ", e);
throw e;
}
- if(LOG.isDebugEnabled()) {
+ if (LOG.isDebugEnabled()) {
LOG.debug(formatMissingRegionsInMetaReport(report));
}
return report;
}
- Map<TableName, List<String>> extraRegionsInMeta(String[] args)
- throws Exception {
+ Map<TableName, List<String>> extraRegionsInMeta(String[] args) throws Exception {
Options options = new Options();
Option fixOption = Option.builder("f").longOpt("fix").build();
options.addOption(fixOption);
@@ -340,30 +333,29 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
boolean fix = commandLine.hasOption(fixOption.getOpt());
boolean inputFileFlag = commandLine.hasOption(inputFile.getOpt());
- try (final FsRegionsMetaRecoverer fsRegionsMetaRecoverer =
- new FsRegionsMetaRecoverer(this.conf)) {
- List<String> namespacesTables =
- getFromArgsOrFiles(commandLine.getArgList(), inputFileFlag);
+ try (
+ final FsRegionsMetaRecoverer fsRegionsMetaRecoverer = new FsRegionsMetaRecoverer(this.conf)) {
+ List<String> namespacesTables = getFromArgsOrFiles(commandLine.getArgList(), inputFileFlag);
Map<TableName, List<HBCKMetaEntry>> reportMap =
fsRegionsMetaRecoverer.reportTablesExtraRegions(namespacesTables);
final List<String> toFix = new ArrayList<>();
reportMap.entrySet().forEach(e -> {
result.put(e.getKey(),
- e.getValue().stream().map(r->r.getEncodedRegionName()).collect(Collectors.toList()));
- if(fix && e.getValue().size()>0){
+ e.getValue().stream().map(r -> r.getEncodedRegionName()).collect(Collectors.toList()));
+ if (fix && e.getValue().size() > 0) {
toFix.add(e.getKey().getNameWithNamespaceInclAsString());
}
});
- if(fix) {
+ if (fix) {
List<Future<List<String>>> removeResult =
fsRegionsMetaRecoverer.removeExtraRegionsFromMetaForTables(toFix);
- if(removeResult!=null) {
+ if (removeResult != null) {
int totalRegions = 0;
List<Exception> errors = new ArrayList<>();
- for(Future<List<String>> f : removeResult){
+ for (Future<List<String>> f : removeResult) {
try {
totalRegions += f.get().size();
- } catch (ExecutionException|InterruptedException e){
+ } catch (ExecutionException | InterruptedException e) {
errors.add(e);
}
}
@@ -374,18 +366,18 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
LOG.error("Error on checking extra regions: ", e);
throw e;
}
- if(LOG.isDebugEnabled()) {
+ if (LOG.isDebugEnabled()) {
LOG.debug(formatExtraRegionsReport(result));
}
return result;
}
- List<Future<List<String>>> addMissingRegionsInMetaForTables(String...
- nameSpaceOrTable) throws IOException {
- try (final FsRegionsMetaRecoverer fsRegionsMetaRecoverer =
- new FsRegionsMetaRecoverer(this.conf)) {
- return fsRegionsMetaRecoverer.addMissingRegionsInMetaForTables(
- getInputList(nameSpaceOrTable));
+ List<Future<List<String>>> addMissingRegionsInMetaForTables(String... nameSpaceOrTable)
+ throws IOException {
+ try (
+ final FsRegionsMetaRecoverer fsRegionsMetaRecoverer = new FsRegionsMetaRecoverer(this.conf)) {
+ return fsRegionsMetaRecoverer
+ .addMissingRegionsInMetaForTables(getInputList(nameSpaceOrTable));
} catch (IOException e) {
LOG.error("Error adding missing regions: ", e);
throw e;
@@ -406,10 +398,10 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
boolean overrideFlag = commandLine.hasOption(override.getOpt());
boolean inputFileFlag = commandLine.hasOption(inputFile.getOpt());
List<String> argList = commandLine.getArgList();
- return hbck.assigns(getFromArgsOrFiles(argList, inputFileFlag),overrideFlag);
+ return hbck.assigns(getFromArgsOrFiles(argList, inputFileFlag), overrideFlag);
}
- List<Long> unassigns(Hbck hbck, String [] args) throws IOException {
+ List<Long> unassigns(Hbck hbck, String[] args) throws IOException {
Options options = new Options();
Option override = Option.builder("o").longOpt("override").build();
Option inputFile = Option.builder("i").longOpt("inputFiles").build();
@@ -426,9 +418,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
return hbck.unassigns(getFromArgsOrFiles(argList, inputFileFlag), overrideFlag);
}
- /**
- * @return List of results OR null if failed to run.
- */
+ /** Returns List of results OR null if failed to run. */
List<Boolean> bypass(String[] args) throws IOException {
// Bypass has two options....
Options options = new Options();
@@ -454,8 +444,8 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
boolean recursiveFlag = commandLine.hasOption(recursive.getOpt());
boolean inputFileFlag = commandLine.hasOption(inputFile.getOpt());
- String[] pidStrs = getFromArgsOrFiles(commandLine.getArgList(), inputFileFlag)
- .toArray(new String[0]);
+ String[] pidStrs =
+ getFromArgsOrFiles(commandLine.getArgList(), inputFileFlag).toArray(new String[0]);
if (pidStrs == null || pidStrs.length <= 0) {
showErrorMessage("No pids supplied.");
return null;
@@ -502,8 +492,8 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
private HBaseProtos.ServerName parseServerName(String serverName) {
ServerName sn = ServerName.parseServerName(serverName);
- return HBaseProtos.ServerName.newBuilder().setHostName(sn.getHostname()).
- setPort(sn.getPort()).setStartCode(sn.getStartcode()).build();
+ return HBaseProtos.ServerName.newBuilder().setHostName(sn.getHostname()).setPort(sn.getPort())
+ .setStartCode(sn.getStartcode()).build();
}
/**
@@ -558,7 +548,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
private static void usageAddFsRegionsMissingInMeta(PrintWriter writer) {
writer.println(" " + ADD_MISSING_REGIONS_IN_META_FOR_TABLES + " [<NAMESPACE|"
- + "NAMESPACE:TABLENAME>...|-i <INPUTFILES>...]");
+ + "NAMESPACE:TABLENAME>...|-i <INPUTFILES>...]");
writer.println(" Options:");
writer.println(" -i,--inputFiles take one or more files of namespace or table names");
writer.println(" To be used when regions missing from hbase:meta but directories");
@@ -577,16 +567,16 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println(" An example adding missing regions for tables 'tbl_1' in the default");
writer.println(" namespace, 'tbl_2' in namespace 'n1' and for all tables from");
writer.println(" namespace 'n2':");
- writer.println(" $ HBCK2 " + ADD_MISSING_REGIONS_IN_META_FOR_TABLES +
- " default:tbl_1 n1:tbl_2 n2");
+ writer.println(
+ " $ HBCK2 " + ADD_MISSING_REGIONS_IN_META_FOR_TABLES + " default:tbl_1 n1:tbl_2 n2");
writer.println(" Returns HBCK2 an 'assigns' command with all re-inserted regions.");
writer.println(" SEE ALSO: " + REPORT_MISSING_REGIONS_IN_META);
writer.println(" SEE ALSO: " + FIX_META);
writer.println(" If -i or --inputFiles is specified, pass one or more input file names.");
writer.println(" Each file contains <NAMESPACE|NAMESPACE:TABLENAME>, one per line.");
writer.println(" For example:");
- writer.println(" $ HBCK2 " + ADD_MISSING_REGIONS_IN_META_FOR_TABLES +
- " -i fileName1 fileName2");
+ writer.println(
+ " $ HBCK2 " + ADD_MISSING_REGIONS_IN_META_FOR_TABLES + " -i fileName1 fileName2");
}
private static void usageAssigns(PrintWriter writer) {
@@ -654,8 +644,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println(" named similarily. Works against the reports generated by the last");
writer.println(" catalog_janitor and hbck chore runs. If nothing to fix, run is a");
writer.println(" noop. Otherwise, if 'HBCK Report' UI reports problems, a run of");
- writer.println(" " + FIX_META +
- " will clear up hbase:meta issues. See 'HBase HBCK' UI");
+ writer.println(" " + FIX_META + " will clear up hbase:meta issues. See 'HBase HBCK' UI");
writer.println(" for how to generate new execute.");
writer.println(" SEE ALSO: " + REPORT_MISSING_REGIONS_IN_META);
}
@@ -715,8 +704,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println(" regions dirs in the filesystem, if not existing.");
writer.println(" An example triggering extra regions report for tables 'table_1'");
writer.println(" and 'table_2', under default namespace:");
- writer.println(" $ HBCK2 " + EXTRA_REGIONS_IN_META +
- " default:table_1 default:table_2");
+ writer.println(" $ HBCK2 " + EXTRA_REGIONS_IN_META + " default:table_1 default:table_2");
writer.println(" An example triggering missing regions report for table 'table_1'");
writer.println(" under default namespace, and for all tables from namespace 'ns1':");
writer.println(" $ HBCK2 " + EXTRA_REGIONS_IN_META + " default:table_1 ns1");
@@ -730,7 +718,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
private static void usageReportMissingRegionsInMeta(PrintWriter writer) {
writer.println(" " + REPORT_MISSING_REGIONS_IN_META + " [<NAMESPACE|"
- + "NAMESPACE:TABLENAME>...|-i <INPUT_FILE>...]");
+ + "NAMESPACE:TABLENAME>...|-i <INPUT_FILE>...]");
writer.println(" Options:");
writer.println(" -i,--inputFiles take one or more files of encoded region names");
writer.println(" To be used when regions missing from hbase:meta but directories");
@@ -739,8 +727,8 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println(" method, designed for reporting purposes and doesn't perform any");
writer.println(" fixes, providing a view of which regions (if any) would get re-added");
writer.println(" to hbase:meta, grouped by respective table/namespace. To effectively");
- writer.println(" re-add regions in meta, run " + ADD_MISSING_REGIONS_IN_META_FOR_TABLES +
- ".");
+ writer
+ .println(" re-add regions in meta, run " + ADD_MISSING_REGIONS_IN_META_FOR_TABLES + ".");
writer.println(" This command needs hbase:meta to be online. For each namespace/table");
writer.println(" passed as parameter, it performs a diff between regions available in");
writer.println(" hbase:meta against existing regions dirs on HDFS. Region dirs with no");
@@ -759,17 +747,17 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println(" Returns list of missing regions for each table passed as parameter, or");
writer.println(" for each table on namespaces specified as parameter.");
writer.println(" If -i or --inputFiles is specified, pass one or more input file names.");
- writer.println(" Each file contains <NAMESPACE|NAMESPACE:TABLENAME>, one per line.);" +
- "For example:");
+ writer.println(
+ " Each file contains <NAMESPACE|NAMESPACE:TABLENAME>, one per line.);" + "For example:");
writer.println(" $ HBCK2 " + REPORT_MISSING_REGIONS_IN_META + " -i fileName1 fileName2");
}
private static void usageSetRegionState(PrintWriter writer) {
- writer.println(" " + SET_REGION_STATE + " [<ENCODED_REGIONNAME> <STATE>"
- +"|-i <INPUT_FILE>...]");
+ writer
+ .println(" " + SET_REGION_STATE + " [<ENCODED_REGIONNAME> <STATE>" + "|-i <INPUT_FILE>...]");
writer.println(" Options:");
- writer.println(" -i,--inputFiles take one or more files of encoded region names " +
- "and states");
+ writer.println(
+ " -i,--inputFiles take one or more files of encoded region names " + "and states");
writer.println(" To set the replica region's state, it needs the primary region's ");
writer.println(" encoded regionname and replica id. The command will be ");
writer.println(" " + SET_REGION_STATE + " <PRIMARY_ENCODED_REGIONNAME>,<replicaId> <STATE>");
@@ -790,8 +778,8 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println(" $ HBCK2 setRegionState de00010733901a05f5a2a3a382e27dd4 CLOSING");
writer.println(" Returns \"0\" if region state changed and \"1\" otherwise.");
writer.println(" If -i or --inputFiles is specified, pass one or more input file names.");
- writer.println(" Each file contains <ENCODED_REGIONNAME> <STATE>, one pair per line.);" +
- "For example:");
+ writer.println(
+ " Each file contains <ENCODED_REGIONNAME> <STATE>, one pair per line.);" + "For example:");
writer.println(" $ HBCK2 " + SET_REGION_STATE + " -i fileName1 fileName2");
}
@@ -799,8 +787,8 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println(" " + SET_TABLE_STATE + " [<TABLENAME> <STATE>|-i <INPUT_FILE>...]");
writer.println(" Options:");
writer.println(" -i,--inputFiles take one or more files of table names and states");
- writer.println(" Possible table states: " + Arrays.stream(TableState.State.values()).
- map(Enum::toString).collect(Collectors.joining(", ")));
+ writer.println(" Possible table states: " + Arrays.stream(TableState.State.values())
+ .map(Enum::toString).collect(Collectors.joining(", ")));
writer.println(" To read current table state, in the hbase shell run:");
writer.println(" hbase> get 'hbase:meta', '<TABLENAME>', 'table:state'");
writer.println(" A value of \\x08\\x00 == ENABLED, \\x08\\x01 == DISABLED, etc.");
@@ -809,8 +797,8 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println(" $ HBCK2 setTableState users ENABLED");
writer.println(" Returns whatever the previous table state was.");
writer.println(" If -i or --inputFiles is specified, pass one or more input file names.");
- writer.println(" Each file contains <TABLENAME> <STATE>, one pair per line.);" +
- "For example:");
+ writer
+ .println(" Each file contains <TABLENAME> <STATE>, one pair per line.);" + "For example:");
writer.println(" $ HBCK2 " + SET_TABLE_STATE + " -i fileName1 fileName2");
}
@@ -888,10 +876,9 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
}
}
- static void showUsage(Options options){
+ static void showUsage(Options options) {
HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("HBCK2 [OPTIONS] COMMAND <ARGS>",
- "Options:", options, getCommandUsage());
+ formatter.printHelp("HBCK2 [OPTIONS] COMMAND <ARGS>", "Options:", options, getCommandUsage());
}
@Override
@@ -916,19 +903,19 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
options.addOption(help);
Option debug = Option.builder("d").longOpt("debug").desc("run with debug output").build();
options.addOption(debug);
- Option quorum = Option.builder("q").longOpt(HConstants.ZOOKEEPER_QUORUM).hasArg().
- desc("hbase ensemble").build();
+ Option quorum = Option.builder("q").longOpt(HConstants.ZOOKEEPER_QUORUM).hasArg()
+ .desc("hbase ensemble").build();
options.addOption(quorum);
Option parent = Option.builder("z").longOpt(HConstants.ZOOKEEPER_ZNODE_PARENT).hasArg()
- .desc("parent znode of hbase ensemble").build();
+ .desc("parent znode of hbase ensemble").build();
options.addOption(parent);
Option peerPort = Option.builder("p").longOpt(HConstants.ZOOKEEPER_CLIENT_PORT).hasArg()
- .desc("port of hbase ensemble").type(Integer.class).build();
+ .desc("port of hbase ensemble").type(Integer.class).build();
options.addOption(peerPort);
Option version = Option.builder("v").longOpt(VERSION).desc("this hbck2 version").build();
options.addOption(version);
- Option skip = Option.builder("s").longOpt("skip").
- desc("skip hbase version check (PleaseHoldException)").build();
+ Option skip = Option.builder("s").longOpt("skip")
+ .desc("skip hbase version check (PleaseHoldException)").build();
options.addOption(skip);
// Parse command-line.
@@ -963,7 +950,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
getConf().setInt(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.parseInt(optionValue));
} else {
showErrorMessage(
- "Invalid client port. Please provide proper port for target hbase ensemble.");
+ "Invalid client port. Please provide proper port for target hbase ensemble.");
return EXIT_FAILURE;
}
}
@@ -973,7 +960,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
getConf().set(HConstants.ZOOKEEPER_ZNODE_PARENT, optionValue);
} else {
showErrorMessage("Invalid parent znode. Please provide proper parent znode of target hbase."
- + " Note that valid znodes must start with \"/\".");
+ + " Note that valid znodes must start with \"/\".");
return EXIT_FAILURE;
}
}
@@ -984,12 +971,11 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
}
/**
- * Create connection.
- * Needs to be called before we go against remote server.
- * Be sure to close when done.
+ * Create connection. Needs to be called before we go against remote server. Be sure to close when
+ * done.
*/
ClusterConnection connect() throws IOException {
- return (ClusterConnection)ConnectionFactory.createConnection(getConf());
+ return (ClusterConnection) ConnectionFactory.createConnection(getConf());
}
/**
@@ -1005,8 +991,8 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
// the feature FIRST, then move to process the command.
case SET_TABLE_STATE:
if (commands.length < 2) {
- showErrorMessage(command +
- " takes tablename and state arguments: e.g. user ENABLED, or a list of input files");
+ showErrorMessage(command
+ + " takes tablename and state arguments: e.g. user ENABLED, or a list of input files");
return EXIT_FAILURE;
}
try (ClusterConnection connection = connect(); Hbck hbck = connection.getHbck()) {
@@ -1058,7 +1044,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
case SET_REGION_STATE:
if (commands.length < 2) {
showErrorMessage(command + " takes region encoded name and state arguments: e.g. "
- + "35f30b0ce922c34bf5c284eff33ba8b3 CLOSING, or a list of input files");
+ + "35f30b0ce922c34bf5c284eff33ba8b3 CLOSING, or a list of input files");
return EXIT_FAILURE;
}
@@ -1073,8 +1059,9 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
try (FileSystemFsck fsfsck = new FileSystemFsck(getConf())) {
Pair<CommandLine, List<String>> pair =
parseCommandWithFixAndInputOptions(purgeFirst(commands));
- return fsfsck.fsck(pair.getSecond(),
- pair.getFirst().hasOption("f"))!= 0? EXIT_FAILURE : EXIT_SUCCESS;
+ return fsfsck.fsck(pair.getSecond(), pair.getFirst().hasOption("f")) != 0
+ ? EXIT_FAILURE
+ : EXIT_SUCCESS;
}
}
@@ -1084,8 +1071,9 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
try (ReplicationFsck replicationFsck = new ReplicationFsck(getConf())) {
Pair<CommandLine, List<String>> pair =
parseCommandWithFixAndInputOptions(purgeFirst(commands));
- return replicationFsck.fsck(pair.getSecond(),
- pair.getFirst().hasOption("f")) != 0? EXIT_FAILURE : EXIT_SUCCESS;
+ return replicationFsck.fsck(pair.getSecond(), pair.getFirst().hasOption("f")) != 0
+ ? EXIT_FAILURE
+ : EXIT_SUCCESS;
}
}
@@ -1124,7 +1112,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
break;
case ADD_MISSING_REGIONS_IN_META_FOR_TABLES:
- if(commands.length < 2){
+ if (commands.length < 2) {
showErrorMessage(command + " takes one or more table names.");
return EXIT_FAILURE;
}
@@ -1132,20 +1120,19 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
addMissingRegionsInMetaForTables(purgeFirst(commands));
List<String> regionNames = new ArrayList<>();
List<Exception> errors = new ArrayList<>();
- for(Future<List<String>> f : addedRegions){
+ for (Future<List<String>> f : addedRegions) {
try {
regionNames.addAll(f.get());
} catch (InterruptedException | ExecutionException e) {
errors.add(e);
}
}
- System.out.println(formatReAddedRegionsMessage(regionNames,
- errors));
+ System.out.println(formatReAddedRegionsMessage(regionNames, errors));
break;
case REPORT_MISSING_REGIONS_IN_META:
try {
- Map<TableName,List<Path>> report =
+ Map<TableName, List<Path>> report =
reportTablesWithMissingRegionsInMeta(purgeFirst(commands));
System.out.println(formatMissingRegionsInMetaReport(report));
} catch (Exception e) {
@@ -1155,8 +1142,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
case EXTRA_REGIONS_IN_META:
try {
- Map<TableName,List<String>> report =
- extraRegionsInMeta(purgeFirst(commands));
+ Map<TableName, List<String>> report = extraRegionsInMeta(purgeFirst(commands));
System.out.println(formatExtraRegionsReport(report));
} catch (Exception e) {
return EXIT_FAILURE;
@@ -1166,10 +1152,10 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
case GENERATE_TABLE_INFO:
List<String> tableNames = Arrays.asList(purgeFirst(commands));
MissingTableDescriptorGenerator tableInfoGenerator =
- new MissingTableDescriptorGenerator(getConf());
+ new MissingTableDescriptorGenerator(getConf());
try (ClusterConnection connection = connect()) {
- tableInfoGenerator
- .generateTableDescriptorFileIfMissing(connection.getAdmin(), tableNames);
+ tableInfoGenerator.generateTableDescriptorFileIfMissing(connection.getAdmin(),
+ tableNames);
} catch (IOException e) {
showErrorMessage(e.getMessage());
return EXIT_FAILURE;
@@ -1201,33 +1187,32 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
return things.stream().map(Object::toString).collect(Collectors.joining(", "));
}
- private String formatMissingRegionsInMetaReport(Map<TableName,List<Path>> report) {
- Function<Path,String> resolver = r -> r.getName();
+ private String formatMissingRegionsInMetaReport(Map<TableName, List<Path>> report) {
+ Function<Path, String> resolver = r -> r.getName();
String message = "Missing Regions for each table:\n\t";
- return formatReportMessage(message, (HashMap)report, resolver);
+ return formatReportMessage(message, (HashMap) report, resolver);
}
- private String formatExtraRegionsReport(Map<TableName,List<String>> report) {
+ private String formatExtraRegionsReport(Map<TableName, List<String>> report) {
String message = "Regions in Meta but having no equivalent dir, for each table:\n\t";
- return formatReportMessage(message, (HashMap)report, s -> s);
+ return formatReportMessage(message, (HashMap) report, s -> s);
}
private String formatReportMessage(String reportMessage, Map<TableName, List<?>> report,
- Function resolver){
+ Function resolver) {
final StringBuilder builder = new StringBuilder();
- if(report.size() < 1) {
- builder.append("\nNo reports were found. You are likely passing non-existent " +
- "namespace or table. Note that table names should include the namespace " +
- "portion even for tables in the default namespace. See also the command usage.\n");
+ if (report.size() < 1) {
+ builder.append("\nNo reports were found. You are likely passing non-existent "
+ + "namespace or table. Note that table names should include the namespace "
+ + "portion even for tables in the default namespace. See also the command usage.\n");
return builder.toString();
}
builder.append(reportMessage);
report.keySet().forEach(table -> {
builder.append(table);
- if (!report.get(table).isEmpty()){
+ if (!report.get(table).isEmpty()) {
builder.append("->\n\t\t");
- report.get(table).forEach(region -> builder.append(resolver.apply(region))
- .append(" "));
+ report.get(table).forEach(region -> builder.append(resolver.apply(region)).append(" "));
} else {
builder.append(" -> No mismatching regions. This table is good!");
}
@@ -1240,31 +1225,27 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
List<Exception> executionErrors) {
final StringBuilder finalText = new StringBuilder();
finalText.append("Regions re-added into Meta: ").append(readdedRegionNames.size());
- if(!readdedRegionNames.isEmpty()){
- finalText.append("\n")
- .append("WARNING: \n\t")
- .append(readdedRegionNames.size()).append(" regions were added ")
+ if (!readdedRegionNames.isEmpty()) {
+ finalText.append("\n").append("WARNING: \n\t").append(readdedRegionNames.size())
+ .append(" regions were added ")
.append("to META, but these are not yet on Masters cache. \n")
.append("You need to restart Masters, then run hbck2 'assigns' command below:\n\t\t")
.append(buildHbck2AssignsCommand(readdedRegionNames));
}
- if(!executionErrors.isEmpty()){
- finalText.append("\n")
- .append("ERROR: \n\t")
+ if (!executionErrors.isEmpty()) {
+ finalText.append("\n").append("ERROR: \n\t")
.append("There were following errors on at least one table thread:\n");
executionErrors.forEach(e -> finalText.append(e.getMessage()).append("\n"));
}
return finalText.toString();
}
- private String formatRemovedRegionsMessage(int totalRemoved,
- List<Exception> executionErrors) {
+ private String formatRemovedRegionsMessage(int totalRemoved, List<Exception> executionErrors) {
final StringBuilder finalText = new StringBuilder();
- finalText.append("Regions that had no dir on the FileSystem and got removed from Meta: ").
- append(totalRemoved);
- if(!executionErrors.isEmpty()){
- finalText.append("\n")
- .append("ERROR: \n\t")
+ finalText.append("Regions that had no dir on the FileSystem and got removed from Meta: ")
+ .append(totalRemoved);
+ if (!executionErrors.isEmpty()) {
+ finalText.append("\n").append("ERROR: \n\t")
.append("There were following errors on at least one table thread:\n");
executionErrors.forEach(e -> finalText.append(e.getMessage()).append("\n"));
}
@@ -1278,27 +1259,23 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
return builder.toString();
}
- /**
- * @return A new array with first element dropped.
- */
+ /** Returns A new array with first element dropped. */
private static String[] purgeFirst(String[] args) {
int size = args.length;
if (size <= 1) {
- return new String [] {};
+ return new String[] {};
}
size--;
- String [] result = new String [size];
+ String[] result = new String[size];
System.arraycopy(args, 1, result, 0, size);
return result;
}
- /**
- * @return arguements for SET_REGION_STATE command
- */
+ /** Returns arguements for SET_REGION_STATE command */
private String[] formatSetRegionStateCommand(String[] commands) {
if (commands.length < 2) {
showErrorMessage("setRegionState takes region encoded name and state arguments: e.g. "
- + "35f30b0ce922c34bf5c284eff33ba8b3 CLOSING");
+ + "35f30b0ce922c34bf5c284eff33ba8b3 CLOSING");
return null;
}
RegionState.State state = RegionState.State.valueOf(commands[1]);
@@ -1310,18 +1287,18 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
replicaId = Integer.getInteger(commands[0].substring(separatorIndex + 1));
}
if (replicaId > 0) {
- System.out.println("Change state for replica reigon " + replicaId +
- " for primary region " + region);
+ System.out
+ .println("Change state for replica reigon " + replicaId + " for primary region " + region);
}
- return new String[]{region, replicaId.toString(), state.name()};
+ return new String[] { region, replicaId.toString(), state.name() };
}
HBCK2(Configuration conf) {
super(conf);
}
- public static void main(String [] args) throws Exception {
+ public static void main(String[] args) throws Exception {
Configuration conf = HBaseConfiguration.create();
int errCode = org.apache.hadoop.util.ToolRunner.run(new HBCK2(conf), args);
if (errCode != 0) {
@@ -1343,8 +1320,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
if (commandLine == null) {
return null;
}
- return getFromArgsOrFiles(commandLine.getArgList(),
- commandLine.hasOption("i"));
+ return getFromArgsOrFiles(commandLine.getArgList(), commandLine.hasOption("i"));
}
private CommandLine parseCommandWithInputList(String[] args, Options options) {
@@ -1359,22 +1335,20 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
return getCommandLine(args, options);
}
- private Pair<CommandLine,List<String>> parseAndGetCommandLineWithInputOption(String[] args,
+ private Pair<CommandLine, List<String>> parseAndGetCommandLineWithInputOption(String[] args,
Options options) throws IOException {
CommandLine commandLine = parseCommandWithInputList(args, options);
- List<String> params = getFromArgsOrFiles(commandLine.getArgList(),
- commandLine.hasOption("i"));
+ List<String> params = getFromArgsOrFiles(commandLine.getArgList(), commandLine.hasOption("i"));
return Pair.newPair(commandLine, params);
}
- private Pair<CommandLine,List<String>> parseCommandWithFixAndInputOptions(String[] args)
+ private Pair<CommandLine, List<String>> parseCommandWithFixAndInputOptions(String[] args)
throws IOException {
Options options = new Options();
Option fixOption = Option.builder("f").longOpt("fix").build();
options.addOption(fixOption);
CommandLine commandLine = parseCommandWithInputList(args, options);
- List<String> params = getFromArgsOrFiles(commandLine.getArgList(),
- commandLine.hasOption("i"));
+ List<String> params = getFromArgsOrFiles(commandLine.getArgList(), commandLine.hasOption("i"));
return Pair.newPair(commandLine, params);
}
@@ -1393,24 +1367,21 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
}
return commandLine;
}
- /**
- * @return Read arguments from args or a list of input files
- */
+
+ /** Returns Read arguments from args or a list of input files */
private List<String> getFromArgsOrFiles(List<String> args, boolean getFromFile)
- throws IOException {
+ throws IOException {
if (!getFromFile || args == null) {
return args;
}
return getFromFiles(args);
}
- /**
- * @return Read arguments from a list of input files
- */
+ /** Returns Read arguments from a list of input files */
private List<String> getFromFiles(List<String> args) throws IOException {
List<String> argList = new ArrayList<>();
for (String filePath : args) {
- try (InputStream fileStream = new FileInputStream(filePath)){
+ try (InputStream fileStream = new FileInputStream(filePath)) {
LineIterator it = IOUtils.lineIterator(fileStream, "UTF-8");
while (it.hasNext()) {
argList.add(it.nextLine().trim());
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKAbstractFileStatusFilter.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKAbstractFileStatusFilter.java
index d9ea58e..4f45840 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKAbstractFileStatusFilter.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKAbstractFileStatusFilter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,7 +19,6 @@ package org.apache.hbase;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import java.io.IOException;
-
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -27,14 +26,10 @@ import org.apache.hadoop.fs.PathFilter;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
-
/**
- *
- * COPIED from org.apache.hadoop.hbase.util.AbstractFileStatusFilter
- * because the original class was tagged with @InterfaceAudience.Private.
- *
- * Typical base class for file status filter. Works more efficiently when
- * filtering file statuses, otherwise implementation will need to lookup filestatus
+ * COPIED from org.apache.hadoop.hbase.util.AbstractFileStatusFilter because the original class was
+ * tagged with @InterfaceAudience.Private. Typical base class for file status filter. Works more
+ * efficiently when filtering file statuses, otherwise implementation will need to lookup filestatus
* for the path which will be expensive.
*/
@InterfaceAudience.Private
@@ -42,12 +37,10 @@ import org.apache.yetus.audience.InterfaceStability;
public abstract class HBCKAbstractFileStatusFilter implements PathFilter, HBCKFileStatusFilter {
/**
- * Filters out a path. Can be given an optional directory hint to avoid
- * filestatus lookup.
- *
- * @param p A filesystem path
- * @param isDir An optional boolean indicating whether the path is a directory or not
- * @return true if the path is accepted, false if the path is filtered out
+ * Filters out a path. Can be given an optional directory hint to avoid filestatus lookup.
+ * @param p A filesystem path
+ * @param isDir An optional boolean indicating whether the path is a directory or not
+ * @return true if the path is accepted, false if the path is filtered out
*/
protected abstract boolean accept(Path p, @CheckForNull Boolean isDir);
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKActions.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKActions.java
index 01dc209..95437cf 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKActions.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKActions.java
@@ -19,7 +19,6 @@ package org.apache.hbase;
import java.io.IOException;
import java.util.List;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
@@ -56,8 +55,7 @@ public class HBCKActions {
}
String tableName = args[1];
tool.deleteRegionFromMeta(tableName);
- }
- else {
+ } else {
System.err.println("ERROR: Unknown option passed.");
printUsageAndExit();
}
@@ -70,14 +68,13 @@ public class HBCKActions {
System.err.println(" Prints this help message.\n");
System.err.println("deleteRegionFromMeta <tableName>");
System.err.println(" Deletes the middle region from the regions of the\n"
- + " given table from Meta table. Removes whole of the\n"
- + " info column family");
+ + " given table from Meta table. Removes whole of the\n" + " info column family");
System.exit(1);
}
/**
- * Deletes the middle region from the regions of the given table from Meta table
- * Removes whole of the "info" column family
+ * Deletes the middle region from the regions of the given table from Meta table Removes whole of
+ * the "info" column family
*/
private void deleteRegionFromMeta(String tname) throws IOException, InterruptedException {
TableName tn = TableName.valueOf(tname);
@@ -85,7 +82,7 @@ public class HBCKActions {
Table metaTable = connection.getTable(TableName.valueOf("hbase:meta"));
List<RegionInfo> ris = HBCKMetaTableAccessor.getTableRegions(connection, tn);
System.out.println(String.format("Current Regions of the table " + tn.getNameAsString()
- + " in Meta before deletion of the region are: " + ris));
+ + " in Meta before deletion of the region are: " + ris));
RegionInfo ri = ris.get(ris.size() / 2);
System.out.println("Deleting Region " + ri);
byte[] key = HBCKMetaTableAccessor.getMetaKeyForRegion(ri);
@@ -98,7 +95,7 @@ public class HBCKActions {
ris = HBCKMetaTableAccessor.getTableRegions(connection, tn);
System.out.println("Current Regions of the table " + tn.getNameAsString()
- + " in Meta after deletion of the region are: " + ris);
+ + " in Meta after deletion of the region are: " + ris);
}
}
-}
\ No newline at end of file
+}
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFileStatusFilter.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFileStatusFilter.java
index 29aab1f..291f5aa 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFileStatusFilter.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFileStatusFilter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -22,19 +22,16 @@ import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
/**
- * COPIED from org.apache.hadoop.hbase.util.FileStatusFilter
- * because the original class was tagged with @InterfaceAudience.Private.
+ * COPIED from org.apache.hadoop.hbase.util.FileStatusFilter because the original class was tagged
+ * with @InterfaceAudience.Private.
*/
@InterfaceAudience.Private
@InterfaceStability.Evolving
public interface HBCKFileStatusFilter {
/**
- * Tests whether or not the specified filestatus should be
- * included in a filestatus list.
- *
- * @param f The filestatus to be tested
- * @return <code>true</code> if and only if the filestatus
- * should be included
+ * Tests whether or not the specified filestatus should be included in a filestatus list.
+ * @param f The filestatus to be tested
+ * @return <code>true</code> if and only if the filestatus should be included
*/
boolean accept(FileStatus f);
}
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsTableDescriptors.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsTableDescriptors.java
index 3f1d90a..869c2cb 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsTableDescriptors.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsTableDescriptors.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.Comparator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.apache.commons.lang3.NotImplementedException;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
@@ -38,7 +37,6 @@ import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.security.AccessControlException;
import org.apache.yetus.audience.InterfaceAudience;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,31 +44,24 @@ import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesti
import org.apache.hbase.thirdparty.com.google.common.primitives.Ints;
/**
- *
- * COPIED (partially) from org.apache.hadoop.hbase.util.FSTableDescriptors
- * because the original class was tagged with @InterfaceAudience.Private.
- *
- * We only kept the public methods we are using in HBCK. Also removed the cache
- * and readonly features.
- *
- * Implementation of {@link TableDescriptors} that reads descriptors from the
- * passed filesystem. It expects descriptors to be in a file in the
- * {@link #TABLEINFO_DIR} subdir of the table's directory in FS.
- * *
- * <p>Also has utility for keeping up the table descriptors tableinfo file.
- * The table schema file is kept in the {@link #TABLEINFO_DIR} subdir
- * of the table directory in the filesystem.
- * It has a {@link #TABLEINFO_FILE_PREFIX} and then a suffix that is the
- * edit sequenceid: e.g. <code>.tableinfo.0000000003</code>. This sequenceid
- * is always increasing. It starts at zero. The table schema file with the
- * highest sequenceid has the most recent schema edit. Usually there is one file
- * only, the most recent but there may be short periods where there are more
- * than one file. Old files are eventually cleaned. Presumption is that there
- * will not be lots of concurrent clients making table schema edits. If so,
- * the below needs a bit of a reworking and perhaps some supporting api in hdfs.
+ * COPIED (partially) from org.apache.hadoop.hbase.util.FSTableDescriptors because the original
+ * class was tagged with @InterfaceAudience.Private. We only kept the public methods we are using in
+ * HBCK. Also removed the cache and readonly features. Implementation of {@link TableDescriptors}
+ * that reads descriptors from the passed filesystem. It expects descriptors to be in a file in the
+ * {@link #TABLEINFO_DIR} subdir of the table's directory in FS. *
+ * <p>
+ * Also has utility for keeping up the table descriptors tableinfo file. The table schema file is
+ * kept in the {@link #TABLEINFO_DIR} subdir of the table directory in the filesystem. It has a
+ * {@link #TABLEINFO_FILE_PREFIX} and then a suffix that is the edit sequenceid: e.g.
+ * <code>.tableinfo.0000000003</code>. This sequenceid is always increasing. It starts at zero. The
+ * table schema file with the highest sequenceid has the most recent schema edit. Usually there is
+ * one file only, the most recent but there may be short periods where there are more than one file.
+ * Old files are eventually cleaned. Presumption is that there will not be lots of concurrent
+ * clients making table schema edits. If so, the below needs a bit of a reworking and perhaps some
+ * supporting api in hdfs.
*/
@InterfaceAudience.Private
-public class HBCKFsTableDescriptors {
+public class HBCKFsTableDescriptors {
private static final Logger LOG = LoggerFactory.getLogger(HBCKFsTableDescriptors.class);
private final FileSystem fs;
private final Path rootdir;
@@ -82,38 +73,31 @@ public class HBCKFsTableDescriptors {
static final String TABLEINFO_DIR = ".tabledesc";
static final String TMP_DIR = ".tmp";
-
public HBCKFsTableDescriptors(final FileSystem fs, final Path rootdir) {
this.fs = fs;
this.rootdir = rootdir;
}
/**
- * Find the most current table info file for the table located in the given table directory.
- *
- * Looks within the {@link #TABLEINFO_DIR} subdirectory of the given directory for any table info
- * files and takes the 'current' one - meaning the one with the highest sequence number if present
- * or no sequence number at all if none exist (for backward compatibility from before there
- * were sequence numbers).
- *
+ * Find the most current table info file for the table located in the given table directory. Looks
+ * within the {@link #TABLEINFO_DIR} subdirectory of the given directory for any table info files
+ * and takes the 'current' one - meaning the one with the highest sequence number if present or no
+ * sequence number at all if none exist (for backward compatibility from before there were
+ * sequence numbers).
* @return The file status of the current table info file or null if it does not exist
* @throws IOException for IO errors
*/
- public static FileStatus getTableInfoPath(FileSystem fs, Path tableDir)
- throws IOException {
+ public static FileStatus getTableInfoPath(FileSystem fs, Path tableDir) throws IOException {
return getTableInfoPath(fs, tableDir, false);
}
/**
- * Find the most current table info file for the table in the given table directory.
- *
- * Looks within the {@link #TABLEINFO_DIR} subdirectory of the given directory for any table info
- * files and takes the 'current' one - meaning the one with the highest sequence number if
- * present or no sequence number at all if none exist (for backward compatibility from before
- * there were sequence numbers).
- * If there are multiple table info files found and removeOldFiles is true it also deletes the
- * older files.
- *
+ * Find the most current table info file for the table in the given table directory. Looks within
+ * the {@link #TABLEINFO_DIR} subdirectory of the given directory for any table info files and
+ * takes the 'current' one - meaning the one with the highest sequence number if present or no
+ * sequence number at all if none exist (for backward compatibility from before there were
+ * sequence numbers). If there are multiple table info files found and removeOldFiles is true it
+ * also deletes the older files.
* @return The file status of the current table info file or null if none exist
* @throws IOException for IO errors
*/
@@ -124,22 +108,18 @@ public class HBCKFsTableDescriptors {
}
/**
- * Find the most current table info file in the given directory
- *
- * Looks within the given directory for any table info files
- * and takes the 'current' one - meaning the one with the highest sequence number if present
- * or no sequence number at all if none exist (for backward compatibility from before there
- * were sequence numbers).
- * If there are multiple possible files found
- * and the we're not in read only mode it also deletes the older files.
- *
+ * Find the most current table info file in the given directory Looks within the given directory
+ * for any table info files and takes the 'current' one - meaning the one with the highest
+ * sequence number if present or no sequence number at all if none exist (for backward
+ * compatibility from before there were sequence numbers). If there are multiple possible files
+ * found and the we're not in read only mode it also deletes the older files.
* @return The file status of the current table info file or null if it does not exist
* @throws IOException for IO errors
*/
// only visible for FSTableDescriptorMigrationToSubdir, can be removed with that
static FileStatus getCurrentTableInfoStatus(FileSystem fs, Path dir, boolean removeOldFiles)
throws IOException {
- FileStatus [] status = HBCKFsUtils.listStatus(fs, dir, TABLEINFO_PATHFILTER);
+ FileStatus[] status = HBCKFsUtils.listStatus(fs, dir, TABLEINFO_PATHFILTER);
if (status == null || status.length < 1) {
return null;
}
@@ -166,8 +146,7 @@ public class HBCKFsTableDescriptors {
}
/**
- * Compare {@link FileStatus} instances by {@link Path#getName()}. Returns in
- * reverse order.
+ * Compare {@link FileStatus} instances by {@link Path#getName()}. Returns in reverse order.
*/
@VisibleForTesting
static final Comparator<FileStatus> TABLEINFO_FILESTATUS_COMPARATOR =
@@ -175,12 +154,14 @@ public class HBCKFsTableDescriptors {
@Override
public int compare(FileStatus left, FileStatus right) {
return right.compareTo(left);
- }};
+ }
+ };
/**
* Return the table directory in HDFS
*/
- @VisibleForTesting Path getTableDir(final TableName tableName) {
+ @VisibleForTesting
+ Path getTableDir(final TableName tableName) {
return HBCKFsUtils.getTableDir(rootdir, tableName);
}
@@ -189,41 +170,43 @@ public class HBCKFsTableDescriptors {
public boolean accept(Path p) {
// Accept any file that starts with TABLEINFO_NAME
return p.getName().startsWith(TABLEINFO_FILE_PREFIX);
- }};
+ }
+ };
/**
* Width of the sequenceid that is a suffix on a tableinfo file.
*/
- @VisibleForTesting static final int WIDTH_OF_SEQUENCE_ID = 10;
+ @VisibleForTesting
+ static final int WIDTH_OF_SEQUENCE_ID = 10;
/*
* @param number Number to use as suffix.
- * @return Returns zero-prefixed decimal version of passed
- * number (Does absolute in case number is negative).
+ * @return Returns zero-prefixed decimal version of passed number (Does absolute in case number is
+ * negative).
*/
private static String formatTableInfoSequenceId(final int number) {
- byte [] b = new byte[WIDTH_OF_SEQUENCE_ID];
+ byte[] b = new byte[WIDTH_OF_SEQUENCE_ID];
int d = Math.abs(number);
for (int i = b.length - 1; i >= 0; i--) {
- b[i] = (byte)((d % 10) + '0');
+ b[i] = (byte) ((d % 10) + '0');
d /= 10;
}
return Bytes.toString(b);
}
/**
- * Regex to eat up sequenceid suffix and file size suffix on a .tableinfo file.
- * Use regex because may encounter oldstyle .tableinfos where there is no
- * sequenceid nor filesize at the end.
+ * Regex to eat up sequenceid suffix and file size suffix on a .tableinfo file. Use regex because
+ * may encounter oldstyle .tableinfos where there is no sequenceid nor filesize at the end.
*/
private static final Pattern TABLEINFO_FILE_REGEX = Pattern.compile(
- TABLEINFO_FILE_PREFIX + "(\\.([0-9]{" + WIDTH_OF_SEQUENCE_ID + "}))?" + "(\\.([0-9]+))?$");
+ TABLEINFO_FILE_PREFIX + "(\\.([0-9]{" + WIDTH_OF_SEQUENCE_ID + "}))?" + "(\\.([0-9]+))?$");
/**
* @param p Path to a <code>.tableinfo</code> file.
* @return The current editid or 0 if none found.
*/
- @VisibleForTesting static int getTableInfoSequenceId(final Path p) {
+ @VisibleForTesting
+ static int getTableInfoSequenceId(final Path p) {
if (p == null) {
return 0;
}
@@ -242,24 +225,24 @@ public class HBCKFsTableDescriptors {
* @param sequenceid sequence id
* @return Name of tableinfo file.
*/
- @VisibleForTesting static String getTableInfoFileName(final int sequenceid) {
+ @VisibleForTesting
+ static String getTableInfoFileName(final int sequenceid) {
return TABLEINFO_FILE_PREFIX + "." + formatTableInfoSequenceId(sequenceid);
}
/**
- * Returns the latest table descriptor for the given table directly from the file system
- * if it exists, bypassing the local cache.
- * Returns null if it's not found.
+ * Returns the latest table descriptor for the given table directly from the file system if it
+ * exists, bypassing the local cache. Returns null if it's not found.
*/
- public static TableDescriptor getTableDescriptorFromFs(FileSystem fs,
- Path hbaseRootDir, TableName tableName) throws IOException {
+ public static TableDescriptor getTableDescriptorFromFs(FileSystem fs, Path hbaseRootDir,
+ TableName tableName) throws IOException {
Path tableDir = HBCKFsUtils.getTableDir(hbaseRootDir, tableName);
return getTableDescriptorFromFs(fs, tableDir);
}
/**
- * Returns the latest table descriptor for the table located at the given directory
- * directly from the file system if it exists.
+ * Returns the latest table descriptor for the table located at the given directory directly from
+ * the file system if it exists.
* @throws TableInfoMissingException if there is no descriptor
*/
public static TableDescriptor getTableDescriptorFromFs(FileSystem fs, Path tableDir)
@@ -274,7 +257,7 @@ public class HBCKFsTableDescriptors {
private static TableDescriptor readTableDescriptor(FileSystem fs, FileStatus status)
throws IOException {
int len = Ints.checkedCast(status.getLen());
- byte [] content = new byte[len];
+ byte[] content = new byte[len];
FSDataInputStream fsDataInputStream = fs.open(status.getPath());
try {
fsDataInputStream.readFully(content);
@@ -291,8 +274,7 @@ public class HBCKFsTableDescriptors {
}
/**
- * Deletes all the table descriptor files from the file system.
- * Used in unit tests only.
+ * Deletes all the table descriptor files from the file system. Used in unit tests only.
* @throws NotImplementedException if in read only mode
*/
public void deleteTableDescriptorIfExists(TableName tableName) throws IOException {
@@ -302,12 +284,12 @@ public class HBCKFsTableDescriptors {
}
/**
- * Deletes files matching the table info file pattern within the given directory
- * whose sequenceId is at most the given max sequenceId.
+ * Deletes files matching the table info file pattern within the given directory whose sequenceId
+ * is at most the given max sequenceId.
*/
private static void deleteTableDescriptorFiles(FileSystem fs, Path dir, int maxSequenceId)
throws IOException {
- FileStatus [] status = HBCKFsUtils.listStatus(fs, dir, TABLEINFO_PATHFILTER);
+ FileStatus[] status = HBCKFsUtils.listStatus(fs, dir, TABLEINFO_PATHFILTER);
for (FileStatus file : status) {
Path path = file.getPath();
int sequenceId = getTableInfoSequenceId(path);
@@ -323,30 +305,26 @@ public class HBCKFsTableDescriptors {
}
/**
- * Attempts to write a new table descriptor to the given table's directory.
- * It first writes it to the .tmp dir then uses an atomic rename to move it into place.
- * It begins at the currentSequenceId + 1 and tries 10 times to find a new sequence number
- * not already in use.
+ * Attempts to write a new table descriptor to the given table's directory. It first writes it to
+ * the .tmp dir then uses an atomic rename to move it into place. It begins at the
+ * currentSequenceId + 1 and tries 10 times to find a new sequence number not already in use.
* Removes the current descriptor file if passed in.
- *
* @return Descriptor file or null if we failed write.
*/
- private static Path writeTableDescriptor(final FileSystem fs,
- final TableDescriptor htd, final Path tableDir,
- final FileStatus currentDescriptorFile)
- throws IOException {
+ private static Path writeTableDescriptor(final FileSystem fs, final TableDescriptor htd,
+ final Path tableDir, final FileStatus currentDescriptorFile) throws IOException {
// Get temporary dir into which we'll first write a file to avoid half-written file phenomenon.
// This directory is never removed to avoid removing it out from under a concurrent writer.
Path tmpTableDir = new Path(tableDir, TMP_DIR);
Path tableInfoDir = new Path(tableDir, TABLEINFO_DIR);
- // What is current sequenceid? We read the current sequenceid from
- // the current file. After we read it, another thread could come in and
- // compete with us writing out next version of file. The below retries
+ // What is current sequenceid? We read the current sequenceid from
+ // the current file. After we read it, another thread could come in and
+ // compete with us writing out next version of file. The below retries
// should help in this case some but its hard to do guarantees in face of
// concurrent schema edits.
- int currentSequenceId = currentDescriptorFile == null ? 0 :
- getTableInfoSequenceId(currentDescriptorFile.getPath());
+ int currentSequenceId =
+ currentDescriptorFile == null ? 0 : getTableInfoSequenceId(currentDescriptorFile.getPath());
int newSequenceId = currentSequenceId;
// Put arbitrary upperbound on how often we retry
@@ -372,7 +350,7 @@ public class HBCKFsTableDescriptors {
} catch (IOException ioe) {
// fail-fast and get out of retry loop as user does not have privilege to write to hdfs
// hence, no point in retrying
- if(ioe instanceof AccessControlException){
+ if (ioe instanceof AccessControlException) {
throw ioe;
}
// Presume clash of names or something; go around again.
@@ -397,7 +375,7 @@ public class HBCKFsTableDescriptors {
FSDataOutputStream out = fs.create(p, false);
try {
// We used to write this file out as a serialized HTD Writable followed by two '\n's and then
- // the toString version of HTD. Now we just write out the pb serialization.
+ // the toString version of HTD. Now we just write out the pb serialization.
out.write(TableDescriptorBuilder.toByteArray(htd));
} finally {
out.close();
@@ -405,10 +383,8 @@ public class HBCKFsTableDescriptors {
}
/**
- * Create new TableDescriptor in HDFS. Happens when we are creating table. If
- * forceCreation is true then even if previous table descriptor is present it
- * will be overwritten
- *
+ * Create new TableDescriptor in HDFS. Happens when we are creating table. If forceCreation is
+ * true then even if previous table descriptor is present it will be overwritten
* @return True if we successfully created file.
*/
public boolean createTableDescriptor(TableDescriptor htd, boolean forceCreation)
@@ -418,18 +394,18 @@ public class HBCKFsTableDescriptors {
}
/**
- * Create a new TableDescriptor in HDFS in the specified table directory. Happens when we create
- * a new table or snapshot a table.
- * @param tableDir table directory under which we should write the file
- * @param htd description of the table to write
+ * Create a new TableDescriptor in HDFS in the specified table directory. Happens when we create a
+ * new table or snapshot a table.
+ * @param tableDir table directory under which we should write the file
+ * @param htd description of the table to write
* @param forceCreation if <tt>true</tt>,then even if previous table descriptor is present it will
- * be overwritten
+ * be overwritten
* @return <tt>true</tt> if the we successfully created the file, <tt>false</tt> if the file
* already exists and we weren't forcing the descriptor creation.
* @throws IOException if a filesystem error occurs
*/
- public boolean createTableDescriptorForTableDirectory(Path tableDir,
- TableDescriptor htd, boolean forceCreation) throws IOException {
+ public boolean createTableDescriptorForTableDirectory(Path tableDir, TableDescriptor htd,
+ boolean forceCreation) throws IOException {
FileStatus status = getTableInfoPath(fs, tableDir);
if (status != null) {
LOG.debug("Current path=" + status.getPath());
@@ -446,5 +422,3 @@ public class HBCKFsTableDescriptors {
return p != null;
}
}
-
-
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsUtils.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsUtils.java
index e7e534a..baf54ae 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsUtils.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsUtils.java
@@ -18,7 +18,6 @@
package org.apache.hbase;
import edu.umd.cs.findbugs.annotations.CheckForNull;
-
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
@@ -30,7 +29,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.regex.Pattern;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
@@ -48,8 +46,8 @@ import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.Iterators;
/**
- * hbck's local version of the CommonFSUtils from the hbase repo
- * A Utility class to facilitate hbck2's access to tables/namespace dir structures.
+ * hbck's local version of the CommonFSUtils from the hbase repo A Utility class to facilitate
+ * hbck2's access to tables/namespace dir structures.
*/
@InterfaceAudience.Private
public final class HBCKFsUtils {
@@ -64,11 +62,8 @@ public final class HBCKFsUtils {
/**
* Returns the {@link org.apache.hadoop.fs.Path} object representing the table directory under
- * path rootdir
- *
- * COPIED from CommonFSUtils.getTableDir
- *
- * @param rootdir qualified path of HBase root directory
+ * path rootdir COPIED from CommonFSUtils.getTableDir
+ * @param rootdir qualified path of HBase root directory
* @param tableName name of table
* @return {@link org.apache.hadoop.fs.Path} for table
*/
@@ -78,27 +73,20 @@ public final class HBCKFsUtils {
}
/**
- * Returns the {@link org.apache.hadoop.fs.Path} object representing
- * the namespace directory under path rootdir
- *
- * COPIED from CommonFSUtils.getNamespaceDir
- *
- * @param rootdir qualified path of HBase root directory
+ * Returns the {@link org.apache.hadoop.fs.Path} object representing the namespace directory under
+ * path rootdir COPIED from CommonFSUtils.getNamespaceDir
+ * @param rootdir qualified path of HBase root directory
* @param namespace namespace name
* @return {@link org.apache.hadoop.fs.Path} for table
*/
public static Path getNamespaceDir(Path rootdir, final String namespace) {
- return new Path(rootdir, new Path(HConstants.BASE_NAMESPACE_DIR,
- new Path(namespace)));
+ return new Path(rootdir, new Path(HConstants.BASE_NAMESPACE_DIR, new Path(namespace)));
}
/**
- *
* COPIED from CommonFSUtils.getRootDir
- *
* @param c configuration
- * @return {@link Path} to hbase root directory from
- * configuration as a qualified Path.
+ * @return {@link Path} to hbase root directory from configuration as a qualified Path.
* @throws IOException e
*/
public static Path getRootDir(final Configuration c) throws IOException {
@@ -117,15 +105,13 @@ public final class HBCKFsUtils {
}
/**
- * Copy all files/subdirectories from source path to destination path.
- *
- * COPIED from FSUtils.copyFilesParallel
- *
- * @param srcFS FileSystem instance for the source path
- * @param src source path
- * @param dstFS FileSystem instance for the destination path
- * @param dst destination path
- * @param conf a valid hbase configuration object
+ * Copy all files/subdirectories from source path to destination path. COPIED from
+ * FSUtils.copyFilesParallel
+ * @param srcFS FileSystem instance for the source path
+ * @param src source path
+ * @param dstFS FileSystem instance for the destination path
+ * @param dst destination path
+ * @param conf a valid hbase configuration object
* @param threads number of threads to execute the copy
* @return list of Path representing all items residing int the source path
* @throws IOException e
@@ -171,26 +157,21 @@ public final class HBCKFsUtils {
}
return traversedPaths;
}
+
/*
- *
- * COPIED from CommonFSUtils.listStatus
- *
- * Calls fs.listStatus() and treats FileNotFoundException as non-fatal
- * This accommodates differences between hadoop versions, where hadoop 1
- * does not throw a FileNotFoundException, and return an empty FileStatus[]
- * while Hadoop 2 will throw FileNotFoundException.
- *
- * Where possible, prefer FSUtils#listStatusWithStatusFilter(FileSystem,
+ * COPIED from CommonFSUtils.listStatus Calls fs.listStatus() and treats FileNotFoundException as
+ * non-fatal This accommodates differences between hadoop versions, where hadoop 1 does not throw
+ * a FileNotFoundException, and return an empty FileStatus[] while Hadoop 2 will throw
+ * FileNotFoundException. Where possible, prefer FSUtils#listStatusWithStatusFilter(FileSystem,
* Path, FileStatusFilter) instead.
- *
* @param fs file system
* @param dir directory
* @param filter path filter
* @return null if dir is empty or doesn't exist, otherwise FileStatus array
*/
- public static FileStatus [] listStatus(final FileSystem fs,
- final Path dir, final PathFilter filter) throws IOException {
- FileStatus [] status = null;
+ public static FileStatus[] listStatus(final FileSystem fs, final Path dir,
+ final PathFilter filter) throws IOException {
+ FileStatus[] status = null;
try {
status = filter == null ? fs.listStatus(dir) : fs.listStatus(dir, filter);
} catch (FileNotFoundException fnfe) {
@@ -206,13 +187,10 @@ public final class HBCKFsUtils {
}
/**
- *
- * COPIED from CommonFSUtils.delete
- *
- * Calls fs.delete() and returns the value returned by the fs.delete()
- *
- * @param fs must not be null
- * @param path must not be null
+ * COPIED from CommonFSUtils.delete Calls fs.delete() and returns the value returned by the
+ * fs.delete()
+ * @param fs must not be null
+ * @param path must not be null
* @param recursive delete tree rooted at path
* @return the value returned by the fs.delete()
* @throws IOException from underlying FileSystem
@@ -223,27 +201,20 @@ public final class HBCKFsUtils {
}
/**
- *
- * COPIED from CommonFSUtils.deleteDirectory
- *
- * Delete if exists.
- * @param fs filesystem object
+ * COPIED from CommonFSUtils.deleteDirectory Delete if exists.
+ * @param fs filesystem object
* @param dir directory to delete
* @return True if deleted <code>dir</code>
* @throws IOException on IO errors
*/
- public static boolean deleteDirectory(final FileSystem fs, final Path dir)
- throws IOException {
+ public static boolean deleteDirectory(final FileSystem fs, final Path dir) throws IOException {
return fs.exists(dir) && fs.delete(dir, true);
}
/**
- *
- * COPIED from FsUtils.getRegionDirs
- *
- * Given a particular table dir, return all the regiondirs inside it, excluding files such as
- * .tableinfo
- * @param fs A file system for the Path
+ * COPIED from FsUtils.getRegionDirs Given a particular table dir, return all the regiondirs
+ * inside it, excluding files such as .tableinfo
+ * @param fs A file system for the Path
* @param tableDir Path to a specific table directory <hbase.rootdir>/<tabledir>
* @return List of paths to valid region directories in table dir.
* @throws IOException on IO errors
@@ -256,7 +227,7 @@ public final class HBCKFsUtils {
return new ArrayList<>();
}
List<Path> regionDirs = new ArrayList<>(rds.size());
- for (FileStatus rdfs: rds) {
+ for (FileStatus rdfs : rds) {
Path rdPath = rdfs.getPath();
regionDirs.add(rdPath);
}
@@ -264,22 +235,18 @@ public final class HBCKFsUtils {
}
/**
- *
- * COPIED from FsUtils.listStatusWithStatusFilter
- *
- * Calls fs.listStatus() and treats FileNotFoundException as non-fatal
- * This accommodates differences between hadoop versions, where hadoop 1
- * does not throw a FileNotFoundException, and return an empty FileStatus[]
- * while Hadoop 2 will throw FileNotFoundException.
- *
- * @param fs file system
- * @param dir directory
+ * COPIED from FsUtils.listStatusWithStatusFilter Calls fs.listStatus() and treats
+ * FileNotFoundException as non-fatal This accommodates differences between hadoop versions, where
+ * hadoop 1 does not throw a FileNotFoundException, and return an empty FileStatus[] while Hadoop
+ * 2 will throw FileNotFoundException.
+ * @param fs file system
+ * @param dir directory
* @param filter file status filter
* @return null if dir is empty or doesn't exist, otherwise FileStatus list
*/
public static List<FileStatus> listStatusWithStatusFilter(final FileSystem fs, final Path dir,
final HBCKFileStatusFilter filter) throws IOException {
- FileStatus [] status = null;
+ FileStatus[] status = null;
try {
status = fs.listStatus(dir);
} catch (FileNotFoundException fnfe) {
@@ -289,7 +256,7 @@ public final class HBCKFsUtils {
}
}
- if (status == null || status.length < 1) {
+ if (status == null || status.length < 1) {
return null;
}
@@ -306,17 +273,13 @@ public final class HBCKFsUtils {
}
/**
- *
- * COPIED from FsUtils.filterFileStatuses
- *
- * Filters FileStatuses in an array and returns a list
- *
- * @param input An array of FileStatuses
- * @param filter A required filter to filter the array
- * @return A list of FileStatuses
+ * COPIED from FsUtils.filterFileStatuses Filters FileStatuses in an array and returns a list
+ * @param input An array of FileStatuses
+ * @param filter A required filter to filter the array
+ * @return A list of FileStatuses
*/
public static List<FileStatus> filterFileStatuses(FileStatus[] input,
- HBCKFileStatusFilter filter) {
+ HBCKFileStatusFilter filter) {
if (input == null) {
return null;
}
@@ -324,17 +287,13 @@ public final class HBCKFsUtils {
}
/**
- *
- * COPIED from FsUtils.filterFileStatuses
- *
- * Filters FileStatuses in an iterator and returns a list
- *
- * @param input An iterator of FileStatuses
- * @param filter A required filter to filter the array
- * @return A list of FileStatuses
+ * COPIED from FsUtils.filterFileStatuses Filters FileStatuses in an iterator and returns a list
+ * @param input An iterator of FileStatuses
+ * @param filter A required filter to filter the array
+ * @return A list of FileStatuses
*/
public static List<FileStatus> filterFileStatuses(Iterator<FileStatus> input,
- HBCKFileStatusFilter filter) {
+ HBCKFileStatusFilter filter) {
if (input == null) {
return null;
}
@@ -348,13 +307,10 @@ public final class HBCKFsUtils {
return results;
}
-
/**
- *
- * COPIED from FsUtils.FamilyDirFilter
- *
- * Filter for all dirs that are legal column family names. This is generally used for colfam
- * dirs <hbase.rootdir>/<tabledir>/<regiondir>/<colfamdir>.
+ * COPIED from FsUtils.FamilyDirFilter Filter for all dirs that are legal column family names.
+ * This is generally used for colfam dirs
+ * <hbase.rootdir>/<tabledir>/<regiondir>/<colfamdir>.
*/
public static class FamilyDirFilter extends HBCKAbstractFileStatusFilter {
final FileSystem fs;
@@ -377,17 +333,14 @@ public final class HBCKFsUtils {
return isDirectory(fs, isDir, p);
} catch (IOException ioe) {
// Maybe the file was moved or the fs was disconnected.
- LOG.warn("Skipping file " + p +" due to IOException", ioe);
+ LOG.warn("Skipping file " + p + " due to IOException", ioe);
return false;
}
}
}
/**
- *
- * COPIED from FsUtils.RegionDirFilter
- *
- * Filter for all dirs that don't start with '.'
+ * COPIED from FsUtils.RegionDirFilter Filter for all dirs that don't start with '.'
*/
public static class RegionDirFilter extends HBCKAbstractFileStatusFilter {
// This pattern will accept 0.90+ style hex region dirs and older numeric region dir names.
@@ -408,7 +361,7 @@ public final class HBCKFsUtils {
return isDirectory(fs, isDir, p);
} catch (IOException ioe) {
// Maybe the file was moved or the fs was disconnected.
- LOG.warn("Skipping file " + p +" due to IOException", ioe);
+ LOG.warn("Skipping file " + p + " due to IOException", ioe);
return false;
}
}
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaEntry.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaEntry.java
index 2c60139..d5f0744 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaEntry.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaEntry.java
@@ -18,8 +18,8 @@
package org.apache.hbase;
/**
- * A conveninent representation of a row in meta, composing the encoded name and the related
- * rowkey (region name).
+ * A conveninent representation of a row in meta, composing the encoded name and the related rowkey
+ * (region name).
*/
public class HBCKMetaEntry {
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java
index 9ac571b..165128b 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java
@@ -34,7 +34,6 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilder;
import org.apache.hadoop.hbase.CellBuilderFactory;
@@ -64,7 +63,6 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.PairOfSameType;
-
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,8 +70,8 @@ import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
/**
- * hbck's local version of the MetaTableAccessor from the hbase repo
- * A Utility class to facilitate hbck2's access to Meta table.
+ * hbck's local version of the MetaTableAccessor from the hbase repo A Utility class to facilitate
+ * hbck2's access to Meta table.
*/
@InterfaceAudience.Private
public final class HBCKMetaTableAccessor {
@@ -82,8 +80,8 @@ public final class HBCKMetaTableAccessor {
static final char META_REPLICA_ID_DELIMITER = '_';
/** A regex for parsing server columns from meta. See above javadoc for meta layout */
- private static final Pattern SERVER_COLUMN_PATTERN
- = Pattern.compile("^server(_[0-9a-fA-F]{4})?$");
+ private static final Pattern SERVER_COLUMN_PATTERN =
+ Pattern.compile("^server(_[0-9a-fA-F]{4})?$");
/**
* Private constructor to keep this class from being instantiated.
@@ -91,8 +89,7 @@ public final class HBCKMetaTableAccessor {
private HBCKMetaTableAccessor() {
}
- private static final Logger LOG = LoggerFactory.getLogger(
- HBCKMetaTableAccessor.class);
+ private static final Logger LOG = LoggerFactory.getLogger(HBCKMetaTableAccessor.class);
// Constants
private static final byte[] MERGE_QUALIFIER_PREFIX = Bytes.toBytes("merge");
@@ -108,8 +105,8 @@ public final class HBCKMetaTableAccessor {
continue;
}
// Ok. This cell is that of a info:merge* column.
- RegionInfo ri = RegionInfo
- .parseFromOrNull(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
+ RegionInfo ri = RegionInfo.parseFromOrNull(cell.getValueArray(), cell.getValueOffset(),
+ cell.getValueLength());
if (ri != null) {
if (regionsToMerge == null) {
regionsToMerge = new ArrayList<>();
@@ -122,7 +119,6 @@ public final class HBCKMetaTableAccessor {
/**
* Delete the passed <code>RegionInfo</code> from the <code>hbase:meta</code> table.
- *
* @param connection connection we're using
* @param regionInfo the regionInfo to delete from the meta table
* @throws IOException if it's not able to delete the regionInfo
@@ -137,7 +133,6 @@ public final class HBCKMetaTableAccessor {
/**
* Delete the passed <code>RegionInfo</code> from the <code>hbase:meta</code> table.
- *
* @param connection connection we're using
* @param regionInfo the regionInfo to delete from the meta table
* @throws IOException if it's not able to delete the regionInfo
@@ -153,13 +148,11 @@ public final class HBCKMetaTableAccessor {
/**
* Delete the passed <code>HBCKMetaEntry</code> from the <code>hbase:meta</code> table.
- *
* @param connection connection we're using
- * @param region the region to be deleted from the meta table
+ * @param region the region to be deleted from the meta table
* @throws IOException if it's not able to delete the regionInfo
*/
- public static void deleteRegion(Connection connection, HBCKMetaEntry region)
- throws IOException {
+ public static void deleteRegion(Connection connection, HBCKMetaEntry region) throws IOException {
Delete delete = new Delete(region.getRegionName());
delete.addFamily(HConstants.CATALOG_FAMILY, HConstants.LATEST_TIMESTAMP);
deleteFromMetaTable(connection, delete);
@@ -171,14 +164,13 @@ public final class HBCKMetaTableAccessor {
// COPIED from MetaTableAccessor.isMergeQualifierPrefix()
private static boolean isMergeQualifierPrefix(Cell cell) {
// Check to see if has family and that qualifier starts with the MERGE_QUALIFIER_PREFIX
- return CellUtil.matchingFamily(cell, HConstants.CATALOG_FAMILY) && qualifierStartsWith(cell,
- MERGE_QUALIFIER_PREFIX);
+ return CellUtil.matchingFamily(cell, HConstants.CATALOG_FAMILY)
+ && qualifierStartsWith(cell, MERGE_QUALIFIER_PREFIX);
}
/**
- * Finds if the start of the qualifier part of the Cell matches 'startsWith'
- *
- * COPIED from PrivateCellUtil.qualifierStartsWith()
+ * Finds if the start of the qualifier part of the Cell matches 'startsWith' COPIED from
+ * PrivateCellUtil.qualifierStartsWith()
* @param left the cell with which we need to match the qualifier
* @param startsWith the serialized keyvalue format byte[]
* @return true if the qualifier have same staring characters, false otherwise
@@ -187,20 +179,18 @@ public final class HBCKMetaTableAccessor {
if (startsWith == null || startsWith.length == 0) {
throw new IllegalArgumentException("Cannot pass an empty startsWith");
}
- return Bytes
- .equals(left.getQualifierArray(), left.getQualifierOffset(), startsWith.length, startsWith,
- 0, startsWith.length);
+ return Bytes.equals(left.getQualifierArray(), left.getQualifierOffset(), startsWith.length,
+ startsWith, 0, startsWith.length);
}
/**
- * Delete the passed <code>d</code> from the <code>hbase:meta</code> table.
- *
- * COPIED MetaTableAccessor.deleteFromMetaTable()
+ * Delete the passed <code>d</code> from the <code>hbase:meta</code> table. COPIED
+ * MetaTableAccessor.deleteFromMetaTable()
* @param connection connection we're using
* @param d Delete to add to hbase:meta
*/
private static void deleteFromMetaTable(final Connection connection, final Delete d)
- throws IOException {
+ throws IOException {
if (connection == null) {
throw new NullPointerException("No connection");
} else if (connection.isClosed()) {
@@ -216,47 +206,45 @@ public final class HBCKMetaTableAccessor {
/**
* Returns all regions in meta for the given table.
- * @param conn a valid, open connection.
+ * @param conn a valid, open connection.
* @param table the table to list regions in meta.
* @return a list of <code>HBCKMetaEntry</code> with encoded region names, and the meta row key
- * for all table regions present in meta.
+ * for all table regions present in meta.
* @throws IOException on any issues related with scanning meta table
- * */
+ */
public static List<HBCKMetaEntry> getTableRegionsAsMetaEntries(final Connection conn,
- final TableName table) throws IOException {
+ final TableName table) throws IOException {
final MetaScanner<HBCKMetaEntry> scanner = new MetaScanner<>();
final String startRow = Bytes.toString(table.getName()) + ",,";
final String stopRow = Bytes.toString(table.getName()) + " ,,";
- return scanner.scanMeta(conn,
- scan -> {
- scan.withStartRow(Bytes.toBytes(startRow));
- scan.withStopRow(Bytes.toBytes(stopRow));
- },
- r -> {
- if (r.getRow() != null) {
- boolean encodedNameOffset = false;
- StringBuilder encodedNameBuilder = new StringBuilder();
- for(int i=0; i<r.getRow().length; i++){
- if (r.getRow()[i]=='.'){
- encodedNameOffset = !encodedNameOffset;
- continue;
- }
- if(encodedNameOffset){
- encodedNameBuilder.append((char)r.getRow()[i]);
- }
+ return scanner.scanMeta(conn, scan -> {
+ scan.withStartRow(Bytes.toBytes(startRow));
+ scan.withStopRow(Bytes.toBytes(stopRow));
+ }, r -> {
+ if (r.getRow() != null) {
+ boolean encodedNameOffset = false;
+ StringBuilder encodedNameBuilder = new StringBuilder();
+ for (int i = 0; i < r.getRow().length; i++) {
+ if (r.getRow()[i] == '.') {
+ encodedNameOffset = !encodedNameOffset;
+ continue;
+ }
+ if (encodedNameOffset) {
+ encodedNameBuilder.append((char) r.getRow()[i]);
}
- return new HBCKMetaEntry(r.getRow(), encodedNameBuilder.toString());
}
- return null;
- });
+ return new HBCKMetaEntry(r.getRow(), encodedNameBuilder.toString());
+ }
+ return null;
+ });
}
/**
* Returns all regions in meta for the given table.
- * @param conn a valid, open connection.
+ * @param conn a valid, open connection.
* @param table the table to list regions in meta.
- * @return a list of <code>String</code> of encoded region names,
- * for all table regions present in meta.
+ * @return a list of <code>String</code> of encoded region names, for all table regions present in
+ * meta.
* @throws IOException on any issues related with scanning meta table
*/
public static List<RegionInfo> getTableRegions(final Connection conn, final TableName table)
@@ -264,20 +252,18 @@ public final class HBCKMetaTableAccessor {
final MetaScanner<RegionInfo> scanner = new MetaScanner<>();
final String startRow = Bytes.toString(table.getName()) + ",,";
final String stopRow = Bytes.toString(table.getName()) + " ,,";
- return scanner.scanMeta(conn,
- scan -> {
- scan.withStartRow(Bytes.toBytes(startRow));
- scan.withStopRow(Bytes.toBytes(stopRow));
- },
- r -> {
- Cell cell = r.getColumnLatestCell(CATALOG_FAMILY, REGIONINFO_QUALIFIER);
- if(cell != null) {
- RegionInfo info = RegionInfo
- .parseFromOrNull(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
- return info;
- }
- return null;
- });
+ return scanner.scanMeta(conn, scan -> {
+ scan.withStartRow(Bytes.toBytes(startRow));
+ scan.withStopRow(Bytes.toBytes(stopRow));
+ }, r -> {
+ Cell cell = r.getColumnLatestCell(CATALOG_FAMILY, REGIONINFO_QUALIFIER);
+ if (cell != null) {
+ RegionInfo info = RegionInfo.parseFromOrNull(cell.getValueArray(), cell.getValueOffset(),
+ cell.getValueLength());
+ return info;
+ }
+ return null;
+ });
}
/**
@@ -288,12 +274,11 @@ public final class HBCKMetaTableAccessor {
*/
public static List<TableName> getTables(final Connection conn) throws IOException {
MetaScanner<TableName> scanner = new MetaScanner<>();
- return scanner.scanMeta(conn,
- scan -> scan.addColumn(TABLE_FAMILY, TABLE_STATE_QUALIFIER),
+ return scanner.scanMeta(conn, scan -> scan.addColumn(TABLE_FAMILY, TABLE_STATE_QUALIFIER),
r -> {
final byte[] rowBytes = r.getRow();
String table = Bytes.toString(rowBytes);
- if(table.lastIndexOf(HConstants.DELIMITER)>0) {
+ if (table.lastIndexOf(HConstants.DELIMITER) > 0) {
table = table.substring(0, table.lastIndexOf(HConstants.DELIMITER));
}
return TableName.valueOf(table);
@@ -303,13 +288,12 @@ public final class HBCKMetaTableAccessor {
/**
* Converts and adds the passed <code>RegionInfo</code> parameter into a valid 'info:regioninfo'
* cell value in 'hbase:meta'.
- * @param conn a valid, open connection.
+ * @param conn a valid, open connection.
* @param region the region to be inserted in meta.
* @throws IOException on any issues related with scanning meta table
*/
public static void addRegionToMeta(Connection conn, RegionInfo region) throws IOException {
- Put put = makePutFromRegionInfo(region,
- System.currentTimeMillis());
+ Put put = makePutFromRegionInfo(region, System.currentTimeMillis());
addRegionStateToPut(put, RegionState.State.CLOSED);
conn.getTable(TableName.META_TABLE_NAME).put(put);
}
@@ -323,12 +307,11 @@ public final class HBCKMetaTableAccessor {
public static List<RegionInfo> getAllRegions(Connection conn) throws IOException {
MetaScanner<RegionInfo> scanner = new MetaScanner<>();
return scanner.scanMeta(conn,
- scan -> scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER),
- r -> {
- Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,
- HConstants.REGIONINFO_QUALIFIER);
- RegionInfo info = RegionInfo.parseFromOrNull(cell.getValueArray(),
- cell.getValueOffset(), cell.getValueLength());
+ scan -> scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER), r -> {
+ Cell cell =
+ r.getColumnLatestCell(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
+ RegionInfo info = RegionInfo.parseFromOrNull(cell.getValueArray(), cell.getValueOffset(),
+ cell.getValueLength());
return info.isSplit() ? null : info;
});
}
@@ -343,22 +326,19 @@ public final class HBCKMetaTableAccessor {
public static Map<TableName, TableState> getAllTablesStates(Connection conn) throws IOException {
final MetaScanner<Pair<TableName, TableState>> scanner = new MetaScanner<>();
final Map<TableName, TableState> resultMap = new HashMap<>();
- scanner.scanMeta(conn,
- scan -> scan.addColumn(TABLE_FAMILY, TABLE_STATE_QUALIFIER),
- r -> {
- try {
- TableState state = getTableState(r);
- TableName name = TableName.valueOf(r.getRow());
- resultMap.put(name, state);
- } catch (IOException e) {
- LOG.error(e.getMessage());
- }
- return null;
- });
+ scanner.scanMeta(conn, scan -> scan.addColumn(TABLE_FAMILY, TABLE_STATE_QUALIFIER), r -> {
+ try {
+ TableState state = getTableState(r);
+ TableName name = TableName.valueOf(r.getRow());
+ resultMap.put(name, state);
+ } catch (IOException e) {
+ LOG.error(e.getMessage());
+ }
+ return null;
+ });
return resultMap;
}
-
/**
* (Copied partially from MetaTableAccessor)
* @param tableName table we're working with
@@ -369,8 +349,7 @@ public final class HBCKMetaTableAccessor {
return null;
}
byte[] startRow = new byte[tableName.getName().length + 2];
- System.arraycopy(tableName.getName(), 0, startRow, 0,
- tableName.getName().length);
+ System.arraycopy(tableName.getName(), 0, startRow, 0, tableName.getName().length);
startRow[startRow.length - 2] = HConstants.DELIMITER;
startRow[startRow.length - 1] = HConstants.DELIMITER;
return startRow;
@@ -386,8 +365,7 @@ public final class HBCKMetaTableAccessor {
}
final byte[] stopRow;
stopRow = new byte[tableName.getName().length + 3];
- System.arraycopy(tableName.getName(), 0, stopRow, 0,
- tableName.getName().length);
+ System.arraycopy(tableName.getName(), 0, stopRow, 0, tableName.getName().length);
stopRow[stopRow.length - 3] = ' ';
stopRow[stopRow.length - 2] = HConstants.DELIMITER;
stopRow[stopRow.length - 1] = HConstants.DELIMITER;
@@ -398,55 +376,35 @@ public final class HBCKMetaTableAccessor {
public static byte[] getMetaKeyForRegion(RegionInfo regionInfo) {
if (regionInfo.isMetaRegion()) {
return RegionInfoBuilder.newBuilder(regionInfo.getTable())
- .setRegionId(regionInfo.getRegionId())
- .setReplicaId(0)
- .setOffline(regionInfo.isOffline())
+ .setRegionId(regionInfo.getRegionId()).setReplicaId(0).setOffline(regionInfo.isOffline())
.build().getRegionName();
} else {
return RegionInfoBuilder.newBuilder(regionInfo.getTable())
- .setStartKey(regionInfo.getStartKey())
- .setEndKey(regionInfo.getEndKey())
- .setSplit(regionInfo.isSplit())
- .setRegionId(regionInfo.getRegionId())
- .setReplicaId(0)
- .setOffline(regionInfo.isOffline())
- .build().getRegionName();
+ .setStartKey(regionInfo.getStartKey()).setEndKey(regionInfo.getEndKey())
+ .setSplit(regionInfo.isSplit()).setRegionId(regionInfo.getRegionId()).setReplicaId(0)
+ .setOffline(regionInfo.isOffline()).build().getRegionName();
}
}
public static Put addLocation(Put p, ServerName sn, long openSeqNum, int replicaId)
throws IOException {
CellBuilder builder = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY);
- return p.add(builder.clear()
- .setRow(p.getRow())
- .setFamily(CATALOG_FAMILY)
- .setQualifier(getServerColumn(replicaId))
- .setTimestamp(p.getTimestamp())
- .setType(Cell.Type.Put)
- .setValue(Bytes.toBytes(sn.getAddress().toString()))
- .build())
- .add(builder.clear()
- .setRow(p.getRow())
- .setFamily(CATALOG_FAMILY)
- .setQualifier(getStartCodeColumn(replicaId))
- .setTimestamp(p.getTimestamp())
- .setType(Cell.Type.Put)
- .setValue(Bytes.toBytes(sn.getStartcode()))
- .build())
- .add(builder.clear()
- .setRow(p.getRow())
- .setFamily(CATALOG_FAMILY)
- .setQualifier(getSeqNumColumn(replicaId))
- .setTimestamp(p.getTimestamp())
- .setType(Cell.Type.Put)
- .setValue(Bytes.toBytes(openSeqNum))
- .build());
+ return p
+ .add(builder.clear().setRow(p.getRow()).setFamily(CATALOG_FAMILY)
+ .setQualifier(getServerColumn(replicaId)).setTimestamp(p.getTimestamp())
+ .setType(Cell.Type.Put).setValue(Bytes.toBytes(sn.getAddress().toString())).build())
+ .add(builder.clear().setRow(p.getRow()).setFamily(CATALOG_FAMILY)
+ .setQualifier(getStartCodeColumn(replicaId)).setTimestamp(p.getTimestamp())
+ .setType(Cell.Type.Put).setValue(Bytes.toBytes(sn.getStartcode())).build())
+ .add(builder.clear().setRow(p.getRow()).setFamily(CATALOG_FAMILY)
+ .setQualifier(getSeqNumColumn(replicaId)).setTimestamp(p.getTimestamp())
+ .setType(Cell.Type.Put).setValue(Bytes.toBytes(openSeqNum)).build());
}
/**
* Count regions in <code>hbase:meta</code> for passed table.
* @param connection Connection object
- * @param tableName table name to count regions for
+ * @param tableName table name to count regions for
* @return Count or regions in table <code>tableName</code>
*/
public static int getRegionCount(final Connection connection, final TableName tableName)
@@ -458,9 +416,8 @@ public final class HBCKMetaTableAccessor {
}
/**
- * Decode table state from META Result.
- * Should contain cell from HConstants.TABLE_FAMILY
- * (Copied from MetaTableAccessor)
+ * Decode table state from META Result. Should contain cell from HConstants.TABLE_FAMILY (Copied
+ * from MetaTableAccessor)
* @return null if not found
*/
public static TableState getTableState(Result r) throws IOException {
@@ -479,11 +436,10 @@ public final class HBCKMetaTableAccessor {
/**
* Fetch table state for given table from META table
- * @param conn connection to use
+ * @param conn connection to use
* @param tableName table to fetch state for
*/
- public static TableState getTableState(Connection conn, TableName tableName)
- throws IOException {
+ public static TableState getTableState(Connection conn, TableName tableName) throws IOException {
if (tableName.equals(TableName.META_TABLE_NAME)) {
return new TableState(tableName, TableState.State.ENABLED);
}
@@ -499,8 +455,7 @@ public final class HBCKMetaTableAccessor {
*/
public static Put makePutFromTableState(TableState state, long ts) {
Put put = new Put(state.getTableName().getName(), ts);
- put.addColumn(TABLE_FAMILY, TABLE_STATE_QUALIFIER,
- state.convert().toByteArray());
+ put.addColumn(TABLE_FAMILY, TABLE_STATE_QUALIFIER, state.convert().toByteArray());
return put;
}
@@ -509,13 +464,10 @@ public final class HBCKMetaTableAccessor {
*/
public static Put makePutFromRegionInfo(RegionInfo region, long ts) throws IOException {
Put put = new Put(region.getRegionName(), ts);
- //copied from MetaTableAccessor
- put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
- .setRow(put.getRow())
- .setFamily(HConstants.CATALOG_FAMILY)
- .setQualifier(HConstants.REGIONINFO_QUALIFIER)
- .setTimestamp(put.getTimestamp())
- .setType(Cell.Type.Put)
+ // copied from MetaTableAccessor
+ put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setRow(put.getRow())
+ .setFamily(HConstants.CATALOG_FAMILY).setQualifier(HConstants.REGIONINFO_QUALIFIER)
+ .setTimestamp(put.getTimestamp()).setType(Cell.Type.Put)
// Serialize the Default Replica HRI otherwise scan of hbase:meta
// shows an info:regioninfo value with encoded name and region
// name that differs from that of the hbase;meta row.
@@ -525,24 +477,18 @@ public final class HBCKMetaTableAccessor {
}
private static void addRegionStateToPut(Put put, RegionState.State state) throws IOException {
- put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
- .setRow(put.getRow())
- .setFamily(HConstants.CATALOG_FAMILY)
- .setQualifier(HConstants.STATE_QUALIFIER)
- .setTimestamp(put.getTimestamp())
- .setType(Cell.Type.Put)
- .setValue(Bytes.toBytes(state.name()))
+ put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setRow(put.getRow())
+ .setFamily(HConstants.CATALOG_FAMILY).setQualifier(HConstants.STATE_QUALIFIER)
+ .setTimestamp(put.getTimestamp()).setType(Cell.Type.Put).setValue(Bytes.toBytes(state.name()))
.build());
}
/**
- * Remove state for table from meta
- * (Copied from MetaTableAccessor)
+ * Remove state for table from meta (Copied from MetaTableAccessor)
* @param connection to use for deletion
- * @param table to delete state for
+ * @param table to delete state for
*/
- public static void deleteTableState(Connection connection, TableName table)
- throws IOException {
+ public static void deleteTableState(Connection connection, TableName table) throws IOException {
long time = EnvironmentEdgeManager.currentTime();
Delete delete = new Delete(table.getName());
delete.addColumns(TABLE_FAMILY, HConstants.TABLE_STATE_QUALIFIER, time);
@@ -552,11 +498,11 @@ public final class HBCKMetaTableAccessor {
/**
* Updates state in META
- * @param conn connection to use
+ * @param conn connection to use
* @param tableName table to look for
*/
- public static void updateTableState(Connection conn, TableName tableName,
- TableState.State actual) throws IOException {
+ public static void updateTableState(Connection conn, TableName tableName, TableState.State actual)
+ throws IOException {
Put put = makePutFromTableState(new TableState(tableName, actual),
EnvironmentEdgeManager.currentTime());
conn.getTable(TableName.META_TABLE_NAME).put(put);
@@ -564,29 +510,27 @@ public final class HBCKMetaTableAccessor {
/**
* Returns the RegionInfo object from the column {@link HConstants#CATALOG_FAMILY} and
- * <code>qualifier</code> of the catalog table result.
- * (Copied from MetaTableAccessor)
- * @param r a Result object from the catalog table scan
+ * <code>qualifier</code> of the catalog table result. (Copied from MetaTableAccessor)
+ * @param r a Result object from the catalog table scan
* @param qualifier Column family qualifier
* @return An RegionInfo instance or null.
*/
- public static RegionInfo getRegionInfo(final Result r, byte [] qualifier) {
+ public static RegionInfo getRegionInfo(final Result r, byte[] qualifier) {
Cell cell = r.getColumnLatestCell(CATALOG_FAMILY, qualifier);
if (cell == null) {
return null;
}
- return RegionInfo.parseFromOrNull(cell.getValueArray(),
- cell.getValueOffset(), cell.getValueLength());
+ return RegionInfo.parseFromOrNull(cell.getValueArray(), cell.getValueOffset(),
+ cell.getValueLength());
}
/**
- * Returns the HRegionLocation parsed from the given meta row Result
- * for the given regionInfo and replicaId. The regionInfo can be the default region info
- * for the replica.
- * (Copied from MetaTableAccessor)
- * @param r the meta row result
+ * Returns the HRegionLocation parsed from the given meta row Result for the given regionInfo and
+ * replicaId. The regionInfo can be the default region info for the replica. (Copied from
+ * MetaTableAccessor)
+ * @param r the meta row result
* @param regionInfo RegionInfo for default replica
- * @param replicaId the replicaId for the HRegionLocation
+ * @param replicaId the replicaId for the HRegionLocation
* @return HRegionLocation parsed from the given meta row Result for the given replicaId
*/
private static HRegionLocation getRegionLocation(final Result r, final RegionInfo regionInfo,
@@ -598,9 +542,9 @@ public final class HBCKMetaTableAccessor {
}
/**
- * The latest seqnum that the server writing to meta observed when opening the region.
- * E.g. the seqNum when the result of {@link #getServerName(Result, int)} was written.
- * (Copied from MetaTableAccessor)
+ * The latest seqnum that the server writing to meta observed when opening the region. E.g. the
+ * seqNum when the result of {@link #getServerName(Result, int)} was written. (Copied from
+ * MetaTableAccessor)
* @param r Result to pull the seqNum from
* @return SeqNum, or HConstants.NO_SEQNUM if there's no value written.
*/
@@ -613,8 +557,7 @@ public final class HBCKMetaTableAccessor {
}
/**
- * Returns a {@link ServerName} from catalog table {@link Result}.
- * (Copied from MetaTableAccessor)
+ * Returns a {@link ServerName} from catalog table {@link Result}. (Copied from MetaTableAccessor)
* @param r Result to pull from
* @return A ServerName instance or null if necessary fields not found or empty.
*/
@@ -625,8 +568,8 @@ public final class HBCKMetaTableAccessor {
if (cell == null || cell.getValueLength() == 0) {
return null;
}
- String hostAndPort = Bytes.toString(
- cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
+ String hostAndPort =
+ Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
byte[] startcodeColumn = getStartCodeColumn(replicaId);
cell = r.getColumnLatestCell(CATALOG_FAMILY, startcodeColumn);
if (cell == null || cell.getValueLength() == 0) {
@@ -642,10 +585,9 @@ public final class HBCKMetaTableAccessor {
}
/**
- * Returns an HRegionLocationList extracted from the result.
- * (Copied from MetaTableAccessor)
- * @return an HRegionLocationList containing all locations for the region range or null if
- * we can't deserialize the result.
+ * Returns an HRegionLocationList extracted from the result. (Copied from MetaTableAccessor)
+ * @return an HRegionLocationList containing all locations for the region range or null if we
+ * can't deserialize the result.
*/
public static RegionLocations getRegionLocations(final Result r) {
if (r == null) {
@@ -657,7 +599,7 @@ public final class HBCKMetaTableAccessor {
}
List<HRegionLocation> locations = new ArrayList<>(1);
- NavigableMap<byte[], NavigableMap<byte[],byte[]>> familyMap = r.getNoVersionMap();
+ NavigableMap<byte[], NavigableMap<byte[], byte[]>> familyMap = r.getNoVersionMap();
locations.add(getRegionLocation(r, regionInfo, 0));
@@ -695,8 +637,7 @@ public final class HBCKMetaTableAccessor {
}
/**
- * Returns the daughter regions by reading the corresponding columns of the catalog table
- * Result.
+ * Returns the daughter regions by reading the corresponding columns of the catalog table Result.
* (Copied from MetaTableAccessor)
* @param data a Result object from the catalog table scan
* @return pair of RegionInfo or PairOfSameType(null, null) if region is not a split parent
@@ -708,21 +649,20 @@ public final class HBCKMetaTableAccessor {
}
/**
- * Returns the column qualifier for serialized region state
- * (Copied from MetaTableAccessor)
+ * Returns the column qualifier for serialized region state (Copied from MetaTableAccessor)
* @param replicaId the replicaId of the region
* @return a byte[] for sn column qualifier
*/
@VisibleForTesting
static byte[] getServerNameColumn(int replicaId) {
- return replicaId == 0 ? HConstants.SERVERNAME_QUALIFIER
+ return replicaId == 0
+ ? HConstants.SERVERNAME_QUALIFIER
: Bytes.toBytes(HConstants.SERVERNAME_QUALIFIER_STR + META_REPLICA_ID_DELIMITER
- + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
+ + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
}
/**
- * Returns the column qualifier for server column for replicaId
- * (Copied from MetaTableAccessor)
+ * Returns the column qualifier for server column for replicaId (Copied from MetaTableAccessor)
* @param replicaId the replicaId of the region
* @return a byte[] for server column qualifier
*/
@@ -731,12 +671,12 @@ public final class HBCKMetaTableAccessor {
return replicaId == 0
? HConstants.SERVER_QUALIFIER
: Bytes.toBytes(HConstants.SERVER_QUALIFIER_STR + META_REPLICA_ID_DELIMITER
- + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
+ + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
}
/**
- * Returns the column qualifier for server start code column for replicaId
- * (Copied from MetaTableAccessor)
+ * Returns the column qualifier for server start code column for replicaId (Copied from
+ * MetaTableAccessor)
* @param replicaId the replicaId of the region
* @return a byte[] for server start code column qualifier
*/
@@ -745,12 +685,11 @@ public final class HBCKMetaTableAccessor {
return replicaId == 0
? HConstants.STARTCODE_QUALIFIER
: Bytes.toBytes(HConstants.STARTCODE_QUALIFIER_STR + META_REPLICA_ID_DELIMITER
- + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
+ + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
}
/**
- * Returns the column qualifier for seqNum column for replicaId
- * (Copied from MetaTableAccessor)
+ * Returns the column qualifier for seqNum column for replicaId (Copied from MetaTableAccessor)
* @param replicaId the replicaId of the region
* @return a byte[] for seqNum column qualifier
*/
@@ -759,13 +698,12 @@ public final class HBCKMetaTableAccessor {
return replicaId == 0
? HConstants.SEQNUM_QUALIFIER
: Bytes.toBytes(HConstants.SEQNUM_QUALIFIER_STR + META_REPLICA_ID_DELIMITER
- + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
+ + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
}
/**
- * Parses the replicaId from the server column qualifier. See top of the class javadoc
- * for the actual meta layout
- * (Copied from MetaTableAccessor)
+ * Parses the replicaId from the server column qualifier. See top of the class javadoc for the
+ * actual meta layout (Copied from MetaTableAccessor)
* @param serverColumn the column qualifier
* @return an int for the replicaId
*/
@@ -788,16 +726,16 @@ public final class HBCKMetaTableAccessor {
public static class MetaScanner<R> {
public List<R> scanMeta(final Connection conn, Consumer<Scan> scanDecorator,
- Function<Result, R> scanProcessor) throws IOException {
+ Function<Result, R> scanProcessor) throws IOException {
final Scan metaScan = new Scan();
scanDecorator.accept(metaScan);
final Table metaTable = conn.getTable(TableName.META_TABLE_NAME);
final ResultScanner rs = metaTable.getScanner(metaScan);
final List<R> results = new ArrayList<>();
Result result;
- while((result = rs.next())!=null){
+ while ((result = rs.next()) != null) {
R processedResult = scanProcessor.apply(result);
- if(processedResult != null) {
+ if (processedResult != null) {
results.add(processedResult);
}
}
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKRegionInfo.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKRegionInfo.java
index 5119b1c..f9a9954 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKRegionInfo.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKRegionInfo.java
@@ -17,7 +17,6 @@
*/
package org.apache.hbase;
-
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.util.ByteArrayHashKey;
@@ -26,14 +25,14 @@ import org.apache.hadoop.hbase.util.HashKey;
import org.apache.hadoop.hbase.util.JenkinsHash;
/**
- * A copy of utilities from {@link org.apache.hadoop.hbase.client.RegionInfo} to
- * copy internal methods into HBCK2 for stability to avoid using Private methods.
+ * A copy of utilities from {@link org.apache.hadoop.hbase.client.RegionInfo} to copy internal
+ * methods into HBCK2 for stability to avoid using Private methods.
*/
public final class HBCKRegionInfo {
/**
- * Separator used to demarcate the encodedName in a region name
- * in the new format. See description on new format above.
+ * Separator used to demarcate the encodedName in a region name in the new format. See description
+ * on new format above.
*/
static final int ENC_SEPARATOR = '.';
@@ -41,33 +40,30 @@ public final class HBCKRegionInfo {
static final int DEFAULT_REPLICA_ID = 0;
- static final byte REPLICA_ID_DELIMITER = (byte)'_';
+ static final byte REPLICA_ID_DELIMITER = (byte) '_';
- private HBCKRegionInfo() {}
+ private HBCKRegionInfo() {
+ }
/**
* Does region name contain its encoded name?
* @param regionName region name
- * @return boolean indicating if this a new format region
- * name which contains its encoded name.
+ * @return boolean indicating if this a new format region name which contains its encoded name.
*/
public static boolean hasEncodedName(final byte[] regionName) {
// check if region name ends in ENC_SEPARATOR
- return (regionName.length >= 1) &&
- (regionName[regionName.length - 1] == RegionInfo.ENC_SEPARATOR);
+ return (regionName.length >= 1)
+ && (regionName[regionName.length - 1] == RegionInfo.ENC_SEPARATOR);
}
- /**
- * @return the encodedName
- */
- public static String encodeRegionName(final byte [] regionName) {
+ /** Returns the encodedName */
+ public static String encodeRegionName(final byte[] regionName) {
String encodedName;
if (hasEncodedName(regionName)) {
// region is in new format:
// <tableName>,<startKey>,<regionIdTimeStamp>/encodedName/
- encodedName = Bytes.toString(regionName,
- regionName.length - MD5_HEX_LENGTH - 1,
- MD5_HEX_LENGTH);
+ encodedName =
+ Bytes.toString(regionName, regionName.length - MD5_HEX_LENGTH - 1, MD5_HEX_LENGTH);
} else {
// old format region name. First hbase:meta region also
// use this format.EncodedName is the JenkinsHash value.
@@ -79,15 +75,13 @@ public final class HBCKRegionInfo {
}
/**
- * Separate elements of a regionName.
- * Region name is of the format:
- * <code>tablename,startkey,regionIdTimestamp[_replicaId][.encodedName.]</code>.
- * Startkey can contain the delimiter (',') so we parse from the start and then parse from
- * the end.
- * @return Array of byte[] containing tableName, startKey and id OR null if not parseable
- * as a region name.
+ * Separate elements of a regionName. Region name is of the format:
+ * <code>tablename,startkey,regionIdTimestamp[_replicaId][.encodedName.]</code>. Startkey can
+ * contain the delimiter (',') so we parse from the start and then parse from the end.
+ * @return Array of byte[] containing tableName, startKey and id OR null if not parseable as a
+ * region name.
*/
- public static byte [][] parseRegionNameOrReturnNull(final byte[] regionName) {
+ public static byte[][] parseRegionNameOrReturnNull(final byte[] regionName) {
int offset = -1;
for (int i = 0; i < regionName.length; i++) {
if (regionName[i] == HConstants.DELIMITER) {
@@ -104,9 +98,10 @@ public final class HBCKRegionInfo {
int endOffset = regionName.length;
// check whether regionName contains encodedName
- if (regionName.length > MD5_HEX_LENGTH + 2 &&
- regionName[regionName.length-1] == ENC_SEPARATOR &&
- regionName[regionName.length-MD5_HEX_LENGTH-2] == ENC_SEPARATOR) {
+ if (
+ regionName.length > MD5_HEX_LENGTH + 2 && regionName[regionName.length - 1] == ENC_SEPARATOR
+ && regionName[regionName.length - MD5_HEX_LENGTH - 2] == ENC_SEPARATOR
+ ) {
endOffset = endOffset - MD5_HEX_LENGTH - 2;
}
@@ -114,10 +109,9 @@ public final class HBCKRegionInfo {
byte[] replicaId = null;
int idEndOffset = endOffset;
for (int i = endOffset - 1; i > 0; i--) {
- if (regionName[i] == REPLICA_ID_DELIMITER) { //replicaId may or may not be present
+ if (regionName[i] == REPLICA_ID_DELIMITER) { // replicaId may or may not be present
replicaId = new byte[endOffset - i - 1];
- System.arraycopy(regionName, i + 1, replicaId, 0,
- endOffset - i - 1);
+ System.arraycopy(regionName, i + 1, replicaId, 0, endOffset - i - 1);
idEndOffset = i;
// do not break, continue to search for id
}
@@ -129,16 +123,15 @@ public final class HBCKRegionInfo {
if (offset == -1) {
return null;
}
- byte [] startKey = HConstants.EMPTY_BYTE_ARRAY;
- if(offset != tableName.length + 1) {
+ byte[] startKey = HConstants.EMPTY_BYTE_ARRAY;
+ if (offset != tableName.length + 1) {
startKey = new byte[offset - tableName.length - 1];
System.arraycopy(regionName, tableName.length + 1, startKey, 0,
offset - tableName.length - 1);
}
- byte [] id = new byte[idEndOffset - offset - 1];
- System.arraycopy(regionName, offset + 1, id, 0,
- idEndOffset - offset - 1);
- byte [][] elements = new byte[replicaId == null ? 3 : 4][];
+ byte[] id = new byte[idEndOffset - offset - 1];
+ System.arraycopy(regionName, offset + 1, id, 0, idEndOffset - offset - 1);
+ byte[][] elements = new byte[replicaId == null ? 3 : 4][];
elements[0] = tableName;
elements[1] = startKey;
elements[2] = id;
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/MissingTableDescriptorGenerator.java b/hbase-hbck2/src/main/java/org/apache/hbase/MissingTableDescriptorGenerator.java
index 842ec95..34d1890 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/MissingTableDescriptorGenerator.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/MissingTableDescriptorGenerator.java
@@ -23,7 +23,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
@@ -41,8 +40,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This class can be used to generate missing table descriptor file based on the in-memory cache
- * of the active master or based on the file system.
+ * This class can be used to generate missing table descriptor file based on the in-memory cache of
+ * the active master or based on the file system.
*/
public class MissingTableDescriptorGenerator {
@@ -60,21 +59,14 @@ public class MissingTableDescriptorGenerator {
/**
* Trying to generate missing table descriptor. If anything goes wrong, then the method throws
- * IllegalStateException without changing anything. The method follows these steps:
- *
- * - if the table folder is missing, then we return
- * - if the .tableinfo file is not missing, then we return (we don't overwrite it)
- * - if TableDescriptor is cached in master then recover the .tableinfo accordingly
- * - if TableDescriptor is not cached in master, then we create a default .tableinfo file
- * with the following items:
- * - the table name
- * - the column family list (determined based on the file system)
- * - the default properties for both {@link TableDescriptor} and
- * {@link ColumnFamilyDescriptor}
- *
- * This method does not change anything in HBase, only writes the new .tableinfo file
- * to the file system.
- *
+ * IllegalStateException without changing anything. The method follows these steps: - if the table
+ * folder is missing, then we return - if the .tableinfo file is not missing, then we return (we
+ * don't overwrite it) - if TableDescriptor is cached in master then recover the .tableinfo
+ * accordingly - if TableDescriptor is not cached in master, then we create a default .tableinfo
+ * file with the following items: - the table name - the column family list (determined based on
+ * the file system) - the default properties for both {@link TableDescriptor} and
+ * {@link ColumnFamilyDescriptor} This method does not change anything in HBase, only writes the
+ * new .tableinfo file to the file system.
* @param tableNameAsString the table name in standard 'table' or 'ns:table' format
*/
public void generateTableDescriptorFileIfMissing(String tableNameAsString) {
@@ -89,25 +81,25 @@ public class MissingTableDescriptorGenerator {
HBCKFsTableDescriptors fstd = new HBCKFsTableDescriptors(fs, rootDir);
try {
if (tableDescriptorFromMaster.isPresent()) {
- LOG.info("Table descriptor found in the cache of HBase Master, " +
- "writing it to the file system.");
+ LOG.info("Table descriptor found in the cache of HBase Master, "
+ + "writing it to the file system.");
fstd.createTableDescriptor(tableDescriptorFromMaster.get(), false);
LOG.info("Table descriptor written successfully. Orphan table {} fixed.", tableName);
} else {
generateDefaultTableInfo(fstd, tableName);
LOG.info("Table descriptor written successfully.");
- LOG.warn("Orphan table {} fixed with a default .tableinfo file. It is strongly " +
- "recommended to review the TableDescriptor and modify if necessary.", tableName);
+ LOG.warn("Orphan table {} fixed with a default .tableinfo file. It is strongly "
+ + "recommended to review the TableDescriptor and modify if necessary.", tableName);
}
} catch (IOException e) {
LOG.error("Exception while writing the table descriptor to the file system for table {}",
- tableName, e);
+ tableName, e);
}
}
public void generateTableDescriptorFileIfMissing(Admin admin, List<String> tableNamesAsString)
- throws IOException {
+ throws IOException {
// if the list is empty, need to check for all tables
if (tableNamesAsString.isEmpty()) {
List<TableName> tableNameList = Arrays.asList(admin.listTableNames());
@@ -124,17 +116,17 @@ public class MissingTableDescriptorGenerator {
final Path tableDir = HBCKFsUtils.getTableDir(rootDir, tableName);
try {
if (!fs.exists(tableDir)) {
- throw new IllegalStateException("Exiting without changing anything. " +
- "Table folder does not exist: " + tableDir);
+ throw new IllegalStateException(
+ "Exiting without changing anything. " + "Table folder does not exist: " + tableDir);
}
if (!fs.getFileStatus(tableDir).isDirectory()) {
- throw new IllegalStateException("Exiting without changing anything. " +
- "Table folder is not a directory: " + tableDir);
+ throw new IllegalStateException(
+ "Exiting without changing anything. " + "Table folder is not a directory: " + tableDir);
}
} catch (IOException e) {
LOG.error("Exception while trying to find table folder for table {}", tableName, e);
- throw new IllegalStateException("Exiting without changing anything. " +
- "Can not validate if table folder exists.");
+ throw new IllegalStateException(
+ "Exiting without changing anything. " + "Can not validate if table folder exists.");
}
}
@@ -148,8 +140,8 @@ public class MissingTableDescriptorGenerator {
}
} catch (IOException e) {
LOG.error("Exception while trying to find the table descriptor for table {}", tableName, e);
- throw new IllegalStateException("Can not validate if table descriptor exists. " +
- "Exiting without changing anything.");
+ throw new IllegalStateException(
+ "Can not validate if table descriptor exists. " + "Exiting without changing anything.");
}
return false;
}
@@ -157,7 +149,7 @@ public class MissingTableDescriptorGenerator {
private Optional<TableDescriptor> getTableDescriptorFromMaster(TableName tableName) {
LOG.info("Trying to fetch table descriptor for orphan table: {}", tableName);
try (Connection conn = ConnectionFactory.createConnection(configuration);
- Admin admin = conn.getAdmin()) {
+ Admin admin = conn.getAdmin()) {
TableDescriptor tds = admin.getDescriptor(tableName);
return Optional.of(tds);
} catch (TableNotFoundException e) {
@@ -171,7 +163,7 @@ public class MissingTableDescriptorGenerator {
private void generateDefaultTableInfo(HBCKFsTableDescriptors fstd, TableName tableName)
throws IOException {
Set<String> columnFamilies = getColumnFamilies(tableName);
- if(columnFamilies.isEmpty()) {
+ if (columnFamilies.isEmpty()) {
LOG.warn("No column family found in HDFS for table {}.", tableName);
} else {
LOG.info("Column families to be listed in the new table info: {}", columnFamilies);
@@ -200,9 +192,9 @@ public class MissingTableDescriptorGenerator {
return columnFamilies;
} catch (IOException e) {
LOG.error("Exception while trying to find in HDFS the column families for table {}",
- tableName, e);
- throw new IllegalStateException("Unable to determine the list of column families. " +
- "Exiting without changing anything.");
+ tableName, e);
+ throw new IllegalStateException(
+ "Unable to determine the list of column families. " + "Exiting without changing anything.");
}
}
}
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/RegionInfoMismatchTool.java b/hbase-hbck2/src/main/java/org/apache/hbase/RegionInfoMismatchTool.java
index 494191e..e48b840 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/RegionInfoMismatchTool.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/RegionInfoMismatchTool.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.List;
-
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -37,9 +36,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Standalone utility to correct the bug corrected by HBASE-23328 in which
- * the region name in the rowkey of a row in meta does not match the name
- * which is stored in the value of the info:regioninfo column of the same row.
+ * Standalone utility to correct the bug corrected by HBASE-23328 in which the region name in the
+ * rowkey of a row in meta does not match the name which is stored in the value of the
+ * info:regioninfo column of the same row.
*/
public class RegionInfoMismatchTool {
private static final Logger LOG = LoggerFactory.getLogger(RegionInfoMismatchTool.class);
@@ -75,45 +74,42 @@ public class RegionInfoMismatchTool {
}
/**
- * Returns a list of {@link MalformedRegion}'s which exist in meta. If there are
- * no malformed regions, the returned list will be empty.
+ * Returns a list of {@link MalformedRegion}'s which exist in meta. If there are no malformed
+ * regions, the returned list will be empty.
*/
List<MalformedRegion> getMalformedRegions() throws IOException {
try (Table meta = connection.getTable(TableName.META_TABLE_NAME)) {
MetaScanner<MalformedRegion> scanner = new MetaScanner<>();
- return scanner.scanMeta(connection,
- scan -> scan.addFamily(HConstants.CATALOG_FAMILY),
- r -> {
- Cell riCell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,
- HConstants.REGIONINFO_QUALIFIER);
- RegionInfo info = RegionInfo.parseFromOrNull(riCell.getValueArray(),
- riCell.getValueOffset(), riCell.getValueLength());
- // Get the expected value from the RegionInfo in the cell value
- byte[] valueEncodedRegionName = info.getEncodedNameAsBytes();
- // Compare that to what is actually in the rowkey
- HBCKMetaTableAccessor.getMetaKeyForRegion(info);
- byte[] rowKeyRegionName = CellUtil.cloneRow(riCell);
- byte[] rowkeyEncodedRegionName = Bytes.toBytes(
- HBCKRegionInfo.encodeRegionName(rowKeyRegionName));
- // If they are equal, we are good.
- if (Arrays.equals(rowkeyEncodedRegionName, valueEncodedRegionName)) {
- // Returning null will cause `scanMeta` to ignore this row
- LOG.debug("Ignoring region {} because rowkey aligns with value", info);
- return null;
- }
-
- LOG.debug("Found mismatched region {} and {}", Bytes.toStringBinary(rowKeyRegionName),
- Bytes.toStringBinary(valueEncodedRegionName));
- // Only return row/regioninfo pairs that are wrong
- return new MalformedRegion(rowKeyRegionName, info);
- });
+ return scanner.scanMeta(connection, scan -> scan.addFamily(HConstants.CATALOG_FAMILY), r -> {
+ Cell riCell =
+ r.getColumnLatestCell(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
+ RegionInfo info = RegionInfo.parseFromOrNull(riCell.getValueArray(),
+ riCell.getValueOffset(), riCell.getValueLength());
+ // Get the expected value from the RegionInfo in the cell value
+ byte[] valueEncodedRegionName = info.getEncodedNameAsBytes();
+ // Compare that to what is actually in the rowkey
+ HBCKMetaTableAccessor.getMetaKeyForRegion(info);
+ byte[] rowKeyRegionName = CellUtil.cloneRow(riCell);
+ byte[] rowkeyEncodedRegionName =
+ Bytes.toBytes(HBCKRegionInfo.encodeRegionName(rowKeyRegionName));
+ // If they are equal, we are good.
+ if (Arrays.equals(rowkeyEncodedRegionName, valueEncodedRegionName)) {
+ // Returning null will cause `scanMeta` to ignore this row
+ LOG.debug("Ignoring region {} because rowkey aligns with value", info);
+ return null;
+ }
+
+ LOG.debug("Found mismatched region {} and {}", Bytes.toStringBinary(rowKeyRegionName),
+ Bytes.toStringBinary(valueEncodedRegionName));
+ // Only return row/regioninfo pairs that are wrong
+ return new MalformedRegion(rowKeyRegionName, info);
+ });
}
}
/**
* Run the RegionInfoMistmatchTool. Use the {@code fix} argument to control whether this method
* will report problems or fix problems.
- *
* @param fix True if hbase:meta should be updated. False to report on any problems.
*/
public void run(boolean fix) throws IOException, DeserializationException {
@@ -126,7 +122,7 @@ public class RegionInfoMismatchTool {
out.println("Fix mode is disabled, printing all malformed regions detected:");
for (MalformedRegion r : regionsToFix) {
out.println("Rowkey " + HBCKRegionInfo.encodeRegionName(r.getRegionName())
- + " does not match " + r.getRegionInfo());
+ + " does not match " + r.getRegionInfo());
}
}
out.println("Found " + regionsToFix.size() + " regions to fix.");
@@ -139,8 +135,8 @@ public class RegionInfoMismatchTool {
// broken by HBASE-23328
byte[][] regionNameParts = HBCKRegionInfo.parseRegionNameOrReturnNull(regionName);
if (regionNameParts == null) {
- throw new RuntimeException("Couldn't parse parts from "
- + Bytes.toStringBinary(regionName));
+ throw new RuntimeException(
+ "Couldn't parse parts from " + Bytes.toStringBinary(regionName));
}
int i = 0;
for (byte[] part : regionNameParts) {
@@ -153,37 +149,33 @@ public class RegionInfoMismatchTool {
// fields by hand which will force the new RegionInfo to recompute the NAME/encodedName
// fields.
RegionInfo correctedRegionInfo = RegionInfoBuilder.newBuilder(wrongRegionInfo.getTable())
- .setRegionId(regionId)
- .setStartKey(wrongRegionInfo.getStartKey())
- .setEndKey(wrongRegionInfo.getEndKey())
- .setReplicaId(0)
- .setOffline(wrongRegionInfo.isOffline())
- .setSplit(wrongRegionInfo.isSplit())
- .build();
+ .setRegionId(regionId).setStartKey(wrongRegionInfo.getStartKey())
+ .setEndKey(wrongRegionInfo.getEndKey()).setReplicaId(0)
+ .setOffline(wrongRegionInfo.isOffline()).setSplit(wrongRegionInfo.isSplit()).build();
String rowkeyEncodedRegionName = HBCKRegionInfo.encodeRegionName(regionName);
String updatedValueEncodedRegionName = correctedRegionInfo.getEncodedName();
if (!rowkeyEncodedRegionName.equals(updatedValueEncodedRegionName)) {
out.println("Aborting: sanity-check failed on updated RegionInfo. Expected encoded "
- + "region name " +rowkeyEncodedRegionName + " but got "
- + updatedValueEncodedRegionName + ".");
+ + "region name " + rowkeyEncodedRegionName + " but got " + updatedValueEncodedRegionName
+ + ".");
out.println("Incorrectly created RegionInfo was: " + correctedRegionInfo);
throw new RuntimeException("Failed sanity-check on corrected RegionInfo");
}
out.println("Updating RegionInfo for " + Bytes.toStringBinary(regionName) + " to "
- + correctedRegionInfo);
+ + correctedRegionInfo);
// Write the update back to meta.
if (fix) {
meta.put(HBCKMetaTableAccessor.makePutFromRegionInfo(correctedRegionInfo,
- System.currentTimeMillis()));
+ System.currentTimeMillis()));
}
}
if (!fix) {
out.println("Fix mode is not enabled, hbase:meta was not updated. See the tool output for"
- + " a list of detected problematic regions. Re-run the tool without the dry run option"
- + " to persist updates to hbase:meta.");
+ + " a list of detected problematic regions. Re-run the tool without the dry run option"
+ + " to persist updates to hbase:meta.");
}
}
}
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/ReplicationFsck.java b/hbase-hbck2/src/main/java/org/apache/hbase/ReplicationFsck.java
index 15baca1..282d7ab 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/ReplicationFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/ReplicationFsck.java
@@ -20,7 +20,6 @@ package org.apache.hbase;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.replication.ReplicationException;
import org.apache.hbase.hbck1.HBaseFsck;
@@ -48,7 +47,7 @@ public class ReplicationFsck implements Closeable {
// Below needs connection to be up; uses admin.
hbaseFsck.connect();
hbaseFsck.setCleanReplicationBarrier(fix);
- for (String table: tables) {
+ for (String table : tables) {
hbaseFsck.setCleanReplicationBarrierTable(table);
hbaseFsck.cleanReplicationBarrier();
}
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/Version.java b/hbase-hbck2/src/main/java/org/apache/hbase/Version.java
index 7e5452a..f139166 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/Version.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/Version.java
@@ -27,25 +27,26 @@ public final class Version {
private static final int MINOR = 1;
private static final int PATCH = 2;
- private Version() {}
+ private Version() {
+ }
/**
* @param thresholdVersions List of versions from oldest to newest.
- * @return true if <code>version</code> is greater-than or equal to thresholdVersions.
- * For example, if passed threshold list is <code>{"2.0.2", "2.1.3", "2.2.1"}</code>
- * and the version is 2.1.2 then the result should be false since 2.1.2
- * is less than the matching passed-in 2.1.3 but if version is 2.1.5 then we return true.
+ * @return true if <code>version</code> is greater-than or equal to thresholdVersions. For
+ * example, if passed threshold list is <code>{"2.0.2", "2.1.3", "2.2.1"}</code> and the
+ * version is 2.1.2 then the result should be false since 2.1.2 is less than the matching
+ * passed-in 2.1.3 but if version is 2.1.5 then we return true.
*/
- static boolean check(final String version, String ... thresholdVersions) {
+ static boolean check(final String version, String... thresholdVersions) {
if (thresholdVersions == null) {
return true;
}
boolean supported = false;
// Components of the server version string.
- String [] versionComponents = getVersionComponents(version);
+ String[] versionComponents = getVersionComponents(version);
boolean excessiveMajor = false;
boolean excessiveMinor = false;
- for (String thresholdVersion: thresholdVersions) {
+ for (String thresholdVersion : thresholdVersions) {
// Get components of current threshold version.
String[] thresholdVersionComponents = getVersionComponents(thresholdVersion);
int serverMajor = Integer.parseInt(versionComponents[MAJOR]);
@@ -68,8 +69,10 @@ public final class Version {
if (serverMinor < thresholdMinor) {
continue;
}
- if (Integer.parseInt(versionComponents[PATCH]) >=
- Integer.parseInt(thresholdVersionComponents[PATCH])) {
+ if (
+ Integer.parseInt(versionComponents[PATCH])
+ >= Integer.parseInt(thresholdVersionComponents[PATCH])
+ ) {
supported = true;
}
break;
@@ -78,17 +81,16 @@ public final class Version {
}
/**
- * Copied from hbase VersionInfo.
- * Returns the version components as String objects
- * Examples: "1.2.3" returns ["1", "2", "3"], "4.5.6-SNAPSHOT" returns ["4", "5", "6", "-1"]
- * "4.5.6-beta" returns ["4", "5", "6", "-2"], "4.5.6-alpha" returns ["4", "5", "6", "-3"]
- * "4.5.6-UNKNOW" returns ["4", "5", "6", "-4"]
+ * Copied from hbase VersionInfo. Returns the version components as String objects Examples:
+ * "1.2.3" returns ["1", "2", "3"], "4.5.6-SNAPSHOT" returns ["4", "5", "6", "-1"] "4.5.6-beta"
+ * returns ["4", "5", "6", "-2"], "4.5.6-alpha" returns ["4", "5", "6", "-3"] "4.5.6-UNKNOW"
+ * returns ["4", "5", "6", "-4"]
* @return the components of the version string
*/
private static String[] getVersionComponents(final String version) {
- assert(version != null);
+ assert (version != null);
String[] strComps = version.split("[\\.-]");
- assert(strComps.length > 0);
+ assert (strComps.length > 0);
String[] comps = new String[strComps.length];
for (int i = 0; i < strComps.length; ++i) {
@@ -97,11 +99,11 @@ public final class Version {
} else if (strComps[i] == null || strComps[i].isEmpty()) {
comps[i] = String.valueOf(VERY_LARGE_NUMBER);
} else {
- if("SNAPSHOT".equals(strComps[i])) {
+ if ("SNAPSHOT".equals(strComps[i])) {
comps[i] = "-1";
- } else if("beta".equals(strComps[i])) {
+ } else if ("beta".equals(strComps[i])) {
comps[i] = "-2";
- } else if("alpha".equals(strComps[i])) {
+ } else if ("alpha".equals(strComps[i])) {
comps[i] = "-3";
} else {
comps[i] = "-4";
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
index 812b2a3..2fb31f2 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
@@ -170,56 +170,49 @@ import org.apache.hbase.thirdparty.com.google.common.collect.TreeMultimap;
import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
/**
- * HBaseFsck (hbck) is(WAS) a tool for checking and repairing region consistency and
- * table integrity problems in a corrupted HBase. This tool was written for hbase-1.x.
- * It was then ported here for use by hbck2 (hbck1 does not work against hbase2; its
- * presumptions about how hbase works do not hold for hbase2). hbck2 exposes pieces
- * of this hbck1 but not all, intentionally. The main method has been removed from
- * this class so it is not directly accessible</p>
- *
- * <p>Below is the old overview for hbck1.</p>
+ * HBaseFsck (hbck) is(WAS) a tool for checking and repairing region consistency and table integrity
+ * problems in a corrupted HBase. This tool was written for hbase-1.x. It was then ported here for
+ * use by hbck2 (hbck1 does not work against hbase2; its presumptions about how hbase works do not
+ * hold for hbase2). hbck2 exposes pieces of this hbck1 but not all, intentionally. The main method
+ * has been removed from this class so it is not directly accessible
+ * </p>
+ * <p>
+ * Below is the old overview for hbck1.
+ * </p>
* <p>
- * Region consistency checks verify that hbase:meta, region deployment on region
- * servers and the state of data in HDFS (.regioninfo files) all are in
- * accordance.
+ * Region consistency checks verify that hbase:meta, region deployment on region servers and the
+ * state of data in HDFS (.regioninfo files) all are in accordance.
* <p>
- * Table integrity checks verify that all possible row keys resolve to exactly
- * one region of a table. This means there are no individual degenerate
- * or backwards regions; no holes between regions; and that there are no
- * overlapping regions.
+ * Table integrity checks verify that all possible row keys resolve to exactly one region of a
+ * table. This means there are no individual degenerate or backwards regions; no holes between
+ * regions; and that there are no overlapping regions.
* <p>
* The general repair strategy works in two phases:
* <ol>
- * <li> Repair Table Integrity on HDFS. (merge or fabricate regions)
- * <li> Repair Region Consistency with hbase:meta and assignments
+ * <li>Repair Table Integrity on HDFS. (merge or fabricate regions)
+ * <li>Repair Region Consistency with hbase:meta and assignments
* </ol>
* <p>
- * For table integrity repairs, the tables' region directories are scanned
- * for .regioninfo files. Each table's integrity is then verified. If there
- * are any orphan regions (regions with no .regioninfo files) or holes, new
- * regions are fabricated. Backwards regions are sidelined as well as empty
- * degenerate (endkey==startkey) regions. If there are any overlapping regions,
- * a new region is created and all data is merged into the new region.
+ * For table integrity repairs, the tables' region directories are scanned for .regioninfo files.
+ * Each table's integrity is then verified. If there are any orphan regions (regions with no
+ * .regioninfo files) or holes, new regions are fabricated. Backwards regions are sidelined as well
+ * as empty degenerate (endkey==startkey) regions. If there are any overlapping regions, a new
+ * region is created and all data is merged into the new region.
* <p>
- * Table integrity repairs deal solely with HDFS and could potentially be done
- * offline -- the hbase region servers or master do not need to be running.
- * This phase can eventually be used to completely reconstruct the hbase:meta table in
- * an offline fashion.
+ * Table integrity repairs deal solely with HDFS and could potentially be done offline -- the hbase
+ * region servers or master do not need to be running. This phase can eventually be used to
+ * completely reconstruct the hbase:meta table in an offline fashion.
* <p>
- * Region consistency requires three conditions -- 1) valid .regioninfo file
- * present in an HDFS region dir, 2) valid row with .regioninfo data in META,
- * and 3) a region is deployed only at the regionserver that was assigned to
- * with proper state in the master.
+ * Region consistency requires three conditions -- 1) valid .regioninfo file present in an HDFS
+ * region dir, 2) valid row with .regioninfo data in META, and 3) a region is deployed only at the
+ * regionserver that was assigned to with proper state in the master.
* <p>
- * Region consistency repairs require hbase to be online so that hbck can
- * contact the HBase master and region servers. The hbck#connect() method must
- * first be called successfully. Much of the region consistency information
- * is transient and less risky to repair.
+ * Region consistency repairs require hbase to be online so that hbck can contact the HBase master
+ * and region servers. The hbck#connect() method must first be called successfully. Much of the
+ * region consistency information is transient and less risky to repair.
* <p>
- * If hbck is run from the command line, there are a handful of arguments that
- * can be used to limit the kinds of repairs hbck will do. See the code in
- * {@link #printUsageAndExit()} for more details.
- *
+ * If hbck is run from the command line, there are a handful of arguments that can be used to limit
+ * the kinds of repairs hbck will do. See the code in {@link #printUsageAndExit()} for more details.
* Copied over wholesale from hbase. Unaltered except for package and imports.
*/
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)
@@ -233,8 +226,8 @@ public class HBaseFsck extends Configured implements Closeable {
private static final int DEFAULT_MAX_MERGE = 5;
private static final String TO_BE_LOADED = "to_be_loaded";
/*
- * Here is where hbase-1.x used to default the lock for hbck1.
- * It puts in place a lock when it goes to write/make changes.
+ * Here is where hbase-1.x used to default the lock for hbck1. It puts in place a lock when it
+ * goes to write/make changes.
*/
/**
@@ -284,9 +277,9 @@ public class HBaseFsck extends Configured implements Closeable {
// Unsupported options in HBase 2.0+
private static final Set<String> unsupportedOptionsInV2 = Sets.newHashSet("-fix",
- "-fixAssignments", "-fixMeta", "-fixHdfsHoles", "-fixHdfsOrphans", "-fixTableOrphans",
- "-fixHdfsOverlaps", "-sidelineBigOverlaps", "-fixSplitParents", "-removeParents",
- "-fixEmptyMetaCells", "-repair", "-repairHoles", "-maxOverlapsToSideline", "-maxMerge");
+ "-fixAssignments", "-fixMeta", "-fixHdfsHoles", "-fixHdfsOrphans", "-fixTableOrphans",
+ "-fixHdfsOverlaps", "-sidelineBigOverlaps", "-fixSplitParents", "-removeParents",
+ "-fixEmptyMetaCells", "-repair", "-repairHoles", "-maxOverlapsToSideline", "-maxMerge");
/***********
* Options
@@ -335,23 +328,20 @@ public class HBaseFsck extends Configured implements Closeable {
int fixes = 0;
/**
- * This map contains the state of all hbck items. It maps from encoded region
- * name to HbckInfo structure. The information contained in HbckInfo is used
- * to detect and correct consistency (hdfs/meta/deployment) problems.
+ * This map contains the state of all hbck items. It maps from encoded region name to HbckInfo
+ * structure. The information contained in HbckInfo is used to detect and correct consistency
+ * (hdfs/meta/deployment) problems.
*/
private TreeMap<String, HbckInfo> regionInfoMap = new TreeMap<>();
// Empty regioninfo qualifiers in hbase:meta
private Set<Result> emptyRegionInfoQualifiers = new HashSet<>();
/**
- * This map from Tablename -> TableInfo contains the structures necessary to
- * detect table consistency problems (holes, dupes, overlaps). It is sorted
- * to prevent dupes.
- *
- * If tablesIncluded is empty, this map contains all tables.
- * Otherwise, it contains only meta tables and tables in tablesIncluded,
- * unless checkMetaOnly is specified, in which case, it contains only
- * the meta table
+ * This map from Tablename -> TableInfo contains the structures necessary to detect table
+ * consistency problems (holes, dupes, overlaps). It is sorted to prevent dupes. If tablesIncluded
+ * is empty, this map contains all tables. Otherwise, it contains only meta tables and tables in
+ * tablesIncluded, unless checkMetaOnly is specified, in which case, it contains only the meta
+ * table
*/
private SortedMap<TableName, TableInfo> tablesInfo = new ConcurrentSkipListMap<>();
@@ -373,9 +363,8 @@ public class HBaseFsck extends Configured implements Closeable {
/**
* Constructor
- *
* @param conf Configuration object
- * @throws MasterNotRunningException if the master is not running
+ * @throws MasterNotRunningException if the master is not running
* @throws ZooKeeperConnectionException if unable to connect to ZooKeeper
*/
public HBaseFsck(Configuration conf) throws IOException, ClassNotFoundException {
@@ -385,22 +374,15 @@ public class HBaseFsck extends Configured implements Closeable {
private static ExecutorService createThreadPool(Configuration conf) {
int numThreads = conf.getInt("hbasefsck.numthreads", MAX_NUM_THREADS);
return new ScheduledThreadPoolExecutor(numThreads,
- new ThreadFactoryBuilder().setNameFormat("hbasefsck-%d")
- .setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build());
+ new ThreadFactoryBuilder().setNameFormat("hbasefsck-%d")
+ .setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build());
}
/**
- * Constructor
- *
- * @param conf
- * Configuration object
- * @throws MasterNotRunningException
- * if the master is not running
- * @throws ZooKeeperConnectionException
- * if unable to connect to ZooKeeper
+ * Constructor Configuration object if the master is not running if unable to connect to ZooKeeper
*/
public HBaseFsck(Configuration conf, ExecutorService exec) throws MasterNotRunningException,
- ZooKeeperConnectionException, IOException, ClassNotFoundException {
+ ZooKeeperConnectionException, IOException, ClassNotFoundException {
super(conf);
errors = getErrorReporter(getConf());
this.executor = exec;
@@ -410,33 +392,27 @@ public class HBaseFsck extends Configured implements Closeable {
rootFs = HBCKFsUtils.getRootDirFileSystem(conf);
}
- /**
- * @return A retry counter factory configured for retrying lock file creation.
- */
+ /** Returns A retry counter factory configured for retrying lock file creation. */
public static RetryCounterFactory createLockRetryCounterFactory(Configuration conf) {
return new RetryCounterFactory(
- conf.getInt("hbase.hbck.lockfile.attempts", DEFAULT_MAX_LOCK_FILE_ATTEMPTS),
- conf.getInt("hbase.hbck.lockfile.attempt.sleep.interval",
- DEFAULT_LOCK_FILE_ATTEMPT_SLEEP_INTERVAL),
- conf.getInt("hbase.hbck.lockfile.attempt.maxsleeptime",
- DEFAULT_LOCK_FILE_ATTEMPT_MAX_SLEEP_TIME));
+ conf.getInt("hbase.hbck.lockfile.attempts", DEFAULT_MAX_LOCK_FILE_ATTEMPTS),
+ conf.getInt("hbase.hbck.lockfile.attempt.sleep.interval",
+ DEFAULT_LOCK_FILE_ATTEMPT_SLEEP_INTERVAL),
+ conf.getInt("hbase.hbck.lockfile.attempt.maxsleeptime",
+ DEFAULT_LOCK_FILE_ATTEMPT_MAX_SLEEP_TIME));
}
- /**
- * @return A retry counter factory configured for retrying znode creation.
- */
+ /** Returns A retry counter factory configured for retrying znode creation. */
private static RetryCounterFactory createZnodeRetryCounterFactory(Configuration conf) {
return new RetryCounterFactory(
- conf.getInt("hbase.hbck.createznode.attempts", DEFAULT_MAX_CREATE_ZNODE_ATTEMPTS),
- conf.getInt("hbase.hbck.createznode.attempt.sleep.interval",
- DEFAULT_CREATE_ZNODE_ATTEMPT_SLEEP_INTERVAL),
- conf.getInt("hbase.hbck.createznode.attempt.maxsleeptime",
- DEFAULT_CREATE_ZNODE_ATTEMPT_MAX_SLEEP_TIME));
+ conf.getInt("hbase.hbck.createznode.attempts", DEFAULT_MAX_CREATE_ZNODE_ATTEMPTS),
+ conf.getInt("hbase.hbck.createznode.attempt.sleep.interval",
+ DEFAULT_CREATE_ZNODE_ATTEMPT_SLEEP_INTERVAL),
+ conf.getInt("hbase.hbck.createznode.attempt.maxsleeptime",
+ DEFAULT_CREATE_ZNODE_ATTEMPT_MAX_SLEEP_TIME));
}
- /**
- * @return Return the tmp dir this tool writes too.
- */
+ /** Returns Return the tmp dir this tool writes too. */
@VisibleForTesting
public static Path getTmpDir(Configuration conf) throws IOException {
return new Path(HBCKFsUtils.getRootDir(conf), HConstants.HBASE_TEMP_DIRECTORY);
@@ -461,9 +437,7 @@ public class HBaseFsck extends Configured implements Closeable {
this.lockFileName = lockFileName;
}
- /**
- * @return Will be <code>null</code> unless you call {@link #call()}
- */
+ /** Returns Will be <code>null</code> unless you call {@link #call()} */
Path getHbckLockPath() {
return this.hbckLockPath;
}
@@ -474,20 +448,20 @@ public class HBaseFsck extends Configured implements Closeable {
// tmpDir is created based on hbase.rootdir
Path tmpDir = getTmpDir(conf);
FileSystem fs = tmpDir.getFileSystem(conf);
- FsPermission defaultPerms = CommonFSUtils.getFilePermissions(fs, this.conf,
- HConstants.DATA_FILE_UMASK_KEY);
+ FsPermission defaultPerms =
+ CommonFSUtils.getFilePermissions(fs, this.conf, HConstants.DATA_FILE_UMASK_KEY);
this.hbckLockPath = new Path(tmpDir, this.lockFileName);
fs.mkdirs(tmpDir);
final FSDataOutputStream out = createFileWithRetries(fs, this.hbckLockPath, defaultPerms);
out.writeBytes(InetAddress.getLocalHost().toString());
// Add a note into the file we write on why hbase2 is writing out an hbck1 lock file.
- out.writeBytes(" Written by an hbase-2.x Master to block an " +
- "attempt by an hbase-1.x HBCK tool making modification to state. " +
- "See 'HBCK must match HBase server version' in the hbase refguide.");
+ out.writeBytes(" Written by an hbase-2.x Master to block an "
+ + "attempt by an hbase-1.x HBCK tool making modification to state. "
+ + "See 'HBCK must match HBase server version' in the hbase refguide.");
out.flush();
return out;
- } catch(RemoteException e) {
- if(AlreadyBeingCreatedException.class.getName().equals(e.getClassName())){
+ } catch (RemoteException e) {
+ if (AlreadyBeingCreatedException.class.getName().equals(e.getClassName())) {
return null;
} else {
throw e;
@@ -496,25 +470,21 @@ public class HBaseFsck extends Configured implements Closeable {
}
private FSDataOutputStream createFileWithRetries(final FileSystem fs,
- final Path hbckLockFilePath, final FsPermission defaultPerms)
- throws IOException {
+ final Path hbckLockFilePath, final FsPermission defaultPerms) throws IOException {
IOException exception = null;
do {
try {
return CommonFSUtils.create(fs, hbckLockFilePath, defaultPerms, false);
} catch (IOException ioe) {
- LOG.info("Failed to create lock file " + hbckLockFilePath.getName()
- + ", try=" + (retryCounter.getAttemptTimes() + 1) + " of "
- + retryCounter.getMaxAttempts());
- LOG.debug("Failed to create lock file " + hbckLockFilePath.getName(),
- ioe);
+ LOG.info("Failed to create lock file " + hbckLockFilePath.getName() + ", try="
+ + (retryCounter.getAttemptTimes() + 1) + " of " + retryCounter.getMaxAttempts());
+ LOG.debug("Failed to create lock file " + hbckLockFilePath.getName(), ioe);
try {
exception = ioe;
retryCounter.sleepUntilNextRetry();
} catch (InterruptedException ie) {
throw (InterruptedIOException) new InterruptedIOException(
- "Can't create lock file " + hbckLockFilePath.getName())
- .initCause(ie);
+ "Can't create lock file " + hbckLockFilePath.getName()).initCause(ie);
}
}
} while (retryCounter.shouldRetry());
@@ -525,23 +495,22 @@ public class HBaseFsck extends Configured implements Closeable {
/**
* This method maintains a lock using a file. If the creation fails we return null
- *
* @return FSDataOutputStream object corresponding to the newly opened lock file
* @throws IOException if IO failure occurs
*/
public static Pair<Path, FSDataOutputStream> checkAndMarkRunningHbck(Configuration conf,
- RetryCounter retryCounter) throws IOException {
+ RetryCounter retryCounter) throws IOException {
return checkAndMarkRunningHbck(conf, retryCounter, HBaseFsck.HBCK2_LOCK_FILE);
}
public static Pair<Path, FSDataOutputStream> checkAndMarkRunningHbck(Configuration conf,
- RetryCounter retryCounter, String lockFileName) throws IOException {
+ RetryCounter retryCounter, String lockFileName) throws IOException {
FileLockCallable callable = new FileLockCallable(conf, retryCounter, lockFileName);
ExecutorService executor = Executors.newFixedThreadPool(1);
FutureTask<FSDataOutputStream> futureTask = new FutureTask<>(callable);
executor.execute(futureTask);
- final int timeoutInSeconds = conf.getInt(
- "hbase.hbck.lockfile.maxwaittime", DEFAULT_WAIT_FOR_LOCK_TIMEOUT);
+ final int timeoutInSeconds =
+ conf.getInt("hbase.hbck.lockfile.maxwaittime", DEFAULT_WAIT_FOR_LOCK_TIMEOUT);
FSDataOutputStream stream = null;
try {
stream = futureTask.get(timeoutInSeconds, TimeUnit.SECONDS);
@@ -570,15 +539,13 @@ public class HBaseFsck extends Configured implements Closeable {
return;
} catch (IOException ioe) {
LOG.info("Failed to delete " + hbckLockPath + ", try="
- + (retryCounter.getAttemptTimes() + 1) + " of "
- + retryCounter.getMaxAttempts());
+ + (retryCounter.getAttemptTimes() + 1) + " of " + retryCounter.getMaxAttempts());
LOG.debug("Failed to delete " + hbckLockPath, ioe);
try {
retryCounter.sleepUntilNextRetry();
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
- LOG.warn("Interrupted while deleting lock file" +
- hbckLockPath);
+ LOG.warn("Interrupted while deleting lock file" + hbckLockPath);
return;
}
}
@@ -587,22 +554,21 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * To repair region consistency, one must call connect() in order to repair
- * online state.
+ * To repair region consistency, one must call connect() in order to repair online state.
*/
public void connect() throws IOException {
if (isExclusive()) {
// Grab the lock
Pair<Path, FSDataOutputStream> pair =
- checkAndMarkRunningHbck(getConf(), this.lockFileRetryCounterFactory.create());
+ checkAndMarkRunningHbck(getConf(), this.lockFileRetryCounterFactory.create());
hbckLockPath = pair.getFirst();
this.hbckOutFd = pair.getSecond();
if (hbckOutFd == null) {
setRetCode(-1);
- LOG.error("Another instance of hbck is fixing HBase, exiting this instance. " +
- "[If you are sure no other instance is running, delete the lock file " +
- hbckLockPath + " and rerun the tool]");
+ LOG.error("Another instance of hbck is fixing HBase, exiting this instance. "
+ + "[If you are sure no other instance is running, delete the lock file " + hbckLockPath
+ + " and rerun the tool]");
throw new IOException("Duplicate hbck - Abort");
}
@@ -610,7 +576,6 @@ public class HBaseFsck extends Configured implements Closeable {
hbckLockCleanup.set(true);
}
-
// Add a shutdown hook to this thread, in case user tries to
// kill the hbck with a ctrl-c, we want to cleanup the lock so that
// it is available for further calls
@@ -626,9 +591,8 @@ public class HBaseFsck extends Configured implements Closeable {
connection = ConnectionFactory.createConnection(getConf());
admin = connection.getAdmin();
meta = connection.getTable(TableName.META_TABLE_NAME);
- status = admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS,
- Option.DEAD_SERVERS, Option.MASTER, Option.BACKUP_MASTERS,
- Option.REGIONS_IN_TRANSITION, Option.HBASE_VERSION));
+ status = admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS, Option.DEAD_SERVERS,
+ Option.MASTER, Option.BACKUP_MASTERS, Option.REGIONS_IN_TRANSITION, Option.HBASE_VERSION));
}
/**
@@ -639,7 +603,7 @@ public class HBaseFsck extends Configured implements Closeable {
Collection<ServerName> regionServers = status.getLiveServerMetrics().keySet();
errors.print("Number of live region servers: " + regionServers.size());
if (details) {
- for (ServerName rsinfo: regionServers) {
+ for (ServerName rsinfo : regionServers) {
errors.print(" " + rsinfo.getServerName());
}
}
@@ -648,7 +612,7 @@ public class HBaseFsck extends Configured implements Closeable {
Collection<ServerName> deadRegionServers = status.getDeadServerNames();
errors.print("Number of dead region servers: " + deadRegionServers.size());
if (details) {
- for (ServerName name: deadRegionServers) {
+ for (ServerName name : deadRegionServers) {
errors.print(" " + name);
}
}
@@ -660,7 +624,7 @@ public class HBaseFsck extends Configured implements Closeable {
Collection<ServerName> backupMasters = status.getBackupMasterNames();
errors.print("Number of backup masters: " + backupMasters.size());
if (details) {
- for (ServerName name: backupMasters) {
+ for (ServerName name : backupMasters) {
errors.print(" " + name);
}
}
@@ -672,7 +636,7 @@ public class HBaseFsck extends Configured implements Closeable {
List<RegionState> rits = status.getRegionStatesInTransition();
errors.print("Number of regions in transition: " + rits.size());
if (details) {
- for (RegionState state: rits) {
+ for (RegionState state : rits) {
errors.print(" " + state.toDescriptiveString());
}
}
@@ -697,14 +661,15 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * This repair method analyzes hbase data in hdfs and repairs it to satisfy
- * the table integrity rules. HBase doesn't need to be online for this
- * operation to work.
+ * This repair method analyzes hbase data in hdfs and repairs it to satisfy the table integrity
+ * rules. HBase doesn't need to be online for this operation to work.
*/
public void offlineHdfsIntegrityRepair() throws IOException, InterruptedException {
// Initial pass to fix orphans.
- if (shouldCheckHdfs() || (shouldFixHdfsOrphans() || shouldFixHdfsHoles()
- || shouldFixHdfsOverlaps() || shouldFixTableOrphans())) {
+ if (
+ shouldCheckHdfs() || (shouldFixHdfsOrphans() || shouldFixHdfsHoles()
+ || shouldFixHdfsOverlaps() || shouldFixTableOrphans())
+ ) {
LOG.info("Loading regioninfos HDFS");
// if nothing is happening this should always complete in two iterations.
int maxIterations = getConf().getInt("hbase.hbck.integrityrepair.iterations.max", 3);
@@ -721,7 +686,7 @@ public class HBaseFsck extends Configured implements Closeable {
if (curIter > 2) {
if (curIter == maxIterations) {
LOG.warn("Exiting integrity repairs after max " + curIter + " iterations. "
- + "Tables integrity may not be fully repaired!");
+ + "Tables integrity may not be fully repaired!");
} else {
LOG.info("Successfully exiting integrity repairs after " + curIter + " iterations");
}
@@ -730,15 +695,12 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * This repair method requires the cluster to be online since it contacts
- * region servers and the masters. It makes each region's state in HDFS, in
- * hbase:meta, and deployments consistent.
- *
- * @return If > 0 , number of errors detected, if < 0 there was an unrecoverable
- * error. If 0, we have a clean hbase.
+ * This repair method requires the cluster to be online since it contacts region servers and the
+ * masters. It makes each region's state in HDFS, in hbase:meta, and deployments consistent.
+ * @return If > 0 , number of errors detected, if < 0 there was an unrecoverable error. If
+ * 0, we have a clean hbase.
*/
- public int onlineConsistencyRepair() throws IOException, KeeperException,
- InterruptedException {
+ public int onlineConsistencyRepair() throws IOException, KeeperException, InterruptedException {
// get regions according to what is online on each RegionServer
loadDeployedRegions();
@@ -801,14 +763,12 @@ public class HBaseFsck extends Configured implements Closeable {
/**
* This method maintains an ephemeral znode. If the creation fails we return false or throw
* exception
- *
* @return true if creating znode succeeds; false otherwise
* @throws IOException if IO failure occurs
*/
private boolean setMasterInMaintenanceMode() throws IOException {
RetryCounter retryCounter = createZNodeRetryCounterFactory.create();
- hbckEphemeralNodePath = ZNodePaths.joinZNode(
- zkw.getZNodePaths().masterMaintZNode,
+ hbckEphemeralNodePath = ZNodePaths.joinZNode(zkw.getZNodePaths().masterMaintZNode,
"hbck-" + System.currentTimeMillis());
do {
try {
@@ -823,14 +783,14 @@ public class HBaseFsck extends Configured implements Closeable {
// fall through and retry
}
- LOG.warn("Fail to create znode " + hbckEphemeralNodePath + ", try=" +
- (retryCounter.getAttemptTimes() + 1) + " of " + retryCounter.getMaxAttempts());
+ LOG.warn("Fail to create znode " + hbckEphemeralNodePath + ", try="
+ + (retryCounter.getAttemptTimes() + 1) + " of " + retryCounter.getMaxAttempts());
try {
retryCounter.sleepUntilNextRetry();
} catch (InterruptedException ie) {
throw (InterruptedIOException) new InterruptedIOException(
- "Can't create znode " + hbckEphemeralNodePath).initCause(ie);
+ "Can't create znode " + hbckEphemeralNodePath).initCause(ie);
}
} while (retryCounter.shouldRetry());
return hbckZodeCreated;
@@ -862,7 +822,7 @@ public class HBaseFsck extends Configured implements Closeable {
* @return 0 on success, non-zero on failure
*/
public int onlineHbck()
- throws IOException, KeeperException, InterruptedException, ReplicationException {
+ throws IOException, KeeperException, InterruptedException, ReplicationException {
// print hbase server version
errors.print("Version: " + status.getHBaseVersion());
@@ -871,7 +831,7 @@ public class HBaseFsck extends Configured implements Closeable {
// Do offline check and repair first
offlineHbck();
// If Master runs maintenance tasks (such as balancer, catalog janitor, etc) during online
- // hbck, it is likely that hbck would be misled and report transient errors. Therefore, it
+ // hbck, it is likely that hbck would be misled and report transient errors. Therefore, it
// is better to set Master into maintenance mode during online hbck.
//
if (!setMasterInMaintenanceMode()) {
@@ -929,19 +889,18 @@ public class HBaseFsck extends Configured implements Closeable {
}
private static class RegionBoundariesInformation {
- private byte [] regionName;
- private byte [] metaFirstKey;
- private byte [] metaLastKey;
- private byte [] storesFirstKey;
- private byte [] storesLastKey;
+ private byte[] regionName;
+ private byte[] metaFirstKey;
+ private byte[] metaLastKey;
+ private byte[] storesFirstKey;
+ private byte[] storesLastKey;
@Override
public String toString() {
- return "regionName=" + Bytes.toStringBinary(regionName) +
- "\nmetaFirstKey=" + Bytes.toStringBinary(metaFirstKey) +
- "\nmetaLastKey=" + Bytes.toStringBinary(metaLastKey) +
- "\nstoresFirstKey=" + Bytes.toStringBinary(storesFirstKey) +
- "\nstoresLastKey=" + Bytes.toStringBinary(storesLastKey);
+ return "regionName=" + Bytes.toStringBinary(regionName) + "\nmetaFirstKey="
+ + Bytes.toStringBinary(metaFirstKey) + "\nmetaLastKey=" + Bytes.toStringBinary(metaLastKey)
+ + "\nstoresFirstKey=" + Bytes.toStringBinary(storesFirstKey) + "\nstoresLastKey="
+ + Bytes.toStringBinary(storesLastKey);
}
}
@@ -950,7 +909,7 @@ public class HBaseFsck extends Configured implements Closeable {
ByteArrayComparator comparator = new ByteArrayComparator();
List<RegionInfo> regions = HBCKMetaTableAccessor.getAllRegions(connection);
final RegionBoundariesInformation currentRegionBoundariesInformation =
- new RegionBoundariesInformation();
+ new RegionBoundariesInformation();
Path hbaseRoot = CommonFSUtils.getRootDir(getConf());
for (RegionInfo regionInfo : regions) {
Path tableDir = CommonFSUtils.getTableDir(hbaseRoot, regionInfo.getTable());
@@ -970,17 +929,21 @@ public class HBaseFsck extends Configured implements Closeable {
FileStatus[] storeFiles = fs.listStatus(file.getPath());
// For all the stores in this column family.
for (FileStatus storeFile : storeFiles) {
- HFile.Reader reader = HFile.createReader(fs, storeFile.getPath(),
- CacheConfig.DISABLED, true, getConf());
- if ((reader.getFirstKey() != null)
+ HFile.Reader reader =
+ HFile.createReader(fs, storeFile.getPath(), CacheConfig.DISABLED, true, getConf());
+ if (
+ (reader.getFirstKey() != null)
&& ((storeFirstKey == null) || (comparator.compare(storeFirstKey,
- ((KeyValue.KeyOnlyKeyValue) reader.getFirstKey().get()).getKey()) > 0))) {
- storeFirstKey = ((KeyValue.KeyOnlyKeyValue)reader.getFirstKey().get()).getKey();
+ ((KeyValue.KeyOnlyKeyValue) reader.getFirstKey().get()).getKey()) > 0))
+ ) {
+ storeFirstKey = ((KeyValue.KeyOnlyKeyValue) reader.getFirstKey().get()).getKey();
}
- if ((reader.getLastKey() != null)
+ if (
+ (reader.getLastKey() != null)
&& ((storeLastKey == null) || (comparator.compare(storeLastKey,
- ((KeyValue.KeyOnlyKeyValue)reader.getLastKey().get()).getKey())) < 0)) {
- storeLastKey = ((KeyValue.KeyOnlyKeyValue)reader.getLastKey().get()).getKey();
+ ((KeyValue.KeyOnlyKeyValue) reader.getLastKey().get()).getKey())) < 0)
+ ) {
+ storeLastKey = ((KeyValue.KeyOnlyKeyValue) reader.getLastKey().get()).getKey();
}
reader.close();
}
@@ -1004,23 +967,24 @@ public class HBaseFsck extends Configured implements Closeable {
boolean valid = true;
// Checking start key.
- if ((currentRegionBoundariesInformation.storesFirstKey != null)
- && (currentRegionBoundariesInformation.metaFirstKey != null)) {
- valid = valid
- && comparator.compare(currentRegionBoundariesInformation.storesFirstKey,
- currentRegionBoundariesInformation.metaFirstKey) >= 0;
+ if (
+ (currentRegionBoundariesInformation.storesFirstKey != null)
+ && (currentRegionBoundariesInformation.metaFirstKey != null)
+ ) {
+ valid = valid && comparator.compare(currentRegionBoundariesInformation.storesFirstKey,
+ currentRegionBoundariesInformation.metaFirstKey) >= 0;
}
// Checking stop key.
- if ((currentRegionBoundariesInformation.storesLastKey != null)
- && (currentRegionBoundariesInformation.metaLastKey != null)) {
- valid = valid
- && comparator.compare(currentRegionBoundariesInformation.storesLastKey,
- currentRegionBoundariesInformation.metaLastKey) < 0;
+ if (
+ (currentRegionBoundariesInformation.storesLastKey != null)
+ && (currentRegionBoundariesInformation.metaLastKey != null)
+ ) {
+ valid = valid && comparator.compare(currentRegionBoundariesInformation.storesLastKey,
+ currentRegionBoundariesInformation.metaLastKey) < 0;
}
if (!valid) {
errors.reportError(ErrorReporter.ERROR_CODE.BOUNDARIES_ERROR,
- "Found issues with regions boundaries",
- tablesInfo.get(regionInfo.getTable()));
+ "Found issues with regions boundaries", tablesInfo.get(regionInfo.getTable()));
LOG.warn("Region's boundaries not aligned between stores and META for:");
LOG.warn(Objects.toString(currentRegionBoundariesInformation));
}
@@ -1041,22 +1005,20 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Orphaned regions are regions without a .regioninfo file in them. We "adopt"
- * these orphans by creating a new region, and moving the column families,
- * recovered edits, WALs, into the new region dir. We determine the region
- * startkey and endkeys by looking at all of the hfiles inside the column
- * families to identify the min and max keys. The resulting region will
- * likely violate table integrity but will be dealt with by merging
- * overlapping regions.
+ * Orphaned regions are regions without a .regioninfo file in them. We "adopt" these orphans by
+ * creating a new region, and moving the column families, recovered edits, WALs, into the new
+ * region dir. We determine the region startkey and endkeys by looking at all of the hfiles inside
+ * the column families to identify the min and max keys. The resulting region will likely violate
+ * table integrity but will be dealt with by merging overlapping regions.
*/
private void adoptHdfsOrphan(HbckInfo hi) throws IOException {
Path p = hi.getHdfsRegionDir();
FileSystem fs = p.getFileSystem(getConf());
FileStatus[] dirs = fs.listStatus(p);
if (dirs == null) {
- LOG.warn("Attempt to adopt orphan hdfs region skipped because no files present in " +
- p + ". This dir could probably be deleted.");
- return ;
+ LOG.warn("Attempt to adopt orphan hdfs region skipped because no files present in " + p
+ + ". This dir could probably be deleted.");
+ return;
}
TableName tableName = hi.getTableName();
@@ -1065,9 +1027,9 @@ public class HBaseFsck extends Configured implements Closeable {
TableDescriptor template = tableInfo.getHTD();
// find min and max key values
- Pair<byte[],byte[]> orphanRegionRange = null;
+ Pair<byte[], byte[]> orphanRegionRange = null;
for (FileStatus cf : dirs) {
- String cfName= cf.getPath().getName();
+ String cfName = cf.getPath().getName();
// TODO Figure out what the special dirs are
if (cfName.startsWith(".") || cfName.equals(HConstants.SPLIT_LOGDIR_NAME)) {
continue;
@@ -1078,8 +1040,7 @@ public class HBaseFsck extends Configured implements Closeable {
byte[] start, end;
HFile.Reader hf = null;
try {
- hf = HFile.createReader(fs, hfile.getPath(), CacheConfig.DISABLED,
- true, getConf());
+ hf = HFile.createReader(fs, hfile.getPath(), CacheConfig.DISABLED, true, getConf());
Optional<Cell> startKv = hf.getFirstKey();
start = CellUtil.cloneRow(startKv.get());
Optional<Cell> endKv = hf.getLastKey();
@@ -1119,14 +1080,13 @@ public class HBaseFsck extends Configured implements Closeable {
sidelineRegionDir(fs, hi);
return;
}
- LOG.info("Min max keys are : [" + Bytes.toString(orphanRegionRange.getFirst()) + ", " +
- Bytes.toString(orphanRegionRange.getSecond()) + ")");
+ LOG.info("Min max keys are : [" + Bytes.toString(orphanRegionRange.getFirst()) + ", "
+ + Bytes.toString(orphanRegionRange.getSecond()) + ")");
// create new region on hdfs. move data into place.
RegionInfo regionInfo = RegionInfoBuilder.newBuilder(template.getTableName())
- .setStartKey(orphanRegionRange.getFirst())
- .setEndKey(Bytes.add(orphanRegionRange.getSecond(), new byte[1]))
- .build();
+ .setStartKey(orphanRegionRange.getFirst())
+ .setEndKey(Bytes.add(orphanRegionRange.getSecond(), new byte[1])).build();
LOG.info("Creating new region : " + regionInfo);
HRegion region = HBaseFsckRepair.createHDFSRegionDir(getConf(), regionInfo, template);
Path target = region.getRegionFileSystem().getRegionDir();
@@ -1137,11 +1097,9 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * This method determines if there are table integrity errors in HDFS. If
- * there are errors and the appropriate "fix" options are enabled, the method
- * will first correct orphan regions making them into legit regiondirs, and
- * then reload to merge potentially overlapping regions.
- *
+ * This method determines if there are table integrity errors in HDFS. If there are errors and the
+ * appropriate "fix" options are enabled, the method will first correct orphan regions making them
+ * into legit regiondirs, and then reload to merge potentially overlapping regions.
* @return number of table integrity errors found
*/
private int restoreHdfsIntegrity() throws IOException, InterruptedException {
@@ -1184,12 +1142,12 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Scan all the store file names to find any lingering reference files,
- * which refer to some none-exiting files. If "fix" option is enabled,
- * any lingering reference file will be sidelined if found.
+ * Scan all the store file names to find any lingering reference files, which refer to some
+ * none-exiting files. If "fix" option is enabled, any lingering reference file will be sidelined
+ * if found.
* <p>
- * Lingering reference file prevents a region from opening. It has to
- * be fixed before a cluster can start properly.
+ * Lingering reference file prevents a region from opening. It has to be fixed before a cluster
+ * can start properly.
*/
private void offlineReferenceFileRepair() throws IOException, InterruptedException {
clearState();
@@ -1198,10 +1156,10 @@ public class HBaseFsck extends Configured implements Closeable {
FileSystem fs = hbaseRoot.getFileSystem(conf);
Map<String, Path> allFiles =
getTableStoreFilePathMap(fs, hbaseRoot, new FSUtils.ReferenceFileFilter(fs), executor);
- for (Path path: allFiles.values()) {
+ for (Path path : allFiles.values()) {
Path referredToFile = StoreFileInfo.getReferredToFile(path);
if (fs.exists(referredToFile)) {
- continue; // good, expected
+ continue; // good, expected
}
// Found a lingering reference file
@@ -1227,8 +1185,7 @@ public class HBaseFsck extends Configured implements Closeable {
Path rootDir = getSidelineDir();
Path dst = new Path(rootDir, pathStr.substring(index + 1));
fs.mkdirs(dst.getParent());
- LOG.info("Trying to sideline reference file "
- + path + " to " + dst);
+ LOG.info("Trying to sideline reference file " + path + " to " + dst);
setShouldRerun();
success = fs.rename(path, dst);
@@ -1242,17 +1199,15 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Runs through the HBase rootdir and creates a reverse lookup map for
- * table StoreFile names to the full Path.
- * <br>
+ * Runs through the HBase rootdir and creates a reverse lookup map for table StoreFile names to
+ * the full Path. <br>
* Example...<br>
- * Key = 3944417774205889744 <br>
+ * Key = 3944417774205889744 <br>
* Value = hdfs://localhost:51169/user/userid/-ROOT-/70236052/info/3944417774205889744
- *
- * @param fs The file system to use.
- * @param hbaseRootDir The root directory to scan.
- * @param sfFilter optional path filter to apply to store files
- * @param executor optional executor service to parallelize this operation
+ * @param fs The file system to use.
+ * @param hbaseRootDir The root directory to scan.
+ * @param sfFilter optional path filter to apply to store files
+ * @param executor optional executor service to parallelize this operation
* @return Map keyed by StoreFile name with a value of the full Path.
* @throws IOException When scanning the directory fails.
*/
@@ -1263,8 +1218,7 @@ public class HBaseFsck extends Configured implements Closeable {
// reporting (to print a '.' every so often). Its just wrong reaching across packages this way,
// especially when no relation.
private Map<String, Path> getTableStoreFilePathMap(final FileSystem fs, final Path hbaseRootDir,
- PathFilter sfFilter, ExecutorService executor)
- throws IOException, InterruptedException {
+ PathFilter sfFilter, ExecutorService executor) throws IOException, InterruptedException {
ConcurrentHashMap<String, Path> map = new ConcurrentHashMap<>(1024, 0.75f, 32);
// if this method looks similar to 'getTableFragmentation' that is because
@@ -1273,28 +1227,26 @@ public class HBaseFsck extends Configured implements Closeable {
// only include the directory paths to tables
for (Path tableDir : tableDirs) {
getTableStoreFilePathMap(map, fs, hbaseRootDir, CommonFSUtils.getTableName(tableDir),
- sfFilter, executor);
+ sfFilter, executor);
}
return map;
}
/**
- * Runs through the HBase rootdir/tablename and creates a reverse lookup map for
- * table StoreFile names to the full Path. Note that because this method can be called
- * on a 'live' HBase system that we will skip files that no longer exist by the time
- * we traverse them and similarly the user of the result needs to consider that some
- * entries in this map may not exist by the time this call completes.
- * <br>
+ * Runs through the HBase rootdir/tablename and creates a reverse lookup map for table StoreFile
+ * names to the full Path. Note that because this method can be called on a 'live' HBase system
+ * that we will skip files that no longer exist by the time we traverse them and similarly the
+ * user of the result needs to consider that some entries in this map may not exist by the time
+ * this call completes. <br>
* Example...<br>
- * Key = 3944417774205889744 <br>
+ * Key = 3944417774205889744 <br>
* Value = hdfs://localhost:51169/user/userid/-ROOT-/70236052/info/3944417774205889744
- *
- * @param resultMap map to add values. If null, method will create and populate one to return
- * @param fs The file system to use.
- * @param hbaseRootDir The root directory to scan.
- * @param tableName name of the table to scan.
- * @param sfFilter optional path filter to apply to store files
- * @param executor optional executor service to parallelize this operation
+ * @param resultMap map to add values. If null, method will create and populate one to return
+ * @param fs The file system to use.
+ * @param hbaseRootDir The root directory to scan.
+ * @param tableName name of the table to scan.
+ * @param sfFilter optional path filter to apply to store files
+ * @param executor optional executor service to parallelize this operation
* @return Map keyed by StoreFile name with a value of the full Path.
* @throws IOException When scanning the directory fails.
*/
@@ -1305,16 +1257,15 @@ public class HBaseFsck extends Configured implements Closeable {
// every so often). Its just wrong reaching across packages this way, especially when
// no relation.
private static Map<String, Path> getTableStoreFilePathMap(Map<String, Path> resultMap,
- final FileSystem fs, final Path hbaseRootDir, TableName tableName,
- final PathFilter sfFilter, ExecutorService executor)
- throws IOException, InterruptedException {
+ final FileSystem fs, final Path hbaseRootDir, TableName tableName, final PathFilter sfFilter,
+ ExecutorService executor) throws IOException, InterruptedException {
final Map<String, Path> finalResultMap =
- resultMap == null ? new ConcurrentHashMap<>(128, 0.75f, 32) : resultMap;
+ resultMap == null ? new ConcurrentHashMap<>(128, 0.75f, 32) : resultMap;
// only include the directory paths to tables
Path tableDir = CommonFSUtils.getTableDir(hbaseRootDir, tableName);
- // Inside a table, there are compaction.dir directories to skip. Otherwise, all else
+ // Inside a table, there are compaction.dir directories to skip. Otherwise, all else
// should be regions.
final FSUtils.FamilyDirFilter familyFilter = new FSUtils.FamilyDirFilter(fs);
final Vector<Exception> exceptions = new Vector<>();
@@ -1339,7 +1290,7 @@ public class HBaseFsck extends Configured implements Closeable {
@Override
public void run() {
try {
- HashMap<String,Path> regionStoreFileMap = new HashMap<>();
+ HashMap<String, Path> regionStoreFileMap = new HashMap<>();
List<FileStatus> familyDirs =
FSUtils.listStatusWithStatusFilter(fs, dd, familyFilter);
if (familyDirs == null) {
@@ -1413,16 +1364,16 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Scan all the store file names to find any lingering HFileLink files,
- * which refer to some none-exiting files. If "fix" option is enabled,
- * any lingering HFileLink file will be sidelined if found.
+ * Scan all the store file names to find any lingering HFileLink files, which refer to some
+ * none-exiting files. If "fix" option is enabled, any lingering HFileLink file will be sidelined
+ * if found.
*/
private void offlineHLinkFileRepair() throws IOException, InterruptedException {
Configuration conf = getConf();
Path hbaseRoot = CommonFSUtils.getRootDir(conf);
FileSystem fs = hbaseRoot.getFileSystem(conf);
- Map<String, Path> allFiles = getTableStoreFilePathMap(fs, hbaseRoot,
- new FSUtils.HFileLinkFilter(), executor);
+ Map<String, Path> allFiles =
+ getTableStoreFilePathMap(fs, hbaseRoot, new FSUtils.HFileLinkFilter(), executor);
for (Path path : allFiles.values()) {
// building HFileLink object to gather locations
HFileLink actualLink = HFileLink.buildFromHFileLinkPattern(conf, path);
@@ -1432,7 +1383,7 @@ public class HBaseFsck extends Configured implements Closeable {
// Found a lingering HFileLink
errors.reportError(ErrorReporter.ERROR_CODE.LINGERING_HFILELINK,
- "Found lingering HFileLink " + path);
+ "Found lingering HFileLink " + path);
if (!shouldFixHFileLinks()) {
continue;
}
@@ -1442,7 +1393,7 @@ public class HBaseFsck extends Configured implements Closeable {
// An HFileLink path should be like
// ${hbase.rootdir}/data/namespace/table_name/region_id/family_name/
- // linkedtable=linkedregionname-linkedhfilename
+ // linkedtable=linkedregionname-linkedhfilename
// sidelineing will happen in the ${hbase.rootdir}/${sidelinedir} directory with the same
// folder structure.
boolean success = sidelineFile(fs, hbaseRoot, path);
@@ -1453,14 +1404,14 @@ public class HBaseFsck extends Configured implements Closeable {
// An HFileLink backreference path should be like
// ${hbase.rootdir}/archive/data/namespace/table_name/region_id/family_name/
- // .links-linkedhfilename
+ // .links-linkedhfilename
// sidelineing will happen in the ${hbase.rootdir}/${sidelinedir} directory with the same
// folder structure.
- Path backRefPath = FileLink.getBackReferencesDir(HFileArchiveUtil.getStoreArchivePath(conf,
+ Path backRefPath = FileLink.getBackReferencesDir(
+ HFileArchiveUtil.getStoreArchivePath(conf,
HFileLink.getReferencedTableName(path.getName().toString()),
- HFileLink.getReferencedRegionName(path.getName().toString()),
- path.getParent().getName()),
- HFileLink.getReferencedHFileName(path.getName().toString()));
+ HFileLink.getReferencedRegionName(path.getName().toString()), path.getParent().getName()),
+ HFileLink.getReferencedHFileName(path.getName().toString()));
success = sidelineFile(fs, hbaseRoot, backRefPath);
if (!success) {
@@ -1490,10 +1441,10 @@ public class HBaseFsck extends Configured implements Closeable {
* TODO -- need to add tests for this.
*/
private void reportEmptyMetaCells() {
- errors.print("Number of empty REGIONINFO_QUALIFIER rows in hbase:meta: " +
- emptyRegionInfoQualifiers.size());
+ errors.print("Number of empty REGIONINFO_QUALIFIER rows in hbase:meta: "
+ + emptyRegionInfoQualifiers.size());
if (details) {
- for (Result r: emptyRegionInfoQualifiers) {
+ for (Result r : emptyRegionInfoQualifiers) {
errors.print(" " + r);
}
}
@@ -1511,10 +1462,9 @@ public class HBaseFsck extends Configured implements Closeable {
errors.detail("Number of Tables in flux: " + numSkipped.get());
}
for (TableDescriptor td : allTables) {
- errors.detail(" Table: " + td.getTableName() + "\t" +
- (td.isReadOnly() ? "ro" : "rw") + "\t" +
- (td.isMetaRegion() ? "META" : " ") + "\t" +
- " families: " + td.getColumnFamilyCount());
+ errors.detail(" Table: " + td.getTableName() + "\t" + (td.isReadOnly() ? "ro" : "rw")
+ + "\t" + (td.isMetaRegion() ? "META" : " ") + "\t" + " families: "
+ + td.getColumnFamilyCount());
}
}
}
@@ -1524,8 +1474,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Read the .regioninfo file from the file system. If there is no
- * .regioninfo, add it to the orphan hdfs region list.
+ * Read the .regioninfo file from the file system. If there is no .regioninfo, add it to the
+ * orphan hdfs region list.
*/
private void loadHdfsRegioninfo(HbckInfo hbi) throws IOException {
Path regionDir = hbi.getHdfsRegionDir();
@@ -1548,12 +1498,12 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Exception thrown when a integrity repair operation fails in an
- * unresolvable way.
+ * Exception thrown when a integrity repair operation fails in an unresolvable way.
*/
public static class RegionRepairException extends IOException {
private static final long serialVersionUID = 1L;
final IOException ioe;
+
public RegionRepairException(String s, IOException ioe) {
super(s);
this.ioe = ioe;
@@ -1564,7 +1514,7 @@ public class HBaseFsck extends Configured implements Closeable {
* Populate hbi's from regionInfos loaded from file system.
*/
private SortedMap<TableName, TableInfo> loadHdfsRegionInfos()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException {
tablesInfo.clear(); // regenerating the data
// generate region split structure
Collection<HbckInfo> hbckInfos = regionInfoMap.values();
@@ -1581,28 +1531,27 @@ public class HBaseFsck extends Configured implements Closeable {
// Submit and wait for completion
hbiFutures = executor.invokeAll(hbis);
- for(int i = 0; i < hbiFutures.size(); i++) {
+ for (int i = 0; i < hbiFutures.size(); i++) {
WorkItemHdfsRegionInfo work = hbis.get(i);
Future<Void> f = hbiFutures.get(i);
try {
f.get();
- } catch(ExecutionException e) {
- LOG.warn("Failed to read .regioninfo file for region " +
- work.hbi.getRegionNameAsString(), e.getCause());
+ } catch (ExecutionException e) {
+ LOG.warn("Failed to read .regioninfo file for region " + work.hbi.getRegionNameAsString(),
+ e.getCause());
}
}
Path hbaseRoot = CommonFSUtils.getRootDir(getConf());
FileSystem fs = hbaseRoot.getFileSystem(getConf());
// serialized table info gathering.
- for (HbckInfo hbi: hbckInfos) {
+ for (HbckInfo hbi : hbckInfos) {
if (hbi.getHdfsHRI() == null) {
// was an orphan
continue;
}
-
// get table name from hdfs, populate various HBaseFsck tables.
TableName tableName = hbi.getTableName();
if (tableName == null) {
@@ -1618,14 +1567,14 @@ public class HBaseFsck extends Configured implements Closeable {
tablesInfo.put(tableName, modTInfo);
try {
TableDescriptor htd =
- FSTableDescriptors.getTableDescriptorFromFs(fs, hbaseRoot, tableName);
+ FSTableDescriptors.getTableDescriptorFromFs(fs, hbaseRoot, tableName);
modTInfo.htds.add(htd);
} catch (IOException ioe) {
if (!orphanTableDirs.containsKey(tableName)) {
LOG.warn("Unable to read .tableinfo from " + hbaseRoot, ioe);
- //should only report once for each table
+ // should only report once for each table
errors.reportError(ErrorReporter.ERROR_CODE.NO_TABLEINFO_FILE,
- "Unable to read .tableinfo from " + hbaseRoot + "/" + tableName);
+ "Unable to read .tableinfo from " + hbaseRoot + "/" + tableName);
Set<String> columns = new HashSet<>();
orphanTableDirs.put(tableName, getColumnFamilyList(columns, hbi));
}
@@ -1665,8 +1614,8 @@ public class HBaseFsck extends Configured implements Closeable {
* {@link ColumnFamilyDescriptor}<br>
*/
private boolean fabricateTableInfo(FSTableDescriptors fstd, TableName tableName,
- Set<String> columns) throws IOException {
- if (columns ==null || columns.isEmpty()) {
+ Set<String> columns) throws IOException {
+ if (columns == null || columns.isEmpty()) {
return false;
}
@@ -1707,14 +1656,12 @@ public class HBaseFsck extends Configured implements Closeable {
List<TableName> tmpList = new ArrayList<>(orphanTableDirs.keySet().size());
tmpList.addAll(orphanTableDirs.keySet());
TableDescriptor[] htds = getTableDescriptors(tmpList);
- Iterator<Entry<TableName, Set<String>>> iter =
- orphanTableDirs.entrySet().iterator();
+ Iterator<Entry<TableName, Set<String>>> iter = orphanTableDirs.entrySet().iterator();
int j = 0;
int numFailedCase = 0;
FSTableDescriptors fstd = new FSTableDescriptors(getConf());
while (iter.hasNext()) {
- Entry<TableName, Set<String>> entry =
- iter.next();
+ Entry<TableName, Set<String>> entry = iter.next();
TableName tableName = entry.getKey();
LOG.info("Trying to fix orphan table error: " + tableName);
if (j < htds.length) {
@@ -1728,12 +1675,12 @@ public class HBaseFsck extends Configured implements Closeable {
} else {
if (fabricateTableInfo(fstd, tableName, entry.getValue())) {
LOG.warn("fixing orphan table: " + tableName + " with a default .tableinfo file");
- LOG.warn("Strongly recommend to modify the TableDescriptor if necessary for: " +
- tableName);
+ LOG.warn(
+ "Strongly recommend to modify the TableDescriptor if necessary for: " + tableName);
iter.remove();
} else {
- LOG.error("Unable to create default .tableinfo for " + tableName +
- " while missing column family information");
+ LOG.error("Unable to create default .tableinfo for " + tableName
+ + " while missing column family information");
numFailedCase++;
}
}
@@ -1744,29 +1691,28 @@ public class HBaseFsck extends Configured implements Closeable {
// all orphanTableDirs are luckily recovered
// re-run doFsck after recovering the .tableinfo file
setShouldRerun();
- LOG.warn("Strongly recommend to re-run manually hfsck after all orphanTableDirs " +
- "being fixed");
+ LOG.warn(
+ "Strongly recommend to re-run manually hfsck after all orphanTableDirs " + "being fixed");
} else if (numFailedCase > 0) {
- LOG.error("Failed to fix " + numFailedCase
- + " OrphanTables with default .tableinfo files");
+ LOG.error("Failed to fix " + numFailedCase + " OrphanTables with default .tableinfo files");
}
}
- //cleanup the list
+ // cleanup the list
orphanTableDirs.clear();
}
/**
- * Generate set of puts to add to new meta. This expects the tables to be
- * clean with no overlaps or holes. If there are any problems it returns null.
- *
- * <p>Adds tables back with disabled state and all regions CLOSED</p>
- *
+ * Generate set of puts to add to new meta. This expects the tables to be clean with no overlaps
+ * or holes. If there are any problems it returns null.
+ * <p>
+ * Adds tables back with disabled state and all regions CLOSED
+ * </p>
* @return An array list of puts to do in bulk, null if tables have problems
*/
private ArrayList<Put> generatePuts(SortedMap<TableName, TableInfo> tablesInfo)
- throws IOException {
+ throws IOException {
ArrayList<Put> puts = new ArrayList<>();
boolean hasProblems = false;
for (Entry<TableName, TableInfo> e : tablesInfo.entrySet()) {
@@ -1781,18 +1727,18 @@ public class HBaseFsck extends Configured implements Closeable {
// Userspace tables are added in DISABLED state but Namespace table is added ENABLED.
// Adding ns ENABLED makes it so less steps for operator performing recovery.
TableName ns = TableDescriptorBuilder.NAMESPACE_TABLEDESC.getTableName();
- TableState.State state = ti.getName().equals(ns)?
- TableState.State.ENABLED: TableState.State.DISABLED;
- puts.add(HBCKMetaTableAccessor.makePutFromTableState(
- new TableState(ti.tableName, state), System.currentTimeMillis()));
+ TableState.State state =
+ ti.getName().equals(ns) ? TableState.State.ENABLED : TableState.State.DISABLED;
+ puts.add(HBCKMetaTableAccessor.makePutFromTableState(new TableState(ti.tableName, state),
+ System.currentTimeMillis()));
for (Entry<byte[], Collection<HbckInfo>> spl : ti.regionSplitCalculator.getStarts().asMap()
- .entrySet()) {
+ .entrySet()) {
Collection<HbckInfo> his = spl.getValue();
int sz = his.size();
if (sz != 1) {
// problem
- LOG.error("Split starting at " + Bytes.toStringBinary(spl.getKey()) +
- " had " + sz + " regions instead of exactly 1.");
+ LOG.error("Split starting at " + Bytes.toStringBinary(spl.getKey()) + " had " + sz
+ + " regions instead of exactly 1.");
hasProblems = true;
continue;
}
@@ -1806,7 +1752,7 @@ public class HBaseFsck extends Configured implements Closeable {
puts.add(p);
}
}
- return hasProblems? null: puts;
+ return hasProblems ? null : puts;
}
/**
@@ -1814,27 +1760,16 @@ public class HBaseFsck extends Configured implements Closeable {
*/
private static Put addEmptyLocation(Put p, int replicaId) throws IOException {
CellBuilder builder = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY);
- return p.add(builder.clear()
- .setRow(p.getRow())
- .setFamily(getCatalogFamily())
+ return p
+ .add(builder.clear().setRow(p.getRow()).setFamily(getCatalogFamily())
.setQualifier(HBCKMetaTableAccessor.getServerColumn(replicaId))
- .setTimestamp(p.getTimestamp())
- .setType(Cell.Type.Put)
- .build())
- .add(builder.clear()
- .setRow(p.getRow())
- .setFamily(getCatalogFamily())
- .setQualifier(HBCKMetaTableAccessor.getStartCodeColumn(replicaId))
- .setTimestamp(p.getTimestamp())
- .setType(Cell.Type.Put)
- .build())
- .add(builder.clear()
- .setRow(p.getRow())
- .setFamily(getCatalogFamily())
- .setQualifier(HBCKMetaTableAccessor.getSeqNumColumn(replicaId))
- .setTimestamp(p.getTimestamp())
- .setType(Cell.Type.Put)
- .build());
+ .setTimestamp(p.getTimestamp()).setType(Cell.Type.Put).build())
+ .add(builder.clear().setRow(p.getRow()).setFamily(getCatalogFamily())
+ .setQualifier(HBCKMetaTableAccessor.getStartCodeColumn(replicaId))
+ .setTimestamp(p.getTimestamp()).setType(Cell.Type.Put).build())
+ .add(builder.clear().setRow(p.getRow()).setFamily(getCatalogFamily())
+ .setQualifier(HBCKMetaTableAccessor.getSeqNumColumn(replicaId))
+ .setTimestamp(p.getTimestamp()).setType(Cell.Type.Put).build());
}
/**
@@ -1849,14 +1784,10 @@ public class HBaseFsck extends Configured implements Closeable {
* Copied from MetaTableAccessor.
*/
private static void addRegionStateToPut(Put put, RegionState.State state) throws IOException {
- put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
- .setRow(put.getRow())
- .setFamily(HConstants.CATALOG_FAMILY)
- .setQualifier(getRegionStateColumn())
- .setTimestamp(put.getTimestamp())
- .setType(Cell.Type.Put)
- .setValue(Bytes.toBytes(state.name()))
- .build());
+ put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setRow(put.getRow())
+ .setFamily(HConstants.CATALOG_FAMILY).setQualifier(getRegionStateColumn())
+ .setTimestamp(put.getTimestamp()).setType(Cell.Type.Put).setValue(Bytes.toBytes(state.name()))
+ .build());
}
private static byte[] getRegionStateColumn() {
@@ -1866,8 +1797,7 @@ public class HBaseFsck extends Configured implements Closeable {
/**
* Suggest fixes for each table
*/
- private void suggestFixes(
- SortedMap<TableName, TableInfo> tablesInfo) throws IOException {
+ private void suggestFixes(SortedMap<TableName, TableInfo> tablesInfo) throws IOException {
logParallelMerge();
for (TableInfo tInfo : tablesInfo.values()) {
TableIntegrityErrorHandler handler = tInfo.new IntegrityFixSuggester(tInfo, errors);
@@ -1876,9 +1806,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Rebuilds meta from information in hdfs/fs. Depends on configuration settings passed into
- * hbck constructor to point to a particular fs/dir. Assumes HBase is OFFLINE.
- *
+ * Rebuilds meta from information in hdfs/fs. Depends on configuration settings passed into hbck
+ * constructor to point to a particular fs/dir. Assumes HBase is OFFLINE.
* @return true if successful, false if attempt failed.
*/
public boolean rebuildMeta() throws IOException, InterruptedException {
@@ -1895,7 +1824,7 @@ public class HBaseFsck extends Configured implements Closeable {
// make sure ok.
if (errors.getErrorList().size() != errs) {
// While in error state, iterate until no more fixes possible
- while(true) {
+ while (true) {
fixes = 0;
suggestFixes(tablesInfo);
errors.clear();
@@ -1919,13 +1848,13 @@ public class HBaseFsck extends Configured implements Closeable {
Path backupDir = sidelineOldMeta();
HRegion meta = createNewMeta();
// Save off the waldir we're writing to so we can delete it when done.
- Path waldir = ((AbstractFSWAL)meta.getWAL()).getCurrentFileName().getParent();
+ Path waldir = ((AbstractFSWAL) meta.getWAL()).getCurrentFileName().getParent();
try {
// populate meta
List<Put> puts = generatePuts(tablesInfo);
if (puts == null) {
- LOG.error("Problem encountered when creating new hbase:meta entries. " +
- "You may need to restore the previously sidelined hbase:meta");
+ LOG.error("Problem encountered when creating new hbase:meta entries. "
+ + "You may need to restore the previously sidelined hbase:meta");
return false;
}
meta.batchMutate(puts.toArray(new Put[puts.size()]));
@@ -1941,7 +1870,6 @@ public class HBaseFsck extends Configured implements Closeable {
/**
* This borrows code from MasterFileSystem.bootstrap()
- *
* @return an open hbase:meta HRegion
*/
private HRegion createNewMeta() throws IOException {
@@ -1956,22 +1884,21 @@ public class HBaseFsck extends Configured implements Closeable {
*/
private void logParallelMerge() {
if (getConf().getBoolean("hbasefsck.overlap.merge.parallel", true)) {
- LOG.trace("Running overlap check in parallel; set hbasefsck.overlap.merge.parallel to" +
- " false to run serially.");
+ LOG.trace("Running overlap check in parallel; set hbasefsck.overlap.merge.parallel to"
+ + " false to run serially.");
} else {
- LOG.trace("Handling overlap check serially; set hbasefsck.overlap.merge.parallel to" +
- " true to run in parallel.");
+ LOG.trace("Handling overlap check serially; set hbasefsck.overlap.merge.parallel to"
+ + " true to run in parallel.");
}
}
- private SortedMap<TableName, TableInfo> checkHdfsIntegrity(boolean fixHoles,
- boolean fixOverlaps) throws IOException {
+ private SortedMap<TableName, TableInfo> checkHdfsIntegrity(boolean fixHoles, boolean fixOverlaps)
+ throws IOException {
logParallelMerge();
for (TableInfo tInfo : tablesInfo.values()) {
TableIntegrityErrorHandler handler;
if (fixHoles || fixOverlaps) {
- handler = tInfo.new HDFSIntegrityFixer(tInfo, errors, getConf(),
- fixHoles, fixOverlaps);
+ handler = tInfo.new HDFSIntegrityFixer(tInfo, errors, getConf(), fixHoles, fixOverlaps);
} else {
handler = tInfo.new IntegrityFixSuggester(tInfo, errors);
}
@@ -1987,8 +1914,7 @@ public class HBaseFsck extends Configured implements Closeable {
if (sidelineDir == null) {
Path hbaseDir = CommonFSUtils.getRootDir(getConf());
Path hbckDir = new Path(hbaseDir, HConstants.HBCK_SIDELINEDIR_NAME);
- sidelineDir = new Path(hbckDir, hbaseDir.getName() + "-"
- + startMillis);
+ sidelineDir = new Path(hbckDir, hbaseDir.getName() + "-" + startMillis);
}
return sidelineDir;
}
@@ -2002,14 +1928,12 @@ public class HBaseFsck extends Configured implements Closeable {
/**
* Sideline a region dir (instead of deleting it)
- *
* @param parentDir if specified, the region will be sidelined to folder like
- * {@literal .../parentDir/<table name>/<region name>}. The purpose is to group together
- * similar regions sidelined, for example, those regions should be bulk loaded back later
- * on. If NULL, it is ignored.
+ * {@literal .../parentDir/<table name>/<region name>}. The purpose is to group
+ * together similar regions sidelined, for example, those regions should be bulk
+ * loaded back later on. If NULL, it is ignored.
*/
- Path sidelineRegionDir(FileSystem fs,
- String parentDir, HbckInfo hi) throws IOException {
+ Path sidelineRegionDir(FileSystem fs, String parentDir, HbckInfo hi) throws IOException {
TableName tableName = hi.getTableName();
Path regionDir = hi.getHdfsRegionDir();
@@ -2022,22 +1946,22 @@ public class HBaseFsck extends Configured implements Closeable {
if (parentDir != null) {
rootDir = new Path(rootDir, parentDir);
}
- Path sidelineTableDir= CommonFSUtils.getTableDir(rootDir, tableName);
+ Path sidelineTableDir = CommonFSUtils.getTableDir(rootDir, tableName);
Path sidelineRegionDir = new Path(sidelineTableDir, regionDir.getName());
fs.mkdirs(sidelineRegionDir);
boolean success = false;
- FileStatus[] cfs = fs.listStatus(regionDir);
+ FileStatus[] cfs = fs.listStatus(regionDir);
if (cfs == null) {
LOG.info("Region dir is empty: " + regionDir);
} else {
for (FileStatus cf : cfs) {
Path src = cf.getPath();
- Path dst = new Path(sidelineRegionDir, src.getName());
+ Path dst = new Path(sidelineRegionDir, src.getName());
if (fs.isFile(src)) {
// simple file
success = fs.rename(src, dst);
if (!success) {
- String msg = "Unable to rename file " + src + " to " + dst;
+ String msg = "Unable to rename file " + src + " to " + dst;
LOG.error(msg);
throw new IOException(msg);
}
@@ -2050,14 +1974,14 @@ public class HBaseFsck extends Configured implements Closeable {
LOG.info("Sidelining files from " + src + " into containing region " + dst);
// FileSystemFsck.rename is inconsistent with directories -- if the
// dst (foo/a) exists and is a dir, and the src (foo/b) is a dir,
- // it moves the src into the dst dir resulting in (foo/a/b). If
+ // it moves the src into the dst dir resulting in (foo/a/b). If
// the dst does not exist, and the src a dir, src becomes dst. (foo/b)
FileStatus[] hfiles = fs.listStatus(src);
if (hfiles != null && hfiles.length > 0) {
for (FileStatus hfile : hfiles) {
success = fs.rename(hfile.getPath(), dst);
if (!success) {
- String msg = "Unable to rename file " + src + " to " + dst;
+ String msg = "Unable to rename file " + src + " to " + dst;
LOG.error(msg);
throw new IOException(msg);
}
@@ -2081,25 +2005,23 @@ public class HBaseFsck extends Configured implements Closeable {
/**
* Side line an entire table.
*/
- void sidelineTable(FileSystem fs, TableName tableName, Path hbaseDir,
- Path backupHbaseDir) throws IOException {
+ void sidelineTable(FileSystem fs, TableName tableName, Path hbaseDir, Path backupHbaseDir)
+ throws IOException {
Path tableDir = CommonFSUtils.getTableDir(hbaseDir, tableName);
if (fs.exists(tableDir)) {
- Path backupTableDir= CommonFSUtils.getTableDir(backupHbaseDir, tableName);
+ Path backupTableDir = CommonFSUtils.getTableDir(backupHbaseDir, tableName);
fs.mkdirs(backupTableDir.getParent());
boolean success = fs.rename(tableDir, backupTableDir);
if (!success) {
- throw new IOException("Failed to move " + tableName + " from "
- + tableDir + " to " + backupTableDir);
+ throw new IOException(
+ "Failed to move " + tableName + " from " + tableDir + " to " + backupTableDir);
}
} else {
- LOG.info("No previous " + tableName + " exists. Continuing.");
+ LOG.info("No previous " + tableName + " exists. Continuing.");
}
}
- /**
- * @return Path to backup of original directory
- */
+ /** Returns Path to backup of original directory */
Path sidelineOldMeta() throws IOException {
// put current hbase:meta aside.
Path hbaseDir = CommonFSUtils.getRootDir(getConf());
@@ -2109,9 +2031,11 @@ public class HBaseFsck extends Configured implements Closeable {
try {
sidelineTable(fs, TableName.META_TABLE_NAME, hbaseDir, backupDir);
} catch (IOException e) {
- LOG.error(HBaseMarkers.FATAL, "... failed to sideline meta. Currently in " +
- "inconsistent state. To restore try to rename hbase:meta in " +
- backupDir.getName() + " to " + hbaseDir.getName() + ".", e);
+ LOG.error(HBaseMarkers.FATAL,
+ "... failed to sideline meta. Currently in "
+ + "inconsistent state. To restore try to rename hbase:meta in " + backupDir.getName()
+ + " to " + hbaseDir.getName() + ".",
+ e);
throw e; // throw original exception
}
return backupDir;
@@ -2126,7 +2050,7 @@ public class HBaseFsck extends Configured implements Closeable {
// has no entry in the table states. HBCK doesn't work right w/ hbase2 but just do this in
// meantime.
this.tableStates.put(TableName.META_TABLE_NAME,
- new TableState(TableName.META_TABLE_NAME, TableState.State.ENABLED));
+ new TableState(TableName.META_TABLE_NAME, TableState.State.ENABLED));
}
/**
@@ -2135,13 +2059,10 @@ public class HBaseFsck extends Configured implements Closeable {
*/
private boolean isTableDisabled(TableName tableName) {
return tableStates.containsKey(tableName)
- && tableStates.get(tableName)
- .inStates(TableState.State.DISABLED, TableState.State.DISABLING);
+ && tableStates.get(tableName).inStates(TableState.State.DISABLED, TableState.State.DISABLING);
}
- /**
- * @return True if the hbase version file exists.
- */
+ /** Returns True if the hbase version file exists. */
// TODO: Add an hbase.version file integrity check.
public static boolean versionFileExists(FileSystem fs, Path rootDir) throws IOException {
return fs.exists(new Path(rootDir, HConstants.VERSION_FILE_NAME));
@@ -2151,16 +2072,14 @@ public class HBaseFsck extends Configured implements Closeable {
* Create hbase.version file.
*/
public static void versionFileCreate(Configuration configuration, FileSystem fs, Path rootDir)
- throws IOException {
+ throws IOException {
FSUtils.setVersion(fs, rootDir,
- configuration.getInt(HConstants.THREAD_WAKE_FREQUENCY, 10 * 1000),
- configuration.getInt(HConstants.VERSION_FILE_WRITE_ATTEMPTS,
- HConstants.DEFAULT_VERSION_FILE_WRITE_ATTEMPTS));
+ configuration.getInt(HConstants.THREAD_WAKE_FREQUENCY, 10 * 1000), configuration.getInt(
+ HConstants.VERSION_FILE_WRITE_ATTEMPTS, HConstants.DEFAULT_VERSION_FILE_WRITE_ATTEMPTS));
}
/**
- * Scan HDFS for all regions, recording their information into
- * regionInfoMap
+ * Scan HDFS for all regions, recording their information into regionInfoMap
*/
public void loadHdfsRegionDirs() throws IOException, InterruptedException {
Path rootDir = CommonFSUtils.getRootDir(getConf());
@@ -2175,18 +2094,18 @@ public class HBaseFsck extends Configured implements Closeable {
tableDirs.add(fs.getFileStatus(tableDir));
} catch (IOException ioe) {
LOG.warn("Failed to get Table directory for included table: {}",
- CommonFSUtils.getTableName(tableDir), ioe);
+ CommonFSUtils.getTableName(tableDir), ioe);
}
}
} else {
- tableDirs.add(fs.getFileStatus(
- CommonFSUtils.getTableDir(rootDir, TableName.META_TABLE_NAME)));
+ tableDirs
+ .add(fs.getFileStatus(CommonFSUtils.getTableDir(rootDir, TableName.META_TABLE_NAME)));
}
// Verify that version file exists
if (!versionFileExists(fs, rootDir)) {
errors.reportError(ErrorReporter.ERROR_CODE.NO_VERSION_FILE,
- "Version file does not exist under " + rootDir);
+ "Version file does not exist under " + rootDir);
if (shouldFixVersionFile()) {
setShouldRerun();
versionFileCreate(getConf(), fs, rootDir);
@@ -2194,21 +2113,20 @@ public class HBaseFsck extends Configured implements Closeable {
}
// Avoid multithreading at table-level because already multithreaded internally at
- // region-level. Additionally multithreading at table-level can lead to deadlock
- // if there are many tables in the cluster. Since there are a limited # of threads
+ // region-level. Additionally multithreading at table-level can lead to deadlock
+ // if there are many tables in the cluster. Since there are a limited # of threads
// in the executor's thread pool and if we multithread at the table-level by putting
// WorkItemHdfsDir callables into the executor, then we will have some threads in the
// executor tied up solely in waiting for the tables' region-level calls to complete.
// If there are enough tables then there will be no actual threads in the pool left
// for the region-level callables to be serviced.
for (FileStatus tableDir : tableDirs) {
- LOG.debug("Loading region dirs from " +tableDir.getPath());
+ LOG.debug("Loading region dirs from " + tableDir.getPath());
WorkItemHdfsDir item = new WorkItemHdfsDir(fs, errors, tableDir);
try {
item.call();
} catch (ExecutionException e) {
- LOG.warn("Could not completely load table dir " +
- tableDir.getPath(), e.getCause());
+ LOG.warn("Could not completely load table dir " + tableDir.getPath(), e.getCause());
}
}
}
@@ -2225,31 +2143,28 @@ public class HBaseFsck extends Configured implements Closeable {
}
if (loc == null) {
errors.reportError(ErrorReporter.ERROR_CODE.NULL_META_REGION,
- "META region was not found in ZooKeeper");
+ "META region was not found in ZooKeeper");
return false;
}
-
HRegionLocation metaLocation = loc;
// Check if Meta region is valid and existing
if (metaLocation == null) {
- errors.reportError(ErrorReporter.ERROR_CODE.NULL_META_REGION,
- "META region location is null");
+ errors.reportError(ErrorReporter.ERROR_CODE.NULL_META_REGION, "META region location is null");
return false;
}
if (metaLocation.getRegion() == null) {
errors.reportError(ErrorReporter.ERROR_CODE.NULL_META_REGION,
- "META location regionInfo is null");
+ "META location regionInfo is null");
return false;
}
if (metaLocation.getHostname() == null) {
errors.reportError(ErrorReporter.ERROR_CODE.NULL_META_REGION,
- "META location hostName is null");
+ "META location hostName is null");
return false;
}
ServerName sn = metaLocation.getServerName();
- MetaEntry m =
- new MetaEntry(metaLocation.getRegion(), sn, System.currentTimeMillis());
+ MetaEntry m = new MetaEntry(metaLocation.getRegion(), sn, System.currentTimeMillis());
HbckInfo hbckInfo = regionInfoMap.get(metaLocation.getRegion().getEncodedName());
if (hbckInfo == null) {
regionInfoMap.put(metaLocation.getRegion().getEncodedName(), new HbckInfo(m));
@@ -2287,18 +2202,18 @@ public class HBaseFsck extends Configured implements Closeable {
List<Future<Void>> workFutures;
// loop to contact each region server in parallel
- for (ServerName rsinfo: regionServerList) {
+ for (ServerName rsinfo : regionServerList) {
workItems.add(new WorkItemRegion(this, rsinfo, errors, connection));
}
workFutures = executor.invokeAll(workItems);
- for(int i=0; i<workFutures.size(); i++) {
+ for (int i = 0; i < workFutures.size(); i++) {
WorkItemRegion item = workItems.get(i);
Future<Void> f = workFutures.get(i);
try {
f.get();
- } catch(ExecutionException e) {
+ } catch (ExecutionException e) {
LOG.warn("Could not process regionserver {}", item.rsinfo.getAddress(), e.getCause());
}
}
@@ -2307,12 +2222,11 @@ public class HBaseFsck extends Configured implements Closeable {
/**
* Check consistency of all regions that have been found in previous phases.
*/
- private void checkAndFixConsistency()
- throws IOException, KeeperException, InterruptedException {
+ private void checkAndFixConsistency() throws IOException, KeeperException, InterruptedException {
// Divide the checks in two phases. One for default/primary replicas and another
// for the non-primary ones. Keeps code cleaner this way.
List<CheckRegionConsistencyWorkItem> workItems = new ArrayList<>(regionInfoMap.size());
- for (java.util.Map.Entry<String, HbckInfo> e: regionInfoMap.entrySet()) {
+ for (java.util.Map.Entry<String, HbckInfo> e : regionInfoMap.entrySet()) {
if (e.getValue().getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID) {
workItems.add(new CheckRegionConsistencyWorkItem(e.getKey(), e.getValue()));
}
@@ -2320,11 +2234,11 @@ public class HBaseFsck extends Configured implements Closeable {
checkRegionConsistencyConcurrently(workItems);
boolean prevHdfsCheck = shouldCheckHdfs();
- setCheckHdfs(false); //replicas don't have any hdfs data
+ setCheckHdfs(false); // replicas don't have any hdfs data
// Run a pass over the replicas and fix any assignment issues that exist on the currently
// deployed/undeployed replicas.
List<CheckRegionConsistencyWorkItem> replicaWorkItems = new ArrayList<>(regionInfoMap.size());
- for (java.util.Map.Entry<String, HbckInfo> e: regionInfoMap.entrySet()) {
+ for (java.util.Map.Entry<String, HbckInfo> e : regionInfoMap.entrySet()) {
if (e.getValue().getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID) {
replicaWorkItems.add(new CheckRegionConsistencyWorkItem(e.getKey(), e.getValue()));
}
@@ -2336,11 +2250,11 @@ public class HBaseFsck extends Configured implements Closeable {
// not get accurate state of the hbase if continuing. The config here allows users to tune
// the tolerance of number of skipped region.
// TODO: evaluate the consequence to continue the hbck operation without config.
- int terminateThreshold = getConf().getInt("hbase.hbck.skipped.regions.limit", 0);
+ int terminateThreshold = getConf().getInt("hbase.hbck.skipped.regions.limit", 0);
int numOfSkippedRegions = skippedRegions.size();
if (numOfSkippedRegions > 0 && numOfSkippedRegions > terminateThreshold) {
- throw new IOException(numOfSkippedRegions
- + " region(s) could not be checked or repaired. See logs for detail.");
+ throw new IOException(
+ numOfSkippedRegions + " region(s) could not be checked or repaired. See logs for detail.");
}
if (shouldCheckHdfs()) {
@@ -2351,25 +2265,25 @@ public class HBaseFsck extends Configured implements Closeable {
/**
* Check consistency of all regions using mulitple threads concurrently.
*/
- private void checkRegionConsistencyConcurrently(
- final List<CheckRegionConsistencyWorkItem> workItems)
- throws IOException, KeeperException, InterruptedException {
+ private void
+ checkRegionConsistencyConcurrently(final List<CheckRegionConsistencyWorkItem> workItems)
+ throws IOException, KeeperException, InterruptedException {
if (workItems.isEmpty()) {
- return; // nothing to check
+ return; // nothing to check
}
List<Future<Void>> workFutures = executor.invokeAll(workItems);
- for(Future<Void> f: workFutures) {
+ for (Future<Void> f : workFutures) {
try {
f.get();
- } catch(ExecutionException e1) {
- LOG.warn("Could not check region consistency " , e1.getCause());
+ } catch (ExecutionException e1) {
+ LOG.warn("Could not check region consistency ", e1.getCause());
if (e1.getCause() instanceof IOException) {
- throw (IOException)e1.getCause();
+ throw (IOException) e1.getCause();
} else if (e1.getCause() instanceof KeeperException) {
- throw (KeeperException)e1.getCause();
+ throw (KeeperException) e1.getCause();
} else if (e1.getCause() instanceof InterruptedException) {
- throw (InterruptedException)e1.getCause();
+ throw (InterruptedException) e1.getCause();
} else {
throw new IOException(e1.getCause());
}
@@ -2393,8 +2307,9 @@ public class HBaseFsck extends Configured implements Closeable {
} catch (Exception e) {
// If the region is non-META region, skip this region and send warning/error message; if
// the region is META region, we should not continue.
- LOG.warn("Unable to complete check or repair the region '" + hbi.getRegionNameAsString()
- + "'.", e);
+ LOG.warn(
+ "Unable to complete check or repair the region '" + hbi.getRegionNameAsString() + "'.",
+ e);
if (hbi.getHdfsHRI().isMetaRegion()) {
throw e;
}
@@ -2415,9 +2330,7 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Check and fix table states, assumes full info available:
- * - tableInfos
- * - empty tables loaded
+ * Check and fix table states, assumes full info available: - tableInfos - empty tables loaded
*/
private void checkAndFixTableStates() throws IOException {
// first check dangling states
@@ -2425,21 +2338,19 @@ public class HBaseFsck extends Configured implements Closeable {
TableName tableName = entry.getKey();
TableState tableState = entry.getValue();
TableInfo tableInfo = tablesInfo.get(tableName);
- if (isTableIncluded(tableName)
- && !tableName.isSystemTable()
- && tableInfo == null) {
+ if (isTableIncluded(tableName) && !tableName.isSystemTable() && tableInfo == null) {
if (fixMeta) {
HBCKMetaTableAccessor.deleteTableState(connection, tableName);
TableState state = HBCKMetaTableAccessor.getTableState(connection, tableName);
if (state != null) {
errors.reportError(ErrorReporter.ERROR_CODE.ORPHAN_TABLE_STATE,
- tableName + " unable to delete dangling table state " + tableState);
+ tableName + " unable to delete dangling table state " + tableState);
}
} else if (!checkMetaOnly) {
// dangling table state in meta if checkMetaOnly is false. If checkMetaOnly is
// true, tableInfo will be null as tablesInfo are not polulated for all tables from hdfs
errors.reportError(ErrorReporter.ERROR_CODE.ORPHAN_TABLE_STATE,
- tableName + " has dangling table state " + tableState);
+ tableName + " has dangling table state " + tableState);
}
}
}
@@ -2451,11 +2362,11 @@ public class HBaseFsck extends Configured implements Closeable {
TableState newState = HBCKMetaTableAccessor.getTableState(connection, tableName);
if (newState == null) {
errors.reportError(ErrorReporter.ERROR_CODE.NO_TABLE_STATE,
- "Unable to change state for table " + tableName + " in meta ");
+ "Unable to change state for table " + tableName + " in meta ");
}
} else {
errors.reportError(ErrorReporter.ERROR_CODE.NO_TABLE_STATE,
- tableName + " has no state in meta ");
+ tableName + " has no state in meta ");
}
}
}
@@ -2476,9 +2387,9 @@ public class HBaseFsck extends Configured implements Closeable {
fs.access(file.getPath(), FsAction.WRITE);
} catch (AccessControlException ace) {
LOG.warn("Got AccessDeniedException when preCheckPermission ", ace);
- errors.reportError(ErrorReporter.ERROR_CODE.WRONG_USAGE, "Current user " +
- ugi.getUserName() + " does not have write perms to " + file.getPath() +
- ". Please rerun hbck as hdfs user " + file.getOwner());
+ errors.reportError(ErrorReporter.ERROR_CODE.WRONG_USAGE,
+ "Current user " + ugi.getUserName() + " does not have write perms to " + file.getPath()
+ + ". Please rerun hbck as hdfs user " + file.getOwner());
throw ace;
}
}
@@ -2510,10 +2421,8 @@ public class HBaseFsck extends Configured implements Closeable {
d.addColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER);
mutations.add(d);
- RegionInfo hri = RegionInfoBuilder.newBuilder(hi.metaEntry)
- .setOffline(false)
- .setSplit(false)
- .build();
+ RegionInfo hri =
+ RegionInfoBuilder.newBuilder(hi.metaEntry).setOffline(false).setSplit(false).build();
Put p = HBCKMetaTableAccessor.makePutFromRegionInfo(hri, System.currentTimeMillis());
mutations.add(p);
@@ -2522,19 +2431,17 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * This backwards-compatibility wrapper for permanently offlining a region
- * that should not be alive. If the region server does not support the
- * "offline" method, it will use the closest unassign method instead. This
- * will basically work until one attempts to disable or delete the affected
- * table. The problem has to do with in-memory only master state, so
- * restarting the HMaster or failing over to another should fix this.
+ * This backwards-compatibility wrapper for permanently offlining a region that should not be
+ * alive. If the region server does not support the "offline" method, it will use the closest
+ * unassign method instead. This will basically work until one attempts to disable or delete the
+ * affected table. The problem has to do with in-memory only master state, so restarting the
+ * HMaster or failing over to another should fix this.
*/
private void offline(byte[] regionName) throws IOException {
String regionString = Bytes.toStringBinary(regionName);
if (!rsSupportsOffline) {
LOG.warn("Using unassign region " + regionString
- + " instead of using offline method, you should"
- + " restart HMaster after these repairs");
+ + " instead of using offline method, you should" + " restart HMaster after these repairs");
admin.unassign(regionName, true);
return;
}
@@ -2544,11 +2451,11 @@ public class HBaseFsck extends Configured implements Closeable {
LOG.info("Offlining region " + regionString);
admin.offline(regionName);
} catch (IOException ioe) {
- String notFoundMsg = "java.lang.NoSuchMethodException: " +
- "org.apache.hadoop.hbase.master.HMaster.offline([B)";
+ String notFoundMsg =
+ "java.lang.NoSuchMethodException: " + "org.apache.hadoop.hbase.master.HMaster.offline([B)";
if (ioe.getMessage().contains(notFoundMsg)) {
- LOG.warn("Using unassign region " + regionString
- + " instead of using offline method, you should"
+ LOG.warn(
+ "Using unassign region " + regionString + " instead of using offline method, you should"
+ " restart HMaster after these repairs");
rsSupportsOffline = false; // in the future just use unassign
admin.unassign(regionName, true);
@@ -2569,13 +2476,13 @@ public class HBaseFsck extends Configured implements Closeable {
if (hi.getPrimaryHRIForDeployedReplica() == null) {
continue;
}
- RegionInfo hri = RegionReplicaUtil.getRegionInfoForReplica(
- hi.getPrimaryHRIForDeployedReplica(), i);
+ RegionInfo hri =
+ RegionReplicaUtil.getRegionInfoForReplica(hi.getPrimaryHRIForDeployedReplica(), i);
HbckInfo h = regionInfoMap.get(hri.getEncodedName());
if (h != null) {
undeployRegionsForHbi(h);
- //set skip checks; we undeployed it, and we don't want to evaluate this anymore
- //in consistency checks
+ // set skip checks; we undeployed it, and we don't want to evaluate this anymore
+ // in consistency checks
h.setSkipChecks(true);
}
}
@@ -2583,28 +2490,25 @@ public class HBaseFsck extends Configured implements Closeable {
private void undeployRegionsForHbi(HbckInfo hi) throws IOException, InterruptedException {
for (OnlineEntry rse : hi.deployedEntries) {
- LOG.debug("Undeploy region " + rse.hri + " from " + rse.hsa);
+ LOG.debug("Undeploy region " + rse.hri + " from " + rse.hsa);
try {
HBaseFsckRepair.closeRegionSilentlyAndWait(connection, rse.hsa, rse.hri);
offline(rse.hri.getRegionName());
} catch (IOException ioe) {
LOG.warn("Got exception when attempting to offline region "
- + Bytes.toString(rse.hri.getRegionName()), ioe);
+ + Bytes.toString(rse.hri.getRegionName()), ioe);
}
}
}
/**
- * Attempts to undeploy a region from a region server based in information in
- * META. Any operations that modify the file system should make sure that
- * its corresponding region is not deployed to prevent data races.
- *
- * A separate call is required to update the master in-memory region state
- * kept in the AssignementManager. Because disable uses this state instead of
- * that found in META, we can't seem to cleanly disable/delete tables that
- * have been hbck fixed. When used on a version of HBase that does not have
- * the offline ipc call exposed on the master (<0.90.5, <0.92.0) a master
- * restart or failover may be required.
+ * Attempts to undeploy a region from a region server based in information in META. Any operations
+ * that modify the file system should make sure that its corresponding region is not deployed to
+ * prevent data races. A separate call is required to update the master in-memory region state
+ * kept in the AssignementManager. Because disable uses this state instead of that found in META,
+ * we can't seem to cleanly disable/delete tables that have been hbck fixed. When used on a
+ * version of HBase that does not have the offline ipc call exposed on the master (<0.90.5,
+ * <0.92.0) a master restart or failover may be required.
*/
private void closeRegion(HbckInfo hi) throws IOException, InterruptedException {
if (hi.metaEntry == null && hi.hdfsEntry == null) {
@@ -2628,25 +2532,22 @@ public class HBaseFsck extends Configured implements Closeable {
Result r = meta.get(get);
RegionLocations rl = HBCKMetaTableAccessor.getRegionLocations(r);
if (rl == null) {
- LOG.warn("Unable to close region " + hi.getRegionNameAsString() +
- " since meta does not have handle to reach it");
+ LOG.warn("Unable to close region " + hi.getRegionNameAsString()
+ + " since meta does not have handle to reach it");
return;
}
for (HRegionLocation h : rl.getRegionLocations()) {
ServerName serverName = h.getServerName();
if (serverName == null) {
- errors.reportError("Unable to close region "
- + hi.getRegionNameAsString() + " because meta does not "
- + "have handle to reach it.");
+ errors.reportError("Unable to close region " + hi.getRegionNameAsString()
+ + " because meta does not " + "have handle to reach it.");
continue;
}
RegionInfo hri = h.getRegion();
if (hri == null) {
LOG.warn("Unable to close region " + hi.getRegionNameAsString()
- + " because hbase:meta had invalid or missing "
- + HConstants.CATALOG_FAMILY_STR + ":"
- + Bytes.toString(HConstants.REGIONINFO_QUALIFIER)
- + " qualifier value.");
+ + " because hbase:meta had invalid or missing " + HConstants.CATALOG_FAMILY_STR + ":"
+ + Bytes.toString(HConstants.REGIONINFO_QUALIFIER) + " qualifier value.");
continue;
}
// close the region -- close files and remove assignment
@@ -2655,17 +2556,17 @@ public class HBaseFsck extends Configured implements Closeable {
}
private void fixHolesAndTryAssignmentRepair(HbckInfo hbi, String msg)
- throws IOException, KeeperException, InterruptedException {
+ throws IOException, KeeperException, InterruptedException {
LOG.info("Patching hbase:meta with with .regioninfo: " + hbi.getHdfsHRI());
int numReplicas = admin.getDescriptor(hbi.getTableName()).getRegionReplication();
HBaseFsckRepair.fixMetaHoleOnlineAndAddReplicas(getConf(), hbi.getHdfsHRI(),
- admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).
- getLiveServerMetrics().keySet(), numReplicas);
+ admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics().keySet(),
+ numReplicas);
tryAssignmentRepair(hbi, msg);
}
- private void tryAssignmentRepair(HbckInfo hbi, String msg) throws IOException,
- KeeperException, InterruptedException {
+ private void tryAssignmentRepair(HbckInfo hbi, String msg)
+ throws IOException, KeeperException, InterruptedException {
// If we are trying to fix the errors
if (shouldFixAssignments()) {
errors.print(msg);
@@ -2688,8 +2589,8 @@ public class HBaseFsck extends Configured implements Closeable {
HbckInfo h = regionInfoMap.get(hri.getEncodedName());
if (h != null) {
undeployRegions(h);
- //set skip checks; we undeploy & deploy it; we don't want to evaluate this hbi anymore
- //in consistency checks
+ // set skip checks; we undeploy & deploy it; we don't want to evaluate this hbi anymore
+ // in consistency checks
h.setSkipChecks(true);
}
HBaseFsckRepair.fixUnassigned(admin, hri);
@@ -2702,7 +2603,7 @@ public class HBaseFsck extends Configured implements Closeable {
* Check a single region for consistency and correct deployment.
*/
private void checkRegionConsistency(final String key, final HbckInfo hbi)
- throws IOException, KeeperException, InterruptedException {
+ throws IOException, KeeperException, InterruptedException {
if (hbi.isSkipChecks()) {
return;
}
@@ -2712,8 +2613,8 @@ public class HBaseFsck extends Configured implements Closeable {
boolean hasMetaAssignment = inMeta && hbi.metaEntry.regionServer != null;
boolean isDeployed = !hbi.deployedOn.isEmpty();
boolean isMultiplyDeployed = hbi.deployedOn.size() > 1;
- boolean deploymentMatchesMeta = hasMetaAssignment && isDeployed && !isMultiplyDeployed &&
- hbi.metaEntry.regionServer.equals(hbi.deployedOn.get(0));
+ boolean deploymentMatchesMeta = hasMetaAssignment && isDeployed && !isMultiplyDeployed
+ && hbi.metaEntry.regionServer.equals(hbi.deployedOn.get(0));
boolean splitParent = inMeta && hbi.metaEntry.isSplit() && hbi.metaEntry.isOffline();
boolean shouldBeDeployed = inMeta && !isTableDisabled(hbi.metaEntry.getTable());
boolean recentlyModified = inHdfs && hbi.getModTime() + timelag > System.currentTimeMillis();
@@ -2731,13 +2632,13 @@ public class HBaseFsck extends Configured implements Closeable {
} else if (recentlyModified) {
LOG.warn(hbi + " was recently modified -- skipping");
return;
- // ========== Cases where the region is not in hbase:meta =============
+ // ========== Cases where the region is not in hbase:meta =============
} else if (!inMeta && !inHdfs && !isDeployed) {
// We shouldn't have record of this region at all then!
assert false : "Entry for region with no data";
} else if (!inMeta && !inHdfs && isDeployed) {
- errors.reportError(ErrorReporter.ERROR_CODE.NOT_IN_META_HDFS, hbi + ", key=" + key +
- ", not on HDFS or hbase:meta but deployed on " + Joiner.on(", ").join(hbi.deployedOn));
+ errors.reportError(ErrorReporter.ERROR_CODE.NOT_IN_META_HDFS, hbi + ", key=" + key
+ + ", not on HDFS or hbase:meta but deployed on " + Joiner.on(", ").join(hbi.deployedOn));
if (shouldFixAssignments()) {
undeployRegions(hbi);
}
@@ -2749,12 +2650,12 @@ public class HBaseFsck extends Configured implements Closeable {
return;
}
errors.reportError(ErrorReporter.ERROR_CODE.NOT_IN_META_OR_DEPLOYED,
- hbi +" on HDFS but not in hbase:meta nor deployed on any region server");
+ hbi + " on HDFS but not in hbase:meta nor deployed on any region server");
// restore region consistency of an adopted orphan
if (shouldFixMeta()) {
if (!hbi.isHdfsRegioninfoPresent()) {
- LOG.error(hbi.getHdfsHRI() + " could have been repaired in table integrity repair " +
- "phase if -fixHdfsOrphans was used.");
+ LOG.error(hbi.getHdfsHRI() + " could have been repaired in table integrity repair "
+ + "phase if -fixHdfsOrphans was used.");
return;
}
if (deletedLeftoverSplitRegion(hbi)) {
@@ -2763,8 +2664,8 @@ public class HBaseFsck extends Configured implements Closeable {
fixHolesAndTryAssignmentRepair(hbi, "Trying to reassign region...");
}
} else if (!inMeta && inHdfs && isDeployed) {
- errors.reportError(ErrorReporter.ERROR_CODE.NOT_IN_META, hbi + " not in META, but " +
- "deployed on " + Joiner.on(", ").join(hbi.deployedOn));
+ errors.reportError(ErrorReporter.ERROR_CODE.NOT_IN_META,
+ hbi + " not in META, but " + "deployed on " + Joiner.on(", ").join(hbi.deployedOn));
debugLsr(hbi.getHdfsRegionDir());
if (hbi.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID) {
// For replicas, this means that we should undeploy the region (we would have gone over the
@@ -2781,22 +2682,22 @@ public class HBaseFsck extends Configured implements Closeable {
}
fixHolesAndTryAssignmentRepair(hbi, "Trying to fix unassigned region...");
}
- // ========== Cases where the region is in hbase:meta =============
+ // ========== Cases where the region is in hbase:meta =============
} else if (inMeta && inHdfs && !isDeployed && splitParent) {
if (skipIfErrorOrTransient(hbi)) {
return;
}
} else if (inMeta && !inHdfs && !isDeployed) {
errors.reportError(ErrorReporter.ERROR_CODE.NOT_IN_HDFS_OR_DEPLOYED,
- hbi + " found in META, but not in HDFS or deployed on any region server.");
+ hbi + " found in META, but not in HDFS or deployed on any region server.");
if (shouldFixMeta()) {
deleteMetaRegion(hbi);
}
} else if (inMeta && !inHdfs && isDeployed) {
- errors.reportError(ErrorReporter.ERROR_CODE.NOT_IN_HDFS, hbi + " found in META, but " +
- "not in HDFS, and deployed on " + Joiner.on(", ").join(hbi.deployedOn));
- // We treat HDFS as ground truth. Any information in meta is transient
- // and equivalent data can be regenerated. So, lets unassign and remove
+ errors.reportError(ErrorReporter.ERROR_CODE.NOT_IN_HDFS, hbi + " found in META, but "
+ + "not in HDFS, and deployed on " + Joiner.on(", ").join(hbi.deployedOn));
+ // We treat HDFS as ground truth. Any information in meta is transient
+ // and equivalent data can be regenerated. So, lets unassign and remove
// these problems from META.
if (shouldFixAssignments()) {
errors.print("Trying to fix unassigned region...");
@@ -2810,55 +2711,54 @@ public class HBaseFsck extends Configured implements Closeable {
errors.reportError(ErrorReporter.ERROR_CODE.NOT_DEPLOYED, hbi + " not deployed.");
tryAssignmentRepair(hbi, "Trying to fix unassigned region...");
} else if (inMeta && inHdfs && isDeployed && !shouldBeDeployed) {
- errors.reportError(ErrorReporter.ERROR_CODE.SHOULD_NOT_BE_DEPLOYED, hbi + " should not be " +
- "deployed according to META, but deployed on " + Joiner.on(", ").join(hbi.deployedOn));
+ errors.reportError(ErrorReporter.ERROR_CODE.SHOULD_NOT_BE_DEPLOYED, hbi + " should not be "
+ + "deployed according to META, but deployed on " + Joiner.on(", ").join(hbi.deployedOn));
if (shouldFixAssignments()) {
setShouldRunAndFixMultiAssignment(connection, hbi, "Trying to close " + hbi);
}
} else if (inMeta && inHdfs && isMultiplyDeployed) {
- errors.reportError(ErrorReporter.ERROR_CODE.MULTI_DEPLOYED, hbi + " listed in hbase:meta " +
- "on " + hbi.metaEntry.regionServer + " but multiply assigned to " +
- Joiner.on(", ").join(hbi.deployedOn));
+ errors.reportError(ErrorReporter.ERROR_CODE.MULTI_DEPLOYED,
+ hbi + " listed in hbase:meta " + "on " + hbi.metaEntry.regionServer
+ + " but multiply assigned to " + Joiner.on(", ").join(hbi.deployedOn));
// If we are trying to fix the errors
if (shouldFixAssignments()) {
setShouldRunAndFixMultiAssignment(connection, hbi, "Trying to fix assignment error...");
}
} else if (inMeta && inHdfs && isDeployed && !deploymentMatchesMeta) {
- errors.reportError(ErrorReporter.ERROR_CODE.SERVER_DOES_NOT_MATCH_META, hbi + " listed in " +
- "hbase:meta on " + hbi.metaEntry.regionServer + " but found on " + hbi.deployedOn.get(0));
+ errors.reportError(ErrorReporter.ERROR_CODE.SERVER_DOES_NOT_MATCH_META, hbi + " listed in "
+ + "hbase:meta on " + hbi.metaEntry.regionServer + " but found on " + hbi.deployedOn.get(0));
// If we are trying to fix the errors
if (shouldFixAssignments()) {
HBaseFsckRepair.waitUntilAssigned(admin, hbi.getHdfsHRI());
errors.print("Trying to fix assignment error...");
}
} else {
- errors.reportError(ErrorReporter.ERROR_CODE.UNKNOWN, hbi + " is in an unforeseen state:" +
- " inMeta=" + inMeta + " inHdfs=" + inHdfs + " isDeployed=" + isDeployed +
- " isMultiplyDeployed=" + isMultiplyDeployed +
- " deploymentMatchesMeta=" + deploymentMatchesMeta +
- " shouldBeDeployed=" + shouldBeDeployed);
+ errors.reportError(ErrorReporter.ERROR_CODE.UNKNOWN,
+ hbi + " is in an unforeseen state:" + " inMeta=" + inMeta + " inHdfs=" + inHdfs
+ + " isDeployed=" + isDeployed + " isMultiplyDeployed=" + isMultiplyDeployed
+ + " deploymentMatchesMeta=" + deploymentMatchesMeta + " shouldBeDeployed="
+ + shouldBeDeployed);
}
}
private void setShouldRunAndFixMultiAssignment(Connection connection, HbckInfo hbi,
- String errorsPrintStr)
- throws InterruptedException, IOException, KeeperException {
+ String errorsPrintStr) throws InterruptedException, IOException, KeeperException {
errors.print(errorsPrintStr);
setShouldRerun();
HBaseFsckRepair.fixMultiAssignment(connection, hbi.metaEntry, hbi.deployedOn);
}
- /**
- * @return Returns true if we deleted a split leftover region.
- */
+ /** Returns Returns true if we deleted a split leftover region. */
private boolean deletedLeftoverSplitRegion(HbckInfo hbi) throws IOException {
RegionInfo hri = hbi.getHdfsHRI();
TableInfo tableInfo = tablesInfo.get(hri.getTable());
for (RegionInfo region : tableInfo.getRegionsFromMeta()) {
- if (Bytes.compareTo(region.getStartKey(), hri.getStartKey()) <= 0
- && (region.getEndKey().length == 0 || Bytes.compareTo(region.getEndKey(),
- hri.getEndKey()) >= 0)
- && Bytes.compareTo(region.getStartKey(), hri.getEndKey()) <= 0) {
+ if (
+ Bytes.compareTo(region.getStartKey(), hri.getStartKey()) <= 0
+ && (region.getEndKey().length == 0
+ || Bytes.compareTo(region.getEndKey(), hri.getEndKey()) >= 0)
+ && Bytes.compareTo(region.getStartKey(), hri.getEndKey()) <= 0
+ ) {
if (region.isSplit() || region.isOffline()) {
continue;
}
@@ -2869,12 +2769,12 @@ public class HBaseFsck extends Configured implements Closeable {
List<Path> referenceFilePaths = FSUtils.getReferenceFilePaths(fs, familyDir);
for (Path referenceFilePath : referenceFilePaths) {
Path parentRegionDir =
- StoreFileInfo.getReferredToFile(referenceFilePath).getParent().getParent();
+ StoreFileInfo.getReferredToFile(referenceFilePath).getParent().getParent();
if (parentRegionDir.toString().endsWith(region.getEncodedName())) {
- LOG.warn(hri + " start and stop keys are in range of " + region + ". Region " +
- "not cleaned from hdfs on " + region + " split fail; deleting from hdfs.");
- HRegionFileSystem.deleteRegionFromFileSystem(getConf(), fs,
- regionDir.getParent(), hri);
+ LOG.warn(hri + " start and stop keys are in range of " + region + ". Region "
+ + "not cleaned from hdfs on " + region + " split fail; deleting from hdfs.");
+ HRegionFileSystem.deleteRegionFromFileSystem(getConf(), fs, regionDir.getParent(),
+ hri);
return true;
}
}
@@ -2884,9 +2784,7 @@ public class HBaseFsck extends Configured implements Closeable {
return false;
}
- /**
- * @return True if we should skip
- */
+ /** Returns True if we should skip */
private boolean skipIfErrorOrTransient(HbckInfo hbi) throws IOException {
// Check whether this is an actual error, or just transient state where parent
// is not cleaned
@@ -2905,13 +2803,13 @@ public class HBaseFsck extends Configured implements Closeable {
// error is going to be reported against primary daughter region.
if (hbi.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID) {
LOG.info("Region " + hbi + " is a split parent in META, in HDFS, "
- + "and not deployed on any region server. This may be transient.");
+ + "and not deployed on any region server. This may be transient.");
hbi.setSkipChecks(true);
return true;
}
- errors.reportError(ErrorReporter.ERROR_CODE.LINGERING_SPLIT_PARENT, "Region "
- + hbi + " is a split parent in META, in HDFS, "
+ errors.reportError(ErrorReporter.ERROR_CODE.LINGERING_SPLIT_PARENT,
+ "Region " + hbi + " is a split parent in META, in HDFS, "
+ "and not deployed on any region server. This could be transient, "
+ "consider to run the catalog janitor first!");
if (shouldFixSplitParents()) {
@@ -2921,9 +2819,7 @@ public class HBaseFsck extends Configured implements Closeable {
return false;
}
- /**
- * @return Returns true if we are to progress with the HbckInfo.
- */
+ /** Returns Returns true if we are to progress with the HbckInfo. */
private boolean checkHbkcInfo(HbckInfo hbi) {
// Check only valid, working regions
if (hbi.metaEntry == null) {
@@ -2950,8 +2846,8 @@ public class HBaseFsck extends Configured implements Closeable {
// Missing regionDir or over-deployment is checked elsewhere. Include
// these cases in modTInfo, so we can evaluate those regions as part of
// the region chain in META
- //if (hbi.foundRegionDir == null) continue;
- //if (hbi.deployedOn.size() != 1) continue;
+ // if (hbi.foundRegionDir == null) continue;
+ // if (hbi.deployedOn.size() != 1) continue;
if (hbi.deployedOn.isEmpty()) {
return false;
}
@@ -2959,9 +2855,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Checks tables integrity. Goes over all regions and scans the tables.
- * Collects all the pieces for each table and checks if there are missing,
- * repeated or overlapping ones.
+ * Checks tables integrity. Goes over all regions and scans the tables. Collects all the pieces
+ * for each table and checks if there are missing, repeated or overlapping ones.
*/
SortedMap<TableName, TableInfo> checkIntegrity() throws IOException {
tablesInfo = new TreeMap<>();
@@ -3000,15 +2895,16 @@ public class HBaseFsck extends Configured implements Closeable {
return tablesInfo;
}
- /** Loads table info's for tables that may not have been included, since there are no
- * regions reported for the table, but table dir is there in hdfs
+ /**
+ * Loads table info's for tables that may not have been included, since there are no regions
+ * reported for the table, but table dir is there in hdfs
*/
private void loadTableInfosForTablesWithNoRegion() throws IOException {
Map<String, TableDescriptor> tables;
FSTableDescriptors tableDescriptors = new FSTableDescriptors(getConf());
if (!tablesIncluded.isEmpty()) {
tables = new HashMap<>();
- for (TableName tableName: getIncludedTables()) {
+ for (TableName tableName : getIncludedTables()) {
tables.put(tableName.getNameWithNamespaceInclAsString(), tableDescriptors.get(tableName));
}
} else {
@@ -3045,11 +2941,11 @@ public class HBaseFsck extends Configured implements Closeable {
try {
dirs = fs.listStatus(contained.getHdfsRegionDir());
} catch (FileNotFoundException fnfe) {
- // region we are attempting to merge in is not present! Since this is a merge, there is
+ // region we are attempting to merge in is not present! Since this is a merge, there is
// no harm skipping this region if it does not exist.
if (!fs.exists(contained.getHdfsRegionDir())) {
LOG.warn("[" + thread + "] HDFS region dir " + contained.getHdfsRegionDir()
- + " is missing. Assuming already sidelined or moved.");
+ + " is missing. Assuming already sidelined or moved.");
} else {
sidelineRegionDir(fs, contained);
}
@@ -3059,7 +2955,7 @@ public class HBaseFsck extends Configured implements Closeable {
if (dirs == null) {
if (!fs.exists(contained.getHdfsRegionDir())) {
LOG.warn("[" + thread + "] HDFS region dir " + contained.getHdfsRegionDir()
- + " already sidelined.");
+ + " already sidelined.");
} else {
sidelineRegionDir(fs, contained);
}
@@ -3068,7 +2964,7 @@ public class HBaseFsck extends Configured implements Closeable {
for (FileStatus cf : dirs) {
Path src = cf.getPath();
- Path dst = new Path(targetRegionDir, src.getName());
+ Path dst = new Path(targetRegionDir, src.getName());
if (src.getName().equals(HRegionFileSystem.REGION_INFO_FILE)) {
// do not copy the old .regioninfo file.
@@ -3083,7 +2979,7 @@ public class HBaseFsck extends Configured implements Closeable {
LOG.info("[" + thread + "] Moving files from " + src + " into containing region " + dst);
// FileSystemFsck.rename is inconsistent with directories -- if the
// dst (foo/a) exists and is a dir, and the src (foo/b) is a dir,
- // it moves the src into the dst dir resulting in (foo/a/b). If
+ // it moves the src into the dst dir resulting in (foo/a/b). If
// the dst does not exist, and the src a dir, src becomes dst. (foo/b)
for (FileStatus hfile : fs.listStatus(src)) {
boolean success = fs.rename(hfile.getPath(), dst);
@@ -3097,14 +2993,13 @@ public class HBaseFsck extends Configured implements Closeable {
// if all success.
sidelineRegionDir(fs, contained);
- LOG.info("[" + thread + "] Sidelined region dir "+ contained.getHdfsRegionDir() + " into " +
- getSidelineDir());
+ LOG.info("[" + thread + "] Sidelined region dir " + contained.getHdfsRegionDir() + " into "
+ + getSidelineDir());
debugLsr(contained.getHdfsRegionDir());
return fileMoves;
}
-
static class WorkItemOverlapMerge implements Callable<Void> {
private TableIntegrityErrorHandler handler;
Collection<HbckInfo> overlapgroup;
@@ -3126,7 +3021,7 @@ public class HBaseFsck extends Configured implements Closeable {
*/
public class TableInfo {
TableName tableName;
- TreeSet <ServerName> deployedOn;
+ TreeSet<ServerName> deployedOn;
// backwards regions
final List<HbckInfo> backwards = new ArrayList<>();
@@ -3135,10 +3030,9 @@ public class HBaseFsck extends Configured implements Closeable {
final Map<Path, HbckInfo> sidelinedRegions = new HashMap<>();
// region split calculator
- final RegionSplitCalculator<HbckInfo> regionSplitCalculator =
- new RegionSplitCalculator<>(cmp);
+ final RegionSplitCalculator<HbckInfo> regionSplitCalculator = new RegionSplitCalculator<>(cmp);
- // Histogram of different TableDescriptors found. Ideally there is only one!
+ // Histogram of different TableDescriptors found. Ideally there is only one!
final Set<TableDescriptor> htds = new HashSet<>();
// key = start split, values = set of splits in problem group
@@ -3150,18 +3044,16 @@ public class HBaseFsck extends Configured implements Closeable {
TableInfo(TableName name) {
this.tableName = name;
- deployedOn = new TreeSet <>();
+ deployedOn = new TreeSet<>();
}
- /**
- * @return descriptor common to all regions. null if are none or multiple!
- */
+ /** Returns descriptor common to all regions. null if are none or multiple! */
private TableDescriptor getHTD() {
if (htds.size() == 1) {
- return (TableDescriptor)htds.toArray()[0];
+ return (TableDescriptor) htds.toArray()[0];
} else {
- LOG.error("None/Multiple table descriptors found for table '"
- + tableName + "' regions: " + htds);
+ LOG.error(
+ "None/Multiple table descriptors found for table '" + tableName + "' regions: " + htds);
}
return null;
}
@@ -3178,12 +3070,11 @@ public class HBaseFsck extends Configured implements Closeable {
// if not the absolute end key, check for cycle
if (Bytes.compareTo(hir.getStartKey(), hir.getEndKey()) > 0) {
- errors.reportError(
- ErrorReporter.ERROR_CODE.REGION_CYCLE,
- String.format("The endkey for this region comes before the "
- + "startkey, startkey=%s, endkey=%s",
- Bytes.toStringBinary(hir.getStartKey()),
- Bytes.toStringBinary(hir.getEndKey())), this, hir);
+ errors.reportError(ErrorReporter.ERROR_CODE.REGION_CYCLE,
+ String.format(
+ "The endkey for this region comes before the " + "startkey, startkey=%s, endkey=%s",
+ Bytes.toStringBinary(hir.getStartKey()), Bytes.toStringBinary(hir.getEndKey())),
+ this, hir);
backwards.add(hir);
return;
}
@@ -3234,24 +3125,26 @@ public class HBaseFsck extends Configured implements Closeable {
}
@Override
- public void handleRegionStartKeyNotEmpty(HbckInfo hi) throws IOException{
- errors.reportError(ErrorReporter.ERROR_CODE.FIRST_REGION_STARTKEY_NOT_EMPTY,
+ public void handleRegionStartKeyNotEmpty(HbckInfo hi) throws IOException {
+ errors
+ .reportError(ErrorReporter.ERROR_CODE.FIRST_REGION_STARTKEY_NOT_EMPTY,
"First region should start with an empty key. You need to "
- + " create a new region and regioninfo in HDFS to plug the hole.",
+ + " create a new region and regioninfo in HDFS to plug the hole.",
getTableInfo(), hi);
}
@Override
public void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException {
errors.reportError(ErrorReporter.ERROR_CODE.LAST_REGION_ENDKEY_NOT_EMPTY,
- "Last region should end with an empty key. You need to "
- + "create a new region and regioninfo in HDFS to plug the hole.", getTableInfo());
+ "Last region should end with an empty key. You need to "
+ + "create a new region and regioninfo in HDFS to plug the hole.",
+ getTableInfo());
}
@Override
- public void handleDegenerateRegion(HbckInfo hi) throws IOException{
+ public void handleDegenerateRegion(HbckInfo hi) throws IOException {
errors.reportError(ErrorReporter.ERROR_CODE.DEGENERATE_REGION,
- "Region has the same start and end key.", getTableInfo(), hi);
+ "Region has the same start and end key.", getTableInfo(), hi);
}
@Override
@@ -3259,11 +3152,11 @@ public class HBaseFsck extends Configured implements Closeable {
byte[] key = r1.getStartKey();
// dup start key
errors.reportError(ErrorReporter.ERROR_CODE.DUPE_STARTKEYS,
- "Multiple regions have the same startkey: "
- + Bytes.toStringBinary(key), getTableInfo(), r1);
+ "Multiple regions have the same startkey: " + Bytes.toStringBinary(key), getTableInfo(),
+ r1);
errors.reportError(ErrorReporter.ERROR_CODE.DUPE_STARTKEYS,
- "Multiple regions have the same startkey: "
- + Bytes.toStringBinary(key), getTableInfo(), r2);
+ "Multiple regions have the same startkey: " + Bytes.toStringBinary(key), getTableInfo(),
+ r2);
}
@Override
@@ -3271,31 +3164,25 @@ public class HBaseFsck extends Configured implements Closeable {
byte[] key = r1.getStartKey();
// dup start key
errors.reportError(ErrorReporter.ERROR_CODE.DUPE_ENDKEYS,
- "Multiple regions have the same regionID: "
- + Bytes.toStringBinary(key), getTableInfo(), r1);
+ "Multiple regions have the same regionID: " + Bytes.toStringBinary(key), getTableInfo(),
+ r1);
errors.reportError(ErrorReporter.ERROR_CODE.DUPE_ENDKEYS,
- "Multiple regions have the same regionID: "
- + Bytes.toStringBinary(key), getTableInfo(), r2);
+ "Multiple regions have the same regionID: " + Bytes.toStringBinary(key), getTableInfo(),
+ r2);
}
@Override
- public void handleOverlapInRegionChain(HbckInfo hi1, HbckInfo hi2)
- throws IOException {
+ public void handleOverlapInRegionChain(HbckInfo hi1, HbckInfo hi2) throws IOException {
errors.reportError(ErrorReporter.ERROR_CODE.OVERLAP_IN_REGION_CHAIN,
- "There is an overlap in the region chain.",
- getTableInfo(), hi1, hi2);
+ "There is an overlap in the region chain.", getTableInfo(), hi1, hi2);
}
@Override
- public void handleHoleInRegionChain(byte[] holeStart, byte[] holeStop)
- throws IOException{
- errors.reportError(
- ErrorReporter.ERROR_CODE.HOLE_IN_REGION_CHAIN,
- "There is a hole in the region chain between "
- + Bytes.toStringBinary(holeStart) + " and "
- + Bytes.toStringBinary(holeStop)
- + ". You need to create a new .regioninfo and region "
- + "dir in hdfs to plug the hole.");
+ public void handleHoleInRegionChain(byte[] holeStart, byte[] holeStop) throws IOException {
+ errors.reportError(ErrorReporter.ERROR_CODE.HOLE_IN_REGION_CHAIN,
+ "There is a hole in the region chain between " + Bytes.toStringBinary(holeStart) + " and "
+ + Bytes.toStringBinary(holeStop) + ". You need to create a new .regioninfo and region "
+ + "dir in hdfs to plug the hole.");
}
/**
@@ -3323,24 +3210,19 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * This handler fixes integrity errors from hdfs information. There are
- * basically three classes of integrity problems 1) holes, 2) overlaps, and
- * 3) invalid regions.
- *
- * This class overrides methods that fix holes and the overlap group case.
- * Individual cases of particular overlaps are handled by the general
- * overlap group merge repair case.
- *
- * If hbase is online, this forces regions offline before doing merge
- * operations.
+ * This handler fixes integrity errors from hdfs information. There are basically three classes
+ * of integrity problems 1) holes, 2) overlaps, and 3) invalid regions. This class overrides
+ * methods that fix holes and the overlap group case. Individual cases of particular overlaps
+ * are handled by the general overlap group merge repair case. If hbase is online, this forces
+ * regions offline before doing merge operations.
*/
private class HDFSIntegrityFixer extends IntegrityFixSuggester {
Configuration conf;
boolean fixOverlaps = true;
- HDFSIntegrityFixer(TableInfo ti, ErrorReporter errors, Configuration conf,
- boolean fixHoles, boolean fixOverlaps) {
+ HDFSIntegrityFixer(TableInfo ti, ErrorReporter errors, Configuration conf, boolean fixHoles,
+ boolean fixOverlaps) {
super(ti, errors);
this.conf = conf;
this.fixOverlaps = fixOverlaps;
@@ -3348,88 +3230,74 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * This is a special case hole -- when the first region of a table is
- * missing from META, HBase doesn't acknowledge the existance of the
- * table.
+ * This is a special case hole -- when the first region of a table is missing from META, HBase
+ * doesn't acknowledge the existance of the table.
*/
@Override
public void handleRegionStartKeyNotEmpty(HbckInfo next) throws IOException {
errors.reportError(ErrorReporter.ERROR_CODE.FIRST_REGION_STARTKEY_NOT_EMPTY,
- "First region should start with an empty key. Creating a new " +
- "region and regioninfo in HDFS to plug the hole.",
- getTableInfo(), next);
+ "First region should start with an empty key. Creating a new "
+ + "region and regioninfo in HDFS to plug the hole.",
+ getTableInfo(), next);
TableDescriptor htd = getTableInfo().getHTD();
// from special EMPTY_START_ROW to next region's startKey
RegionInfo newRegion = RegionInfoBuilder.newBuilder(htd.getTableName())
- .setStartKey(HConstants.EMPTY_START_ROW)
- .setEndKey(next.getStartKey())
- .build();
+ .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(next.getStartKey()).build();
// TODO test
HRegion region = HBaseFsckRepair.createHDFSRegionDir(conf, newRegion, htd);
- LOG.info("Table region start key was not empty. Created new empty region: "
- + newRegion + " " +region);
+ LOG.info("Table region start key was not empty. Created new empty region: " + newRegion
+ + " " + region);
fixes++;
}
@Override
public void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException {
errors.reportError(ErrorReporter.ERROR_CODE.LAST_REGION_ENDKEY_NOT_EMPTY,
- "Last region should end with an empty key. Creating a new "
- + "region and regioninfo in HDFS to plug the hole.", getTableInfo());
+ "Last region should end with an empty key. Creating a new "
+ + "region and regioninfo in HDFS to plug the hole.",
+ getTableInfo());
TableDescriptor htd = getTableInfo().getHTD();
// from curEndKey to EMPTY_START_ROW
RegionInfo newRegion = RegionInfoBuilder.newBuilder(htd.getTableName())
- .setStartKey(curEndKey)
- .setEndKey(HConstants.EMPTY_START_ROW)
- .build();
+ .setStartKey(curEndKey).setEndKey(HConstants.EMPTY_START_ROW).build();
HRegion region = HBaseFsckRepair.createHDFSRegionDir(conf, newRegion, htd);
- LOG.info("Table region end key was not empty. Created new empty region: " + newRegion
- + " " + region);
+ LOG.info("Table region end key was not empty. Created new empty region: " + newRegion + " "
+ + region);
fixes++;
}
/**
- * There is a hole in the hdfs regions that violates the table integrity
- * rules. Create a new empty region that patches the hole.
+ * There is a hole in the hdfs regions that violates the table integrity rules. Create a new
+ * empty region that patches the hole.
*/
@Override
public void handleHoleInRegionChain(byte[] holeStartKey, byte[] holeStopKey)
- throws IOException {
- errors.reportError(
- ErrorReporter.ERROR_CODE.HOLE_IN_REGION_CHAIN,
- "There is a hole in the region chain between "
- + Bytes.toStringBinary(holeStartKey) + " and "
- + Bytes.toStringBinary(holeStopKey)
- + ". Creating a new regioninfo and region "
- + "dir in hdfs to plug the hole.");
+ throws IOException {
+ errors.reportError(ErrorReporter.ERROR_CODE.HOLE_IN_REGION_CHAIN,
+ "There is a hole in the region chain between " + Bytes.toStringBinary(holeStartKey)
+ + " and " + Bytes.toStringBinary(holeStopKey)
+ + ". Creating a new regioninfo and region " + "dir in hdfs to plug the hole.");
TableDescriptor htd = getTableInfo().getHTD();
RegionInfo newRegion = RegionInfoBuilder.newBuilder(htd.getTableName())
- .setStartKey(holeStartKey)
- .setEndKey(holeStopKey)
- .build();
+ .setStartKey(holeStartKey).setEndKey(holeStopKey).build();
HRegion region = HBaseFsckRepair.createHDFSRegionDir(conf, newRegion, htd);
- LOG.info("Plugged hole by creating new empty region: "+ newRegion + " " +region);
+ LOG.info("Plugged hole by creating new empty region: " + newRegion + " " + region);
fixes++;
}
/**
- * This takes set of overlapping regions and merges them into a single
- * region. This covers cases like degenerate regions, shared start key,
- * general overlaps, duplicate ranges, and partial overlapping regions.
- *
- * Cases:
- * - Clean regions that overlap
- * - Only .oldlogs regions (can't find start/stop range, or figure out)
- *
- * This is basically threadsafe, except for the fixer increment in mergeOverlaps.
+ * This takes set of overlapping regions and merges them into a single region. This covers
+ * cases like degenerate regions, shared start key, general overlaps, duplicate ranges, and
+ * partial overlapping regions. Cases: - Clean regions that overlap - Only .oldlogs regions
+ * (can't find start/stop range, or figure out) This is basically threadsafe, except for the
+ * fixer increment in mergeOverlaps.
*/
@Override
- public void handleOverlapGroup(Collection<HbckInfo> overlap)
- throws IOException {
+ public void handleOverlapGroup(Collection<HbckInfo> overlap) throws IOException {
Preconditions.checkNotNull(overlap);
- Preconditions.checkArgument(overlap.size() >0);
+ Preconditions.checkArgument(overlap.size() > 0);
if (!this.fixOverlaps) {
LOG.warn("Not attempting to repair overlaps.");
@@ -3437,8 +3305,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
if (overlap.size() > maxMerge) {
- LOG.warn("Overlap group has " + overlap.size() + " overlapping " +
- "regions which is greater than " + maxMerge + ", the max number of regions to merge");
+ LOG.warn("Overlap group has " + overlap.size() + " overlapping "
+ + "regions which is greater than " + maxMerge + ", the max number of regions to merge");
if (sidelineBigOverlaps) {
// we only sideline big overlapped groups that exceeds the max number of regions
// to merge
@@ -3472,12 +3340,14 @@ public class HBaseFsck extends Configured implements Closeable {
if (range == null) {
range = new Pair<>(hi.getStartKey(), hi.getEndKey());
} else {
- if (RegionSplitCalculator.BYTES_COMPARATOR
- .compare(hi.getStartKey(), range.getFirst()) < 0) {
+ if (
+ RegionSplitCalculator.BYTES_COMPARATOR.compare(hi.getStartKey(), range.getFirst()) < 0
+ ) {
range.setFirst(hi.getStartKey());
}
- if (RegionSplitCalculator.BYTES_COMPARATOR
- .compare(hi.getEndKey(), range.getSecond()) > 0) {
+ if (
+ RegionSplitCalculator.BYTES_COMPARATOR.compare(hi.getEndKey(), range.getSecond()) > 0
+ ) {
range.setSecond(hi.getEndKey());
}
}
@@ -3488,8 +3358,10 @@ public class HBaseFsck extends Configured implements Closeable {
// attempt to find a possible parent for the edge case of a split
for (HbckInfo hi : overlap) {
- if (Bytes.compareTo(hi.getHdfsHRI().getStartKey(), range.getFirst()) == 0
- && Bytes.compareTo(hi.getHdfsHRI().getEndKey(), range.getSecond()) == 0) {
+ if (
+ Bytes.compareTo(hi.getHdfsHRI().getStartKey(), range.getFirst()) == 0
+ && Bytes.compareTo(hi.getHdfsHRI().getEndKey(), range.getSecond()) == 0
+ ) {
LOG.info("This is a parent for this group: " + hi.toString());
parent = hi;
}
@@ -3516,8 +3388,10 @@ public class HBaseFsck extends Configured implements Closeable {
}
// daughters must share the same regionID and we should have a parent too
- if (daughterA.getHdfsHRI().getRegionId() != daughterB.getHdfsHRI().getRegionId() ||
- parent == null) {
+ if (
+ daughterA.getHdfsHRI().getRegionId() != daughterB.getHdfsHRI().getRegionId()
+ || parent == null
+ ) {
return;
}
@@ -3549,8 +3423,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
sidelineRegionDir(rootFs, parent);
- LOG.info("[" + thread + "] Sidelined parent region dir "+ parent.getHdfsRegionDir() +
- " into " + getSidelineDir());
+ LOG.info("[" + thread + "] Sidelined parent region dir " + parent.getHdfsRegionDir()
+ + " into " + getSidelineDir());
debugLsr(parent.getHdfsRegionDir());
// Make sure we don't have the parents and daughters around
@@ -3562,36 +3436,37 @@ public class HBaseFsck extends Configured implements Closeable {
}
- void mergeOverlaps(Collection<HbckInfo> overlap)
- throws IOException {
+ void mergeOverlaps(Collection<HbckInfo> overlap) throws IOException {
String thread = Thread.currentThread().getName();
- LOG.info("== [" + thread + "] Merging regions into one region: "
- + Joiner.on(",").join(overlap));
+ LOG.info(
+ "== [" + thread + "] Merging regions into one region: " + Joiner.on(",").join(overlap));
// get the min / max range and close all concerned regions
Pair<byte[], byte[]> range = null;
for (HbckInfo hi : overlap) {
if (range == null) {
range = new Pair<>(hi.getStartKey(), hi.getEndKey());
} else {
- if (RegionSplitCalculator.BYTES_COMPARATOR
- .compare(hi.getStartKey(), range.getFirst()) < 0) {
+ if (
+ RegionSplitCalculator.BYTES_COMPARATOR.compare(hi.getStartKey(), range.getFirst()) < 0
+ ) {
range.setFirst(hi.getStartKey());
}
- if (RegionSplitCalculator.BYTES_COMPARATOR
- .compare(hi.getEndKey(), range.getSecond()) > 0) {
+ if (
+ RegionSplitCalculator.BYTES_COMPARATOR.compare(hi.getEndKey(), range.getSecond()) > 0
+ ) {
range.setSecond(hi.getEndKey());
}
}
// need to close files so delete can happen.
- LOG.debug("[" + thread + "] Closing region before moving data around: " + hi);
+ LOG.debug("[" + thread + "] Closing region before moving data around: " + hi);
LOG.debug("[" + thread + "] Contained region dir before close");
debugLsr(hi.getHdfsRegionDir());
try {
LOG.info("[" + thread + "] Closing region: " + hi);
closeRegion(hi);
} catch (IOException | InterruptedException e) {
- LOG.warn("[" + thread + "] Was unable to close region " + hi
- + ". Just continuing... ", e);
+ LOG.warn("[" + thread + "] Was unable to close region " + hi + ". Just continuing... ",
+ e);
}
try {
@@ -3607,19 +3482,17 @@ public class HBaseFsck extends Configured implements Closeable {
TableDescriptor htd = getTableInfo().getHTD();
// from start key to end Key
RegionInfo newRegion = RegionInfoBuilder.newBuilder(htd.getTableName())
- .setStartKey(range.getFirst())
- .setEndKey(range.getSecond())
- .build();
+ .setStartKey(range.getFirst()).setEndKey(range.getSecond()).build();
HRegion region = HBaseFsckRepair.createHDFSRegionDir(conf, newRegion, htd);
- LOG.info("[" + thread + "] Created new empty container region: " +
- newRegion + " to contain regions: " + Joiner.on(",").join(overlap));
+ LOG.info("[" + thread + "] Created new empty container region: " + newRegion
+ + " to contain regions: " + Joiner.on(",").join(overlap));
debugLsr(region.getRegionFileSystem().getRegionDir());
// all target regions are closed, should be able to safely cleanup.
- boolean didFix= false;
+ boolean didFix = false;
Path target = region.getRegionFileSystem().getRegionDir();
for (HbckInfo contained : overlap) {
- LOG.info("[" + thread + "] Merging " + contained + " into " + target);
+ LOG.info("[" + thread + "] Merging " + contained + " into " + target);
int merges = mergeRegionDirs(target, contained);
if (merges > 0) {
didFix = true;
@@ -3631,26 +3504,24 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Sideline some regions in a big overlap group so that it
- * will have fewer regions, and it is easier to merge them later on.
- *
+ * Sideline some regions in a big overlap group so that it will have fewer regions, and it is
+ * easier to merge them later on.
* @param bigOverlap the overlapped group with regions more than maxMerge
*/
- void sidelineBigOverlaps(
- Collection<HbckInfo> bigOverlap) throws IOException {
+ void sidelineBigOverlaps(Collection<HbckInfo> bigOverlap) throws IOException {
int overlapsToSideline = bigOverlap.size() - maxMerge;
if (overlapsToSideline > maxOverlapsToSideline) {
overlapsToSideline = maxOverlapsToSideline;
}
List<HbckInfo> regionsToSideline =
RegionSplitCalculator.findBigRanges(bigOverlap, overlapsToSideline);
- for (HbckInfo regionToSideline: regionsToSideline) {
+ for (HbckInfo regionToSideline : regionsToSideline) {
try {
LOG.info("Closing region: " + regionToSideline);
closeRegion(regionToSideline);
} catch (IOException | InterruptedException e) {
- LOG.warn("Was unable to close region " + regionToSideline
- + ". Just continuing... ", e);
+ LOG.warn("Was unable to close region " + regionToSideline + ". Just continuing... ",
+ e);
}
try {
@@ -3666,8 +3537,7 @@ public class HBaseFsck extends Configured implements Closeable {
if (sidelineRegionDir != null) {
sidelinedRegions.put(sidelineRegionDir, regionToSideline);
LOG.info("After sidelined big overlapped region: "
- + regionToSideline.getRegionNameAsString()
- + " to " + sidelineRegionDir.toString());
+ + regionToSideline.getRegionNameAsString() + " to " + sidelineRegionDir.toString());
fixes++;
}
}
@@ -3675,8 +3545,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Check the region chain (from META) of this table. We are looking for
- * holes, overlaps, and cycles.
+ * Check the region chain (from META) of this table. We are looking for holes, overlaps, and
+ * cycles.
* @return false if there are errors
*/
public boolean checkRegionChain(TableIntegrityErrorHandler handler) throws IOException {
@@ -3711,7 +3581,7 @@ public class HBaseFsck extends Configured implements Closeable {
// special endkey case converts '' to null
byte[] endKey = rng.getEndKey();
endKey = (endKey.length == 0) ? null : endKey;
- if (Bytes.equals(rng.getStartKey(),endKey)) {
+ if (Bytes.equals(rng.getStartKey(), endKey)) {
handler.handleDegenerateRegion(rng);
}
}
@@ -3734,7 +3604,7 @@ public class HBaseFsck extends Configured implements Closeable {
// record errors
ArrayList<HbckInfo> subRange = new ArrayList<>(ranges);
- // this dumb and n^2 but this shouldn't happen often
+ // this dumb and n^2 but this shouldn't happen often
for (HbckInfo r1 : ranges) {
if (r1.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID) {
continue;
@@ -3745,10 +3615,12 @@ public class HBaseFsck extends Configured implements Closeable {
continue;
}
// general case of same start key
- if (Bytes.compareTo(r1.getStartKey(), r2.getStartKey())==0) {
- handler.handleDuplicateStartKeys(r1,r2);
- } else if (Bytes.compareTo(r1.getEndKey(), r2.getStartKey())==0 &&
- r1.getHdfsHRI().getRegionId() == r2.getHdfsHRI().getRegionId()) {
+ if (Bytes.compareTo(r1.getStartKey(), r2.getStartKey()) == 0) {
+ handler.handleDuplicateStartKeys(r1, r2);
+ } else if (
+ Bytes.compareTo(r1.getEndKey(), r2.getStartKey()) == 0
+ && r1.getHdfsHRI().getRegionId() == r2.getHdfsHRI().getRegionId()
+ ) {
LOG.info("this is a split, log to splits");
handler.handleSplit(r1, r2);
} else {
@@ -3794,28 +3666,24 @@ public class HBaseFsck extends Configured implements Closeable {
if (details) {
// do full region split map dump
- errors.print("---- Table '" + this.tableName
- + "': region split map");
+ errors.print("---- Table '" + this.tableName + "': region split map");
dump(splits, regions);
- errors.print("---- Table '" + this.tableName
- + "': overlap groups");
+ errors.print("---- Table '" + this.tableName + "': overlap groups");
dumpOverlapProblems(overlapGroups);
- errors.print("There are " + overlapGroups.keySet().size()
- + " overlap groups with " + overlapGroups.size()
- + " overlapping regions");
+ errors.print("There are " + overlapGroups.keySet().size() + " overlap groups with "
+ + overlapGroups.size() + " overlapping regions");
}
if (!sidelinedRegions.isEmpty()) {
LOG.warn("Sidelined big overlapped regions, please bulk load them!");
- errors.print("---- Table '" + this.tableName
- + "': sidelined big overlapped regions");
+ errors.print("---- Table '" + this.tableName + "': sidelined big overlapped regions");
dumpSidelinedRegions(sidelinedRegions);
}
return errors.getErrorList().size() == originalErrorsCount;
}
private boolean handleOverlapsParallel(TableIntegrityErrorHandler handler, byte[] prevKey)
- throws IOException {
- // we parallelize overlap handler for the case we have lots of groups to fix. We can
+ throws IOException {
+ // we parallelize overlap handler for the case we have lots of groups to fix. We can
// safely assume each group is independent.
List<WorkItemOverlapMerge> merges = new ArrayList<>(overlapGroups.size());
List<Future<Void>> rets;
@@ -3829,12 +3697,12 @@ public class HBaseFsck extends Configured implements Closeable {
LOG.error("Overlap merges were interrupted", e);
return false;
}
- for(int i=0; i<merges.size(); i++) {
+ for (int i = 0; i < merges.size(); i++) {
WorkItemOverlapMerge work = merges.get(i);
Future<Void> f = rets.get(i);
try {
f.get();
- } catch(ExecutionException e) {
+ } catch (ExecutionException e) {
LOG.warn("Failed to merge overlap group" + work, e.getCause());
} catch (InterruptedException e) {
LOG.error("Waiting for overlap merges was interrupted", e);
@@ -3854,8 +3722,7 @@ public class HBaseFsck extends Configured implements Closeable {
sb.setLength(0); // clear out existing buffer, if any.
sb.append(Bytes.toStringBinary(k) + ":\t");
for (HbckInfo r : regions.get(k)) {
- sb.append("[ "+ r.toString() + ", "
- + Bytes.toStringBinary(r.getEndKey())+ "]\t");
+ sb.append("[ " + r.toString() + ", " + Bytes.toStringBinary(r.getEndKey()) + "]\t");
}
errors.print(sb.toString());
}
@@ -3868,8 +3735,7 @@ public class HBaseFsck extends Configured implements Closeable {
for (byte[] k : regions.keySet()) {
errors.print(Bytes.toStringBinary(k) + ":");
for (HbckInfo r : regions.get(k)) {
- errors.print("[ " + r.toString() + ", "
- + Bytes.toStringBinary(r.getEndKey()) + "]");
+ errors.print("[ " + r.toString() + ", " + Bytes.toStringBinary(r.getEndKey()) + "]");
}
errors.print("----");
}
@@ -3881,23 +3747,21 @@ public class HBaseFsck extends Configured implements Closeable {
Path path = entry.getKey();
errors.print("This sidelined region dir should be bulk loaded: " + path.toString());
// From BulkLoadHFilesTool...
- // public static final String NAME = "completebulkload";
- errors.print("Bulk load command looks like: " + "completebulkload" + " " +
- path.toUri().getPath() + " " + tableName);
+ // public static final String NAME = "completebulkload";
+ errors.print("Bulk load command looks like: " + "completebulkload" + " "
+ + path.toUri().getPath() + " " + tableName);
}
}
- public Multimap<byte[], HbckInfo> getOverlapGroups(
- TableName table) {
+ public Multimap<byte[], HbckInfo> getOverlapGroups(TableName table) {
TableInfo ti = tablesInfo.get(table);
return ti.overlapGroups;
}
/**
- * Return a list of user-space table names whose metadata have not been
- * modified in the last few milliseconds specified by timelag
- * if any of the REGIONINFO_QUALIFIER, SERVER_QUALIFIER, STARTCODE_QUALIFIER,
- * SPLITA_QUALIFIER, SPLITB_QUALIFIER have not changed in the last
+ * Return a list of user-space table names whose metadata have not been modified in the last few
+ * milliseconds specified by timelag if any of the REGIONINFO_QUALIFIER, SERVER_QUALIFIER,
+ * STARTCODE_QUALIFIER, SPLITA_QUALIFIER, SPLITB_QUALIFIER have not changed in the last
* milliseconds specified by timelag, then the table is a candidate to be returned.
* @return tables that have not been modified recently
*/
@@ -3924,7 +3788,7 @@ public class HBaseFsck extends Configured implements Closeable {
TableDescriptor[] getTableDescriptors(List<TableName> tableNames) {
LOG.info("getTableDescriptors == tableNames => " + tableNames);
try (Connection conn = ConnectionFactory.createConnection(getConf());
- Admin admin = conn.getAdmin()) {
+ Admin admin = conn.getAdmin()) {
List<TableDescriptor> tds = admin.listTableDescriptors(tableNames);
return tds.toArray(new TableDescriptor[tds.size()]);
} catch (IOException e) {
@@ -3934,9 +3798,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Gets the entry in regionInfo corresponding to the the given encoded
- * region name. If the region has not been seen yet, a new entry is added
- * and returned.
+ * Gets the entry in regionInfo corresponding to the the given encoded region name. If the region
+ * has not been seen yet, a new entry is added and returned.
*/
private synchronized HbckInfo getOrCreateInfo(String name) {
HbckInfo hbi = regionInfoMap.get(name);
@@ -3958,12 +3821,11 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Check values in regionInfo for hbase:meta
- * Check if zero or more than one regions with hbase:meta are found.
- * If there are inconsistencies (i.e. zero or more than one regions
- * pretend to be holding the hbase:meta) try to fix that and report an error.
- * @throws IOException from HBaseFsckRepair functions
- */
+ * Check values in regionInfo for hbase:meta Check if zero or more than one regions with
+ * hbase:meta are found. If there are inconsistencies (i.e. zero or more than one regions pretend
+ * to be holding the hbase:meta) try to fix that and report an error.
+ * @throws IOException from HBaseFsckRepair functions
+ */
boolean checkMetaRegion() throws IOException, KeeperException, InterruptedException {
Map<Integer, HbckInfo> metaRegions = new HashMap<>();
for (HbckInfo value : regionInfoMap.values()) {
@@ -3971,8 +3833,7 @@ public class HBaseFsck extends Configured implements Closeable {
metaRegions.put(value.getReplicaId(), value);
}
}
- int metaReplication = admin.getDescriptor(TableName.META_TABLE_NAME)
- .getRegionReplication();
+ int metaReplication = admin.getDescriptor(TableName.META_TABLE_NAME).getRegionReplication();
boolean noProblem = true;
// There will be always entries in regionInfoMap corresponding to hbase:meta & its replicas
// Check the deployed servers. It should be exactly one server for each replica.
@@ -3987,12 +3848,11 @@ public class HBaseFsck extends Configured implements Closeable {
if (servers.isEmpty()) {
assignMetaReplica(i);
} else if (servers.size() > 1) {
- errors.reportError(ErrorReporter.ERROR_CODE.MULTI_META_REGION,
- "hbase:meta, replicaId " + metaHbckInfo.getReplicaId() +
- " is found on more than one region.");
+ errors.reportError(ErrorReporter.ERROR_CODE.MULTI_META_REGION, "hbase:meta, replicaId "
+ + metaHbckInfo.getReplicaId() + " is found on more than one region.");
if (shouldFixAssignments()) {
- errors.print("Trying to fix a problem with hbase:meta, replicaId " +
- metaHbckInfo.getReplicaId() +"..");
+ errors.print("Trying to fix a problem with hbase:meta, replicaId "
+ + metaHbckInfo.getReplicaId() + "..");
setShouldRerun();
// try fix it (treat is a dupe assignment)
HBaseFsckRepair.fixMultiAssignment(connection, metaHbckInfo.metaEntry, servers);
@@ -4004,11 +3864,11 @@ public class HBaseFsck extends Configured implements Closeable {
for (Map.Entry<Integer, HbckInfo> entry : metaRegions.entrySet()) {
noProblem = false;
errors.reportError(ErrorReporter.ERROR_CODE.SHOULD_NOT_BE_DEPLOYED,
- "hbase:meta replicas are deployed in excess. Configured " + metaReplication +
- ", deployed " + metaRegions.size());
+ "hbase:meta replicas are deployed in excess. Configured " + metaReplication + ", deployed "
+ + metaRegions.size());
if (shouldFixAssignments()) {
- errors.print("Trying to undeploy excess replica, replicaId: " + entry.getKey() +
- " of hbase:meta..");
+ errors.print(
+ "Trying to undeploy excess replica, replicaId: " + entry.getKey() + " of hbase:meta..");
setShouldRerun();
unassignMetaReplica(entry.getValue());
}
@@ -4019,21 +3879,21 @@ public class HBaseFsck extends Configured implements Closeable {
}
private void unassignMetaReplica(HbckInfo hi)
- throws IOException, InterruptedException, KeeperException {
+ throws IOException, InterruptedException, KeeperException {
undeployRegions(hi);
ZKUtil.deleteNode(zkw, zkw.getZNodePaths().getZNodeForReplica(hi.metaEntry.getReplicaId()));
}
private void assignMetaReplica(int replicaId)
- throws IOException, KeeperException, InterruptedException {
- errors.reportError(ErrorReporter.ERROR_CODE.NO_META_REGION, "hbase:meta, replicaId " +
- replicaId +" is not found on any region.");
+ throws IOException, KeeperException, InterruptedException {
+ errors.reportError(ErrorReporter.ERROR_CODE.NO_META_REGION,
+ "hbase:meta, replicaId " + replicaId + " is not found on any region.");
if (shouldFixAssignments()) {
errors.print("Trying to fix a problem with hbase:meta..");
setShouldRerun();
// try to fix it (treat it as unassigned region)
- RegionInfo h = RegionReplicaUtil.getRegionInfoForReplica(
- RegionInfoBuilder.FIRST_META_REGIONINFO, replicaId);
+ RegionInfo h = RegionReplicaUtil
+ .getRegionInfoForReplica(RegionInfoBuilder.FIRST_META_REGIONINFO, replicaId);
HBaseFsckRepair.fixUnassigned(admin, h);
HBaseFsckRepair.waitUntilAssigned(admin, h);
}
@@ -4054,11 +3914,12 @@ public class HBaseFsck extends Configured implements Closeable {
return Long.compare(k1.getTimestamp(), k2.getTimestamp());
}
};
+
@Override
public RegionInfo apply(Result result) {
try {
// record the latest modification of this META record
- long ts = Collections.max(result.listCells(), comp).getTimestamp();
+ long ts = Collections.max(result.listCells(), comp).getTimestamp();
RegionLocations rl = HBCKMetaTableAccessor.getRegionLocations(result);
if (rl == null) {
emptyRegionInfoQualifiers.add(result);
@@ -4067,16 +3928,17 @@ public class HBaseFsck extends Configured implements Closeable {
return null;
}
ServerName sn = null;
- if (rl.getRegionLocation(RegionInfo.DEFAULT_REPLICA_ID) == null ||
- rl.getRegionLocation(RegionInfo.DEFAULT_REPLICA_ID).getRegion() == null) {
+ if (
+ rl.getRegionLocation(RegionInfo.DEFAULT_REPLICA_ID) == null
+ || rl.getRegionLocation(RegionInfo.DEFAULT_REPLICA_ID).getRegion() == null
+ ) {
emptyRegionInfoQualifiers.add(result);
errors.reportError(ErrorReporter.ERROR_CODE.EMPTY_META_CELL,
"Empty REGIONINFO_QUALIFIER found in hbase:meta");
return null;
}
RegionInfo hri = rl.getRegionLocation(RegionInfo.DEFAULT_REPLICA_ID).getRegion();
- if (!(isTableIncluded(hri.getTable())
- || hri.isMetaRegion())) {
+ if (!(isTableIncluded(hri.getTable()) || hri.isMetaRegion())) {
return hri;
}
PairOfSameType<RegionInfo> daughters = HBCKMetaTableAccessor.getDaughterRegions(result);
@@ -4129,9 +3991,8 @@ public class HBaseFsck extends Configured implements Closeable {
// Scan hbase:meta to pick up user regions
final HBCKMetaTableAccessor.MetaScanner<RegionInfo> scanner =
new HBCKMetaTableAccessor.MetaScanner<>();
- result = scanner.scanMeta(connection,
- scan -> {},
- visitor);
+ result = scanner.scanMeta(connection, scan -> {
+ }, visitor);
}
return !result.isEmpty();
@@ -4141,16 +4002,16 @@ public class HBaseFsck extends Configured implements Closeable {
* Stores the regioninfo entries scanned from META
*/
static class MetaEntry extends HRegionInfo {
- ServerName regionServer; // server hosting this region
- long modTime; // timestamp of most recent modification metadata
- RegionInfo splitA, splitB; //split daughters
+ ServerName regionServer; // server hosting this region
+ long modTime; // timestamp of most recent modification metadata
+ RegionInfo splitA, splitB; // split daughters
public MetaEntry(RegionInfo rinfo, ServerName regionServer, long modTime) {
this(rinfo, regionServer, modTime, null, null);
}
- public MetaEntry(RegionInfo rinfo, ServerName regionServer, long modTime,
- RegionInfo splitA, RegionInfo splitB) {
+ public MetaEntry(RegionInfo rinfo, ServerName regionServer, long modTime, RegionInfo splitA,
+ RegionInfo splitB) {
super(rinfo);
this.regionServer = regionServer;
this.modTime = modTime;
@@ -4194,7 +4055,7 @@ public class HBaseFsck extends Configured implements Closeable {
static class HdfsEntry {
RegionInfo hri;
Path hdfsRegionDir = null;
- long hdfsRegionDirModTime = 0;
+ long hdfsRegionDirModTime = 0;
boolean hdfsRegioninfoFilePresent = false;
boolean hdfsOnlyEdits = false;
}
@@ -4213,8 +4074,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Maintain information about a particular region. It gathers information
- * from three places -- HDFS, META, and region servers.
+ * Maintain information about a particular region. It gathers information from three places --
+ * HDFS, META, and region servers.
*/
public static class HbckInfo implements KeyRange {
private MetaEntry metaEntry = null; // info in META
@@ -4231,26 +4092,25 @@ public class HBaseFsck extends Configured implements Closeable {
}
public synchronized int getReplicaId() {
- return metaEntry != null? metaEntry.getReplicaId(): deployedReplicaId;
+ return metaEntry != null ? metaEntry.getReplicaId() : deployedReplicaId;
}
public synchronized void addServer(RegionInfo hri, ServerName server) {
- OnlineEntry rse = new OnlineEntry() ;
+ OnlineEntry rse = new OnlineEntry();
rse.hri = hri;
rse.hsa = server;
this.deployedEntries.add(rse);
this.deployedOn.add(server);
// save the replicaId that we see deployed in the cluster
this.deployedReplicaId = hri.getReplicaId();
- this.primaryHRIForDeployedReplica =
- RegionReplicaUtil.getRegionInfoForDefaultReplica(hri);
+ this.primaryHRIForDeployedReplica = RegionReplicaUtil.getRegionInfoForDefaultReplica(hri);
}
@Override
public synchronized String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{ meta => ");
- sb.append((metaEntry != null)? metaEntry.getRegionNameAsString() : "null");
+ sb.append((metaEntry != null) ? metaEntry.getRegionNameAsString() : "null");
sb.append(", hdfs => " + getHdfsRegionDir());
sb.append(", deployed => " + Joiner.on(", ").join(deployedEntries));
sb.append(", replicaId => " + getReplicaId());
@@ -4398,8 +4258,8 @@ public class HBaseFsck extends Configured implements Closeable {
return tableCompare;
}
- int startComparison = RegionSplitCalculator.BYTES_COMPARATOR.compare(
- l.getStartKey(), r.getStartKey());
+ int startComparison =
+ RegionSplitCalculator.BYTES_COMPARATOR.compare(l.getStartKey(), r.getStartKey());
if (startComparison != 0) {
return startComparison;
}
@@ -4409,8 +4269,7 @@ public class HBaseFsck extends Configured implements Closeable {
endKey = (endKey.length == 0) ? null : endKey;
byte[] endKey2 = l.getEndKey();
endKey2 = (endKey2.length == 0) ? null : endKey2;
- int endComparison = RegionSplitCalculator.BYTES_COMPARATOR.compare(
- endKey2, endKey);
+ int endComparison = RegionSplitCalculator.BYTES_COMPARATOR.compare(endKey2, endKey);
if (endComparison != 0) {
return endComparison;
@@ -4441,16 +4300,16 @@ public class HBaseFsck extends Configured implements Closeable {
int numOfSkippedRegions;
errors.print("Summary:");
for (TableInfo tInfo : tablesInfo.values()) {
- numOfSkippedRegions = (skippedRegions.containsKey(tInfo.getName())) ?
- skippedRegions.get(tInfo.getName()).size() : 0;
+ numOfSkippedRegions = (skippedRegions.containsKey(tInfo.getName()))
+ ? skippedRegions.get(tInfo.getName()).size()
+ : 0;
if (errors.tableHasErrors(tInfo)) {
errors.print("Table " + tInfo.getName() + " is inconsistent.");
- } else if (numOfSkippedRegions > 0){
- errors.print("Table " + tInfo.getName() + " is okay (with "
- + numOfSkippedRegions + " skipped regions).");
- }
- else {
+ } else if (numOfSkippedRegions > 0) {
+ errors.print("Table " + tInfo.getName() + " is okay (with " + numOfSkippedRegions
+ + " skipped regions).");
+ } else {
errors.print("Table " + tInfo.getName() + " is okay.");
}
errors.print(" Number of regions: " + tInfo.getNumRegions());
@@ -4458,7 +4317,7 @@ public class HBaseFsck extends Configured implements Closeable {
Set<String> skippedRegionStrings = skippedRegions.get(tInfo.getName());
System.out.println(" Number of skipped regions: " + numOfSkippedRegions);
System.out.println(" List of skipped regions:");
- for(String sr : skippedRegionStrings) {
+ for (String sr : skippedRegionStrings) {
System.out.println(" " + sr);
}
}
@@ -4471,45 +4330,81 @@ public class HBaseFsck extends Configured implements Closeable {
}
}
- static ErrorReporter getErrorReporter(
- final Configuration conf) throws ClassNotFoundException {
- Class<? extends ErrorReporter> reporter = conf.getClass("hbasefsck.errorreporter",
- PrintingErrorReporter.class, ErrorReporter.class);
+ static ErrorReporter getErrorReporter(final Configuration conf) throws ClassNotFoundException {
+ Class<? extends ErrorReporter> reporter =
+ conf.getClass("hbasefsck.errorreporter", PrintingErrorReporter.class, ErrorReporter.class);
return ReflectionUtils.newInstance(reporter, conf);
}
public interface ErrorReporter {
enum ERROR_CODE {
- UNKNOWN, NO_META_REGION, NULL_META_REGION, NO_VERSION_FILE, NOT_IN_META_HDFS, NOT_IN_META,
- NOT_IN_META_OR_DEPLOYED, NOT_IN_HDFS_OR_DEPLOYED, NOT_IN_HDFS, SERVER_DOES_NOT_MATCH_META,
- NOT_DEPLOYED, MULTI_DEPLOYED, SHOULD_NOT_BE_DEPLOYED, MULTI_META_REGION, RS_CONNECT_FAILURE,
- FIRST_REGION_STARTKEY_NOT_EMPTY, LAST_REGION_ENDKEY_NOT_EMPTY, DUPE_STARTKEYS,
- HOLE_IN_REGION_CHAIN, OVERLAP_IN_REGION_CHAIN, REGION_CYCLE, DEGENERATE_REGION,
- ORPHAN_HDFS_REGION, LINGERING_SPLIT_PARENT, NO_TABLEINFO_FILE, LINGERING_REFERENCE_HFILE,
- LINGERING_HFILELINK, WRONG_USAGE, EMPTY_META_CELL, EXPIRED_TABLE_LOCK, BOUNDARIES_ERROR,
- ORPHAN_TABLE_STATE, NO_TABLE_STATE, UNDELETED_REPLICATION_QUEUE, DUPE_ENDKEYS,
- UNSUPPORTED_OPTION, INVALID_TABLE
+ UNKNOWN,
+ NO_META_REGION,
+ NULL_META_REGION,
+ NO_VERSION_FILE,
+ NOT_IN_META_HDFS,
+ NOT_IN_META,
+ NOT_IN_META_OR_DEPLOYED,
+ NOT_IN_HDFS_OR_DEPLOYED,
+ NOT_IN_HDFS,
+ SERVER_DOES_NOT_MATCH_META,
+ NOT_DEPLOYED,
+ MULTI_DEPLOYED,
+ SHOULD_NOT_BE_DEPLOYED,
+ MULTI_META_REGION,
+ RS_CONNECT_FAILURE,
+ FIRST_REGION_STARTKEY_NOT_EMPTY,
+ LAST_REGION_ENDKEY_NOT_EMPTY,
+ DUPE_STARTKEYS,
+ HOLE_IN_REGION_CHAIN,
+ OVERLAP_IN_REGION_CHAIN,
+ REGION_CYCLE,
+ DEGENERATE_REGION,
+ ORPHAN_HDFS_REGION,
+ LINGERING_SPLIT_PARENT,
+ NO_TABLEINFO_FILE,
+ LINGERING_REFERENCE_HFILE,
+ LINGERING_HFILELINK,
+ WRONG_USAGE,
+ EMPTY_META_CELL,
+ EXPIRED_TABLE_LOCK,
+ BOUNDARIES_ERROR,
+ ORPHAN_TABLE_STATE,
+ NO_TABLE_STATE,
+ UNDELETED_REPLICATION_QUEUE,
+ DUPE_ENDKEYS,
+ UNSUPPORTED_OPTION,
+ INVALID_TABLE
}
+
void clear();
+
void report(String message);
+
void reportError(String message);
+
void reportError(ErrorReporter.ERROR_CODE errorCode, String message);
+
void reportError(ErrorReporter.ERROR_CODE errorCode, String message, TableInfo table);
+
void reportError(ErrorReporter.ERROR_CODE errorCode, String message, TableInfo table,
HbckInfo info);
- void reportError(
- ERROR_CODE errorCode,
- String message,
- TableInfo table,
- HbckInfo info1,
- HbckInfo info2
- );
+
+ void reportError(ERROR_CODE errorCode, String message, TableInfo table, HbckInfo info1,
+ HbckInfo info2);
+
int summarize();
+
void detail(String details);
+
ArrayList<ERROR_CODE> getErrorList();
+
void progress();
+
void print(String message);
+
void resetErrors();
+
boolean tableHasErrors(TableInfo table);
}
@@ -4548,14 +4443,14 @@ public class HBaseFsck extends Configured implements Closeable {
@Override
public synchronized void reportError(ErrorReporter.ERROR_CODE errorCode, String message,
- TableInfo table) {
+ TableInfo table) {
errorTables.add(table);
reportError(errorCode, message);
}
@Override
- public synchronized void reportError(ErrorReporter.ERROR_CODE errorCode,
- String message, TableInfo table, HbckInfo info) {
+ public synchronized void reportError(ErrorReporter.ERROR_CODE errorCode, String message,
+ TableInfo table, HbckInfo info) {
errorTables.add(table);
String reference = "(region " + info.getRegionNameAsString() + ")";
reportError(errorCode, reference + " " + message);
@@ -4563,10 +4458,10 @@ public class HBaseFsck extends Configured implements Closeable {
@Override
public synchronized void reportError(ErrorReporter.ERROR_CODE errorCode, String message,
- TableInfo table, HbckInfo info1, HbckInfo info2) {
+ TableInfo table, HbckInfo info1, HbckInfo info2) {
errorTables.add(table);
- String reference = "(regions " + info1.getRegionNameAsString()
- + " and " + info2.getRegionNameAsString() + ")";
+ String reference =
+ "(regions " + info1.getRegionNameAsString() + " and " + info2.getRegionNameAsString() + ")";
reportError(errorCode, reference + " " + message);
}
@@ -4576,12 +4471,12 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Report error information, but do not increment the error count. Intended for cases
- * where the actual error would have been reported previously.
+ * Report error information, but do not increment the error count. Intended for cases where the
+ * actual error would have been reported previously.
*/
@Override
public synchronized void report(String message) {
- if (! summary) {
+ if (!summary) {
System.out.println("ERROR: " + message);
}
showProgress = 0;
@@ -4646,8 +4541,7 @@ public class HBaseFsck extends Configured implements Closeable {
private final ErrorReporter errors;
private final Connection connection;
- WorkItemRegion(HBaseFsck hbck, ServerName info,
- ErrorReporter errors, Connection connection) {
+ WorkItemRegion(HBaseFsck hbck, ServerName info, ErrorReporter errors, Connection connection) {
this.hbck = hbck;
this.rsinfo = info;
this.errors = errors;
@@ -4666,10 +4560,10 @@ public class HBaseFsck extends Configured implements Closeable {
errors.detail(
"RegionServer: " + rsinfo.getServerName() + " number of regions: " + regions.size());
for (RegionInfo rinfo : regions) {
- errors.detail(" " + rinfo.getRegionNameAsString() + " id: " + rinfo.getRegionId() +
- " encoded_name: " + rinfo.getEncodedName() + " start: " +
- Bytes.toStringBinary(rinfo.getStartKey()) + " end: " +
- Bytes.toStringBinary(rinfo.getEndKey()));
+ errors.detail(" " + rinfo.getRegionNameAsString() + " id: " + rinfo.getRegionId()
+ + " encoded_name: " + rinfo.getEncodedName() + " start: "
+ + Bytes.toStringBinary(rinfo.getStartKey()) + " end: "
+ + Bytes.toStringBinary(rinfo.getEndKey()));
}
}
@@ -4680,8 +4574,7 @@ public class HBaseFsck extends Configured implements Closeable {
}
} catch (IOException e) { // unable to connect to the region server.
errors.reportError(ErrorReporter.ERROR_CODE.RS_CONNECT_FAILURE,
- "RegionServer: " + rsinfo.getServerName() +
- " Unable to fetch region information. " + e);
+ "RegionServer: " + rsinfo.getServerName() + " Unable to fetch region information. " + e);
throw e;
}
return null;
@@ -4690,8 +4583,7 @@ public class HBaseFsck extends Configured implements Closeable {
private List<RegionInfo> filterRegions(List<RegionInfo> regions) {
List<RegionInfo> ret = Lists.newArrayList();
for (RegionInfo hri : regions) {
- if (hri.isMetaRegion() || (!hbck.checkMetaOnly
- && hbck.isTableIncluded(hri.getTable()))) {
+ if (hri.isMetaRegion() || (!hbck.checkMetaOnly && hbck.isTableIncluded(hri.getTable()))) {
ret.add(hri);
}
}
@@ -4700,16 +4592,14 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Contact hdfs and get all information about specified table directory into
- * regioninfo list.
+ * Contact hdfs and get all information about specified table directory into regioninfo list.
*/
class WorkItemHdfsDir implements Callable<Void> {
private FileStatus tableDir;
private ErrorReporter errors;
private FileSystem fs;
- WorkItemHdfsDir(FileSystem fs, ErrorReporter errors,
- FileStatus status) {
+ WorkItemHdfsDir(FileSystem fs, ErrorReporter errors, FileStatus status) {
this.fs = fs;
this.tableDir = status;
this.errors = errors;
@@ -4739,18 +4629,18 @@ public class HBaseFsck extends Configured implements Closeable {
@Override
public void run() {
try {
- LOG.debug("Loading region info from hdfs:"+ regionDir.getPath());
+ LOG.debug("Loading region info from hdfs:" + regionDir.getPath());
- Path regioninfoFile = new Path(regionDir.getPath(),
- HRegionFileSystem.REGION_INFO_FILE);
+ Path regioninfoFile =
+ new Path(regionDir.getPath(), HRegionFileSystem.REGION_INFO_FILE);
boolean regioninfoFileExists = fs.exists(regioninfoFile);
if (!regioninfoFileExists) {
// As tables become larger it is more and more likely that by the time you
// reach a given region that it will be gone due to region splits/merges.
if (!fs.exists(regionDir.getPath())) {
- LOG.warn("By the time we tried to process this region dir it was already " +
- "gone: " + regionDir.getPath());
+ LOG.warn("By the time we tried to process this region dir it was already "
+ + "gone: " + regionDir.getPath());
return;
}
}
@@ -4759,8 +4649,8 @@ public class HBaseFsck extends Configured implements Closeable {
HdfsEntry he = new HdfsEntry();
synchronized (hbi) {
if (hbi.getHdfsRegionDir() != null) {
- errors.print("Directory " + encodedName + " duplicate?? " +
- hbi.getHdfsRegionDir());
+ errors
+ .print("Directory " + encodedName + " duplicate?? " + hbi.getHdfsRegionDir());
}
he.hdfsRegionDir = regionDir.getPath();
@@ -4773,7 +4663,7 @@ public class HBaseFsck extends Configured implements Closeable {
he.hdfsOnlyEdits = true;
FileStatus[] subDirs = fs.listStatus(regionDir.getPath());
Path ePath = new Path(regionDir.getPath(), HConstants.RECOVERED_EDITS_DIR);
- // WAS => WALSplitUtil.getRegionDirRecoveredEditsDir(regionDir.getPath());
+ // WAS => WALSplitUtil.getRegionDirRecoveredEditsDir(regionDir.getPath());
for (FileStatus subDir : subDirs) {
errors.progress();
String sdName = subDir.getPath().getName();
@@ -4809,13 +4699,12 @@ public class HBaseFsck extends Configured implements Closeable {
exceptions.add(e);
} finally {
if (!exceptions.isEmpty()) {
- errors.reportError(ErrorReporter.ERROR_CODE.RS_CONNECT_FAILURE,
- "Table Directory: " + tableDir.getPath().getName() +
- " Unable to fetch all HDFS region information. ");
+ errors.reportError(ErrorReporter.ERROR_CODE.RS_CONNECT_FAILURE, "Table Directory: "
+ + tableDir.getPath().getName() + " Unable to fetch all HDFS region information. ");
// Just throw the first exception as an indication something bad happened
// Don't need to propagate all the exceptions, we already logged them all anyway
throw new ExecutionException("First exception in WorkItemHdfsDir",
- exceptions.firstElement());
+ exceptions.firstElement());
}
}
return null;
@@ -4823,8 +4712,7 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Contact hdfs and get all information about specified table directory into
- * regioninfo list.
+ * Contact hdfs and get all information about specified table directory into regioninfo list.
*/
static class WorkItemHdfsRegionInfo implements Callable<Void> {
private HbckInfo hbi;
@@ -4846,10 +4734,9 @@ public class HBaseFsck extends Configured implements Closeable {
hbck.loadHdfsRegioninfo(hbi);
} catch (IOException ioe) {
String msg = "Orphan region in HDFS: Unable to load .regioninfo from table "
- + hbi.getTableName() + " in hdfs dir "
- + hbi.getHdfsRegionDir()
- + "! It may be an invalid format or version file. Treating as "
- + "an orphaned regiondir.";
+ + hbi.getTableName() + " in hdfs dir " + hbi.getHdfsRegionDir()
+ + "! It may be an invalid format or version file. Treating as "
+ + "an orphaned regiondir.";
errors.reportError(ErrorReporter.ERROR_CODE.ORPHAN_HDFS_REGION, msg);
try {
hbck.debugLsr(hbi.getHdfsRegionDir());
@@ -4866,8 +4753,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Display the full report from fsck. This displays all live and dead region
- * servers, and all known regions.
+ * Display the full report from fsck. This displays all live and dead region servers, and all
+ * known regions.
*/
public static void setDisplayFullReport() {
details = true;
@@ -4888,16 +4775,14 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Set summary mode.
- * Print only summary of the tables and status (OK or INCONSISTENT)
+ * Set summary mode. Print only summary of the tables and status (OK or INCONSISTENT)
*/
static void setSummary() {
summary = true;
}
/**
- * Set hbase:meta check mode.
- * Print only info about hbase:meta table deployment/state
+ * Set hbase:meta check mode. Print only info about hbase:meta table deployment/state
*/
void setCheckMetaOnly() {
checkMetaOnly = true;
@@ -4923,9 +4808,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Check if we should rerun fsck again. This checks if we've tried to
- * fix something and we should rerun fsck tool again.
- * Display the full report from fsck. This displays all live and dead
+ * Check if we should rerun fsck again. This checks if we've tried to fix something and we should
+ * rerun fsck tool again. Display the full report from fsck. This displays all live and dead
* region servers, and all known regions.
*/
public void setShouldRerun() {
@@ -4937,8 +4821,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Fix inconsistencies found by fsck. This should try to fix errors (if any)
- * found by fsck utility.
+ * Fix inconsistencies found by fsck. This should try to fix errors (if any) found by fsck
+ * utility.
*/
public void setFixAssignments(boolean shouldFix) {
fixAssignments = shouldFix;
@@ -5092,8 +4976,7 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * Only check/fix tables specified by the list,
- * Empty list means all tables are included.
+ * Only check/fix tables specified by the list, Empty list means all tables are included.
*/
boolean isTableIncluded(TableName table) {
return (tablesIncluded.isEmpty()) || tablesIncluded.contains(table);
@@ -5108,8 +4991,8 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- * We are interested in only those tables that have not changed their state in
- * hbase:meta during the last few seconds specified by hbase.admin.fsck.timelag
+ * We are interested in only those tables that have not changed their state in hbase:meta during
+ * the last few seconds specified by hbase.admin.fsck.timelag
* @param seconds - the time in seconds
*/
public void setTimeLag(long seconds) {
@@ -5117,7 +5000,6 @@ public class HBaseFsck extends Configured implements Closeable {
}
/**
- *
* @param sidelineDir - HDFS path to sideline data
*/
public void setSidelineDir(String sidelineDir) {
@@ -5125,7 +5007,7 @@ public class HBaseFsck extends Configured implements Closeable {
}
public HFileCorruptionChecker createHFileCorruptionChecker(boolean sidelineCorruptHFiles)
- throws IOException {
+ throws IOException {
return new HFileCorruptionChecker(getConf(), executor, sidelineCorruptHFiles);
}
@@ -5160,77 +5042,76 @@ public class HBaseFsck extends Configured implements Closeable {
out.println(" where [opts] are:");
out.println(" -help Display help options (this)");
out.println(" -details Display full report of all regions.");
- out.println(" -timelag <timeInSeconds> Process only regions that " +
- " have not experienced any metadata updates in the last " +
- " <timeInSeconds> seconds.");
- out.println(" -sleepBeforeRerun <timeInSeconds> Sleep this many seconds" +
- " before checking if the fix worked if run with -fix");
+ out.println(" -timelag <timeInSeconds> Process only regions that "
+ + " have not experienced any metadata updates in the last " + " <timeInSeconds> seconds.");
+ out.println(" -sleepBeforeRerun <timeInSeconds> Sleep this many seconds"
+ + " before checking if the fix worked if run with -fix");
out.println(" -summary Print only summary of the tables and status.");
out.println(" -metaonly Only check the state of the hbase:meta table.");
out.println(" -sidelineDir <hdfs://> HDFS path to backup existing meta.");
- out.println(" -boundaries Verify that regions boundaries are the same between " +
- "META and store files.");
+ out.println(" -boundaries Verify that regions boundaries are the same between "
+ + "META and store files.");
out.println(" -exclusive Abort if another hbck is exclusive or fixing.");
out.println("");
out.println(" Datafile Repair options: (expert features, use with caution!)");
- out.println(" -checkCorruptHFiles Check all Hfiles by opening them to make " +
- "sure they are valid");
- out.println(" -sidelineCorruptHFiles Quarantine corrupted HFiles. " +
- "implies -checkCorruptHFiles");
+ out.println(" -checkCorruptHFiles Check all Hfiles by opening them to make "
+ + "sure they are valid");
+ out.println(
+ " -sidelineCorruptHFiles Quarantine corrupted HFiles. " + "implies -checkCorruptHFiles");
out.println("");
out.println(" Replication options");
out.println(" -fixReplication Deletes replication queues for removed peers");
out.println("");
- out.println(" Metadata Repair options supported as of version 2.0: (expert features, use " +
- "with caution!)");
+ out.println(" Metadata Repair options supported as of version 2.0: (expert features, use "
+ + "with caution!)");
out.println(" -fixVersionFile Try to fix missing hbase.version file in hdfs.");
out.println(" -fixReferenceFiles Try to offline lingering reference store files");
out.println(" -fixHFileLinks Try to offline lingering HFileLinks");
out.println(" -noHdfsChecking Don't load/check region info from HDFS."
- + " Assumes hbase:meta region info is good. Won't check/fix any HDFS issue, e.g. hole, " +
- "orphan, or overlap");
+ + " Assumes hbase:meta region info is good. Won't check/fix any HDFS issue, e.g. hole, "
+ + "orphan, or overlap");
out.println(" -ignorePreCheckPermission ignore filesystem permission pre-check");
out.println("");
out.println("NOTE: Following options are NOT supported as of HBase version 2.0+.");
out.println("");
out.println(" UNSUPPORTED Metadata Repair options: (expert features, use with caution!)");
- out.println(" -fix Try to fix region assignments. This is for backwards " +
- "compatiblity");
+ out.println(" -fix Try to fix region assignments. This is for backwards "
+ + "compatiblity");
out.println(" -fixAssignments Try to fix region assignments. Replaces the old -fix");
- out.println(" -fixMeta Try to fix meta problems. This assumes HDFS region info " +
- "kis good.");
+ out.println(" -fixMeta Try to fix meta problems. This assumes HDFS region info "
+ + "kis good.");
out.println(" -fixHdfsHoles Try to fix region holes in hdfs.");
out.println(" -fixHdfsOrphans Try to fix region dirs with no .regioninfo file in hdfs");
- out.println(" -fixTableOrphans Try to fix table dirs with no .tableinfo file in hdfs " +
- "(online mode only)");
+ out.println(" -fixTableOrphans Try to fix table dirs with no .tableinfo file in hdfs "
+ + "(online mode only)");
out.println(" -fixHdfsOverlaps Try to fix region overlaps in hdfs.");
- out.println(" -maxMerge <n> When fixing region overlaps, allow at most <n> regions " +
- "to merge. (n=" + DEFAULT_MAX_MERGE +" by default)");
- out.println(" -sidelineBigOverlaps When fixing region overlaps, allow to sideline big " +
- "overlaps");
- out.println(" -maxOverlapsToSideline <n> When fixing region overlaps, allow at most" +
- " <n> regions to sideline per group. (n=" + DEFAULT_OVERLAPS_TO_SIDELINE +" by default)");
+ out.println(" -maxMerge <n> When fixing region overlaps, allow at most <n> regions "
+ + "to merge. (n=" + DEFAULT_MAX_MERGE + " by default)");
+ out.println(
+ " -sidelineBigOverlaps When fixing region overlaps, allow to sideline big " + "overlaps");
+ out.println(" -maxOverlapsToSideline <n> When fixing region overlaps, allow at most"
+ + " <n> regions to sideline per group. (n=" + DEFAULT_OVERLAPS_TO_SIDELINE + " by default)");
out.println(" -fixSplitParents Try to force offline split parents to be online.");
- out.println(" -removeParents Try to offline and sideline lingering parents and keep " +
- "daughter regions.");
+ out.println(" -removeParents Try to offline and sideline lingering parents and keep "
+ + "daughter regions.");
out.println(" -fixEmptyMetaCells Try to fix hbase:meta entries not referencing any region"
- + " (empty REGIONINFO_QUALIFIER rows)");
+ + " (empty REGIONINFO_QUALIFIER rows)");
out.println("");
out.println(" UNSUPPORTED Metadata Repair shortcuts");
- out.println(" -repair Shortcut for -fixAssignments -fixMeta -fixHdfsHoles " +
- "-fixHdfsOrphans -fixHdfsOverlaps -fixVersionFile -sidelineBigOverlaps " +
- "-fixReferenceFiles -fixHFileLinks");
+ out.println(" -repair Shortcut for -fixAssignments -fixMeta -fixHdfsHoles "
+ + "-fixHdfsOrphans -fixHdfsOverlaps -fixVersionFile -sidelineBigOverlaps "
+ + "-fixReferenceFiles -fixHFileLinks");
out.println(" -repairHoles Shortcut for -fixAssignments -fixMeta -fixHdfsHoles");
out.println("");
out.println(" Replication options");
out.println(" -fixReplication Deletes replication queues for removed peers");
- out.println(" -cleanReplicationBrarier [tableName] clean the replication barriers " +
- "of a specified table, tableName is required");
+ out.println(" -cleanReplicationBrarier [tableName] clean the replication barriers "
+ + "of a specified table, tableName is required");
out.flush();
errors.reportError(ErrorReporter.ERROR_CODE.WRONG_USAGE, sw.toString());
@@ -5288,14 +5169,14 @@ public class HBaseFsck extends Configured implements Closeable {
} else if (cmd.equals("-sleepBeforeRerun")) {
if (i == args.length - 1) {
errors.reportError(ErrorReporter.ERROR_CODE.WRONG_USAGE,
- "-sleepBeforeRerun needs value.");
+ "-sleepBeforeRerun needs value.");
return printUsageAndExit();
}
try {
cld.sleepBeforeRerun = Long.parseLong(args[++i]);
} catch (NumberFormatException e) {
errors.reportError(ErrorReporter.ERROR_CODE.WRONG_USAGE,
- "-sleepBeforeRerun needs a numeric value.");
+ "-sleepBeforeRerun needs a numeric value.");
return printUsageAndExit();
}
} else if (cmd.equals("-sidelineDir")) {
@@ -5306,7 +5187,7 @@ public class HBaseFsck extends Configured implements Closeable {
setSidelineDir(args[++i]);
} else if (cmd.equals("-fix")) {
errors.reportError(ErrorReporter.ERROR_CODE.WRONG_USAGE,
- "This option is deprecated, please use -fixAssignments instead.");
+ "This option is deprecated, please use -fixAssignments instead.");
setFixAssignments(true);
} else if (cmd.equals("-fixAssignments")) {
setFixAssignments(true);
@@ -5349,7 +5230,7 @@ public class HBaseFsck extends Configured implements Closeable {
} else if (cmd.equals("-maxOverlapsToSideline")) {
if (i == args.length - 1) {
errors.reportError(ErrorReporter.ERROR_CODE.WRONG_USAGE,
- "-maxOverlapsToSideline needs a numeric value argument.");
+ "-maxOverlapsToSideline needs a numeric value argument.");
return printUsageAndExit();
}
try {
@@ -5357,7 +5238,7 @@ public class HBaseFsck extends Configured implements Closeable {
setMaxOverlapsToSideline(maxOverlapsToSideline);
} catch (NumberFormatException e) {
errors.reportError(ErrorReporter.ERROR_CODE.WRONG_USAGE,
- "-maxOverlapsToSideline needs a numeric value argument.");
+ "-maxOverlapsToSideline needs a numeric value argument.");
return printUsageAndExit();
}
} else if (cmd.equals("-maxMerge")) {
@@ -5425,7 +5306,7 @@ public class HBaseFsck extends Configured implements Closeable {
}
public HBaseFsck exec(ExecutorService exec, String[] args)
- throws KeeperException, IOException, InterruptedException, ReplicationException {
+ throws KeeperException, IOException, InterruptedException, ReplicationException {
errors.print("HBaseFsck command line options: " + String.join(" ", args));
CommandLineData cld = new CommandLineData();
doCommandLine(args, cld);
@@ -5506,7 +5387,7 @@ public class HBaseFsck extends Configured implements Closeable {
for (String arg : args) {
if (unsupportedOptionsInV2.contains(arg)) {
errors.reportError(ErrorReporter.ERROR_CODE.UNSUPPORTED_OPTION,
- "option '" + arg + "' is not " + "supportted!");
+ "option '" + arg + "' is not " + "supportted!");
result = false;
break;
}
@@ -5531,8 +5412,7 @@ public class HBaseFsck extends Configured implements Closeable {
boolean isGlobalScope = false;
try {
- isGlobalScope =
- admin.getDescriptor(cleanReplicationBarrierTable).hasGlobalReplicationScope();
+ isGlobalScope = admin.getDescriptor(cleanReplicationBarrierTable).hasGlobalReplicationScope();
} catch (TableNotFoundException e) {
LOG.info("we may need to clean some erroneous data due to bugs");
}
@@ -5547,8 +5427,8 @@ public class HBaseFsck extends Configured implements Closeable {
barrierScan.setCaching(100);
barrierScan.addFamily(HConstants.REPLICATION_BARRIER_FAMILY);
barrierScan
- .withStartRow(HBCKMetaTableAccessor.getTableStartRowForMeta(cleanReplicationBarrierTable))
- .withStopRow(HBCKMetaTableAccessor.getTableStopRowForMeta(cleanReplicationBarrierTable));
+ .withStartRow(HBCKMetaTableAccessor.getTableStartRowForMeta(cleanReplicationBarrierTable))
+ .withStopRow(HBCKMetaTableAccessor.getTableStopRowForMeta(cleanReplicationBarrierTable));
Result result;
try (ResultScanner scanner = meta.getScanner(barrierScan)) {
while ((result = scanner.next()) != null) {
@@ -5561,13 +5441,13 @@ public class HBaseFsck extends Configured implements Closeable {
return;
}
ReplicationQueueStorage queueStorage =
- ReplicationStorageFactory.getReplicationQueueStorage(zkw, getConf());
+ ReplicationStorageFactory.getReplicationQueueStorage(zkw, getConf());
List<ReplicationPeerDescription> peerDescriptions = admin.listReplicationPeers();
if (peerDescriptions != null && peerDescriptions.size() > 0) {
List<String> peers = peerDescriptions.stream()
- .filter(peerConfig -> peerConfig.getPeerConfig()
- .needToReplicate(cleanReplicationBarrierTable))
- .map(ReplicationPeerDescription::getPeerId).collect(Collectors.toList());
+ .filter(
+ peerConfig -> peerConfig.getPeerConfig().needToReplicate(cleanReplicationBarrierTable))
+ .map(ReplicationPeerDescription::getPeerId).collect(Collectors.toList());
try {
List<String> batch = new ArrayList<>();
for (String peer : peers) {
@@ -5603,16 +5483,14 @@ public class HBaseFsck extends Configured implements Closeable {
/**
* ls -r for debugging purposes
*/
- public static void debugLsr(Configuration conf,
- Path p) throws IOException {
+ public static void debugLsr(Configuration conf, Path p) throws IOException {
debugLsr(conf, p, new PrintingErrorReporter());
}
/**
* ls -r for debugging purposes
*/
- public static void debugLsr(Configuration conf,
- Path p, ErrorReporter errors) throws IOException {
+ public static void debugLsr(Configuration conf, Path p, ErrorReporter errors) throws IOException {
if (!LOG.isDebugEnabled() || p == null) {
return;
}
@@ -5629,7 +5507,7 @@ public class HBaseFsck extends Configured implements Closeable {
}
if (fs.getFileStatus(p).isDirectory()) {
- FileStatus[] fss= fs.listStatus(p);
+ FileStatus[] fss = fs.listStatus(p);
for (FileStatus status : fss) {
debugLsr(conf, status.getPath(), errors);
}
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsckRepair.java b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsckRepair.java
index 0b0f7d7..ebde4bf 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsckRepair.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsckRepair.java
@@ -1,5 +1,4 @@
/*
- *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -23,7 +22,6 @@ import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.ClusterMetrics.Option;
@@ -48,10 +46,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This class contains helper methods that repair parts of hbase's filesystem
- * contents.
- *
- * Copied over wholesale from hbase. Unaltered except for package and imports.
+ * This class contains helper methods that repair parts of hbase's filesystem contents. Copied over
+ * wholesale from hbase. Unaltered except for package and imports.
*/
public final class HBaseFsckRepair {
private static final Logger LOG = LoggerFactory.getLogger(HBaseFsckRepair.class);
@@ -59,22 +55,20 @@ public final class HBaseFsckRepair {
/**
* Shut down constructor.
*/
- private HBaseFsckRepair() {}
+ private HBaseFsckRepair() {
+ }
/**
- * Fix multiple assignment by doing silent closes on each RS hosting the region
- * and then force ZK unassigned node to OFFLINE to trigger assignment by
- * master.
- *
+ * Fix multiple assignment by doing silent closes on each RS hosting the region and then force ZK
+ * unassigned node to OFFLINE to trigger assignment by master.
* @param connection HBase connection to the cluster
- * @param region Region to undeploy
- * @param servers list of Servers to undeploy from
+ * @param region Region to undeploy
+ * @param servers list of Servers to undeploy from
*/
public static void fixMultiAssignment(Connection connection, RegionInfo region,
- List<ServerName> servers)
- throws IOException, KeeperException, InterruptedException {
+ List<ServerName> servers) throws IOException, KeeperException, InterruptedException {
// Close region on the servers silently
- for(ServerName server : servers) {
+ for (ServerName server : servers) {
closeRegionSilentlyAndWait(connection, server, region);
}
@@ -83,45 +77,41 @@ public final class HBaseFsckRepair {
}
/**
- * Fix unassigned by creating/transition the unassigned ZK node for this
- * region to OFFLINE state with a special flag to tell the master that this is
- * a forced operation by HBCK.
- *
- * This assumes that info is in META.
+ * Fix unassigned by creating/transition the unassigned ZK node for this region to OFFLINE state
+ * with a special flag to tell the master that this is a forced operation by HBCK. This assumes
+ * that info is in META.
*/
public static void fixUnassigned(Admin admin, RegionInfo region)
- throws IOException, KeeperException, InterruptedException {
+ throws IOException, KeeperException, InterruptedException {
// Force ZK node to OFFLINE so master assigns
forceOfflineInZK(admin, region);
}
/**
- * In 0.90, this forces an HRI offline by setting the RegionTransitionData
- * in ZK to have HBCK_CODE_NAME as the server. This is a special case in
- * the AssignmentManager that attempts an assign call by the master.
- *
- * This doesn't seem to work properly in the updated version of 0.92+'s hbck
- * so we use assign to force the region into transition. This has the
- * side-effect of requiring a RegionInfo that considers regionId (timestamp)
- * in comparators that is addressed by HBASE-5563.
+ * In 0.90, this forces an HRI offline by setting the RegionTransitionData in ZK to have
+ * HBCK_CODE_NAME as the server. This is a special case in the AssignmentManager that attempts an
+ * assign call by the master. This doesn't seem to work properly in the updated version of 0.92+'s
+ * hbck so we use assign to force the region into transition. This has the side-effect of
+ * requiring a RegionInfo that considers regionId (timestamp) in comparators that is addressed by
+ * HBASE-5563.
*/
private static void forceOfflineInZK(Admin admin, final RegionInfo region)
- throws ZooKeeperConnectionException, KeeperException, IOException, InterruptedException {
+ throws ZooKeeperConnectionException, KeeperException, IOException, InterruptedException {
admin.assign(region.getRegionName());
}
/*
* Should we check all assignments or just not in RIT?
*/
- public static void waitUntilAssigned(Admin admin,
- RegionInfo region) throws IOException, InterruptedException {
+ public static void waitUntilAssigned(Admin admin, RegionInfo region)
+ throws IOException, InterruptedException {
long timeout = admin.getConfiguration().getLong("hbase.hbck.assign.timeout", 120000);
long expiration = timeout + System.currentTimeMillis();
while (System.currentTimeMillis() < expiration) {
try {
boolean inTransition = false;
for (RegionState rs : admin.getClusterMetrics(EnumSet.of(Option.REGIONS_IN_TRANSITION))
- .getRegionStatesInTransition()) {
+ .getRegionStatesInTransition()) {
if (RegionInfo.COMPARATOR.compare(rs.getRegion(), region) == 0) {
inTransition = true;
break;
@@ -132,16 +122,14 @@ public final class HBaseFsckRepair {
return;
}
// still in rit
- LOG.info("Region still in transition, waiting for "
- + "it to become assigned: " + region);
+ LOG.info("Region still in transition, waiting for " + "it to become assigned: " + region);
} catch (IOException e) {
- LOG.warn("Exception when waiting for region to become assigned,"
- + " retrying", e);
+ LOG.warn("Exception when waiting for region to become assigned," + " retrying", e);
}
Thread.sleep(1000);
}
- throw new IOException("Region " + region + " failed to move out of " +
- "transition within timeout " + timeout + "ms");
+ throw new IOException("Region " + region + " failed to move out of "
+ + "transition within timeout " + timeout + "ms");
}
/**
@@ -149,18 +137,17 @@ public final class HBaseFsckRepair {
* the region. This bypasses the active hmaster.
*/
public static void closeRegionSilentlyAndWait(Connection connection, ServerName server,
- RegionInfo region) throws IOException, InterruptedException {
- long timeout = connection.getConfiguration()
- .getLong("hbase.hbck.close.timeout", 120000);
- ServerManager.closeRegionSilentlyAndWait((ClusterConnection)connection, server,
- region, timeout);
+ RegionInfo region) throws IOException, InterruptedException {
+ long timeout = connection.getConfiguration().getLong("hbase.hbck.close.timeout", 120000);
+ ServerManager.closeRegionSilentlyAndWait((ClusterConnection) connection, server, region,
+ timeout);
}
/**
* Puts the specified RegionInfo into META with replica related columns
*/
- public static void fixMetaHoleOnlineAndAddReplicas(Configuration conf,
- RegionInfo hri, Collection<ServerName> servers, int numReplicas) throws IOException {
+ public static void fixMetaHoleOnlineAndAddReplicas(Configuration conf, RegionInfo hri,
+ Collection<ServerName> servers, int numReplicas) throws IOException {
Connection conn = ConnectionFactory.createConnection(conf);
Table meta = conn.getTable(TableName.META_TABLE_NAME);
Put put = HBCKMetaTableAccessor.makePutFromRegionInfo(hri, System.currentTimeMillis());
@@ -184,8 +171,8 @@ public final class HBaseFsckRepair {
/**
* Creates, flushes, and closes a new region.
*/
- public static HRegion createHDFSRegionDir(Configuration conf,
- RegionInfo hri, TableDescriptor htd) throws IOException {
+ public static HRegion createHDFSRegionDir(Configuration conf, RegionInfo hri, TableDescriptor htd)
+ throws IOException {
// Create HRegion
Path root = CommonFSUtils.getRootDir(conf);
HRegion region = HRegion.createHRegion(hri, root, conf, htd, null);
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HFileCorruptionChecker.java b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HFileCorruptionChecker.java
index 2d569bf..0ba480a 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HFileCorruptionChecker.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HFileCorruptionChecker.java
@@ -30,7 +30,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
@@ -48,19 +47,15 @@ import org.apache.hadoop.hbase.util.FSUtils.HFileFilter;
import org.apache.hadoop.hbase.util.FSUtils.RegionDirFilter;
import org.apache.hbase.HBCKFsUtils;
import org.apache.yetus.audience.InterfaceAudience;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This class marches through all of the region's hfiles and verifies that
- * they are all valid files. One just needs to instantiate the class, use
- * checkTables(List<Path>) and then retrieve the corrupted hfiles (and
- * quarantined files if in quarantining mode)
- *
- * The implementation currently parallelizes at the regionDir level.
- *
- * Copied over wholesale from hbase. Unaltered except for package and imports.
+ * This class marches through all of the region's hfiles and verifies that they are all valid files.
+ * One just needs to instantiate the class, use checkTables(List<Path>) and then retrieve the
+ * corrupted hfiles (and quarantined files if in quarantining mode) The implementation currently
+ * parallelizes at the regionDir level. Copied over wholesale from hbase. Unaltered except for
+ * package and imports.
*/
@InterfaceAudience.Private
public class HFileCorruptionChecker {
@@ -82,8 +77,8 @@ public class HFileCorruptionChecker {
final AtomicInteger hfilesChecked = new AtomicInteger();
final AtomicInteger mobFilesChecked = new AtomicInteger();
- public HFileCorruptionChecker(Configuration conf, ExecutorService executor,
- boolean quarantine) throws IOException {
+ public HFileCorruptionChecker(Configuration conf, ExecutorService executor, boolean quarantine)
+ throws IOException {
this.conf = conf;
this.fs = HBCKFsUtils.getRootDirFileSystem(conf);
this.cacheConf = CacheConfig.DISABLED;
@@ -92,12 +87,8 @@ public class HFileCorruptionChecker {
}
/**
- * Checks a path to see if it is a valid hfile.
- *
- * @param p
- * full Path to an HFile
- * @throws IOException
- * This is a connectivity related exception
+ * Checks a path to see if it is a valid hfile. full Path to an HFile This is a connectivity
+ * related exception
*/
protected void checkHFile(Path p) throws IOException {
HFile.Reader r = null;
@@ -110,7 +101,7 @@ public class HFileCorruptionChecker {
Path dest = createQuarantinePath(p);
LOG.warn("Quarantining corrupt HFile " + p + " into " + dest);
boolean success = fs.mkdirs(dest.getParent());
- success = success ? fs.rename(p, dest): false;
+ success = success ? fs.rename(p, dest) : false;
if (!success) {
failures.add(p);
} else {
@@ -130,12 +121,8 @@ public class HFileCorruptionChecker {
}
/**
- * Given a path, generates a new path to where we move a corrupted hfile (bad
- * trailer, no trailer).
- *
- * @param hFile
- * Path to a corrupt hfile (assumes that it is HBASE_DIR/ table
- * /region/cf/file)
+ * Given a path, generates a new path to where we move a corrupted hfile (bad trailer, no
+ * trailer). Path to a corrupt hfile (assumes that it is HBASE_DIR/ table /region/cf/file)
* @return path to where corrupted files are stored. This should be
* HBASE_DIR/.corrupt/table/region/cf/file.
*/
@@ -166,8 +153,8 @@ public class HFileCorruptionChecker {
statuses = fs.listStatus(cfDir); // use same filter as scanner.
} catch (FileNotFoundException fnfe) {
// Hadoop 0.23+ listStatus semantics throws an exception if the path does not exist.
- LOG.warn("Colfam Directory " + cfDir +
- " does not exist. Likely due to concurrent split/compaction. Skipping.");
+ LOG.warn("Colfam Directory " + cfDir
+ + " does not exist. Likely due to concurrent split/compaction. Skipping.");
missing.add(cfDir);
return;
}
@@ -175,8 +162,8 @@ public class HFileCorruptionChecker {
List<FileStatus> hfs = FSUtils.filterFileStatuses(statuses, new HFileFilter(fs));
// Hadoop 1.0 listStatus does not throw an exception if the path does not exist.
if (hfs.isEmpty() && !fs.exists(cfDir)) {
- LOG.warn("Colfam Directory " + cfDir +
- " does not exist. Likely due to concurrent split/compaction. Skipping.");
+ LOG.warn("Colfam Directory " + cfDir
+ + " does not exist. Likely due to concurrent split/compaction. Skipping.");
missing.add(cfDir);
return;
}
@@ -195,8 +182,8 @@ public class HFileCorruptionChecker {
statuses = fs.listStatus(cfDir); // use same filter as scanner.
} catch (FileNotFoundException fnfe) {
// Hadoop 0.23+ listStatus semantics throws an exception if the path does not exist.
- LOG.warn("Mob colfam Directory " + cfDir +
- " does not exist. Likely the table is deleted. Skipping.");
+ LOG.warn("Mob colfam Directory " + cfDir
+ + " does not exist. Likely the table is deleted. Skipping.");
missedMobFiles.add(cfDir);
return;
}
@@ -204,8 +191,8 @@ public class HFileCorruptionChecker {
List<FileStatus> hfs = FSUtils.filterFileStatuses(statuses, new HFileFilter(fs));
// Hadoop 1.0 listStatus does not throw an exception if the path does not exist.
if (hfs.isEmpty() && !fs.exists(cfDir)) {
- LOG.warn("Mob colfam Directory " + cfDir +
- " does not exist. Likely the table is deleted. Skipping.");
+ LOG.warn("Mob colfam Directory " + cfDir
+ + " does not exist. Likely the table is deleted. Skipping.");
missedMobFiles.add(cfDir);
return;
}
@@ -216,12 +203,8 @@ public class HFileCorruptionChecker {
}
/**
- * Checks a path to see if it is a valid mob file.
- *
- * @param p
- * full Path to a mob file.
- * @throws IOException
- * This is a connectivity related exception
+ * Checks a path to see if it is a valid mob file. full Path to a mob file. This is a connectivity
+ * related exception
*/
protected void checkMobFile(Path p) throws IOException {
HFile.Reader r = null;
@@ -234,7 +217,7 @@ public class HFileCorruptionChecker {
Path dest = createQuarantinePath(p);
LOG.warn("Quarantining corrupt mob file " + p + " into " + dest);
boolean success = fs.mkdirs(dest.getParent());
- success = success ? fs.rename(p, dest): false;
+ success = success ? fs.rename(p, dest) : false;
if (!success) {
failureMobFiles.add(p);
} else {
@@ -265,16 +248,16 @@ public class HFileCorruptionChecker {
hfs = fs.listStatus(regionDir, new FamilyDirFilter(fs));
} catch (FileNotFoundException fnfe) {
// Hadoop 0.23+ listStatus semantics throws an exception if the path does not exist.
- LOG.warn("Mob directory " + regionDir
- + " does not exist. Likely the table is deleted. Skipping.");
+ LOG.warn(
+ "Mob directory " + regionDir + " does not exist. Likely the table is deleted. Skipping.");
missedMobFiles.add(regionDir);
return;
}
// Hadoop 1.0 listStatus does not throw an exception if the path does not exist.
if (hfs.length == 0 && !fs.exists(regionDir)) {
- LOG.warn("Mob directory " + regionDir
- + " does not exist. Likely the table is deleted. Skipping.");
+ LOG.warn(
+ "Mob directory " + regionDir + " does not exist. Likely the table is deleted. Skipping.");
missedMobFiles.add(regionDir);
return;
}
@@ -293,8 +276,8 @@ public class HFileCorruptionChecker {
statuses = fs.listStatus(regionDir);
} catch (FileNotFoundException fnfe) {
// Hadoop 0.23+ listStatus semantics throws an exception if the path does not exist.
- LOG.warn("Region Directory " + regionDir +
- " does not exist. Likely due to concurrent split/compaction. Skipping.");
+ LOG.warn("Region Directory " + regionDir
+ + " does not exist. Likely due to concurrent split/compaction. Skipping.");
missing.add(regionDir);
return;
}
@@ -302,8 +285,8 @@ public class HFileCorruptionChecker {
List<FileStatus> cfs = FSUtils.filterFileStatuses(statuses, new FamilyDirFilter(fs));
// Hadoop 1.0 listStatus does not throw an exception if the path does not exist.
if (cfs.isEmpty() && !fs.exists(regionDir)) {
- LOG.warn("Region Directory " + regionDir +
- " does not exist. Likely due to concurrent split/compaction. Skipping.");
+ LOG.warn("Region Directory " + regionDir
+ + " does not exist. Likely due to concurrent split/compaction. Skipping.");
missing.add(regionDir);
return;
}
@@ -319,11 +302,11 @@ public class HFileCorruptionChecker {
*/
void checkTableDir(Path tableDir) throws IOException {
List<FileStatus> rds =
- FSUtils.listStatusWithStatusFilter(fs, tableDir, new RegionDirFilter(fs));
+ FSUtils.listStatusWithStatusFilter(fs, tableDir, new RegionDirFilter(fs));
if (rds == null) {
if (!fs.exists(tableDir)) {
- LOG.warn("Table Directory " + tableDir +
- " does not exist. Likely due to concurrent delete. Skipping.");
+ LOG.warn("Table Directory " + tableDir
+ + " does not exist. Likely due to concurrent delete. Skipping.");
missing.add(tableDir);
}
return;
@@ -355,8 +338,8 @@ public class HFileCorruptionChecker {
try {
f.get();
} catch (ExecutionException e) {
- LOG.warn("Failed to quarantine an HFile in regiondir "
- + rdcs.get(i).regionDir, e.getCause());
+ LOG.warn("Failed to quarantine an HFile in regiondir " + rdcs.get(i).regionDir,
+ e.getCause());
// rethrow IOExceptions
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
@@ -380,8 +363,8 @@ public class HFileCorruptionChecker {
}
/**
- * An individual work item for parallelized regiondir processing. This is
- * intentionally an inner class so it can use the shared error sets and fs.
+ * An individual work item for parallelized regiondir processing. This is intentionally an inner
+ * class so it can use the shared error sets and fs.
*/
private class RegionDirChecker implements Callable<Void> {
final Path regionDir;
@@ -398,8 +381,8 @@ public class HFileCorruptionChecker {
}
/**
- * An individual work item for parallelized mob dir processing. This is
- * intentionally an inner class so it can use the shared error sets and fs.
+ * An individual work item for parallelized mob dir processing. This is intentionally an inner
+ * class so it can use the shared error sets and fs.
*/
private class MobRegionDirChecker extends RegionDirChecker {
@@ -434,73 +417,57 @@ public class HFileCorruptionChecker {
}
}
- /**
- * @return the set of check failure file paths after checkTables is called.
- */
+ /** Returns the set of check failure file paths after checkTables is called. */
public Collection<Path> getFailures() {
return new HashSet<>(failures);
}
- /**
- * @return the set of corrupted file paths after checkTables is called.
- */
+ /** Returns the set of corrupted file paths after checkTables is called. */
public Collection<Path> getCorrupted() {
return new HashSet<>(corrupted);
}
- /**
- * @return number of hfiles checked in the last HfileCorruptionChecker run
- */
+ /** Returns number of hfiles checked in the last HfileCorruptionChecker run */
public int getHFilesChecked() {
return hfilesChecked.get();
}
- /**
- * @return the set of successfully quarantined paths after checkTables is called.
- */
+ /** Returns the set of successfully quarantined paths after checkTables is called. */
public Collection<Path> getQuarantined() {
return new HashSet<>(quarantined);
}
/**
- * @return the set of paths that were missing. Likely due to deletion/moves from
- * compaction or flushes.
+ * @return the set of paths that were missing. Likely due to deletion/moves from compaction or
+ * flushes.
*/
public Collection<Path> getMissing() {
return new HashSet<>(missing);
}
- /**
- * @return the set of check failure mob file paths after checkTables is called.
- */
+ /** Returns the set of check failure mob file paths after checkTables is called. */
public Collection<Path> getFailureMobFiles() {
return new HashSet<>(failureMobFiles);
}
- /**
- * @return the set of corrupted mob file paths after checkTables is called.
- */
+ /** Returns the set of corrupted mob file paths after checkTables is called. */
public Collection<Path> getCorruptedMobFiles() {
return new HashSet<>(corruptedMobFiles);
}
- /**
- * @return number of mob files checked in the last HfileCorruptionChecker run
- */
+ /** Returns number of mob files checked in the last HfileCorruptionChecker run */
public int getMobFilesChecked() {
return mobFilesChecked.get();
}
- /**
- * @return the set of successfully quarantined paths after checkTables is called.
- */
+ /** Returns the set of successfully quarantined paths after checkTables is called. */
public Collection<Path> getQuarantinedMobFiles() {
return new HashSet<>(quarantinedMobFiles);
}
/**
- * @return the set of paths that were missing. Likely due to table deletion or deletion/moves
- * from compaction.
+ * @return the set of paths that were missing. Likely due to table deletion or deletion/moves from
+ * compaction.
*/
public Collection<Path> getMissedMobFiles() {
return new HashSet<>(missedMobFiles);
@@ -528,8 +495,7 @@ public class HFileCorruptionChecker {
}
String initialState = (corrupted.isEmpty()) ? "OK" : "CORRUPTED";
- String fixedState = (corrupted.size() == quarantined.size()) ? "OK"
- : "CORRUPTED";
+ String fixedState = (corrupted.size() == quarantined.size()) ? "OK" : "CORRUPTED";
if (inQuarantineMode) {
out.print("HFile Summary: " + initialState + " => " + fixedState);
@@ -555,8 +521,8 @@ public class HFileCorruptionChecker {
out.print(" " + mq);
}
String initialMobState = (corruptedMobFiles.isEmpty()) ? "OK" : "CORRUPTED";
- String fixedMobState = (corruptedMobFiles.size() == quarantinedMobFiles.size()) ? "OK"
- : "CORRUPTED";
+ String fixedMobState =
+ (corruptedMobFiles.size() == quarantinedMobFiles.size()) ? "OK" : "CORRUPTED";
if (inQuarantineMode) {
out.print("MOB summary: " + initialMobState + " => " + fixedMobState);
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/OfflineMetaRepair.java b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/OfflineMetaRepair.java
index d945194..98e9a35 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/OfflineMetaRepair.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/OfflineMetaRepair.java
@@ -18,31 +18,27 @@
package org.apache.hbase.hbck1;
import java.io.IOException;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.io.MultipleIOException;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This code is used to rebuild meta offline from metadata hbase drops into the
- * filesystem. If there are any problem detected, it will fail suggesting actions
- * for the user to "fix" problems. If it succeeds, it will backup the previous
- * hbase:meta and write new tables in place.
- *
- * <p>This is an advanced feature, so is only exposed for use if explicitly
- * mentioned.
- *
- * <p>It came from hbck1 retains same class name and arguments (though it has
- * been moved to a different package)</p>
- *
- *
- * <p>Run the below to see options. Passing no argument will set the tool
- * running trying to effect a repair so pass '-h' to see output:
+ * This code is used to rebuild meta offline from metadata hbase drops into the filesystem. If there
+ * are any problem detected, it will fail suggesting actions for the user to "fix" problems. If it
+ * succeeds, it will backup the previous hbase:meta and write new tables in place.
+ * <p>
+ * This is an advanced feature, so is only exposed for use if explicitly mentioned.
+ * <p>
+ * It came from hbck1 retains same class name and arguments (though it has been moved to a different
+ * package)
+ * </p>
+ * <p>
+ * Run the below to see options. Passing no argument will set the tool running trying to effect a
+ * repair so pass '-h' to see output:
* <code>$ hbase org.apache.hbase.hbck1.OfflineMetaRepair ...</code>
*/
public final class OfflineMetaRepair {
@@ -51,16 +47,16 @@ public final class OfflineMetaRepair {
/**
* Hide constructor.
*/
- private OfflineMetaRepair() {}
+ private OfflineMetaRepair() {
+ }
protected static void printUsageAndExit() {
StringBuilder sb = new StringBuilder();
- sb.append("Usage: OfflineMetaRepair [opts]\n").
- append("Where [opts] are:\n").
- append(" -details report of all regions before hbase:meta rebuild.\n").
- append(" -base <hdfs://> Base HBase Data directory to read from.\n").
- append(" -sidelineDir <hdfs://> path of where to backup existing hbase:meta.\n").
- append("Master should be down (Script runs regardless!)");
+ sb.append("Usage: OfflineMetaRepair [opts]\n").append("Where [opts] are:\n")
+ .append(" -details report of all regions before hbase:meta rebuild.\n")
+ .append(" -base <hdfs://> Base HBase Data directory to read from.\n")
+ .append(" -sidelineDir <hdfs://> path of where to backup existing hbase:meta.\n")
+ .append("Master should be down (Script runs regardless!)");
System.err.println(sb.toString());
Runtime.getRuntime().exit(-2);
}
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/ReplicationChecker.java b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/ReplicationChecker.java
index 4613d9d..d329bf2 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/ReplicationChecker.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/ReplicationChecker.java
@@ -36,9 +36,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Check and fix undeleted replication queues for removed peerId.
- *
- * Copied over wholesale from hbase. Unaltered except for package and imports.
+ * Check and fix undeleted replication queues for removed peerId. Copied over wholesale from hbase.
+ * Unaltered except for package and imports.
*/
@InterfaceAudience.Private
public class ReplicationChecker {
@@ -55,7 +54,7 @@ public class ReplicationChecker {
private final ReplicationQueueStorage queueStorage;
public ReplicationChecker(Configuration conf, ZKWatcher zkw,
- HBaseFsck.ErrorReporter errorReporter) {
+ HBaseFsck.ErrorReporter errorReporter) {
this.peerStorage = ReplicationStorageFactory.getReplicationPeerStorage(zkw, conf);
this.queueStorage = ReplicationStorageFactory.getReplicationQueueStorage(zkw, conf);
this.errorReporter = errorReporter;
@@ -63,7 +62,7 @@ public class ReplicationChecker {
public boolean hasUnDeletedQueues() {
return errorReporter.getErrorList()
- .contains(HBaseFsck.ErrorReporter.ERROR_CODE.UNDELETED_REPLICATION_QUEUE);
+ .contains(HBaseFsck.ErrorReporter.ERROR_CODE.UNDELETED_REPLICATION_QUEUE);
}
private Map<ServerName, List<String>> getUnDeletedQueues() throws ReplicationException {
@@ -75,8 +74,8 @@ public class ReplicationChecker {
if (!peerIds.contains(queueInfo.getPeerId())) {
undeletedQueues.computeIfAbsent(replicator, key -> new ArrayList<>()).add(queueId);
LOG.debug(
- "Undeleted replication queue for removed peer found: " +
- "[removedPeerId={}, replicator={}, queueId={}]",
+ "Undeleted replication queue for removed peer found: "
+ + "[removedPeerId={}, replicator={}, queueId={}]",
queueInfo.getPeerId(), replicator, queueId);
}
}
@@ -102,8 +101,8 @@ public class ReplicationChecker {
undeletedQueueIds.forEach((replicator, queueIds) -> {
queueIds.forEach(queueId -> {
ReplicationQueueInfo queueInfo = new ReplicationQueueInfo(queueId);
- String msg = "Undeleted replication queue for removed peer found: " +
- String.format("[removedPeerId=%s, replicator=%s, queueId=%s]", queueInfo.getPeerId(),
+ String msg = "Undeleted replication queue for removed peer found: "
+ + String.format("[removedPeerId=%s, replicator=%s, queueId=%s]", queueInfo.getPeerId(),
replicator, queueId);
errorReporter.reportError(HBaseFsck.ErrorReporter.ERROR_CODE.UNDELETED_REPLICATION_QUEUE,
msg);
@@ -111,10 +110,9 @@ public class ReplicationChecker {
});
undeletedHFileRefsPeerIds = getUndeletedHFileRefsPeers();
undeletedHFileRefsPeerIds.stream()
- .map(
- peerId -> "Undeleted replication hfile-refs queue for removed peer " + peerId + " found")
- .forEach(msg -> errorReporter
- .reportError(HBaseFsck.ErrorReporter.ERROR_CODE.UNDELETED_REPLICATION_QUEUE, msg));
+ .map(peerId -> "Undeleted replication hfile-refs queue for removed peer " + peerId + " found")
+ .forEach(msg -> errorReporter
+ .reportError(HBaseFsck.ErrorReporter.ERROR_CODE.UNDELETED_REPLICATION_QUEUE, msg));
}
public void fixUnDeletedQueues() throws ReplicationException {
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/TableIntegrityErrorHandler.java b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/TableIntegrityErrorHandler.java
index 2d699fa..9df64dd 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/TableIntegrityErrorHandler.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/TableIntegrityErrorHandler.java
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.hbase.hbck1;
import java.io.IOException;
@@ -23,12 +22,10 @@ import java.util.Collection;
import org.apache.yetus.audience.InterfaceAudience;
/**
- * This interface provides callbacks for handling particular table integrity
- * invariant violations. This could probably be boiled down to handling holes
- * and handling overlaps but currently preserves the older more specific error
- * condition codes.
- *
- * Copied over wholesale from hbase. Unaltered except for package and imports.
+ * This interface provides callbacks for handling particular table integrity invariant violations.
+ * This could probably be boiled down to handling holes and handling overlaps but currently
+ * preserves the older more specific error condition codes. Copied over wholesale from hbase.
+ * Unaltered except for package and imports.
*/
@InterfaceAudience.Private
public interface TableIntegrityErrorHandler {
@@ -41,66 +38,57 @@ public interface TableIntegrityErrorHandler {
void setTableInfo(HBaseFsck.TableInfo ti);
/**
- * Callback for handling case where a Table has a first region that does not
- * have an empty start key.
- *
- * @param hi An HbckInfo of the second region in a table. This should have
- * a non-empty startkey, and can be used to fabricate a first region that
- * has an empty start key.
+ * Callback for handling case where a Table has a first region that does not have an empty start
+ * key.
+ * @param hi An HbckInfo of the second region in a table. This should have a non-empty startkey,
+ * and can be used to fabricate a first region that has an empty start key.
*/
void handleRegionStartKeyNotEmpty(HBaseFsck.HbckInfo hi) throws IOException;
/**
- * Callback for handling case where a Table has a last region that does not
- * have an empty end key.
- *
- * @param curEndKey The end key of the current last region. There should be a new region
- * with start key as this and an empty end key.
+ * Callback for handling case where a Table has a last region that does not have an empty end key.
+ * @param curEndKey The end key of the current last region. There should be a new region with
+ * start key as this and an empty end key.
*/
void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException;
/**
* Callback for handling a region that has the same start and end key.
- *
* @param hi An HbckInfo for a degenerate key.
*/
void handleDegenerateRegion(HBaseFsck.HbckInfo hi) throws IOException;
/**
- * Callback for handling two regions that have the same start key. This is
- * a specific case of a region overlap.
+ * Callback for handling two regions that have the same start key. This is a specific case of a
+ * region overlap.
* @param hi1 one of the overlapping HbckInfo
* @param hi2 the other overlapping HbckInfo
*/
void handleDuplicateStartKeys(HBaseFsck.HbckInfo hi1, HBaseFsck.HbckInfo hi2) throws IOException;
/**
- * Callback for handling two regions that have the same regionID
- * a specific case of a split
+ * Callback for handling two regions that have the same regionID a specific case of a split
* @param hi1 one of the overlapping HbckInfo
* @param hi2 the other overlapping HbckInfo
*/
void handleSplit(HBaseFsck.HbckInfo hi1, HBaseFsck.HbckInfo hi2) throws IOException;
/**
- * Callback for handling two reigons that overlap in some arbitrary way.
- * This is a specific case of region overlap, and called for each possible
- * pair. If two regions have the same start key, the handleDuplicateStartKeys
- * method is called.
+ * Callback for handling two reigons that overlap in some arbitrary way. This is a specific case
+ * of region overlap, and called for each possible pair. If two regions have the same start key,
+ * the handleDuplicateStartKeys method is called.
* @param hi1 one of the overlapping HbckInfo
* @param hi2 the other overlapping HbckInfo
*/
void handleOverlapInRegionChain(HBaseFsck.HbckInfo hi1, HBaseFsck.HbckInfo hi2)
- throws IOException;
+ throws IOException;
/**
* Callback for handling a region hole between two keys.
* @param holeStartKey key at the beginning of the region hole
- * @param holeEndKey key at the end of the region hole
-
+ * @param holeEndKey key at the end of the region hole
*/
- void handleHoleInRegionChain(byte[] holeStartKey, byte[] holeEndKey)
- throws IOException;
+ void handleHoleInRegionChain(byte[] holeStartKey, byte[] holeEndKey) throws IOException;
/**
* Callback for handling an group of regions that overlap.
diff --git a/hbase-hbck2/src/test/java/org/apache/hbase/TestFsRegionsMetaRecoverer.java b/hbase-hbck2/src/test/java/org/apache/hbase/TestFsRegionsMetaRecoverer.java
index 68101a6..b77c775 100644
--- a/hbase-hbck2/src/test/java/org/apache/hbase/TestFsRegionsMetaRecoverer.java
+++ b/hbase-hbck2/src/test/java/org/apache/hbase/TestFsRegionsMetaRecoverer.java
@@ -26,7 +26,6 @@ import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSInputStream;
@@ -51,7 +50,6 @@ import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.master.RegionState;
import org.apache.hadoop.hbase.util.Bytes;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -82,61 +80,52 @@ public class TestFsRegionsMetaRecoverer {
this.fixer = new FsRegionsMetaRecoverer(config, mockedConnection, mockedFileSystem);
}
- private RegionInfo createRegionInfo(String table){
+ private RegionInfo createRegionInfo(String table) {
long regionTS = System.currentTimeMillis();
- RegionInfo info = RegionInfoBuilder.newBuilder(TableName.valueOf(table))
- .setRegionId(regionTS)
- .build();
+ RegionInfo info =
+ RegionInfoBuilder.newBuilder(TableName.valueOf(table)).setRegionId(regionTS).build();
return info;
}
- private Cell createCellForRegionInfo(RegionInfo info){
- byte[] regionInfoValue = ProtobufUtil.prependPBMagic(ProtobufUtil.toRegionInfo(info)
- .toByteArray());
- Cell cell = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
- .setRow(info.getRegionName())
- .setFamily(Bytes.toBytes("info"))
- .setQualifier(Bytes.toBytes("regioninfo"))
- .setType(Cell.Type.Put)
- .setValue(regionInfoValue)
- .build();
+ private Cell createCellForRegionInfo(RegionInfo info) {
+ byte[] regionInfoValue =
+ ProtobufUtil.prependPBMagic(ProtobufUtil.toRegionInfo(info).toByteArray());
+ Cell cell = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setRow(info.getRegionName())
+ .setFamily(Bytes.toBytes("info")).setQualifier(Bytes.toBytes("regioninfo"))
+ .setType(Cell.Type.Put).setValue(regionInfoValue).build();
return cell;
}
- private Cell createCellForTableState(TableName tableName){
- Cell cell = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
- .setRow(tableName.getName())
- .setFamily(Bytes.toBytes("table"))
- .setQualifier(Bytes.toBytes("state"))
- .setType(Cell.Type.Put)
- .setValue(HBaseProtos.TableState.newBuilder()
- .setState(TableState.State.ENABLED.convert()).build().toByteArray())
+ private Cell createCellForTableState(TableName tableName) {
+ Cell cell = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setRow(tableName.getName())
+ .setFamily(Bytes.toBytes("table")).setQualifier(Bytes.toBytes("state")).setType(Cell.Type.Put)
+ .setValue(HBaseProtos.TableState.newBuilder().setState(TableState.State.ENABLED.convert())
+ .build().toByteArray())
.build();
return cell;
}
@Test
- public void testFindMissingRegionsInMETANoMissing() throws Exception {
+ public void testFindMissingRegionsInMETANoMissing() throws Exception {
createRegionInMetaAndFileSystem();
- assertEquals("Should had returned 0 missing regions",
- 0, fixer.findMissingRegionsInMETA("test-tbl").size());
+ assertEquals("Should had returned 0 missing regions", 0,
+ fixer.findMissingRegionsInMETA("test-tbl").size());
}
@Test
- public void testFindMissingRegionsInMETAOneMissing() throws Exception {
+ public void testFindMissingRegionsInMETAOneMissing() throws Exception {
ResultScanner mockedRS = Mockito.mock(ResultScanner.class);
when(this.mockedTable.getScanner(any(Scan.class))).thenReturn(mockedRS);
List<Cell> cells = new ArrayList<>();
Result result = Result.create(cells);
- when(mockedRS.next()).thenReturn(result,(Result)null);
- Path p = new Path(this.testTblDir+ "/182182182121");
- FileStatus status = new FileStatus(0, true, 0, 0,0, p);
+ when(mockedRS.next()).thenReturn(result, (Result) null);
+ Path p = new Path(this.testTblDir + "/182182182121");
+ FileStatus status = new FileStatus(0, true, 0, 0, 0, p);
when(mockedFileSystem.listStatus(new Path(this.testTblDir)))
- .thenReturn(new FileStatus[]{status});
+ .thenReturn(new FileStatus[] { status });
List<Path> missingRegions = fixer.findMissingRegionsInMETA("test-tbl");
- assertEquals("Should had returned 1 missing region",
- 1, missingRegions.size());
- assertEquals(p,missingRegions.get(0));
+ assertEquals("Should had returned 1 missing region", 1, missingRegions.size());
+ assertEquals(p, missingRegions.get(0));
}
@Test
@@ -144,57 +133,53 @@ public class TestFsRegionsMetaRecoverer {
RegionInfo info = this.createRegionInfo("test-tbl");
Path regionPath = new Path("/hbase/data/default/test-tbl/" + info.getEncodedName());
FSDataInputStream fis = new FSDataInputStream(new TestInputStreamSeekable(info));
- when(this.mockedFileSystem.open(new Path(regionPath, ".regioninfo")))
- .thenReturn(fis);
+ when(this.mockedFileSystem.open(new Path(regionPath, ".regioninfo"))).thenReturn(fis);
fixer.putRegionInfoFromHdfsInMeta(regionPath);
Mockito.verify(this.mockedConnection).getTable(TableName.META_TABLE_NAME);
ArgumentCaptor<Put> captor = ArgumentCaptor.forClass(Put.class);
Mockito.verify(this.mockedTable).put(captor.capture());
Put capturedPut = captor.getValue();
- List<Cell> cells = capturedPut.get(HConstants.CATALOG_FAMILY,
- HConstants.STATE_QUALIFIER);
+ List<Cell> cells = capturedPut.get(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER);
assertEquals(1, cells.size());
- String state = Bytes.toString(cells.get(0).getValueArray(),
- cells.get(0).getValueOffset(), cells.get(0).getValueLength());
+ String state = Bytes.toString(cells.get(0).getValueArray(), cells.get(0).getValueOffset(),
+ cells.get(0).getValueLength());
assertEquals(RegionState.State.valueOf(state), RegionState.State.CLOSED);
- cells = capturedPut.get(HConstants.CATALOG_FAMILY,
- HConstants.REGIONINFO_QUALIFIER);
- byte[] returnedInfo = Bytes.copy(cells.get(0).getValueArray(),
- cells.get(0).getValueOffset(), cells.get(0).getValueLength());
+ cells = capturedPut.get(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
+ byte[] returnedInfo = Bytes.copy(cells.get(0).getValueArray(), cells.get(0).getValueOffset(),
+ cells.get(0).getValueLength());
assertEquals(info, RegionInfo.parseFrom(returnedInfo));
}
@Test
- public void testReportTablesMissingRegionsOneMissing() throws Exception {
+ public void testReportTablesMissingRegionsOneMissing() throws Exception {
ResultScanner mockedRS = Mockito.mock(ResultScanner.class);
when(this.mockedTable.getScanner(any(Scan.class))).thenReturn(mockedRS);
List<Cell> cells = new ArrayList<>();
cells.add(createCellForTableState(TableName.valueOf("test-tbl")));
Result result = Result.create(cells);
- when(mockedRS.next()).thenReturn(result,(Result)null);
+ when(mockedRS.next()).thenReturn(result, (Result) null);
FileStatus status = new FileStatus();
- Path p = new Path(this.testTblDir+ "/182182182121");
+ Path p = new Path(this.testTblDir + "/182182182121");
status.setPath(p);
when(mockedFileSystem.listStatus(new Path(this.testTblDir)))
- .thenReturn(new FileStatus[]{status});
+ .thenReturn(new FileStatus[] { status });
Map<TableName, List<Path>> report = fixer.reportTablesMissingRegions(null);
- assertEquals("Should had returned 1 missing region",
- 1,report.size());
+ assertEquals("Should had returned 1 missing region", 1, report.size());
}
@Test
- public void testFindExtraRegionsInMETANoExtra() throws Exception {
+ public void testFindExtraRegionsInMETANoExtra() throws Exception {
createRegionInMetaAndFileSystem();
- assertEquals("Should had returned 0 extra regions",
- 0, fixer.findExtraRegionsInMETA("test-tbl").size());
+ assertEquals("Should had returned 0 extra regions", 0,
+ fixer.findExtraRegionsInMETA("test-tbl").size());
}
- private void createRegionInMetaAndFileSystem() throws Exception{
+ private void createRegionInMetaAndFileSystem() throws Exception {
RegionInfo info = createRegionInMeta(Mockito.mock(ResultScanner.class));
- FileStatus status = new FileStatus(0, true, 1,128,
- System.currentTimeMillis(), new Path(this.testTblDir + "/" + info.getEncodedName()));
+ FileStatus status = new FileStatus(0, true, 1, 128, System.currentTimeMillis(),
+ new Path(this.testTblDir + "/" + info.getEncodedName()));
when(mockedFileSystem.listStatus(new Path(this.testTblDir)))
- .thenReturn(new FileStatus[]{status});
+ .thenReturn(new FileStatus[] { status });
}
private RegionInfo createRegionInMeta(ResultScanner mockedRS) throws Exception {
@@ -203,17 +188,16 @@ public class TestFsRegionsMetaRecoverer {
List<Cell> cells = new ArrayList<>();
cells.add(createCellForRegionInfo(info));
Result result = Result.create(cells);
- when(mockedRS.next()).thenReturn(result,(Result)null);
+ when(mockedRS.next()).thenReturn(result, (Result) null);
return info;
}
@Test
- public void testFindExtraRegionsInMETAOneExtra() throws Exception {
+ public void testFindExtraRegionsInMETAOneExtra() throws Exception {
RegionInfo info = createRegionInMeta(Mockito.mock(ResultScanner.class));
List<HBCKMetaEntry> missingRegions = fixer.findExtraRegionsInMETA("test-tbl");
- assertEquals("Should had returned 1 extra region",
- 1, missingRegions.size());
- assertEquals(info.getEncodedName(),missingRegions.get(0).getEncodedRegionName());
+ assertEquals("Should had returned 1 extra region", 1, missingRegions.size());
+ assertEquals(info.getEncodedName(), missingRegions.get(0).getEncodedRegionName());
}
@Test
@@ -224,28 +208,25 @@ public class TestFsRegionsMetaRecoverer {
Result result = Result.create(cells);
ResultScanner mockedRsRegions = Mockito.mock(ResultScanner.class);
createRegionInMeta(mockedRsRegions);
- when(this.mockedTable.getScanner(any(Scan.class))).
- thenReturn(mockedRsTables).
- thenReturn(mockedRsRegions);
- when(mockedRsTables.next()).thenReturn(result,(Result)null);
+ when(this.mockedTable.getScanner(any(Scan.class))).thenReturn(mockedRsTables)
+ .thenReturn(mockedRsRegions);
+ when(mockedRsTables.next()).thenReturn(result, (Result) null);
List<String> tableList = new ArrayList<>();
tableList.add("default:test-tbl");
fixer.removeExtraRegionsFromMetaForTables(tableList);
Mockito.verify(this.mockedTable).delete(anyList());
}
-
@Test
- public void testReportTablesExtraRegionsOneExtra() throws Exception {
+ public void testReportTablesExtraRegionsOneExtra() throws Exception {
ResultScanner mockedRS = Mockito.mock(ResultScanner.class);
Mockito.when(this.mockedTable.getScanner(Mockito.any(Scan.class))).thenReturn(mockedRS);
List<Cell> cells = new ArrayList<>();
cells.add(createCellForTableState(TableName.valueOf("test-tbl")));
Result result = Result.create(cells);
- Mockito.when(mockedRS.next()).thenReturn(result,(Result)null);
+ Mockito.when(mockedRS.next()).thenReturn(result, (Result) null);
Map<TableName, List<HBCKMetaEntry>> report = fixer.reportTablesExtraRegions(null);
- assertEquals("Should had returned 1 extra region.",
- 1,report.size());
+ assertEquals("Should had returned 1 extra region.", 1, report.size());
}
private static final class TestInputStreamSeekable extends FSInputStream {
diff --git a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCK2.java b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCK2.java
index e795650..3cedc64 100644
--- a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCK2.java
+++ b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCK2.java
@@ -36,7 +36,6 @@ import java.util.Scanner;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
-
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
@@ -54,7 +53,6 @@ import org.apache.hadoop.hbase.master.RegionState;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.Threads;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -73,8 +71,8 @@ public class TestHBCK2 {
private static final Logger LOG = LoggerFactory.getLogger(TestHBCK2.class);
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static final TableName TABLE_NAME = TableName.valueOf(TestHBCK2.class.getSimpleName());
- private static final TableName REGION_STATES_TABLE_NAME = TableName.
- valueOf(TestHBCK2.class.getSimpleName() + "-REGIONS_STATES");
+ private static final TableName REGION_STATES_TABLE_NAME =
+ TableName.valueOf(TestHBCK2.class.getSimpleName() + "-REGIONS_STATES");
private final static String ASSIGNS = "assigns";
private static final String EXTRA_REGIONS_IN_META = "extraRegionsInMeta";
private final static String UNASSIGNS = "unassigns";
@@ -127,7 +125,7 @@ public class TestHBCK2 {
assertTrue("Found=" + state.getState(), state.isDisabled());
// Test the new method with arg list
- String[] args = new String[]{TABLE_NAME.getNameAsString(), "DISABLED"};
+ String[] args = new String[] { TABLE_NAME.getNameAsString(), "DISABLED" };
state = this.hbck2.setTableStateByArgs(hbck, args);
assertTrue("Found=" + state.getState(), state.isEnabled());
}
@@ -136,8 +134,8 @@ public class TestHBCK2 {
@Test
public void testSetTableStateWithInputFiles() throws IOException {
File testFile = new File(TEST_UTIL.getDataTestDir().toString(), "inputForSetTableTest");
- writeStringsToAFile(testFile, new String[]{TABLE_NAME.getNameAsString() + " DISABLED"});
- String result = testRunWithArgs(new String[]{SET_TABLE_STATE, "-i", testFile.toString()});
+ writeStringsToAFile(testFile, new String[] { TABLE_NAME.getNameAsString() + " DISABLED" });
+ String result = testRunWithArgs(new String[] { SET_TABLE_STATE, "-i", testFile.toString() });
assertTrue(result.contains("tableName=TestHBCK2, state=ENABLED"));
// Restore the state.
@@ -152,15 +150,15 @@ public class TestHBCK2 {
try (Admin admin = TEST_UTIL.getConnection().getAdmin()) {
List<RegionInfo> regions = admin.getRegions(TABLE_NAME);
for (RegionInfo ri : regions) {
- RegionState rs = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
- getRegionStates().getRegionState(ri.getEncodedName());
+ RegionState rs = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
+ .getRegionStates().getRegionState(ri.getEncodedName());
LOG.info("RS: {}", rs.toString());
}
String[] regionStrsArray =
- regions.stream().map(RegionInfo::getEncodedName).toArray(String[]::new);
+ regions.stream().map(RegionInfo::getEncodedName).toArray(String[]::new);
File testFile = new File(TEST_UTIL.getDataTestDir().toString(), "inputForUnAssignsTest");
writeStringsToAFile(testFile, regionStrsArray);
- String result = testRunWithArgs(new String[]{UNASSIGNS, "-i", testFile.toString()});
+ String result = testRunWithArgs(new String[] { UNASSIGNS, "-i", testFile.toString() });
validateRegionEndState(getPidsFromResult(result), regions, false);
}
}
@@ -170,20 +168,20 @@ public class TestHBCK2 {
try (Admin admin = TEST_UTIL.getConnection().getAdmin()) {
List<RegionInfo> regions = admin.getRegions(TABLE_NAME);
for (RegionInfo ri : regions) {
- RegionState rs = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
- getRegionStates().getRegionState(ri.getEncodedName());
+ RegionState rs = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
+ .getRegionStates().getRegionState(ri.getEncodedName());
LOG.info("RS: {}", rs.toString());
}
String[] regionStrsArray =
- regions.stream().map(RegionInfo::getEncodedName).toArray(String[]::new);
+ regions.stream().map(RegionInfo::getEncodedName).toArray(String[]::new);
try (ClusterConnection connection = this.hbck2.connect(); Hbck hbck = connection.getHbck()) {
unassigns(regions, regionStrsArray);
List<Long> pids = this.hbck2.assigns(hbck, regionStrsArray);
validateRegionEndState(pids, regions, true);
// What happens if crappy region list passed?
- pids = this.hbck2.assigns(hbck, Arrays.stream(new String[]{"a", "some rubbish name"}).
- collect(Collectors.toList()).toArray(new String[]{}));
+ pids = this.hbck2.assigns(hbck, Arrays.stream(new String[] { "a", "some rubbish name" })
+ .collect(Collectors.toList()).toArray(new String[] {}));
for (long pid : pids) {
assertEquals(org.apache.hadoop.hbase.procedure2.Procedure.NO_PROC_ID, pid);
}
@@ -192,7 +190,7 @@ public class TestHBCK2 {
unassigns(regions, regionStrsArray);
File testFile = new File(TEST_UTIL.getDataTestDir().toString(), "inputForAssignsTest");
writeStringsToAFile(testFile, regionStrsArray);
- String result = testRunWithArgs(new String[]{ASSIGNS, "-i", testFile.toString()});
+ String result = testRunWithArgs(new String[] { ASSIGNS, "-i", testFile.toString() });
validateRegionEndState(getPidsFromResult(result), regions, true);
// Test multiple input files
@@ -201,12 +199,12 @@ public class TestHBCK2 {
params.add(ASSIGNS);
params.add("-i");
for (String regionStr : regionStrsArray) {
- File tempTestFile = new File(TEST_UTIL.getDataTestDir().toString(),
- "inputForAssignsTest-" + regionStr);
- writeStringsToAFile(tempTestFile, new String[]{regionStr});
+ File tempTestFile =
+ new File(TEST_UTIL.getDataTestDir().toString(), "inputForAssignsTest-" + regionStr);
+ writeStringsToAFile(tempTestFile, new String[] { regionStr });
params.add(tempTestFile.toString());
}
- result = testRunWithArgs(params.toArray(new String[]{}));
+ result = testRunWithArgs(params.toArray(new String[] {}));
validateRegionEndState(getPidsFromResult(result), regions, true);
}
}
@@ -237,7 +235,7 @@ public class TestHBCK2 {
RegionInfo info = regions.get(0);
assertEquals(RegionState.State.OPEN, getCurrentRegionState(info));
String region = info.getEncodedName();
- String[] args = new String[]{region, "0", "CLOSING"};
+ String[] args = new String[] { region, "0", "CLOSING" };
try (ClusterConnection connection = this.hbck2.connect()) {
this.hbck2.setRegionStateByArgs(connection, args);
}
@@ -262,7 +260,7 @@ public class TestHBCK2 {
File testFile = new File(TEST_UTIL.getDataTestDir().toString(), "inputForSetRegionStateTest");
writeStringsToAFile(testFile, input);
- testRunWithArgs(new String[]{SET_REGION_STATE, "-i", testFile.toString()});
+ testRunWithArgs(new String[] { SET_REGION_STATE, "-i", testFile.toString() });
for (RegionInfo info : regions) {
assertEquals(RegionState.State.CLOSING, getCurrentRegionState(info));
@@ -288,7 +286,7 @@ public class TestHBCK2 {
String primaryRegion = primaryRegionInfo.getEncodedName();
try (ClusterConnection connection = this.hbck2.connect()) {
this.hbck2.setRegionState(connection, primaryRegion, regions.get(1).getReplicaId(),
- RegionState.State.CLOSING);
+ RegionState.State.CLOSING);
}
assertEquals(RegionState.State.CLOSING, getCurrentRegionState(primaryRegionInfo, replicaId));
} finally {
@@ -299,8 +297,8 @@ public class TestHBCK2 {
@Test
public void testSetRegionStateInvalidRegion() throws IOException {
try (ClusterConnection connection = this.hbck2.connect()) {
- assertEquals(HBCK2.EXIT_FAILURE, this.hbck2.setRegionState(connection, "NO_REGION",
- RegionState.State.CLOSING));
+ assertEquals(HBCK2.EXIT_FAILURE,
+ this.hbck2.setRegionState(connection, "NO_REGION", RegionState.State.CLOSING));
}
}
@@ -333,29 +331,27 @@ public class TestHBCK2 {
@Test
public void testReportMissingRegionsInMetaAllNsTbls() throws Exception {
String[] nullArgs = null;
- this.testReportMissingRegionsInMeta(5, 5,
- nullArgs);
+ this.testReportMissingRegionsInMeta(5, 5, nullArgs);
}
@Test
public void testReportMissingRegionsInMetaSpecificTbl() throws Exception {
- this.testReportMissingRegionsInMeta(5, 5,
- TABLE_NAME.getNameWithNamespaceInclAsString());
+ this.testReportMissingRegionsInMeta(5, 5, TABLE_NAME.getNameWithNamespaceInclAsString());
}
@Test
public void testReportMissingRegionsInMetaSpecificTblAndNsTbl() throws Exception {
- this.testReportMissingRegionsInMeta(5, 5,
- TABLE_NAME.getNameWithNamespaceInclAsString(), "hbase:namespace");
+ this.testReportMissingRegionsInMeta(5, 5, TABLE_NAME.getNameWithNamespaceInclAsString(),
+ "hbase:namespace");
}
@Test
public void testReportMissingRegionsInMetaSpecificTblAndNsTblAlsoMissing() throws Exception {
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), TableName.valueOf("hbase:namespace"));
+ List<RegionInfo> regions = HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(),
+ TableName.valueOf("hbase:namespace"));
HBCKMetaTableAccessor.deleteRegionInfo(TEST_UTIL.getConnection(), regions.get(0));
- this.testReportMissingRegionsInMeta(5, 6,
- TABLE_NAME.getNameWithNamespaceInclAsString(), "hbase:namespace");
+ this.testReportMissingRegionsInMeta(5, 6, TABLE_NAME.getNameWithNamespaceInclAsString(),
+ "hbase:namespace");
}
@Test
@@ -372,18 +368,18 @@ public class TestHBCK2 {
@Test
public void testFormatReportMissingInMetaOneMissing() throws IOException {
TableName tableName = createTestTable(5);
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), tableName);
+ List<RegionInfo> regions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName);
HBCKMetaTableAccessor.deleteRegionInfo(TEST_UTIL.getConnection(), regions.get(0));
String expectedResult = "Missing Regions for each table:\n";
String result = testFormatMissingRegionsInMetaReport();
- //validates initial report message
+ // validates initial report message
assertTrue(result.contains(expectedResult));
- //validates our test table region is reported missing
- expectedResult = "\t" + tableName.getNameAsString() + "->\n\t\t"
- + regions.get(0).getEncodedName();
+ // validates our test table region is reported missing
+ expectedResult =
+ "\t" + tableName.getNameAsString() + "->\n\t\t" + regions.get(0).getEncodedName();
assertTrue(result.contains(expectedResult));
- //validates namespace region is not reported missing
+ // validates namespace region is not reported missing
expectedResult = "\n\thbase:namespace -> No mismatching regions. This table is good!\n\t";
assertTrue(result.contains(expectedResult));
}
@@ -412,26 +408,24 @@ public class TestHBCK2 {
waitOnPids(pids);
}
for (RegionInfo ri : regions) {
- RegionState rs = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
- getRegionStates().getRegionState(ri.getEncodedName());
+ RegionState rs = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
+ .getRegionStates().getRegionState(ri.getEncodedName());
LOG.info("RS: {}", rs.toString());
assertTrue(rs.toString(), rs.isClosed());
}
}
-
private void validateRegionEndState(List<Long> pids, List<RegionInfo> regions, boolean open) {
waitOnPids(pids);
for (RegionInfo ri : regions) {
- RegionState rs = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
- getRegionStates().getRegionState(ri.getEncodedName());
+ RegionState rs = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
+ .getRegionStates().getRegionState(ri.getEncodedName());
LOG.info("RS: {}", rs.toString());
assertTrue(rs.toString(), open ? rs.isOpened() : rs.isClosed());
}
}
- private String testFormatMissingRegionsInMetaReport()
- throws IOException {
+ private String testFormatMissingRegionsInMetaReport() throws IOException {
HBCK2 hbck = new HBCK2(TEST_UTIL.getConfiguration());
final StringBuilder builder = new StringBuilder();
PrintStream originalOS = System.out;
@@ -443,7 +437,7 @@ public class TestHBCK2 {
};
System.setOut(new PrintStream(testOS));
- hbck.run(new String[]{"reportMissingRegionsInMeta"});
+ hbck.run(new String[] { "reportMissingRegionsInMeta" });
System.setOut(originalOS);
return builder.toString();
}
@@ -455,18 +449,18 @@ public class TestHBCK2 {
}
private void testAddMissingRegionsInMetaForTables(int missingRegions, int totalRegions)
- throws Exception {
+ throws Exception {
TableName tableName = createTestTable(totalRegions);
HBCK2 hbck = new HBCK2(TEST_UTIL.getConfiguration());
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), tableName);
+ List<RegionInfo> regions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName);
Connection connection = TEST_UTIL.getConnection();
regions.subList(0, missingRegions).forEach(r -> deleteRegionInfo(connection, r));
int remaining = totalRegions - missingRegions;
assertEquals("Table should have " + remaining + " regions in META.", remaining,
- HBCKMetaTableAccessor.getRegionCount(TEST_UTIL.getConnection(), tableName));
- List<Future<List<String>>> result = hbck.addMissingRegionsInMetaForTables("default:" +
- tableName.getNameAsString());
+ HBCKMetaTableAccessor.getRegionCount(TEST_UTIL.getConnection(), tableName));
+ List<Future<List<String>>> result =
+ hbck.addMissingRegionsInMetaForTables("default:" + tableName.getNameAsString());
Integer total = result.stream().map(f -> {
try {
@@ -478,24 +472,24 @@ public class TestHBCK2 {
}).reduce(0, Integer::sum);
assertEquals(missingRegions, total.intValue());
assertEquals("Table regions should had been re-added in META.", totalRegions,
- HBCKMetaTableAccessor.getRegionCount(TEST_UTIL.getConnection(), tableName));
- //compare the added regions to make sure those are the same
- List<RegionInfo> newRegions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), tableName);
+ HBCKMetaTableAccessor.getRegionCount(TEST_UTIL.getConnection(), tableName));
+ // compare the added regions to make sure those are the same
+ List<RegionInfo> newRegions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName);
assertEquals("All re-added regions should be the same", regions, newRegions);
}
private void testReportMissingRegionsInMeta(int missingRegionsInTestTbl,
- int expectedTotalMissingRegions, String... namespaceOrTable) throws Exception {
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), TABLE_NAME);
+ int expectedTotalMissingRegions, String... namespaceOrTable) throws Exception {
+ List<RegionInfo> regions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), TABLE_NAME);
Connection connection = TEST_UTIL.getConnection();
regions.subList(0, missingRegionsInTestTbl).forEach(r -> deleteRegionInfo(connection, r));
HBCK2 hbck = new HBCK2(TEST_UTIL.getConfiguration());
final Map<TableName, List<Path>> report =
- hbck.reportTablesWithMissingRegionsInMeta(namespaceOrTable);
- long resultingMissingRegions = report.keySet().stream().mapToLong(nsTbl ->
- report.get(nsTbl).size()).sum();
+ hbck.reportTablesWithMissingRegionsInMeta(namespaceOrTable);
+ long resultingMissingRegions =
+ report.keySet().stream().mapToLong(nsTbl -> report.get(nsTbl).size()).sum();
assertEquals(expectedTotalMissingRegions, resultingMissingRegions);
String[] nullArgs = null;
hbck.addMissingRegionsInMetaForTables(nullArgs);
@@ -513,30 +507,31 @@ public class TestHBCK2 {
Get get = new Get(regionInfo.getRegionName());
get.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER);
Result result = metaTable.get(get);
- byte[] currentStateValue = result.getValue(HConstants.CATALOG_FAMILY,
- HConstants.STATE_QUALIFIER);
- return currentStateValue != null ?
- RegionState.State.valueOf(Bytes.toString(currentStateValue))
- : null;
+ byte[] currentStateValue =
+ result.getValue(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER);
+ return currentStateValue != null
+ ? RegionState.State.valueOf(Bytes.toString(currentStateValue))
+ : null;
}
private RegionState.State getCurrentRegionState(RegionInfo primary, int replicaId)
- throws IOException {
+ throws IOException {
Table metaTable = TEST_UTIL.getConnection().getTable(TableName.valueOf("hbase:meta"));
Get get = new Get(primary.getRegionName());
get.addColumn(HConstants.CATALOG_FAMILY, HBCK2.getRegionStateColumn(replicaId));
Result result = metaTable.get(get);
- byte[] currentStateValue = result.getValue(HConstants.CATALOG_FAMILY,
- HBCK2.getRegionStateColumn(replicaId));
- return currentStateValue != null ?
- RegionState.State.valueOf(Bytes.toString(currentStateValue))
- : null;
+ byte[] currentStateValue =
+ result.getValue(HConstants.CATALOG_FAMILY, HBCK2.getRegionStateColumn(replicaId));
+ return currentStateValue != null
+ ? RegionState.State.valueOf(Bytes.toString(currentStateValue))
+ : null;
}
private void waitOnPids(List<Long> pids) {
for (Long pid : pids) {
- while (!TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().
- isFinished(pid)) {
+ while (
+ !TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().isFinished(pid)
+ ) {
Threads.sleep(100);
}
}
@@ -568,31 +563,28 @@ public class TestHBCK2 {
@Test
public void testReportExtraRegionsInMetaAllNsTbls() throws Exception {
String[] nullArgs = null;
- this.testReportExtraRegionsInMeta(5, 5,
- nullArgs);
+ this.testReportExtraRegionsInMeta(5, 5, nullArgs);
}
@Test
public void testReportExtraRegionsInMetaSpecificTbl() throws Exception {
- this.testReportExtraRegionsInMeta(5, 5,
- TABLE_NAME.getNameWithNamespaceInclAsString());
+ this.testReportExtraRegionsInMeta(5, 5, TABLE_NAME.getNameWithNamespaceInclAsString());
}
@Test
public void testReportExtraRegionsInMetaSpecificTblAndNsTbl() throws Exception {
- this.testReportExtraRegionsInMeta(5, 5,
- TABLE_NAME.getNameWithNamespaceInclAsString(), "hbase:namespace");
+ this.testReportExtraRegionsInMeta(5, 5, TABLE_NAME.getNameWithNamespaceInclAsString(),
+ "hbase:namespace");
}
@Test
public void testReportExtraRegionsInMetaSpecificTblAndNsTblAlsoExtra() throws Exception {
TableName tableName = createTestTable(5);
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), tableName);
+ List<RegionInfo> regions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName);
deleteRegionDir(tableName, regions.get(0).getEncodedName());
- this.testReportExtraRegionsInMeta(5, 6,
- TABLE_NAME.getNameWithNamespaceInclAsString(),
- tableName.getNameWithNamespaceInclAsString());
+ this.testReportExtraRegionsInMeta(5, 6, TABLE_NAME.getNameWithNamespaceInclAsString(),
+ tableName.getNameWithNamespaceInclAsString());
}
@Test
@@ -609,18 +601,18 @@ public class TestHBCK2 {
@Test
public void testFormatReportExtraInMetaOneExtra() throws IOException {
TableName tableName = createTestTable(5);
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), tableName);
+ List<RegionInfo> regions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName);
deleteRegionDir(tableName, regions.get(0).getEncodedName());
String expectedResult = "Regions in Meta but having no equivalent dir, for each table:\n";
String result = testFormatExtraRegionsInMetaReport();
- //validates initial report message
+ // validates initial report message
assertTrue(result.contains(expectedResult));
- //validates our test table region is reported as extra
- expectedResult = "\t" + tableName.getNameAsString() + "->\n\t\t"
- + regions.get(0).getEncodedName();
+ // validates our test table region is reported as extra
+ expectedResult =
+ "\t" + tableName.getNameAsString() + "->\n\t\t" + regions.get(0).getEncodedName();
assertTrue(result.contains(expectedResult));
- //validates namespace region is not reported missing
+ // validates namespace region is not reported missing
expectedResult = "\n\thbase:namespace -> No mismatching regions. This table is good!\n\t";
assertTrue(result.contains(expectedResult));
}
@@ -639,7 +631,7 @@ public class TestHBCK2 {
@Test
public void testFormatFixExtraRegionsInMetaNoExtraSpecifyTable() throws IOException {
final String expectedResult = "Regions in Meta but having no equivalent dir, for each table:\n"
- + "\thbase:namespace -> No mismatching regions. This table is good!\n\t";
+ + "\thbase:namespace -> No mismatching regions. This table is good!\n\t";
String result = testFormatExtraRegionsInMetaFix("hbase:namespace");
assertTrue(result.contains(expectedResult));
}
@@ -647,18 +639,18 @@ public class TestHBCK2 {
@Test
public void testFormatFixExtraInMetaOneExtra() throws IOException {
TableName tableName = createTestTable(5);
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), tableName);
+ List<RegionInfo> regions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName);
deleteRegionDir(tableName, regions.get(0).getEncodedName());
String expectedResult = "Regions in Meta but having no equivalent dir, for each table:\n";
String result = testFormatExtraRegionsInMetaFix(null);
- //validates initial execute message
+ // validates initial execute message
assertTrue(result.contains(expectedResult));
- //validates our test table region is reported as extra
- expectedResult = "\t" + tableName.getNameAsString() + "->\n\t\t"
- + regions.get(0).getEncodedName();
+ // validates our test table region is reported as extra
+ expectedResult =
+ "\t" + tableName.getNameAsString() + "->\n\t\t" + regions.get(0).getEncodedName();
assertTrue(result.contains(expectedResult));
- //validates namespace region is not reported missing
+ // validates namespace region is not reported missing
expectedResult = "\n\thbase:namespace -> No mismatching regions. This table is good!\n\t";
assertTrue(result.contains(expectedResult));
}
@@ -666,18 +658,18 @@ public class TestHBCK2 {
@Test
public void testFormatFixExtraInMetaOneExtraSpecificTable() throws IOException {
TableName tableName = createTestTable(5);
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), tableName);
+ List<RegionInfo> regions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName);
deleteRegionDir(tableName, regions.get(0).getEncodedName());
String expectedResult = "Regions in Meta but having no equivalent dir, for each table:\n";
String result = testFormatExtraRegionsInMetaFix(tableName.getNameWithNamespaceInclAsString());
- //validates initial execute message
+ // validates initial execute message
assertTrue(result.contains(expectedResult));
- //validates our test table region is reported as extra
- expectedResult = "\t" + tableName.getNameAsString() + "->\n\t\t"
- + regions.get(0).getEncodedName();
+ // validates our test table region is reported as extra
+ expectedResult =
+ "\t" + tableName.getNameAsString() + "->\n\t\t" + regions.get(0).getEncodedName();
assertTrue(result.contains(expectedResult));
- //validates namespace region is not reported missing
+ // validates namespace region is not reported missing
expectedResult = "\n\thbase:namespace -> No mismatching regions. This table is good!\n\t";
assertFalse("Should not contain: " + expectedResult, result.contains(expectedResult));
}
@@ -700,25 +692,26 @@ public class TestHBCK2 {
public void testRemoveExtraRegionWithoutInfo() throws Exception {
TableName tableName = createTestTable(5);
HBCK2 hbck = new HBCK2(TEST_UTIL.getConfiguration());
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), tableName);
+ List<RegionInfo> regions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName);
deleteRegionDir(tableName, regions.get(0).getEncodedName());
HBCKMetaTableAccessor.deleteRegionInfoColumn(TEST_UTIL.getConnection(), regions.get(0));
- assertEquals(1, hbck.extraRegionsInMeta(new String[]{"-f",
- "default:" + tableName.getNameAsString()}).get(tableName).size());
+ assertEquals(1,
+ hbck.extraRegionsInMeta(new String[] { "-f", "default:" + tableName.getNameAsString() })
+ .get(tableName).size());
assertEquals("Table regions should had been removed from META.", 4,
HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName).size());
}
private String testFormatExtraRegionsInMetaReport() throws IOException {
- return testRunWithArgs(new String[]{EXTRA_REGIONS_IN_META});
+ return testRunWithArgs(new String[] { EXTRA_REGIONS_IN_META });
}
private String testFormatExtraRegionsInMetaFix(String table) throws IOException {
if (table != null) {
- return testRunWithArgs(new String[]{EXTRA_REGIONS_IN_META, "-f", table});
+ return testRunWithArgs(new String[] { EXTRA_REGIONS_IN_META, "-f", table });
} else {
- return testRunWithArgs(new String[]{EXTRA_REGIONS_IN_META, "-f"});
+ return testRunWithArgs(new String[] { EXTRA_REGIONS_IN_META, "-f" });
}
}
@@ -739,38 +732,38 @@ public class TestHBCK2 {
}
private void testRemoveExtraRegionsInMetaForTables(int extraRegions, int totalRegions)
- throws Exception {
+ throws Exception {
TableName tableName = createTestTable(totalRegions);
HBCK2 hbck = new HBCK2(TEST_UTIL.getConfiguration());
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), tableName);
+ List<RegionInfo> regions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName);
regions.subList(0, extraRegions).forEach(r -> deleteRegionDir(tableName, r.getEncodedName()));
int remaining = totalRegions - extraRegions;
- assertEquals(extraRegions, hbck.extraRegionsInMeta(new String[]{"-f",
- "default:" + tableName.getNameAsString()}).get(tableName).size());
+ assertEquals(extraRegions,
+ hbck.extraRegionsInMeta(new String[] { "-f", "default:" + tableName.getNameAsString() })
+ .get(tableName).size());
assertEquals("Table regions should had been removed from META.", remaining,
- HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName).size());
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName).size());
}
private void testReportExtraRegionsInMeta(int extraRegionsInTestTbl,
- int expectedTotalExtraRegions, String... namespaceOrTable) throws Exception {
- List<RegionInfo> regions = HBCKMetaTableAccessor
- .getTableRegions(TEST_UTIL.getConnection(), TABLE_NAME);
- regions.subList(0, extraRegionsInTestTbl).forEach(r -> deleteRegionDir(TABLE_NAME,
- r.getEncodedName()));
+ int expectedTotalExtraRegions, String... namespaceOrTable) throws Exception {
+ List<RegionInfo> regions =
+ HBCKMetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), TABLE_NAME);
+ regions.subList(0, extraRegionsInTestTbl)
+ .forEach(r -> deleteRegionDir(TABLE_NAME, r.getEncodedName()));
HBCK2 hbck = new HBCK2(TEST_UTIL.getConfiguration());
- final Map<TableName, List<String>> report =
- hbck.extraRegionsInMeta(namespaceOrTable);
- long resultingExtraRegions = report.keySet().stream().mapToLong(nsTbl ->
- report.get(nsTbl).size()).sum();
+ final Map<TableName, List<String>> report = hbck.extraRegionsInMeta(namespaceOrTable);
+ long resultingExtraRegions =
+ report.keySet().stream().mapToLong(nsTbl -> report.get(nsTbl).size()).sum();
assertEquals(expectedTotalExtraRegions, resultingExtraRegions);
}
@Test
public void testByPassWithInputFiles() throws IOException {
File testFile = new File(TEST_UTIL.getDataTestDir().toString(), "inputForSetRegionStateTest");
- writeStringsToAFile(testFile, new String[]{"100568", "200568"});
- List<Boolean> result = this.hbck2.bypass(new String[]{"-i", testFile.toString()});
+ writeStringsToAFile(testFile, new String[] { "100568", "200568" });
+ List<Boolean> result = this.hbck2.bypass(new String[] { "-i", testFile.toString() });
assertNotNull(result);
assertEquals(result.size(), 2);
for (boolean rs : result) {
diff --git a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java
index 6dd3b91..adf720c 100644
--- a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java
+++ b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java
@@ -31,12 +31,12 @@ import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.util.Properties;
-
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+
/**
* Does command-line parsing tests. No clusters.
* @see TestHBCK2 for cluster-tests.
@@ -70,39 +70,39 @@ public class TestHBCKCommandLineParsing {
assertTrue(output, output.startsWith("usage: HBCK2"));
// Passing -h/--help does the same
- output = retrieveOptionOutput(new String[]{"-h"});
+ output = retrieveOptionOutput(new String[] { "-h" });
assertTrue(output, output.startsWith("usage: HBCK2"));
}
@Test
- public void testErrorMessage() throws IOException{
+ public void testErrorMessage() throws IOException {
// just chose some of the commands to test for
- String[] cmds = new String[]{"setTableState", "bypass", "scheduleRecoveries"};
+ String[] cmds = new String[] { "setTableState", "bypass", "scheduleRecoveries" };
String output;
- for(String cmd: cmds){
- output = retrieveOptionOutput(new String[]{cmd});
+ for (String cmd : cmds) {
+ output = retrieveOptionOutput(new String[] { cmd });
assertTrue(output, output.startsWith("ERROR: "));
assertTrue(output, output.contains("FOR USAGE, use the -h or --help option"));
}
}
- @Test (expected=NumberFormatException.class)
+ @Test(expected = NumberFormatException.class)
public void testCommandWithOptions() throws IOException {
// The 'x' below should cause the NumberFormatException. The Options should all be good.
- this.hbck2.run(new String[]{"bypass", "--lockWait=3", "--override", "--recursive", "x"});
+ this.hbck2.run(new String[] { "bypass", "--lockWait=3", "--override", "--recursive", "x" });
}
- @Test (expected=FileNotFoundException.class)
+ @Test(expected = FileNotFoundException.class)
public void testInputFileOption() throws IOException {
// The 'x' below should cause the io exception for file not found.
// The Options should all be good.
- this.hbck2.run(new String[]{"bypass", "--override", "--inputFile", "x"});
+ this.hbck2.run(new String[] { "bypass", "--override", "--inputFile", "x" });
}
- @Test (expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testSetRegionStateCommandInvalidState() throws IOException {
// The 'INVALID_STATE' below should cause the IllegalArgumentException.
- this.hbck2.run(new String[]{"setRegionState", "region_encoded", "INVALID_STATE"});
+ this.hbck2.run(new String[] { "setRegionState", "region_encoded", "INVALID_STATE" });
}
@Test
@@ -113,27 +113,26 @@ public class TestHBCKCommandLineParsing {
properties.load(inputStream);
String expectedVersionOutput = properties.getProperty("version");
// Get hbck version option output.
- String actualVersionOutput = retrieveOptionOutput(new String[]{"-v"}).trim();
+ String actualVersionOutput = retrieveOptionOutput(new String[] { "-v" }).trim();
assertEquals(expectedVersionOutput, actualVersionOutput);
}
@Test
public void testReplicationNoOption() throws IOException {
- String output = retrieveOptionOutput(new String[]{"replication"});
+ String output = retrieveOptionOutput(new String[] { "replication" });
assertFalse(output.contains("ERROR: Unrecognized option: -f"));
}
@Test
public void testReplicationFixShortOption() throws IOException {
- String output = retrieveOptionOutput(new String[]{"replication", "-f"});
+ String output = retrieveOptionOutput(new String[] { "replication", "-f" });
assertFalse(output.contains("ERROR: Unrecognized option: -f"));
}
@Test
public void testReplicationFixShortOptionTable() throws IOException {
- String output = retrieveOptionOutput(new String[]{"replication", "-f", "table"});
- assertTrue(
- output.contains("ERROR: No replication barrier(s) on table: table\n"));
+ String output = retrieveOptionOutput(new String[] { "replication", "-f", "table" });
+ assertTrue(output.contains("ERROR: No replication barrier(s) on table: table\n"));
assertFalse(output.contains("ERROR: Unrecognized option: --fix"));
}
@@ -144,8 +143,7 @@ public class TestHBCKCommandLineParsing {
input = createInputFile();
String output =
retrieveOptionOutput(new String[] { "replication", "-f", "-i", input.getPath() });
- assertTrue(
- output.contains("ERROR: No replication barrier(s) on table: table\n"));
+ assertTrue(output.contains("ERROR: No replication barrier(s) on table: table\n"));
assertFalse(output.contains("ERROR: Unrecognized option: -f"));
assertFalse(output.contains("ERROR: Unrecognized option: -i"));
} finally {
@@ -155,13 +153,13 @@ public class TestHBCKCommandLineParsing {
@Test
public void testReplicationFixLongOption() throws IOException {
- String output = retrieveOptionOutput(new String[]{"replication", "--fix"});
+ String output = retrieveOptionOutput(new String[] { "replication", "--fix" });
assertFalse(output.contains("ERROR: Unrecognized option: --fix"));
}
@Test
public void testReplicationFixLongOptionTable() throws IOException {
- String output = retrieveOptionOutput(new String[]{"replication", "--fix", "table"});
+ String output = retrieveOptionOutput(new String[] { "replication", "--fix", "table" });
assertTrue(output.contains("ERROR: No replication barrier(s) on table: table\n"));
assertFalse(output.contains("ERROR: Unrecognized option: -f"));
}
@@ -173,8 +171,7 @@ public class TestHBCKCommandLineParsing {
input = createInputFile();
String output =
retrieveOptionOutput(new String[] { "replication", "--fix", "-i", input.getPath() });
- assertTrue(
- output.contains("ERROR: No replication barrier(s) on table: table\n"));
+ assertTrue(output.contains("ERROR: No replication barrier(s) on table: table\n"));
assertFalse(output.contains("ERROR: Unrecognized option: --fix"));
assertFalse(output.contains("ERROR: Unrecognized option: -i"));
} finally {
@@ -189,8 +186,7 @@ public class TestHBCKCommandLineParsing {
input = createInputFile();
String output =
retrieveOptionOutput(new String[] { "replication", "-f", "--inputFiles", input.getPath() });
- assertTrue(
- output.contains("ERROR: No replication barrier(s) on table: table\n"));
+ assertTrue(output.contains("ERROR: No replication barrier(s) on table: table\n"));
assertFalse(output.contains("ERROR: Unrecognized option: -f"));
assertFalse(output.contains("ERROR: Unrecognized option: --inputFiles"));
} finally {
@@ -203,11 +199,9 @@ public class TestHBCKCommandLineParsing {
File input = null;
try {
input = createInputFile();
- String output =
- retrieveOptionOutput(new String[] { "replication", "--fix", "--inputFiles",
- input.getPath() });
- assertTrue(
- output.contains("ERROR: No replication barrier(s) on table: table\n"));
+ String output = retrieveOptionOutput(
+ new String[] { "replication", "--fix", "--inputFiles", input.getPath() });
+ assertTrue(output.contains("ERROR: No replication barrier(s) on table: table\n"));
assertFalse(output.contains("ERROR: Unrecognized option: --fix"));
assertFalse(output.contains("ERROR: Unrecognized option: --inoutFiles"));
} finally {
@@ -234,8 +228,7 @@ public class TestHBCKCommandLineParsing {
File input = null;
try {
input = createInputFile();
- String output =
- retrieveOptionOutput(new String[] { "replication", "-i", input.getPath() });
+ String output = retrieveOptionOutput(new String[] { "replication", "-i", input.getPath() });
assertFalse(output.contains("ERROR: Unrecognized option: -i"));
} finally {
input.delete();
@@ -244,8 +237,8 @@ public class TestHBCKCommandLineParsing {
private File createInputFile() throws Exception {
File f = new File("input");
- try(BufferedWriter writer = new BufferedWriter(
- new OutputStreamWriter(new FileOutputStream(f)))) {
+ try (
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)))) {
writer.write("table");
writer.flush();
}
@@ -254,13 +247,13 @@ public class TestHBCKCommandLineParsing {
@Test
public void testFilesystemFixShortOption() throws IOException {
- String output = retrieveOptionOutput(new String[]{"filesystem", "-f"});
+ String output = retrieveOptionOutput(new String[] { "filesystem", "-f" });
assertFalse(output.contains("ERROR: Unrecognized option: -f"));
}
@Test
public void testFilesystemFixShortOptionTable() throws IOException {
- String output = retrieveOptionOutput(new String[]{"filesystem", "-f", "table"});
+ String output = retrieveOptionOutput(new String[] { "filesystem", "-f", "table" });
assertFalse(output.contains("ERROR: Unrecognized option: --fix"));
}
@@ -280,13 +273,13 @@ public class TestHBCKCommandLineParsing {
@Test
public void testFilesystemFixLongOption() throws IOException {
- String output = retrieveOptionOutput(new String[]{"filesystem", "--fix"});
+ String output = retrieveOptionOutput(new String[] { "filesystem", "--fix" });
assertFalse(output.contains("ERROR: Unrecognized option: --fix"));
}
@Test
public void testFilesystemFixLongOptionTable() throws IOException {
- String output = retrieveOptionOutput(new String[]{"filesystem", "--fix", "table"});
+ String output = retrieveOptionOutput(new String[] { "filesystem", "--fix", "table" });
assertFalse(output.contains("ERROR: Unrecognized option: -f"));
}
@@ -323,9 +316,8 @@ public class TestHBCKCommandLineParsing {
File input = null;
try {
input = createInputFile();
- String output =
- retrieveOptionOutput(new String[] { "filesystem", "--fix", "--inputFiles",
- input.getPath() });
+ String output = retrieveOptionOutput(
+ new String[] { "filesystem", "--fix", "--inputFiles", input.getPath() });
assertFalse(output.contains("ERROR: Unrecognized option: --fix"));
assertFalse(output.contains("ERROR: Unrecognized option: --inputFiles"));
} finally {
@@ -351,8 +343,7 @@ public class TestHBCKCommandLineParsing {
File input = null;
try {
input = createInputFile();
- String output =
- retrieveOptionOutput(new String[] { "filesystem", "-i", input.getPath() });
+ String output = retrieveOptionOutput(new String[] { "filesystem", "-i", input.getPath() });
assertFalse(output.contains("ERROR: Unrecognized option: -i"));
} finally {
input.delete();
diff --git a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKFsTableDescriptorForceCreation.java b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKFsTableDescriptorForceCreation.java
index 5b5b853..f521cd0 100644
--- a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKFsTableDescriptorForceCreation.java
+++ b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKFsTableDescriptorForceCreation.java
@@ -39,7 +39,7 @@ import org.junit.rules.TestName;
/**
* COPIED from org.apache.hadoop.hbase.TestFSTableDescriptorForceCreation
*/
-@Category({MiscTests.class, SmallTests.class})
+@Category({ MiscTests.class, SmallTests.class })
public class TestHBCKFsTableDescriptorForceCreation {
@ClassRule
@@ -52,16 +52,14 @@ public class TestHBCKFsTableDescriptorForceCreation {
public TestName name = new TestName();
@Test
- public void testShouldCreateNewTableDescriptorIfForcefulCreationIsFalse()
- throws IOException {
+ public void testShouldCreateNewTableDescriptorIfForcefulCreationIsFalse() throws IOException {
final String name = this.name.getMethodName();
... 2648 lines suppressed ...