use of org.apache.pulsar.websocket.WebSocketService in project incubator-pulsar by apache.
the class ProxyPublishConsumeWithoutZKTest method setup.
@BeforeMethod
public void setup() throws Exception {
super.internalSetup();
super.producerBaseSetup();
port = PortManager.nextFreePort();
WebSocketProxyConfiguration config = new WebSocketProxyConfiguration();
config.setWebServicePort(port);
config.setClusterName("use");
config.setServiceUrl(pulsar.getWebServiceAddress());
config.setServiceUrlTls(pulsar.getWebServiceAddressTls());
service = spy(new WebSocketService(config));
doReturn(mockZooKeeperClientFactory).when(service).getZooKeeperClientFactory();
proxyServer = new ProxyServer(config);
WebSocketServiceStarter.start(proxyServer, service);
log.info("Proxy Server Started");
}
use of org.apache.pulsar.websocket.WebSocketService in project incubator-pulsar by apache.
the class WebSocketServiceStarter method main.
public static void main(String[] args) throws Exception {
checkArgument(args.length == 1, "Need to specify a configuration file");
try {
// load config file and start proxy service
String configFile = args[0];
log.info("Loading configuration from {}", configFile);
WebSocketProxyConfiguration config = PulsarConfigurationLoader.create(configFile, WebSocketProxyConfiguration.class);
ProxyServer proxyServer = new ProxyServer(config);
WebSocketService service = new WebSocketService(config);
start(proxyServer, service);
} catch (Exception e) {
log.error("Failed to start WebSocket service", e);
Runtime.getRuntime().halt(1);
}
}
use of org.apache.pulsar.websocket.WebSocketService in project incubator-pulsar by apache.
the class LookupProtocolTest method httpLookupTest.
@Test(timeOut = 10000)
public void httpLookupTest() throws Exception {
WebSocketProxyConfiguration conf = new WebSocketProxyConfiguration();
conf.setServiceUrl("http://localhost:8080");
conf.setServiceUrlTls("https://localhost:8443");
WebSocketService service = new WebSocketService(conf);
PulsarClientImpl testClient = (PulsarClientImpl) service.getPulsarClient();
Field lookupField = PulsarClientImpl.class.getDeclaredField("lookup");
lookupField.setAccessible(true);
Assert.assertEquals(lookupField.get(testClient).getClass().getName(), "org.apache.pulsar.client.impl.HttpLookupService");
Assert.assertFalse(testClient.getConfiguration().isUseTls());
service.close();
}
use of org.apache.pulsar.websocket.WebSocketService in project incubator-pulsar by apache.
the class LookupProtocolTest method httpsLookupTest.
@Test(timeOut = 10000)
public void httpsLookupTest() throws Exception {
WebSocketProxyConfiguration conf = new WebSocketProxyConfiguration();
conf.setServiceUrl("http://localhost:8080");
conf.setServiceUrlTls("https://localhost:8443");
conf.setBrokerServiceUrl("pulsar://localhost:6650");
conf.setTlsEnabled(true);
WebSocketService service = new WebSocketService(conf);
PulsarClientImpl testClient = (PulsarClientImpl) service.getPulsarClient();
Field lookupField = PulsarClientImpl.class.getDeclaredField("lookup");
lookupField.setAccessible(true);
Assert.assertEquals(lookupField.get(testClient).getClass().getName(), "org.apache.pulsar.client.impl.HttpLookupService");
Assert.assertTrue(testClient.getConfiguration().isUseTls());
service.close();
}
use of org.apache.pulsar.websocket.WebSocketService in project incubator-pulsar by apache.
the class LookupProtocolTest method binaryTlsLookupTest.
@Test(timeOut = 10000)
public void binaryTlsLookupTest() throws Exception {
WebSocketProxyConfiguration conf = new WebSocketProxyConfiguration();
conf.setServiceUrl("http://localhost:8080");
conf.setServiceUrlTls("https://localhost:8443");
conf.setBrokerServiceUrl("pulsar://localhost:6650");
conf.setBrokerServiceUrlTls("pulsar+ssl://localhost:6651");
conf.setTlsEnabled(true);
WebSocketService service = new WebSocketService(conf);
PulsarClientImpl testClient = (PulsarClientImpl) service.getPulsarClient();
Field lookupField = PulsarClientImpl.class.getDeclaredField("lookup");
lookupField.setAccessible(true);
Assert.assertEquals(lookupField.get(testClient).getClass().getName(), "org.apache.pulsar.client.impl.BinaryProtoLookupService");
Assert.assertTrue(testClient.getConfiguration().isUseTls());
service.close();
}
Aggregations