Search in sources :

Example 1 with SamplerException

use of org.apache.druid.indexing.overlord.sampler.SamplerException in project druid by druid-io.

the class SeekableStreamSamplerSpec method sample.

@Override
public SamplerResponse sample() {
    final InputSource inputSource;
    final InputFormat inputFormat;
    if (dataSchema.getParser() != null) {
        inputSource = new FirehoseFactoryToInputSourceAdaptor(new SeekableStreamSamplerFirehoseFactory(), dataSchema.getParser());
        inputFormat = null;
    } else {
        RecordSupplier<PartitionIdType, SequenceOffsetType, RecordType> recordSupplier;
        try {
            recordSupplier = createRecordSupplier();
        } catch (Exception e) {
            throw new SamplerException(e, "Unable to create RecordSupplier: %s", Throwables.getRootCause(e).getMessage());
        }
        inputSource = new RecordSupplierInputSource<>(ioConfig.getStream(), recordSupplier, ioConfig.isUseEarliestSequenceNumber());
        inputFormat = Preconditions.checkNotNull(ioConfig.getInputFormat(), "[spec.ioConfig.inputFormat] is required");
    }
    return inputSourceSampler.sample(inputSource, inputFormat, dataSchema, samplerConfig);
}
Also used : InputSource(org.apache.druid.data.input.InputSource) SamplerException(org.apache.druid.indexing.overlord.sampler.SamplerException) InputFormat(org.apache.druid.data.input.InputFormat) FirehoseFactoryToInputSourceAdaptor(org.apache.druid.data.input.FirehoseFactoryToInputSourceAdaptor) ParseException(org.apache.druid.java.util.common.parsers.ParseException) SamplerException(org.apache.druid.indexing.overlord.sampler.SamplerException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 FirehoseFactoryToInputSourceAdaptor (org.apache.druid.data.input.FirehoseFactoryToInputSourceAdaptor)1 InputFormat (org.apache.druid.data.input.InputFormat)1 InputSource (org.apache.druid.data.input.InputSource)1 SamplerException (org.apache.druid.indexing.overlord.sampler.SamplerException)1 ParseException (org.apache.druid.java.util.common.parsers.ParseException)1