forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Yang, Tong <yangtong2@huawei.com> Co-committed-by: Yang, Tong <yangtong2@huawei.com>
30 lines
2.1 KiB
HTML
30 lines
2.1 KiB
HTML
<a name="mrs_01_1051"></a><a name="mrs_01_1051"></a>
|
|
|
|
<h1 class="topictitle1">Performing Embedded Service Migration</h1>
|
|
<div id="body1590370637070"><div class="section" id="mrs_01_1051__section159162041122612"><h4 class="sectiontitle">Scenarios</h4><p id="mrs_01_1051__p154642112610">This section describes how to embed Storm code in DataStream of Flink in embedded migration mode. For example, the code of Spout or Bolt compiled using Storm API is embedded.</p>
|
|
</div>
|
|
<div class="section" id="mrs_01_1051__section9917241182615"><h4 class="sectiontitle">Procedure</h4><ol id="mrs_01_1051__ol9412429269"><li id="mrs_01_1051__li1441742102610"><span>In Flink, perform embedded conversion to Spout and Bolt in the Storm topology to convert them to Flink operators. The following is an example of the code:</span><p><pre class="screen" id="mrs_01_1051__screen164114219265">//set up the execution environment
|
|
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
|
|
//get input data
|
|
final DataStream<String> text = getTextDataStream(env);
|
|
final DataStream<Tuple2<String, Integer>> counts = text
|
|
//split up the lines in pairs (2-tuples) containing: (word,1)
|
|
//this is done by a bolt that is wrapped accordingly
|
|
.transform("CountBolt",
|
|
TypeExtractor.getForObject(new Tuple2<String, Integer>("", 0)),
|
|
new BoltWrapper<String, Tuple2<String, Integer>>(new CountBolt()))
|
|
//group by the tuple field "0" and sum up tuple field "1"
|
|
.keyBy(0).sum(1);
|
|
// execute program
|
|
env.execute("Streaming WordCount with bolt tokenizer");</pre>
|
|
</p></li><li id="mrs_01_1051__li124242182619"><span>After the modification, run the following command to submit the modification:</span><p><p id="mrs_01_1051__p54124222616"><strong id="mrs_01_1051__b1344424263">flink run -class {MainClass} WordCount.jar</strong></p>
|
|
</p></li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_1048.html">Migrating Storm Services to Flink</a></div>
|
|
</div>
|
|
</div>
|
|
|