Search in sources :

Example 1 with SpoutExecutorStats

use of org.apache.storm.stats.SpoutExecutorStats in project storm by apache.

the class SpoutExecutor method ackSpoutMsg.

public void ackSpoutMsg(Executor executor, Task taskData, Long timeDelta, TupleInfo tupleInfo) {
    try {
        ISpout spout = (ISpout) taskData.getTaskObject();
        int taskId = taskData.getTaskId();
        if (executor.getIsDebug()) {
            LOG.info("SPOUT Acking message {} {}", tupleInfo.getId(), tupleInfo.getMessageId());
        }
        spout.ack(tupleInfo.getMessageId());
        new SpoutAckInfo(tupleInfo.getMessageId(), taskId, timeDelta).applyOn(taskData.getUserContext());
        if (timeDelta != null) {
            ((SpoutExecutorStats) executor.getStats()).spoutAckedTuple(tupleInfo.getStream(), timeDelta);
        }
    } catch (Exception e) {
        throw Utils.wrapInRuntime(e);
    }
}
Also used : SpoutExecutorStats(org.apache.storm.stats.SpoutExecutorStats) ISpout(org.apache.storm.spout.ISpout) SpoutAckInfo(org.apache.storm.hooks.info.SpoutAckInfo)

Example 2 with SpoutExecutorStats

use of org.apache.storm.stats.SpoutExecutorStats in project storm by apache.

the class Executor method mkExecutor.

public static Executor mkExecutor(WorkerState workerState, List<Long> executorId, Map<String, String> credentials) {
    Executor executor;
    WorkerTopologyContext workerTopologyContext = workerState.getWorkerTopologyContext();
    List<Integer> taskIds = StormCommon.executorIdToTasks(executorId);
    String componentId = workerTopologyContext.getComponentId(taskIds.get(0));
    String type = getExecutorType(workerTopologyContext, componentId);
    if (StatsUtil.SPOUT.equals(type)) {
        executor = new SpoutExecutor(workerState, executorId, credentials);
        executor.stats = new SpoutExecutorStats(ConfigUtils.samplingRate(executor.getStormConf()));
    } else {
        executor = new BoltExecutor(workerState, executorId, credentials);
        executor.stats = new BoltExecutorStats(ConfigUtils.samplingRate(executor.getStormConf()));
    }
    Map<Integer, Task> idToTask = new HashMap<>();
    for (Integer taskId : taskIds) {
        try {
            Task task = new Task(executor, taskId);
            executor.sendUnanchored(task, StormCommon.SYSTEM_STREAM_ID, new Values("startup"), executor.getExecutorTransfer());
            idToTask.put(taskId, task);
        } catch (IOException ex) {
            throw Utils.wrapInRuntime(ex);
        }
    }
    executor.idToTask = idToTask;
    return executor;
}
Also used : Task(org.apache.storm.daemon.Task) HashMap(java.util.HashMap) Values(org.apache.storm.tuple.Values) IOException(java.io.IOException) BoltExecutorStats(org.apache.storm.stats.BoltExecutorStats) SpoutExecutor(org.apache.storm.executor.spout.SpoutExecutor) BoltExecutor(org.apache.storm.executor.bolt.BoltExecutor) WorkerTopologyContext(org.apache.storm.task.WorkerTopologyContext) SpoutExecutor(org.apache.storm.executor.spout.SpoutExecutor) SpoutExecutorStats(org.apache.storm.stats.SpoutExecutorStats) BoltExecutor(org.apache.storm.executor.bolt.BoltExecutor)

Example 3 with SpoutExecutorStats

use of org.apache.storm.stats.SpoutExecutorStats in project storm by apache.

the class SpoutExecutor method failSpoutMsg.

public void failSpoutMsg(Executor executor, Task taskData, Long timeDelta, TupleInfo tupleInfo, String reason) {
    try {
        ISpout spout = (ISpout) taskData.getTaskObject();
        int taskId = taskData.getTaskId();
        if (executor.getIsDebug()) {
            LOG.info("SPOUT Failing {} : {} REASON: {}", tupleInfo.getId(), tupleInfo, reason);
        }
        spout.fail(tupleInfo.getMessageId());
        new SpoutFailInfo(tupleInfo.getMessageId(), taskId, timeDelta).applyOn(taskData.getUserContext());
        if (timeDelta != null) {
            ((SpoutExecutorStats) executor.getStats()).spoutFailedTuple(tupleInfo.getStream(), timeDelta);
        }
    } catch (Exception e) {
        throw Utils.wrapInRuntime(e);
    }
}
Also used : SpoutExecutorStats(org.apache.storm.stats.SpoutExecutorStats) SpoutFailInfo(org.apache.storm.hooks.info.SpoutFailInfo) ISpout(org.apache.storm.spout.ISpout)

Aggregations

SpoutExecutorStats (org.apache.storm.stats.SpoutExecutorStats)3 ISpout (org.apache.storm.spout.ISpout)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Task (org.apache.storm.daemon.Task)1 BoltExecutor (org.apache.storm.executor.bolt.BoltExecutor)1 SpoutExecutor (org.apache.storm.executor.spout.SpoutExecutor)1 SpoutAckInfo (org.apache.storm.hooks.info.SpoutAckInfo)1 SpoutFailInfo (org.apache.storm.hooks.info.SpoutFailInfo)1 BoltExecutorStats (org.apache.storm.stats.BoltExecutorStats)1 WorkerTopologyContext (org.apache.storm.task.WorkerTopologyContext)1 Values (org.apache.storm.tuple.Values)1