use of com.linkedin.darkcluster.impl.DarkClusterStrategyFactoryImpl in project rest.li by linkedin.
the class TestDarkClusterStrategyFactory method setup.
@BeforeMethod
public void setup() {
_clusterInfoProvider = new MockClusterInfoProvider();
Facilities facilities = new MockFacilities(_clusterInfoProvider);
DarkClusterConfig darkClusterConfigOld = createRelativeTrafficMultiplierConfig(0.5f);
_clusterInfoProvider.addDarkClusterConfig(SOURCE_CLUSTER_NAME, PREEXISTING_DARK_CLUSTER_NAME, darkClusterConfigOld);
DarkClusterDispatcher darkClusterDispatcher = new DefaultDarkClusterDispatcher(new MockClient(false));
ClockedExecutor executor = new ClockedExecutor();
_rateLimiterSupplier = () -> new ConstantQpsRateLimiter(executor, executor, executor, TestConstantQpsDarkClusterStrategy.getBuffer(executor));
_strategyFactory = new DarkClusterStrategyFactoryImpl(facilities, SOURCE_CLUSTER_NAME, darkClusterDispatcher, new DoNothingNotifier(), new Random(SEED), new CountingVerifierManager(), _rateLimiterSupplier);
_strategyFactory.start();
}
use of com.linkedin.darkcluster.impl.DarkClusterStrategyFactoryImpl 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.impl.DarkClusterStrategyFactoryImpl 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