http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a2b2dd19/devapidocs/src-html/org/apache/hadoop/hbase/util/HBaseFsck.OnlineEntry.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/util/HBaseFsck.OnlineEntry.html b/devapidocs/src-html/org/apache/hadoop/hbase/util/HBaseFsck.OnlineEntry.html index c9a18a3..c80f6d8 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/util/HBaseFsck.OnlineEntry.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/util/HBaseFsck.OnlineEntry.html @@ -2492,2617 +2492,2627 @@ <span class="sourceLineNo">2484</span> return;<a name="line.2484"></a> <span class="sourceLineNo">2485</span> }<a name="line.2485"></a> <span class="sourceLineNo">2486</span> }<a name="line.2486"></a> -<span class="sourceLineNo">2487</span> errors.reportError(ERROR_CODE.LINGERING_SPLIT_PARENT, "Region "<a name="line.2487"></a> -<span class="sourceLineNo">2488</span> + descriptiveName + " is a split parent in META, in HDFS, "<a name="line.2488"></a> -<span class="sourceLineNo">2489</span> + "and not deployed on any region server. This could be transient, "<a name="line.2489"></a> -<span class="sourceLineNo">2490</span> + "consider to run the catalog janitor first!");<a name="line.2490"></a> -<span class="sourceLineNo">2491</span> if (shouldFixSplitParents()) {<a name="line.2491"></a> -<span class="sourceLineNo">2492</span> setShouldRerun();<a name="line.2492"></a> -<span class="sourceLineNo">2493</span> resetSplitParent(hbi);<a name="line.2493"></a> -<span class="sourceLineNo">2494</span> }<a name="line.2494"></a> -<span class="sourceLineNo">2495</span> } else if (inMeta && !inHdfs && !isDeployed) {<a name="line.2495"></a> -<span class="sourceLineNo">2496</span> errors.reportError(ERROR_CODE.NOT_IN_HDFS_OR_DEPLOYED, "Region "<a name="line.2496"></a> -<span class="sourceLineNo">2497</span> + descriptiveName + " found in META, but not in HDFS "<a name="line.2497"></a> -<span class="sourceLineNo">2498</span> + "or deployed on any region server.");<a name="line.2498"></a> -<span class="sourceLineNo">2499</span> if (shouldFixMeta()) {<a name="line.2499"></a> -<span class="sourceLineNo">2500</span> deleteMetaRegion(hbi);<a name="line.2500"></a> -<span class="sourceLineNo">2501</span> }<a name="line.2501"></a> -<span class="sourceLineNo">2502</span> } else if (inMeta && !inHdfs && isDeployed) {<a name="line.2502"></a> -<span class="sourceLineNo">2503</span> errors.reportError(ERROR_CODE.NOT_IN_HDFS, "Region " + descriptiveName<a name="line.2503"></a> -<span class="sourceLineNo">2504</span> + " found in META, but not in HDFS, " +<a name="line.2504"></a> -<span class="sourceLineNo">2505</span> "and deployed on " + Joiner.on(", ").join(hbi.deployedOn));<a name="line.2505"></a> -<span class="sourceLineNo">2506</span> // We treat HDFS as ground truth. Any information in meta is transient<a name="line.2506"></a> -<span class="sourceLineNo">2507</span> // and equivalent data can be regenerated. So, lets unassign and remove<a name="line.2507"></a> -<span class="sourceLineNo">2508</span> // these problems from META.<a name="line.2508"></a> -<span class="sourceLineNo">2509</span> if (shouldFixAssignments()) {<a name="line.2509"></a> -<span class="sourceLineNo">2510</span> errors.print("Trying to fix unassigned region...");<a name="line.2510"></a> -<span class="sourceLineNo">2511</span> undeployRegions(hbi);<a name="line.2511"></a> -<span class="sourceLineNo">2512</span> }<a name="line.2512"></a> -<span class="sourceLineNo">2513</span> if (shouldFixMeta()) {<a name="line.2513"></a> -<span class="sourceLineNo">2514</span> // wait for it to complete<a name="line.2514"></a> -<span class="sourceLineNo">2515</span> deleteMetaRegion(hbi);<a name="line.2515"></a> -<span class="sourceLineNo">2516</span> }<a name="line.2516"></a> -<span class="sourceLineNo">2517</span> } else if (inMeta && inHdfs && !isDeployed && shouldBeDeployed) {<a name="line.2517"></a> -<span class="sourceLineNo">2518</span> errors.reportError(ERROR_CODE.NOT_DEPLOYED, "Region " + descriptiveName<a name="line.2518"></a> -<span class="sourceLineNo">2519</span> + " not deployed on any region server.");<a name="line.2519"></a> -<span class="sourceLineNo">2520</span> tryAssignmentRepair(hbi, "Trying to fix unassigned region...");<a name="line.2520"></a> -<span class="sourceLineNo">2521</span> } else if (inMeta && inHdfs && isDeployed && !shouldBeDeployed) {<a name="line.2521"></a> -<span class="sourceLineNo">2522</span> errors.reportError(ERROR_CODE.SHOULD_NOT_BE_DEPLOYED,<a name="line.2522"></a> -<span class="sourceLineNo">2523</span> "Region " + descriptiveName + " should not be deployed according " +<a name="line.2523"></a> -<span class="sourceLineNo">2524</span> "to META, but is deployed on " + Joiner.on(", ").join(hbi.deployedOn));<a name="line.2524"></a> -<span class="sourceLineNo">2525</span> if (shouldFixAssignments()) {<a name="line.2525"></a> -<span class="sourceLineNo">2526</span> errors.print("Trying to close the region " + descriptiveName);<a name="line.2526"></a> -<span class="sourceLineNo">2527</span> setShouldRerun();<a name="line.2527"></a> -<span class="sourceLineNo">2528</span> HBaseFsckRepair.fixMultiAssignment(connection, hbi.metaEntry, hbi.deployedOn);<a name="line.2528"></a> -<span class="sourceLineNo">2529</span> }<a name="line.2529"></a> -<span class="sourceLineNo">2530</span> } else if (inMeta && inHdfs && isMultiplyDeployed) {<a name="line.2530"></a> -<span class="sourceLineNo">2531</span> errors.reportError(ERROR_CODE.MULTI_DEPLOYED, "Region " + descriptiveName<a name="line.2531"></a> -<span class="sourceLineNo">2532</span> + " is listed in hbase:meta on region server " + hbi.metaEntry.regionServer<a name="line.2532"></a> -<span class="sourceLineNo">2533</span> + " but is multiply assigned to region servers " +<a name="line.2533"></a> -<span class="sourceLineNo">2534</span> Joiner.on(", ").join(hbi.deployedOn));<a name="line.2534"></a> -<span class="sourceLineNo">2535</span> // If we are trying to fix the errors<a name="line.2535"></a> -<span class="sourceLineNo">2536</span> if (shouldFixAssignments()) {<a name="line.2536"></a> -<span class="sourceLineNo">2537</span> errors.print("Trying to fix assignment error...");<a name="line.2537"></a> -<span class="sourceLineNo">2538</span> setShouldRerun();<a name="line.2538"></a> -<span class="sourceLineNo">2539</span> HBaseFsckRepair.fixMultiAssignment(connection, hbi.metaEntry, hbi.deployedOn);<a name="line.2539"></a> -<span class="sourceLineNo">2540</span> }<a name="line.2540"></a> -<span class="sourceLineNo">2541</span> } else if (inMeta && inHdfs && isDeployed && !deploymentMatchesMeta) {<a name="line.2541"></a> -<span class="sourceLineNo">2542</span> errors.reportError(ERROR_CODE.SERVER_DOES_NOT_MATCH_META, "Region "<a name="line.2542"></a> -<span class="sourceLineNo">2543</span> + descriptiveName + " listed in hbase:meta on region server " +<a name="line.2543"></a> -<span class="sourceLineNo">2544</span> hbi.metaEntry.regionServer + " but found on region server " +<a name="line.2544"></a> -<span class="sourceLineNo">2545</span> hbi.deployedOn.get(0));<a name="line.2545"></a> -<span class="sourceLineNo">2546</span> // If we are trying to fix the errors<a name="line.2546"></a> -<span class="sourceLineNo">2547</span> if (shouldFixAssignments()) {<a name="line.2547"></a> -<span class="sourceLineNo">2548</span> errors.print("Trying to fix assignment error...");<a name="line.2548"></a> -<span class="sourceLineNo">2549</span> setShouldRerun();<a name="line.2549"></a> -<span class="sourceLineNo">2550</span> HBaseFsckRepair.fixMultiAssignment(connection, hbi.metaEntry, hbi.deployedOn);<a name="line.2550"></a> -<span class="sourceLineNo">2551</span> HBaseFsckRepair.waitUntilAssigned(admin, hbi.getHdfsHRI());<a name="line.2551"></a> -<span class="sourceLineNo">2552</span> }<a name="line.2552"></a> -<span class="sourceLineNo">2553</span> } else {<a name="line.2553"></a> -<span class="sourceLineNo">2554</span> errors.reportError(ERROR_CODE.UNKNOWN, "Region " + descriptiveName +<a name="line.2554"></a> -<span class="sourceLineNo">2555</span> " is in an unforeseen state:" +<a name="line.2555"></a> -<span class="sourceLineNo">2556</span> " inMeta=" + inMeta +<a name="line.2556"></a> -<span class="sourceLineNo">2557</span> " inHdfs=" + inHdfs +<a name="line.2557"></a> -<span class="sourceLineNo">2558</span> " isDeployed=" + isDeployed +<a name="line.2558"></a> -<span class="sourceLineNo">2559</span> " isMultiplyDeployed=" + isMultiplyDeployed +<a name="line.2559"></a> -<span class="sourceLineNo">2560</span> " deploymentMatchesMeta=" + deploymentMatchesMeta +<a name="line.2560"></a> -<span class="sourceLineNo">2561</span> " shouldBeDeployed=" + shouldBeDeployed);<a name="line.2561"></a> -<span class="sourceLineNo">2562</span> }<a name="line.2562"></a> -<span class="sourceLineNo">2563</span> }<a name="line.2563"></a> -<span class="sourceLineNo">2564</span><a name="line.2564"></a> -<span class="sourceLineNo">2565</span> /**<a name="line.2565"></a> -<span class="sourceLineNo">2566</span> * Checks tables integrity. Goes over all regions and scans the tables.<a name="line.2566"></a> -<span class="sourceLineNo">2567</span> * Collects all the pieces for each table and checks if there are missing,<a name="line.2567"></a> -<span class="sourceLineNo">2568</span> * repeated or overlapping ones.<a name="line.2568"></a> -<span class="sourceLineNo">2569</span> * @throws IOException<a name="line.2569"></a> -<span class="sourceLineNo">2570</span> */<a name="line.2570"></a> -<span class="sourceLineNo">2571</span> SortedMap<TableName, TableInfo> checkIntegrity() throws IOException {<a name="line.2571"></a> -<span class="sourceLineNo">2572</span> tablesInfo = new TreeMap<>();<a name="line.2572"></a> -<span class="sourceLineNo">2573</span> LOG.debug("There are " + regionInfoMap.size() + " region info entries");<a name="line.2573"></a> -<span class="sourceLineNo">2574</span> for (HbckInfo hbi : regionInfoMap.values()) {<a name="line.2574"></a> -<span class="sourceLineNo">2575</span> // Check only valid, working regions<a name="line.2575"></a> -<span class="sourceLineNo">2576</span> if (hbi.metaEntry == null) {<a name="line.2576"></a> -<span class="sourceLineNo">2577</span> // this assumes that consistency check has run loadMetaEntry<a name="line.2577"></a> -<span class="sourceLineNo">2578</span> Path p = hbi.getHdfsRegionDir();<a name="line.2578"></a> -<span class="sourceLineNo">2579</span> if (p == null) {<a name="line.2579"></a> -<span class="sourceLineNo">2580</span> errors.report("No regioninfo in Meta or HDFS. " + hbi);<a name="line.2580"></a> -<span class="sourceLineNo">2581</span> }<a name="line.2581"></a> -<span class="sourceLineNo">2582</span><a name="line.2582"></a> -<span class="sourceLineNo">2583</span> // TODO test.<a name="line.2583"></a> -<span class="sourceLineNo">2584</span> continue;<a name="line.2584"></a> -<span class="sourceLineNo">2585</span> }<a name="line.2585"></a> -<span class="sourceLineNo">2586</span> if (hbi.metaEntry.regionServer == null) {<a name="line.2586"></a> -<span class="sourceLineNo">2587</span> errors.detail("Skipping region because no region server: " + hbi);<a name="line.2587"></a> -<span class="sourceLineNo">2588</span> continue;<a name="line.2588"></a> -<span class="sourceLineNo">2589</span> }<a name="line.2589"></a> -<span class="sourceLineNo">2590</span> if (hbi.metaEntry.isOffline()) {<a name="line.2590"></a> -<span class="sourceLineNo">2591</span> errors.detail("Skipping region because it is offline: " + hbi);<a name="line.2591"></a> -<span class="sourceLineNo">2592</span> continue;<a name="line.2592"></a> -<span class="sourceLineNo">2593</span> }<a name="line.2593"></a> -<span class="sourceLineNo">2594</span> if (hbi.containsOnlyHdfsEdits()) {<a name="line.2594"></a> -<span class="sourceLineNo">2595</span> errors.detail("Skipping region because it only contains edits" + hbi);<a name="line.2595"></a> -<span class="sourceLineNo">2596</span> continue;<a name="line.2596"></a> -<span class="sourceLineNo">2597</span> }<a name="line.2597"></a> -<span class="sourceLineNo">2598</span><a name="line.2598"></a> -<span class="sourceLineNo">2599</span> // Missing regionDir or over-deployment is checked elsewhere. Include<a name="line.2599"></a> -<span class="sourceLineNo">2600</span> // these cases in modTInfo, so we can evaluate those regions as part of<a name="line.2600"></a> -<span class="sourceLineNo">2601</span> // the region chain in META<a name="line.2601"></a> -<span class="sourceLineNo">2602</span> //if (hbi.foundRegionDir == null) continue;<a name="line.2602"></a> -<span class="sourceLineNo">2603</span> //if (hbi.deployedOn.size() != 1) continue;<a name="line.2603"></a> -<span class="sourceLineNo">2604</span> if (hbi.deployedOn.isEmpty()) continue;<a name="line.2604"></a> -<span class="sourceLineNo">2605</span><a name="line.2605"></a> -<span class="sourceLineNo">2606</span> // We should be safe here<a name="line.2606"></a> -<span class="sourceLineNo">2607</span> TableName tableName = hbi.metaEntry.getTable();<a name="line.2607"></a> -<span class="sourceLineNo">2608</span> TableInfo modTInfo = tablesInfo.get(tableName);<a name="line.2608"></a> -<span class="sourceLineNo">2609</span> if (modTInfo == null) {<a name="line.2609"></a> -<span class="sourceLineNo">2610</span> modTInfo = new TableInfo(tableName);<a name="line.2610"></a> -<span class="sourceLineNo">2611</span> }<a name="line.2611"></a> -<span class="sourceLineNo">2612</span> for (ServerName server : hbi.deployedOn) {<a name="line.2612"></a> -<span class="sourceLineNo">2613</span> modTInfo.addServer(server);<a name="line.2613"></a> -<span class="sourceLineNo">2614</span> }<a name="line.2614"></a> +<span class="sourceLineNo">2487</span><a name="line.2487"></a> +<span class="sourceLineNo">2488</span> // For Replica region, we need to do a similar check. If replica is not split successfully,<a name="line.2488"></a> +<span class="sourceLineNo">2489</span> // error is going to be reported against primary daughter region.<a name="line.2489"></a> +<span class="sourceLineNo">2490</span> if (hbi.getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) {<a name="line.2490"></a> +<span class="sourceLineNo">2491</span> LOG.info("Region " + descriptiveName + " is a split parent in META, in HDFS, "<a name="line.2491"></a> +<span class="sourceLineNo">2492</span> + "and not deployed on any region server. This may be transient.");<a name="line.2492"></a> +<span class="sourceLineNo">2493</span> hbi.setSkipChecks(true);<a name="line.2493"></a> +<span class="sourceLineNo">2494</span> return;<a name="line.2494"></a> +<span class="sourceLineNo">2495</span> }<a name="line.2495"></a> +<span class="sourceLineNo">2496</span><a name="line.2496"></a> +<span class="sourceLineNo">2497</span> errors.reportError(ERROR_CODE.LINGERING_SPLIT_PARENT, "Region "<a name="line.2497"></a> +<span class="sourceLineNo">2498</span> + descriptiveName + " is a split parent in META, in HDFS, "<a name="line.2498"></a> +<span class="sourceLineNo">2499</span> + "and not deployed on any region server. This could be transient, "<a name="line.2499"></a> +<span class="sourceLineNo">2500</span> + "consider to run the catalog janitor first!");<a name="line.2500"></a> +<span class="sourceLineNo">2501</span> if (shouldFixSplitParents()) {<a name="line.2501"></a> +<span class="sourceLineNo">2502</span> setShouldRerun();<a name="line.2502"></a> +<span class="sourceLineNo">2503</span> resetSplitParent(hbi);<a name="line.2503"></a> +<span class="sourceLineNo">2504</span> }<a name="line.2504"></a> +<span class="sourceLineNo">2505</span> } else if (inMeta && !inHdfs && !isDeployed) {<a name="line.2505"></a> +<span class="sourceLineNo">2506</span> errors.reportError(ERROR_CODE.NOT_IN_HDFS_OR_DEPLOYED, "Region "<a name="line.2506"></a> +<span class="sourceLineNo">2507</span> + descriptiveName + " found in META, but not in HDFS "<a name="line.2507"></a> +<span class="sourceLineNo">2508</span> + "or deployed on any region server.");<a name="line.2508"></a> +<span class="sourceLineNo">2509</span> if (shouldFixMeta()) {<a name="line.2509"></a> +<span class="sourceLineNo">2510</span> deleteMetaRegion(hbi);<a name="line.2510"></a> +<span class="sourceLineNo">2511</span> }<a name="line.2511"></a> +<span class="sourceLineNo">2512</span> } else if (inMeta && !inHdfs && isDeployed) {<a name="line.2512"></a> +<span class="sourceLineNo">2513</span> errors.reportError(ERROR_CODE.NOT_IN_HDFS, "Region " + descriptiveName<a name="line.2513"></a> +<span class="sourceLineNo">2514</span> + " found in META, but not in HDFS, " +<a name="line.2514"></a> +<span class="sourceLineNo">2515</span> "and deployed on " + Joiner.on(", ").join(hbi.deployedOn));<a name="line.2515"></a> +<span class="sourceLineNo">2516</span> // We treat HDFS as ground truth. Any information in meta is transient<a name="line.2516"></a> +<span class="sourceLineNo">2517</span> // and equivalent data can be regenerated. So, lets unassign and remove<a name="line.2517"></a> +<span class="sourceLineNo">2518</span> // these problems from META.<a name="line.2518"></a> +<span class="sourceLineNo">2519</span> if (shouldFixAssignments()) {<a name="line.2519"></a> +<span class="sourceLineNo">2520</span> errors.print("Trying to fix unassigned region...");<a name="line.2520"></a> +<span class="sourceLineNo">2521</span> undeployRegions(hbi);<a name="line.2521"></a> +<span class="sourceLineNo">2522</span> }<a name="line.2522"></a> +<span class="sourceLineNo">2523</span> if (shouldFixMeta()) {<a name="line.2523"></a> +<span class="sourceLineNo">2524</span> // wait for it to complete<a name="line.2524"></a> +<span class="sourceLineNo">2525</span> deleteMetaRegion(hbi);<a name="line.2525"></a> +<span class="sourceLineNo">2526</span> }<a name="line.2526"></a> +<span class="sourceLineNo">2527</span> } else if (inMeta && inHdfs && !isDeployed && shouldBeDeployed) {<a name="line.2527"></a> +<span class="sourceLineNo">2528</span> errors.reportError(ERROR_CODE.NOT_DEPLOYED, "Region " + descriptiveName<a name="line.2528"></a> +<span class="sourceLineNo">2529</span> + " not deployed on any region server.");<a name="line.2529"></a> +<span class="sourceLineNo">2530</span> tryAssignmentRepair(hbi, "Trying to fix unassigned region...");<a name="line.2530"></a> +<span class="sourceLineNo">2531</span> } else if (inMeta && inHdfs && isDeployed && !shouldBeDeployed) {<a name="line.2531"></a> +<span class="sourceLineNo">2532</span> errors.reportError(ERROR_CODE.SHOULD_NOT_BE_DEPLOYED,<a name="line.2532"></a> +<span class="sourceLineNo">2533</span> "Region " + descriptiveName + " should not be deployed according " +<a name="line.2533"></a> +<span class="sourceLineNo">2534</span> "to META, but is deployed on " + Joiner.on(", ").join(hbi.deployedOn));<a name="line.2534"></a> +<span class="sourceLineNo">2535</span> if (shouldFixAssignments()) {<a name="line.2535"></a> +<span class="sourceLineNo">2536</span> errors.print("Trying to close the region " + descriptiveName);<a name="line.2536"></a> +<span class="sourceLineNo">2537</span> setShouldRerun();<a name="line.2537"></a> +<span class="sourceLineNo">2538</span> HBaseFsckRepair.fixMultiAssignment(connection, hbi.metaEntry, hbi.deployedOn);<a name="line.2538"></a> +<span class="sourceLineNo">2539</span> }<a name="line.2539"></a> +<span class="sourceLineNo">2540</span> } else if (inMeta && inHdfs && isMultiplyDeployed) {<a name="line.2540"></a> +<span class="sourceLineNo">2541</span> errors.reportError(ERROR_CODE.MULTI_DEPLOYED, "Region " + descriptiveName<a name="line.2541"></a> +<span class="sourceLineNo">2542</span> + " is listed in hbase:meta on region server " + hbi.metaEntry.regionServer<a name="line.2542"></a> +<span class="sourceLineNo">2543</span> + " but is multiply assigned to region servers " +<a name="line.2543"></a> +<span class="sourceLineNo">2544</span> Joiner.on(", ").join(hbi.deployedOn));<a name="line.2544"></a> +<span class="sourceLineNo">2545</span> // If we are trying to fix the errors<a name="line.2545"></a> +<span class="sourceLineNo">2546</span> if (shouldFixAssignments()) {<a name="line.2546"></a> +<span class="sourceLineNo">2547</span> errors.print("Trying to fix assignment error...");<a name="line.2547"></a> +<span class="sourceLineNo">2548</span> setShouldRerun();<a name="line.2548"></a> +<span class="sourceLineNo">2549</span> HBaseFsckRepair.fixMultiAssignment(connection, hbi.metaEntry, hbi.deployedOn);<a name="line.2549"></a> +<span class="sourceLineNo">2550</span> }<a name="line.2550"></a> +<span class="sourceLineNo">2551</span> } else if (inMeta && inHdfs && isDeployed && !deploymentMatchesMeta) {<a name="line.2551"></a> +<span class="sourceLineNo">2552</span> errors.reportError(ERROR_CODE.SERVER_DOES_NOT_MATCH_META, "Region "<a name="line.2552"></a> +<span class="sourceLineNo">2553</span> + descriptiveName + " listed in hbase:meta on region server " +<a name="line.2553"></a> +<span class="sourceLineNo">2554</span> hbi.metaEntry.regionServer + " but found on region server " +<a name="line.2554"></a> +<span class="sourceLineNo">2555</span> hbi.deployedOn.get(0));<a name="line.2555"></a> +<span class="sourceLineNo">2556</span> // If we are trying to fix the errors<a name="line.2556"></a> +<span class="sourceLineNo">2557</span> if (shouldFixAssignments()) {<a name="line.2557"></a> +<span class="sourceLineNo">2558</span> errors.print("Trying to fix assignment error...");<a name="line.2558"></a> +<span class="sourceLineNo">2559</span> setShouldRerun();<a name="line.2559"></a> +<span class="sourceLineNo">2560</span> HBaseFsckRepair.fixMultiAssignment(connection, hbi.metaEntry, hbi.deployedOn);<a name="line.2560"></a> +<span class="sourceLineNo">2561</span> HBaseFsckRepair.waitUntilAssigned(admin, hbi.getHdfsHRI());<a name="line.2561"></a> +<span class="sourceLineNo">2562</span> }<a name="line.2562"></a> +<span class="sourceLineNo">2563</span> } else {<a name="line.2563"></a> +<span class="sourceLineNo">2564</span> errors.reportError(ERROR_CODE.UNKNOWN, "Region " + descriptiveName +<a name="line.2564"></a> +<span class="sourceLineNo">2565</span> " is in an unforeseen state:" +<a name="line.2565"></a> +<span class="sourceLineNo">2566</span> " inMeta=" + inMeta +<a name="line.2566"></a> +<span class="sourceLineNo">2567</span> " inHdfs=" + inHdfs +<a name="line.2567"></a> +<span class="sourceLineNo">2568</span> " isDeployed=" + isDeployed +<a name="line.2568"></a> +<span class="sourceLineNo">2569</span> " isMultiplyDeployed=" + isMultiplyDeployed +<a name="line.2569"></a> +<span class="sourceLineNo">2570</span> " deploymentMatchesMeta=" + deploymentMatchesMeta +<a name="line.2570"></a> +<span class="sourceLineNo">2571</span> " shouldBeDeployed=" + shouldBeDeployed);<a name="line.2571"></a> +<span class="sourceLineNo">2572</span> }<a name="line.2572"></a> +<span class="sourceLineNo">2573</span> }<a name="line.2573"></a> +<span class="sourceLineNo">2574</span><a name="line.2574"></a> +<span class="sourceLineNo">2575</span> /**<a name="line.2575"></a> +<span class="sourceLineNo">2576</span> * Checks tables integrity. Goes over all regions and scans the tables.<a name="line.2576"></a> +<span class="sourceLineNo">2577</span> * Collects all the pieces for each table and checks if there are missing,<a name="line.2577"></a> +<span class="sourceLineNo">2578</span> * repeated or overlapping ones.<a name="line.2578"></a> +<span class="sourceLineNo">2579</span> * @throws IOException<a name="line.2579"></a> +<span class="sourceLineNo">2580</span> */<a name="line.2580"></a> +<span class="sourceLineNo">2581</span> SortedMap<TableName, TableInfo> checkIntegrity() throws IOException {<a name="line.2581"></a> +<span class="sourceLineNo">2582</span> tablesInfo = new TreeMap<>();<a name="line.2582"></a> +<span class="sourceLineNo">2583</span> LOG.debug("There are " + regionInfoMap.size() + " region info entries");<a name="line.2583"></a> +<span class="sourceLineNo">2584</span> for (HbckInfo hbi : regionInfoMap.values()) {<a name="line.2584"></a> +<span class="sourceLineNo">2585</span> // Check only valid, working regions<a name="line.2585"></a> +<span class="sourceLineNo">2586</span> if (hbi.metaEntry == null) {<a name="line.2586"></a> +<span class="sourceLineNo">2587</span> // this assumes that consistency check has run loadMetaEntry<a name="line.2587"></a> +<span class="sourceLineNo">2588</span> Path p = hbi.getHdfsRegionDir();<a name="line.2588"></a> +<span class="sourceLineNo">2589</span> if (p == null) {<a name="line.2589"></a> +<span class="sourceLineNo">2590</span> errors.report("No regioninfo in Meta or HDFS. " + hbi);<a name="line.2590"></a> +<span class="sourceLineNo">2591</span> }<a name="line.2591"></a> +<span class="sourceLineNo">2592</span><a name="line.2592"></a> +<span class="sourceLineNo">2593</span> // TODO test.<a name="line.2593"></a> +<span class="sourceLineNo">2594</span> continue;<a name="line.2594"></a> +<span class="sourceLineNo">2595</span> }<a name="line.2595"></a> +<span class="sourceLineNo">2596</span> if (hbi.metaEntry.regionServer == null) {<a name="line.2596"></a> +<span class="sourceLineNo">2597</span> errors.detail("Skipping region because no region server: " + hbi);<a name="line.2597"></a> +<span class="sourceLineNo">2598</span> continue;<a name="line.2598"></a> +<span class="sourceLineNo">2599</span> }<a name="line.2599"></a> +<span class="sourceLineNo">2600</span> if (hbi.metaEntry.isOffline()) {<a name="line.2600"></a> +<span class="sourceLineNo">2601</span> errors.detail("Skipping region because it is offline: " + hbi);<a name="line.2601"></a> +<span class="sourceLineNo">2602</span> continue;<a name="line.2602"></a> +<span class="sourceLineNo">2603</span> }<a name="line.2603"></a> +<span class="sourceLineNo">2604</span> if (hbi.containsOnlyHdfsEdits()) {<a name="line.2604"></a> +<span class="sourceLineNo">2605</span> errors.detail("Skipping region because it only contains edits" + hbi);<a name="line.2605"></a> +<span class="sourceLineNo">2606</span> continue;<a name="line.2606"></a> +<span class="sourceLineNo">2607</span> }<a name="line.2607"></a> +<span class="sourceLineNo">2608</span><a name="line.2608"></a> +<span class="sourceLineNo">2609</span> // Missing regionDir or over-deployment is checked elsewhere. Include<a name="line.2609"></a> +<span class="sourceLineNo">2610</span> // these cases in modTInfo, so we can evaluate those regions as part of<a name="line.2610"></a> +<span class="sourceLineNo">2611</span> // the region chain in META<a name="line.2611"></a> +<span class="sourceLineNo">2612</span> //if (hbi.foundRegionDir == null) continue;<a name="line.2612"></a> +<span class="sourceLineNo">2613</span> //if (hbi.deployedOn.size() != 1) continue;<a name="line.2613"></a> +<span class="sourceLineNo">2614</span> if (hbi.deployedOn.isEmpty()) continue;<a name="line.2614"></a> <span class="sourceLineNo">2615</span><a name="line.2615"></a> -<span class="sourceLineNo">2616</span> if (!hbi.isSkipChecks()) {<a name="line.2616"></a> -<span class="sourceLineNo">2617</span> modTInfo.addRegionInfo(hbi);<a name="line.2617"></a> -<span class="sourceLineNo">2618</span> }<a name="line.2618"></a> -<span class="sourceLineNo">2619</span><a name="line.2619"></a> -<span class="sourceLineNo">2620</span> tablesInfo.put(tableName, modTInfo);<a name="line.2620"></a> -<span class="sourceLineNo">2621</span> }<a name="line.2621"></a> -<span class="sourceLineNo">2622</span><a name="line.2622"></a> -<span class="sourceLineNo">2623</span> loadTableInfosForTablesWithNoRegion();<a name="line.2623"></a> -<span class="sourceLineNo">2624</span><a name="line.2624"></a> -<span class="sourceLineNo">2625</span> logParallelMerge();<a name="line.2625"></a> -<span class="sourceLineNo">2626</span> for (TableInfo tInfo : tablesInfo.values()) {<a name="line.2626"></a> -<span class="sourceLineNo">2627</span> TableIntegrityErrorHandler handler = tInfo.new IntegrityFixSuggester(tInfo, errors);<a name="line.2627"></a> -<span class="sourceLineNo">2628</span> if (!tInfo.checkRegionChain(handler)) {<a name="line.2628"></a> -<span class="sourceLineNo">2629</span> errors.report("Found inconsistency in table " + tInfo.getName());<a name="line.2629"></a> -<span class="sourceLineNo">2630</span> }<a name="line.2630"></a> +<span class="sourceLineNo">2616</span> // We should be safe here<a name="line.2616"></a> +<span class="sourceLineNo">2617</span> TableName tableName = hbi.metaEntry.getTable();<a name="line.2617"></a> +<span class="sourceLineNo">2618</span> TableInfo modTInfo = tablesInfo.get(tableName);<a name="line.2618"></a> +<span class="sourceLineNo">2619</span> if (modTInfo == null) {<a name="line.2619"></a> +<span class="sourceLineNo">2620</span> modTInfo = new TableInfo(tableName);<a name="line.2620"></a> +<span class="sourceLineNo">2621</span> }<a name="line.2621"></a> +<span class="sourceLineNo">2622</span> for (ServerName server : hbi.deployedOn) {<a name="line.2622"></a> +<span class="sourceLineNo">2623</span> modTInfo.addServer(server);<a name="line.2623"></a> +<span class="sourceLineNo">2624</span> }<a name="line.2624"></a> +<span class="sourceLineNo">2625</span><a name="line.2625"></a> +<span class="sourceLineNo">2626</span> if (!hbi.isSkipChecks()) {<a name="line.2626"></a> +<span class="sourceLineNo">2627</span> modTInfo.addRegionInfo(hbi);<a name="line.2627"></a> +<span class="sourceLineNo">2628</span> }<a name="line.2628"></a> +<span class="sourceLineNo">2629</span><a name="line.2629"></a> +<span class="sourceLineNo">2630</span> tablesInfo.put(tableName, modTInfo);<a name="line.2630"></a> <span class="sourceLineNo">2631</span> }<a name="line.2631"></a> -<span class="sourceLineNo">2632</span> return tablesInfo;<a name="line.2632"></a> -<span class="sourceLineNo">2633</span> }<a name="line.2633"></a> +<span class="sourceLineNo">2632</span><a name="line.2632"></a> +<span class="sourceLineNo">2633</span> loadTableInfosForTablesWithNoRegion();<a name="line.2633"></a> <span class="sourceLineNo">2634</span><a name="line.2634"></a> -<span class="sourceLineNo">2635</span> /** Loads table info's for tables that may not have been included, since there are no<a name="line.2635"></a> -<span class="sourceLineNo">2636</span> * regions reported for the table, but table dir is there in hdfs<a name="line.2636"></a> -<span class="sourceLineNo">2637</span> */<a name="line.2637"></a> -<span class="sourceLineNo">2638</span> private void loadTableInfosForTablesWithNoRegion() throws IOException {<a name="line.2638"></a> -<span class="sourceLineNo">2639</span> Map<String, HTableDescriptor> allTables = new FSTableDescriptors(getConf()).getAll();<a name="line.2639"></a> -<span class="sourceLineNo">2640</span> for (HTableDescriptor htd : allTables.values()) {<a name="line.2640"></a> -<span class="sourceLineNo">2641</span> if (checkMetaOnly && !htd.isMetaTable()) {<a name="line.2641"></a> -<span class="sourceLineNo">2642</span> continue;<a name="line.2642"></a> -<span class="sourceLineNo">2643</span> }<a name="line.2643"></a> +<span class="sourceLineNo">2635</span> logParallelMerge();<a name="line.2635"></a> +<span class="sourceLineNo">2636</span> for (TableInfo tInfo : tablesInfo.values()) {<a name="line.2636"></a> +<span class="sourceLineNo">2637</span> TableIntegrityErrorHandler handler = tInfo.new IntegrityFixSuggester(tInfo, errors);<a name="line.2637"></a> +<span class="sourceLineNo">2638</span> if (!tInfo.checkRegionChain(handler)) {<a name="line.2638"></a> +<span class="sourceLineNo">2639</span> errors.report("Found inconsistency in table " + tInfo.getName());<a name="line.2639"></a> +<span class="sourceLineNo">2640</span> }<a name="line.2640"></a> +<span class="sourceLineNo">2641</span> }<a name="line.2641"></a> +<span class="sourceLineNo">2642</span> return tablesInfo;<a name="line.2642"></a> +<span class="sourceLineNo">2643</span> }<a name="line.2643"></a> <span class="sourceLineNo">2644</span><a name="line.2644"></a> -<span class="sourceLineNo">2645</span> TableName tableName = htd.getTableName();<a name="line.2645"></a> -<span class="sourceLineNo">2646</span> if (isTableIncluded(tableName) && !tablesInfo.containsKey(tableName)) {<a name="line.2646"></a> -<span class="sourceLineNo">2647</span> TableInfo tableInfo = new TableInfo(tableName);<a name="line.2647"></a> -<span class="sourceLineNo">2648</span> tableInfo.htds.add(htd);<a name="line.2648"></a> -<span class="sourceLineNo">2649</span> tablesInfo.put(htd.getTableName(), tableInfo);<a name="line.2649"></a> -<span class="sourceLineNo">2650</span> }<a name="line.2650"></a> -<span class="sourceLineNo">2651</span> }<a name="line.2651"></a> -<span class="sourceLineNo">2652</span> }<a name="line.2652"></a> -<span class="sourceLineNo">2653</span><a name="line.2653"></a> -<span class="sourceLineNo">2654</span> /**<a name="line.2654"></a> -<span class="sourceLineNo">2655</span> * Merge hdfs data by moving from contained HbckInfo into targetRegionDir.<a name="line.2655"></a> -<span class="sourceLineNo">2656</span> * @return number of file move fixes done to merge regions.<a name="line.2656"></a> -<span class="sourceLineNo">2657</span> */<a name="line.2657"></a> -<span class="sourceLineNo">2658</span> public int mergeRegionDirs(Path targetRegionDir, HbckInfo contained) throws IOException {<a name="line.2658"></a> -<span class="sourceLineNo">2659</span> int fileMoves = 0;<a name="line.2659"></a> -<span class="sourceLineNo">2660</span> String thread = Thread.currentThread().getName();<a name="line.2660"></a> -<span class="sourceLineNo">2661</span> LOG.debug("[" + thread + "] Contained region dir after close and pause");<a name="line.2661"></a> -<span class="sourceLineNo">2662</span> debugLsr(contained.getHdfsRegionDir());<a name="line.2662"></a> +<span class="sourceLineNo">2645</span> /** Loads table info's for tables that may not have been included, since there are no<a name="line.2645"></a> +<span class="sourceLineNo">2646</span> * regions reported for the table, but table dir is there in hdfs<a name="line.2646"></a> +<span class="sourceLineNo">2647</span> */<a name="line.2647"></a> +<span class="sourceLineNo">2648</span> private void loadTableInfosForTablesWithNoRegion() throws IOException {<a name="line.2648"></a> +<span class="sourceLineNo">2649</span> Map<String, HTableDescriptor> allTables = new FSTableDescriptors(getConf()).getAll();<a name="line.2649"></a> +<span class="sourceLineNo">2650</span> for (HTableDescriptor htd : allTables.values()) {<a name="line.2650"></a> +<span class="sourceLineNo">2651</span> if (checkMetaOnly && !htd.isMetaTable()) {<a name="line.2651"></a> +<span class="sourceLineNo">2652</span> continue;<a name="line.2652"></a> +<span class="sourceLineNo">2653</span> }<a name="line.2653"></a> +<span class="sourceLineNo">2654</span><a name="line.2654"></a> +<span class="sourceLineNo">2655</span> TableName tableName = htd.getTableName();<a name="line.2655"></a> +<span class="sourceLineNo">2656</span> if (isTableIncluded(tableName) && !tablesInfo.containsKey(tableName)) {<a name="line.2656"></a> +<span class="sourceLineNo">2657</span> TableInfo tableInfo = new TableInfo(tableName);<a name="line.2657"></a> +<span class="sourceLineNo">2658</span> tableInfo.htds.add(htd);<a name="line.2658"></a> +<span class="sourceLineNo">2659</span> tablesInfo.put(htd.getTableName(), tableInfo);<a name="line.2659"></a> +<span class="sourceLineNo">2660</span> }<a name="line.2660"></a> +<span class="sourceLineNo">2661</span> }<a name="line.2661"></a> +<span class="sourceLineNo">2662</span> }<a name="line.2662"></a> <span class="sourceLineNo">2663</span><a name="line.2663"></a> -<span class="sourceLineNo">2664</span> // rename the contained into the container.<a name="line.2664"></a> -<span class="sourceLineNo">2665</span> FileSystem fs = targetRegionDir.getFileSystem(getConf());<a name="line.2665"></a> -<span class="sourceLineNo">2666</span> FileStatus[] dirs = null;<a name="line.2666"></a> -<span class="sourceLineNo">2667</span> try {<a name="line.2667"></a> -<span class="sourceLineNo">2668</span> dirs = fs.listStatus(contained.getHdfsRegionDir());<a name="line.2668"></a> -<span class="sourceLineNo">2669</span> } catch (FileNotFoundException fnfe) {<a name="line.2669"></a> -<span class="sourceLineNo">2670</span> // region we are attempting to merge in is not present! Since this is a merge, there is<a name="line.2670"></a> -<span class="sourceLineNo">2671</span> // no harm skipping this region if it does not exist.<a name="line.2671"></a> -<span class="sourceLineNo">2672</span> if (!fs.exists(contained.getHdfsRegionDir())) {<a name="line.2672"></a> -<span class="sourceLineNo">2673</span> LOG.warn("[" + thread + "] HDFS region dir " + contained.getHdfsRegionDir()<a name="line.2673"></a> -<span class="sourceLineNo">2674</span> + " is missing. Assuming already sidelined or moved.");<a name="line.2674"></a> -<span class="sourceLineNo">2675</span> } else {<a name="line.2675"></a> -<span class="sourceLineNo">2676</span> sidelineRegionDir(fs, contained);<a name="line.2676"></a> -<span class="sourceLineNo">2677</span> }<a name="line.2677"></a> -<span class="sourceLineNo">2678</span> return fileMoves;<a name="line.2678"></a> -<span class="sourceLineNo">2679</span> }<a name="line.2679"></a> -<span class="sourceLineNo">2680</span><a name="line.2680"></a> -<span class="sourceLineNo">2681</span> if (dirs == null) {<a name="line.2681"></a> +<span class="sourceLineNo">2664</span> /**<a name="line.2664"></a> +<span class="sourceLineNo">2665</span> * Merge hdfs data by moving from contained HbckInfo into targetRegionDir.<a name="line.2665"></a> +<span class="sourceLineNo">2666</span> * @return number of file move fixes done to merge regions.<a name="line.2666"></a> +<span class="sourceLineNo">2667</span> */<a name="line.2667"></a> +<span class="sourceLineNo">2668</span> public int mergeRegionDirs(Path targetRegionDir, HbckInfo contained) throws IOException {<a name="line.2668"></a> +<span class="sourceLineNo">2669</span> int fileMoves = 0;<a name="line.2669"></a> +<span class="sourceLineNo">2670</span> String thread = Thread.currentThread().getName();<a name="line.2670"></a> +<span class="sourceLineNo">2671</span> LOG.debug("[" + thread + "] Contained region dir after close and pause");<a name="line.2671"></a> +<span class="sourceLineNo">2672</span> debugLsr(contained.getHdfsRegionDir());<a name="line.2672"></a> +<span class="sourceLineNo">2673</span><a name="line.2673"></a> +<span class="sourceLineNo">2674</span> // rename the contained into the container.<a name="line.2674"></a> +<span class="sourceLineNo">2675</span> FileSystem fs = targetRegionDir.getFileSystem(getConf());<a name="line.2675"></a> +<span class="sourceLineNo">2676</span> FileStatus[] dirs = null;<a name="line.2676"></a> +<span class="sourceLineNo">2677</span> try {<a name="line.2677"></a> +<span class="sourceLineNo">2678</span> dirs = fs.listStatus(contained.getHdfsRegionDir());<a name="line.2678"></a> +<span class="sourceLineNo">2679</span> } catch (FileNotFoundException fnfe) {<a name="line.2679"></a> +<span class="sourceLineNo">2680</span> // region we are attempting to merge in is not present! Since this is a merge, there is<a name="line.2680"></a> +<span class="sourceLineNo">2681</span> // no harm skipping this region if it does not exist.<a name="line.2681"></a> <span class="sourceLineNo">2682</span> if (!fs.exists(contained.getHdfsRegionDir())) {<a name="line.2682"></a> <span class="sourceLineNo">2683</span> LOG.warn("[" + thread + "] HDFS region dir " + contained.getHdfsRegionDir()<a name="line.2683"></a> -<span class="sourceLineNo">2684</span> + " already sidelined.");<a name="line.2684"></a> +<span class="sourceLineNo">2684</span> + " is missing. Assuming already sidelined or moved.");<a name="line.2684"></a> <span class="sourceLineNo">2685</span> } else {<a name="line.2685"></a> <span class="sourceLineNo">2686</span> sidelineRegionDir(fs, contained);<a name="line.2686"></a> <span class="sourceLineNo">2687</span> }<a name="line.2687"></a> <span class="sourceLineNo">2688</span> return fileMoves;<a name="line.2688"></a> <span class="sourceLineNo">2689</span> }<a name="line.2689"></a> <span class="sourceLineNo">2690</span><a name="line.2690"></a> -<span class="sourceLineNo">2691</span> for (FileStatus cf : dirs) {<a name="line.2691"></a> -<span class="sourceLineNo">2692</span> Path src = cf.getPath();<a name="line.2692"></a> -<span class="sourceLineNo">2693</span> Path dst = new Path(targetRegionDir, src.getName());<a name="line.2693"></a> -<span class="sourceLineNo">2694</span><a name="line.2694"></a> -<span class="sourceLineNo">2695</span> if (src.getName().equals(HRegionFileSystem.REGION_INFO_FILE)) {<a name="line.2695"></a> -<span class="sourceLineNo">2696</span> // do not copy the old .regioninfo file.<a name="line.2696"></a> -<span class="sourceLineNo">2697</span> continue;<a name="line.2697"></a> -<span class="sourceLineNo">2698</span> }<a name="line.2698"></a> -<span class="sourceLineNo">2699</span><a name="line.2699"></a> -<span class="sourceLineNo">2700</span> if (src.getName().equals(HConstants.HREGION_OLDLOGDIR_NAME)) {<a name="line.2700"></a> -<span class="sourceLineNo">2701</span> // do not copy the .oldlogs files<a name="line.2701"></a> -<span class="sourceLineNo">2702</span> continue;<a name="line.2702"></a> -<span class="sourceLineNo">2703</span> }<a name="line.2703"></a> +<span class="sourceLineNo">2691</span> if (dirs == null) {<a name="line.2691"></a> +<span class="sourceLineNo">2692</span> if (!fs.exists(contained.getHdfsRegionDir())) {<a name="line.2692"></a> +<span class="sourceLineNo">2693</span> LOG.warn("[" + thread + "] HDFS region dir " + contained.getHdfsRegionDir()<a name="line.2693"></a> +<span class="sourceLineNo">2694</span> + " already sidelined.");<a name="line.2694"></a> +<span class="sourceLineNo">2695</span> } else {<a name="line.2695"></a> +<span class="sourceLineNo">2696</span> sidelineRegionDir(fs, contained);<a name="line.2696"></a> +<span class="sourceLineNo">2697</span> }<a name="line.2697"></a> +<span class="sourceLineNo">2698</span> return fileMoves;<a name="line.2698"></a> +<span class="sourceLineNo">2699</span> }<a name="line.2699"></a> +<span class="sourceLineNo">2700</span><a name="line.2700"></a> +<span class="sourceLineNo">2701</span> for (FileStatus cf : dirs) {<a name="line.2701"></a> +<span class="sourceLineNo">2702</span> Path src = cf.getPath();<a name="line.2702"></a> +<span class="sourceLineNo">2703</span> Path dst = new Path(targetRegionDir, src.getName());<a name="line.2703"></a> <span class="sourceLineNo">2704</span><a name="line.2704"></a> -<span class="sourceLineNo">2705</span> LOG.info("[" + thread + "] Moving files from " + src + " into containing region " + dst);<a name="line.2705"></a> -<span class="sourceLineNo">2706</span> // FileSystem.rename is inconsistent with directories -- if the<a name="line.2706"></a> -<span class="sourceLineNo">2707</span> // dst (foo/a) exists and is a dir, and the src (foo/b) is a dir,<a name="line.2707"></a> -<span class="sourceLineNo">2708</span> // it moves the src into the dst dir resulting in (foo/a/b). If<a name="line.2708"></a> -<span class="sourceLineNo">2709</span> // the dst does not exist, and the src a dir, src becomes dst. (foo/b)<a name="line.2709"></a> -<span class="sourceLineNo">2710</span> for (FileStatus hfile : fs.listStatus(src)) {<a name="line.2710"></a> -<span class="sourceLineNo">2711</span> boolean success = fs.rename(hfile.getPath(), dst);<a name="line.2711"></a> -<span class="sourceLineNo">2712</span> if (success) {<a name="line.2712"></a> -<span class="sourceLineNo">2713</span> fileMoves++;<a name="line.2713"></a> -<span class="sourceLineNo">2714</span> }<a name="line.2714"></a> -<span class="sourceLineNo">2715</span> }<a name="line.2715"></a> -<span class="sourceLineNo">2716</span> LOG.debug("[" + thread + "] Sideline directory contents:");<a name="line.2716"></a> -<span class="sourceLineNo">2717</span> debugLsr(targetRegionDir);<a name="line.2717"></a> -<span class="sourceLineNo">2718</span> }<a name="line.2718"></a> -<span class="sourceLineNo">2719</span><a name="line.2719"></a> -<span class="sourceLineNo">2720</span> // if all success.<a name="line.2720"></a> -<span class="sourceLineNo">2721</span> sidelineRegionDir(fs, contained);<a name="line.2721"></a> -<span class="sourceLineNo">2722</span> LOG.info("[" + thread + "] Sidelined region dir "+ contained.getHdfsRegionDir() + " into " +<a name="line.2722"></a> -<span class="sourceLineNo">2723</span> getSidelineDir());<a name="line.2723"></a> -<span class="sourceLineNo">2724</span> debugLsr(contained.getHdfsRegionDir());<a name="line.2724"></a> -<span class="sourceLineNo">2725</span><a name="line.2725"></a> -<span class="sourceLineNo">2726</span> return fileMoves;<a name="line.2726"></a> -<span class="sourceLineNo">2727</span> }<a name="line.2727"></a> -<span class="sourceLineNo">2728</span><a name="line.2728"></a> +<span class="sourceLineNo">2705</span> if (src.getName().equals(HRegionFileSystem.REGION_INFO_FILE)) {<a name="line.2705"></a> +<span class="sourceLineNo">2706</span> // do not copy the old .regioninfo file.<a name="line.2706"></a> +<span class="sourceLineNo">2707</span> continue;<a name="line.2707"></a> +<span class="sourceLineNo">2708</span> }<a name="line.2708"></a> +<span class="sourceLineNo">2709</span><a name="line.2709"></a> +<span class="sourceLineNo">2710</span> if (src.getName().equals(HConstants.HREGION_OLDLOGDIR_NAME)) {<a name="line.2710"></a> +<span class="sourceLineNo">2711</span> // do not copy the .oldlogs files<a name="line.2711"></a> +<span class="sourceLineNo">2712</span> continue;<a name="line.2712"></a> +<span class="sourceLineNo">2713</span> }<a name="line.2713"></a> +<span class="sourceLineNo">2714</span><a name="line.2714"></a> +<span class="sourceLineNo">2715</span> LOG.info("[" + thread + "] Moving files from " + src + " into containing region " + dst);<a name="line.2715"></a> +<span class="sourceLineNo">2716</span> // FileSystem.rename is inconsistent with directories -- if the<a name="line.2716"></a> +<span class="sourceLineNo">2717</span> // dst (foo/a) exists and is a dir, and the src (foo/b) is a dir,<a name="line.2717"></a> +<span class="sourceLineNo">2718</span> // it moves the src into the dst dir resulting in (foo/a/b). If<a name="line.2718"></a> +<span class="sourceLineNo">2719</span> // the dst does not exist, and the src a dir, src becomes dst. (foo/b)<a name="line.2719"></a> +<span class="sourceLineNo">2720</span> for (FileStatus hfile : fs.listStatus(src)) {<a name="line.2720"></a> +<span class="sourceLineNo">2721</span> boolean success = fs.rename(hfile.getPath(), dst);<a name="line.2721"></a> +<span class="sourceLineNo">2722</span> if (success) {<a name="line.2722"></a> +<span class="sourceLineNo">2723</span> fileMoves++;<a name="line.2723"></a> +<span class="sourceLineNo">2724</span> }<a name="line.2724"></a> +<span class="sourceLineNo">2725</span> }<a name="line.2725"></a> +<span class="sourceLineNo">2726</span> LOG.debug("[" + thread + "] Sideline directory contents:");<a name="line.2726"></a> +<span class="sourceLineNo">2727</span> debugLsr(targetRegionDir);<a name="line.2727"></a> +<span class="sourceLineNo">2728</span> }<a name="line.2728"></a> <span class="sourceLineNo">2729</span><a name="line.2729"></a> -<span class="sourceLineNo">2730</span> static class WorkItemOverlapMerge implements Callable<Void> {<a name="line.2730"></a> -<span class="sourceLineNo">2731</span> private TableIntegrityErrorHandler handler;<a name="line.2731"></a> -<span class="sourceLineNo">2732</span> Collection<HbckInfo> overlapgroup;<a name="line.2732"></a> -<span class="sourceLineNo">2733</span><a name="line.2733"></a> -<span class="sourceLineNo">2734</span> WorkItemOverlapMerge(Collection<HbckInfo> overlapgroup, TableIntegrityErrorHandler handler) {<a name="line.2734"></a> -<span class="sourceLineNo">2735</span> this.handler = handler;<a name="line.2735"></a> -<span class="sourceLineNo">2736</span> this.overlapgroup = overlapgroup;<a name="line.2736"></a> -<span class="sourceLineNo">2737</span> }<a name="line.2737"></a> +<span class="sourceLineNo">2730</span> // if all success.<a name="line.2730"></a> +<span class="sourceLineNo">2731</span> sidelineRegionDir(fs, contained);<a name="line.2731"></a> +<span class="sourceLineNo">2732</span> LOG.info("[" + thread + "] Sidelined region dir "+ contained.getHdfsRegionDir() + " into " +<a name="line.2732"></a> +<span class="sourceLineNo">2733</span> getSidelineDir());<a name="line.2733"></a> +<span class="sourceLineNo">2734</span> debugLsr(contained.getHdfsRegionDir());<a name="line.2734"></a> +<span class="sourceLineNo">2735</span><a name="line.2735"></a> +<span class="sourceLineNo">2736</span> return fileMoves;<a name="line.2736"></a> +<span class="sourceLineNo">2737</span> }<a name="line.2737"></a> <span class="sourceLineNo">2738</span><a name="line.2738"></a> -<span class="sourceLineNo">2739</span> @Override<a name="line.2739"></a> -<span class="sourceLineNo">2740</span> public Void call() throws Exception {<a name="line.2740"></a> -<span class="sourceLineNo">2741</span> handler.handleOverlapGroup(overlapgroup);<a name="line.2741"></a> -<span class="sourceLineNo">2742</span> return null;<a name="line.2742"></a> -<span class="sourceLineNo">2743</span> }<a name="line.2743"></a> -<span class="sourceLineNo">2744</span> };<a name="line.2744"></a> -<span class="sourceLineNo">2745</span><a name="line.2745"></a> -<span class="sourceLineNo">2746</span><a name="line.2746"></a> -<span class="sourceLineNo">2747</span> /**<a name="line.2747"></a> -<span class="sourceLineNo">2748</span> * Maintain information about a particular table.<a name="line.2748"></a> -<span class="sourceLineNo">2749</span> */<a name="line.2749"></a> -<span class="sourceLineNo">2750</span> public class TableInfo {<a name="line.2750"></a> -<span class="sourceLineNo">2751</span> TableName tableName;<a name="line.2751"></a> -<span class="sourceLineNo">2752</span> TreeSet <ServerName> deployedOn;<a name="line.2752"></a> -<span class="sourceLineNo">2753</span><a name="line.2753"></a> -<span class="sourceLineNo">2754</span> // backwards regions<a name="line.2754"></a> -<span class="sourceLineNo">2755</span> final List<HbckInfo> backwards = new ArrayList<>();<a name="line.2755"></a> +<span class="sourceLineNo">2739</span><a name="line.2739"></a> +<span class="sourceLineNo">2740</span> static class WorkItemOverlapMerge implements Callable<Void> {<a name="line.2740"></a> +<span class="sourceLineNo">2741</span> private TableIntegrityErrorHandler handler;<a name="line.2741"></a> +<span class="sourceLineNo">2742</span> Collection<HbckInfo> overlapgroup;<a name="line.2742"></a> +<span class="sourceLineNo">2743</span><a name="line.2743"></a> +<span class="sourceLineNo">2744</span> WorkItemOverlapMerge(Collection<HbckInfo> overlapgroup, TableIntegrityErrorHandler handler) {<a name="line.2744"></a> +<span class="sourceLineNo">2745</span> this.handler = handler;<a name="line.2745"></a> +<span class="sourceLineNo">2746</span> this.overlapgroup = overlapgroup;<a name="line.2746"></a> +<span class="sourceLineNo">2747</span> }<a name="line.2747"></a> +<span class="sourceLineNo">2748</span><a name="line.2748"></a> +<span class="sourceLineNo">2749</span> @Override<a name="line.2749"></a> +<span class="sourceLineNo">2750</span> public Void call() throws Exception {<a name="line.2750"></a> +<span class="sourceLineNo">2751</span> handler.handleOverlapGroup(overlapgroup);<a name="line.2751"></a> +<span class="sourceLineNo">2752</span> return null;<a name="line.2752"></a> +<span class="sourceLineNo">2753</span> }<a name="line.2753"></a> +<span class="sourceLineNo">2754</span> };<a name="line.2754"></a> +<span class="sourceLineNo">2755</span><a name="line.2755"></a> <span class="sourceLineNo">2756</span><a name="line.2756"></a> -<span class="sourceLineNo">2757</span> // sidelined big overlapped regions<a name="line.2757"></a> -<span class="sourceLineNo">2758</span> final Map<Path, HbckInfo> sidelinedRegions = new HashMap<>();<a name="line.2758"></a> -<span class="sourceLineNo">2759</span><a name="line.2759"></a> -<span class="sourceLineNo">2760</span> // region split calculator<a name="line.2760"></a> -<span class="sourceLineNo">2761</span> final RegionSplitCalculator<HbckInfo> sc = new RegionSplitCalculator<>(cmp);<a name="line.2761"></a> -<span class="sourceLineNo">2762</span><a name="line.2762"></a> -<span class="sourceLineNo">2763</span> // Histogram of different HTableDescriptors found. Ideally there is only one!<a name="line.2763"></a> -<span class="sourceLineNo">2764</span> final Set<HTableDescriptor> htds = new HashSet<>();<a name="line.2764"></a> -<span class="sourceLineNo">2765</span><a name="line.2765"></a> -<span class="sourceLineNo">2766</span> // key = start split, values = set of splits in problem group<a name="line.2766"></a> -<span class="sourceLineNo">2767</span> final Multimap<byte[], HbckInfo> overlapGroups =<a name="line.2767"></a> -<span class="sourceLineNo">2768</span> TreeMultimap.create(RegionSplitCalculator.BYTES_COMPARATOR, cmp);<a name="line.2768"></a> +<span class="sourceLineNo">2757</span> /**<a name="line.2757"></a> +<span class="sourceLineNo">2758</span> * Maintain information about a particular table.<a name="line.2758"></a> +<span class="sourceLineNo">2759</span> */<a name="line.2759"></a> +<span class="sourceLineNo">2760</span> public class TableInfo {<a name="line.2760"></a> +<span class="sourceLineNo">2761</span> TableName tableName;<a name="line.2761"></a> +<span class="sourceLineNo">2762</span> TreeSet <ServerName> deployedOn;<a name="line.2762"></a> +<span class="sourceLineNo">2763</span><a name="line.2763"></a> +<span class="sourceLineNo">2764</span> // backwards regions<a name="line.2764"></a> +<span class="sourceLineNo">2765</span> final List<HbckInfo> backwards = new ArrayList<>();<a name="line.2765"></a> +<span class="sourceLineNo">2766</span><a name="line.2766"></a> +<span class="sourceLineNo">2767</span> // sidelined big overlapped regions<a name="line.2767"></a> +<span class="sourceLineNo">2768</span> final Map<Path, HbckInfo> sidelinedRegions = new HashMap<>();<a name="line.2768"></a> <span class="sourceLineNo">2769</span><a name="line.2769"></a> -<span class="sourceLineNo">2770</span> // list of regions derived from meta entries.<a name="line.2770"></a> -<span class="sourceLineNo">2771</span> private ImmutableList<HRegionInfo> regionsFromMeta = null;<a name="line.2771"></a> +<span class="sourceLineNo">2770</span> // region split calculator<a name="line.2770"></a> +<span class="sourceLineNo">2771</span> final RegionSplitCalculator<HbckInfo> sc = new RegionSplitCalculator<>(cmp);<a name="line.2771"></a> <span class="sourceLineNo">2772</span><a name="line.2772"></a> -<span class="sourceLineNo">2773</span> TableInfo(TableName name) {<a name="line.2773"></a> -<span class="sourceLineNo">2774</span> this.tableName = name;<a name="line.2774"></a> -<span class="sourceLineNo">2775</span> deployedOn = new TreeSet <>();<a name="line.2775"></a> -<span class="sourceLineNo">2776</span> }<a name="line.2776"></a> -<span class="sourceLineNo">2777</span><a name="line.2777"></a> -<span class="sourceLineNo">2778</span> /**<a name="line.2778"></a> -<span class="sourceLineNo">2779</span> * @return descriptor common to all regions. null if are none or multiple!<a name="line.2779"></a> -<span class="sourceLineNo">2780</span> */<a name="line.2780"></a> -<span class="sourceLineNo">2781</span> private HTableDescriptor getHTD() {<a name="line.2781"></a> -<span class="sourceLineNo">2782</span> if (htds.size() == 1) {<a name="line.2782"></a> -<span class="sourceLineNo">2783</span> return (HTableDescriptor)htds.toArray()[0];<a name="line.2783"></a> -<span class="sourceLineNo">2784</span> } else {<a name="line.2784"></a> -<span class="sourceLineNo">2785</span> LOG.error("None/Multiple table descriptors found for table '"<a name="line.2785"></a> -<span class="sourceLineNo">2786</span> + tableName + "' regions: " + htds);<a name="line.2786"></a> -<span class="sourceLineNo">2787</span> }<a name="line.2787"></a> -<span class="sourceLineNo">2788</span> return null;<a name="line.2788"></a> -<span class="sourceLineNo">2789</span> }<a name="line.2789"></a> -<span class="sourceLineNo">2790</span><a name="line.2790"></a> -<span class="sourceLineNo">2791</span> public void addRegionInfo(HbckInfo hir) {<a name="line.2791"></a> -<span class="sourceLineNo">2792</span> if (Bytes.equals(hir.getEndKey(), HConstants.EMPTY_END_ROW)) {<a name="line.2792"></a> -<span class="sourceLineNo">2793</span> // end key is absolute end key, just add it.<a name="line.2793"></a> -<span class="sourceLineNo">2794</span> // ignore replicas other than primary for these checks<a name="line.2794"></a> -<span class="sourceLineNo">2795</span> if (hir.getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) sc.add(hir);<a name="line.2795"></a> -<span class="sourceLineNo">2796</span> return;<a name="line.2796"></a> +<span class="sourceLineNo">2773</span> // Histogram of different HTableDescriptors found. Ideally there is only one!<a name="line.2773"></a> +<span class="sourceLineNo">2774</span> final Set<HTableDescriptor> htds = new HashSet<>();<a name="line.2774"></a> +<span class="sourceLineNo">2775</span><a name="line.2775"></a> +<span class="sourceLineNo">2776</span> // key = start split, values = set of splits in problem group<a name="line.2776"></a> +<span class="sourceLineNo">2777</span> final Multimap<byte[], HbckInfo> overlapGroups =<a name="line.2777"></a> +<span class="sourceLineNo">2778</span> TreeMultimap.create(RegionSplitCalculator.BYTES_COMPARATOR, cmp);<a name="line.2778"></a> +<span class="sourceLineNo">2779</span><a name="line.2779"></a> +<span class="sourceLineNo">2780</span> // list of regions derived from meta entries.<a name="line.2780"></a> +<span class="sourceLineNo">2781</span> private ImmutableList<HRegionInfo> regionsFromMeta = null;<a name="line.2781"></a> +<span class="sourceLineNo">2782</span><a name="line.2782"></a> +<span class="sourceLineNo">2783</span> TableInfo(TableName name) {<a name="line.2783"></a> +<span class="sourceLineNo">2784</span> this.tableName = name;<a name="line.2784"></a> +<span class="sourceLineNo">2785</span> deployedOn = new TreeSet <>();<a name="line.2785"></a> +<span class="sourceLineNo">2786</span> }<a name="line.2786"></a> +<span class="sourceLineNo">2787</span><a name="line.2787"></a> +<span class="sourceLineNo">2788</span> /**<a name="line.2788"></a> +<span class="sourceLineNo">2789</span> * @return descriptor common to all regions. null if are none or multiple!<a name="line.2789"></a> +<span class="sourceLineNo">2790</span> */<a name="line.2790"></a> +<span class="sourceLineNo">2791</span> private HTableDescriptor getHTD() {<a name="line.2791"></a> +<span class="sourceLineNo">2792</span> if (htds.size() == 1) {<a name="line.2792"></a> +<span class="sourceLineNo">2793</span> return (HTableDescriptor)htds.toArray()[0];<a name="line.2793"></a> +<span class="sourceLineNo">2794</span> } else {<a name="line.2794"></a> +<span class="sourceLineNo">2795</span> LOG.error("None/Multiple table descriptors found for table '"<a name="line.2795"></a> +<span class="sourceLineNo">2796</span> + tableName + "' regions: " + htds);<a name="line.2796"></a> <span class="sourceLineNo">2797</span> }<a name="line.2797"></a> -<span class="sourceLineNo">2798</span><a name="line.2798"></a> -<span class="sourceLineNo">2799</span> // if not the absolute end key, check for cycle<a name="line.2799"></a> -<span class="sourceLineNo">2800</span> if (Bytes.compareTo(hir.getStartKey(), hir.getEndKey()) > 0) {<a name="line.2800"></a> -<span class="sourceLineNo">2801</span> errors.reportError(<a name="line.2801"></a> -<span class="sourceLineNo">2802</span> ERROR_CODE.REGION_CYCLE,<a name="line.2802"></a> -<span class="sourceLineNo">2803</span> String.format("The endkey for this region comes before the "<a name="line.2803"></a> -<span class="sourceLineNo">2804</span> + "startkey, startkey=%s, endkey=%s",<a name="line.2804"></a> -<span class="sourceLineNo">2805</span> Bytes.toStringBinary(hir.getStartKey()),<a name="line.2805"></a> -<span class="sourceLineNo">2806</span> Bytes.toStringBinary(hir.getEndKey())), this, hir);<a name="line.2806"></a> -<span class="sourceLineNo">2807</span> backwards.add(hir);<a name="line.2807"></a> -<span class="sourceLineNo">2808</span> return;<a name="line.2808"></a> -<span class="sourceLineNo">2809</span> }<a name="line.2809"></a> -<span class="sourceLineNo">2810</span><a name="line.2810"></a> -<span class="sourceLineNo">2811</span> // main case, add to split calculator<a name="line.2811"></a> -<span class="sourceLineNo">2812</span> // ignore replicas other than primary for these checks<a name="line.2812"></a> -<span class="sourceLineNo">2813</span> if (hir.getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) sc.add(hir);<a name="line.2813"></a> -<span class="sourceLineNo">2814</span> }<a name="line.2814"></a> -<span class="sourceLineNo">2815</span><a name="line.2815"></a> -<span class="sourceLineNo">2816</span> public void addServer(ServerName server) {<a name="line.2816"></a> -<span class="sourceLineNo">2817</span> this.deployedOn.add(server);<a name="line.2817"></a> -<span class="sourceLineNo">2818</span> }<a name="line.2818"></a> -<span class="sourceLineNo">2819</span><a name="line.2819"></a> -<span class="sourceLineNo">2820</span> public TableName getName() {<a name="line.2820"></a> -<span class="sourceLineNo">2821</span> return tableName;<a name="line.2821"></a> -<span class="sourceLineNo">2822</span> }<a name="line.2822"></a> -<span class="sourceLineNo">2823</span><a name="line.2823"></a> -<span class="sourceLineNo">2824</span> public int getNumRegions() {<a name="line.2824"></a> -<span class="sourceLineNo">2825</span> return sc.getStarts().size() + backwards.size();<a name="line.2825"></a> -<span class="sourceLineNo">2826</span> }<a name="line.2826"></a> -<span class="sourceLineNo">2827</span><a name="line.2827"></a> -<span class="sourceLineNo">2828</span> public synchronized ImmutableList<HRegionInfo> getRegionsFromMeta() {<a name="line.2828"></a> -<span class="sourceLineNo">2829</span> // lazy loaded, synchronized to ensure a single load<a name="line.2829"></a> -<span class="sourceLineNo">2830</span> if (regionsFromMeta == null) {<a name="line.2830"></a> -<span class="sourceLineNo">2831</span> List<HRegionInfo> regions = new ArrayList<>();<a name="line.2831"></a> -<span class="sourceLineNo">2832</span> for (HbckInfo h : HBaseFsck.this.regionInfoMap.values()) {<a name="line.2832"></a> -<span class="sourceLineNo">2833</span> if (tableName.equals(h.getTableName())) {<a name="line.2833"></a> -<span class="sourceLineNo">2834</span> if (h.metaEntry != null) {<a name="line.2834"></a> -<span class="sourceLineNo">2835</span> regions.add((HRegionInfo) h.metaEntry);<a name="line.2835"></a> -<span class="sourceLineNo">2836</span> }<a name="line.2836"></a> -<span class="sourceLineNo">2837</span> }<a name="line.2837"></a> -<span class="sourceLineNo">2838</span> }<a name="line.2838"></a> -<span class="sourceLineNo">2839</span> regionsFromMeta = Ordering.natural().immutableSortedCopy(regions);<a name="line.2839"></a> -<span class="sourceLineNo">2840</span> }<a name="line.2840"></a> -<span class="sourceLineNo">2841</span><a name="line.2841"></a> -<span class="sourceLineNo">2842</span> return regionsFromMeta;<a name="line.2842"></a> -<span class="sourceLineNo">2843</span> }<a name="line.2843"></a> -<span class="sourceLineNo">2844</span><a name="line.2844"></a> -<span class="sourceLineNo">2845</span> private class IntegrityFixSuggester extends TableIntegrityErrorHandlerImpl {<a name="line.2845"></a> -<span class="sourceLineNo">2846</span> ErrorReporter errors;<a name="line.2846"></a> -<span class="sourceLineNo">2847</span><a name="line.2847"></a> -<span class="sourceLineNo">2848</span> IntegrityFixSuggester(TableInfo ti, ErrorReporter errors) {<a name="line.2848"></a> -<span class="sourceLineNo">2849</span> this.errors = errors;<a name="line.2849"></a> -<span class="sourceLineNo">2850</span> setTableInfo(ti);<a name="line.2850"></a> -<span class="sourceLineNo">2851</span> }<a name="line.2851"></a> -<span class="sourceLineNo">2852</span><a name="line.2852"></a> -<span class="sourceLineNo">2853</span> @Override<a name="line.2853"></a> -<span class="sourceLineNo">2854</span> public void handleRegionStartKeyNotEmpty(HbckInfo hi) throws IOException{<a name="line.2854"></a> -<span class="sourceLineNo">2855</span> errors.reportError(ERROR_CODE.FIRST_REGION_STARTKEY_NOT_EMPTY,<a name="line.2855"></a> -<span class="sourceLineNo">2856</span> "First region should start with an empty key. You need to "<a name="line.2856"></a> -<span class="sourceLineNo">2857</span> + " create a new region and regioninfo in HDFS to plug the hole.",<a name="line.2857"></a> -<span class="sourceLineNo">2858</span> getTableInfo(), hi);<a name="line.2858"></a> -<span class="sourceLineNo">2859</span> }<a name="line.2859"></a> -<span class="sourceLineNo">2860</span><a name="line.2860"></a> -<span class="sourceLineNo">2861</span> @Override<a name="line.2861"></a> -<span class="sourceLineNo">2862</span> public void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException {<a name="line.2862"></a> -<span class="sourceLineNo">2863</span> errors.reportError(ERROR_CODE.LAST_REGION_ENDKEY_NOT_EMPTY,<a name="line.2863"></a> -<span class="sourceLineNo">2864</span> "Last region should end with an empty key. You need to "<a name="line.2864"></a> -<span class="sourceLineNo">2865</span> + "create a new region and regioninfo in HDFS to plug the hole.", getTableInfo());<a name="line.2865"></a> -<span class="sourceLineNo">2866</span> }<a name="line.2866"></a> -<span class="sourceLineNo">2867</span><a name="line.2867"></a> -<span class="sourceLineNo">2868</span> @Override<a name="line.2868"></a> -<span class="sourceLineNo">2869</span> public void handleDegenerateRegion(HbckInfo hi) throws IOException{<a name="line.2869"></a> -<span class="sourceLineNo">2870</span> errors.reportError(ERROR_CODE.DEGENERATE_REGION,<a name="line.2870"></a> -<span class="sourceLineNo">2871</span> "Region has the same start and end key.", getTableInfo(), hi);<a name="line.2871"></a> -<span class="sourceLineNo">2872</span> }<a name="line.2872"></a> -<span class="sourceLineNo">2873</span><a name="line.2873"></a> -<span class="sourceLineNo">2874</span> @Override<a name="line.2874"></a> -<span class="sourceLineNo">2875</span> public void handleDuplicateStartKeys(HbckInfo r1, HbckInfo r2) throws IOException{<a name="line.2875"></a> -<span class="sourceLineNo">2876</span> byte[] key = r1.getStartKey();<a name="line.2876"></a> -<span class="sourceLineNo">2877</span> // dup start key<a name="line.2877"></a> -<span class="sourceLineNo">2878</span> errors.reportError(ERROR_CODE.DUPE_STARTKEYS,<a name="line.2878"></a> -<span class="sourceLineNo">2879</span> "Multiple regions have the same startkey: "<a name="line.2879"></a> -<span class="sourceLineNo">2880</span> + Bytes.toStringBinary(key), getTableInfo(), r1);<a name="line.2880"></a> -<span class="sourceLineNo">2881</span> errors.reportError(ERROR_CODE.DUPE_STARTKEYS,<a name="line.2881"></a> -<span class="sourceLineNo">2882</span> "Multiple regions have the same startkey: "<a name="line.2882"></a> -<span class="sourceLineNo">2883</span> + Bytes.toStringBinary(key), getTableInfo(), r2);<a name="line.2883"></a> -<span class="sourceLineNo">2884</span> }<a name="line.2884"></a> -<span class="sourceLineNo">2885</span><a name="line.2885"></a> -<span class="sourceLineNo">2886</span> @Override<a name="line.2886"></a> -<span class="sourceLineNo">2887</span> public void handleSplit(HbckInfo r1, HbckInfo r2) throws IOException{<a name="line.2887"></a> -<span class="sourceLineNo">2888</span> byte[] key = r1.getStartKey();<a name="line.2888"></a> -<span class="sourceLineNo">2889</span> // dup start key<a name="line.2889"></a> -<span class="sourceLineNo">2890</span> errors.reportError(ERROR_CODE.DUPE_ENDKEYS,<a name="line.2890"></a> -<span class="sourceLineNo">2891</span> "Multiple regions have the same regionID: "<a name="line.2891"></a> -<span class="sourceLineNo">2892</span> + Bytes.toStringBinary(key), getTableInfo(), r1);<a name="line.2892"></a> -<span class="sourceLineNo">2893</span> errors.reportError(ERROR_CODE.DUPE_ENDKEYS,<a name="line.2893"></a> -<span class="sourceLineNo">2894</span> "Multiple regions have the same regionID: "<a name="line.2894"></a> -<span class="sourceLineNo">2895</span> + Bytes.toStringBinary(key), getTableInfo(), r2);<a name="line.2895"></a> -<span class="sourceLineNo">2896</span> }<a name="line.2896"></a> -<span class="sourceLineNo">2897</span><a name="line.2897"></a> -<span class="sourceLineNo">2898</span> @Override<a name="line.2898"></a> -<span class="sourceLineNo">2899</span> public void handleOverlapInRegionChain(HbckInfo hi1, HbckInfo hi2) throws IOException{<a name="line.2899"></a> -<span class="sourceLineNo">2900</span> errors.reportError(ERROR_CODE.OVERLAP_IN_REGION_CHAIN,<a name="line.2900"></a> -<span class="sourceLineNo">2901</span> "There is an overlap in the region chain.",<a name="line.2901"></a> -<span class="sourceLineNo">2902</span> getTableInfo(), hi1, hi2);<a name="line.2902"></a> -<span class="sourceLineNo">2903</span> }<a name="line.2903"></a> -<span class="sourceLineNo">2904</span><a name="line.2904"></a> -<span class="sourceLineNo">2905</span> @Override<a name="line.2905"></a> -<span class="sourceLineNo">2906</span> public void handleHoleInRegionChain(byte[] holeStart, byte[] holeStop) throws IOException{<a name="line.2906"></a> -<span class="sourceLineNo">2907</span> errors.reportError(<a name="line.2907"></a> -<span class="sourceLineNo">2908</span> ERROR_CODE.HOLE_IN_REGION_CHAIN,<a name="line.2908"></a> -<span class="sourceLineNo">2909</span> "There is a hole in the region chain between "<a name="line.2909"></a> -<span class="sourceLineNo">2910</span> + Bytes.toStringBinary(holeStart) + " and "<a name="line.2910"></a> -<span class="sourceLineNo">2911</span> + Bytes.toStringBinary(holeStop)<a name="line.2911"></a> -<span class="sourceLineNo">2912</span> + ". You need to create a new .regioninfo and region "<a name="line.2912"></a> -<span class="sourceLineNo">2913</span> + "dir in hdfs to plug the hole.");<a name="line.2913"></a> -<span class="sourceLineNo">2914</span> }<a name="line.2914"></a> -<span class="sourceLineNo">2915</span> };<a name="line.2915"></a> -<span class="sourceLineNo">2916</span><a name="line.2916"></a> -<span class="sourceLineNo">2917</span> /**<a name="line.2917"></a> -<span class="sourceLineNo">2918</span> * This handler fixes integrity errors from hdfs information. There are<a name="line.2918"></a> -<span class="sourceLineNo">2919</span> * basically three classes of integrity problems 1) holes, 2) overlaps, and<a name="line.2919"></a> -<span class="sourceLineNo">2920</span> * 3) invalid regions.<a name="line.2920"></a> -<span class="sourceLineNo">2921</span> *<a name="line.2921"></a> -<span class="sourceLineNo">2922</span> * This class overrides methods that fix holes and the overlap group case.<a name="line.2922"></a> -<span class="sourceLineNo">2923</span> * Individual cases of particular overlaps are handled by the general<a name="line.2923"></a> -<span class="sourceLineNo">2924</span> * overlap group merge repair case.<a name="line.2924"></a> -<span class="sourceLineNo">2925</span> *<a name="line.2925"></a> -<span class="sourceLineNo">2926</span> * If hbase is online, this forces regions offline before doing merge<a name="line.2926"></a> -<span class="sourceLineNo">2927</span> * operations.<a name="line.2927"></a> -<span class="sourceLineNo">2928</span> */<a name="line.2928"></a> -<span class="sourceLineNo">2929</span> private class HDFSIntegrityFixer extends IntegrityFixSuggester {<a name="line.2929"></a> -<span class="sourceLineNo">2930</span> Configuration conf;<a name="line.2930"></a> -<span class="sourceLineNo">2931</span><a name="line.2931"></a> -<span class="sourceLineNo">2932</span> boolean fixOverlaps = true;<a name="line.2932"></a> -<span class="sourceLineNo">2933</span><a name="line.2933"></a> -<span class="sourceLineNo">2934</span> HDFSIntegrityFixer(TableInfo ti, ErrorReporter errors, Configuration conf,<a name="line.2934"></a> -<span class="sourceLineNo">2935</span> boolean fixHoles, boolean fixOverlaps) {<a name="line.2935"></a> -<span class="sourceLineNo">2936</span> super(ti, errors);<a name="line.2936"></a> -<span class="sourceLineNo">2937</span> this.conf = conf;<a name="line.2937"></a> -<span class="sourceLineNo">2938</span> this.fixOverlaps = fixOverlaps;<a name="line.2938"></a> -<span class="sourceLineNo">2939</span> // TODO properly use fixHoles<a name="line.2939"></a> -<span class="sourceLineNo">2940</span> }<a name="line.2940"></a> +<span class="sourceLineNo">2798</span> return null;<a name="line.2798"></a> +<span class="sourceLineNo">2799</span> }<a name="line.2799"></a> +<span class="sourceLineNo">2800</span><a name="line.2800"></a> +<span class="sourceLineNo">2801</span> public void addRegionInfo(HbckInfo hir) {<a name="line.2801"></a> +<span class="sourceLineNo">2802</span> if (Bytes.equals(hir.getEndKey(), HConstants.EMPTY_END_ROW)) {<a name="line.2802"></a> +<span class="sourceLineNo">2803</span> // end key is absolute end key, just add it.<a name="line.2803"></a> +<span class="sourceLineNo">2804</span> // ignore replicas other than primary for these checks<a name="line.2804"></a> +<span class="sourceLineNo">2805</span> if (hir.getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) sc.add(hir);<a name="line.2805"></a> +<span class="sourceLineNo">2806</span> return;<a name="line.2806"></a> +<span class="sourceLineNo">2807</span> }<a name="line.2807"></a> +<span class="sourceLineNo">2808</span><a name="line.2808"></a> +<span class="sourceLineNo">2809</span> // if not the absolute end key, check for cycle<a name="line.2809"></a> +<span class="sourceLineNo">2810</span> if (Bytes.compareTo(hir.getStartKey(), hir.getEndKey()) > 0) {<a name="line.2810"></a> +<span class="sourceLineNo">2811</span> errors.reportError(<a name="line.2811"></a> +<span class="sourceLineNo">2812</span> ERROR_CODE.REGION_CYCLE,<a name="line.2812"></a> +<span class="sourceLineNo">2813</span> String.format("The endkey for this region comes before the "<a name="line.2813"></a> +<span class="sourceLineNo">2814</span> + "startkey, startkey=%s, endkey=%s",<a name="line.2814"></a> +<span class="sourceLineNo">2815</span> Bytes.toStringBinary(hir.getStartKey()),<a name="line.2815"></a> +<span class="sourceLineNo">2816</span> Bytes.toStringBinary(hir.getEndKey())), this, hir);<a name="line.2816"></a> +<span class="sourceLineNo">2817</span> backwards.add(hir);<a name="line.2817"></a> +<span class="sourceLineNo">2818</span> return;<a name="line.2818"></a> +<span class="sourceLineNo">2819</span> }<a name="line.2819"></a> +<span class="sourceLineNo">2820</span><a name="line.2820"></a> +<span class="sourceLineNo">2821</span> // main case, add to split calculator<a name="line.2821"></a> +<span class="sourceLineNo">2822</span> // ignore replicas other than primary for these checks<a name="line.2822"></a> +<span class="sourceLineNo">2823</span> if (hir.getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) sc.add(hir);<a name="line.2823"></a> +<span class="sourceLineNo">2824</span> }<a name="line.2824"></a> +<span class="sourceLineNo">2825</span><a name="line.2825"></a> +<span class="sourceLineNo">2826</span> public void addServer(ServerName server) {<a name="line.2826"></a> +<span class="sourceLineNo">2827</span> this.deployedOn.add(server);<a name="line.2827"></a> +<span class="sourceLineNo">2828</span> }<a name="line.2828"></a> +<span class="sourceLineNo">2829</span><a name="line.2829"></a> +<span class="sourceLineNo">2830</span> public TableName getName() {<a name="line.2830"></a> +<span class="sourceLineNo">2831</span> return tableName;<a name="line.2831"></a> +<span class="sourceLineNo">2832</span> }<a name="line.2832"></a> +<span class="sourceLineNo">2833</span><a name="line.2833"></a> +<span class="sourceLineNo">2834</span> public int getNumRegions() {<a name="line.2834"></a> +<span class="sourceLineNo">2835</span> return sc.getStarts().size() + backwards.size();<a name="line.2835"></a> +<span class="sourceLineNo">2836</span> }<a name="line.2836"></a> +<span class="sourceLineNo">2837</span><a name="line.2837"></a> +<span class="sourceLineNo">2838</span> public synchronized ImmutableList<HRegionInfo> getRegionsFromMeta() {<a name="line.2838"></a> +<span class="sourceLineNo">2839</span> // lazy loaded, synchronized to ensure a single load<a name="line.2839"></a> +<span class="sourceLineNo">2840</span> if (regionsFromMeta == null) {<a name="line.2840"></a> +<span class="sourceLineNo">2841</span> List<HRegionInfo> regions = new ArrayList<>();<a name="line.2841"></a> +<span class="sourceLineNo">2842</span> for (HbckInfo h : HBaseFsck.this.regionInfoMap.values()) {<a name="line.2842"></a> +<span class="sourceLineNo">2843</span> if (tableName.equals(h.getTableName())) {<a name="line.2843"></a> +<span class="sourceLineNo">2844</span> if (h.metaEntry != null) {<a name="line.2844"></a> +<span class="sourceLineNo">2845</span> regions.add((HRegionInfo) h.metaEntry);<a name="line.2845"></a> +<span class="sourceLineNo">2846</span> }<a name="line.2846"></a> +<span class="sourceLineNo">2847</span> }<a name="line.2847"></a> +<span class="sourceLineNo">2848</span> }<a name="line.2848"></a> +<span class="sourceLineNo">2849</span> regionsFromMeta = Ordering.natural().immutableSortedCopy(regions);<a name="line.2849"></a> +<span class="sourceLineNo">2850</span> }<a name="line.2850"></a> +<span class="sourceLineNo">2851</span><a name="line.2851"></a> +<span class="sourceLineNo">2852</span> return regionsFromMeta;<a name="line.2852"></a> +<span class="sourceLineNo">2853</span> }<a name="line.2853"></a> +<span class="sourceLineNo">2854</span><a name="line.2854"></a> +<span class="sourceLineNo">2855</span> private class IntegrityFixSuggester extends TableIntegrityErrorHandlerImpl {<a name="line.2855"></a> +<span class="sourceLineNo">2856</span> ErrorReporter errors;<a name="line.2856"></a> +<span class="sourceLineNo">2857</span><a name="line.2857"></a> +<span class="sourceLineNo">2858</span> IntegrityFixSuggester(TableInfo ti, ErrorReporter errors) {<a name="line.2858"></a> +<span class="sourceLineNo">2859</span> this.errors = errors;<a name="line.2859"></a> +<span class="sourceLineNo">2860</span> setTableInfo(ti);<a name="line.2860"></a> +<span class="sourceLineNo">2861</span> }<a name="line.2861"></a> +<span class="sourceLineNo">2862</span><a name="line.2862"></a> +<span class="sourceLineNo">2863</span> @Override<a name="line.2863"></a> +<span class="sourceLineNo">2864</span> public void handleRegionStartKeyNotEmpty(HbckInfo hi) throws IOException{<a name="line.2864"></a> +<span class="sourceLineNo">2865</span> errors.reportError(ERROR_CODE.FIRST_REGION_STARTKEY_NOT_EMPTY,<a name="line.2865"></a> +<span class="sourceLineNo">2866</span> "First region should start with an empty key. You need to "<a name="line.2866"></a> +<span class="sourceLineNo">2867</span> + " create a new region and regioninfo in HDFS to plug the hole.",<a name="line.2867"></a> +<span class="sourceLineNo">2868</span> getTableInfo(), hi);<a name="line.2868"></a> +<span class="sourceLineNo">2869</span> }<a name="line.2869"></a> +<span class="sourceLineNo">2870</span><a name="line.2870"></a> +<span class="sourceLineNo">2871</span> @Override<a name="line.2871"></a> +<span class="sourceLineNo">2872</span> public void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException {<a name="line.2872"></a> +<span class="sourceLineNo">2873</span> errors.reportError(ERROR_CODE.LAST_REGION_ENDKEY_NOT_EMPTY,<a name="line.2873"></a> +<span class="sourceLineNo">2874</span> "Last region should end with an empty key. You need to "<a name="line.2874"></a> +<span class="sourceLineNo">2875</span> + "create a new region and regioninfo in HDFS to plug the hole.", getTableInfo());<a name="line.2875"></a> +<span class="sourceLineNo">2876</span> }<a name="line.2876"></a> +<span class="sourceLineNo">2877</span><a name="line.2877"></a> +<span class="sourceLineNo">2878</span> @Override<a name="line.2878"></a> +<span class="sourceLineNo">2879</span> public void handleDegenerateRegion(HbckInfo hi) throws IOException{<a name="line.2879"></a> +<span class="sourceLineNo">2880</span> errors.reportError(ERROR_CODE.DEGENERATE_REGION,<a name="line.2880"></a> +<span class="sourceLineNo">2881</span> "Region has the same start and end key.", getTableInfo(), hi);<a name="line.2881"></a> +<span class="sourceLineNo">2882</span> }<a name="line.2882"></a> +<span class="sourceLineNo">2883</span><a name="line.2883"></a> +<span class="sourceLineNo">2884</span> @Override<a name="line.2884"></a> +<span class="sourceLineNo">2885</span> public void handleDuplicateStartKeys(HbckInfo r1, HbckInfo r2) throws IOException{<a name="line.2885"></a> +<span class="sourceLineNo">2886</span> byte[] key = r1.getStartKey();<a name="line.2886"></a> +<span class="sourceLineNo">2887</span> // dup start key<a name="line.2887"></a> +<span class="sourceLineNo">2888</span> errors.reportError(ERROR_CODE.DUPE_STARTKEYS,<a name="line.2888"></a> +<span class="sourceLineNo">2889</span> "Multiple regions have the same startkey: "<a name="line.2889"></a> +<span class="sourceLineNo">2890</span> + Bytes.toStringBinary(key), getTableInfo(), r1);<a name="line.2890"></a> +<span class="sourceLineNo">2891</span> errors.reportError(ERROR_CODE.DUPE_STARTKEYS,<a name="line.2891"></a> +<span class="sourceLineNo">2892</span> "Multiple regions have the same startkey: "<a name="line.2892"></a> +<span class="sourceLineNo">2893</span> + Bytes.toStringBinary(key), getTableInfo(), r2);<a name="line.2893"></a> +<span class="sourceLineNo">2894</span> }<a name="line.2894"></a> +<span class="sourceLineNo">2895</span><a name="line.2895"></a> +<span class="sourceLineNo">2896</span> @Override<a name="line.2896"></a> +<span class="sourceLineNo">2897</span> public void handleSplit(HbckInfo r1, HbckInfo r2) throws IOException{<a name="line.2897"></a> +<span class="sourceLineNo">2898</span> byte[] key = r1.getStartKey();<a name="line.2898"></a> +<span class="sourceLineNo">2899</span> // dup start key<a name="line.2899"></a> +<span class="sourceLineNo">2900</span> errors.reportError(ERROR_CODE.DUPE_ENDKEYS,<a name="line.2900"></a> +<span class="sourceLineNo">2901</span> "Multiple regions have the same regionID: "<a name="line.2901"></a> +<span class="sourceLineNo">2902</span> + Bytes.toStringBinary(key), getTableInfo(), r1);<a name="line.2902"></a> +<span class="sourceLineNo">2903</span> errors.reportError(ERROR_CODE.DUPE_ENDKEYS,<a name="line.2903"></a> +<span class="sourceLineNo">2904</span> "Multiple regions have the same regionID: "<a name="line.2904"></a> +<span class="sourceLineNo">2905</span> + Bytes.toStringBinary(key), getTableInfo(), r2);<a name="line.2905"></a> +<span class="sourceLineNo">2906</span> }<a name="line.2906"></a> +<span class="sourceLineNo">2907</span><a name="line.2907"></a> +<span class="sourceLineNo">2908</span> @Override<a name="line.2908"></a> +<span class="sourceLineNo">2909</span> public void handleOverlapInRegionChain(HbckInfo hi1, HbckInfo hi2) throws IOException{<a name="line.2909"></a> +<span class="sourceLineNo">2910</span> errors.reportError(ERROR_CODE.OVERLAP_IN_REGION_CHAIN,<a name="line.2910"></a> +<span class="sourceLineNo">2911</span> "There is an overlap in the region chain.",<a name="line.2911"></a> +<span class="sourceLineNo">2912</span> getTableInfo(), hi1, hi2);<a name="line.2912"></a> +<span class="sourceLineNo">2913</span> }<a name="line.2913"></a> +<span class="sourceLineNo">2914</span><a name="line.2914"></a> +<span class="sourceLineNo">2915</span> @Override<a name="line.2915"></a> +<span class="sourceLineNo">2916</span> public void handleHoleInRegionChain(byte[] holeStart, byte[] holeStop) throws IOException{<a name="line.2916"></a> +<span class="sourceLineNo">2917</span> errors.reportError(<a name="line.2917"></a> +<span class="sourceLineNo">2918</span> ERROR_CODE.HOLE_IN_REGION_
<TRUNCATED>