use of org.apache.pulsar.client.impl.BinaryProtoLookupService in project pulsar by apache.
the class SimpleSchemaTest method testGetSchemaByVersion.
@Test
public void testGetSchemaByVersion() throws PulsarClientException, PulsarAdminException, ExecutionException, InterruptedException {
final String topic = "persistent://my-property/my-ns/testGetSchemaByVersion";
@Cleanup PulsarClientImpl httpProtocolClient = (PulsarClientImpl) PulsarClient.builder().serviceUrl(brokerUrl.toString()).build();
PulsarClientImpl binaryProtocolClient = (PulsarClientImpl) pulsarClient;
pulsarClient.newProducer(Schema.AVRO(V1Data.class)).topic(topic).create();
pulsarClient.newProducer(Schema.AVRO(V2Data.class)).topic(topic).create();
LookupService httpLookupService = httpProtocolClient.getLookup();
LookupService binaryLookupService = binaryProtocolClient.getLookup();
Assert.assertTrue(httpLookupService instanceof HttpLookupService);
Assert.assertTrue(binaryLookupService instanceof BinaryProtoLookupService);
Assert.assertEquals(admin.schemas().getAllSchemas(topic).size(), 2);
Assert.assertTrue(httpLookupService.getSchema(TopicName.get(topic), ByteBuffer.allocate(8).putLong(0).array()).get().isPresent());
Assert.assertTrue(httpLookupService.getSchema(TopicName.get(topic), ByteBuffer.allocate(8).putLong(1).array()).get().isPresent());
Assert.assertTrue(binaryLookupService.getSchema(TopicName.get(topic), ByteBuffer.allocate(8).putLong(0).array()).get().isPresent());
Assert.assertTrue(binaryLookupService.getSchema(TopicName.get(topic), ByteBuffer.allocate(8).putLong(1).array()).get().isPresent());
}
use of org.apache.pulsar.client.impl.BinaryProtoLookupService in project pulsar by apache.
the class PulsarMultiListenersWithInternalListenerNameTest method doFindBrokerWithListenerName.
private void doFindBrokerWithListenerName(boolean useHttp) throws Exception {
ClientConfigurationData conf = new ClientConfigurationData();
conf.setListenerName("internal");
conf.setServiceUrl(pulsar.getWebServiceAddress());
conf.setMaxLookupRedirects(10);
@Cleanup LookupService lookupService = useHttp ? new HttpLookupService(conf, eventExecutors) : new BinaryProtoLookupService((PulsarClientImpl) this.pulsarClient, lookupUrl.toString(), "internal", false, this.executorService);
// test request 1
{
CompletableFuture<Pair<InetSocketAddress, InetSocketAddress>> future = lookupService.getBroker(TopicName.get("persistent://public/default/test"));
Pair<InetSocketAddress, InetSocketAddress> result = future.get(10, TimeUnit.SECONDS);
Assert.assertEquals(result.getKey(), brokerAddress);
Assert.assertEquals(result.getValue(), brokerAddress);
}
// test request 2
{
CompletableFuture<Pair<InetSocketAddress, InetSocketAddress>> future = lookupService.getBroker(TopicName.get("persistent://public/default/test"));
Pair<InetSocketAddress, InetSocketAddress> result = future.get(10, TimeUnit.SECONDS);
Assert.assertEquals(result.getKey(), brokerAddress);
Assert.assertEquals(result.getValue(), brokerAddress);
}
}
use of org.apache.pulsar.client.impl.BinaryProtoLookupService in project pulsar by yahoo.
the class PulsarMultiListenersWithInternalListenerNameTest method doFindBrokerWithListenerName.
private void doFindBrokerWithListenerName(boolean useHttp) throws Exception {
ClientConfigurationData conf = new ClientConfigurationData();
conf.setListenerName("internal");
conf.setServiceUrl(pulsar.getWebServiceAddress());
conf.setMaxLookupRedirects(10);
@Cleanup LookupService lookupService = useHttp ? new HttpLookupService(conf, eventExecutors) : new BinaryProtoLookupService((PulsarClientImpl) this.pulsarClient, lookupUrl.toString(), "internal", false, this.executorService);
// test request 1
{
CompletableFuture<Pair<InetSocketAddress, InetSocketAddress>> future = lookupService.getBroker(TopicName.get("persistent://public/default/test"));
Pair<InetSocketAddress, InetSocketAddress> result = future.get(10, TimeUnit.SECONDS);
Assert.assertEquals(result.getKey(), brokerAddress);
Assert.assertEquals(result.getValue(), brokerAddress);
}
// test request 2
{
CompletableFuture<Pair<InetSocketAddress, InetSocketAddress>> future = lookupService.getBroker(TopicName.get("persistent://public/default/test"));
Pair<InetSocketAddress, InetSocketAddress> result = future.get(10, TimeUnit.SECONDS);
Assert.assertEquals(result.getKey(), brokerAddress);
Assert.assertEquals(result.getValue(), brokerAddress);
}
}
use of org.apache.pulsar.client.impl.BinaryProtoLookupService in project incubator-pulsar by apache.
the class SimpleSchemaTest method testGetSchemaByVersion.
@Test
public void testGetSchemaByVersion() throws PulsarClientException, PulsarAdminException, ExecutionException, InterruptedException {
final String topic = "persistent://my-property/my-ns/testGetSchemaByVersion";
@Cleanup PulsarClientImpl httpProtocolClient = (PulsarClientImpl) PulsarClient.builder().serviceUrl(brokerUrl.toString()).build();
PulsarClientImpl binaryProtocolClient = (PulsarClientImpl) pulsarClient;
pulsarClient.newProducer(Schema.AVRO(V1Data.class)).topic(topic).create();
pulsarClient.newProducer(Schema.AVRO(V2Data.class)).topic(topic).create();
LookupService httpLookupService = httpProtocolClient.getLookup();
LookupService binaryLookupService = binaryProtocolClient.getLookup();
Assert.assertTrue(httpLookupService instanceof HttpLookupService);
Assert.assertTrue(binaryLookupService instanceof BinaryProtoLookupService);
Assert.assertEquals(admin.schemas().getAllSchemas(topic).size(), 2);
Assert.assertTrue(httpLookupService.getSchema(TopicName.get(topic), ByteBuffer.allocate(8).putLong(0).array()).get().isPresent());
Assert.assertTrue(httpLookupService.getSchema(TopicName.get(topic), ByteBuffer.allocate(8).putLong(1).array()).get().isPresent());
Assert.assertTrue(binaryLookupService.getSchema(TopicName.get(topic), ByteBuffer.allocate(8).putLong(0).array()).get().isPresent());
Assert.assertTrue(binaryLookupService.getSchema(TopicName.get(topic), ByteBuffer.allocate(8).putLong(1).array()).get().isPresent());
}
use of org.apache.pulsar.client.impl.BinaryProtoLookupService in project incubator-pulsar by apache.
the class PulsarMultiListenersWithInternalListenerNameTest method doFindBrokerWithListenerName.
private void doFindBrokerWithListenerName(boolean useHttp) throws Exception {
ClientConfigurationData conf = new ClientConfigurationData();
conf.setListenerName("internal");
conf.setServiceUrl(pulsar.getWebServiceAddress());
conf.setMaxLookupRedirects(10);
@Cleanup LookupService lookupService = useHttp ? new HttpLookupService(conf, eventExecutors) : new BinaryProtoLookupService((PulsarClientImpl) this.pulsarClient, lookupUrl.toString(), "internal", false, this.executorService);
// test request 1
{
CompletableFuture<Pair<InetSocketAddress, InetSocketAddress>> future = lookupService.getBroker(TopicName.get("persistent://public/default/test"));
Pair<InetSocketAddress, InetSocketAddress> result = future.get(10, TimeUnit.SECONDS);
Assert.assertEquals(result.getKey(), brokerAddress);
Assert.assertEquals(result.getValue(), brokerAddress);
}
// test request 2
{
CompletableFuture<Pair<InetSocketAddress, InetSocketAddress>> future = lookupService.getBroker(TopicName.get("persistent://public/default/test"));
Pair<InetSocketAddress, InetSocketAddress> result = future.get(10, TimeUnit.SECONDS);
Assert.assertEquals(result.getKey(), brokerAddress);
Assert.assertEquals(result.getValue(), brokerAddress);
}
}
Aggregations