use of org.apache.bookkeeper.bookie.BookieException.MetadataStoreException 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);
}
use of org.apache.bookkeeper.bookie.BookieException.MetadataStoreException in project bookkeeper by apache.
the class ZKRegistrationManager method doRegisterBookie.
private void doRegisterBookie(String regPath) throws BookieException {
// ZK ephemeral node for this Bookie.
try {
if (!checkRegNodeAndWaitExpired(regPath)) {
// Create the ZK ephemeral node for this Bookie.
zk.create(regPath, new byte[0], zkAcls, CreateMode.EPHEMERAL);
zkRegManagerInitialized = true;
}
} catch (KeeperException ke) {
log.error("ZK exception registering ephemeral Znode for Bookie!", ke);
// exit here as this is a fatal error.
throw new MetadataStoreException(ke);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
log.error("Interrupted exception registering ephemeral Znode for Bookie!", ie);
// exit here as this is a fatal error.
throw new MetadataStoreException(ie);
} catch (IOException e) {
throw new MetadataStoreException(e);
}
}
use of org.apache.bookkeeper.bookie.BookieException.MetadataStoreException in project bookkeeper by apache.
the class ZKRegistrationManager method doRegisterReadOnlyBookie.
private void doRegisterReadOnlyBookie(String bookieId) throws BookieException {
try {
if (null == zk.exists(this.bookieReadonlyRegistrationPath, false)) {
try {
zk.create(this.bookieReadonlyRegistrationPath, new byte[0], zkAcls, CreateMode.PERSISTENT);
} catch (NodeExistsException e) {
// this node is just now created by someone.
}
}
String regPath = bookieReadonlyRegistrationPath + "/" + bookieId;
doRegisterBookie(regPath);
// clear the write state
regPath = bookieRegistrationPath + "/" + bookieId;
try {
// Clear the current registered node
zk.delete(regPath, -1);
} catch (KeeperException.NoNodeException nne) {
log.warn("No writable bookie registered node {} when transitioning to readonly", regPath, nne);
}
} catch (KeeperException | InterruptedException e) {
throw new MetadataStoreException(e);
}
}
Aggregations