Search in sources :

Example 21 with ServiceConfiguration

use of com.yahoo.pulsar.broker.ServiceConfiguration in project pulsar by yahoo.

the class DiscoveryService method start.

/**
     * Starts discovery service by initializing zookkeeper and server
     * @throws Exception
     */
public void start() throws Exception {
    discoveryProvider = new BrokerDiscoveryProvider(this.config, getZooKeeperClientFactory());
    this.configurationCacheService = new ConfigurationCacheService(discoveryProvider.globalZkCache);
    ServiceConfiguration serviceConfiguration = createServiceConfiguration(config);
    authenticationService = new AuthenticationService(serviceConfiguration);
    authorizationManager = new AuthorizationManager(serviceConfiguration, configurationCacheService);
    startServer();
}
Also used : ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration) ConfigurationCacheService(com.yahoo.pulsar.broker.cache.ConfigurationCacheService) AuthorizationManager(com.yahoo.pulsar.broker.authorization.AuthorizationManager) AuthenticationService(com.yahoo.pulsar.broker.authentication.AuthenticationService)

Example 22 with ServiceConfiguration

use of com.yahoo.pulsar.broker.ServiceConfiguration in project pulsar by yahoo.

the class PulsarConfigurationLoaderTest method testPulsarConfiguraitonComplete.

@Test
public void testPulsarConfiguraitonComplete() throws Exception {
    final String zk = "localhost:2184";
    final Properties prop = new Properties();
    prop.setProperty("zookeeperServers", zk);
    final ServiceConfiguration serviceConfig = PulsarConfigurationLoader.create(prop, ServiceConfiguration.class);
    try {
        isComplete(serviceConfig);
        fail("it should fail as config is not complete");
    } catch (IllegalArgumentException e) {
    // Ok
    }
}
Also used : ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration) Properties(java.util.Properties) Test(org.testng.annotations.Test)

Example 23 with ServiceConfiguration

use of com.yahoo.pulsar.broker.ServiceConfiguration in project pulsar by yahoo.

the class PulsarBrokerStarter method main.

public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        throw new IllegalArgumentException("Need to specify a configuration file");
    }
    Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> {
        log.error("Uncaught exception in thread {}: {}", thread.getName(), exception.getMessage(), exception);
    });
    String configFile = args[0];
    ServiceConfiguration config = loadConfig(configFile);
    @SuppressWarnings("resource") final PulsarService service = new PulsarService(config);
    Runtime.getRuntime().addShutdownHook(service.getShutdownService());
    try {
        service.start();
        log.info("PulsarService started");
    } catch (PulsarServerException e) {
        log.error("Failed to start pulsar service.", e);
        Runtime.getRuntime().halt(1);
    }
    service.waitUntilClosed();
}
Also used : PulsarServerException(com.yahoo.pulsar.broker.PulsarServerException) ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration) PulsarService(com.yahoo.pulsar.broker.PulsarService)

Example 24 with ServiceConfiguration

use of com.yahoo.pulsar.broker.ServiceConfiguration in project pulsar by yahoo.

the class DiscoveryService method createServiceConfiguration.

private ServiceConfiguration createServiceConfiguration(ServiceConfig config) {
    ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
    serviceConfiguration.setAuthenticationEnabled(config.isAuthenticationEnabled());
    serviceConfiguration.setAuthorizationEnabled(config.isAuthorizationEnabled());
    serviceConfiguration.setAuthenticationProviders(config.getAuthenticationProviders());
    serviceConfiguration.setProperties(config.getProperties());
    return serviceConfiguration;
}
Also used : ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration)

Example 25 with ServiceConfiguration

use of com.yahoo.pulsar.broker.ServiceConfiguration in project pulsar by yahoo.

the class AuthenticationServiceTest method testAuthenticationHttp.

@Test
public void testAuthenticationHttp() throws Exception {
    ServiceConfiguration config = new ServiceConfiguration();
    Set<String> providersClassNames = Sets.newHashSet(MockAuthenticationProvider.class.getName());
    config.setAuthenticationProviders(providersClassNames);
    config.setAuthenticationEnabled(true);
    AuthenticationService service = new AuthenticationService(config);
    HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getRemoteAddr()).thenReturn("192.168.1.1");
    when(request.getRemotePort()).thenReturn(8080);
    when(request.getHeader(anyString())).thenReturn("data");
    String result = service.authenticateHttpRequest(request);
    assertEquals(result, s_authentication_success);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration) Matchers.anyString(org.mockito.Matchers.anyString) AuthenticationService(com.yahoo.pulsar.broker.authentication.AuthenticationService) Test(org.testng.annotations.Test)

Aggregations

ServiceConfiguration (com.yahoo.pulsar.broker.ServiceConfiguration)36 PulsarService (com.yahoo.pulsar.broker.PulsarService)18 Test (org.testng.annotations.Test)15 ClusterData (com.yahoo.pulsar.common.policies.data.ClusterData)8 BeforeMethod (org.testng.annotations.BeforeMethod)8 AuthenticationService (com.yahoo.pulsar.broker.authentication.AuthenticationService)7 DestinationName (com.yahoo.pulsar.common.naming.DestinationName)7 URL (java.net.URL)7 PulsarAdmin (com.yahoo.pulsar.client.admin.PulsarAdmin)6 Authentication (com.yahoo.pulsar.client.api.Authentication)6 NamespaceBundle (com.yahoo.pulsar.common.naming.NamespaceBundle)6 Field (java.lang.reflect.Field)6 ConfigurationCacheService (com.yahoo.pulsar.broker.cache.ConfigurationCacheService)5 NamespaceService (com.yahoo.pulsar.broker.namespace.NamespaceService)5 Policies (com.yahoo.pulsar.common.policies.data.Policies)5 LocalBookkeeperEnsemble (com.yahoo.pulsar.zookeeper.LocalBookkeeperEnsemble)5 InetSocketAddress (java.net.InetSocketAddress)5 URI (java.net.URI)5 ManagedLedgerFactory (org.apache.bookkeeper.mledger.ManagedLedgerFactory)5 AuthorizationManager (com.yahoo.pulsar.broker.authorization.AuthorizationManager)4