Search in sources :

Example 1 with NoopEventEmitter

use of com.linkedin.d2.balancer.event.NoopEventEmitter in project rest.li by linkedin.

the class SimpleLoadBalancerStateTest method reset.

public void reset(boolean useSSL, boolean enableRelativeLoadBalancer) {
    _executorService = new SynchronousExecutorService();
    _uriRegistry = new MockStore<>();
    _clusterRegistry = new MockStore<>();
    _serviceRegistry = new MockStore<>();
    _clientFactories = new HashMap<>();
    _loadBalancerStrategyFactories = new HashMap<>();
    if (enableRelativeLoadBalancer) {
        _loadBalancerStrategyFactories.put(RelativeLoadBalancerStrategy.RELATIVE_LOAD_BALANCER_STRATEGY_NAME, new RelativeLoadBalancerStrategyFactory(new ClockedExecutor(), null, Collections.emptyList(), new NoopEventEmitter(), SystemClock.instance()));
    }
    _loadBalancerStrategyFactories.put("random", new RandomLoadBalancerStrategyFactory());
    _loadBalancerStrategyFactories.put("degraderV3", new DegraderLoadBalancerStrategyFactoryV3());
    _loadBalancerStrategyFactories.put(DegraderLoadBalancerStrategyV3.DEGRADER_STRATEGY_NAME, new DegraderLoadBalancerStrategyFactoryV3());
    try {
        _sslContext = SSLContext.getDefault();
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }
    _sslParameters = new SSLParameters();
    if (useSSL) {
        _clientFactories.put("https", new SimpleLoadBalancerTest.DoNothingClientFactory());
        _state = new SimpleLoadBalancerState(_executorService, new PropertyEventBusImpl<>(_executorService, _uriRegistry), new PropertyEventBusImpl<>(_executorService, _clusterRegistry), new PropertyEventBusImpl<>(_executorService, _serviceRegistry), _clientFactories, _loadBalancerStrategyFactories, _sslContext, _sslParameters, true, null, SSL_SESSION_VALIDATOR_FACTORY);
    } else {
        _clientFactories.put("http", new SimpleLoadBalancerTest.DoNothingClientFactory());
        _state = new SimpleLoadBalancerState(_executorService, _uriRegistry, _clusterRegistry, _serviceRegistry, _clientFactories, _loadBalancerStrategyFactories);
    }
    FutureCallback<None> callback = new FutureCallback<>();
    _state.start(callback);
    try {
        callback.get();
    } catch (Exception e) {
        Assert.fail("State start failed", e);
    }
}
Also used : SynchronousExecutorService(com.linkedin.d2.discovery.event.SynchronousExecutorService) NoopEventEmitter(com.linkedin.d2.balancer.event.NoopEventEmitter) DegraderLoadBalancerStrategyFactoryV3(com.linkedin.d2.balancer.strategies.degrader.DegraderLoadBalancerStrategyFactoryV3) RandomLoadBalancerStrategyFactory(com.linkedin.d2.balancer.strategies.random.RandomLoadBalancerStrategyFactory) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ClockedExecutor(com.linkedin.test.util.ClockedExecutor) URISyntaxException(java.net.URISyntaxException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SslSessionNotTrustedException(com.linkedin.r2.transport.http.client.common.ssl.SslSessionNotTrustedException) ExecutionException(java.util.concurrent.ExecutionException) SSLParameters(javax.net.ssl.SSLParameters) RelativeLoadBalancerStrategyFactory(com.linkedin.d2.balancer.strategies.relative.RelativeLoadBalancerStrategyFactory) PropertyEventBusImpl(com.linkedin.d2.discovery.event.PropertyEventBusImpl) None(com.linkedin.common.util.None) FutureCallback(com.linkedin.common.callback.FutureCallback)

Aggregations

FutureCallback (com.linkedin.common.callback.FutureCallback)1 None (com.linkedin.common.util.None)1 NoopEventEmitter (com.linkedin.d2.balancer.event.NoopEventEmitter)1 DegraderLoadBalancerStrategyFactoryV3 (com.linkedin.d2.balancer.strategies.degrader.DegraderLoadBalancerStrategyFactoryV3)1 RandomLoadBalancerStrategyFactory (com.linkedin.d2.balancer.strategies.random.RandomLoadBalancerStrategyFactory)1 RelativeLoadBalancerStrategyFactory (com.linkedin.d2.balancer.strategies.relative.RelativeLoadBalancerStrategyFactory)1 PropertyEventBusImpl (com.linkedin.d2.discovery.event.PropertyEventBusImpl)1 SynchronousExecutorService (com.linkedin.d2.discovery.event.SynchronousExecutorService)1 SslSessionNotTrustedException (com.linkedin.r2.transport.http.client.common.ssl.SslSessionNotTrustedException)1 ClockedExecutor (com.linkedin.test.util.ClockedExecutor)1 URISyntaxException (java.net.URISyntaxException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ExecutionException (java.util.concurrent.ExecutionException)1 SSLParameters (javax.net.ssl.SSLParameters)1