Search in sources :

Example 1 with SpoutExecutor

use of org.apache.storm.executor.spout.SpoutExecutor 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 (ClientStatsUtil.SPOUT.equals(type)) {
        executor = new SpoutExecutor(workerState, executorId, credentials);
    } else {
        executor = new BoltExecutor(workerState, executorId, credentials);
    }
    int minId = Integer.MAX_VALUE;
    Map<Integer, Task> idToTask = new HashMap<>();
    for (Integer taskId : taskIds) {
        minId = Math.min(minId, taskId);
        try {
            Task task = new Task(executor, taskId);
            idToTask.put(taskId, task);
        } catch (IOException ex) {
            throw Utils.wrapInRuntime(ex);
        }
    }
    executor.idToTaskBase = minId;
    executor.idToTask = Utils.convertToArray(idToTask, minId);
    return executor;
}
Also used : Task(org.apache.storm.daemon.Task) 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) HashMap(java.util.HashMap) IOException(java.io.IOException) BoltExecutor(org.apache.storm.executor.bolt.BoltExecutor)

Aggregations

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 WorkerTopologyContext (org.apache.storm.task.WorkerTopologyContext)1