Database Reference
In-Depth Information
A “Lorem Ipsum” Spout
Storm includes several mechanisms for testing topologies, which are
covered a bit later on, but it is often useful to have a spout that can
generate random data.
“Lorem Ipsum” is famous nonsense text that is often used by designers
to simulate blocks of text for layout. The text itself is a mangled Latin
text roughly a paragraph long, but modern implementations can
generate arbitrarily long pieces of text.
There is a Java class,
LoremIpsum
, available via the Maven Central
repository that can generate strings of arbitrary length from this
original paragraph.
<dependency>
<groupId>de.sven-jacobs</groupId>
<artifactId>loremipsum</artifactId>
<version>1.0</version>
</dependency>
To begin, the spout is defined with field names for the tuple that will be
generated:
public class
LoremIpsumSpout
implements
IRichSpout {
private static final long
serialVersionUID
= 1L;
String[] fields;
public
LoremIpsumSpout tuple(String...fields) {
this
.fields = fields;
return this
;
}
int
maxWords = 25;
public
LoremIpsumSpout maxWords(
int
maxWords) {
this
.maxWords = maxWords;
return this
;
}