summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/RepositoryIndexTable.java17
-rw-r--r--org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/cache/CacheRepositoryIndexTable.java14
-rw-r--r--org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/memory/MemRepositoryIndexTable.java12
3 files changed, 43 insertions, 0 deletions
diff --git a/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/RepositoryIndexTable.java b/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/RepositoryIndexTable.java
index 794db6e5e2..36afd13229 100644
--- a/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/RepositoryIndexTable.java
+++ b/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/RepositoryIndexTable.java
@@ -87,4 +87,21 @@ public interface RepositoryIndexTable {
*/
public void putUnique(RepositoryName name, RepositoryKey key)
throws DhtException, TimeoutException;
+
+ /**
+ * Remove the association of a name to an identifier.
+ * <p>
+ * This method must use some sort of transaction system to ensure the name
+ * is removed only if it currently references {@code key}. This may require
+ * running some sort of lock management service in parallel to the database.
+ *
+ * @param name
+ * name of the repository.
+ * @param key
+ * internal key defining the repository.
+ * @throws DhtException
+ * @throws TimeoutException
+ */
+ public void remove(RepositoryName name, RepositoryKey key)
+ throws DhtException, TimeoutException;
}
diff --git a/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/cache/CacheRepositoryIndexTable.java b/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/cache/CacheRepositoryIndexTable.java
index 5ff43910f3..b50092c6d1 100644
--- a/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/cache/CacheRepositoryIndexTable.java
+++ b/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/cache/CacheRepositoryIndexTable.java
@@ -128,4 +128,18 @@ public class CacheRepositoryIndexTable implements RepositoryIndexTable {
throw new TimeoutException();
}
}
+
+ public void remove(RepositoryName name, RepositoryKey key)
+ throws DhtException, TimeoutException {
+ db.remove(name, key);
+
+ Sync<Void> sync = Sync.create();
+ CacheKey memKey = ns.key(name);
+ client.modify(singleton(Change.remove(memKey)), sync);
+ try {
+ sync.get(options.getTimeout());
+ } catch (InterruptedException e) {
+ throw new TimeoutException();
+ }
+ }
}
diff --git a/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/memory/MemRepositoryIndexTable.java b/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/memory/MemRepositoryIndexTable.java
index 46a1fd619a..000ff77327 100644
--- a/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/memory/MemRepositoryIndexTable.java
+++ b/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/spi/memory/MemRepositoryIndexTable.java
@@ -78,4 +78,16 @@ final class MemRepositoryIndexTable implements RepositoryIndexTable {
throw new DhtException(MessageFormat.format(
DhtText.get().repositoryAlreadyExists, name.asString()));
}
+
+ public void remove(RepositoryName name, RepositoryKey key)
+ throws DhtException, TimeoutException {
+ boolean ok = table.compareAndSet(
+ name.asBytes(),
+ colId.name(),
+ key.asBytes(),
+ null);
+ if (!ok)
+ throw new DhtException(MessageFormat.format(
+ DhtText.get().repositoryAlreadyExists, name.asString()));
+ }
}