use of org.apache.bookkeeper.bookie.BookieException.CookieNotFoundException in project bookkeeper by apache.
the class ZKRegistrationManager method readCookie.
@Override
public Versioned<byte[]> readCookie(String bookieId) throws BookieException {
String zkPath = getCookiePath(bookieId);
try {
Stat stat = zk.exists(zkPath, false);
byte[] data = zk.getData(zkPath, false, stat);
// sets stat version from ZooKeeper
LongVersion version = new LongVersion(stat.getVersion());
return new Versioned<>(data, version);
} catch (NoNodeException nne) {
throw new CookieNotFoundException(bookieId);
} catch (KeeperException | InterruptedException e) {
throw new MetadataStoreException("Failed to read cookie for bookie " + bookieId);
}
}
use of org.apache.bookkeeper.bookie.BookieException.CookieNotFoundException in project bookkeeper by apache.
the class ZKRegistrationManager method removeCookie.
@Override
public void removeCookie(String bookieId, Version version) throws BookieException {
String zkPath = getCookiePath(bookieId);
try {
zk.delete(zkPath, (int) ((LongVersion) version).getLongVersion());
} catch (NoNodeException e) {
throw new CookieNotFoundException(bookieId);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new MetadataStoreException("Interrupted deleting cookie for bookie " + bookieId, e);
} catch (KeeperException e) {
throw new MetadataStoreException("Failed to delete cookie for bookie " + bookieId);
}
log.info("Removed cookie from {} for bookie {}.", cookiePath, bookieId);
}
Aggregations