use of org.apache.bookkeeper.bookie.BookieException.UnknownBookieIdException in project bookkeeper by apache.
the class Cookie method writeToRegistrationManager.
/**
* Writes cookie details to registration manager.
*
* @param rm registration manager
* @param conf configuration
* @param version version
* @throws BookieException when fail to write the cookie.
*/
public void writeToRegistrationManager(RegistrationManager rm, ServerConfiguration conf, Version version) throws BookieException {
BookieSocketAddress address = null;
try {
address = Bookie.getBookieAddress(conf);
} catch (UnknownHostException e) {
throw new UnknownBookieIdException(e);
}
byte[] data = toString().getBytes(UTF_8);
rm.writeCookie(address.toString(), new Versioned<>(data, version));
}
use of org.apache.bookkeeper.bookie.BookieException.UnknownBookieIdException in project bookkeeper by apache.
the class Cookie method deleteFromRegistrationManager.
/**
* Deletes cookie from registration manager.
*
* @param rm registration manager
* @param conf configuration
* @param version cookie version
* @throws BookieException when fail to delete cookie.
*/
public void deleteFromRegistrationManager(RegistrationManager rm, ServerConfiguration conf, Version version) throws BookieException {
BookieSocketAddress address = null;
try {
address = Bookie.getBookieAddress(conf);
} catch (UnknownHostException e) {
throw new UnknownBookieIdException(e);
}
deleteFromRegistrationManager(rm, address, version);
}
use of org.apache.bookkeeper.bookie.BookieException.UnknownBookieIdException in project bookkeeper by apache.
the class Bookie method possibleBookieIds.
static List<BookieSocketAddress> possibleBookieIds(ServerConfiguration conf) throws BookieException {
// we need to loop through all possible bookie identifiers to ensure it is treated as a new environment
// just because of bad configuration
List<BookieSocketAddress> addresses = Lists.newArrayListWithExpectedSize(3);
try {
// ip address
addresses.add(getBookieAddress(new ServerConfiguration(conf).setUseHostNameAsBookieID(false).setAdvertisedAddress(null)));
// host name
addresses.add(getBookieAddress(new ServerConfiguration(conf).setUseHostNameAsBookieID(true).setAdvertisedAddress(null)));
// advertised address
if (null != conf.getAdvertisedAddress()) {
addresses.add(getBookieAddress(conf));
}
} catch (UnknownHostException e) {
throw new UnknownBookieIdException(e);
}
return addresses;
}
Aggregations