本文整理汇总了Java中org.apache.storm.utils.TupleUtils类的典型用法代码示例。如果您正苦于以下问题:Java TupleUtils类的具体用法?Java TupleUtils怎么用?Java TupleUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TupleUtils类属于org.apache.storm.utils包,在下文中一共展示了TupleUtils类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
@Override
public void execute(Tuple input) {
if (TupleUtils.isTick(input)) {
collector.ack(input);
return;
}
try {
Command cmd = (Command) input.getValueByField(EmitFields.COMMAND);
BoltCommandHandler handler = handlerManager.getHandler(cmd);
handler.handle(input);
this.collector.ack(input);
} catch (Exception e) {
logger.error("Process data error", e);
this.collector.reportError(e);
this.collector.fail(input);
}
}
示例2: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
@Override
public void execute(Tuple input) {
if (TupleUtils.isTick(input)) {
collector.ack(input);
return;
}
try {
Command cmd = (Command) input.getValueByField(EmitFields.COMMAND);
BoltCommandHandler handler = handlerManager.getHandler(cmd);
handler.handle(input);
this.collector.ack(input);
} catch (Exception e) {
this.collector.fail(input);
this.collector.reportError(e);
logger.error("Process Error!", e);
}
}
示例3: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
@Override
public void execute(Tuple input) {
if (TupleUtils.isTick(input)) {
collector.ack(input);
return;
}
try {
Command cmd = (Command) input.getValueByField(EmitFields.COMMAND);
BoltCommandHandler handler = handlerManager.getHandler(cmd);
handler.handle(input);
} catch (Exception e) {
logger.error("Process data error", e);
this.collector.reportError(e);
this.collector.fail(input);
}
}
示例4: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
@Override
public void execute(Tuple tuple) {
long currTime = System.currentTimeMillis();
for (JoinInfo joinInfo : joinInfos) {
joinInfo.expireAndAckTimedOutEntries(collector, currTime);
}
if (TupleUtils.isTick(tuple))
return;
try {
String stream = streamKind.getStreamId(tuple);
if (stream.equalsIgnoreCase(fromStream))
processFromStreamTuple(tuple, currTime);
else if(stream.equalsIgnoreCase(joinStream))
processJoinStreamTuple(tuple, currTime);
else
throw new InvalidTuple("Source component/streamId for Tuple not part of streams being joined : " + stream, tuple);
} catch (InvalidTuple e) {
collector.ack(tuple);
LOG.warn("{}. Tuple will be dropped.", e.toString());
}
}
示例5: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
/**
* Expect to receive either a tick tuple or a telemetry message that needs applied
* to a profile.
* @param input The tuple.
*/
@Override
public void execute(Tuple input) {
try {
if(TupleUtils.isTick(input)) {
handleTick();
} else {
handleMessage(input);
}
} catch (Throwable e) {
LOG.error(format("Unexpected failure: message='%s', tuple='%s'", e.getMessage(), input), e);
collector.reportError(e);
} finally {
collector.ack(input);
}
}
示例6: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
public void execute(Tuple input) {
if (TupleUtils.isTick(input)) {
collector.ack(input);
return;
}
try {
Command cmd = (Command) input.getValueByField(Constants.EmitFields.COMMAND);
BoltCommandHandler handler = handlerManager.getHandler(cmd);
handler.handle(input);
this.collector.ack(input);
} catch (Exception e) {
this.collector.ack(input);
logger.error("Heartbeat error, ignore this error", e);
}
}
示例7: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
@Override
public void execute(Tuple tuple) {
//如果是TickTuple(则说明该Tuple触发了时间窗口),则将当前时间窗口的计数和实际的时间窗口长度emit。
if (TupleUtils.isTick(tuple)) {
LOG.debug("Received tick tuple, triggering emit of current window counts");
emitCurrentWindowCounts();
}
else {
countObjAndAck(tuple);
}
}
示例8: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
/**
* This method functions as a template method (design pattern).
*/
@Override
public final void execute(Tuple tuple, BasicOutputCollector collector) {
if (TupleUtils.isTick(tuple)) {
getLogger().debug("Received tick tuple, triggering emit of current rankings");
emitRankings(collector);
}
else {
updateRankingsWithTuple(tuple);
}
}
示例9: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param tuple the tuple to process.
*/
@Override
public void execute(final Tuple tuple) {
if (TupleUtils.isTick(tuple)) {
onTickTuple(tuple);
} else {
process(tuple);
}
}
示例10: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param tuple the tuple to process.
*/
@Override
public void execute(final Tuple tuple) {
if (TupleUtils.isTick(tuple)) {
onTickTuple(tuple);
} else {
process(tuple);
}
}
示例11: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
@Override
public void execute(Tuple tuple) {
if (TupleUtils.isTick(tuple)) {
LOG.debug("Received tick tuple, triggering emit of current window counts");
emitCurrentWindowCounts();
}
else {
countObjAndAck(tuple);
}
}
示例12: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
@Override
public void execute(Tuple input) {
if (TupleUtils.isTick(input)) {
collector.ack(input);
return;
}
try {
if (producer != null) {
// a message key can be provided in the mapper
Message msg = pulsarBoltConf.getTupleToMessageMapper().toMessage(input);
if (msg == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("[{}] Cannot send null message, acking the collector", boltId);
}
collector.ack(input);
} else {
final long messageSizeToBeSent = msg.getData().length;
producer.sendAsync(msg).handle((r, ex) -> {
synchronized (collector) {
if (ex != null) {
collector.reportError(ex);
collector.fail(input);
LOG.error("[{}] Message send failed", boltId, ex);
} else {
collector.ack(input);
++messagesSent;
messageSizeSent += messageSizeToBeSent;
if (LOG.isDebugEnabled()) {
LOG.debug("[{}] Message sent with id {}", boltId, msg.getMessageId());
}
}
}
return null;
});
}
}
} catch (Exception e) {
LOG.error("[{}] Message processing failed", boltId, e);
collector.reportError(e);
collector.fail(input);
}
}
示例13: execute
import org.apache.storm.utils.TupleUtils; //导入依赖的package包/类
@Override
public void execute(Tuple input) {
_collector.ack(input);
// this bolt can be connected to anything
// we just want to trigger a new search when the input is a tick tuple
if (!TupleUtils.isTick(input)) {
return;
}
Status[] slist = new Status[] { Status.DISCOVERED, Status.ERROR,
Status.FETCH_ERROR, Status.FETCHED, Status.REDIRECTION };
MultiSearchRequestBuilder multi = connection.getClient()
.prepareMultiSearch();
// should be faster than running the aggregations
// sent as a single multisearch
for (Status s : slist) {
SearchRequestBuilder request = connection.getClient()
.prepareSearch(indexName).setTypes(docType).setFrom(0)
.setSize(0).setExplain(false);
request.setQuery(QueryBuilders.termQuery("status", s.name()));
multi.add(request);
}
long start = System.currentTimeMillis();
MultiSearchResponse response = multi.get();
long end = System.currentTimeMillis();
LOG.info("Multiquery returned in {} msec", end - start);
for (int i = 0; i < response.getResponses().length; i++) {
SearchResponse res = response.getResponses()[i].getResponse();
long total = res.getHits().getTotalHits();
latestStatusCounts.put(slist[i].name(), total);
}
}