use of org.apache.storm.tuple.AddressedTuple in project storm by apache.
the class DeserializingConnectionCallback method recv.
@Override
public void recv(List<TaskMessage> batch) {
KryoTupleDeserializer des = _des.get();
ArrayList<AddressedTuple> ret = new ArrayList<>(batch.size());
for (TaskMessage message : batch) {
ret.add(new AddressedTuple(message.task(), des.deserialize(message.message())));
}
_cb.transfer(ret);
}
use of org.apache.storm.tuple.AddressedTuple in project storm by apache.
the class WorkerState method transferLocal.
public void transferLocal(List<AddressedTuple> tupleBatch) {
Map<Integer, List<AddressedTuple>> grouped = new HashMap<>();
for (AddressedTuple tuple : tupleBatch) {
Integer executor = taskToShortExecutor.get(tuple.dest);
if (null == executor) {
LOG.warn("Received invalid messages for unknown tasks. Dropping... ");
continue;
}
List<AddressedTuple> current = grouped.get(executor);
if (null == current) {
current = new ArrayList<>();
grouped.put(executor, current);
}
current.add(tuple);
}
for (Map.Entry<Integer, List<AddressedTuple>> entry : grouped.entrySet()) {
DisruptorQueue queue = shortExecutorReceiveQueueMap.get(entry.getKey());
if (null != queue) {
queue.publish(entry.getValue());
} else {
LOG.warn("Received invalid messages for unknown tasks. Dropping... ");
}
}
}
use of org.apache.storm.tuple.AddressedTuple in project storm by apache.
the class Executor method setupMetrics.
protected void setupMetrics() {
for (final Integer interval : intervalToTaskToMetricToRegistry.keySet()) {
StormTimer timerTask = workerData.getUserTimer();
timerTask.scheduleRecurring(interval, interval, new Runnable() {
@Override
public void run() {
TupleImpl tuple = new TupleImpl(workerTopologyContext, new Values(interval), (int) Constants.SYSTEM_TASK_ID, Constants.METRICS_TICK_STREAM_ID);
List<AddressedTuple> metricsTickTuple = Lists.newArrayList(new AddressedTuple(AddressedTuple.BROADCAST_DEST, tuple));
receiveQueue.publish(metricsTickTuple);
}
});
}
}
Aggregations