Created
January 26, 2013 06:15
-
-
Save yelcat/4640514 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderEnabledMockSpout implements IRichSpout { | |
private final static String[] ipAddress = new String[] | |
{"10.13.43.154", "10.112.43.12", "10.13.45.123", "10.113.43.4"}; | |
private SpoutOutputCollector collector; | |
@Override | |
public boolean isDistributed() { | |
return true; | |
} | |
@Override | |
public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) { | |
outputFieldsDeclarer.declare(new Fields("IP", "BizOrderId")); | |
} | |
@Override | |
public void open(Map map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) { | |
this.collector = spoutOutputCollector; | |
} | |
@Override | |
public void close() { | |
//To change body of implemented methods use File | Settings | File Templates. | |
} | |
@Override | |
public void nextTuple() { | |
Utils.sleep(4000); | |
final Random rand = new Random(); | |
collector.emit(new Values(ipAddress[rand.nextInt(ipAddress.length)], Math.abs(rand.nextLong()))); | |
} | |
@Override | |
public void ack(Object o) { | |
//To change body of implemented methods use File | Settings | File Templates. | |
} | |
@Override | |
public void fail(Object o) { | |
//To change body of implemented methods use File | Settings | File Templates. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment