/** * This method can only be used to update packetRemote and flowmod counters NOTE: flowmod is * counted per switch and for controller, not per port/proto * * @param sw * @param m */ public void updatePktRemoteFMCounterStore(IOFSwitch sw, OFMessage m) { List<ICounter> counters = this.getPktRemoteFMCounters(sw, m); if (counters != null) { for (ICounter c : counters) { c.increment(); } } return; }
public void updatePacketInCounters(IOFSwitch sw, OFMessage m, Ethernet eth) { if (((OFPacketIn) m).getPacketData().length <= 0) { return; } List<ICounter> counters = this.getPacketInCounters(sw, m, eth); if (counters != null) { for (ICounter c : counters) { c.increment(); } } return; }
@Override public void updateFlush() { Date date = new Date(); Map<String, MutableInt> pktin_buffer = this.pktin_local_buffer.get(); for (String key : pktin_buffer.keySet()) { MutableInt currval = pktin_buffer.get(key); int delta = currval.get(); if (delta > 0) { List<ICounter> counters = this.pktinCounters.get(key); if (counters != null) { for (ICounter c : counters) { c.increment(date, delta); } } } } // We could do better "GC" of counters that have not been update "recently" pktin_buffer.clear(); Map<String, MutableInt> pktout_buffer = this.pktout_local_buffer.get(); for (String key : pktout_buffer.keySet()) { MutableInt currval = pktout_buffer.get(key); int delta = currval.get(); if (delta > 0) { List<ICounter> counters = this.pktoutCounters.get(key); if (counters != null) { for (ICounter c : counters) { c.increment(date, delta); } } } } // We could do better "GC" of counters that have not been update "recently" pktout_buffer.clear(); }
@Override public String recieveMessage(ICounter callback, boolean useCounter) throws IOException { this.recieving = false; final char endata = '+'; char[] buffer = new char[1024]; int byteread = 0; // bytes devueltos del read() int pos = 0; // update last firmware, the last firware send the message recieved if (BluetoothService.inputStream != null) { // if (BluetoothService.btSocket.isConnected()) { int comandRead = BluetoothService.inputStream.read(); Log.i(kdUINOApplication.TAG, "Command received from kduino: " + (char) comandRead); callback.receivedCommand((char) comandRead); } StringBuilder sb = new StringBuilder(); int counter = 0; int total = 0; boolean firstRead = true; do { try { if (BluetoothService.inputStream != null) { // if (BluetoothService.btSocket.isConnected()) { byteread = BluetoothService.inputStream.read(); } else { return ""; } // } /*else { new Handler(Looper.getMainLooper()) .post(new Runnable() { @Override public void run() { bus.post(new KdUinoMessageBusEvent(KdUINOMessages.BLUETOOTH_ERROR, null)); } }); }*/ } catch (IOException io) { this.view.post( new Runnable() { @Override public void run() { try { ((kdUINOApplication) context.getApplicationContext()) .getBus() .post(new KdUinoMessageBusEvent(KdUINOMessages.BLUETOOTH_ERROR, null)); } catch (Exception ex) { Log.e(kdUINOApplication.TAG, "Error sending message", ex); } } }); /*new Handler(Looper.getMainLooper()) .post(new Runnable() { @Override public void run() { bus.post(new KdUinoMessageBusEvent(KdUINOMessages.BLUETOOTH_ERROR, null)); } }); */ Log.e(kdUINOApplication.TAG, "Error inputstrem bluetooth", io); return ""; } recieving = true; if (pos < 1024) { buffer[pos++] = (char) byteread; if (useCounter) { if (byteread == 0x0D) { if (callback != null) { callback.updateData(counter); } counter++; } else if (byteread == 32) { if (firstRead) { String value = new String(buffer).trim(); if (value.matches("\\d+")) { total = Integer.parseInt(value); if (total == 0) { recieving = false; return "0+"; } callback.totalCounter(total); } firstRead = false; } } } } else { String message = new String(buffer); sb.append(message); buffer = new char[1024]; pos = 0; buffer[pos] = (char) byteread; } } while ((char) byteread != endata); recieving = false; String message = new String(buffer); sb.append(message); return sb.toString().trim(); }