Search in sources :

Example 6 with Http2ClientConfig

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<>()));
}
Also used : SSLFactory(com.github.ambry.commons.SSLFactory) Http2ClientMetrics(com.github.ambry.network.http2.Http2ClientMetrics) VerifiableProperties(com.github.ambry.config.VerifiableProperties) MetricRegistry(com.codahale.metrics.MetricRegistry) Port(com.github.ambry.network.Port) ArrayList(java.util.ArrayList) Http2ClientConfig(com.github.ambry.config.Http2ClientConfig) NettySslHttp2Factory(com.github.ambry.commons.NettySslHttp2Factory) BlobProperties(com.github.ambry.messageformat.BlobProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) MockDataNodeId(com.github.ambry.clustermap.MockDataNodeId) Http2NetworkClient(com.github.ambry.network.http2.Http2NetworkClient) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) Test(org.junit.Test)

Example 7 with Http2ClientConfig

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;
}
Also used : Http2ClientMetrics(com.github.ambry.network.http2.Http2ClientMetrics) Http2BlockingChannel(com.github.ambry.network.http2.Http2BlockingChannel) VerifiableProperties(com.github.ambry.config.VerifiableProperties) MetricRegistry(com.codahale.metrics.MetricRegistry) ConnectedChannel(com.github.ambry.network.ConnectedChannel) Http2ClientConfig(com.github.ambry.config.Http2ClientConfig) BlobProperties(com.github.ambry.messageformat.BlobProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) BlockingChannel(com.github.ambry.network.BlockingChannel) Http2BlockingChannel(com.github.ambry.network.http2.Http2BlockingChannel) SSLBlockingChannel(com.github.ambry.network.SSLBlockingChannel) SSLBlockingChannel(com.github.ambry.network.SSLBlockingChannel)

Aggregations

Http2ClientConfig (com.github.ambry.config.Http2ClientConfig)7 VerifiableProperties (com.github.ambry.config.VerifiableProperties)5 Http2ClientMetrics (com.github.ambry.network.http2.Http2ClientMetrics)5 NettySslHttp2Factory (com.github.ambry.commons.NettySslHttp2Factory)4 SSLFactory (com.github.ambry.commons.SSLFactory)4 Port (com.github.ambry.network.Port)4 ArrayList (java.util.ArrayList)4 Properties (java.util.Properties)4 MetricRegistry (com.codahale.metrics.MetricRegistry)3 DataNodeId (com.github.ambry.clustermap.DataNodeId)3 BlobProperties (com.github.ambry.messageformat.BlobProperties)3 AccountService (com.github.ambry.account.AccountService)2 AccountServiceFactory (com.github.ambry.account.AccountServiceFactory)2 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)2 MockDataNodeId (com.github.ambry.clustermap.MockDataNodeId)2 CloudConfig (com.github.ambry.config.CloudConfig)2 ClusterMapConfig (com.github.ambry.config.ClusterMapConfig)2 ConnectionPoolConfig (com.github.ambry.config.ConnectionPoolConfig)2 NettyConfig (com.github.ambry.config.NettyConfig)2 NetworkConfig (com.github.ambry.config.NetworkConfig)2