Skip to content

STORM-2826#1

Merged
srdo merged 3 commits into
srdo:STORM-2826from
hmcl:1.x-branch_PR_STORM-2826_KVSerDe
Dec 13, 2017
Merged

STORM-2826#1
srdo merged 3 commits into
srdo:STORM-2826from
hmcl:1.x-branch_PR_STORM-2826_KVSerDe

Conversation

@hmcl

@hmcl hmcl commented Dec 9, 2017

Copy link
Copy Markdown
  • Suggested Fix

- Suggested Fix
- Suggested Fix2
@hmcl hmcl force-pushed the 1.x-branch_PR_STORM-2826_KVSerDe branch from 5ccf478 to ed2c886 Compare December 12, 2017 02:20

@srdo srdo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Most of the changes seem good. Left a few comments.

if (bootstrapServers == null || bootstrapServers.isEmpty()) {
throw new IllegalArgumentException("bootstrap servers cannot be null");
} else {
setNonNullValProp(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers, false);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It doesn't make sense to use setNonNullValProp here, we already know bootstrapServers isn't null.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done.

this(keyDes, keyDesClazz, valueDes, valueDesClazz, builder.subscription,
(RecordTranslator<K, V>) builder.translator, new HashMap<String, Object>());

this.kafkaProps.putAll(builder.kafkaProps);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It's probably nicer to put this in the HashMap constructor call in line 300 instead

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I thought about that, but then i would have to use the anonymous class with methods, i.e. the following code, which a lot of people call an anti-pattern. I am fine either way. What do you think is best?

new HashMap<String,Object>(){{putAll(builder.kafkaProps);}}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Of course. Thanks.


private void setNonNullValProp(String key, Object val, boolean isClass) {
if (val != null) {
if (isClass) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think you should rename the parameter. It's true if the val is not a class.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I removed this method

} else if (valueDesClazz != null) {
this.kafkaProps.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, valueDesClazz);
}
setSerDeKafkaProps(keyDes, keyDesClazz, valueDes, valueDesClazz);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can we add a note to this constructor that only one of keyDes, keyDesClazz, valueDes, valueDesClazz should be non-null at a time? It was part of the reason for the if-else-if-else above. I'd say we should add a check that only one is not null, but it's probably not going to be pretty so a comment is fine.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure, I agree. But the reason I didn't put it is because in one of the constructors there was no if-else-if. We will be modifying the semantics slightly, but I think it is safe to do so. Agree?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This constructor is private and only used by the setKey/setValue methods, so it's easy to check that it's never called incorrectly. The other constructor shouldn't have this rule.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

- Suggested Fix2 - Address code reviews
@hmcl

hmcl commented Dec 12, 2017

Copy link
Copy Markdown
Author

@srdo can you please check now, and in case it is fine, incorporate these changes in the main patch in Apache Storm. Thanks.

@srdo

srdo commented Dec 13, 2017

Copy link
Copy Markdown
Owner

Looks good, thanks.

@srdo srdo merged commit b724725 into srdo:STORM-2826 Dec 13, 2017
srdo pushed a commit that referenced this pull request May 11, 2018
srdo pushed a commit that referenced this pull request May 11, 2018
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