use of com.github.ambry.config.Http2ClientConfig in project ambry by linkedin.
the class Http2NetworkClientTest method warmUpConnections.
@Test
public void warmUpConnections() throws Exception {
int connectionPerPort = 4;
SSLFactory sslFactory = new NettySslHttp2Factory(clientSSLConfig);
Properties properties = new Properties();
properties.setProperty(Http2ClientConfig.HTTP2_MIN_CONNECTION_PER_PORT, Integer.toString(connectionPerPort));
Http2ClientConfig http2ClientConfig = new Http2ClientConfig(new VerifiableProperties(properties));
Http2NetworkClient networkClient = new Http2NetworkClient(new Http2ClientMetrics(new MetricRegistry()), http2ClientConfig, sslFactory, eventLoopGroup);
MockClusterMap clusterMap = http2Cluster.getClusterMap();
assertEquals("Connection count is not expected", 0, networkClient.warmUpConnections(clusterMap.getDataNodeIds(), 0, 1000, new ArrayList<>()));
assertEquals("Connection count is not expected", clusterMap.getDataNodeIds().size() * connectionPerPort / 2, networkClient.warmUpConnections(clusterMap.getDataNodeIds(), 50, 1000, new ArrayList<>()));
assertEquals("Connection count is not expected", clusterMap.getDataNodeIds().size() * connectionPerPort, networkClient.warmUpConnections(clusterMap.getDataNodeIds(), 100, 1000, new ArrayList<>()));
// All connection should be failed. Connection refused exceptions will be in test log.
List<Port> ports = new ArrayList<>();
ports.add(new Port(79, PortType.HTTP2));
ports.add(new Port(78, PortType.PLAINTEXT));
assertEquals("Connection count is not expected", 0, networkClient.warmUpConnections(Collections.singletonList(new MockDataNodeId(ports, null, "DC1")), 100, 1000, new ArrayList<>()));
}
use of com.github.ambry.config.Http2ClientConfig in project ambry by linkedin.
the class ServerTestUtil method getBlockingChannelBasedOnPortType.
/**
* Returns BlockingChannel, SSLBlockingChannel or Http2BlockingChannel depending on whether the port type is PlainText,
* SSL or HTTP2 port for the given targetPort
* @param portType The type of port to connect to
* @param dataNodeId To which {@link MockDataNodeId} to connect
* @param sslSocketFactory the {@link SSLSocketFactory}.
* @param sslConfig the {@link SSLConfig}.
* @return ConnectedChannel
*/
private static ConnectedChannel getBlockingChannelBasedOnPortType(PortType portType, DataNodeId dataNodeId, SSLSocketFactory sslSocketFactory, SSLConfig sslConfig) {
ConnectedChannel channel = null;
String hostName = dataNodeId.getHostname();
if (portType == PortType.PLAINTEXT) {
channel = new BlockingChannel(hostName, dataNodeId.getPort(), 10000, 10000, 10000, 2000);
} else if (portType == PortType.SSL) {
channel = new SSLBlockingChannel(hostName, dataNodeId.getSSLPort(), new MetricRegistry(), 10000, 10000, 10000, 4000, sslSocketFactory, sslConfig);
} else if (portType == PortType.HTTP2) {
channel = new Http2BlockingChannel(hostName, dataNodeId.getHttp2Port(), sslConfig, new Http2ClientConfig(new VerifiableProperties(new Properties())), new Http2ClientMetrics(new MetricRegistry()));
}
return channel;
}
Aggregations