-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
[STORM-3004] storm-elasticsearch-examples: fixed all checkstyle warnings #2596
Conversation
@krichter722 Thanks for the fixes. I'll review this as soon as I can. In the meantime, could you raise issues on https://issues.apache.org/jira to track your changes? It makes it easier for us to track which branches fixes have been applied to, and we use the JIRA issues to generate release notes. Please also rename the PR and commit to contain the JIRA issue number. Thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, left some comments. My only real concern is that I feel like some of the comments don't really help understand the code, because they're documenting e.g. field X with "The X", which seems redundant.
@@ -34,52 +39,128 @@ | |||
import org.apache.storm.tuple.Fields; | |||
import org.apache.storm.tuple.Values; | |||
|
|||
public class EsIndexTopology { | |||
/** | |||
* Demonstrates an ElasticSearch Strom topology. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strom -> Storm
public class EsIndexTopology { | ||
/** | ||
* Demonstrates an ElasticSearch Strom topology. | ||
* @author unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally don't use @author
in the javadoc, it's just noise since most files are worked on by more than one person. Could you remove it here and elsewhere?
|
||
/** | ||
* The id of the used spout. | ||
*/ | ||
static final String SPOUT_ID = "spout"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should be private, that way checkstyle hopefully won't complain about missing comments.
}; | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is checkstyle requiring these comments? If not I'd rather we don't have them. Comments that are just "The $variable_name" are just noise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the current setup requires comments on almost everything. I agree that they almost no use. Therefore this PR is a good usability check for the current extremely strict checkstyle configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked, and checkstyle passes fine for me without these comments. As far as I can tell, comments are required on public classes, public methods that don't override supertype methods, and public constructors/variables.
For example, this file works for me with only comments on the EsIndexTopology class and the main method. All the others can be removed without violating the checkstyle check.
Does this not work for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right, I was using the checkstyle:check
target which apparently uses a much stricter set of rules which might be even different from the one configured to run in the validate
phase. I'll remove the noisy comments on private fields and methods.
} | ||
|
||
/** | ||
* Processes the next tuple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: nextTuple makes the spout emit the next tuple, if any.
*/ | ||
public final class TridentEsTopology { | ||
/** | ||
* The default batch size. Necessary in order to avoid magic number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I don't think you need to mention why the field is here. Won't checkstyle complain if someone replaces the field with a magic number again?
@Override | ||
public Fields getOutputFields() { | ||
return new Fields("source", "index", "type", "id"); | ||
} | ||
|
||
/** | ||
* Open the topology. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Opens the spout, not the topology
} | ||
for (List<Object> list : batch) { | ||
collector.emit(list); | ||
} | ||
} | ||
|
||
/** | ||
* Acknoledges the message with id {@code msgId}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acknowledges
if (batch == null) { | ||
batch = new ArrayList<List<Object>>(); | ||
if (index >= outputs.length && cycle) { | ||
if (index >= outputs.length && isCycle()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Doesn't seem like there's any reason to use the getter rather than referring to the field?
* Get the maximum batch size. | ||
* @return the maxBatchSize | ||
*/ | ||
public int getMaxBatchSize() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little unsure why we need these getters and setters?
I agree with all your comments and removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good pending the last two comments, +1 after that.
external/storm-opentsdb/pom.xml
Outdated
@@ -1,3 +1,4 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems unnecessary.
System.out.println("**** RESENDING FAILED TUPLE"); | ||
this.collector.emit(this.pending.get(msgId), msgId); | ||
} | ||
} | ||
|
||
/** | ||
* Utility constructor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation, that makes sense. Could you change the comment to e.g. "Prevent instantiation" or something similar, so people who run across this later will know why it's there?
@krichter722 kindly reminder. |
Last comments incorporated. |
+1, thanks for being patient. @krichter722 could you add the issue number to the commit message, I'll merge after that. I'd add it myself, but then the PR won't show as merged. |
@krichter722 Thanks, merged to master. I also added you to the contributors list in JIRA, so you should be able to assign tasks to yourself now. |
I'd like to share my hands-on reflection on whether it makes sense to take over you checkstyle-config for some of my projects. The approx. 100 violations cost about 1,5h to fix which seems a realistic indicator for the time needed for similar fixes.