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);
}
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);
}
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());
}
}
}
Aggregations