use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class StreamsBuilderTest method shouldUseSpecifiedNameForJoinOperationBetweenKStreamAndKTable.
@Test
public void shouldUseSpecifiedNameForJoinOperationBetweenKStreamAndKTable() {
final KStream<String, String> streamOne = builder.stream(STREAM_TOPIC);
final KTable<String, String> streamTwo = builder.table("table-topic");
streamOne.join(streamTwo, (value1, value2) -> value1, Joined.as(STREAM_OPERATION_NAME));
builder.build();
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
assertNamesForOperation(topology, "KSTREAM-SOURCE-0000000000", "KSTREAM-SOURCE-0000000002", "KTABLE-SOURCE-0000000003", STREAM_OPERATION_NAME);
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class StreamsBuilderTest method shouldUseSpecifiedNameForFilterOperation.
@Test
public void shouldUseSpecifiedNameForFilterOperation() {
builder.stream(STREAM_TOPIC).filter((k, v) -> true, Named.as(STREAM_OPERATION_NAME));
builder.build();
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
assertNamesForOperation(topology, "KSTREAM-SOURCE-0000000000", STREAM_OPERATION_NAME);
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class StreamsBuilderTest method shouldAllowJoinMaterializedFilteredKTable.
@Test
public void shouldAllowJoinMaterializedFilteredKTable() {
final KTable<Bytes, String> filteredKTable = builder.<Bytes, String>table(TABLE_TOPIC).filter(MockPredicate.allGoodPredicate(), Materialized.as("store"));
builder.<Bytes, String>stream(STREAM_TOPIC).join(filteredKTable, MockValueJoiner.TOSTRING_JOINER);
builder.build();
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
assertThat(topology.stateStores().size(), equalTo(1));
assertThat(topology.processorConnectedStateStores("KSTREAM-JOIN-0000000005"), equalTo(Collections.singleton("store")));
assertThat(topology.processorConnectedStateStores("KTABLE-FILTER-0000000003"), equalTo(Collections.singleton("store")));
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.
the class StreamThreadStateStoreProviderTest method before.
@SuppressWarnings("deprecation")
@Before
public void before() throws IOException {
final TopologyBuilder builder = new TopologyBuilder();
builder.addSource("the-source", topicName);
builder.addProcessor("the-processor", new MockProcessorSupplier(), "the-source");
builder.addStateStore(Stores.create("kv-store").withStringKeys().withStringValues().inMemory().build(), "the-processor");
builder.addStateStore(Stores.create("window-store").withStringKeys().withStringValues().persistent().windowed(10, 10, 2, false).build(), "the-processor");
final Properties properties = new Properties();
final String applicationId = "applicationId";
properties.put(StreamsConfig.APPLICATION_ID_CONFIG, applicationId);
properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
stateDir = TestUtils.tempDirectory();
properties.put(StreamsConfig.STATE_DIR_CONFIG, stateDir.getPath());
final StreamsConfig streamsConfig = new StreamsConfig(properties);
final MockClientSupplier clientSupplier = new MockClientSupplier();
configureRestoreConsumer(clientSupplier, "applicationId-kv-store-changelog");
configureRestoreConsumer(clientSupplier, "applicationId-window-store-changelog");
builder.setApplicationId(applicationId);
final ProcessorTopology topology = builder.build(null);
tasks = new HashMap<>();
stateDirectory = new StateDirectory(streamsConfig, new MockTime());
taskOne = createStreamsTask(applicationId, streamsConfig, clientSupplier, topology, new TaskId(0, 0));
taskOne.initializeStateStores();
tasks.put(new TaskId(0, 0), taskOne);
taskTwo = createStreamsTask(applicationId, streamsConfig, clientSupplier, topology, new TaskId(0, 1));
taskTwo.initializeStateStores();
tasks.put(new TaskId(0, 1), taskTwo);
threadMock = EasyMock.createNiceMock(StreamThread.class);
provider = new StreamThreadStateStoreProvider(threadMock);
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.
the class StreamsBuilderTest method shouldAllowJoinMaterializedFilteredKTable.
@Test
public void shouldAllowJoinMaterializedFilteredKTable() {
final KTable<Bytes, String> filteredKTable = builder.<Bytes, String>table("table-topic").filter(MockPredicate.<Bytes, String>allGoodPredicate(), Materialized.<Bytes, String, KeyValueStore<Bytes, byte[]>>as("store"));
builder.<Bytes, String>stream("stream-topic").join(filteredKTable, MockValueJoiner.TOSTRING_JOINER);
driver.setUp(builder, TestUtils.tempDirectory());
ProcessorTopology topology = builder.internalTopologyBuilder.build();
assertThat(topology.stateStores().size(), equalTo(2));
assertThat(topology.processorConnectedStateStores("KSTREAM-JOIN-0000000005"), equalTo(Collections.singleton("store")));
assertThat(topology.processorConnectedStateStores("KTABLE-FILTER-0000000003"), equalTo(Collections.singleton("store")));
}
Aggregations