vaijosh commented on code in PR #5462:
URL: https://github.com/apache/hbase/pull/5462#discussion_r1363735051
##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java:
##########
@@ -1623,6 +1623,61 @@ private CompletableFuture<Void> split(final RegionInfo
hri, byte[] splitPoint) {
return future;
}
+ @Override
+ public CompletableFuture<Void> truncateRegion(byte[] regionName) {
+ CompletableFuture<Void> future = new CompletableFuture<>();
+ addListener(getRegionLocation(regionName), (location, err) -> {
+ if (err != null) {
+ future.completeExceptionally(err);
+ return;
+ }
+ RegionInfo regionInfo = location.getRegion();
+ if (regionInfo.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID) {
+ future.completeExceptionally(new IllegalArgumentException(
+ "Can't truncate replicas directly.Replicas are auto-truncated "
+ + "when their primary is truncated."));
+ return;
+ }
+ ServerName serverName = location.getServerName();
+ if (serverName == null) {
+ future
+ .completeExceptionally(new
NoServerForRegionException(Bytes.toStringBinary(regionName)));
+ return;
+ }
+ addListener(truncate_region(regionInfo), (ret, err2) -> {
+ if (err2 != null) {
+ future.completeExceptionally(err2);
+ } else {
+ future.complete(ret);
+ }
+ });
+ });
+ return future;
+ }
+
+ private CompletableFuture<Void> truncate_region(final RegionInfo hri) {
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]