Skip to content
Merged
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 @@ -582,6 +582,7 @@ public class StreamsConfig extends AbstractConfig {
.define(COMMIT_INTERVAL_MS_CONFIG,
Type.LONG,
DEFAULT_COMMIT_INTERVAL_MS,
atLeast(0),
Importance.LOW,
COMMIT_INTERVAL_MS_DOC)
.define(CONNECTIONS_MAX_IDLE_MS_CONFIG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void pollAndUpdate() {
stateMaintainer.update(record);
}
final long now = time.milliseconds();
if (flushInterval >= 0 && now >= lastFlush + flushInterval) {
if (now >= lastFlush + flushInterval) {
stateMaintainer.flushState();
lastFlush = now;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ private boolean maybePunctuate() {
boolean maybeCommit() {
int committed = 0;

if (commitTimeMs >= 0 && now - lastCommitMs > commitTimeMs) {
if (now - lastCommitMs > commitTimeMs) {
if (log.isTraceEnabled()) {
log.trace("Committing all active tasks {} and standby tasks {} since {}ms has elapsed (commit interval is {}ms)",
taskManager.activeTaskIds(), taskManager.standbyTaskIds(), now - lastCommitMs, commitTimeMs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,18 @@ public void shouldNotOverrideUserConfigCommitIntervalMsIfExactlyOnceEnabled() {
assertThat(streamsConfig.getLong(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG), equalTo(commitIntervalMs));
}

@Test
public void shouldThrowExceptionIfCommitIntervalMsIsNegative() {
final long commitIntervalMs = -1;
props.put(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG, commitIntervalMs);
try {
new StreamsConfig(props);
fail("Should throw ConfigException when commitIntervalMs is set to a negative value");
} catch (final ConfigException e) {
assertEquals("Invalid value -1 for configuration commit.interval.ms: Value must be at least 0", e.getMessage());
}
}

@Test
public void shouldUseNewConfigsWhenPresent() {
final Properties props = getStreamsConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ public void close() { }
{
put(StreamsConfig.PROCESSING_GUARANTEE_CONFIG, StreamsConfig.EXACTLY_ONCE);
put(StreamsConfig.NUM_STREAM_THREADS_CONFIG, numberOfStreamsThreads);
put(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG, -1);
put(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG, Long.MAX_VALUE);
put(StreamsConfig.consumerPrefix(ConsumerConfig.METADATA_MAX_AGE_CONFIG), "1000");
put(StreamsConfig.consumerPrefix(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG), "earliest");
put(StreamsConfig.consumerPrefix(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG), 5 * 1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,6 @@ public void shouldNotFlushOffsetsWhenFlushIntervalHasNotLapsed() {
assertFalse(stateMaintainer.flushed);
}

@Test
public void shouldNotFlushWhenFlushIntervalIsZero() {
stateConsumer = new GlobalStreamThread.StateConsumer(logContext, consumer, stateMaintainer, time, Duration.ofMillis(10L), -1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe keep this test but pass in 0 instead?

@occho occho Oct 21, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, the test name is wrong and should be like shouldNotFlushWhenFlushIntervalIsNegative.
The code that shouldNotFlushWhenFlushIntervalIsZero tests is about this line:

if (flushInterval >= 0 && now >= lastFlush + flushInterval) {

With the code on trunk, when flushInterval is set to negative, stateMaintainer.flushState() is not called.
But, since this spec is removed, I think it is okay to remove the test.

WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, thanks for the explanation. Sounds good to me.

stateConsumer.initialize();
time.sleep(100);
stateConsumer.pollAndUpdate();
assertFalse(stateMaintainer.flushed);
}

@Test
public void shouldCloseConsumer() throws IOException {
stateConsumer.close();
Expand Down