class GroupExecutor implements Executor, Closeable {

  public void initConfig() {
    if (LOG_PRINTED.compareAndSet(false, true)) {
      LOGGER.info("thread pool rules:\n"
          + "1.use core threads.\n"
          + "2.if all core threads are busy, then create new thread.\n"
          + "3.if thread count reach the max limitation, then queue the request.\n"
          + "4.if queue is full, and threads count is max, then reject the request.");
    }

    groupCount = DynamicPropertyFactory.getInstance().getIntProperty(KEY_GROUP, 2).get();
    coreThreads = DynamicPropertyFactory.getInstance().getIntProperty(KEY_CORE_THREADS, 25).get();

    maxThreads = DynamicPropertyFactory.getInstance().getIntProperty(KEY_MAX_THREADS, -1).get();
    if (maxThreads <= 0) {
      maxThreads = DynamicPropertyFactory.getInstance().getIntProperty(KEY_OLD_MAX_THREAD, -1).get();
      if (maxThreads > 0) {
        LOGGER.warn("{} is deprecated, recommended to use {}.", KEY_OLD_MAX_THREAD, KEY_MAX_THREADS);
      } else {
        maxThreads = 100;
      }
    }
    if (coreThreads > maxThreads) {
      LOGGER.warn("coreThreads is bigger than maxThreads, change from {} to {}.", coreThreads, maxThreads);
      coreThreads = maxThreads;
    }

    maxIdleInSecond = DynamicPropertyFactory.getInstance().getIntProperty(KEY_MAX_IDLE_SECOND, 60).get();
    maxQueueSize = DynamicPropertyFactory.getInstance().getIntProperty(KEY_MAX_QUEUE_SIZE, Integer.MAX_VALUE).get();

    LOGGER.info(
        "executor name={}, group={}. per group settings, coreThreads={}, maxThreads={}, maxIdleInSecond={}, maxQueueSize={}.",
        groupName, groupCount, coreThreads, maxThreads, maxIdleInSecond, maxQueueSize);
  }

}