Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,11 @@ private static Metrics createMetrics(final StreamsConfig config, final Time time
* @return name of the added stream thread or empty if a new stream thread could not be added
*/
public Optional<String> addStreamThread() {
if (topologyMetadata.hasNoLocalTopology()) {
log.warn("Cannot add a stream thread to a topology with no local processing tasks");
return Optional.empty();
}

if (isRunningOrRebalancing()) {
final StreamThread streamThread;
synchronized (changeThreadCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,22 @@ public void shouldAddThreadWhenRunning() throws Exception {
}
}

@Test
public void shouldNotAddThreadToGlobalOnlyTopology() {
prepareStreams();
final StreamsBuilder builder = new StreamsBuilder();
builder.globalTable("global-topic");
props.put(StreamsConfig.NUM_STREAM_THREADS_CONFIG, 1);

try (final KafkaStreams streams = new KafkaStreams(builder.build(), props, supplier, time)) {
streams.start();

assertThat(streams.threads.size(), equalTo(0));
assertThat(streams.addStreamThread(), equalTo(Optional.empty()));
assertThat(streams.threads.size(), equalTo(0));
}
}

@Test
public void shouldNotAddThreadWhenCreated() {
prepareStreams();
Expand Down