Search in sources :

Example 1 with InLongMsgDeserializationInfo

use of org.apache.inlong.sort.protocol.deserialization.InLongMsgDeserializationInfo in project incubator-inlong by apache.

the class CommonUtils method getInLongGroupIdAndStreamId.

public static Pair<String, String> getInLongGroupIdAndStreamId(DataFlowInfo dataFlowInfo) {
    String groupId = "";
    String streamId = "";
    if (dataFlowInfo != null) {
        // Get group id
        Map<String, Object> properties = dataFlowInfo.getProperties();
        if (properties != null) {
            groupId = properties.getOrDefault(Constants.INLONG_GROUP_ID, "").toString();
        }
        // Get stream id
        final DeserializationInfo deserializationInfo = dataFlowInfo.getSourceInfo().getDeserializationInfo();
        if (deserializationInfo instanceof InLongMsgDeserializationInfo) {
            streamId = ((InLongMsgDeserializationInfo) deserializationInfo).getTid();
        }
    }
    return Pair.of(groupId, streamId);
}
Also used : InLongMsgDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgDeserializationInfo) DeserializationInfo(org.apache.inlong.sort.protocol.deserialization.DeserializationInfo) InLongMsgDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgDeserializationInfo)

Example 2 with InLongMsgDeserializationInfo

use of org.apache.inlong.sort.protocol.deserialization.InLongMsgDeserializationInfo in project incubator-inlong by apache.

the class MultiTenancyInLongMsgMixedDeserializer method updateDataFlow.

@Override
public void updateDataFlow(DataFlowInfo dataFlowInfo) {
    if (!isInLongMsgDataFlow(dataFlowInfo)) {
        return;
    }
    final InLongMsgDeserializationInfo inLongMsgDeserializationInfo = (InLongMsgDeserializationInfo) dataFlowInfo.getSourceInfo().getDeserializationInfo();
    Pair<AbstractInLongMsgMixedFormatDeserializer, InLongMsgMixedFormatConverter> allDeserializer = generateDeserializer(dataFlowInfo.getSourceInfo().getFields(), inLongMsgDeserializationInfo);
    final AbstractInLongMsgMixedFormatDeserializer preDeserializer = allDeserializer.getLeft();
    final InLongMsgMixedFormatConverter deserializer = allDeserializer.getRight();
    final String topic;
    if (dataFlowInfo.getSourceInfo() instanceof TubeSourceInfo) {
        topic = ((TubeSourceInfo) dataFlowInfo.getSourceInfo()).getTopic();
    } else if (dataFlowInfo.getSourceInfo() instanceof PulsarSourceInfo) {
        topic = ((PulsarSourceInfo) dataFlowInfo.getSourceInfo()).getTopic();
    } else {
        throw new UnsupportedOperationException("Unknown source type " + dataFlowInfo.getSourceInfo());
    }
    final InLongMsgMixedDeserializer mixedDeserializer = mixedDeserializerMap.computeIfAbsent(topic, key -> new InLongMsgMixedDeserializer());
    mixedDeserializer.updateDataFlow(dataFlowInfo.getId(), inLongMsgDeserializationInfo.getTid(), preDeserializer, deserializer);
}
Also used : InLongMsgMixedFormatConverter(org.apache.inlong.sort.formats.inlongmsg.InLongMsgMixedFormatConverter) InLongMsgDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgDeserializationInfo) PulsarSourceInfo(org.apache.inlong.sort.protocol.source.PulsarSourceInfo) AbstractInLongMsgMixedFormatDeserializer(org.apache.inlong.sort.formats.inlongmsg.AbstractInLongMsgMixedFormatDeserializer) TubeSourceInfo(org.apache.inlong.sort.protocol.source.TubeSourceInfo)

Example 3 with InLongMsgDeserializationInfo

use of org.apache.inlong.sort.protocol.deserialization.InLongMsgDeserializationInfo in project incubator-inlong by apache.

the class MultiTenancyInLongMsgMixedDeserializer method removeDataFlow.

@Override
public void removeDataFlow(DataFlowInfo dataFlowInfo) {
    if (!isInLongMsgDataFlow(dataFlowInfo)) {
        return;
    }
    final TubeSourceInfo tubeSourceInfo = (TubeSourceInfo) dataFlowInfo.getSourceInfo();
    final InLongMsgDeserializationInfo inLongMsgDeserializationInfo = (InLongMsgDeserializationInfo) tubeSourceInfo.getDeserializationInfo();
    final InLongMsgMixedDeserializer mixedDeserializer = mixedDeserializerMap.get(tubeSourceInfo.getTopic());
    if (mixedDeserializer != null) {
        mixedDeserializer.removeDataFlow(dataFlowInfo.getId(), inLongMsgDeserializationInfo.getTid());
        if (mixedDeserializer.isEmpty()) {
            mixedDeserializerMap.remove(tubeSourceInfo.getTopic());
        }
    }
}
Also used : InLongMsgDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgDeserializationInfo) TubeSourceInfo(org.apache.inlong.sort.protocol.source.TubeSourceInfo)

Aggregations

InLongMsgDeserializationInfo (org.apache.inlong.sort.protocol.deserialization.InLongMsgDeserializationInfo)3 TubeSourceInfo (org.apache.inlong.sort.protocol.source.TubeSourceInfo)2 AbstractInLongMsgMixedFormatDeserializer (org.apache.inlong.sort.formats.inlongmsg.AbstractInLongMsgMixedFormatDeserializer)1 InLongMsgMixedFormatConverter (org.apache.inlong.sort.formats.inlongmsg.InLongMsgMixedFormatConverter)1 DeserializationInfo (org.apache.inlong.sort.protocol.deserialization.DeserializationInfo)1 PulsarSourceInfo (org.apache.inlong.sort.protocol.source.PulsarSourceInfo)1