package com.github.ambry.config;

/**
 * The configs for connection pool.
 */
public class ConnectionPoolConfig {

  /**
   * The read buffer size in bytes for a connection.
   */
  @Config("connectionpool.read.buffer.size.bytes")
  @Default("10000")
  public final int connectionPoolReadBufferSizeBytes;

  /**
   * The write buffer size in bytes for a connection.
   */
  @Config("connectionpool.write.buffer.size.bytes")
  @Default("10000")
  public final int connectionPoolWriteBufferSizeBytes;

  /**
   * Read timeout in milliseconds for a connection.
   */
  @Config("connectionpool.read.timeout.ms")
  @Default("10000")
  public final int connectionPoolReadTimeoutMs;

  /**
   * Connect timeout in milliseconds for a connection.
   */
   @Config("connectionpool.connect.timeout.ms")
   @Default("2000")
   public final int connectionPoolConnectTimeoutMs;

  /**
   * The max connections allowed per host
   */
  @Config("connectionpool.max.connections.per.host")
  @Default("40")
  public final int connectionPoolMaxConnectionsPerHost;

  public ConnectionPoolConfig(VerifiableProperties verifiableProperties) {
    connectionPoolReadBufferSizeBytes =
        verifiableProperties.getIntInRange("connectionpool.read.buffer.size.bytes", 10000, 1, 1024 * 1024 * 1024);
    connectionPoolWriteBufferSizeBytes =
        verifiableProperties.getIntInRange("connectionpool.write.buffer.size.bytes", 10000, 1, 1024 * 1024 * 1024);
    connectionPoolReadTimeoutMs =
        verifiableProperties.getIntInRange("connectionpool.read.timeout.ms", 10000, 1, 100000);
    connectionPoolConnectTimeoutMs =
        verifiableProperties.getIntInRange("connectionpool.connect.timeout.ms", 2000, 1, 100000);
    connectionPoolMaxConnectionsPerHost =
        verifiableProperties.getIntInRange("connectionpool.max.connections.per.host", 5, 1, 20);
  }
}

@@ -606,34 +606,33 @@
 %22)%0A  @Default(%221
-00
+5
 00%22)%0A  public fi
@@ -797,18 +797,17 @@
 efault(%22
-20
+8
 00%22)%0A   
@@ -979,10 +979,9 @@
 lt(%22
-40
+5
 %22)%0A 
@@ -1531,26 +1531,25 @@
 meout.ms%22, 1
-00
+5
 00, 1, 10000
@@ -1669,18 +1669,17 @@
 ut.ms%22, 
-20
+8
 00, 1, 1

Change defaults for certain timeouts