Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recreate producers and consumers during config reload command #123

Merged
merged 6 commits into from
Jun 21, 2019

Conversation

kehuum
Copy link
Collaborator

@kehuum kehuum commented Jun 19, 2019

Re-create producers and consumers as part of config reload command instead of lazy construction to avoid delay of errors and user impact.

@kehuum kehuum requested review from radai-rosenblatt and jonlee2 and removed request for radai-rosenblatt June 19, 2019 00:48

if (recreateSucceeded) {
// replace _consumers with newly created consumers
_consumers.clear();
Copy link
Contributor

@jonlee2 jonlee2 Jun 19, 2019

Choose a reason for hiding this comment

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

How about moving this to the try block and move the else block into the catch block?

_commonConsumerConfigs = new LiKafkaConsumerConfig(originalConfigs);

for (ClusterConsumerPair<K, V> entry : _consumers) {
getOrCreatePerClusterConsumer(newConsumers, entry.getCluster());
Copy link
Contributor

Choose a reason for hiding this comment

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

It does what we want, but it is not obvious that newConsumers is updated. Can we add a new method called createPerClusterConsumer() and use it here and also refactor getOrCreatePerClusterConsumer()?

convertedConfig.put(entry.getKey(), String.valueOf(entry.getValue()));
}
// TODO: add a flag in RELOAD_CONFIG_RESPONSE message to indicate result of config reload
// TODO: add a flag in RELOAD_CONFIG_RESPONSE message to indicate result of config reload
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as the previous line

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove line 411?

}

if (recreateSucceeded) {
// replace _producers with newly created producers
Copy link
Contributor

Choose a reason for hiding this comment

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

All comments for consumer config reload apply here as well.

LiKafkaConsumer<K, V> curConsumer = createPerClusterConsumer(entry.getCluster());
newConsumers.add(new ClusterConsumerPair<K, V>(entry.getCluster(), curConsumer));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, we will need to re-assign/subscribe the previous assignment/subscriptions with the newly created consumers.

_closed = false;

// keep previous partition assignment after config reload
// TODO: after subscribe() is supported, we need to also keep the original subscription
Map<ClusterDescriptor, Set<TopicPartition>> perClusterTopicPartitionSet = getPerClusterTopicPartitionSet(curPartitions);
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar comment as above. Why don't you use a map from cluster descriptor to topic partition set to begin with by calling per-cluster consumer's assignment()?

@kehuum kehuum merged commit 2fe620c into linkedin:master Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants