HBASE-27369 BufferedMutator#mutate supports mutation type verification

This commit is contained in:
LiangJun He 2022-09-15 09:11:08 +08:00
parent 3f38dcd3f9
commit 8a960d3ccd
2 changed files with 4 additions and 1 deletions

View File

@ -56,6 +56,9 @@ public interface AsyncBufferedMutator extends Closeable {
* @param mutation The data to send.
*/
default CompletableFuture<Void> mutate(Mutation mutation) {
if (!(mutation instanceof Put) && !(mutation instanceof Delete)) {
throw new UnsupportedOperationException("Only supports Put and Delete mutation");
}
return Iterables.getOnlyElement(mutate(Collections.singletonList(mutation)));
}

View File

@ -77,7 +77,7 @@ class BufferedMutatorOverAsyncBufferedMutator implements BufferedMutator {
@Override
public void mutate(Mutation mutation) throws IOException {
if (!(mutation instanceof Put) && !(mutation instanceof Delete)) {
throw new IOException("Only supports Put and Delete mutation");
throw new UnsupportedOperationException("Only supports Put and Delete mutation");
}
mutate(Collections.singletonList(mutation));
}