Skip to content
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

make FixedTupleSpout implement IRichSpout so it can be used for tests #663

Merged
merged 1 commit into from
Aug 27, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions storm-core/src/jvm/backtype/storm/testing/FixedTupleSpout.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package backtype.storm.testing;

import backtype.storm.spout.ISpout;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.IRichSpout;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.tuple.Fields;
import backtype.storm.utils.Utils;
import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -11,7 +13,7 @@
import java.util.UUID;
import static backtype.storm.utils.Utils.get;

public class FixedTupleSpout implements ISpout {
public class FixedTupleSpout implements IRichSpout {
private static final Map<String, Integer> acked = new HashMap<String, Integer>();
private static final Map<String, Integer> failed = new HashMap<String, Integer>();

Expand Down Expand Up @@ -40,8 +42,13 @@ public static void clear(String stormId) {
private Map<String, FixedTuple> _pending;

private String _id;

private String _fieldName;

public FixedTupleSpout(List tuples) {
this(tuples, null);
}

public FixedTupleSpout(List tuples, String fieldName) {
_id = UUID.randomUUID().toString();
synchronized(acked) {
acked.put(_id, 0);
Expand All @@ -59,6 +66,7 @@ public FixedTupleSpout(List tuples) {
}
_tuples.add(ft);
}
_fieldName = fieldName;
}

public List<FixedTuple> getSourceTuples() {
Expand Down Expand Up @@ -139,4 +147,16 @@ public void activate() {
@Override
public void deactivate() {
}

@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
if (_fieldName != null) {
declarer.declare(new Fields(_fieldName));
}
}

@Override
public Map<String, Object> getComponentConfiguration() {
return null;
}
}