use of org.apache.storm.tuple.AddressedTuple in project storm by apache.
the class Executor method setupTicks.
protected void setupTicks(boolean isSpout) {
final Integer tickTimeSecs = Utils.getInt(stormConf.get(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS), null);
boolean enableMessageTimeout = (Boolean) stormConf.get(Config.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS);
if (tickTimeSecs != null) {
if (Utils.isSystemId(componentId) || (!enableMessageTimeout && isSpout)) {
LOG.info("Timeouts disabled for executor " + componentId + ":" + executorId);
} else {
StormTimer timerTask = workerData.getUserTimer();
timerTask.scheduleRecurring(tickTimeSecs, tickTimeSecs, new Runnable() {
@Override
public void run() {
TupleImpl tuple = new TupleImpl(workerTopologyContext, new Values(tickTimeSecs), (int) Constants.SYSTEM_TASK_ID, Constants.SYSTEM_TICK_STREAM_ID);
List<AddressedTuple> tickTuple = Lists.newArrayList(new AddressedTuple(AddressedTuple.BROADCAST_DEST, tuple));
receiveQueue.publish(tickTuple);
}
});
}
}
}
use of org.apache.storm.tuple.AddressedTuple in project storm by apache.
the class Executor method onEvent.
@SuppressWarnings("unchecked")
@Override
public void onEvent(Object event, long seq, boolean endOfBatch) throws Exception {
ArrayList<AddressedTuple> addressedTuples = (ArrayList<AddressedTuple>) event;
for (AddressedTuple addressedTuple : addressedTuples) {
TupleImpl tuple = (TupleImpl) addressedTuple.getTuple();
int taskId = addressedTuple.getDest();
if (isDebug) {
LOG.info("Processing received message FOR {} TUPLE: {}", taskId, tuple);
}
if (taskId != AddressedTuple.BROADCAST_DEST) {
tupleActionFn(taskId, tuple);
} else {
for (Integer t : taskIds) {
tupleActionFn(t, tuple);
}
}
}
}
use of org.apache.storm.tuple.AddressedTuple in project storm by apache.
the class ExecutorShutdown method credentialsChanged.
@Override
public void credentialsChanged(Credentials credentials) {
TupleImpl tuple = new TupleImpl(executor.getWorkerTopologyContext(), new Values(credentials), (int) Constants.SYSTEM_TASK_ID, Constants.CREDENTIALS_CHANGED_STREAM_ID);
List<AddressedTuple> addressedTuple = Lists.newArrayList(new AddressedTuple(AddressedTuple.BROADCAST_DEST, tuple));
executor.getReceiveQueue().publish(addressedTuple);
}
use of org.apache.storm.tuple.AddressedTuple in project storm by apache.
the class ExecutorTransfer method transfer.
public void transfer(int task, Tuple tuple) {
AddressedTuple val = new AddressedTuple(task, tuple);
if (isDebug) {
LOG.info("TRANSFERRING tuple {}", val);
}
batchTransferQueue.publish(val);
}
use of org.apache.storm.tuple.AddressedTuple in project storm by apache.
the class WorkerState method transfer.
public void transfer(KryoTupleSerializer serializer, List<AddressedTuple> tupleBatch) {
if (trySerializeLocal) {
assertCanSerialize(serializer, tupleBatch);
}
List<AddressedTuple> local = new ArrayList<>();
Map<Integer, List<TaskMessage>> remoteMap = new HashMap<>();
for (AddressedTuple addressedTuple : tupleBatch) {
int destTask = addressedTuple.getDest();
if (taskIds.contains(destTask)) {
// Local task
local.add(addressedTuple);
} else {
// Using java objects directly to avoid performance issues in java code
if (!remoteMap.containsKey(destTask)) {
remoteMap.put(destTask, new ArrayList<>());
}
remoteMap.get(destTask).add(new TaskMessage(destTask, serializer.serialize(addressedTuple.getTuple())));
}
}
if (!local.isEmpty()) {
transferLocal(local);
}
if (!remoteMap.isEmpty()) {
transferQueue.publish(remoteMap);
}
}
Aggregations