Search in sources :

Example 1 with TransactionOutputFieldsDeclarer

use of com.alibaba.jstorm.transactional.TransactionOutputFieldsDeclarer in project jstorm by alibaba.

the class TransactionSpout method declareOutputFields.

@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
    declarer.declareStream(TransactionCommon.BARRIER_STREAM_ID, new Fields(TransactionCommon.BATCH_GROUP_ID_FIELD, TransactionCommon.BARRIER_SNAPSHOT_FIELD));
    TransactionOutputFieldsDeclarer transactionDeclarer = new TransactionOutputFieldsDeclarer();
    spoutExecutor.declareOutputFields(transactionDeclarer);
    Map<String, StreamInfo> streams = transactionDeclarer.getFieldsDeclaration();
    for (Entry<String, StreamInfo> entry : streams.entrySet()) {
        String streamName = entry.getKey();
        StreamInfo streamInfo = entry.getValue();
        declarer.declareStream(streamName, streamInfo.is_direct(), new Fields(streamInfo.get_output_fields()));
    }
}
Also used : Fields(backtype.storm.tuple.Fields) TransactionOutputFieldsDeclarer(com.alibaba.jstorm.transactional.TransactionOutputFieldsDeclarer) StreamInfo(backtype.storm.generated.StreamInfo)

Example 2 with TransactionOutputFieldsDeclarer

use of com.alibaba.jstorm.transactional.TransactionOutputFieldsDeclarer in project jstorm by alibaba.

the class TransactionBolt method declareOutputFields.

@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
    TransactionOutputFieldsDeclarer transactionDeclarer = new TransactionOutputFieldsDeclarer();
    boltExecutor.declareOutputFields(transactionDeclarer);
    Map<String, StreamInfo> streams = transactionDeclarer.getFieldsDeclaration();
    for (Entry<String, StreamInfo> entry : streams.entrySet()) {
        String streamName = entry.getKey();
        StreamInfo streamInfo = entry.getValue();
        declarer.declareStream(streamName, streamInfo.is_direct(), new Fields(streamInfo.get_output_fields()));
    }
    if (streams.size() > 0) {
        declarer.declareStream(TransactionCommon.BARRIER_STREAM_ID, new Fields(TransactionCommon.BATCH_GROUP_ID_FIELD, TransactionCommon.BARRIER_SNAPSHOT_FIELD));
    } else {
        isEndBolt = true;
    }
}
Also used : Fields(backtype.storm.tuple.Fields) TransactionOutputFieldsDeclarer(com.alibaba.jstorm.transactional.TransactionOutputFieldsDeclarer) StreamInfo(backtype.storm.generated.StreamInfo)

Aggregations

StreamInfo (backtype.storm.generated.StreamInfo)2 Fields (backtype.storm.tuple.Fields)2 TransactionOutputFieldsDeclarer (com.alibaba.jstorm.transactional.TransactionOutputFieldsDeclarer)2