Search in sources :

Example 1 with SharedLimiterFactory

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();
}
Also used : SharedLimiterFactory(org.apache.gobblin.util.limiter.broker.SharedLimiterFactory) SharedRestClientKey(org.apache.gobblin.restli.SharedRestClientKey) SimpleScopeType(org.apache.gobblin.broker.SimpleScopeType) SharedLimiterKey(org.apache.gobblin.util.limiter.broker.SharedLimiterKey) Test(org.testng.annotations.Test)

Aggregations

SimpleScopeType (org.apache.gobblin.broker.SimpleScopeType)1 SharedRestClientKey (org.apache.gobblin.restli.SharedRestClientKey)1 SharedLimiterFactory (org.apache.gobblin.util.limiter.broker.SharedLimiterFactory)1 SharedLimiterKey (org.apache.gobblin.util.limiter.broker.SharedLimiterKey)1 Test (org.testng.annotations.Test)1