Search in sources :

Example 1 with IWaitStrategy

use of org.apache.storm.policy.IWaitStrategy in project storm by apache.

the class WorkerState method mkReceiveQueueMap.

private Map<List<Long>, JCQueue> mkReceiveQueueMap(Map<String, Object> topologyConf, Set<List<Long>> executors, Map<Integer, String> taskToComponent) {
    Integer recvQueueSize = ObjectReader.getInt(topologyConf.get(Config.TOPOLOGY_EXECUTOR_RECEIVE_BUFFER_SIZE));
    Integer recvBatchSize = ObjectReader.getInt(topologyConf.get(Config.TOPOLOGY_PRODUCER_BATCH_SIZE));
    Integer overflowLimit = ObjectReader.getInt(topologyConf.get(Config.TOPOLOGY_EXECUTOR_OVERFLOW_LIMIT));
    if (recvBatchSize > recvQueueSize / 2) {
        throw new IllegalArgumentException(Config.TOPOLOGY_PRODUCER_BATCH_SIZE + ":" + recvBatchSize + " is greater than half of " + Config.TOPOLOGY_EXECUTOR_RECEIVE_BUFFER_SIZE + ":" + recvQueueSize);
    }
    IWaitStrategy backPressureWaitStrategy = IWaitStrategy.createBackPressureWaitStrategy(topologyConf);
    Map<List<Long>, JCQueue> receiveQueueMap = new HashMap<>();
    for (List<Long> executor : executors) {
        List<Integer> taskIds = StormCommon.executorIdToTasks(executor);
        int taskId = taskIds.get(0);
        String compId;
        if (taskId == Constants.SYSTEM_TASK_ID) {
            compId = Constants.SYSTEM_COMPONENT_ID;
        } else {
            compId = taskToComponent.get(taskId);
        }
        receiveQueueMap.put(executor, new JCQueue("receive-queue" + executor.toString(), "receive-queue", recvQueueSize, overflowLimit, recvBatchSize, backPressureWaitStrategy, this.getTopologyId(), compId, taskIds, this.getPort(), metricRegistry));
    }
    return receiveQueueMap;
}
Also used : JCQueue(org.apache.storm.utils.JCQueue) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) ArrayList(java.util.ArrayList) IWaitStrategy(org.apache.storm.policy.IWaitStrategy)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IWaitStrategy (org.apache.storm.policy.IWaitStrategy)1 JCQueue (org.apache.storm.utils.JCQueue)1