Committed by
Gerrit Code Review
[Emu] openTAM: NewAdaptiveFlowStatsCollector Implementation
- NewAdaptiveFlowStatsCollector.java .Bug fix to initialize callCountCalAndShortFlowsTask value .Added flowMissingXid variable to identify individual StatsRequest or match all StatsRequest message or not - DefaultTypedFlowEntry.java, TypedStoredFlowEntry.java .Added javadoc for class - OpenFlowRuleProvider.java .Line 2: 2014 -> 2015 .Added adaptiveFlowSampling boolean property with default .Added call providerService.pushFlowMetricsWithoutFlowMissing in case of individual StatsRequest - FlowRuleProviderService.java .Added pushFlowMetricsWithoutFlowMissing() function - FlowRuleManager.java .Added pushFlowMetricsWithoutFlowMissing() implementation - OpenFlowControllerImpl.java .Bug fix to unchange the StatsRequest Xid value in case of StatsReply Flow message type Change-Id: Id4dc4a164da654af7b6dfb090af7336e748ef118
Showing
7 changed files
with
219 additions
and
9 deletions
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +package org.onosproject.net.flow; | ||
| 18 | + | ||
| 19 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * Default flow entry class with FlowLiveType value, IMMEDIATE_FLOW, SHORT_FLOW, MID_FLOW, LONG_FLOW. | ||
| 23 | + */ | ||
| 24 | +public class DefaultTypedFlowEntry extends DefaultFlowEntry | ||
| 25 | + implements TypedStoredFlowEntry { | ||
| 26 | + private FlowLiveType liveType; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * Creates a typed flow entry from flow rule and its statistics, with default flow live type(IMMEDIATE_FLOW). | ||
| 30 | + * | ||
| 31 | + * @param rule the flow rule | ||
| 32 | + * @param state the flow state | ||
| 33 | + * @param life the flow duration since creation | ||
| 34 | + * @param packets the flow packets count | ||
| 35 | + * @param bytes the flow bytes count | ||
| 36 | + * | ||
| 37 | + */ | ||
| 38 | + public DefaultTypedFlowEntry(FlowRule rule, FlowEntryState state, | ||
| 39 | + long life, long packets, long bytes) { | ||
| 40 | + super(rule, state, life, packets, bytes); | ||
| 41 | + this.liveType = FlowLiveType.IMMEDIATE_FLOW; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Creates a typed flow entry from flow rule, with default flow live type(IMMEDIATE_FLOW). | ||
| 46 | + * | ||
| 47 | + * @param rule the flow rule | ||
| 48 | + * | ||
| 49 | + */ | ||
| 50 | + public DefaultTypedFlowEntry(FlowRule rule) { | ||
| 51 | + super(rule); | ||
| 52 | + this.liveType = FlowLiveType.IMMEDIATE_FLOW; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * Creates a typed flow entry from flow entry, with default flow live type(IMMEDIATE_FLOW). | ||
| 57 | + * | ||
| 58 | + * @param fe the flow entry | ||
| 59 | + * | ||
| 60 | + */ | ||
| 61 | + public DefaultTypedFlowEntry(FlowEntry fe) { | ||
| 62 | + super(fe, fe.state(), fe.life(), fe.packets(), fe.bytes()); | ||
| 63 | + this.liveType = FlowLiveType.IMMEDIATE_FLOW; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * Creates a typed flow entry from flow rule and flow live type. | ||
| 68 | + * | ||
| 69 | + * @param rule the flow rule | ||
| 70 | + * @param liveType the flow live type | ||
| 71 | + * | ||
| 72 | + */ | ||
| 73 | + public DefaultTypedFlowEntry(FlowRule rule, FlowLiveType liveType) { | ||
| 74 | + super(rule); | ||
| 75 | + this.liveType = liveType; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * Creates a typed flow entry from flow entry and flow live type. | ||
| 80 | + * | ||
| 81 | + * @param fe the flow rule | ||
| 82 | + * @param liveType the flow live type | ||
| 83 | + * | ||
| 84 | + */ | ||
| 85 | + public DefaultTypedFlowEntry(FlowEntry fe, FlowLiveType liveType) { | ||
| 86 | + super(fe, fe.state(), fe.life(), fe.packets(), fe.bytes()); | ||
| 87 | + this.liveType = liveType; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * Creates a typed flow entry from flow rule, error code and flow live type. | ||
| 92 | + * | ||
| 93 | + * @param rule the flow rule | ||
| 94 | + * @param errType the flow error type | ||
| 95 | + * @param errCode the flow error code | ||
| 96 | + * @param liveType the flow live type | ||
| 97 | + * | ||
| 98 | + */ | ||
| 99 | + public DefaultTypedFlowEntry(FlowRule rule, int errType, int errCode, FlowLiveType liveType) { | ||
| 100 | + super(rule, errType, errCode); | ||
| 101 | + this.liveType = liveType; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @Override | ||
| 105 | + public FlowLiveType flowLiveType() { | ||
| 106 | + return this.liveType; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + @Override | ||
| 110 | + public void setFlowLiveType(FlowLiveType liveType) { | ||
| 111 | + this.liveType = liveType; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + @Override | ||
| 115 | + public String toString() { | ||
| 116 | + return toStringHelper(this) | ||
| 117 | + .add("entry", super.toString()) | ||
| 118 | + .add("type", liveType) | ||
| 119 | + .toString(); | ||
| 120 | + } | ||
| 121 | +} | ||
| 122 | + |
| ... | @@ -41,6 +41,15 @@ public interface FlowRuleProviderService extends ProviderService<FlowRuleProvide | ... | @@ -41,6 +41,15 @@ public interface FlowRuleProviderService extends ProviderService<FlowRuleProvide |
| 41 | void pushFlowMetrics(DeviceId deviceId, Iterable<FlowEntry> flowEntries); | 41 | void pushFlowMetrics(DeviceId deviceId, Iterable<FlowEntry> flowEntries); |
| 42 | 42 | ||
| 43 | /** | 43 | /** |
| 44 | + * Pushes the collection of flow entries currently applied on the given | ||
| 45 | + * device without flowMissing process. | ||
| 46 | + * | ||
| 47 | + * @param deviceId device identifier | ||
| 48 | + * @param flowEntries collection of flow rules | ||
| 49 | + */ | ||
| 50 | + void pushFlowMetricsWithoutFlowMissing(DeviceId deviceId, Iterable<FlowEntry> flowEntries); | ||
| 51 | + | ||
| 52 | + /** | ||
| 44 | * Indicates to the core that the requested batch operation has | 53 | * Indicates to the core that the requested batch operation has |
| 45 | * been completed. | 54 | * been completed. |
| 46 | * | 55 | * | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +package org.onosproject.net.flow; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Represents a flow live type for a given flow entry. | ||
| 21 | + */ | ||
| 22 | +public interface TypedStoredFlowEntry extends StoredFlowEntry { | ||
| 23 | + enum FlowLiveType { | ||
| 24 | + /** | ||
| 25 | + * Indicates that this rule has been submitted for addition immediately. | ||
| 26 | + * Not necessarily collecting flow stats. | ||
| 27 | + */ | ||
| 28 | + IMMEDIATE_FLOW, | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Indicates that this rule has been submitted for a short time. | ||
| 32 | + * Necessarily collecting flow stats every calAndPollInterval. | ||
| 33 | + */ | ||
| 34 | + SHORT_FLOW, | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Indicates that this rule has been submitted for a mid time. | ||
| 38 | + * Necessarily collecting flow stats every midPollInterval. | ||
| 39 | + */ | ||
| 40 | + MID_FLOW, | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * Indicates that this rule has been submitted for a long time. | ||
| 44 | + * Necessarily collecting flow stats every longPollInterval. | ||
| 45 | + */ | ||
| 46 | + LONG_FLOW, | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * Indicates that this rule has been submitted for UNKNOWN or ERROR. | ||
| 50 | + * Not necessarily collecting flow stats. | ||
| 51 | + */ | ||
| 52 | + UNKNOWN_FLOW | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * Gets the flow live type for this entry. | ||
| 57 | + */ | ||
| 58 | + FlowLiveType flowLiveType(); | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * Sets the new flow live type for this entry. | ||
| 62 | + * @param liveType new flow live type. | ||
| 63 | + */ | ||
| 64 | + void setFlowLiveType(FlowLiveType liveType); | ||
| 65 | +} |
| ... | @@ -388,6 +388,16 @@ public class FlowRuleManager | ... | @@ -388,6 +388,16 @@ public class FlowRuleManager |
| 388 | 388 | ||
| 389 | @Override | 389 | @Override |
| 390 | public void pushFlowMetrics(DeviceId deviceId, Iterable<FlowEntry> flowEntries) { | 390 | public void pushFlowMetrics(DeviceId deviceId, Iterable<FlowEntry> flowEntries) { |
| 391 | + pushFlowMetricsInternal(deviceId, flowEntries, true); | ||
| 392 | + } | ||
| 393 | + | ||
| 394 | + @Override | ||
| 395 | + public void pushFlowMetricsWithoutFlowMissing(DeviceId deviceId, Iterable<FlowEntry> flowEntries) { | ||
| 396 | + pushFlowMetricsInternal(deviceId, flowEntries, false); | ||
| 397 | + } | ||
| 398 | + | ||
| 399 | + private void pushFlowMetricsInternal(DeviceId deviceId, Iterable<FlowEntry> flowEntries, | ||
| 400 | + boolean useMissingFlow) { | ||
| 391 | Map<FlowEntry, FlowEntry> storedRules = Maps.newHashMap(); | 401 | Map<FlowEntry, FlowEntry> storedRules = Maps.newHashMap(); |
| 392 | store.getFlowEntries(deviceId).forEach(f -> storedRules.put(f, f)); | 402 | store.getFlowEntries(deviceId).forEach(f -> storedRules.put(f, f)); |
| 393 | 403 | ||
| ... | @@ -415,17 +425,20 @@ public class FlowRuleManager | ... | @@ -415,17 +425,20 @@ public class FlowRuleManager |
| 415 | continue; | 425 | continue; |
| 416 | } | 426 | } |
| 417 | } | 427 | } |
| 418 | - for (FlowEntry rule : storedRules.keySet()) { | 428 | + |
| 419 | - try { | 429 | + // DO NOT reinstall |
| 420 | - // there are rules in the store that aren't on the switch | 430 | + if (useMissingFlow) { |
| 421 | - log.debug("Adding rule in store, but not on switch {}", rule); | 431 | + for (FlowEntry rule : storedRules.keySet()) { |
| 422 | - flowMissing(rule); | 432 | + try { |
| 423 | - } catch (Exception e) { | 433 | + // there are rules in the store that aren't on the switch |
| 424 | - log.debug("Can't add missing flow rule {}", e.getMessage()); | 434 | + log.debug("Adding rule in store, but not on switch {}", rule); |
| 425 | - continue; | 435 | + flowMissing(rule); |
| 436 | + } catch (Exception e) { | ||
| 437 | + log.debug("Can't add missing flow rule {}", e.getMessage()); | ||
| 438 | + continue; | ||
| 439 | + } | ||
| 426 | } | 440 | } |
| 427 | } | 441 | } |
| 428 | - | ||
| 429 | } | 442 | } |
| 430 | 443 | ||
| 431 | @Override | 444 | @Override | ... | ... |
| ... | @@ -273,6 +273,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -273,6 +273,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
| 273 | OFFlowStatsReply.Builder rep = | 273 | OFFlowStatsReply.Builder rep = |
| 274 | OFFactories.getFactory(msg.getVersion()).buildFlowStatsReply(); | 274 | OFFactories.getFactory(msg.getVersion()).buildFlowStatsReply(); |
| 275 | rep.setEntries(Lists.newLinkedList(flowStats)); | 275 | rep.setEntries(Lists.newLinkedList(flowStats)); |
| 276 | + rep.setXid(reply.getXid()); | ||
| 276 | executorMsgs.submit(new OFMessageHandler(dpid, rep.build())); | 277 | executorMsgs.submit(new OFMessageHandler(dpid, rep.build())); |
| 277 | } | 278 | } |
| 278 | break; | 279 | break; | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment