<commit_before>package com.xjeffrose.xio.server;

import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ExecutionError;
import com.google.inject.Inject;
import com.xjeffrose.xio.core.XioMetrics;
import io.netty.channel.group.ChannelGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import java.util.Map;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.apache.log4j.Logger;


public class XioBootstrap {
  private static final Logger log = Logger.getLogger(XioServerTransport.class.getName());

  private final XioServerConfig xioServerConfig;
  private final Map<XioServerDef, XioServerTransport> transports;
  private NioEventLoopGroup bossGroup;
  private NioEventLoopGroup workerGroup;

  @Inject
  public XioBootstrap(
      Set<XioServerDef> xioServerDefs,
      XioServerConfig xioServerConfig,
      ChannelGroup allChannels) {
    ImmutableMap.Builder<XioServerDef, XioServerTransport> builder = new ImmutableMap.Builder<>();
    this.xioServerConfig = xioServerConfig;
    for (XioServerDef XioServerDef : xioServerDefs) {
      builder.put(XioServerDef, new XioServerTransport(XioServerDef,
          xioServerConfig,
          allChannels));
    }
    transports = builder.build();
  }

  @PostConstruct
  public void start() {
    bossGroup = new NioEventLoopGroup(xioServerConfig.getBossThreadCount());
    workerGroup = new NioEventLoopGroup(xioServerConfig.getWorkerThreadCount());
    for (XioServerTransport transport : transports.values()) {
      try {
        transport.start(bossGroup, workerGroup);
      } catch (ExecutionError e) {
        log.error("Error starting port " + transport.getPort());
        throw new RuntimeException(e);
      }
    }
  }

  @PreDestroy
  public void stop() {
    for (XioServerTransport transport : transports.values()) {
      try {
        transport.stop();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }

    bossGroup.shutdownGracefully();
    workerGroup.shutdownGracefully();
  }

  public Map<XioServerDef, Integer> getBoundPorts() {
    ImmutableMap.Builder<XioServerDef, Integer> builder = new ImmutableMap.Builder<>();
    for (Map.Entry<XioServerDef, XioServerTransport> entry : transports.entrySet()) {
      builder.put(entry.getKey(), entry.getValue().getPort());
    }
    return builder.build();
  }

  public Map<XioServerDef, XioMetrics> getXioMetrics() {
    ImmutableMap.Builder<XioServerDef, XioMetrics> builder = new ImmutableMap.Builder<>();
    for (Map.Entry<XioServerDef, XioServerTransport> entry : transports.entrySet()) {
      builder.put(entry.getKey(), entry.getValue().getMetrics());
    }
    return builder.build();
  }
}<commit_msg>Changing the transport to non final for dynamic Confiig<commit_after>package com.xjeffrose.xio.server;

import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ExecutionError;
import com.google.inject.Inject;
import com.xjeffrose.xio.core.XioMetrics;
import io.netty.channel.group.ChannelGroup;
import io.netty.channel.nio.NioEventLoopGroup;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import jdk.nashorn.internal.ir.annotations.Immutable;
import org.apache.log4j.Logger;


public class XioBootstrap {
  private static final Logger log = Logger.getLogger(XioServerTransport.class.getName());

  private final XioServerConfig xioServerConfig;
  private Map<XioServerDef, XioServerTransport> transports;
  private NioEventLoopGroup bossGroup;
  private NioEventLoopGroup workerGroup;
  private final ChannelGroup allChannels;

  @Inject
  public XioBootstrap(
      Set<XioServerDef> xioServerDefs,
      XioServerConfig xioServerConfig,
      ChannelGroup allChannels) {
    ImmutableMap.Builder builder = ImmutableMap.builder();
    this.xioServerConfig = xioServerConfig;
    this.allChannels = allChannels;
    for (XioServerDef XioServerDef : xioServerDefs) {
      builder.put(XioServerDef, new XioServerTransport(XioServerDef,
          xioServerConfig,
          allChannels));
    }
    transports = builder.build();
  }

  @PostConstruct
  public void start() {
    bossGroup = new NioEventLoopGroup(xioServerConfig.getBossThreadCount());
    workerGroup = new NioEventLoopGroup(xioServerConfig.getWorkerThreadCount());
    for (XioServerTransport transport : transports.values()) {
      try {
        transport.start(bossGroup, workerGroup);
      } catch (ExecutionError e) {
        log.error("Error starting port " + transport.getPort());
        throw new RuntimeException(e);
      }
    }
  }

  @PreDestroy
  public void stop() {
    for (XioServerTransport transport : transports.values()) {
      try {
        transport.stop();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }

    bossGroup.shutdownGracefully();
    workerGroup.shutdownGracefully();
  }

  public Map<XioServerDef, Integer> getBoundPorts() {
    ImmutableMap.Builder<XioServerDef, Integer> builder = new ImmutableMap.Builder<>();
    for (Map.Entry<XioServerDef, XioServerTransport> entry : transports.entrySet()) {
      builder.put(entry.getKey(), entry.getValue().getPort());
    }
    return builder.build();
  }

  public Map<XioServerDef, XioMetrics> getXioMetrics() {
    ImmutableMap.Builder<XioServerDef, XioMetrics> builder = new ImmutableMap.Builder<>();
    for (Map.Entry<XioServerDef, XioServerTransport> entry : transports.entrySet()) {
      builder.put(entry.getKey(), entry.getValue().getMetrics());
    }
    return builder.build();
  }

  public void stopPort(int port){
    ImmutableMap.Builder builder = ImmutableMap.builder();
    for (XioServerDef key : transports.keySet()) {
      XioServerTransport v = transports.get(key);
      if(v.getPort() == port){
        try {
          v.stop();
        } catch (InterruptedException e) {
          Thread.currentThread().interrupt();
        }
      }
      else{
        builder.put(key,v);
      }
    }
    transports = builder.build();
  }

  public void startServer(XioServerDef serverDef){
    XioServerTransport transport = new  XioServerTransport(serverDef,
            xioServerConfig,
            allChannels);
    try {
      transport.start(bossGroup, workerGroup);
    } catch (ExecutionError e) {
      log.error("Error starting port " + transport.getPort());
      throw new RuntimeException(e);
    }
    ImmutableMap.Builder builder = ImmutableMap.builder().putAll(transports).put(serverDef,transport);
    transports = builder.build();
  }
}
{'fraction_non_alphanumeric': 0.10735139991016619, 'fraction_numerical': 0.0002994460248540201, 'mean_word_length': 3.854651162790698, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '7056270', 'n_tokens_mistral': 1997, 'n_tokens_neox': 1992, 'n_words': 377}