Search in sources :

Example 1 with FirehoseFactoryToInputSourceAdaptor

use of org.apache.druid.data.input.FirehoseFactoryToInputSourceAdaptor in project druid by druid-io.

the class InputSourceSplitParallelIndexTaskRunner method newTaskSpec.

final SubTaskSpec<T> newTaskSpec(InputSplit split) {
    final FirehoseFactory firehoseFactory;
    final InputSource inputSource;
    if (baseInputSource instanceof FirehoseFactoryToInputSourceAdaptor) {
        firehoseFactory = ((FirehoseFactoryToInputSourceAdaptor) baseInputSource).getFirehoseFactory().withSplit(split);
        inputSource = null;
    } else {
        firehoseFactory = null;
        inputSource = baseInputSource.withSplit(split);
    }
    final ParallelIndexIngestionSpec subTaskIngestionSpec = new ParallelIndexIngestionSpec(ingestionSchema.getDataSchema(), new ParallelIndexIOConfig(firehoseFactory, inputSource, ingestionSchema.getIOConfig().getInputFormat(), ingestionSchema.getIOConfig().isAppendToExisting(), ingestionSchema.getIOConfig().isDropExisting()), ingestionSchema.getTuningConfig());
    return createSubTaskSpec(getBaseSubtaskSpecName() + "_" + getAndIncrementNextSpecId(), getGroupId(), getTaskId(), getContext(), split, subTaskIngestionSpec);
}
Also used : InputSource(org.apache.druid.data.input.InputSource) SplittableInputSource(org.apache.druid.data.input.impl.SplittableInputSource) FirehoseFactory(org.apache.druid.data.input.FirehoseFactory) FirehoseFactoryToInputSourceAdaptor(org.apache.druid.data.input.FirehoseFactoryToInputSourceAdaptor)

Example 2 with FirehoseFactoryToInputSourceAdaptor

use of org.apache.druid.data.input.FirehoseFactoryToInputSourceAdaptor in project druid by druid-io.

the class SinglePhaseParallelIndexTaskRunner method newTaskSpec.

@VisibleForTesting
SubTaskSpec<SinglePhaseSubTask> newTaskSpec(InputSplit split) {
    final FirehoseFactory firehoseFactory;
    final InputSource inputSource;
    if (baseInputSource instanceof FirehoseFactoryToInputSourceAdaptor) {
        firehoseFactory = ((FirehoseFactoryToInputSourceAdaptor) baseInputSource).getFirehoseFactory().withSplit(split);
        inputSource = null;
    } else {
        firehoseFactory = null;
        inputSource = baseInputSource.withSplit(split);
    }
    final Map<String, Object> subtaskContext = new HashMap<>(getContext());
    return new SinglePhaseSubTaskSpec(getBaseSubtaskSpecName() + "_" + getAndIncrementNextSpecId(), getGroupId(), getTaskId(), new ParallelIndexIngestionSpec(ingestionSchema.getDataSchema(), new ParallelIndexIOConfig(firehoseFactory, inputSource, ingestionSchema.getIOConfig().getInputFormat(), ingestionSchema.getIOConfig().isAppendToExisting(), ingestionSchema.getIOConfig().isDropExisting()), ingestionSchema.getTuningConfig()), subtaskContext, split);
}
Also used : InputSource(org.apache.druid.data.input.InputSource) SplittableInputSource(org.apache.druid.data.input.impl.SplittableInputSource) FirehoseFactory(org.apache.druid.data.input.FirehoseFactory) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MutableObject(org.apache.commons.lang3.mutable.MutableObject) FirehoseFactoryToInputSourceAdaptor(org.apache.druid.data.input.FirehoseFactoryToInputSourceAdaptor) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with FirehoseFactoryToInputSourceAdaptor

use of org.apache.druid.data.input.FirehoseFactoryToInputSourceAdaptor 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

FirehoseFactoryToInputSourceAdaptor (org.apache.druid.data.input.FirehoseFactoryToInputSourceAdaptor)3 InputSource (org.apache.druid.data.input.InputSource)3 FirehoseFactory (org.apache.druid.data.input.FirehoseFactory)2 SplittableInputSource (org.apache.druid.data.input.impl.SplittableInputSource)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 MutableObject (org.apache.commons.lang3.mutable.MutableObject)1 InputFormat (org.apache.druid.data.input.InputFormat)1 SamplerException (org.apache.druid.indexing.overlord.sampler.SamplerException)1 ParseException (org.apache.druid.java.util.common.parsers.ParseException)1