<commit_before>package cz.muni.fi.xtovarn.heimdall.netty;

import cz.muni.fi.xtovarn.heimdall.netty.group.SecureChannelGroup;
import cz.muni.fi.xtovarn.heimdall.commons.Startable;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;

import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class NettyServer implements Startable {

	private final SecureChannelGroup secureChannelGroup;
	public final static int SERVER_PORT = 6000;

	private ServerBootstrap bootstrap;

//	@Inject
	public NettyServer(SecureChannelGroup secureChannelGroup) {
		this.secureChannelGroup = secureChannelGroup;
	}

	@Override
	public void start() {
		ChannelFactory factory = new NioServerSocketChannelFactory(Executors.newSingleThreadExecutor(), Executors.newFixedThreadPool(2));

		bootstrap = new ServerBootstrap(factory);

		bootstrap.setPipelineFactory(new ServerPipelineFactory(secureChannelGroup));

		bootstrap.setOption("child.tcpNoDelay", true);
		bootstrap.setOption("child.keepAlive", true);

		bootstrap.bind(new InetSocketAddress(SERVER_PORT));

		System.out.println(getClass().getCanonicalName() + "started");
	}

	@Override
	public void stop() {
		System.out.println("Closing " + this.getClass() + "...");

		try {
			secureChannelGroup.close().await(5, TimeUnit.SECONDS);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}<commit_msg>! fixedThreadPool changed to cachedPool<commit_after>package cz.muni.fi.xtovarn.heimdall.netty;

import cz.muni.fi.xtovarn.heimdall.netty.group.SecureChannelGroup;
import cz.muni.fi.xtovarn.heimdall.commons.Startable;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;

import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class NettyServer implements Startable {

	private final SecureChannelGroup secureChannelGroup;
	public final static int SERVER_PORT = 6000;

	private ServerBootstrap bootstrap;

//	@Inject
	public NettyServer(SecureChannelGroup secureChannelGroup) {
		this.secureChannelGroup = secureChannelGroup;
	}

	@Override
	public void start() {
		ChannelFactory factory = new NioServerSocketChannelFactory(Executors.newSingleThreadExecutor(), Executors.newCachedThreadPool(), 2);

		bootstrap = new ServerBootstrap(factory);

		bootstrap.setPipelineFactory(new ServerPipelineFactory(secureChannelGroup));

		bootstrap.setOption("child.tcpNoDelay", true);
		bootstrap.setOption("child.keepAlive", true);

		bootstrap.bind(new InetSocketAddress(SERVER_PORT));

		System.out.println(getClass().getCanonicalName() + "started");
	}

	@Override
	public void stop() {
		System.out.println("Closing " + this.getClass() + "...");

		try {
			secureChannelGroup.close().await(5, TimeUnit.SECONDS);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
{'fraction_non_alphanumeric': 0.10984725381865454, 'fraction_numerical': 0.003899902502437439, 'mean_word_length': 6.092165898617512, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6890168', 'n_tokens_mistral': 998, 'n_tokens_neox': 935, 'n_words': 159}