001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.master.hbck; 019 020import java.time.Instant; 021import java.util.HashMap; 022import java.util.HashSet; 023import java.util.List; 024import java.util.Map; 025import java.util.Set; 026import org.apache.hadoop.fs.Path; 027import org.apache.hadoop.hbase.ServerName; 028import org.apache.hadoop.hbase.util.HbckRegionInfo; 029import org.apache.hadoop.hbase.util.Pair; 030import org.apache.yetus.audience.InterfaceAudience; 031 032/** 033 * The result of an {@link HbckChore} execution. 034 */ 035@InterfaceAudience.Private 036public class HbckReport { 037 038 private final Map<String, HbckRegionInfo> regionInfoMap = new HashMap<>(); 039 private final Set<String> disabledTableRegions = new HashSet<>(); 040 private final Set<String> splitParentRegions = new HashSet<>(); 041 private final Map<String, ServerName> orphanRegionsOnRS = new HashMap<>(); 042 private final Map<String, Path> orphanRegionsOnFS = new HashMap<>(); 043 private final Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegions = 044 new HashMap<>(); 045 046 private Instant checkingStartTimestamp = null; 047 private Instant checkingEndTimestamp = null; 048 049 /** 050 * Used for web ui to show when the HBCK checking started. 051 */ 052 public Instant getCheckingStartTimestamp() { 053 return checkingStartTimestamp; 054 } 055 056 public void setCheckingStartTimestamp(Instant checkingStartTimestamp) { 057 this.checkingStartTimestamp = checkingStartTimestamp; 058 } 059 060 /** 061 * Used for web ui to show when the HBCK checking report generated. 062 */ 063 public Instant getCheckingEndTimestamp() { 064 return checkingEndTimestamp; 065 } 066 067 public void setCheckingEndTimestamp(Instant checkingEndTimestamp) { 068 this.checkingEndTimestamp = checkingEndTimestamp; 069 } 070 071 /** 072 * This map contains the state of all hbck items. It maps from encoded region name to 073 * HbckRegionInfo structure. The information contained in HbckRegionInfo is used to detect and 074 * correct consistency (hdfs/meta/deployment) problems. 075 */ 076 public Map<String, HbckRegionInfo> getRegionInfoMap() { 077 return regionInfoMap; 078 } 079 080 public Set<String> getDisabledTableRegions() { 081 return disabledTableRegions; 082 } 083 084 public Set<String> getSplitParentRegions() { 085 return splitParentRegions; 086 } 087 088 /** 089 * The regions only opened on RegionServers, but no region info in meta. 090 */ 091 public Map<String, ServerName> getOrphanRegionsOnRS() { 092 return orphanRegionsOnRS; 093 } 094 095 /** 096 * The regions have directory on FileSystem, but no region info in meta. 097 */ 098 public Map<String, Path> getOrphanRegionsOnFS() { 099 return orphanRegionsOnFS; 100 } 101 102 /** 103 * The inconsistent regions. There are three case: case 1. Master thought this region opened, but 104 * no regionserver reported it. case 2. Master thought this region opened on Server1, but 105 * regionserver reported Server2 case 3. More than one regionservers reported opened this region 106 */ 107 public Map<String, Pair<ServerName, List<ServerName>>> getInconsistentRegions() { 108 return inconsistentRegions; 109 } 110}