*/
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;
}
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();
+ }
+ }
}
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()));
+ }
}