Search in sources :

Example 11 with SimpleScopeType

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;
}
Also used : Joiner(com.google.common.base.Joiner) Config(com.typesafe.config.Config) SharedResourcesBrokerImpl(org.apache.gobblin.broker.SharedResourcesBrokerImpl) SimpleScopeType(org.apache.gobblin.broker.SimpleScopeType)

Example 12 with SimpleScopeType

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();
}
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)

Example 13 with SimpleScopeType

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();
}
Also used : 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)

Example 14 with SimpleScopeType

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);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalFileSystem(org.apache.hadoop.fs.LocalFileSystem) FileSystem(org.apache.hadoop.fs.FileSystem) LocalFileSystem(org.apache.hadoop.fs.LocalFileSystem) SimpleScopeType(org.apache.gobblin.broker.SimpleScopeType) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 15 with SimpleScopeType

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);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalFileSystem(org.apache.hadoop.fs.LocalFileSystem) FileSystem(org.apache.hadoop.fs.FileSystem) LocalFileSystem(org.apache.hadoop.fs.LocalFileSystem) SimpleScopeType(org.apache.gobblin.broker.SimpleScopeType) URI(java.net.URI) Test(org.testng.annotations.Test)

Aggregations

SimpleScopeType (org.apache.gobblin.broker.SimpleScopeType)17 Test (org.testng.annotations.Test)15 SharedLimiterKey (org.apache.gobblin.util.limiter.broker.SharedLimiterKey)6 Config (com.typesafe.config.Config)4 Limiter (org.apache.gobblin.util.limiter.Limiter)4 MultiLimiter (org.apache.gobblin.util.limiter.MultiLimiter)4 NoopLimiter (org.apache.gobblin.util.limiter.NoopLimiter)4 URI (java.net.URI)3 ResourceInstance (org.apache.gobblin.broker.ResourceInstance)3 SharedRestClientKey (org.apache.gobblin.restli.SharedRestClientKey)3 CountBasedLimiter (org.apache.gobblin.util.limiter.CountBasedLimiter)3 Configuration (org.apache.hadoop.conf.Configuration)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 LocalFileSystem (org.apache.hadoop.fs.LocalFileSystem)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Map (java.util.Map)2 SharedResourcesBroker (org.apache.gobblin.broker.iface.SharedResourcesBroker)2 MetricContext (org.apache.gobblin.metrics.MetricContext)2 EmbeddedRestliServer (org.apache.gobblin.restli.EmbeddedRestliServer)2 ThrottlingGuiceServletConfig (org.apache.gobblin.restli.throttling.ThrottlingGuiceServletConfig)2