/** * Create a map of queues to switches, with each queue grouped by port number. * @param queueBandwidthMap * @param switchMap * @param switchPortMap * @return HashMap<IOFSwitch, HashMap<Integer, ArrayList<FlowQueue>>>, ArrayList<FlowQueue> per port number per switch */ public HashMap<IOFSwitch, HashMap<Integer, ArrayList<FlowQueue>>> createQueueMap(HashMap<Long, Long> queueBandwidthMap, Map<DatapathId, IOFSwitch> switchMap, HashMap<IOFSwitch, ArrayList<OFPortDesc>> switchPortMap){ HashMap<IOFSwitch, HashMap<Integer, ArrayList<FlowQueue>>> queueMap = new HashMap<IOFSwitch, HashMap<Integer, ArrayList<FlowQueue>>>(); for(IOFSwitch thisSwitch : switchMap.values()){ HashMap<Integer, ArrayList<FlowQueue>> portQueueMap = new HashMap<Integer, ArrayList<FlowQueue>>(); for(OFPortDesc portDesc : switchPortMap.get(thisSwitch)){ ArrayList<FlowQueue> queuesThisPort = new ArrayList<FlowQueue>(); OFQueueGetConfigRequest cr = arscheduler.of13Factory.buildQueueGetConfigRequest().setPort(portDesc.getPortNo()).build(); // Get all queues on all ports ListenableFuture<OFQueueGetConfigReply> future = thisSwitch.writeRequest(cr); // Send request to switch 1 try { // Wait up to 10s for a reply; return when received; else exception thrown OFQueueGetConfigReply reply = future.get(10, TimeUnit.SECONDS); // Iterate over all queues for (OFPacketQueue q : reply.getQueues()) { ///queues.add(q); if(q.getQueueId() == 0) continue; FlowQueue newQueue = new FlowQueue(portDesc.getPortNo().getPortNumber(), q.getQueueId(), queueBandwidthMap.get(Long.valueOf(q.getQueueId()))); queuesThisPort.add(newQueue); } int portNum = portDesc.getPortNo().getPortNumber(); portQueueMap.put(Integer.valueOf(portNum), queuesThisPort); } catch (InterruptedException | ExecutionException | TimeoutException e) { e.printStackTrace(); } } queueMap.put(thisSwitch, portQueueMap); } return queueMap; }