Index: hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java =================================================================== --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (revision 1483123) +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (working copy) @@ -2553,6 +2553,24 @@ } /** + * List all the completed snapshots matching the given pattern. + * + * @param pattern The compiled regular expression to match against + * @return - returns a List of SnapshotDescription + * @throws IOException if a remote or network exception occurs + */ + public List listSnapshots(Pattern pattern) throws IOException { + List matched = new LinkedList(); + List snapshots = listSnapshots(); + for (SnapshotDescription snapshot : snapshots) { + if (pattern.matcher(snapshot.getName()).matches()) { + matched.add(snapshot); + } + } + return matched; + } + + /** * Delete an existing snapshot. * @param snapshotName name of the snapshot * @throws IOException if a remote or network exception occurs @@ -2583,6 +2601,27 @@ } /** + * Delete existing snapshots whose names match the pattern passed. + * @param pattern pattern for names of the snapshot to match + * @throws IOException if a remote or network exception occurs + */ + public void deleteSnapshot(final Pattern pattern) throws IOException { + List snapshots = listSnapshots(pattern); + for (final SnapshotDescription snapshot : snapshots) { + // do the delete + execute(new MasterAdminCallable() { + @Override + public Void call() throws ServiceException { + masterAdmin.deleteSnapshot( + null, + DeleteSnapshotRequest.newBuilder().setSnapshot(snapshot).build()); + return null; + } + }); + } + } + + /** * @see {@link #execute(MasterAdminCallable)} */ private abstract static class MasterAdminCallable implements Callable{