/** * 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); } }
@Test public void testOtherMethods() { Assert.assertTrue(this.taskContext.getSource() instanceof TestSource); Assert.assertEquals(this.taskContext.getStatusReportingInterval(), ConfigurationKeys.DEFAULT_TASK_STATUS_REPORT_INTERVAL_IN_MS); Assert.assertEquals(this.taskContext.getDestinationType(1, 0), Destination.DestinationType.HDFS); Assert.assertEquals(this.taskContext.getWriterOutputFormat(1, 0), WriterOutputFormat.AVRO); Assert.assertTrue(this.taskContext.getConverters().isEmpty()); } }
/** * 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); } }