Search in sources :

Example 1 with SourceEventType

use of org.apache.inlong.sort.flink.SourceEvent.SourceEventType in project incubator-inlong by apache.

the class MultiTopicPulsarSourceFunction method processEvent.

private void processEvent(SourceEvent sourceEvent) throws Exception {
    SourceEventType sourceEventType = sourceEvent.getSourceEventType();
    PulsarSourceInfo pulsarSourceInfo = (PulsarSourceInfo) sourceEvent.getSourceInfo();
    Map<String, Object> properties = sourceEvent.getProperties();
    long dataFlowId = sourceEvent.getDataFlowId();
    switch(sourceEventType) {
        case ADDED:
            PulsarSourceFunction<SerializedRecord> pulsarSourceFunction = generateSourceFunction(dataFlowId, properties, pulsarSourceInfo);
            pulsarConsumer.addPulsarSource(dataFlowId, pulsarSourceFunction);
            break;
        case UPDATE:
            PulsarSourceFunction<SerializedRecord> updateSourceFunction = generateSourceFunction(dataFlowId, properties, pulsarSourceInfo);
            pulsarConsumer.updatePulsarSource(dataFlowId, updateSourceFunction);
            break;
        case REMOVED:
            pulsarConsumer.removePulsarSource(dataFlowId);
            break;
        default:
            LOG.error("Unknown source event type {}", sourceEvent.getSourceEventType());
            throw new RuntimeException("Unknown source event type " + sourceEvent.getSourceEventType());
    }
}
Also used : SerializedRecord(org.apache.inlong.sort.flink.SerializedRecord) PulsarSourceInfo(org.apache.inlong.sort.protocol.source.PulsarSourceInfo) SourceEventType(org.apache.inlong.sort.flink.SourceEvent.SourceEventType)

Aggregations

SerializedRecord (org.apache.inlong.sort.flink.SerializedRecord)1 SourceEventType (org.apache.inlong.sort.flink.SourceEvent.SourceEventType)1 PulsarSourceInfo (org.apache.inlong.sort.protocol.source.PulsarSourceInfo)1