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);
}
}
Aggregations