public boolean collect(OFStatisticsReply reply) { synchronized (result) { stats.addAll(reply.getStatistics()); if ((reply.getFlags() & 0x01) == 0) { // all stats are collected, done result = stats; return true; } else { // still waiting for more to come return false; } } }
@Override public OFMessage instantiate() { return new OFStatisticsReply(); } }), BARRIER_REQUEST(18, OFBarrierRequest.class,
private void processStatsReply(OFStatisticsReply reply) { Integer xid = reply.getXid(); StatisticsCollector worker = (StatisticsCollector) messageWaitingDone.get(xid); if (worker == null) { return; } if (worker.collect(reply)) { // if all the stats records are received (collect() returns true) // then we are done. messageWaitingDone.remove(xid); worker.wakeup(); } }
@Override void processOFStatisticsReply(final SwitchChannelHandler h, final OFStatisticsReply m) { // Read description, if it has been updated final OVXDescriptionStatistics description = new OVXDescriptionStatistics(); final ChannelBuffer data = ChannelBuffers.buffer(description .getLength()); final OFStatistics f = m.getFirstStatistics(); f.writeTo(data); description.readFrom(data); OFFlowMod fm = new OFFlowMod(); fm.setCommand(OFFlowMod.OFPFC_DELETE); fm.setMatch(new OFMatch()); h.channel.write(Collections.singletonList(fm)); h.sw = new PhysicalSwitch(h.featuresReply.getDatapathId()); // set switch information // set features reply and channel first so we have a DPID and // channel info. h.sw.setFeaturesReply(h.featuresReply); h.sw.setDescriptionStats(description); h.sw.setConnected(true); h.sw.setChannel(h.channel); for (final OFPortStatus ps : h.pendingPortStatusMsg) { this.handlePortStatusMessage(h, ps); } h.pendingPortStatusMsg.clear(); h.sw.boot(); h.setState(ACTIVE); }
private void processStatsReply(OFStatisticsReply reply) { Integer xid = reply.getXid(); StatisticsCollector worker = (StatisticsCollector) messageWaitingDone .get(xid); if (worker == null) { return; } if (worker.collect(reply)) { // if all the stats records are received (collect() returns true) // then we are done. messageWaitingDone.remove(xid); worker.wakeup(); } }
public boolean collect(OFStatisticsReply reply) { synchronized (result) { stats.addAll(reply.getStatistics()); if ((reply.getFlags() & 0x01) == 0) { // all stats are collected, done result = stats; return true; } else { // still waiting for more to come return false; } } }