private Future<?> startServerInPooledThread() {
if (!started.compareAndSet(false, true)) {
return null;
}
return ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
BuiltInServer mainServer = StartupUtil.getServer();
if (mainServer == null || mainServer.getEventLoopGroup() instanceof OioEventLoopGroup) {
server = BuiltInServer.start(1, getDefaultPort(), PORTS_COUNT, false, null);
}
else {
server = BuiltInServer.start(mainServer.getEventLoopGroup(), false, getDefaultPort(), PORTS_COUNT, true, null);
}
bindCustomPorts(server);
}
catch (Throwable e) {
LOG.info(e);
NOTIFICATION_GROUP.getValue().createNotification("Cannot start internal HTTP server. Git integration, Some plugins may operate with errors. " +
"Please check your firewall settings and restart " + ApplicationNamesInfo.getInstance().getFullProductName(),
NotificationType.ERROR).notify(null);
return;
}
LOG.info("built-in server started, port " + server.getPort());
Disposer.register(ApplicationManager.getApplication(), server);
});
}
java类io.netty.channel.oio.OioEventLoopGroup的实例源码
BuiltInServerManagerImpl.java 文件源码
项目:consulo
阅读 27
收藏 0
点赞 0
评论 0
RpcClient.java 文件源码
项目:TakinRPC
阅读 23
收藏 0
点赞 0
评论 0
public RpcClient(OioEventLoopGroup eventLoopGroup, EventExecutorGroup eventExecutor) {
this(eventLoopGroup, eventExecutor, OioSocketChannel.class);
}
RpcServer.java 文件源码
项目:TakinRPC
阅读 22
收藏 0
点赞 0
评论 0
public RpcServer(OioEventLoopGroup eventLoopGroup, EventExecutorGroup eventExecutor, @Assisted SocketAddress address) {
this(eventLoopGroup, eventExecutor, OioServerSocketChannel.class, address);
}
SocketChannelResolverTest.java 文件源码
项目:aws-sdk-java-v2
阅读 17
收藏 0
点赞 0
评论 0
@Test
public void worksWithOioEventLoopGroup() {
assertThat(resolveSocketChannelClass(new OioEventLoopGroup())).isEqualTo(OioSocketChannel.class);
}
DefaultServer.java 文件源码
项目:yajsw
阅读 27
收藏 0
点赞 0
评论 0
public DefaultServer(Class serverChannelClass,
ChannelPipelineFactoryFactory factory, Set<String> channelOptions,
int port, InetAddress address)
{
if (!ServerChannel.class.isAssignableFrom(serverChannelClass))
throw new RuntimeException(
"serverChannelClass must implement ServerChannel");
// Configure the server.
bootstrap = new ServerBootstrap();
_port = port;
_address = address;
internalGroup = new DefaultEventExecutorGroup(10);
if (isNio(serverChannelClass))
{
bossGroup = new NioEventLoopGroup();
childGroup = new NioEventLoopGroup();
}
else if (isOio(serverChannelClass))
{
bossGroup = new OioEventLoopGroup();
childGroup = new OioEventLoopGroup();
}
else
{
bossGroup = new NioEventLoopGroup();
childGroup = new NioEventLoopGroup();
}
bootstrap.group(bossGroup, childGroup);
bootstrap.channel(serverChannelClass);
// bootstrap.setOption("child.trafficClass", IPTOS_LOWDELAY);
// bootstrap.setOption("child.tcpNoDelay", false);
// bootstrap.childOption(ChannelOption.IP_TOS, IPTOS_THROUGHPUT);
setChannelOptions(channelOptions);
bootstrap.option(ChannelOption.SO_BACKLOG, 100);
ChannelPipelineFactory channelPipelineFactory = factory.create(
internalGroup, bootstrap);
bootstrap.childHandler(channelPipelineFactory);
}
MockBookKeeper.java 文件源码
项目:incubator-pulsar
阅读 16
收藏 0
点赞 0
评论 0
public MockBookKeeper(ClientConfiguration conf, ZooKeeper zk) throws Exception {
super(conf, zk, new OioEventLoopGroup());
}
NettyUtil.java 文件源码
项目:intellij-ce-playground
阅读 25
收藏 0
点赞 0
评论 0
@NotNull
public static Bootstrap oioClientBootstrap() {
Bootstrap bootstrap = new Bootstrap().group(new OioEventLoopGroup(1, PooledThreadExecutor.INSTANCE)).channel(OioSocketChannel.class);
bootstrap.option(ChannelOption.TCP_NODELAY, true).option(ChannelOption.SO_KEEPALIVE, true);
return bootstrap;
}
SimpleRtspSession.java 文件源码
项目:imflux
阅读 19
收藏 0
点赞 0
评论 0
/**
* {@inheritDoc}
*/
@Override
public synchronized boolean init() {
if(this.running.get()) {
return true;
}
// create bootstrap
Class<? extends ServerChannel> channelType;
if(useNio) {
this.workerGroup = new NioEventLoopGroup();
this.bossGroup = new NioEventLoopGroup();
channelType = NioServerSocketChannel.class;
} else {
this.workerGroup = new OioEventLoopGroup();
this.bossGroup = new OioEventLoopGroup();
channelType = OioServerSocketChannel.class;
}
bootstrap = new ServerBootstrap();
bootstrap.group(this.bossGroup, this.workerGroup)
.option(ChannelOption.SO_SNDBUF, this.sendBufferSize)
.option(ChannelOption.SO_RCVBUF, this.receiveBufferSize)
.channel(channelType)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new ChannelInitializer<Channel>() { // is used to initialize the ChannelPipeline
@Override
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("encoder", new RtspEncoder());
pipeline.addLast("decoder", new RtspDecoder());
pipeline.addLast("aggregator", new HttpObjectAggregator(64*1024));
pipeline.addLast("handler", new RtspHandler(SimpleRtspSession.this));
}
});
// create channel
try {
ChannelFuture future = bootstrap.bind(this.localAddress);
this.channel = future.sync().channel(); // wait for future to complete and retrieve channel
} catch (Exception e) {
LOG.error("Failed to bind RTSP channel for session with id " + this.id, e);
this.workerGroup.shutdownGracefully();
this.bossGroup.shutdownGracefully();
this.workerGroup.terminationFuture().syncUninterruptibly();
this.bossGroup.terminationFuture().syncUninterruptibly();
return false;
}
LOG.debug("RTSP channel bound for RtspSession with id {}.", this.id);
this.running.set(true);
return true;
}
BlockingNettyServerBuilder.java 文件源码
项目:Jasmine
阅读 16
收藏 0
点赞 0
评论 0
@Override
protected void configureBootstrap() {
serverBootstrap.group(new OioEventLoopGroup(workerCount))
.channel(OioServerSocketChannel.class);
}
BlockingHttpServerBuilder.java 文件源码
项目:baiji4j
阅读 20
收藏 0
点赞 0
评论 0
@Override
protected void configureBootstrap() {
_nettyBootstrap.group(new OioEventLoopGroup(workerCount))
.channel(OioServerSocketChannel.class);
}