/** * Creates PulsarConfiguration and loads it with populated attribute values loaded from provided property file. * * @param configFile * @throws IOException * @throws IllegalArgumentException */ public static <T extends PulsarConfiguration> T create(String configFile, Class<? extends PulsarConfiguration> clazz) throws IOException, IllegalArgumentException { checkNotNull(configFile); return create(new FileInputStream(configFile), clazz); }
public static ServiceConfiguration convertFrom(PulsarConfiguration conf) throws RuntimeException { return convertFrom(conf, true); }
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; }
final ProxyConfiguration config = PulsarConfigurationLoader.create(configFile, ProxyConfiguration.class); PulsarConfigurationLoader.convertFrom(config));
long minValue = ((FieldContext) field.getAnnotation(FieldContext.class)).minValue(); long maxValue = ((FieldContext) field.getAnnotation(FieldContext.class)).maxValue(); if (isRequired && isEmpty(value)) { error.append(String.format("Required %s is null,", field.getName()));
public PulsarService(ServiceConfiguration config, Optional<WorkerService> functionWorkerService) { // Validate correctness of configuration PulsarConfigurationLoader.isComplete(config); state = State.Init; this.bindAddress = ServiceConfigurationUtils.getDefaultOrConfiguredAddress(config.getBindAddress()); this.advertisedAddress = advertisedAddress(config); this.webServiceAddress = webAddress(config); this.webServiceAddressTls = webAddressTls(config); this.brokerServiceUrl = brokerUrl(config); this.brokerServiceUrlTls = brokerUrlTls(config); this.brokerVersion = PulsarBrokerVersionStringUtils.getNormalizedVersionString(); this.config = config; this.shutdownService = new MessagingServiceShutdownHook(this); this.loadManagerExecutor = Executors .newSingleThreadScheduledExecutor(new DefaultThreadFactory("pulsar-load-manager")); this.functionWorkerService = functionWorkerService; }
/** * Creates PulsarConfiguration and loads it with populated attribute values loaded from provided inputstream * property file. * * @param inStream * @throws IOException * if an error occurred when reading from the input stream. * @throws IllegalArgumentException * if the input stream contains incorrect value type */ public static <T extends PulsarConfiguration> T create(InputStream inStream, Class<? extends PulsarConfiguration> clazz) throws IOException, IllegalArgumentException { try { checkNotNull(inStream); Properties properties = new Properties(); properties.load(inStream); return (create(properties, clazz)); } finally { if (inStream != null) { inStream.close(); } } }
public WebSocketService(WebSocketProxyConfiguration config) { this(createClusterData(config), PulsarConfigurationLoader.convertFrom(config)); }
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); } }
public void start() throws Exception { if (!isBlank(proxyConfig.getZookeeperServers()) && !isBlank(proxyConfig.getConfigurationStoreServers())) { discoveryProvider = new BrokerDiscoveryProvider(this.proxyConfig, getZooKeeperClientFactory()); this.configurationCacheService = new ConfigurationCacheService(discoveryProvider.globalZkCache); authorizationService = new AuthorizationService(PulsarConfigurationLoader.convertFrom(proxyConfig), 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. try { bootstrap.bind(proxyConfig.getServicePort()).sync(); } catch (Exception e) { throw new IOException("Failed to bind Pulsar Proxy on port " + proxyConfig.getServicePort(), e); } 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()); } }
public static void init(String configFile) throws Exception { // setup handlers removeHandlersForRootLogger(); install(); setDefaultUncaughtExceptionHandler((thread, exception) -> { log.error("Uncaught exception in thread {}: {}", thread.getName(), exception.getMessage(), exception); }); // load config file final ServiceConfig config = PulsarConfigurationLoader.create(configFile, ServiceConfig.class); checkConfig(config); // create Discovery service DiscoveryService discoveryService = new DiscoveryService(config); // create a web-service final ServerManager server = new ServerManager(config); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { discoveryService.close(); server.stop(); } catch (Exception e) { log.warn("server couldn't stop gracefully {}", e.getMessage(), e); } } }); discoveryService.start(); startWebService(server, config); }
/** * 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 = PulsarConfigurationLoader.convertFrom(config); authenticationService = new AuthenticationService(serviceConfiguration); authorizationService = new AuthorizationService(serviceConfiguration, configurationCacheService); startServer(); }
throw new IllegalArgumentException("Need to specify a configuration file for broker"); } else { brokerConfig = PulsarConfigurationLoader.create( arguments.brokerConfigFile, ServiceConfiguration.class);
this.config = PulsarConfigurationLoader.create((new FileInputStream(this.getConfigFile())), ServiceConfiguration.class);