Search in sources :

Example 6 with NetworkConfig

use of com.github.ambry.config.NetworkConfig in project ambry by linkedin.

the class ConnectionTrackerTest method initialize.

@Before
public void initialize() {
    Properties props = new Properties();
    props.setProperty("router.hostname", "localhost");
    props.setProperty("router.datacenter.name", "DC1");
    props.setProperty("router.scaling.unit.max.connections.per.port.plain.text", "3");
    props.setProperty("router.scaling.unit.max.connections.per.port.ssl", "2");
    verifiableProperties = new VerifiableProperties((props));
    routerConfig = new RouterConfig(verifiableProperties);
    networkConfig = new NetworkConfig(verifiableProperties);
    time = new MockTime();
    plainTextPort = new Port(100, PortType.PLAINTEXT);
    sslPort = new Port(200, PortType.SSL);
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) NetworkConfig(com.github.ambry.config.NetworkConfig) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) RouterConfig(com.github.ambry.config.RouterConfig) MockTime(com.github.ambry.utils.MockTime) Before(org.junit.Before)

Example 7 with NetworkConfig

use of com.github.ambry.config.NetworkConfig in project ambry by linkedin.

the class SelectorTest method setup.

@Before
public void setup() throws Exception {
    this.server = new EchoServer(18283);
    this.server.start();
    Properties props = new Properties();
    props.setProperty("selector.executor.pool.size", Integer.toString(selectorExecutorPoolSize));
    VerifiableProperties vprops = new VerifiableProperties(props);
    NetworkConfig networkConfig = new NetworkConfig(vprops);
    this.selector = new Selector(new NetworkMetrics(new MetricRegistry()), SystemTime.getInstance(), null, networkConfig);
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) MetricRegistry(com.codahale.metrics.MetricRegistry) NetworkConfig(com.github.ambry.config.NetworkConfig) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) Before(org.junit.Before)

Example 8 with NetworkConfig

use of com.github.ambry.config.NetworkConfig in project ambry by linkedin.

the class CloudRouterTest method setRouter.

/**
 * Initialize and set the router with the given {@link Properties} and {@link MockServerLayout}
 * @param props the {@link Properties}
 * @param notificationSystem the {@link NotificationSystem} to use.
 */
@Override
protected void setRouter(Properties props, MockServerLayout mockServerLayout, NotificationSystem notificationSystem) throws Exception {
    VerifiableProperties verifiableProperties = new VerifiableProperties((props));
    RouterConfig routerConfig = new RouterConfig(verifiableProperties);
    routerMetrics = new NonBlockingRouterMetrics(mockClusterMap, routerConfig);
    CloudConfig cloudConfig = new CloudConfig(verifiableProperties);
    CloudDestinationFactory cloudDestinationFactory = Utils.getObj(cloudConfig.cloudDestinationFactoryClass, verifiableProperties, mockClusterMap.getMetricRegistry(), mockClusterMap);
    CloudDestination cloudDestination = cloudDestinationFactory.getCloudDestination();
    AccountService accountService = new InMemAccountService(false, true);
    CloudRouterFactory cloudRouterFactory = new CloudRouterFactory(verifiableProperties, mockClusterMap, new LoggingNotificationSystem(), null, accountService);
    RequestHandlerPool requestHandlerPool = cloudRouterFactory.getRequestHandlerPool(verifiableProperties, mockClusterMap, cloudDestination, cloudConfig);
    Map<ReplicaType, NetworkClientFactory> childFactories = new EnumMap<>(ReplicaType.class);
    childFactories.put(ReplicaType.CLOUD_BACKED, new LocalNetworkClientFactory((LocalRequestResponseChannel) requestHandlerPool.getChannel(), new NetworkConfig(verifiableProperties), new NetworkMetrics(routerMetrics.getMetricRegistry()), mockTime));
    childFactories.put(ReplicaType.DISK_BACKED, new MockNetworkClientFactory(verifiableProperties, mockSelectorState, MAX_PORTS_PLAIN_TEXT, MAX_PORTS_SSL, CHECKOUT_TIMEOUT_MS, mockServerLayout, mockTime));
    NetworkClientFactory networkClientFactory = new CompositeNetworkClientFactory(childFactories);
    router = new NonBlockingRouter(routerConfig, routerMetrics, networkClientFactory, notificationSystem, mockClusterMap, kms, cryptoService, cryptoJobHandler, accountService, mockTime, MockClusterMap.DEFAULT_PARTITION_CLASS);
    router.addResourceToClose(requestHandlerPool);
}
Also used : LocalNetworkClientFactory(com.github.ambry.network.LocalNetworkClientFactory) LocalRequestResponseChannel(com.github.ambry.network.LocalRequestResponseChannel) VerifiableProperties(com.github.ambry.config.VerifiableProperties) LocalNetworkClientFactory(com.github.ambry.network.LocalNetworkClientFactory) NetworkClientFactory(com.github.ambry.network.NetworkClientFactory) CompositeNetworkClientFactory(com.github.ambry.network.CompositeNetworkClientFactory) NetworkMetrics(com.github.ambry.network.NetworkMetrics) CloudDestination(com.github.ambry.cloud.CloudDestination) CloudConfig(com.github.ambry.config.CloudConfig) NetworkConfig(com.github.ambry.config.NetworkConfig) CloudDestinationFactory(com.github.ambry.cloud.CloudDestinationFactory) LatchBasedInMemoryCloudDestinationFactory(com.github.ambry.cloud.LatchBasedInMemoryCloudDestinationFactory) RouterConfig(com.github.ambry.config.RouterConfig) CompositeNetworkClientFactory(com.github.ambry.network.CompositeNetworkClientFactory) InMemAccountService(com.github.ambry.account.InMemAccountService) LoggingNotificationSystem(com.github.ambry.commons.LoggingNotificationSystem) ReplicaType(com.github.ambry.clustermap.ReplicaType) RequestHandlerPool(com.github.ambry.protocol.RequestHandlerPool) AccountService(com.github.ambry.account.AccountService) InMemAccountService(com.github.ambry.account.InMemAccountService) EnumMap(java.util.EnumMap)

Aggregations

NetworkConfig (com.github.ambry.config.NetworkConfig)8 VerifiableProperties (com.github.ambry.config.VerifiableProperties)6 Properties (java.util.Properties)5 MetricRegistry (com.codahale.metrics.MetricRegistry)4 ArrayList (java.util.ArrayList)4 AccountService (com.github.ambry.account.AccountService)3 DataNodeId (com.github.ambry.clustermap.DataNodeId)3 CloudConfig (com.github.ambry.config.CloudConfig)3 RequestHandlerPool (com.github.ambry.protocol.RequestHandlerPool)3 AccountServiceFactory (com.github.ambry.account.AccountServiceFactory)2 NettySslHttp2Factory (com.github.ambry.commons.NettySslHttp2Factory)2 SSLFactory (com.github.ambry.commons.SSLFactory)2 ClusterMapConfig (com.github.ambry.config.ClusterMapConfig)2 ConnectionPoolConfig (com.github.ambry.config.ConnectionPoolConfig)2 Http2ClientConfig (com.github.ambry.config.Http2ClientConfig)2 NettyConfig (com.github.ambry.config.NettyConfig)2 ReplicationConfig (com.github.ambry.config.ReplicationConfig)2 RouterConfig (com.github.ambry.config.RouterConfig)2 SSLConfig (com.github.ambry.config.SSLConfig)2 ServerConfig (com.github.ambry.config.ServerConfig)2