protected ServerState(ServerState<R, W> toCopy, final SocketAddress socketAddress) { this.socketAddress = socketAddress; bootstrap = toCopy.bootstrap.clone(); detachedPipeline = toCopy.detachedPipeline; bootstrap.childHandler(detachedPipeline.getChannelInitializer()); }
protected ServerState(ServerState<?, ?> toCopy, final DetachedChannelPipeline newPipeline) { final ServerState<R, W> toCopyCast = toCopy.cast(); socketAddress = toCopy.socketAddress; bootstrap = toCopyCast.bootstrap.clone(); detachedPipeline = newPipeline; bootstrap.childHandler(detachedPipeline.getChannelInitializer()); }
@Override public ServerBootstrap configure() { return this.serverBootstrap.clone(); }
@Override public ServerBootstrap configure() { return this.serverBootstrap.clone(); }
@Override protected ServerState<R, W> copyBootstrapOnly() { return new TcpServerState<>(this, bootstrap.clone()); }
public void start() { if (serviceName == null) { this.serviceName = getNextDefaultServiceName(); } if (initIsa.getPort() == 0) { try { int port = getUnusedPort(); serverAddr = new InetSocketAddress(initIsa.getHostName(), port); } catch (IOException e) { LOG.error(e, e); } } else { serverAddr = initIsa; } this.channelFuture = bootstrap.clone().bind(serverAddr).syncUninterruptibly(); this.bindAddress = (InetSocketAddress) channelFuture.channel().localAddress(); LOG.info("Rpc (" + serviceName + ") listens on " + this.bindAddress); }
public void start() { for (RpcEventListener listener: listeners) { listener.onBeforeStart(this); } if (serviceName == null) { this.serviceName = getNextDefaultServiceName(); } if (initIsa.getPort() == 0) { try { int port = getUnusedPort(); serverAddr = new InetSocketAddress(initIsa.getHostName(), port); } catch (IOException e) { LOG.error(e, e); } } else { serverAddr = initIsa; } this.channelFuture = bootstrap.clone().bind(serverAddr).syncUninterruptibly(); this.bindAddress = (InetSocketAddress) channelFuture.channel().localAddress(); for (RpcEventListener listener: listeners) { listener.onAfterStart(this); } LOG.info("Rpc (" + serviceName + ") listens on " + this.bindAddress); }
/** * starts server to handle discovery-request from client-channel * * @throws Exception */ public void startServer() throws Exception { 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)); if (workerGroup instanceof EpollEventLoopGroup) { bootstrap.channel(EpollServerSocketChannel.class); bootstrap.childOption(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED); } else { bootstrap.channel(NioServerSocketChannel.class); } bootstrap.childHandler(new ServiceChannelInitializer(this, config, false)); // Bind and start to accept incoming connections. bootstrap.bind(config.getServicePort()).sync(); LOG.info("Started Pulsar Broker service on port {}", config.getWebServicePort()); if (config.isTlsEnabled()) { ServerBootstrap tlsBootstrap = bootstrap.clone(); tlsBootstrap.childHandler(new ServiceChannelInitializer(this, config, true)); tlsBootstrap.bind(config.getServicePortTls()).sync(); LOG.info("Started Pulsar Broker TLS service on port {}", config.getWebServicePortTls()); } }
/** * starts server to handle discovery-request from client-channel * * @throws Exception */ public void startServer() throws Exception { 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, config, false)); // Bind and start to accept incoming connections. bootstrap.bind(config.getServicePort()).sync(); LOG.info("Started Pulsar Discovery service on port {}", config.getServicePort()); if (config.isTlsEnabled()) { ServerBootstrap tlsBootstrap = bootstrap.clone(); tlsBootstrap.childHandler(new ServiceChannelInitializer(this, config, true)); tlsBootstrap.bind(config.getServicePortTls()).sync(); LOG.info("Started Pulsar Discovery TLS service on port {}", config.getServicePortTls()); } }
serverChannels.add(serverBootstrap.clone().localAddress(address).bind());
ServerBootstrap bootstrap = selector.clone(); final TajoConf tajoConf = (TajoConf)conf; try {
ServerBootstrap tlsBootstrap = bootstrap.clone(); tlsBootstrap.childHandler(new PulsarChannelInitializer(this, serviceConfig, true)); tlsBootstrap.bind(new InetSocketAddress(pulsar.getBindAddress(), tlsPort)).sync();
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()); } }
LOG.info("Tajo PullServer initialized: readaheadLength=" + readaheadLength); ServerBootstrap bootstrap = selector.clone(); try { channelInitializer = new HttpChannelInitializer(tajoConf);
ServerBootstrap tlsBootstrap = bootstrap.clone(); tlsBootstrap.childHandler(new PulsarChannelInitializer(pulsar, true)); tlsBootstrap.bind(new InetSocketAddress(pulsar.getBindAddress(), tlsPort)).sync();
@Override public Mono<? extends DisposableServer> bind(ServerBootstrap b) { SslProvider ssl = SslProvider.findSslSupport(b); if (ssl != null && ssl.getDefaultConfigurationType() == null) { ssl = SslProvider.updateDefaultConfiguration(ssl, SslProvider.DefaultConfigurationType.TCP); SslProvider.setBootstrap(b, ssl); } if (b.config() .group() == null) { TcpServerRunOn.configure(b, LoopResources.DEFAULT_NATIVE, TcpResources.get()); } return Mono.create(sink -> { ServerBootstrap bootstrap = b.clone(); ConnectionObserver obs = BootstrapHandlers.connectionObserver(bootstrap); ConnectionObserver childObs = BootstrapHandlers.childConnectionObserver(bootstrap); ChannelOperations.OnSetup ops = BootstrapHandlers.channelOperationFactory(bootstrap); convertLazyLocalAddress(bootstrap); BootstrapHandlers.finalizeHandler(bootstrap, ops, new ChildObserver(childObs)); ChannelFuture f = bootstrap.bind(); DisposableBind disposableServer = new DisposableBind(sink, f, obs, bootstrap); f.addListener(disposableServer); sink.onCancel(disposableServer); }); }
@Override public Mono<? extends DisposableServer> bind(ServerBootstrap b) { SslProvider ssl = SslProvider.findSslSupport(b); if (ssl != null && ssl.getDefaultConfigurationType() == null) { ssl = SslProvider.updateDefaultConfiguration(ssl, SslProvider.DefaultConfigurationType.TCP); SslProvider.setBootstrap(b, ssl); } if (b.config() .group() == null) { TcpServerRunOn.configure(b, LoopResources.DEFAULT_NATIVE, TcpResources.get()); } return Mono.create(sink -> { ServerBootstrap bootstrap = b.clone(); ConnectionObserver obs = BootstrapHandlers.connectionObserver(bootstrap); ConnectionObserver childObs = BootstrapHandlers.childConnectionObserver(bootstrap); ChannelOperations.OnSetup ops = BootstrapHandlers.channelOperationFactory(bootstrap); convertLazyLocalAddress(bootstrap); BootstrapHandlers.finalizeHandler(bootstrap, ops, new ChildObserver(childObs)); ChannelFuture f = bootstrap.bind(); DisposableBind disposableServer = new DisposableBind(sink, f, obs, bootstrap); f.addListener(disposableServer); sink.onCancel(disposableServer); }); }