use of org.apache.bookkeeper.discover.BookieServiceInfo in project incubator-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(result.getValue().size(), addresses.size());
}
use of org.apache.bookkeeper.discover.BookieServiceInfo in project pulsar by yahoo.
the class BookieServiceInfoSerde method serialize.
@Override
public byte[] serialize(String path, BookieServiceInfo bookieServiceInfo) throws IOException {
if (log.isDebugEnabled()) {
log.debug("serialize BookieServiceInfo {}", bookieServiceInfo);
}
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
BookieServiceInfoFormat.Builder builder = BookieServiceInfoFormat.newBuilder();
List<BookieServiceInfoFormat.Endpoint> bsiEndpoints = bookieServiceInfo.getEndpoints().stream().map(e -> BookieServiceInfoFormat.Endpoint.newBuilder().setId(e.getId()).setPort(e.getPort()).setHost(e.getHost()).setProtocol(e.getProtocol()).addAllAuth(e.getAuth()).addAllExtensions(e.getExtensions()).build()).collect(Collectors.toList());
builder.addAllEndpoints(bsiEndpoints);
builder.putAllProperties(bookieServiceInfo.getProperties());
builder.build().writeTo(os);
return os.toByteArray();
}
}
use of org.apache.bookkeeper.discover.BookieServiceInfo in project pulsar by yahoo.
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(result.getValue().size(), addresses.size());
}
use of org.apache.bookkeeper.discover.BookieServiceInfo in project pulsar by yahoo.
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());
}
use of org.apache.bookkeeper.discover.BookieServiceInfo in project pulsar by yahoo.
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(result.getValue().size(), addresses.size());
}
Aggregations