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