use of com.linkedin.darkcluster.filter.DarkClusterFilter in project rest.li by linkedin.
the class TestDarkClusterFilter method setup.
@BeforeMethod
public void setup() {
_client = new MockClient(false);
_darkClusterDispatcher = new DefaultDarkClusterDispatcher(_client);
_clusterInfoProvider = new SimpleLoadBalancer(new LoadBalancerTestState(), _scheduledExecutorService);
_facilities = new MockFacilities(_clusterInfoProvider);
_darkClusterStrategyFactory = new DarkClusterStrategyFactoryImpl(_facilities, SOURCE_CLUSTER_NAME, _darkClusterDispatcher, _notifier, _random, _verifierManager, _rateLimiterSupplier);
DarkClusterManager darkClusterManager = new DarkClusterManagerImpl(SOURCE_CLUSTER_NAME, _facilities, _darkClusterStrategyFactory, "", "", _notifier);
_darkClusterFilter = new DarkClusterFilter(darkClusterManager, _verifierManager);
}
use of com.linkedin.darkcluster.filter.DarkClusterFilter in project rest.li by linkedin.
the class TestDarkClusterFilter method testDarkClusterAssemblyWithDarkCluster.
@Test
public void testDarkClusterAssemblyWithDarkCluster() {
// we need to have a Mock clusterInfoProvider in order to set up a dark cluster.
MockClusterInfoProvider clusterInfoProvider = new MockClusterInfoProvider();
_facilities = new MockFacilities(clusterInfoProvider);
_darkClusterStrategyFactory = new DarkClusterStrategyFactoryImpl(_facilities, SOURCE_CLUSTER_NAME, _darkClusterDispatcher, _notifier, _random, _verifierManager, _rateLimiterSupplier);
_darkClusterStrategyFactory.start();
DarkClusterManager darkClusterManager = new DarkClusterManagerImpl(SOURCE_CLUSTER_NAME, _facilities, _darkClusterStrategyFactory, "", "", _notifier);
_darkClusterFilter = new DarkClusterFilter(darkClusterManager, _verifierManager);
// set the multiplier to 1 so that traffic gets sent.
DarkClusterConfig darkClusterConfig = createRelativeTrafficMultiplierConfig(1.0f);
clusterInfoProvider.addDarkClusterConfig(SOURCE_CLUSTER_NAME, DARK_CLUSTER_NAME, darkClusterConfig);
clusterInfoProvider.notifyListenersClusterAdded(SOURCE_CLUSTER_NAME);
// send the request, expecting it to make it all the way down to the client
RestRequest restRequest = new RestRequestBuilder(URI.create("foo")).build();
_darkClusterFilter.onRestRequest(restRequest, new RequestContext(), new HashMap<>(), new DummyNextFilter());
Assert.assertEquals(_client.requestAuthorityMap.size(), 1, "expected 1 request to be sent");
_darkClusterFilter.onRestError(new RuntimeException("test"), new RequestContext(), new HashMap<>(), new DummyNextFilter());
_darkClusterFilter.onRestResponse(new RestResponseBuilder().build(), new RequestContext(), new HashMap<>(), new DummyNextFilter());
}
Aggregations