当前位置: 首页>>代码示例>>Java>>正文


Java KStreamBuilder.addProcessor方法代码示例

本文整理汇总了Java中org.apache.kafka.streams.kstream.KStreamBuilder.addProcessor方法的典型用法代码示例。如果您正苦于以下问题:Java KStreamBuilder.addProcessor方法的具体用法?Java KStreamBuilder.addProcessor怎么用?Java KStreamBuilder.addProcessor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.kafka.streams.kstream.KStreamBuilder的用法示例。


在下文中一共展示了KStreamBuilder.addProcessor方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: merge

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
public static <K, V> KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams) {
    if (streams == null || streams.length == 0) {
        throw new IllegalArgumentException("Parameter <streams> must not be null or has length zero");
    }

    String name = topology.newName(MERGE_NAME);
    String[] parentNames = new String[streams.length];
    Set<String> allSourceNodes = new HashSet<>();
    boolean requireRepartitioning = false;

    for (int i = 0; i < streams.length; i++) {
        KStreamImpl stream = (KStreamImpl) streams[i];

        parentNames[i] = stream.name;
        requireRepartitioning |= stream.repartitionRequired;
        allSourceNodes.addAll(stream.sourceNodes);
    }

    topology.addProcessor(name, new KStreamPassThrough<>(), parentNames);

    return new KStreamImpl<>(topology, name, allSourceNodes, requireRepartitioning);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:23,代码来源:KStreamImpl.java

示例2: testNotSendingOldValues

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
@Test
public void testNotSendingOldValues() throws Exception {
    final KStreamBuilder builder = new KStreamBuilder();

    final int[] expectedKeys = new int[]{0, 1, 2, 3};

    final KTable<Integer, String> table1;
    final KTable<Integer, String> table2;
    final KTable<Integer, String> joined;
    final MockProcessorSupplier<Integer, String> proc;

    table1 = builder.table(intSerde, stringSerde, topic1, storeName1);
    table2 = builder.table(intSerde, stringSerde, topic2, storeName2);
    joined = table1.join(table2, MockValueJoiner.TOSTRING_JOINER);
    proc = new MockProcessorSupplier<>();
    builder.addProcessor("proc", proc, ((KTableImpl<?, ?, ?>) joined).name);

    doTestSendingOldValues(builder, expectedKeys, table1, table2, proc, joined, false);

}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:21,代码来源:KTableKTableJoinTest.java

示例3: testQueryableNotSendingOldValues

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
@Test
public void testQueryableNotSendingOldValues() throws Exception {
    final KStreamBuilder builder = new KStreamBuilder();

    final int[] expectedKeys = new int[]{0, 1, 2, 3};

    final KTable<Integer, String> table1;
    final KTable<Integer, String> table2;
    final KTable<Integer, String> joined;
    final MockProcessorSupplier<Integer, String> proc;

    table1 = builder.table(intSerde, stringSerde, topic1, storeName1);
    table2 = builder.table(intSerde, stringSerde, topic2, storeName2);
    joined = table1.join(table2, MockValueJoiner.TOSTRING_JOINER, Serdes.String(), "anyQueryableName");
    proc = new MockProcessorSupplier<>();
    builder.addProcessor("proc", proc, ((KTableImpl<?, ?, ?>) joined).name);

    doTestSendingOldValues(builder, expectedKeys, table1, table2, proc, joined, false);

}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:21,代码来源:KTableKTableJoinTest.java

示例4: testSendingOldValues

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
@Test
public void testSendingOldValues() throws Exception {
    final KStreamBuilder builder = new KStreamBuilder();

    final int[] expectedKeys = new int[]{0, 1, 2, 3};

    final KTable<Integer, String> table1;
    final KTable<Integer, String> table2;
    final KTable<Integer, String> joined;
    final MockProcessorSupplier<Integer, String> proc;

    table1 = builder.table(intSerde, stringSerde, topic1, storeName1);
    table2 = builder.table(intSerde, stringSerde, topic2, storeName2);
    joined = table1.join(table2, MockValueJoiner.TOSTRING_JOINER);

    proc = new MockProcessorSupplier<>();
    builder.addProcessor("proc", proc, ((KTableImpl<?, ?, ?>) joined).name);

    doTestSendingOldValues(builder, expectedKeys, table1, table2, proc, joined, true);

}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:22,代码来源:KTableKTableJoinTest.java

示例5: doTestSkipNullOnMaterialization

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
private void doTestSkipNullOnMaterialization(final KStreamBuilder builder,
                                             final KTableImpl<String, String, String> table1,
                                             final KTableImpl<String, String, String> table2,
                                             final String topic1) throws IOException {
    MockProcessorSupplier<String, String> proc1 = new MockProcessorSupplier<>();
    MockProcessorSupplier<String, String> proc2 = new MockProcessorSupplier<>();

    builder.addProcessor("proc1", proc1, table1.name);
    builder.addProcessor("proc2", proc2, table2.name);

    driver = new KStreamTestDriver(builder, stateDir, stringSerde, stringSerde);

    driver.process(topic1, "A", "reject");
    driver.process(topic1, "B", "reject");
    driver.process(topic1, "C", "reject");
    driver.flushState();
    proc1.checkAndClearProcessResult("A:(reject<-null)", "B:(reject<-null)", "C:(reject<-null)");
    proc2.checkEmptyAndClearProcessResult();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:20,代码来源:KTableFilterTest.java

示例6: doTestNotSendingOldValue

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
private void doTestNotSendingOldValue(final KStreamBuilder builder,
                                      final KTableImpl<String, Integer, Integer> table1,
                                      final KTableImpl<String, Integer, Integer> table2,
                                      final String topic1) throws IOException {
    MockProcessorSupplier<String, Integer> proc1 = new MockProcessorSupplier<>();
    MockProcessorSupplier<String, Integer> proc2 = new MockProcessorSupplier<>();

    builder.addProcessor("proc1", proc1, table1.name);
    builder.addProcessor("proc2", proc2, table2.name);

    driver = new KStreamTestDriver(builder, stateDir, Serdes.String(), Serdes.Integer());

    driver.process(topic1, "A", 1);
    driver.process(topic1, "B", 1);
    driver.process(topic1, "C", 1);
    driver.flushState();

    proc1.checkAndClearProcessResult("A:(1<-null)", "B:(1<-null)", "C:(1<-null)");
    proc2.checkAndClearProcessResult("A:(null<-null)", "B:(null<-null)", "C:(null<-null)");

    driver.process(topic1, "A", 2);
    driver.process(topic1, "B", 2);
    driver.flushState();
    proc1.checkAndClearProcessResult("A:(2<-null)", "B:(2<-null)");
    proc2.checkAndClearProcessResult("A:(2<-null)", "B:(2<-null)");

    driver.process(topic1, "A", 3);
    driver.flushState();
    proc1.checkAndClearProcessResult("A:(3<-null)");
    proc2.checkAndClearProcessResult("A:(null<-null)");

    driver.process(topic1, "A", null);
    driver.process(topic1, "B", null);
    driver.flushState();
    proc1.checkAndClearProcessResult("A:(null<-null)", "B:(null<-null)");
    proc2.checkAndClearProcessResult("A:(null<-null)", "B:(null<-null)");
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:38,代码来源:KTableFilterTest.java

示例7: doTestSendingOldValue

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
private void doTestSendingOldValue(final KStreamBuilder builder,
                                   final KTableImpl<String, Integer, Integer> table1,
                                   final KTableImpl<String, Integer, Integer> table2,
                                   final String topic1) throws IOException {
    table2.enableSendingOldValues();

    MockProcessorSupplier<String, Integer> proc1 = new MockProcessorSupplier<>();
    MockProcessorSupplier<String, Integer> proc2 = new MockProcessorSupplier<>();

    builder.addProcessor("proc1", proc1, table1.name);
    builder.addProcessor("proc2", proc2, table2.name);

    driver = new KStreamTestDriver(builder, stateDir, Serdes.String(), Serdes.Integer());

    driver.process(topic1, "A", 1);
    driver.process(topic1, "B", 1);
    driver.process(topic1, "C", 1);
    driver.flushState();

    proc1.checkAndClearProcessResult("A:(1<-null)", "B:(1<-null)", "C:(1<-null)");
    proc2.checkEmptyAndClearProcessResult();

    driver.process(topic1, "A", 2);
    driver.process(topic1, "B", 2);
    driver.flushState();
    proc1.checkAndClearProcessResult("A:(2<-1)", "B:(2<-1)");
    proc2.checkAndClearProcessResult("A:(2<-null)", "B:(2<-null)");

    driver.process(topic1, "A", 3);
    driver.flushState();
    proc1.checkAndClearProcessResult("A:(3<-2)");
    proc2.checkAndClearProcessResult("A:(null<-2)");

    driver.process(topic1, "A", null);
    driver.process(topic1, "B", null);
    driver.flushState();
    proc1.checkAndClearProcessResult("A:(null<-3)", "B:(null<-2)");
    proc2.checkAndClearProcessResult("B:(null<-2)");
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:40,代码来源:KTableFilterTest.java

示例8: testNotSendingOldValue

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
@Test
public void testNotSendingOldValue() throws IOException {
    KStreamBuilder builder = new KStreamBuilder();

    String topic1 = "topic1";

    KTableImpl<String, String, String> table1 =
            (KTableImpl<String, String, String>) builder.table(stringSerde, stringSerde, topic1, "anyStoreName");
    KTableImpl<String, String, Integer> table2 = (KTableImpl<String, String, Integer>) table1.mapValues(
            new ValueMapper<String, Integer>() {
                @Override
                public Integer apply(String value) {
                    return new Integer(value);
                }
            });

    MockProcessorSupplier<String, Integer> proc = new MockProcessorSupplier<>();

    builder.addProcessor("proc", proc, table2.name);

    driver = new KStreamTestDriver(builder, stateDir, null, null);
    assertFalse(table1.sendingOldValueEnabled());
    assertFalse(table2.sendingOldValueEnabled());

    driver.process(topic1, "A", "01");
    driver.process(topic1, "B", "01");
    driver.process(topic1, "C", "01");
    driver.flushState();

    proc.checkAndClearProcessResult("A:(1<-null)", "B:(1<-null)", "C:(1<-null)");

    driver.process(topic1, "A", "02");
    driver.process(topic1, "B", "02");
    driver.flushState();

    proc.checkAndClearProcessResult("A:(2<-null)", "B:(2<-null)");

    driver.process(topic1, "A", "03");
    driver.flushState();

    proc.checkAndClearProcessResult("A:(3<-null)");

    driver.process(topic1, "A", null);
    driver.flushState();

    proc.checkAndClearProcessResult("A:(null<-null)");
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:48,代码来源:KTableMapValuesTest.java

示例9: testSendingOldValue

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
@Test
public void testSendingOldValue() throws IOException {
    KStreamBuilder builder = new KStreamBuilder();

    String topic1 = "topic1";

    KTableImpl<String, String, String> table1 =
            (KTableImpl<String, String, String>) builder.table(stringSerde, stringSerde, topic1, "anyStoreName");
    KTableImpl<String, String, Integer> table2 = (KTableImpl<String, String, Integer>) table1.mapValues(
            new ValueMapper<String, Integer>() {
                @Override
                public Integer apply(String value) {
                    return new Integer(value);
                }
            });

    table2.enableSendingOldValues();

    MockProcessorSupplier<String, Integer> proc = new MockProcessorSupplier<>();

    builder.addProcessor("proc", proc, table2.name);

    driver = new KStreamTestDriver(builder, stateDir, null, null);
    assertTrue(table1.sendingOldValueEnabled());
    assertTrue(table2.sendingOldValueEnabled());

    driver.process(topic1, "A", "01");
    driver.process(topic1, "B", "01");
    driver.process(topic1, "C", "01");
    driver.flushState();

    proc.checkAndClearProcessResult("A:(1<-null)", "B:(1<-null)", "C:(1<-null)");

    driver.process(topic1, "A", "02");
    driver.process(topic1, "B", "02");
    driver.flushState();

    proc.checkAndClearProcessResult("A:(2<-1)", "B:(2<-1)");

    driver.process(topic1, "A", "03");
    driver.flushState();

    proc.checkAndClearProcessResult("A:(3<-2)");

    driver.process(topic1, "A", null);
    driver.flushState();

    proc.checkAndClearProcessResult("A:(null<-3)");
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:50,代码来源:KTableMapValuesTest.java

示例10: testNotSendingOldValue

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
@Test
public void testNotSendingOldValue() throws IOException {
    final KStreamBuilder builder = new KStreamBuilder();

    String topic1 = "topic1";

    KTableImpl<String, String, String> table1 = (KTableImpl<String, String, String>) builder.table(stringSerde, stringSerde, topic1, "anyStoreName");

    MockProcessorSupplier<String, Integer> proc1 = new MockProcessorSupplier<>();

    builder.addProcessor("proc1", proc1, table1.name);

    driver = new KStreamTestDriver(builder, stateDir, null, null);
    driver.process(topic1, "A", "01");
    driver.process(topic1, "B", "01");
    driver.process(topic1, "C", "01");
    driver.flushState();

    proc1.checkAndClearProcessResult("A:(01<-null)", "B:(01<-null)", "C:(01<-null)");

    driver.process(topic1, "A", "02");
    driver.process(topic1, "B", "02");
    driver.flushState();

    proc1.checkAndClearProcessResult("A:(02<-null)", "B:(02<-null)");

    driver.process(topic1, "A", "03");
    driver.flushState();

    proc1.checkAndClearProcessResult("A:(03<-null)");

    driver.process(topic1, "A", null);
    driver.process(topic1, "B", null);
    driver.flushState();

    proc1.checkAndClearProcessResult("A:(null<-null)", "B:(null<-null)");
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:38,代码来源:KTableSourceTest.java

示例11: testSendingOldValue

import org.apache.kafka.streams.kstream.KStreamBuilder; //导入方法依赖的package包/类
@Test
public void testSendingOldValue() throws IOException {
    final KStreamBuilder builder = new KStreamBuilder();

    String topic1 = "topic1";

    KTableImpl<String, String, String> table1 = (KTableImpl<String, String, String>) builder.table(stringSerde, stringSerde, topic1, "anyStoreName");

    table1.enableSendingOldValues();

    assertTrue(table1.sendingOldValueEnabled());

    MockProcessorSupplier<String, Integer> proc1 = new MockProcessorSupplier<>();

    builder.addProcessor("proc1", proc1, table1.name);

    driver = new KStreamTestDriver(builder, stateDir, null, null);

    driver.process(topic1, "A", "01");
    driver.process(topic1, "B", "01");
    driver.process(topic1, "C", "01");
    driver.flushState();

    proc1.checkAndClearProcessResult("A:(01<-null)", "B:(01<-null)", "C:(01<-null)");

    driver.process(topic1, "A", "02");
    driver.process(topic1, "B", "02");
    driver.flushState();

    proc1.checkAndClearProcessResult("A:(02<-01)", "B:(02<-01)");

    driver.process(topic1, "A", "03");
    driver.flushState();

    proc1.checkAndClearProcessResult("A:(03<-02)");

    driver.process(topic1, "A", null);
    driver.process(topic1, "B", null);
    driver.flushState();

    proc1.checkAndClearProcessResult("A:(null<-03)", "B:(null<-02)");
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:43,代码来源:KTableSourceTest.java


注:本文中的org.apache.kafka.streams.kstream.KStreamBuilder.addProcessor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。