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
[FLINK-2525]Add configuration support in Storm-compatibility #1046
Conversation
{ | ||
Configuration jobConfiguration = ((StreamingRuntimeContext) ctx).getJobConfiguration(); | ||
stormConf = new HashMap<String, Object>(); | ||
stormConf.putAll(jobConfiguration.getConfData()); |
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.
Missing null
test on jobConfiguration
(or is this test not necessary -- it is done in StromBoltWrapper)
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 will add null test.In fact, jobConfiguration can not be null. Because StromBoltWrapper unit test mock StreamingRuntimeContext object, so its jobConfiguration can be null.
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.
If it cannot be null
in test, does not mean it cannot be null
in real cluster deployment...
I don't see changes in |
Travis fails because you broke something... |
@mjsax Thank you very much.I miss the change in FlinkClient.I will fix it and test via bin/start-local.sh.In china, now we can not see the CI details and it is hard to know why CI failed.Thank you for your reminder. |
It fails in two test. You should actually see it, if you execute test locally. You should run test each time before you open/update an PR (at least for the module you did changes).
and
Just out of curiosity: why can you not see Travis details? |
@mjsax .The reason why i can not see Travis details is that(from reply mail): I will fix the code.I only run the test of core, and miss the test in example.It is my fault.Thanks! |
5dcf493
to
705b56d
Compare
Map mapExpect = new HashMap(); | ||
mapExpect.put(new String("path"), new String("/home/user/file.txt")); | ||
mapExpect.put(1, 1024); | ||
verify(bolt).prepare(eq(mapExpect), any(TopologyContext.class), any(OutputCollector.class)); |
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.
Remove mapExpected
and use stormConf
from above to avoid code duplication.
Can anyone have a look at |
@ffbin Can you extend |
Putting a nested "stormConf" into the configuration seems just wrong, sorry. Such a specific hack in a generic utility cannot yield maintainable code. Why is that needed in the first place? Why not have a dedicated configuration object for storm? |
You can turn the storm config into a byte[] via the We could also add a "nested config" class which only shows keys that start with a certain key prefix. This would be a config view over another config. Inside the |
I think the |
@StephanEwen Thansk.The key of storm config is object, so maybe the confData(HashMap<String, Object>) of Configuration is not enough. |
@ffbin: Can you try if you can simply put the serialized Storm Config as a byte[] into the Flink configuration? You can the unpack it inside the storm code, when needed. |
@mjsax hi. I want to make the number of added '!' in ExclamationBolt and ExclamationWithStormSpout.ExclamationMap configurabled by prepare() / open() function.The number can be get from jobConfiguration.What is your suggestion? Thanks |
Sorry, but I don't understand your question... |
@StephanEwen Hi. Your suggestion is good.I think i can serialized the key and value together as the value of confData in Job configuration.And create stormconf prefix(like "stormcong_1") as key of confData.Then get storm conf from job configuration and add them into task configuration.I will have a try. |
Can you try to serialize the whole |
Oh. you are right. Serialize the whole Map into a single byte[] is better.Thanks. |
@mjsax @StephanEwen I have finish the code changes. |
This is the stack trace (occurs in 4/5 runs -- the other run failed before due to unrelated test). It seems you broke something.
I will review after you fixed it. |
1.Storm topologies mode example | ||
|
||
... | ||
Map conf = new HashMap(); |
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.
Can you please use the same markup code as in the other code examples.
I just had a few "cosmetic" comments. Otherwise it looks good to me to get merged. |
0165a26
to
687c664
Compare
@mjsax Thanks. I have finish the change about all comments. |
@StephanEwen @rmetzger Can you have a look at it if it can be merged? I am also work on storm task hooks and it depend on this PR. Thank you very much! |
@@ -169,6 +169,13 @@ The input type is `Tuple1<String>` and `Fields("sentence")` specify that `input. | |||
|
|||
See [BoltTokenizerWordCountPojo](https://github.com/apache/flink/tree/master/flink-contrib/flink-storm-compatibility/flink-storm-compatibility-examples/src/main/java/org/apache/flink/stormcompatibility/wordcount/BoltTokenizerWordCountPojo.java) and [BoltTokenizerWordCountWithNames](https://github.com/apache/flink/tree/master/flink-contrib/flink-storm-compatibility/flink-storm-compatibility-examples/src/main/java/org/apache/flink/stormcompatibility/wordcount/BoltTokenizerWordCountWithNames.java) for examples. | |||
|
|||
## Configure for embedded Spouts/Bolts | |||
Embedded Spouts/Bolts can be configure with user defined parameters. | |||
User defined parameters is stored in a `Map`(as in Storm). |
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.
... are stored ...
Actually, I think going through the The purpose of |
It is not clear (at least to me) how to do this. The API does not offer an (obvious) way to set a configuration... (or I just don't get it). IHMO, the best way would be the possibility to set a configuration in the environment that is distributed to all operators. Should be extend Streaming API for this? |
As per discussion on the dev list, the If each of the operators needs its own config, can you create an abstract base class for the storm functions which takes a configuration as an argumen? BTW: There is no plan to remove the |
Storm only supports one global configuration that is shared over all spout/bolts. So |
Hi @ffbin, See the discussion here. It would be nice, if you could update the PR to use ExecutionConfig. |
Hi @fhueske , i will update the PR to use ExecutionConfig. Thanks. |
Example like this:
public static void main(final String[] args) {
String topologyId = "Streaming WordCount";
final FlinkTopologyBuilder builder = new FlinkTopologyBuilder();
...
final Config conf = new Config();
conf.put("wordsFile", "/home/user/");
conf.put("delimitSize", 1024);
final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
cluster.submitTopology(topologyId, conf, builder.createTopology());
Utils.sleep(10 * 1000);
cluster.killTopology(topologyId);
cluster.shutdown();
}
public class WordReader implements IRichSpout {
....
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
try {
this.context = context;
this.fileReader = new FileReader(conf.get("wordsFile"));
} catch (FileNotFoundException e) {
throw new RuntimeException("Error reading file ["+conf.get("wordFile")+"]");
}
this.collector = collector;
}
}
public final class StormBoltTokenizer implements IRichBolt {
....
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
this.delimitSize = stormConf.get("delimitSize");
this.collector = collector;
}
}