Skip to content

MINOR: Refactor StreamsProducer usage#8249

Closed
mjsax wants to merge 5 commits intoapache:trunkfrom
mjsax:minor-kip447
Closed

MINOR: Refactor StreamsProducer usage#8249
mjsax wants to merge 5 commits intoapache:trunkfrom
mjsax:minor-kip447

Conversation

@mjsax
Copy link
Copy Markdown
Member

@mjsax mjsax commented Mar 7, 2020

Related to KIP-447 (extracted from #8218 to keep the other PR smaller):

We want to use StreamsProducer instead of KafkaProducer within ActiveTaskCreator. Furthermore, StreamsProducer should expose metrics and close the internal KafkaProducer.

The lion's share of the PR is additional code cleanup, mostly related to generics.

Call for review @guozhangwang @abbccdda @vvcephei

@mjsax mjsax added the streams label Mar 7, 2020
} catch (final RuntimeException e) {
throw new StreamsException("Thread Producer encounter unexpected error trying to close", e);
}
threadProducer.close();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Exception handling is moved into StreamsProducer (similar below)

this.producer = Objects.requireNonNull(producer, "producer cannot be null");
this.applicationId = applicationId;
this.eosEnabled = eosEnabled;
this.eosEnabled = applicationId != null;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We need the application.id only if EOS is enabled -- hence we simplify the constructor to 3 parameter and enable EOS is application.id is provided (this avoid the redundant eosEnabled parameter)


private String formatException(final String message) {
return message + " [" + logPrefix + ", " + (eosEnabled ? "eos" : "alo") + "]";
return message + " [" + logPrefix + "]";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's redundant to log if EOS is enabled or not; it's a single global config. Not need to include.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would rather we keep it here so that we don't need to look around the log to identify the latest restart log to determine whether we are on EOS or not.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If we argue this way, you could also justify to log the whole config each time :)

Copy link
Copy Markdown

@abbccdda abbccdda left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, the changes LGTM, but I still have doubts about how this could simplifies the work for KIP-447, as activeTaskCreator shall only handle the producer close and metric stuff IIUC?


private String formatException(final String message) {
return message + " [" + logPrefix + ", " + (eosEnabled ? "eos" : "alo") + "]";
return message + " [" + logPrefix + "]";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would rather we keep it here so that we don't need to look around the log to identify the latest restart log to determine whether we are on EOS or not.

@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Mar 9, 2020

After taking to @guozhangwang offline, I realize that this PR does actually not make sense. The idea of KIP-447 is to have a StreamProducer per task that all share the same KafkaProducer. Hence, the TaskCreator must stay in charge to create the producer as the StreamsProducer cannot guarantee the correct setup.

@mjsax mjsax closed this Mar 9, 2020
@mjsax mjsax deleted the minor-kip447 branch June 11, 2020 01:13
@mjsax mjsax added the kip Requires or implements a KIP label Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kip Requires or implements a KIP streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants