use of org.apache.storm.tuple.Values in project storm by apache.
the class HBaseState method batchRetrieve.
public List<List<Values>> batchRetrieve(List<TridentTuple> tridentTuples) {
List<List<Values>> batchRetrieveResult = Lists.newArrayList();
List<Get> gets = Lists.newArrayList();
for (TridentTuple tuple : tridentTuples) {
byte[] rowKey = options.mapper.rowKey(tuple);
gets.add(hBaseClient.constructGetRequests(rowKey, options.projectionCriteria));
}
try {
Result[] results = hBaseClient.batchGet(gets);
for (int i = 0; i < results.length; i++) {
Result result = results[i];
TridentTuple tuple = tridentTuples.get(i);
List<Values> values = options.rowToStormValueMapper.toValues(tuple, result);
batchRetrieveResult.add(values);
}
} catch (Exception e) {
LOG.warn("Batch get operation failed. Triggering replay.", e);
throw new FailedException(e);
}
return batchRetrieveResult;
}
use of org.apache.storm.tuple.Values in project storm by apache.
the class AvroGenericRecordBoltTest method generateTestTuple.
private static Tuple generateTestTuple(GenericRecord record) {
TopologyBuilder builder = new TopologyBuilder();
GeneralTopologyContext topologyContext = new GeneralTopologyContext(builder.createTopology(), new Config(), new HashMap(), new HashMap(), new HashMap(), "") {
@Override
public Fields getComponentOutputFields(String componentId, String streamId) {
return new Fields("record");
}
};
return new TupleImpl(topologyContext, new Values(record), 1, "");
}
use of org.apache.storm.tuple.Values in project storm by apache.
the class TestHdfsBolt method generateTestTuple.
private Tuple generateTestTuple(Object id, Object msg, Object city, Object state) {
TopologyBuilder builder = new TopologyBuilder();
GeneralTopologyContext topologyContext = new GeneralTopologyContext(builder.createTopology(), new Config(), new HashMap(), new HashMap(), new HashMap(), "") {
@Override
public Fields getComponentOutputFields(String componentId, String streamId) {
return new Fields("id", "msg", "city", "state");
}
};
return new TupleImpl(topologyContext, new Values(id, msg, city, state), 1, "");
}
use of org.apache.storm.tuple.Values in project storm by apache.
the class TestSequenceFileBolt method generateTestTuple.
private Tuple generateTestTuple(Long key, String value) {
TopologyBuilder builder = new TopologyBuilder();
GeneralTopologyContext topologyContext = new GeneralTopologyContext(builder.createTopology(), new Config(), new HashMap(), new HashMap(), new HashMap(), "") {
@Override
public Fields getComponentOutputFields(String componentId, String streamId) {
return new Fields("key", "value");
}
};
return new TupleImpl(topologyContext, new Values(key, value), 1, "");
}
use of org.apache.storm.tuple.Values in project storm by apache.
the class JmsSpout method nextTuple.
public void nextTuple() {
Message msg = this.queue.poll();
if (msg == null) {
Utils.sleep(50);
} else {
LOG.debug("sending tuple: " + msg);
// get the tuple from the handler
try {
Values vals = this.tupleProducer.toTuple(msg);
// ack if we're not in AUTO_ACKNOWLEDGE mode, or the message requests ACKNOWLEDGE
LOG.debug("Requested deliveryMode: " + toDeliveryModeString(msg.getJMSDeliveryMode()));
LOG.debug("Our deliveryMode: " + toDeliveryModeString(this.jmsAcknowledgeMode));
if (this.isDurableSubscription()) {
LOG.debug("Requesting acks.");
JmsMessageID messageId = new JmsMessageID(this.messageSequence++, msg.getJMSMessageID());
this.collector.emit(vals, messageId);
// at this point we successfully emitted. Store
// the message and message ID so we can do a
// JMS acknowledge later
this.pendingMessages.put(messageId, msg);
this.toCommit.add(messageId);
} else {
this.collector.emit(vals);
}
} catch (JMSException e) {
LOG.warn("Unable to convert JMS message: " + msg);
}
}
}
Aggregations