use of backtype.storm.tuple.ITupleExt in project jstorm by alibaba.
the class DrainerCtrlRunable method serialize.
protected byte[] serialize(ITupleExt tuple) {
byte[] bytes = null;
KryoTupleSerializer kryo = atomKryoSerializer.get();
if (kryo != null) {
bytes = kryo.serialize((TupleExt) tuple);
} else {
LOG.warn("KryoTupleSerializer is null, so drop tuple...");
}
return bytes;
}
use of backtype.storm.tuple.ITupleExt in project jstorm by alibaba.
the class DrainerCtrlRunable method handleEvent.
@Override
public void handleEvent(Object event, boolean endOfBatch) throws Exception {
if (event == null) {
return;
}
ITupleExt tuple = (ITupleExt) event;
int targetTask = tuple.getTargetTaskId();
IConnection conn = getConnection(targetTask);
if (conn != null) {
byte[] tupleMessage = null;
try {
//it maybe happened errors when update_topology
tupleMessage = serialize(tuple);
} catch (Throwable e) {
if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e)) {
throw new RuntimeException(e);
} else {
LOG.warn("serialize happened errors!!!", e);
}
}
TaskMessage message = new TaskMessage((short) TaskMessage.CONTROL_MESSAGE, targetTask, tupleMessage);
conn.send(message);
}
}
use of backtype.storm.tuple.ITupleExt in project jstorm by alibaba.
the class TaskTransfer method serialize.
protected void serialize(KryoTupleSerializer serializer, Object event) {
long start = serializeTimer.getTime();
try {
ITupleExt tuple = (ITupleExt) event;
int targetTaskid = tuple.getTargetTaskId();
IConnection conn = getConnection(targetTaskid);
if (conn != null) {
byte[] tupleMessage = serializer.serialize((TupleExt) tuple);
//LOG.info("Task-{} sent msg to task-{}, data={}", task.getTaskId(), taskid, JStormUtils.toPrintableString(tupleMessage));
TaskMessage taskMessage = new TaskMessage(targetTaskid, tupleMessage);
conn.send(taskMessage);
} else {
LOG.error("Can not find connection for task-{}", targetTaskid);
}
} finally {
if (MetricUtils.metricAccurateCal)
serializeTimer.updateTime(start);
}
}
Aggregations