Search in sources :

Example 6 with ServiceConfiguration

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;
}
Also used : ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) FileInputStream(java.io.FileInputStream)

Example 7 with ServiceConfiguration

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");
}
Also used : ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) AuthenticationProviderAthenz(org.apache.pulsar.broker.authentication.AuthenticationProviderAthenz) Properties(java.util.Properties) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with ServiceConfiguration

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");
}
Also used : ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Test(org.testng.annotations.Test)

Example 9 with ServiceConfiguration

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());
}
Also used : ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Test(org.testng.annotations.Test)

Example 10 with ServiceConfiguration

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());
    }
}
Also used : ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) AdaptiveRecvByteBufAllocator(io.netty.channel.AdaptiveRecvByteBufAllocator) LocalZooKeeperConnectionService(org.apache.pulsar.zookeeper.LocalZooKeeperConnectionService) AuthorizationService(org.apache.pulsar.broker.authorization.AuthorizationService) ShutdownService(org.apache.pulsar.zookeeper.ZooKeeperSessionWatcher.ShutdownService) ConfigurationCacheService(org.apache.pulsar.broker.cache.ConfigurationCacheService) AuthenticationService(org.apache.pulsar.broker.authentication.AuthenticationService) ServerBootstrap(io.netty.bootstrap.ServerBootstrap)

Aggregations

ServiceConfiguration (org.apache.pulsar.broker.ServiceConfiguration)58 Test (org.testng.annotations.Test)28 PulsarService (org.apache.pulsar.broker.PulsarService)24 BeforeMethod (org.testng.annotations.BeforeMethod)14 URL (java.net.URL)11 ClusterData (org.apache.pulsar.common.policies.data.ClusterData)10 Field (java.lang.reflect.Field)9 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)9 TopicName (org.apache.pulsar.common.naming.TopicName)9 LoadManager (org.apache.pulsar.broker.loadbalance.LoadManager)8 Authentication (org.apache.pulsar.client.api.Authentication)8 NamespaceBundle (org.apache.pulsar.common.naming.NamespaceBundle)8 Policies (org.apache.pulsar.common.policies.data.Policies)8 LocalBookkeeperEnsemble (org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble)8 InputStream (java.io.InputStream)7 URI (java.net.URI)7 NamespaceService (org.apache.pulsar.broker.namespace.NamespaceService)7 IOException (java.io.IOException)6 ManagedLedgerFactory (org.apache.bookkeeper.mledger.ManagedLedgerFactory)6 Map (java.util.Map)5