use of org.apache.pulsar.broker.ServiceConfiguration in project incubator-pulsar by apache.
the class PulsarBrokerStarter method loadConfig.
private static ServiceConfiguration loadConfig(String configFile) throws Exception {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
ServiceConfiguration config = create((new FileInputStream(configFile)), ServiceConfiguration.class);
// it validates provided configuration is completed
isComplete(config);
return config;
}
use of org.apache.pulsar.broker.ServiceConfiguration in project incubator-pulsar by apache.
the class AuthenticationProviderAthenzTest method setup.
@BeforeClass
public void setup() throws Exception {
// Set provider domain name
properties = new Properties();
properties.setProperty("athenzDomainNames", "test_provider");
config = new ServiceConfiguration();
config.setProperties(properties);
// Initialize authentication provider
provider = new AuthenticationProviderAthenz();
provider.initialize(config);
// Specify Athenz configuration file for AuthZpeClient which is used in AuthenticationProviderAthenz
System.setProperty(ZpeConsts.ZPE_PROP_ATHENZ_CONF, "./src/test/resources/athenz.conf.test");
}
use of org.apache.pulsar.broker.ServiceConfiguration in project incubator-pulsar by apache.
the class ServiceConfigurationTest method testInit.
/**
* test {@link ServiceConfiguration} initialization
*
* @throws Exception
*/
@Test
public void testInit() throws Exception {
final String zookeeperServer = "localhost:2184";
final int brokerServicePort = 1000;
InputStream newStream = updateProp(zookeeperServer, String.valueOf(brokerServicePort), "ns1,ns2");
final ServiceConfiguration config = PulsarConfigurationLoader.create(newStream, ServiceConfiguration.class);
assertTrue(isNotBlank(config.getZookeeperServers()));
assertTrue(config.getBrokerServicePort() == brokerServicePort);
assertEquals(config.getBootstrapNamespaces().get(1), "ns2");
}
use of org.apache.pulsar.broker.ServiceConfiguration in project incubator-pulsar by apache.
the class ServiceConfigurationTest method testOptionalSettingEmpty.
@Test
public void testOptionalSettingEmpty() throws Exception {
String confFile = "loadBalancerOverrideBrokerNicSpeedGbps=\n";
InputStream stream = new ByteArrayInputStream(confFile.getBytes());
final ServiceConfiguration config = PulsarConfigurationLoader.create(stream, ServiceConfiguration.class);
assertEquals(config.getLoadBalancerOverrideBrokerNicSpeedGbps(), Optional.empty());
}
use of org.apache.pulsar.broker.ServiceConfiguration in project incubator-pulsar by apache.
the class ProxyService method start.
public void start() throws Exception {
ServiceConfiguration serviceConfiguration = PulsarConfigurationLoader.convertFrom(proxyConfig);
authenticationService = new AuthenticationService(serviceConfiguration);
if (!isBlank(proxyConfig.getZookeeperServers()) && !isBlank(proxyConfig.getGlobalZookeeperServers())) {
localZooKeeperConnectionService = new LocalZooKeeperConnectionService(getZooKeeperClientFactory(), proxyConfig.getZookeeperServers(), proxyConfig.getZookeeperSessionTimeoutMs());
localZooKeeperConnectionService.start(new ShutdownService() {
@Override
public void shutdown(int exitCode) {
LOG.error("Lost local ZK session. Shutting down the proxy");
Runtime.getRuntime().halt(-1);
}
});
discoveryProvider = new BrokerDiscoveryProvider(this.proxyConfig, getZooKeeperClientFactory());
this.configurationCacheService = new ConfigurationCacheService(discoveryProvider.globalZkCache);
authorizationService = new AuthorizationService(serviceConfiguration, configurationCacheService);
}
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
bootstrap.group(acceptorGroup, workerGroup);
bootstrap.childOption(ChannelOption.TCP_NODELAY, true);
bootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator(1024, 16 * 1024, 1 * 1024 * 1024));
bootstrap.channel(EventLoopUtil.getServerSocketChannelClass(workerGroup));
EventLoopUtil.enableTriggeredMode(bootstrap);
bootstrap.childHandler(new ServiceChannelInitializer(this, proxyConfig, false));
// Bind and start to accept incoming connections.
bootstrap.bind(proxyConfig.getServicePort()).sync();
LOG.info("Started Pulsar Proxy at {}", serviceUrl);
if (proxyConfig.isTlsEnabledInProxy()) {
ServerBootstrap tlsBootstrap = bootstrap.clone();
tlsBootstrap.childHandler(new ServiceChannelInitializer(this, proxyConfig, true));
tlsBootstrap.bind(proxyConfig.getServicePortTls()).sync();
LOG.info("Started Pulsar TLS Proxy on port {}", proxyConfig.getServicePortTls());
}
}
Aggregations