/** * @return the encoded region name */ @Override public synchronized String getEncodedName() { if (this.encodedName == null) { this.encodedName = RegionInfo.encodeRegionName(this.regionName); } return this.encodedName; }
/** * @param regionName * @return the encodedName * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 * Use {@link org.apache.hadoop.hbase.client.RegionInfo#encodeRegionName(byte[])}. */ @Deprecated public static String encodeRegionName(final byte [] regionName) { return RegionInfo.encodeRegionName(regionName); }
/** * @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) { String encodedRegionName = RegionInfo.encodeRegionName(regionName); return this.onlineRegions.get(encodedRegionName); }
private String getFailedRegions() { return exceptions.keySet().stream() .map(regionName -> RegionInfo.prettyPrint(RegionInfo.encodeRegionName(regionName))) .collect(Collectors.toList()) .toString(); }
private byte[] toEncodeRegionName(byte[] regionName) { try { return RegionInfo.isEncodedRegionName(regionName) ? regionName : Bytes.toBytes(RegionInfo.encodeRegionName(regionName)); } catch (IOException e) { return regionName; } }
/** * Protected Utility method for safely obtaining an HRegion handle. * * @param regionName * Name of online {@link HRegion} to return * @return {@link HRegion} for <code>regionName</code> * @throws NotServingRegionException */ protected HRegion getRegion(final byte[] regionName) throws NotServingRegionException { String encodedRegionName = RegionInfo.encodeRegionName(regionName); return getRegionByEncodedName(regionName, encodedRegionName); }
private boolean isParentFinished(byte[] regionName) throws IOException { long[] barriers = MetaTableAccessor.getReplicationBarrier(conn, regionName); if (barriers.length == 0) { return true; } return isRangeFinished(barriers[barriers.length - 1], RegionInfo.encodeRegionName(regionName)); }
public static List<String> getTableEncodedRegionNamesForSerialReplication(Connection conn, TableName tableName) throws IOException { List<String> list = new ArrayList<>(); scanMeta(conn, getTableStartRowForMeta(tableName, QueryType.REPLICATION), getTableStopRowForMeta(tableName, QueryType.REPLICATION), QueryType.REPLICATION, new FirstKeyOnlyFilter(), Integer.MAX_VALUE, r -> { list.add(RegionInfo.encodeRegionName(r.getRow())); return true; }); return list; }
public static List<Pair<String, Long>> getTableEncodedRegionNameAndLastBarrier(Connection conn, TableName tableName) throws IOException { List<Pair<String, Long>> list = new ArrayList<>(); scanMeta(conn, getTableStartRowForMeta(tableName, QueryType.REPLICATION), getTableStopRowForMeta(tableName, QueryType.REPLICATION), QueryType.REPLICATION, r -> { byte[] value = r.getValue(HConstants.REPLICATION_BARRIER_FAMILY, HConstants.SEQNUM_QUALIFIER); if (value == null) { return true; } long lastBarrier = Bytes.toLong(value); String encodedRegionName = RegionInfo.encodeRegionName(r.getRow()); list.add(Pair.newPair(encodedRegionName, lastBarrier)); return true; }); return list; }
byte[] encodedRegionName = Bytes.toBytes(RegionInfo.encodeRegionName(entry.getKey())); Long existingValue = flushedSequenceIdByRegion.get(encodedRegionName); long l = entry.getValue().getCompletedSequenceId();
MutableRegionInfo(final TableName tableName, final byte[] startKey, final byte[] endKey, final boolean split, final long regionId, final int replicaId, boolean offLine, byte[] regionName) { this(checkTableName(tableName), checkStartKey(startKey), checkEndKey(endKey), split, regionId, checkReplicaId(replicaId), offLine, regionName, RegionInfo.encodeRegionName(regionName)); }
Bytes.toBytes(RegionInfo.encodeRegionName(ri.getRegionName())); len += encodedRegionName.length;
MutableRegionInfo(final TableName tableName, final byte[] startKey, final byte[] endKey, final boolean split, final long regionId, final int replicaId, boolean offLine, byte[] regionName, String encodedName) { this.tableName = checkTableName(tableName); this.startKey = checkStartKey(startKey); this.endKey = checkEndKey(endKey); this.split = split; this.regionId = regionId; this.replicaId = checkReplicaId(replicaId); this.offLine = offLine; if (ArrayUtils.isEmpty(regionName)) { this.regionName = RegionInfo.createRegionName(this.tableName, this.startKey, this.regionId, this.replicaId, !this.tableName.equals(TableName.META_TABLE_NAME)); this.encodedName = RegionInfo.encodeRegionName(this.regionName); } else { this.regionName = regionName; this.encodedName = encodedName; } this.hashCode = generateHashCode( this.tableName, this.startKey, this.endKey, this.regionId, this.replicaId, this.offLine, this.regionName); this.encodedNameAsBytes = Bytes.toBytes(this.encodedName); } /**
for (String peer : peers) { for (byte[] regionName : regionNames) { batch.add(RegionInfo.encodeRegionName(regionName)); if (batch.size() % 100 == 0) { queueStorage.removeLastSequenceIds(peer, batch);
/** * 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 { ByteString value = regionSpecifier.getValue(); RegionSpecifierType type = regionSpecifier.getType(); switch (type) { case REGION_NAME: return org.apache.hadoop.hbase.client.RegionInfo.encodeRegionName(value.toByteArray()); case ENCODED_REGION_NAME: return value.toStringUtf8(); default: throw new DoNotRetryIOException( "Unsupported region specifier type: " + type); } }
@InterfaceAudience.Private static String getRegionNameAsString(@CheckForNull RegionInfo ri, byte[] regionName) { if (RegionInfo.hasEncodedName(regionName)) { // new format region names already have their encoded name. return Bytes.toStringBinary(regionName); } // old format. regionNameStr doesn't have the region name. if (ri == null) { return Bytes.toStringBinary(regionName) + "." + RegionInfo.encodeRegionName(regionName); } else { return Bytes.toStringBinary(regionName) + "." + ri.getEncodedName(); } }
/** * Extract the region encoded name from the region manifest */ static String getRegionNameFromManifest(final SnapshotRegionManifest manifest) { byte[] regionName = RegionInfo.createRegionName( ProtobufUtil.toTableName(manifest.getRegionInfo().getTableName()), manifest.getRegionInfo().getStartKey().toByteArray(), manifest.getRegionInfo().getRegionId(), true); return RegionInfo.encodeRegionName(regionName); }
continue; String encodedRegionName = RegionInfo.encodeRegionName(regionName); long pushedSeqId = Long.MAX_VALUE; for (String peerId : peerIds) {
public static ReplicationBarrierResult getReplicationBarrierResult(Connection conn, TableName tableName, byte[] row, byte[] encodedRegionName) throws IOException { byte[] metaStartKey = RegionInfo.createRegionName(tableName, row, HConstants.NINES, false); byte[] metaStopKey = RegionInfo.createRegionName(tableName, HConstants.EMPTY_START_ROW, "", false); Scan scan = new Scan().withStartRow(metaStartKey).withStopRow(metaStopKey) .addColumn(getCatalogFamily(), getRegionStateColumn()) .addFamily(HConstants.REPLICATION_BARRIER_FAMILY).readAllVersions().setReversed(true) .setCaching(10); try (Table table = getMetaHTable(conn); ResultScanner scanner = table.getScanner(scan)) { for (Result result;;) { result = scanner.next(); if (result == null) { return new ReplicationBarrierResult(new long[0], null, Collections.emptyList()); } byte[] regionName = result.getRow(); // TODO: we may look up a region which has already been split or merged so we need to check // whether the encoded name matches. Need to find a way to quit earlier when there is no // record for the given region, for now it will scan to the end of the table. if (!Bytes.equals(encodedRegionName, Bytes.toBytes(RegionInfo.encodeRegionName(regionName)))) { continue; } return getReplicationBarrierResult(result); } } }
Bytes.toBytes(RegionInfo.encodeRegionName(Bytes.toBytes(targetRegion))), Bytes.toBytes(targetServer.getServerName())); TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {