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();
}
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
}
}
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();
}
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;
}
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);
}
Aggregations