private ServerName findRegionLocation(TableName tableName, byte[] startKey, int replicaId) { return UTIL.getMiniHBaseCluster().getRegionServerThreads().stream() .map(t -> t.getRegionServer()) .filter(rs -> rs.getRegions(tableName).stream().map(Region::getRegionInfo) .anyMatch(r -> r.containsRow(startKey) && r.getReplicaId() == replicaId)) .findFirst().get().getServerName(); }
@Override public void accept(HRegion hRegion) { if (hRegion.getRegionInfo().containsRow(key3)) { Threads.shutdown(ealierBulkload);/// wait util the other bulkload finished } } } ;
c == 0 || (c > 0 && Bytes.compareTo(loc.getRegion().getStartKey(), req.row) < 0); } else { completed = loc.getRegion().containsRow(req.row);
@Override public void split(final TableName tableName, final byte[] splitPoint) throws IOException { checkTableExists(tableName); for (HRegionLocation loc : connection.locateRegions(tableName, false, false)) { ServerName sn = loc.getServerName(); if (sn == null) { continue; } RegionInfo r = loc.getRegion(); // check for parents if (r.isSplitParent()) { continue; } // if a split point given, only split that particular region if (r.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID || (splitPoint != null && !r.containsRow(splitPoint))) { continue; } // call out to master to do split now splitRegionAsync(r, splitPoint); } }
if (!regionToSplit.containsRow(bestSplitRow)) { throw new DoNotRetryIOException("Split row is not inside region key range splitKey:" + Bytes.toStringBinary(splitRow) + " region: " + regionToSplit);
byte[] splitKey = Bytes.toBytes("3"); HRegion regionToSplit = UTIL.getMiniHBaseCluster().getRegions(tableTwo).stream() .filter(r -> r.getRegionInfo().containsRow(splitKey)).findFirst().get(); regionToSplit.compact(true);
if (!regionInfo.containsRow(row)) { throw new IOException( "Unable to find region for " + Bytes.toStringBinary(row) + " in " + tableName);
if (region.containsRow(row)) { admin.compactRegion(region.getRegionName());
private void separateLocalAndRemoteMutations(Region region, List<Mutation> mutations, List<Mutation> localMutations, List<Mutation> remoteMutations) { RegionInfo regionInfo = region.getRegionInfo(); for (Mutation mutation : mutations) { if (regionInfo.containsRow(mutation.getRow())) { localMutations.add(mutation); } else { remoteMutations.add(mutation); } } }
private void separateLocalAndRemoteMutations(Table targetHTable, Region region, List<Mutation> mutations, List<Mutation> localRegionMutations, List<Mutation> remoteRegionMutations, boolean isPKChanging){ boolean areMutationsInSameTable = areMutationsInSameTable(targetHTable, region); //if we're writing to the same table, but the PK can change, that means that some //mutations might be in our current region, and others in a different one. if (areMutationsInSameTable && isPKChanging) { RegionInfo regionInfo = region.getRegionInfo(); for (Mutation mutation : mutations){ if (regionInfo.containsRow(mutation.getRow())){ localRegionMutations.add(mutation); } else { remoteRegionMutations.add(mutation); } } } else if (areMutationsInSameTable && !isPKChanging) { localRegionMutations.addAll(mutations); } else { remoteRegionMutations.addAll(mutations); } }
private boolean tryComplete(LocateRequest req, CompletableFuture<HRegionLocation> future, Optional<HRegionLocation> location) { if (future.isDone()) { return true; } if (!location.isPresent()) { return false; } HRegionLocation loc = location.get(); boolean completed; if (req.locateType.equals(RegionLocateType.BEFORE)) { // for locating the row before current row, the common case is to find the previous region // in reverse scan, so we check the endKey first. In general, the condition should be // startKey < req.row and endKey >= req.row. Here we split it to endKey == req.row || // (endKey > req.row && startKey < req.row). The two conditions are equal since startKey < // endKey. int c = Bytes.compareTo(loc.getRegion().getEndKey(), req.row); completed = c == 0 || (c > 0 && Bytes.compareTo(loc.getRegion().getStartKey(), req.row) < 0); } else { completed = loc.getRegion().containsRow(req.row); } if (completed) { future.complete(loc); return true; } else { return false; } } }
@Override public void split(final TableName tableName, final byte[] splitPoint) throws IOException { checkTableExists(tableName); for (HRegionLocation loc : connection.locateRegions(tableName, false, false)) { ServerName sn = loc.getServerName(); if (sn == null) { continue; } RegionInfo r = loc.getRegion(); // check for parents if (r.isSplitParent()) { continue; } // if a split point given, only split that particular region if (r.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID || (splitPoint != null && !r.containsRow(splitPoint))) { continue; } // call out to master to do split now splitRegionAsync(r, splitPoint); } }
tableMetaData.add(linkDelete); if (!region.getRegionInfo().containsRow(indexKey)) { Properties props = new Properties(); if (tenantId != null) {
final byte[] key = SchemaUtil.getTableKey(tenantId, schemaName, tableName); if (!region.getRegionInfo().containsRow(key)) { Properties props = new Properties(); if (tenantId != null) {
if (!regionInfo.containsRow(row)) { throw new IOException( "Unable to find region for " + Bytes.toStringBinary(row) + " in " + tableName);
private void separateLocalAndRemoteMutations(Region region, List<Mutation> mutations, List<Mutation> localMutations, List<Mutation> remoteMutations) { RegionInfo regionInfo = region.getRegionInfo(); for (Mutation mutation : mutations) { if (regionInfo.containsRow(mutation.getRow())) { localMutations.add(mutation); } else { remoteMutations.add(mutation); } } }
private void separateLocalAndRemoteMutations(Table targetHTable, Region region, List<Mutation> mutations, List<Mutation> localRegionMutations, List<Mutation> remoteRegionMutations, boolean isPKChanging){ boolean areMutationsInSameTable = areMutationsInSameTable(targetHTable, region); //if we're writing to the same table, but the PK can change, that means that some //mutations might be in our current region, and others in a different one. if (areMutationsInSameTable && isPKChanging) { RegionInfo regionInfo = region.getRegionInfo(); for (Mutation mutation : mutations){ if (regionInfo.containsRow(mutation.getRow())){ localRegionMutations.add(mutation); } else { remoteRegionMutations.add(mutation); } } } else if (areMutationsInSameTable && !isPKChanging) { localRegionMutations.addAll(mutations); } else { remoteRegionMutations.addAll(mutations); } }
@Override public CompletableFuture<HRegionLocation> getRegionLocation(byte[] row, boolean reload) { return FutureUtils.toCompletableFuture(getRegionsAsync(reload)) .thenApplyAsync(result -> { for (HRegionLocation region : result) { if (region.getRegion().containsRow(row)) { hRegionLocation = region; break; } } return hRegionLocation; }); }
@Override public CompletableFuture<HRegionLocation> getRegionLocation(byte[] row, boolean reload) { return FutureUtils.toCompletableFuture(getRegionsAsync(reload)) .thenApplyAsync(result -> { for (HRegionLocation region : result) { if (region.getRegion().containsRow(row)) { hRegionLocation = region; break; } } return hRegionLocation; }); }
@Override public void accept(HRegion hRegion) { if (hRegion.getRegionInfo().containsRow(key3)) { Threads.shutdown(ealierBulkload);/// wait util the other bulkload finished } } } ;