Search in sources :

Example 1 with UnknownBookieIdException

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));
}
Also used : UnknownHostException(java.net.UnknownHostException) BookieSocketAddress(org.apache.bookkeeper.net.BookieSocketAddress) UnknownBookieIdException(org.apache.bookkeeper.bookie.BookieException.UnknownBookieIdException)

Example 2 with UnknownBookieIdException

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);
}
Also used : UnknownHostException(java.net.UnknownHostException) BookieSocketAddress(org.apache.bookkeeper.net.BookieSocketAddress) UnknownBookieIdException(org.apache.bookkeeper.bookie.BookieException.UnknownBookieIdException)

Example 3 with UnknownBookieIdException

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;
}
Also used : UnknownHostException(java.net.UnknownHostException) BookieSocketAddress(org.apache.bookkeeper.net.BookieSocketAddress) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) UnknownBookieIdException(org.apache.bookkeeper.bookie.BookieException.UnknownBookieIdException)

Aggregations

UnknownHostException (java.net.UnknownHostException)3 UnknownBookieIdException (org.apache.bookkeeper.bookie.BookieException.UnknownBookieIdException)3 BookieSocketAddress (org.apache.bookkeeper.net.BookieSocketAddress)3 ServerConfiguration (org.apache.bookkeeper.conf.ServerConfiguration)1