use of org.apache.gobblin.broker.SimpleScopeType in project incubator-gobblin by apache.
the class AsyncHttpWriterTest method createMockBroker.
private static SharedResourcesBroker createMockBroker() {
Joiner JOINER = Joiner.on(".");
Config config = ConfigFactory.parseMap(ImmutableMap.of(JOINER.join(BrokerConstants.GOBBLIN_BROKER_CONFIG_PREFIX, SharedLimiterFactory.NAME, SharedLimiterFactory.LIMITER_CLASS_KEY), "qps", JOINER.join(BrokerConstants.GOBBLIN_BROKER_CONFIG_PREFIX, SharedLimiterFactory.NAME, RateBasedLimiter.Factory.QPS_KEY), "10"));
SharedResourcesBrokerImpl broker = SharedResourcesBrokerFactory.<SimpleScopeType>createDefaultTopLevelBroker(config, SimpleScopeType.GLOBAL.defaultScopeInstance());
return broker;
}
use of org.apache.gobblin.broker.SimpleScopeType 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();
}
use of org.apache.gobblin.broker.SimpleScopeType in project incubator-gobblin by apache.
the class RestliLimiterFactoryTest method testFactory.
@Test
public void testFactory() throws Exception {
SharedResourcesBroker<SimpleScopeType> broker = SharedResourcesBrokerFactory.createDefaultTopLevelBroker(ConfigFactory.empty(), SimpleScopeType.GLOBAL.defaultScopeInstance());
MyRequestSender requestSender = new MyRequestSender();
broker.bindSharedResourceAtScope(new RedirectAwareRestClientRequestSender.Factory<>(), new SharedRestClientKey(RestliLimiterFactory.RESTLI_SERVICE_NAME), SimpleScopeType.GLOBAL, requestSender);
RestliServiceBasedLimiter limiter = broker.getSharedResource(new RestliLimiterFactory<>(), new SharedLimiterKey("my/resource"));
Assert.assertNotNull(limiter.acquirePermits(10));
Assert.assertEquals(requestSender.requestList.size(), 1);
broker.close();
}
use of org.apache.gobblin.broker.SimpleScopeType in project incubator-gobblin by apache.
the class FileSystemFactoryTest method testCreationWithConfigurationFSImpl.
@Test
public void testCreationWithConfigurationFSImpl() throws Exception {
SharedResourcesBrokerImpl<SimpleScopeType> broker = SharedResourcesBrokerFactory.<SimpleScopeType>createDefaultTopLevelBroker(ConfigFactory.empty(), SimpleScopeType.GLOBAL.defaultScopeInstance());
Configuration conf = new Configuration();
conf.set("fs.local.impl", InstrumentedLocalFileSystem.class.getName());
FileSystemKey key = new FileSystemKey(new URI("file:///"), new Configuration());
FileSystemFactory<SimpleScopeType> factory = new FileSystemFactory<>();
FileSystem fs = broker.getSharedResource(factory, key);
verifyInstrumentedOnce(fs);
Assert.assertTrue(DecoratorUtils.resolveUnderlyingObject(fs) instanceof LocalFileSystem);
}
use of org.apache.gobblin.broker.SimpleScopeType in project incubator-gobblin by apache.
the class FileSystemFactoryTest method testCreationWithInstrumentedScheme.
@Test
public void testCreationWithInstrumentedScheme() throws Exception {
SharedResourcesBrokerImpl<SimpleScopeType> broker = SharedResourcesBrokerFactory.<SimpleScopeType>createDefaultTopLevelBroker(ConfigFactory.empty(), SimpleScopeType.GLOBAL.defaultScopeInstance());
FileSystemKey key = new FileSystemKey(new URI("instrumented-file:///"), new Configuration());
FileSystemFactory<SimpleScopeType> factory = new FileSystemFactory<>();
FileSystem fs = broker.getSharedResource(factory, key);
verifyInstrumentedOnce(fs);
Assert.assertTrue(DecoratorUtils.resolveUnderlyingObject(fs) instanceof LocalFileSystem);
}
Aggregations