Search in sources :

Example 1 with RateBasedLimiter

use of org.apache.gobblin.util.limiter.RateBasedLimiter in project incubator-gobblin by apache.

the class MRStressTest method createLimiter.

static Limiter createLimiter(Configuration configuration, SharedResourcesBroker<SimpleScopeType> broker) {
    try {
        Limiter limiter = new NoopLimiter();
        long localQps = configuration.getLong(LOCALLY_ENFORCED_QPS, 0);
        if (localQps > 0) {
            log.info("Setting up local qps " + localQps);
            limiter = new MultiLimiter(limiter, new RateBasedLimiter(localQps));
        }
        if (configuration.getBoolean(USE_THROTTLING_SERVER, false)) {
            log.info("Setting up remote throttling.");
            String resourceId = configuration.get(RESOURCE_ID);
            Limiter globalLimiter = broker.getSharedResource(new RestliLimiterFactory<SimpleScopeType>(), new SharedLimiterKey(resourceId));
            limiter = new MultiLimiter(limiter, globalLimiter);
        }
        return limiter;
    } catch (NotConfiguredException nce) {
        throw new RuntimeException(nce);
    }
}
Also used : NotConfiguredException(org.apache.gobblin.broker.iface.NotConfiguredException) NoopLimiter(org.apache.gobblin.util.limiter.NoopLimiter) RateBasedLimiter(org.apache.gobblin.util.limiter.RateBasedLimiter) MultiLimiter(org.apache.gobblin.util.limiter.MultiLimiter) SimpleScopeType(org.apache.gobblin.broker.SimpleScopeType) SharedLimiterKey(org.apache.gobblin.util.limiter.broker.SharedLimiterKey) Limiter(org.apache.gobblin.util.limiter.Limiter) MultiLimiter(org.apache.gobblin.util.limiter.MultiLimiter) RateBasedLimiter(org.apache.gobblin.util.limiter.RateBasedLimiter) NoopLimiter(org.apache.gobblin.util.limiter.NoopLimiter)

Example 2 with RateBasedLimiter

use of org.apache.gobblin.util.limiter.RateBasedLimiter in project incubator-gobblin by apache.

the class RateControlledFileSystem method getRateLimiter.

protected Limiter getRateLimiter() {
    try {
        String key = getUri().toString();
        RateBasedLimiter limiter = FS_URI_TO_RATE_LIMITER_CACHE.get(key, this.callableLimiter);
        if (limiter.getRateLimitPerSecond() < this.limitPerSecond) {
            try {
                limiter = this.callableLimiter.call();
                FS_URI_TO_RATE_LIMITER_CACHE.put(key, limiter);
            } catch (Exception exc) {
                throw new ExecutionException(exc);
            }
        }
        return limiter;
    } catch (ExecutionException ee) {
        throw new RuntimeException(ee);
    }
}
Also used : RateBasedLimiter(org.apache.gobblin.util.limiter.RateBasedLimiter) ExecutionException(java.util.concurrent.ExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with RateBasedLimiter

use of org.apache.gobblin.util.limiter.RateBasedLimiter in project incubator-gobblin by apache.

the class RatedControlledFileSystemTest method setUp.

@BeforeClass
public void setUp() throws IOException, ExecutionException {
    Limiter limiter = new RateBasedLimiter(20);
    this.rateControlledFs = new TestRateControlledFileSystem(FileSystem.getLocal(new Configuration()), 20, limiter);
    this.rateControlledFs.startRateControl();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) RateBasedLimiter(org.apache.gobblin.util.limiter.RateBasedLimiter) RateBasedLimiter(org.apache.gobblin.util.limiter.RateBasedLimiter) Limiter(org.apache.gobblin.util.limiter.Limiter) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with RateBasedLimiter

use of org.apache.gobblin.util.limiter.RateBasedLimiter in project incubator-gobblin by apache.

the class RateBasedLimiterTest method setUp.

@BeforeClass
public void setUp() {
    this.limiter = new RateBasedLimiter(20, TimeUnit.SECONDS);
    this.limiter.start();
}
Also used : RateBasedLimiter(org.apache.gobblin.util.limiter.RateBasedLimiter) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

RateBasedLimiter (org.apache.gobblin.util.limiter.RateBasedLimiter)4 Limiter (org.apache.gobblin.util.limiter.Limiter)2 BeforeClass (org.testng.annotations.BeforeClass)2 ExecutionException (java.util.concurrent.ExecutionException)1 SimpleScopeType (org.apache.gobblin.broker.SimpleScopeType)1 NotConfiguredException (org.apache.gobblin.broker.iface.NotConfiguredException)1 MultiLimiter (org.apache.gobblin.util.limiter.MultiLimiter)1 NoopLimiter (org.apache.gobblin.util.limiter.NoopLimiter)1 SharedLimiterKey (org.apache.gobblin.util.limiter.broker.SharedLimiterKey)1 Configuration (org.apache.hadoop.conf.Configuration)1