Search in sources :

Example 1 with TubeSourceInfo

use of org.apache.inlong.sort.protocol.source.TubeSourceInfo in project incubator-inlong by apache.

the class MultiTenancyInLongMsgMixedDeserializerTest method testIsInLongMsgDataFlow.

@Test
public void testIsInLongMsgDataFlow() {
    final TubeSourceInfo tubeSourceInfo = new TubeSourceInfo("topic", "address", null, new InLongMsgCsvDeserializationInfo("tid", ',', false), new FieldInfo[0]);
    final EmptySinkInfo sinkInfo = new EmptySinkInfo();
    final DataFlowInfo dataFlowInfo = new DataFlowInfo(1L, tubeSourceInfo, sinkInfo);
    assertTrue(MultiTenancyInLongMsgMixedDeserializer.isInLongMsgDataFlow(dataFlowInfo));
    final DataFlowInfo nonInLongMsgDataFlow = new DataFlowInfo(2L, new EmptySourceInfo(), sinkInfo);
    assertFalse(MultiTenancyInLongMsgMixedDeserializer.isInLongMsgDataFlow(nonInLongMsgDataFlow));
}
Also used : EmptySinkInfo(org.apache.inlong.sort.util.TestingUtils.EmptySinkInfo) InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) TubeSourceInfo(org.apache.inlong.sort.protocol.source.TubeSourceInfo) EmptySourceInfo(org.apache.inlong.sort.util.TestingUtils.EmptySourceInfo) DataFlowInfo(org.apache.inlong.sort.protocol.DataFlowInfo) Test(org.junit.Test)

Example 2 with TubeSourceInfo

use of org.apache.inlong.sort.protocol.source.TubeSourceInfo in project incubator-inlong by apache.

the class TubeSubscriptionDescriptionTest method testCopyConstructor.

@Test
public void testCopyConstructor() {
    final TubeSubscriptionDescription description = new TubeSubscriptionDescription(topic, masterAddress, null);
    final TubeSourceInfo tubeSourceInfo = new TubeSourceInfo(topic, masterAddress, null, new InLongMsgCsvDeserializationInfo(tid, ',', true), new FieldInfo[0]);
    description.addDataFlow(dataFlowId, tubeSourceInfo);
    final TubeSubscriptionDescription copied = new TubeSubscriptionDescription(description);
    assertEquals(description, copied);
    copied.removeDataFlow(dataFlowId);
    assertNotEquals(description, copied);
}
Also used : InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) TubeSourceInfo(org.apache.inlong.sort.protocol.source.TubeSourceInfo) Test(org.junit.Test)

Example 3 with TubeSourceInfo

use of org.apache.inlong.sort.protocol.source.TubeSourceInfo 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 4 with TubeSourceInfo

use of org.apache.inlong.sort.protocol.source.TubeSourceInfo in project incubator-inlong by apache.

the class DeserializationInfoTest method testToJson.

@Test
public void testToJson() throws JsonProcessingException {
    DataFlowInfo dataFlowInfo = new DataFlowInfo(1, new TubeSourceInfo("topic" + System.currentTimeMillis(), "ma", "cg", new InLongMsgCsvDeserializationInfo("tid", ','), new FieldInfo[0]), new ClickHouseSinkInfo("url", "dn", "tn", "un", "pw", false, PartitionStrategy.HASH, "pk", new FieldInfo[0], new String[0], 100, 100, 100));
    ObjectMapper objectMapper = new ObjectMapper();
    System.out.println(objectMapper.writeValueAsString(dataFlowInfo));
}
Also used : ClickHouseSinkInfo(org.apache.inlong.sort.protocol.sink.ClickHouseSinkInfo) InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) TubeSourceInfo(org.apache.inlong.sort.protocol.source.TubeSourceInfo) ObjectMapper(org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 5 with TubeSourceInfo

use of org.apache.inlong.sort.protocol.source.TubeSourceInfo in project incubator-inlong by apache.

the class TubeSubscriptionDescriptionTest method testAddAndRemoveDataFlow.

@Test
public void testAddAndRemoveDataFlow() {
    final TubeSubscriptionDescription description = new TubeSubscriptionDescription(topic, masterAddress, null);
    final TubeSourceInfo tubeSourceInfo1 = new TubeSourceInfo(topic, masterAddress, null, new InLongMsgCsvDeserializationInfo(tid, ',', true), new FieldInfo[0]);
    description.addDataFlow(dataFlowId, tubeSourceInfo1);
    final String tid2 = "10002";
    final String consumerGroup = "consumerGroup";
    final TubeSourceInfo tubeSourceInfo2 = new TubeSourceInfo(topic, masterAddress, consumerGroup, new InLongMsgCsvDeserializationInfo(tid2, ',', true), new FieldInfo[0]);
    final long dataFlowId2 = 10086L;
    description.addDataFlow(dataFlowId2, tubeSourceInfo2);
    final List<String> expectedTids = new ArrayList<>();
    expectedTids.add(tid);
    expectedTids.add(tid2);
    Collections.sort(expectedTids);
    final List<String> tids = description.getTids();
    Collections.sort(tids);
    assertEquals(expectedTids, tids);
    description.removeDataFlow(dataFlowId);
    assertEquals(Collections.singletonList(tid2), description.getTids());
    description.removeDataFlow(dataFlowId2);
    try {
        description.getTids();
        fail("Should throw exception when get tids from an empty description");
    } catch (IllegalStateException expected) {
    }
}
Also used : ArrayList(java.util.ArrayList) InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) TubeSourceInfo(org.apache.inlong.sort.protocol.source.TubeSourceInfo) Test(org.junit.Test)

Aggregations

TubeSourceInfo (org.apache.inlong.sort.protocol.source.TubeSourceInfo)7 InLongMsgCsvDeserializationInfo (org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo)5 Test (org.junit.Test)5 DataFlowInfo (org.apache.inlong.sort.protocol.DataFlowInfo)2 InLongMsgDeserializationInfo (org.apache.inlong.sort.protocol.deserialization.InLongMsgDeserializationInfo)2 EmptySinkInfo (org.apache.inlong.sort.util.TestingUtils.EmptySinkInfo)2 Timestamp (java.sql.Timestamp)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ObjectMapper (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper)1 InLongMsg (org.apache.inlong.common.msg.InLongMsg)1 InLongMsgMixedSerializedRecord (org.apache.inlong.sort.flink.InLongMsgMixedSerializedRecord)1 Record (org.apache.inlong.sort.flink.Record)1 LongFormatInfo (org.apache.inlong.sort.formats.common.LongFormatInfo)1 StringFormatInfo (org.apache.inlong.sort.formats.common.StringFormatInfo)1 AbstractInLongMsgMixedFormatDeserializer (org.apache.inlong.sort.formats.inlongmsg.AbstractInLongMsgMixedFormatDeserializer)1 InLongMsgMixedFormatConverter (org.apache.inlong.sort.formats.inlongmsg.InLongMsgMixedFormatConverter)1 FieldInfo (org.apache.inlong.sort.protocol.FieldInfo)1 ClickHouseSinkInfo (org.apache.inlong.sort.protocol.sink.ClickHouseSinkInfo)1