/** * Lists all of the table regions currently in META. * @param conf * @param offlined True if we are to include offlined regions, false and we'll * leave out offlined regions from returned list. * @return Map of all user-space regions to servers * @throws IOException * @deprecated Use {@link #allTableRegions(Connection, TableName)} instead */ @Deprecated public static NavigableMap<HRegionInfo, ServerName> allTableRegions(Configuration conf, Connection connection, final TableName tableName, boolean offlined) throws IOException { return allTableRegions(connection, tableName); }
/** * Gets all the regions and their address for this table. * <p> * This is mainly useful for the MapReduce integration. * @return A map of HRegionInfo with it's server address * @throws IOException if a remote or network exception occurs * @deprecated This is no longer a public API. Use {@link #getAllRegionLocations()} instead. */ @Deprecated public NavigableMap<HRegionInfo, ServerName> getRegionLocations() throws IOException { // TODO: Odd that this returns a Map of HRI to SN whereas getRegionLocator, singular, returns an HRegionLocation. return MetaScanner.allTableRegions(this.connection, getName()); }
@Override public List<HRegionLocation> getAllRegionLocations() throws IOException { NavigableMap<HRegionInfo, ServerName> locations = MetaScanner.allTableRegions(this.connection, getName()); ArrayList<HRegionLocation> regions = new ArrayList<>(locations.size()); for (Entry<HRegionInfo, ServerName> entry : locations.entrySet()) { regions.add(new HRegionLocation(entry.getKey(), entry.getValue())); } return regions; }
/** * Gets all the regions and their address for this table. * <p> * This is mainly useful for the MapReduce integration. * @return A map of HRegionInfo with it's server address * @throws IOException if a remote or network exception occurs */ public NavigableMap<HRegionInfo, ServerName> getRegionLocations() throws IOException { return MetaScanner.allTableRegions(getConfiguration(), getTableName(), false); }
@Override public List<HRegionLocation> locateRegions(final TableName tableName, final boolean useCache, final boolean offlined) throws IOException { NavigableMap<HRegionInfo, ServerName> regions = MetaScanner.allTableRegions(this, tableName); final List<HRegionLocation> locations = new ArrayList<HRegionLocation>(); for (HRegionInfo regionInfo : regions.keySet()) { RegionLocations list = locateRegion(tableName, regionInfo.getStartKey(), useCache, true); if (list != null) { for (HRegionLocation loc : list.getRegionLocations()) { if (loc != null) { locations.add(loc); } } } } return locations; }
String tableName = tableResource.getName(); TableInfoModel model = new TableInfoModel(tableName); Map<HRegionInfo,ServerName> regions = MetaScanner.allTableRegions( servlet.getConfiguration(), Bytes.toBytes(tableName), false); for (Map.Entry<HRegionInfo,ServerName> e: regions.entrySet()) {
/** * Initialize namespace state cache by scanning meta table. */ private void initialize() throws IOException { List<NamespaceDescriptor> namespaces = this.master.listNamespaceDescriptors(); for (NamespaceDescriptor namespace : namespaces) { addNamespace(namespace.getName()); List<TableName> tables = this.master.listTableNamesByNamespace(namespace.getName()); for (TableName table : tables) { if (table.isSystemTable()) { continue; } int regionCount = 0; Map<HRegionInfo, ServerName> regions = MetaScanner.allTableRegions(this.master.getConnection(), table); for (HRegionInfo info : regions.keySet()) { if (!info.isSplit()) { regionCount++; } } addTable(table, regionCount); } } LOG.info("Finished updating state of " + nsStateCache.size() + " namespaces. "); initialized = true; }