use of org.apache.gobblin.util.limiter.broker.SharedLimiterFactory in project incubator-gobblin by apache.
the class RestliLimiterFactoryTest method testSkipGlobalLimiterOnLimiterFactory.
@Test
public void testSkipGlobalLimiterOnLimiterFactory() throws Exception {
Map<String, String> configMap = ImmutableMap.of(BrokerConfigurationKeyGenerator.generateKey(new SharedLimiterFactory(), null, null, SharedLimiterFactory.SKIP_GLOBAL_LIMITER_KEY), "true");
SharedResourcesBroker<SimpleScopeType> broker = SharedResourcesBrokerFactory.createDefaultTopLevelBroker(ConfigFactory.parseMap(configMap), SimpleScopeType.GLOBAL.defaultScopeInstance());
MyRequestSender requestSender = new MyRequestSender();
broker.bindSharedResourceAtScope(new RedirectAwareRestClientRequestSender.Factory<>(), new SharedRestClientKey(RestliLimiterFactory.RESTLI_SERVICE_NAME), SimpleScopeType.GLOBAL, requestSender);
Limiter limiter = broker.getSharedResource(new SharedLimiterFactory<>(), new SharedLimiterKey("my/resource"));
Assert.assertNotNull(limiter.acquirePermits(10));
Assert.assertEquals(requestSender.requestList.size(), 0);
broker.close();
}
Aggregations