Uh oh!
There was an error while loading. Please reload this page.
STORM-2358: Update storm hdfs spout to remove specific implementation handling - #1942
STORM-2358: Update storm hdfs spout to remove specific implementation handling#1942pasalkarsachin1 wants to merge 3 commits into
Conversation
… handling As part of this change we have removed specific handling in code for TextFileReader & SequenceFileReader also made AbstractFileReader as public
pasalkarsachin1
commented
Feb 17, 2017
Can someone take a look at this? |
| try { | ||
| Class<?> clsType = Class.forName(readerType); | ||
| Constructor<?> constructor = clsType.getConstructor(FileSystem.class, Path.class, Map.class, String.class); | ||
| Constructor<?> constructor = readerType.getConstructor(FileSystem.class, Path.class, Map.class, String.class); |
There was a problem hiding this comment.
This assumes a ctor with expected number and type of params is available and tries to invoke it via reflection. Adding an init/open with required params in the FileReader is much cleaner IMO and avoids having to check and throw exceptions at runtime.
There was a problem hiding this comment.
Same code is being there before my changes, I can create JIRA for this. ATM I am just trying to get rid of specific implementations
There was a problem hiding this comment.
Not sure what you mean by "get rid of specific implementations". I see that you are mainly cleaning up and refactoring the code and so its better if you do it with this patch.
| // Reader type config | ||
| if ( readerType==null && conf.containsKey(Configs.READER_TYPE) ) { | ||
| readerType = conf.get(Configs.READER_TYPE).toString(); | ||
| String className = (String) conf.get(Configs.READER_TYPE); |
There was a problem hiding this comment.
What is the need for this when the spout accepts the readerType via setReaderType ?
There was a problem hiding this comment.
It was already there so I updated as per requirement.
| } | ||
| public HdfsSpout setReaderType(String readerType) { | ||
| public HDFSSpout setReaderType(Class<? extends FileReader> readerType) { |
There was a problem hiding this comment.
How about backward compatibility ? Changing the signature will break existing clients. May be you can deprecate the earlier method and add a new one like
setFileReader(Class<? extends FileReader> reader)How would one initialize a
HDFSSpoutvia Flux? Earlier since the method accepted a String it was pretty trivial. Try it out and add some example, or add an additional method likesetFileReader(String className)that takes the class name.
There was a problem hiding this comment.
Sure I will deprecate this. However adding deprecation will add more code
There was a problem hiding this comment.
Done please review
There was a problem hiding this comment.
Looks like you are removing support for aliases. Is that right ?
There was a problem hiding this comment.
I have deprecated as per comments, not removed.
roshannaik
left a comment
There was a problem hiding this comment.
Overall this PR seems to be guided by misplaced ideas ... and complete disregard for backward compatibility.
| import org.apache.storm.tuple.Fields; | ||
| public class HdfsSpout extends BaseRichSpout { | ||
| public class HDFSSpout extends BaseRichSpout { |
There was a problem hiding this comment.
Do you realize what you are doing here ?
HeartSaVioR
commented
Feb 17, 2017
First of all, thanks for the contribution. I'm seeing backward incompatible as @roshannaik stated, and like renaming class is not strictly necessary to. Huge part of maintaining open source is fighting with backward compatibility. What you change will affect number of developers. It's joyful thing for open source developers but also huge pain point. Unless there are critical places so need to change or get rid of, breaking backward compatibility would not be accepted, and even it is really needed, it would be better to discuss widely. |
@HeartSaVioR@roshannaik I have reverted class renaming. Other than this I don't see break in backward compatibility |
pasalkarsachin1
commented
Feb 20, 2017
@HeartSaVioR@roshannaik@arunmahadevan Can you review this? Let me know if there is any issue you see with backward compatibility. |
roshannaik
commented
Feb 20, 2017
Deprecating/removing aliasing support IS naturally a backward compat issue. You have expressed your concern that you don't like registering aliases in HdfsSpout. But removing aliasing is not the solution to address your concern. Like I said before, If you know how to implement aliasing without registering in HdfsSpout then it would address your concern and we can look into this PR.... otherwise there is nothing left to look into here. |
@roshannaik Like I said even on Jira STORM-2358. I don't see point having code just to specifically handle alias. Code should be generic to handle all cases. If you want to push to have specific handling I don't think its right contribution & we already have this discussion on STORM-2358. I would like to see view from community. Let me know from your point of view on backward compatibility. I know moving away from alias will have issues but to keep specific code just to support this is not worth |
@pasalkarsachin1@roshannaik
cc. @arunmahadevan ps. Keeping backward compatibility makes it bad here. If 1 is not true, we should keep method signature as it is, then we can't deprecate the alias usage even we want to get rid of it, since we're not changing method signature or even overload method here. |
arunmahadevan
commented
Feb 20, 2017
Agree and pointed out in one of the earlier comments. One suggestion was to have two methods,
Right now the method accepts special strings "text", "seq" or class name, which looks confusing and not type safe. The proposed patch addresses this by accepting a FileReader class. I am not sure why cant we directly pass the FileReader implementation instead of the class (like The current FileReader implementation is expected to have constructor with a specific signature, which cannot be enforced at compile time. IMO, this should also be fixed along with this patch by introducing some init method in the FileReader interface. Regarding backward compatibility, if we are fine to break it in the next major version (2.0) we can keep this out of 1.x branch. |
HeartSaVioR
commented
Feb 20, 2017
It enforces implementation to be |
roshannaik
commented
Feb 20, 2017
@HeartSaVioR However... the author's concern is quite the opposite ... it is not from a user perspective. He is trying to make code more generic (as he puts it) by removing aliasing ... because we need to make the alias known to Hdfs Spout.... Which means no enums, no text() or sequence() etc. Side note: This approach of using aliases OR class names in the same place has precedence in other projects as well... Apache Flume uses this pattern a fair amount. |
HeartSaVioR
commented
Feb 20, 2017
@roshannaik |
Clink on this link : in file based config also dual methods/settings can be used to keep aliases and class names separate just like in code. |
For points made by @HeartSaVioR For point 2, I have various implementations in mind to add to open source one of them is implemented by megha10 for ZipTextFileReader another can be anySepratorReader like (pipe,comma). If we add enum for every implementation contributor has to do other extra work to enable it rather just adding reader. Also if user adds his class where he can add it? He has to provide FQCN which comes back to same implementation which I did. |
pasalkarsachin1
commented
Feb 20, 2017
I am thinking to work on this after this patch we can have init() api which verifies things before it proceeds.
Once we provide init method we are providing user a way to initialize the non Serializable member. |
For point 2 I suggest adding shortcut, not removing previous one. Providing FQDN is not easiest way to do so we can make some implementations taking precedence and support it via easiest way. IMHO providing shortcut method is easiest (or similar to providing enum), and providing enum is good enough, and receiving only FQDN is not convenient, but just has to use. First two things make IDE providing various hints, and the last thing doesn't. Adding it to enum or even providing shortcut method will be done in 10 lines. I don't think it gives contributors more extra works, but we might need to guide it properly.
There're various ways to do it. |
My intention was never to use FQCN it was just to use className rather than Constants. Even you look at my code I am just using class name. setReader(Class<? extendsFileReader> reader)However what you are suggesting is in HdfsSpout I should add something like below publichdfsSpoutuseTextFileReader() {
this.readerType = TextFileReader.class;
returnthis;
}
publichdfsSpoutuseSequenceFileReader() {
this.readerType = SequenceFileReader.class;
}Also have a way to provide way to support FQCN, Correct? If everyone agrees I will do the change. |
pasalkarsachin1
commented
Feb 22, 2017
@HeartSaVioR@roshannaik@arunmahadevan are you OK with this approach? |
We are closing stale Pull Requests to make the list more manageable. Please re-open any Pull Request that has been closed in error. Closesapache#608Closesapache#639Closesapache#640Closesapache#648Closesapache#662Closesapache#668Closesapache#692Closesapache#705Closesapache#724Closesapache#728Closesapache#730Closesapache#753Closesapache#803Closesapache#854Closesapache#922Closesapache#986Closesapache#992Closesapache#1019Closesapache#1040Closesapache#1041Closesapache#1043Closesapache#1046Closesapache#1051Closesapache#1078Closesapache#1146Closesapache#1164Closesapache#1165Closesapache#1178Closesapache#1213Closesapache#1225Closesapache#1258Closesapache#1259Closesapache#1268Closesapache#1272Closesapache#1277Closesapache#1278Closesapache#1288Closesapache#1296Closesapache#1328Closesapache#1342Closesapache#1353Closesapache#1370Closesapache#1376Closesapache#1391Closesapache#1395Closesapache#1399Closesapache#1406Closesapache#1410Closesapache#1422Closesapache#1427Closesapache#1443Closesapache#1462Closesapache#1468Closesapache#1483Closesapache#1506Closesapache#1509Closesapache#1515Closesapache#1520Closesapache#1521Closesapache#1525Closesapache#1527Closesapache#1544Closesapache#1550Closesapache#1566Closesapache#1569Closesapache#1570Closesapache#1575Closesapache#1580Closesapache#1584Closesapache#1591Closesapache#1600Closesapache#1611Closesapache#1613Closesapache#1639Closesapache#1703Closesapache#1711Closesapache#1719Closesapache#1737Closesapache#1760Closesapache#1767Closesapache#1768Closesapache#1785Closesapache#1799Closesapache#1822Closesapache#1824Closesapache#1844Closesapache#1874Closesapache#1918Closesapache#1928Closesapache#1937Closesapache#1942Closesapache#1951Closesapache#1957Closesapache#1963Closesapache#1964Closesapache#1965Closesapache#1967Closesapache#1968Closesapache#1971Closesapache#1985Closesapache#1986Closesapache#1998Closesapache#2031Closesapache#2032Closesapache#2071Closesapache#2076Closesapache#2108Closesapache#2119Closesapache#2128Closesapache#2142Closesapache#2174Closesapache#2206Closesapache#2297Closesapache#2322Closesapache#2332Closesapache#2341Closesapache#2377Closesapache#2414Closesapache#2469
We are closing stale Pull Requests to make the list more manageable. Please re-open any Pull Request that has been closed in error. Closesapache#608Closesapache#639Closesapache#640Closesapache#648Closesapache#662Closesapache#668Closesapache#692Closesapache#705Closesapache#724Closesapache#728Closesapache#730Closesapache#753Closesapache#803Closesapache#854Closesapache#922Closesapache#986Closesapache#992Closesapache#1019Closesapache#1040Closesapache#1041Closesapache#1043Closesapache#1046Closesapache#1051Closesapache#1078Closesapache#1146Closesapache#1164Closesapache#1165Closesapache#1178Closesapache#1213Closesapache#1225Closesapache#1258Closesapache#1259Closesapache#1268Closesapache#1272Closesapache#1277Closesapache#1278Closesapache#1288Closesapache#1296Closesapache#1328Closesapache#1342Closesapache#1353Closesapache#1370Closesapache#1376Closesapache#1391Closesapache#1395Closesapache#1399Closesapache#1406Closesapache#1410Closesapache#1422Closesapache#1427Closesapache#1443Closesapache#1462Closesapache#1468Closesapache#1483Closesapache#1506Closesapache#1509Closesapache#1515Closesapache#1520Closesapache#1521Closesapache#1525Closesapache#1527Closesapache#1544Closesapache#1550Closesapache#1566Closesapache#1569Closesapache#1570Closesapache#1575Closesapache#1580Closesapache#1584Closesapache#1591Closesapache#1600Closesapache#1611Closesapache#1613Closesapache#1639Closesapache#1703Closesapache#1711Closesapache#1719Closesapache#1737Closesapache#1760Closesapache#1767Closesapache#1768Closesapache#1785Closesapache#1799Closesapache#1822Closesapache#1824Closesapache#1844Closesapache#1874Closesapache#1918Closesapache#1928Closesapache#1937Closesapache#1942Closesapache#1951Closesapache#1957Closesapache#1963Closesapache#1964Closesapache#1965Closesapache#1967Closesapache#1968Closesapache#1971Closesapache#1985Closesapache#1986Closesapache#1998Closesapache#2031Closesapache#2032Closesapache#2071Closesapache#2076Closesapache#2108Closesapache#2119Closesapache#2128Closesapache#2142Closesapache#2174Closesapache#2206Closesapache#2297Closesapache#2322Closesapache#2332Closesapache#2341Closesapache#2377Closesapache#2414Closesapache#2469
As part of this change I have removed specific handling in code for TextFileReader & SequenceFileReader also made AbstractFileReader as public