Search in sources :

Example 1 with BoltExecutorStats

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

the class BoltOutputCollectorImpl method ack.

@Override
public void ack(Tuple input) {
    long ackValue = ((TupleImpl) input).getAckVal();
    Map<Long, Long> anchorsToIds = input.getMessageId().getAnchorsToIds();
    for (Map.Entry<Long, Long> entry : anchorsToIds.entrySet()) {
        executor.sendUnanchored(taskData, Acker.ACKER_ACK_STREAM_ID, new Values(entry.getKey(), Utils.bitXor(entry.getValue(), ackValue)), executor.getExecutorTransfer());
    }
    long delta = tupleTimeDelta((TupleImpl) input);
    if (isDebug) {
        LOG.info("BOLT ack TASK: {} TIME: {} TUPLE: {}", taskId, delta, input);
    }
    BoltAckInfo boltAckInfo = new BoltAckInfo(input, taskId, delta);
    boltAckInfo.applyOn(taskData.getUserContext());
    if (delta != 0) {
        ((BoltExecutorStats) executor.getStats()).boltAckedTuple(input.getSourceComponent(), input.getSourceStreamId(), delta);
    }
}
Also used : BoltAckInfo(org.apache.storm.hooks.info.BoltAckInfo) BoltExecutorStats(org.apache.storm.stats.BoltExecutorStats) Values(org.apache.storm.tuple.Values) TupleImpl(org.apache.storm.tuple.TupleImpl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with BoltExecutorStats

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

the class BoltOutputCollectorImpl method fail.

@Override
public void fail(Tuple input) {
    Set<Long> roots = input.getMessageId().getAnchors();
    for (Long root : roots) {
        executor.sendUnanchored(taskData, Acker.ACKER_FAIL_STREAM_ID, new Values(root), executor.getExecutorTransfer());
    }
    long delta = tupleTimeDelta((TupleImpl) input);
    if (isDebug) {
        LOG.info("BOLT fail TASK: {} TIME: {} TUPLE: {}", taskId, delta, input);
    }
    BoltFailInfo boltFailInfo = new BoltFailInfo(input, taskId, delta);
    boltFailInfo.applyOn(taskData.getUserContext());
    if (delta != 0) {
        ((BoltExecutorStats) executor.getStats()).boltFailedTuple(input.getSourceComponent(), input.getSourceStreamId(), delta);
    }
}
Also used : BoltExecutorStats(org.apache.storm.stats.BoltExecutorStats) BoltFailInfo(org.apache.storm.hooks.info.BoltFailInfo) Values(org.apache.storm.tuple.Values)

Example 3 with BoltExecutorStats

use of org.apache.storm.stats.BoltExecutorStats 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)

Aggregations

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