This commit is contained in:
crusader 2018-04-24 19:44:23 +09:00
parent 14a7e47e3a
commit cabbe71a80
2 changed files with 11 additions and 10 deletions

View File

@ -18,7 +18,9 @@ import com.loafle.overflow.container.server.handler.RPCServerHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
@ -34,6 +36,8 @@ import io.netty.handler.logging.LoggingHandler;
* ContainerConfiguration
*/
@Configuration
@ComponentScan(basePackages = { "com.loafle.overflow" })
@PropertySource({ "classpath:netty.properties"})
public class ContainerConfiguration {
@Autowired
@Qualifier(Container.PIPELINE_CHANNEL_HANDLERS)
@ -42,20 +46,17 @@ public class ContainerConfiguration {
@Autowired(required=false)
private Gson gson;
@Bean()
@Qualifier(Server.CHANNEL_CLASS)
@Bean(Server.CHANNEL_CLASS)
public Class<? extends ServerChannel> channelClass() {
return NioServerSocketChannel.class;
}
@Bean
@Qualifier(Server.CHANNEL_OPTIONS)
@Bean(Server.CHANNEL_OPTIONS)
public List<Server.ChannelOptionItem<?>> channelOptions() {
return Arrays.asList(new Server.ChannelOptionItem<>(ChannelOption.SO_BACKLOG, 100));
}
@Bean
@Qualifier(Server.CHANNEL_HANDLER)
@Bean(Server.CHANNEL_HANDLER)
public ChannelHandler channelHandler() {
return new LoggingHandler(LogLevel.INFO);
}
@ -74,8 +75,7 @@ public class ContainerConfiguration {
return new POJORPCRegistry();
}
@Bean
@Qualifier(Server.CHANNEL_INITIALIZER)
@Bean(Server.CHANNEL_INITIALIZER)
public ChannelInitializer<?> channelInitializer() {
return new ChannelInitializer<SocketChannel>() {
@Override
@ -90,8 +90,7 @@ public class ContainerConfiguration {
};
}
@Bean
@Qualifier(Server.SOCKET_ADDRESS)
@Bean(Server.SOCKET_ADDRESS)
public SocketAddress address() {
return new InetSocketAddress("127.0.0.1", 60000);
}

View File

@ -0,0 +1,2 @@
server.netty.thread.count.boss=1
server.netty.thread.count.worker=10