@Override public Future<Void> splitRegionAsync(byte[] regionName, byte[] splitPoint) throws IOException { byte[] encodedNameofRegionToSplit = HRegionInfo.isEncodedRegionName(regionName) ? regionName : Bytes.toBytes(HRegionInfo.encodeRegionName(regionName)); Pair<RegionInfo, ServerName> pair = getRegion(regionName); if (pair != null) { if (pair.getFirst() != null && pair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) { throw new IllegalArgumentException ("Can't invoke split on non-default regions directly"); } } else { throw new UnknownRegionException ( "Can't invoke merge on unknown region " + Bytes.toStringBinary(encodedNameofRegionToSplit)); } return splitRegionAsync(pair.getFirst(), splitPoint); }
for (int i = 0; i < victimRegionCount; ++i) { int victimIx = RandomUtils.nextInt(0, regions.size()); String regionId = HRegionInfo.encodeRegionName(regions.remove(victimIx)); victimRegions.add(Bytes.toBytes(regionId));
Path rootDir = FSUtils.getRootDir(getConf()); Path tableDir = FSUtils.getTableDir(rootDir, TableName.valueOf(hri[0])); String enc = HRegionInfo.encodeRegionName(rn); Path regionDir = new Path(tableDir, enc); if (verbose)
encodedNameofRegionsToMerge[i] = HRegionInfo.isEncodedRegionName(nameofRegionsToMerge[i]) ? nameofRegionsToMerge[i] : Bytes.toBytes(HRegionInfo.encodeRegionName(nameofRegionsToMerge[i]));
@Override public Future<Void> splitRegionAsync(byte[] regionName, byte[] splitPoint) throws IOException { byte[] encodedNameofRegionToSplit = HRegionInfo.isEncodedRegionName(regionName) ? regionName : Bytes.toBytes(HRegionInfo.encodeRegionName(regionName)); Pair<RegionInfo, ServerName> pair = getRegion(regionName); if (pair != null) { if (pair.getFirst() != null && pair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) { throw new IllegalArgumentException ("Can't invoke split on non-default regions directly"); } } else { throw new UnknownRegionException ( "Can't invoke merge on unknown region " + Bytes.toStringBinary(encodedNameofRegionToSplit)); } return splitRegionAsync(pair.getFirst(), splitPoint); }
/** @return the encoded region name */ public synchronized String getEncodedName() { if (this.encodedName == NO_HASH) { this.encodedName = encodeRegionName(this.regionName); } return this.encodedName; }
/** @return the encoded region name */ public synchronized String getEncodedName() { if (this.encodedName == null) { this.encodedName = encodeRegionName(this.regionName); } return this.encodedName; }
/** * @param regionName * @return HRegion for the passed binary <code>regionName</code> or null if * named region is not member of the online regions. */ public Region getOnlineRegion(final byte[] regionName) { String encodedRegionName = HRegionInfo.encodeRegionName(regionName); return this.onlineRegions.get(encodedRegionName); }
encodedNameofRegionsToMerge[i] = HRegionInfo.isEncodedRegionName(nameofRegionsToMerge[i]) ? nameofRegionsToMerge[i] : Bytes.toBytes(HRegionInfo.encodeRegionName(nameofRegionsToMerge[i]));
/** * @param regionName * @return HRegion for the passed binary <code>regionName</code> or null if * named region is not member of the online regions. */ public HRegion getOnlineRegion(final byte[] regionName) { return getFromOnlineRegions(HRegionInfo.encodeRegionName(regionName)); }
/** * Protected utility method for safely obtaining an HRegion handle. * * @param regionName * Name of online {@link Region} to return * @return {@link Region} for <code>regionName</code> * @throws NotServingRegionException */ protected Region getRegion(final byte[] regionName) throws NotServingRegionException { String encodedRegionName = HRegionInfo.encodeRegionName(regionName); return getRegionByEncodedName(regionName, encodedRegionName); }
/** * Get the directory to archive a store directory * @param conf {@link Configuration} to read for the archive directory name. Can be null. * @param region parent region information under which the store currently lives * @param tabledir directory for the table under which the store currently lives * @param family name of the family in the store * @return {@link Path} to the directory to archive the given store or <tt>null</tt> if it should * not be archived */ public static Path getStoreArchivePath(Configuration conf, HRegionInfo region, Path tabledir, byte[] family) { Path tableArchiveDir = getTableArchivePath(tabledir); return Store.getStoreHomedir(tableArchiveDir, HRegionInfo.encodeRegionName(region.getRegionName()), family); }
/** * Find the HRegion encoded name based on a region specifier * * @param regionSpecifier the region specifier * @return the corresponding region's encoded name * @throws DoNotRetryIOException if the specifier type is unsupported */ public static String getRegionEncodedName( final RegionSpecifier regionSpecifier) throws DoNotRetryIOException { byte[] value = regionSpecifier.getValue().toByteArray(); RegionSpecifierType type = regionSpecifier.getType(); switch (type) { case REGION_NAME: return HRegionInfo.encodeRegionName(value); case ENCODED_REGION_NAME: return Bytes.toString(value); default: throw new DoNotRetryIOException( "Unsupported region specifier type: " + type); } }
@SuppressWarnings("deprecation") public static Map<String, Map<String, String>> versionedRegionMap(HBaseAdmin admin, long timestamp) throws IOException { Map<String, Map<String, String>> regionLocationMap = new HashMap<>(); try (HTable metaTable = new HTable(admin.getConfiguration(), metaTableName())) { Scan scan = new Scan(); scan.setSmall(true); scan.setCaching(1000); scan.setMaxVersions(); ResultScanner scanner = metaTable.getScanner(scan); for (Result result : scanner) { List<Cell> columnCells = result.getColumnCells("info".getBytes(), "server".getBytes()); for (Cell cell : columnCells) { if (cell.getTimestamp() <= timestamp) { String tableName = Bytes.toString(HRegionInfo.getTableName(cell.getRow())); String encodeRegionName = HRegionInfo.encodeRegionName(cell.getRow()); String regionServer = Bytes.toString(cell.getValue()).replaceAll(":", ","); Map<String, String> innerMap = regionLocationMap.get(tableName); if (innerMap == null) { innerMap = new HashMap<>(); regionLocationMap.put(tableName, innerMap); } if (innerMap.get(encodeRegionName) == null) innerMap.put(encodeRegionName, regionServer); } } } } return regionLocationMap; }
Map<byte[], RegionLoad> regionsLoad = hsl.getRegionsLoad(); for (Entry<byte[], RegionLoad> entry : regionsLoad.entrySet()) { byte[] encodedRegionName = Bytes.toBytes(HRegionInfo.encodeRegionName(entry.getKey())); Long existingValue = flushedSequenceIdByRegion.get(encodedRegionName); long l = entry.getValue().getCompleteSequenceId();
@Override public Future<Void> splitRegionAsync(byte[] regionName, byte[] splitPoint) throws IOException { byte[] encodedNameofRegionToSplit = HRegionInfo.isEncodedRegionName(regionName) ? regionName : Bytes.toBytes(HRegionInfo.encodeRegionName(regionName)); Pair<RegionInfo, ServerName> pair = getRegion(regionName); if (pair != null) { if (pair.getFirst() != null && pair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) { throw new IllegalArgumentException ("Can't invoke split on non-default regions directly"); } } else { throw new UnknownRegionException ( "Can't invoke merge on unknown region " + Bytes.toStringBinary(encodedNameofRegionToSplit)); } return splitRegionAsync(pair.getFirst(), splitPoint); }
for (int i = 0; i < victimRegionCount; ++i) { int victimIx = RandomUtils.nextInt(0, regions.size()); String regionId = HRegionInfo.encodeRegionName(regions.remove(victimIx)); victimRegions.add(Bytes.toBytes(regionId));
/** * Update a region state. It will be put in transition if not already there. * * If we can't find the region info based on the region name in * the transition, log a warning and return null. */ public RegionState updateRegionState( final RegionTransition transition, final State state) { byte [] regionName = transition.getRegionName(); HRegionInfo regionInfo = getRegionInfo(regionName); if (regionInfo == null) { String prettyRegionName = HRegionInfo.prettyPrint( HRegionInfo.encodeRegionName(regionName)); LOG.warn("Failed to find region " + prettyRegionName + " in updating its state to " + state + " based on region transition " + transition); return null; } return updateRegionState(regionInfo, state, transition.getServerName()); }
/** * Extract the region encoded name from the region manifest */ static String getRegionNameFromManifest(final SnapshotRegionManifest manifest) { byte[] regionName = HRegionInfo.createRegionName( ProtobufUtil.toTableName(manifest.getRegionInfo().getTableName()), manifest.getRegionInfo().getStartKey().toByteArray(), manifest.getRegionInfo().getRegionId(), true); return HRegionInfo.encodeRegionName(regionName); }
/** * Get the HRegionInfo from cache, if not there, from the hbase:meta table * @param regionName * @return HRegionInfo for the region */ @SuppressWarnings("deprecation") protected HRegionInfo getRegionInfo(final byte [] regionName) { String encodedName = HRegionInfo.encodeRegionName(regionName); RegionState regionState = getRegionState(encodedName); if (regionState != null) { return regionState.getRegion(); } try { Pair<HRegionInfo, ServerName> p = MetaTableAccessor.getRegion(server.getConnection(), regionName); HRegionInfo hri = p == null ? null : p.getFirst(); if (hri != null) { createRegionState(hri); } return hri; } catch (IOException e) { server.abort("Aborting because error occoured while reading " + Bytes.toStringBinary(regionName) + " from hbase:meta", e); return null; } }