Search in sources :

Example 1 with NonRefillableLimiter

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

the class TaskContext method getExtractor.

/**
 * Get a {@link Extractor} instance.
 *
 * @return a {@link Extractor} instance
 */
public Extractor getExtractor() {
    try {
        this.rawSourceExtractor = getSource().getExtractor(this.taskState);
        boolean throttlingEnabled = this.taskState.getPropAsBoolean(ConfigurationKeys.EXTRACT_LIMIT_ENABLED_KEY, ConfigurationKeys.DEFAULT_EXTRACT_LIMIT_ENABLED);
        if (throttlingEnabled) {
            Limiter limiter = DefaultLimiterFactory.newLimiter(this.taskState);
            if (!(limiter instanceof NonRefillableLimiter)) {
                throw new IllegalArgumentException("The Limiter used with an Extractor should be an instance of " + NonRefillableLimiter.class.getSimpleName());
            }
            return new LimitingExtractorDecorator<>(this.rawSourceExtractor, limiter, this.taskState);
        }
        return this.rawSourceExtractor;
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
Also used : NonRefillableLimiter(org.apache.gobblin.util.limiter.NonRefillableLimiter) IOException(java.io.IOException) NonRefillableLimiter(org.apache.gobblin.util.limiter.NonRefillableLimiter) Limiter(org.apache.gobblin.util.limiter.Limiter)

Aggregations

IOException (java.io.IOException)1 Limiter (org.apache.gobblin.util.limiter.Limiter)1 NonRefillableLimiter (org.apache.gobblin.util.limiter.NonRefillableLimiter)1