@Override public void write(OFMessage m) { if (!isConnected()) { if (logger.isDebugEnabled()) logger.debug("{}: not connected - dropping message {}", this, m); return; } if (logger.isDebugEnabled()) logger.debug("{}: send {}", this, m); List<OFMessage> msgBuffer = localMsgBuffer.get(); if (msgBuffer == null) { msgBuffer = new ArrayList<OFMessage>(); localMsgBuffer.set(msgBuffer); } counters.updateWriteStats(m); msgBuffer.add(m); if ((msgBuffer.size() >= Controller.BATCH_MAX_SIZE) || ((m.getType() != OFType.PACKET_OUT) && (m.getType() != OFType.FLOW_MOD))) { this.write(msgBuffer); localMsgBuffer.set(null); } }
@Override public void write(OFMessage m, FloodlightContext bc) { if (channel == null || !isConnected()) return; //throws IOException { Map<IOFSwitch,List<OFMessage>> msg_buffer_map = local_msg_buffer.get(); List<OFMessage> msg_buffer = msg_buffer_map.get(this); if (msg_buffer == null) { msg_buffer = new ArrayList<OFMessage>(); msg_buffer_map.put(this, msg_buffer); } this.floodlightProvider.handleOutgoingMessage(this, m, bc); msg_buffer.add(m); if ((msg_buffer.size() >= Controller.BATCH_MAX_SIZE) || ((m.getType() != OFType.PACKET_OUT) && (m.getType() != OFType.FLOW_MOD))) { this.write(msg_buffer); msg_buffer.clear(); } }
@Override public void write(OFMessage m, FloodlightContext bc) throws IOException { Map<IOFSwitch,List<OFMessage>> msg_buffer_map = local_msg_buffer.get(); List<OFMessage> msg_buffer = msg_buffer_map.get(this); if (msg_buffer == null) { msg_buffer = new ArrayList<OFMessage>(); msg_buffer_map.put(this, msg_buffer); } this.floodlightProvider.handleOutgoingMessage(this, m, bc); msg_buffer.add(m); if ((msg_buffer.size() >= Controller.BATCH_MAX_SIZE) || ((m.getType() != OFType.PACKET_OUT) && (m.getType() != OFType.FLOW_MOD))) { this.write(msg_buffer); msg_buffer.clear(); } }
/** * Compute the maximum number of flows to be reconciled. * * It computes the packetIn increment from the counter values in * the counter store; * Then computes the rate based on the elapsed time * from the last query; * Then compute the max flow reconcile rate by subtracting the packetIn * rate from the hard-coded max system rate. * If the system rate is reached or less than MIN_FLOW_RECONCILE_PER_SECOND, * set the maximum flow reconcile rate to the MIN_FLOW_RECONCILE_PER_SECOND * to prevent starvation. * Then convert the rate to an absolute number for the * FLOW_RECONCILE_PERIOD. * @return */ protected int getCurrentCapacity() { int minFlows = MIN_FLOW_RECONCILE_PER_SECOND * FLOW_RECONCILE_DELAY_MILLISEC / 1000; List<DebugCounterResource> contCtrRsrcList = debugCounterService.getModuleCounterValues(Controller.class.getName()); for (DebugCounterResource dcr : contCtrRsrcList) { if (dcr.getCounterHierarchy().equals("packet-in")) { ctrPacketInRsrc = dcr; break; } } // If no packetInCounter, then there shouldn't be any flow. if (ctrPacketInRsrc == null || ctrPacketInRsrc.getCounterValue() == null || ctrPacketInRsrc.getCounterValue() == 0) { logger.debug("counter {} doesn't exist", ctrPacketInRsrc); return minFlows; } // We're the first packet_in if (lastPacketInCounter.getCounterValue() == 0) { logger.debug("First time get the count for {}", lastPacketInCounter); return minFlows; } int pktInRate = getPktInRate(ctrPacketInRsrc, new Date()); // Update the last packetInCounter lastPacketInCounter.reset(); int capacity = minFlows; if ((pktInRate + MIN_FLOW_RECONCILE_PER_SECOND) <= MAX_SYSTEM_LOAD_PER_SECOND) { capacity = (MAX_SYSTEM_LOAD_PER_SECOND - pktInRate) * FLOW_RECONCILE_DELAY_MILLISEC / 1000; } if (logger.isTraceEnabled()) { logger.trace("Capacity is {}", capacity); } return capacity; }
@Override public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() { controller = new Controller(); Map<Class<? extends IFloodlightService>, IFloodlightService> m = new HashMap<Class<? extends IFloodlightService>, IFloodlightService>(); m.put(IFloodlightProviderService.class, controller); return m; }