Hi <@U078Y59KC3B> what is the most efficient and r...
# ask-ai
s
Hi @RunLLM what is the most efficient and robust way to find the number of writable bookies.
r
To find the number of writable bookies efficiently, you can use the
getWritableBookies
method from the BookKeeperAdmin class. This method retrieves the set of writable bookies in the cluster. The size of this set gives you the number of writable bookies. Here's a concise code snippet to achieve this:
Copy code
import org.apache.bookkeeper.client.BookKeeperAdmin;
import org.apache.bookkeeper.conf.ClientConfiguration;

ClientConfiguration clientConfiguration = new ClientConfiguration();
try (BookKeeperAdmin admin = new BookKeeperAdmin(clientConfiguration)) {
    int writableBookiesCount = admin.getAvailableBookies().size();
    System.out.println("Number of writable bookies: " + writableBookiesCount);
} catch (Exception e) {
    e.printStackTrace();
}
Would you like more details on this process? Sources: - ClusterInfoCommand.java 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
s
@RunLLM can we get similar code for python.
Copy code
import org.apache.bookkeeper.client.BookKeeperAdmin;
import org.apache.bookkeeper.conf.ClientConfiguration;

ClientConfiguration clientConfiguration = new ClientConfiguration();
try (BookKeeperAdmin admin = new BookKeeperAdmin(clientConfiguration)) {
    int writableBookiesCount = admin.getAvailableBookies().size();
    System.out.println("Number of writable bookies: " + writableBookiesCount);
} catch (Exception e) {
    e.printStackTrace();
}
r
I'm not able to find any data sources to answer your question. You might want to specify the Python library or API you are using to interact with BookKeeper. If this doesn't help, please reach out to the StreamNative support team for further assistance. 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.