Committed by
Gerrit Code Review
Bug fix: make sure that divisor is non-zero value
Change-Id: I7214ebf552ba60db149db2b4edbb90f59d3bdd16
Showing
2 changed files
with
11 additions
and
2 deletions
| ... | @@ -28,6 +28,7 @@ import org.onosproject.cpman.message.ControlMessageProviderService; | ... | @@ -28,6 +28,7 @@ import org.onosproject.cpman.message.ControlMessageProviderService; |
| 28 | import org.onosproject.net.DeviceId; | 28 | import org.onosproject.net.DeviceId; |
| 29 | import org.projectfloodlight.openflow.protocol.OFMessage; | 29 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 30 | import org.projectfloodlight.openflow.protocol.OFType; | 30 | import org.projectfloodlight.openflow.protocol.OFType; |
| 31 | +import org.slf4j.Logger; | ||
| 31 | 32 | ||
| 32 | import java.util.ArrayList; | 33 | import java.util.ArrayList; |
| 33 | import java.util.Collection; | 34 | import java.util.Collection; |
| ... | @@ -36,12 +37,15 @@ import java.util.Map; | ... | @@ -36,12 +37,15 @@ import java.util.Map; |
| 36 | import java.util.Set; | 37 | import java.util.Set; |
| 37 | 38 | ||
| 38 | import static org.onosproject.provider.of.message.impl.OpenFlowControlMessageMapper.lookupControlMessageType; | 39 | import static org.onosproject.provider.of.message.impl.OpenFlowControlMessageMapper.lookupControlMessageType; |
| 40 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 39 | 41 | ||
| 40 | /** | 42 | /** |
| 41 | * Collects the OpenFlow messages and aggregates using MetricsService. | 43 | * Collects the OpenFlow messages and aggregates using MetricsService. |
| 42 | */ | 44 | */ |
| 43 | public class OpenFlowControlMessageAggregator implements Runnable { | 45 | public class OpenFlowControlMessageAggregator implements Runnable { |
| 44 | 46 | ||
| 47 | + private final Logger log = getLogger(getClass()); | ||
| 48 | + | ||
| 45 | private static final Set<OFType> OF_TYPE_SET = | 49 | private static final Set<OFType> OF_TYPE_SET = |
| 46 | ImmutableSet.of(OFType.PACKET_IN, OFType.PACKET_OUT, OFType.FLOW_MOD, | 50 | ImmutableSet.of(OFType.PACKET_IN, OFType.PACKET_OUT, OFType.FLOW_MOD, |
| 47 | OFType.FLOW_REMOVED, OFType.STATS_REQUEST, OFType.STATS_REPLY); | 51 | OFType.FLOW_REMOVED, OFType.STATS_REQUEST, OFType.STATS_REPLY); |
| ... | @@ -103,8 +107,10 @@ public class OpenFlowControlMessageAggregator implements Runnable { | ... | @@ -103,8 +107,10 @@ public class OpenFlowControlMessageAggregator implements Runnable { |
| 103 | new DefaultControlMessage(lookupControlMessageType(type), | 107 | new DefaultControlMessage(lookupControlMessageType(type), |
| 104 | getLoad(type), getRate(type), getCount(type), | 108 | getLoad(type), getRate(type), getCount(type), |
| 105 | System.currentTimeMillis()))); | 109 | System.currentTimeMillis()))); |
| 110 | + log.debug("sent aggregated control message"); | ||
| 106 | providerService.updateStatsInfo(deviceId, | 111 | providerService.updateStatsInfo(deviceId, |
| 107 | Collections.unmodifiableCollection(controlMessages)); | 112 | Collections.unmodifiableCollection(controlMessages)); |
| 113 | + controlMessages.clear(); | ||
| 108 | } | 114 | } |
| 109 | 115 | ||
| 110 | /** | 116 | /** |
| ... | @@ -114,8 +120,11 @@ public class OpenFlowControlMessageAggregator implements Runnable { | ... | @@ -114,8 +120,11 @@ public class OpenFlowControlMessageAggregator implements Runnable { |
| 114 | * @return load value | 120 | * @return load value |
| 115 | */ | 121 | */ |
| 116 | private long getLoad(OFType type) { | 122 | private long getLoad(OFType type) { |
| 123 | + if (countMeterMap.get(type).getOneMinuteRate() == 0D) { | ||
| 124 | + return 0L; | ||
| 125 | + } | ||
| 117 | return (long) rateMeterMap.get(type).getOneMinuteRate() / | 126 | return (long) rateMeterMap.get(type).getOneMinuteRate() / |
| 118 | - (long) countMeterMap.get(type).getOneMinuteRate(); | 127 | + (long) countMeterMap.get(type).getOneMinuteRate(); |
| 119 | } | 128 | } |
| 120 | 129 | ||
| 121 | /** | 130 | /** | ... | ... |
| ... | @@ -106,7 +106,7 @@ public class OpenFlowControlMessageProvider extends AbstractProvider | ... | @@ -106,7 +106,7 @@ public class OpenFlowControlMessageProvider extends AbstractProvider |
| 106 | controller.getSwitches().forEach(sw -> sw.addEventListener(outMsgListener)); | 106 | controller.getSwitches().forEach(sw -> sw.addEventListener(outMsgListener)); |
| 107 | 107 | ||
| 108 | executor = Executors.newSingleThreadScheduledExecutor( | 108 | executor = Executors.newSingleThreadScheduledExecutor( |
| 109 | - groupedThreads("onos/provider", "aggregator")); | 109 | + groupedThreads("onos/provider", "aggregator")); |
| 110 | 110 | ||
| 111 | connectInitialDevices(); | 111 | connectInitialDevices(); |
| 112 | log.info("Started"); | 112 | log.info("Started"); | ... | ... |
-
Please register or login to post a comment