forked from nathanmarz/storm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug where committer spouts (including opaque spouts) could cause …
…processing to freeze due to commit being interpreted as new batch of processing
- Loading branch information
Nathan Marz
committed
Aug 20, 2012
1 parent
09f86bd
commit f66ad09
Showing
9 changed files
with
201 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
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
79 changes: 79 additions & 0 deletions
79
src/jvm/storm/trident/testing/FeederCommitterBatchSpout.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package storm.trident.testing; | ||
|
||
import backtype.storm.task.TopologyContext; | ||
import backtype.storm.tuple.Fields; | ||
import java.util.List; | ||
import java.util.Map; | ||
import storm.trident.operation.TridentCollector; | ||
import storm.trident.spout.ICommitterTridentSpout; | ||
import storm.trident.spout.ITridentSpout; | ||
import storm.trident.topology.TransactionAttempt; | ||
|
||
|
||
public class FeederCommitterBatchSpout implements ICommitterTridentSpout, IFeeder { | ||
|
||
FeederBatchSpout _spout; | ||
|
||
public FeederCommitterBatchSpout(List<String> fields) { | ||
_spout = new FeederBatchSpout(fields); | ||
} | ||
|
||
public void setWaitToEmit(boolean trueIfWait) { | ||
_spout.setWaitToEmit(trueIfWait); | ||
} | ||
|
||
static class CommitterEmitter implements ICommitterTridentSpout.Emitter { | ||
ITridentSpout.Emitter _emitter; | ||
|
||
|
||
public CommitterEmitter(ITridentSpout.Emitter e) { | ||
_emitter = e; | ||
} | ||
|
||
@Override | ||
public void commit(TransactionAttempt attempt) { | ||
} | ||
|
||
@Override | ||
public void emitBatch(TransactionAttempt tx, Object coordinatorMeta, TridentCollector collector) { | ||
_emitter.emitBatch(tx, coordinatorMeta, collector); | ||
} | ||
|
||
@Override | ||
public void success(TransactionAttempt tx) { | ||
_emitter.success(tx); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
_emitter.close(); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public Emitter getEmitter(String txStateId, Map conf, TopologyContext context) { | ||
return new CommitterEmitter(_spout.getEmitter(txStateId, conf, context)); | ||
} | ||
|
||
@Override | ||
public BatchCoordinator getCoordinator(String txStateId, Map conf, TopologyContext context) { | ||
return _spout.getCoordinator(txStateId, conf, context); | ||
} | ||
|
||
@Override | ||
public Fields getOutputFields() { | ||
return _spout.getOutputFields(); | ||
} | ||
|
||
@Override | ||
public Map getComponentConfiguration() { | ||
return _spout.getComponentConfiguration(); | ||
} | ||
|
||
@Override | ||
public void feed(Object tuples) { | ||
_spout.feed(tuples); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package storm.trident.testing; | ||
|
||
|
||
public interface IFeeder { | ||
void feed(Object tuples); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package storm.trident.testing; | ||
|
||
import java.util.List; | ||
import org.json.simple.JSONValue; | ||
import storm.trident.operation.BaseFunction; | ||
import storm.trident.operation.TridentCollector; | ||
import storm.trident.tuple.TridentTuple; | ||
|
||
public class TuplifyArgs extends BaseFunction { | ||
|
||
@Override | ||
public void execute(TridentTuple input, TridentCollector collector) { | ||
String args = input.getString(0); | ||
List<List<Object>> tuples = (List) JSONValue.parse(args); | ||
for(List<Object> tuple: tuples) { | ||
collector.emit(tuple); | ||
} | ||
} | ||
|
||
} |
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
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