diff --git a/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java b/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java
index fbca2c3..95a08bc 100644
--- a/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java
+++ b/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java
@@ -373,6 +373,26 @@ public class SnapshotManager implements Stoppable {
}
/**
+ * Check to see if there is a snapshot in progress with the same name or on the same table.
+ * Currently we have a limitation only allowing a single snapshot per table at a time. Also we
+ * don't allow snapshot with the same name.
+ * @param snapshot description of the snapshot being checked.
+ * @return true if there is a snapshot in progress with the same name or on the same
+ * table.
+ */
+ synchronized boolean isTakingSnapshot(final SnapshotDescription snapshot) {
+ Iterator> it = this.snapshotHandlers.entrySet().iterator();
+ if (isTakingSnapshot(snapshot.getTable())) return true;
+ while (it.hasNext()) {
+ Map.Entry entry = it.next();
+ SnapshotSentinel sentinel = entry.getValue();
+ if (snapshot.getName().equals(sentinel.getSnapshot().getName()) && !sentinel.isFinished())
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Check to see if the specified table has a snapshot in progress. Currently we have a
* limitation only allowing a single snapshot per table at a time.
* @param tableName name of the table being snapshotted.
@@ -393,14 +413,14 @@ public class SnapshotManager implements Stoppable {
throws HBaseSnapshotException {
FileSystem fs = master.getMasterFileSystem().getFileSystem();
Path workingDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, rootDir);
-
// make sure we aren't already running a snapshot
- if (isTakingSnapshot(snapshot.getTable())) {
+ if (isTakingSnapshot(snapshot)) {
SnapshotSentinel handler = this.snapshotHandlers.get(snapshot.getTable());
throw new SnapshotCreationException("Rejected taking "
+ SnapshotDescriptionUtils.toString(snapshot)
+ " because we are already running another snapshot "
- + SnapshotDescriptionUtils.toString(handler.getSnapshot()), snapshot);
+ + (handler != null ? ("on the same table " + SnapshotDescriptionUtils.toString(handler.getSnapshot()))
+ : "with the same name"), snapshot);
}
// make sure we aren't running a restore on the same table