use of org.apache.bookkeeper.discover.BookieServiceInfo in project pulsar by apache.
the class PulsarRegistrationClientTest method testGetAllBookies.
@Test(dataProvider = "impl")
public void testGetAllBookies(String provider, Supplier<String> urlSupplier) throws Exception {
@Cleanup MetadataStoreExtended store = MetadataStoreExtended.create(urlSupplier.get(), MetadataStoreConfig.builder().build());
String ledgersRoot = "/test/ledgers-" + UUID.randomUUID();
@Cleanup RegistrationManager rm = new PulsarRegistrationManager(store, ledgersRoot, mock(AbstractConfiguration.class));
@Cleanup RegistrationClient rc = new PulsarRegistrationClient(store, ledgersRoot);
Set<BookieId> addresses = prepareNBookies(10);
List<String> children = new ArrayList<>();
for (BookieId address : addresses) {
children.add(address.toString());
boolean isReadOnly = children.size() % 2 == 0;
rm.registerBookie(address, isReadOnly, new BookieServiceInfo());
}
Versioned<Set<BookieId>> result = result(rc.getAllBookies());
assertEquals(addresses.size(), result.getValue().size());
}
use of org.apache.bookkeeper.discover.BookieServiceInfo in project pulsar by apache.
the class PulsarRegistrationClientTest method testGetReadonlyBookies.
@Test(dataProvider = "impl")
public void testGetReadonlyBookies(String provider, Supplier<String> urlSupplier) throws Exception {
@Cleanup MetadataStoreExtended store = MetadataStoreExtended.create(urlSupplier.get(), MetadataStoreConfig.builder().build());
String ledgersRoot = "/test/ledgers-" + UUID.randomUUID();
@Cleanup RegistrationManager rm = new PulsarRegistrationManager(store, ledgersRoot, mock(AbstractConfiguration.class));
@Cleanup RegistrationClient rc = new PulsarRegistrationClient(store, ledgersRoot);
Set<BookieId> addresses = prepareNBookies(10);
List<String> children = new ArrayList<>();
for (BookieId address : addresses) {
children.add(address.toString());
rm.registerBookie(address, true, new BookieServiceInfo());
}
Versioned<Set<BookieId>> result = result(rc.getReadOnlyBookies());
assertEquals(addresses.size(), result.getValue().size());
}
use of org.apache.bookkeeper.discover.BookieServiceInfo in project pulsar by apache.
the class PulsarRegistrationClientTest method testGetWritableBookies.
@Test(dataProvider = "impl")
public void testGetWritableBookies(String provider, Supplier<String> urlSupplier) throws Exception {
@Cleanup MetadataStoreExtended store = MetadataStoreExtended.create(urlSupplier.get(), MetadataStoreConfig.builder().build());
String ledgersRoot = "/test/ledgers-" + UUID.randomUUID();
@Cleanup RegistrationManager rm = new PulsarRegistrationManager(store, ledgersRoot, mock(AbstractConfiguration.class));
@Cleanup RegistrationClient rc = new PulsarRegistrationClient(store, ledgersRoot);
Set<BookieId> addresses = prepareNBookies(10);
List<String> children = new ArrayList<>();
for (BookieId address : addresses) {
children.add(address.toString());
rm.registerBookie(address, false, new BookieServiceInfo());
}
Versioned<Set<BookieId>> result = result(rc.getWritableBookies());
assertEquals(addresses.size(), result.getValue().size());
}
use of org.apache.bookkeeper.discover.BookieServiceInfo in project pulsar by yahoo.
the class PulsarRegistrationClientTest method testWatchBookiesSuccess.
private void testWatchBookiesSuccess(String provider, Supplier<String> urlSupplier, boolean isWritable) throws Exception {
@Cleanup MetadataStoreExtended store = MetadataStoreExtended.create(urlSupplier.get(), MetadataStoreConfig.builder().build());
String ledgersRoot = "/test/ledgers-" + UUID.randomUUID();
@Cleanup RegistrationManager rm = new PulsarRegistrationManager(store, ledgersRoot, mock(AbstractConfiguration.class));
@Cleanup RegistrationClient rc = new PulsarRegistrationClient(store, ledgersRoot);
//
// 1. test watch bookies with a listener
//
Queue<Versioned<Set<BookieId>>> updates = new ConcurrentLinkedQueue<>();
Map<BookieId, Boolean> bookies = new ConcurrentHashMap<>();
RegistrationClient.RegistrationListener listener = (b) -> {
updates.add(b);
b.getValue().forEach(x -> bookies.put(x, true));
};
int BOOKIES = 10;
Set<BookieId> addresses = prepareNBookies(BOOKIES);
if (isWritable) {
result(rc.watchWritableBookies(listener));
} else {
result(rc.watchReadOnlyBookies(listener));
}
for (BookieId address : addresses) {
rm.registerBookie(address, !isWritable, new BookieServiceInfo());
}
Awaitility.await().untilAsserted(() -> {
assertFalse(updates.isEmpty());
assertEquals(bookies.size(), BOOKIES);
});
}
use of org.apache.bookkeeper.discover.BookieServiceInfo in project incubator-pulsar by apache.
the class PulsarRegistrationClientTest method testGetReadonlyBookies.
@Test(dataProvider = "impl")
public void testGetReadonlyBookies(String provider, Supplier<String> urlSupplier) throws Exception {
@Cleanup MetadataStoreExtended store = MetadataStoreExtended.create(urlSupplier.get(), MetadataStoreConfig.builder().build());
String ledgersRoot = "/test/ledgers-" + UUID.randomUUID();
@Cleanup RegistrationManager rm = new PulsarRegistrationManager(store, ledgersRoot, mock(AbstractConfiguration.class));
@Cleanup RegistrationClient rc = new PulsarRegistrationClient(store, ledgersRoot);
Set<BookieId> addresses = prepareNBookies(10);
List<String> children = new ArrayList<>();
for (BookieId address : addresses) {
children.add(address.toString());
rm.registerBookie(address, true, new BookieServiceInfo());
}
Versioned<Set<BookieId>> result = result(rc.getReadOnlyBookies());
assertEquals(result.getValue().size(), addresses.size());
}
Aggregations