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