Committed by
Gerrit Code Review
[Emu] openTAM: FlowStatisticManager, DistributedFlowStatisticStore, get-flow-sta…
…ts CLI Implementation and NewAdaptiveFlowStatsCollector update and typo - GetFlowStatistics.java .Fixed function name typo: immediateLoad() - SummaryFlowEntryWithLoad.java .Added javadoc - TypedFlowEntryWithLoad.java .Added javadoc, .and replace checknotnull and throw NullPointerException in typedPollInterval() at line 104 Change-Id: I23d2eaf234d0affeb5f927275148d9165c66c774
Showing
11 changed files
with
486 additions
and
17 deletions
| ... | @@ -25,6 +25,8 @@ import org.onosproject.net.ElementId; | ... | @@ -25,6 +25,8 @@ import org.onosproject.net.ElementId; |
| 25 | import org.onosproject.net.Port; | 25 | import org.onosproject.net.Port; |
| 26 | import org.onosproject.net.flow.FlowRule; | 26 | import org.onosproject.net.flow.FlowRule; |
| 27 | import org.onosproject.net.group.Group; | 27 | import org.onosproject.net.group.Group; |
| 28 | + | ||
| 29 | +import org.onosproject.net.statistic.TypedFlowEntryWithLoad; | ||
| 28 | import org.onosproject.net.topology.TopologyCluster; | 30 | import org.onosproject.net.topology.TopologyCluster; |
| 29 | 31 | ||
| 30 | import java.util.Comparator; | 32 | import java.util.Comparator; |
| ... | @@ -115,4 +117,12 @@ public final class Comparators { | ... | @@ -115,4 +117,12 @@ public final class Comparators { |
| 115 | public static final Comparator<Interface> INTERFACES_COMPARATOR = (intf1, intf2) -> | 117 | public static final Comparator<Interface> INTERFACES_COMPARATOR = (intf1, intf2) -> |
| 116 | CONNECT_POINT_COMPARATOR.compare(intf1.connectPoint(), intf2.connectPoint()); | 118 | CONNECT_POINT_COMPARATOR.compare(intf1.connectPoint(), intf2.connectPoint()); |
| 117 | 119 | ||
| 120 | + public static final Comparator<TypedFlowEntryWithLoad> TYPEFLOWENTRY_WITHLOAD_COMPARATOR = | ||
| 121 | + new Comparator<TypedFlowEntryWithLoad>() { | ||
| 122 | + @Override | ||
| 123 | + public int compare(TypedFlowEntryWithLoad fe1, TypedFlowEntryWithLoad fe2) { | ||
| 124 | + long delta = fe1.load().rate() - fe2.load().rate(); | ||
| 125 | + return delta == 0 ? 0 : (delta > 0 ? -1 : +1); | ||
| 126 | + } | ||
| 127 | + }; | ||
| 118 | } | 128 | } | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -222,6 +222,12 @@ | ... | @@ -222,6 +222,12 @@ |
| 222 | </completers> | 222 | </completers> |
| 223 | </command> | 223 | </command> |
| 224 | <command> | 224 | <command> |
| 225 | + <action class="org.onosproject.cli.net.GetFlowStatistics"/> | ||
| 226 | + <completers> | ||
| 227 | + <ref component-id="deviceIdCompleter"/> | ||
| 228 | + </completers> | ||
| 229 | + </command> | ||
| 230 | + <command> | ||
| 225 | <action class="org.onosproject.cli.net.AddMultiPointToSinglePointIntentCommand"/> | 231 | <action class="org.onosproject.cli.net.AddMultiPointToSinglePointIntentCommand"/> |
| 226 | <completers> | 232 | <completers> |
| 227 | <ref component-id="connectPointCompleter"/> | 233 | <ref component-id="connectPointCompleter"/> |
| ... | @@ -333,7 +339,6 @@ | ... | @@ -333,7 +339,6 @@ |
| 333 | <command> | 339 | <command> |
| 334 | <action class="org.onosproject.cli.net.InterfacesListCommand"/> | 340 | <action class="org.onosproject.cli.net.InterfacesListCommand"/> |
| 335 | </command> | 341 | </command> |
| 336 | - | ||
| 337 | <command> | 342 | <command> |
| 338 | <action class="org.onosproject.cli.net.GroupsListCommand"/> | 343 | <action class="org.onosproject.cli.net.GroupsListCommand"/> |
| 339 | </command> | 344 | </command> | ... | ... |
| 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.statistic; | ||
| 18 | + | ||
| 19 | +import org.onosproject.net.ConnectPoint; | ||
| 20 | +import org.onosproject.net.Device; | ||
| 21 | +import org.onosproject.net.PortNumber; | ||
| 22 | +import org.onosproject.net.flow.TypedStoredFlowEntry; | ||
| 23 | +import org.onosproject.net.flow.instructions.Instruction; | ||
| 24 | + | ||
| 25 | +import java.util.List; | ||
| 26 | +import java.util.Map; | ||
| 27 | + | ||
| 28 | +/** | ||
| 29 | + * Service for obtaining individual flow statistic information about device and link in the system. | ||
| 30 | + * Basic statistics are obtained from the StatisticService | ||
| 31 | + */ | ||
| 32 | +public interface FlowStatisticService { | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Obtain the summary load list for the device with the given link. | ||
| 36 | + * | ||
| 37 | + * @param device the Device to query. | ||
| 38 | + * @return map of summary flow entry load | ||
| 39 | + */ | ||
| 40 | + Map<ConnectPoint, SummaryFlowEntryWithLoad> loadSummary(Device device); | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * Obtain the summary load for the device with the given link or port. | ||
| 44 | + * | ||
| 45 | + * @param device the Device to query. | ||
| 46 | + * @param pNumber the port number to query. | ||
| 47 | + * @return summary flow entry load | ||
| 48 | + */ | ||
| 49 | + SummaryFlowEntryWithLoad loadSummary(Device device, PortNumber pNumber); | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * Obtain the set of the flow type and load list for the device with the given link. | ||
| 53 | + * | ||
| 54 | + * @param device the Device to query. | ||
| 55 | + * @param liveType the FlowLiveType to filter, null means no filtering . | ||
| 56 | + * @param instType the InstructionType to filter, null means no filtering. | ||
| 57 | + * @return map of flow entry load | ||
| 58 | + */ | ||
| 59 | + Map<ConnectPoint, List<TypedFlowEntryWithLoad>> loadAllByType(Device device, | ||
| 60 | + TypedStoredFlowEntry.FlowLiveType liveType, | ||
| 61 | + Instruction.Type instType); | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * Obtain the flow type and load list for the device with the given link or port. | ||
| 65 | + * | ||
| 66 | + * @param device the Device to query. | ||
| 67 | + * @param pNumber the port number of the Device to query | ||
| 68 | + * @param liveType the FlowLiveType to filter, null means no filtering . | ||
| 69 | + * @param instType the InstructionType to filter, null means no filtering. | ||
| 70 | + * @return list of flow entry load | ||
| 71 | + */ | ||
| 72 | + List<TypedFlowEntryWithLoad> loadAllByType(Device device, PortNumber pNumber, | ||
| 73 | + TypedStoredFlowEntry.FlowLiveType liveType, | ||
| 74 | + Instruction.Type instType); | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * Obtain the set of the flow type and load topn list for the device with the given link. | ||
| 78 | + * | ||
| 79 | + * @param device the Device to query. | ||
| 80 | + * @param liveType the FlowLiveType to filter, null means no filtering . | ||
| 81 | + * @param instType the InstructionType to filter, null means no filtering. | ||
| 82 | + * @param topn the top number to filter, null means no filtering. | ||
| 83 | + * @return map of flow entry load | ||
| 84 | + */ | ||
| 85 | + Map<ConnectPoint, List<TypedFlowEntryWithLoad>> loadTopnByType(Device device, | ||
| 86 | + TypedStoredFlowEntry.FlowLiveType liveType, | ||
| 87 | + Instruction.Type instType, | ||
| 88 | + int topn); | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * Obtain the flow type and load topn list for the device with the given link or port. | ||
| 92 | + * | ||
| 93 | + * @param device the Device to query. | ||
| 94 | + * @param pNumber the port number of the Device to query | ||
| 95 | + * @param liveType the FlowLiveType to filter, null means no filtering . | ||
| 96 | + * @param instType the InstructionType to filter, null means no filtering. | ||
| 97 | + * @return list of flow entry load | ||
| 98 | + */ | ||
| 99 | + List<TypedFlowEntryWithLoad> loadTopnByType(Device device, PortNumber pNumber, | ||
| 100 | + TypedStoredFlowEntry.FlowLiveType liveType, | ||
| 101 | + Instruction.Type instType, | ||
| 102 | + int topn); | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | + |
| 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.statistic; | ||
| 18 | + | ||
| 19 | +import org.onosproject.net.ConnectPoint; | ||
| 20 | +import org.onosproject.net.flow.FlowEntry; | ||
| 21 | +import org.onosproject.net.flow.FlowRule; | ||
| 22 | + | ||
| 23 | +import java.util.Set; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * Flow Store to house the computed statistics. | ||
| 27 | + */ | ||
| 28 | +public interface FlowStatisticStore { | ||
| 29 | + /** | ||
| 30 | + * Remove entries associated with this rule. | ||
| 31 | + * | ||
| 32 | + * @param rule {@link org.onosproject.net.flow.FlowRule} | ||
| 33 | + */ | ||
| 34 | + void removeFlowStatistic(FlowRule rule); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Adds a flow stats observation for a flow rule. The previous flow will be removed. | ||
| 38 | + * | ||
| 39 | + * @param rule a {@link org.onosproject.net.flow.FlowEntry} | ||
| 40 | + */ | ||
| 41 | + void addFlowStatistic(FlowEntry rule); | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * Updates a stats observation for a flow rule. The old flow stats will be moved to previous stats. | ||
| 45 | + * | ||
| 46 | + * @param rule a {@link org.onosproject.net.flow.FlowEntry} | ||
| 47 | + */ | ||
| 48 | + void updateFlowStatistic(FlowEntry rule); | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * Fetches the current observed flow stats values. | ||
| 52 | + * | ||
| 53 | + * @param connectPoint the port to fetch information for | ||
| 54 | + * @return set of current flow rules | ||
| 55 | + */ | ||
| 56 | + Set<FlowEntry> getCurrentFlowStatistic(ConnectPoint connectPoint); | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * Fetches the current observed flow stats values. | ||
| 60 | + * | ||
| 61 | + * @param connectPoint the port to fetch information for | ||
| 62 | + * @return set of current values | ||
| 63 | + */ | ||
| 64 | + Set<FlowEntry> getPreviousFlowStatistic(ConnectPoint connectPoint); | ||
| 65 | +} |
| 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.statistic; | ||
| 18 | + | ||
| 19 | +import org.onosproject.net.ConnectPoint; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * Summary Load classified by flow live type. | ||
| 23 | + */ | ||
| 24 | +public class SummaryFlowEntryWithLoad { | ||
| 25 | + private ConnectPoint cp; | ||
| 26 | + private Load totalLoad; | ||
| 27 | + private Load immediateLoad; | ||
| 28 | + private Load shortLoad; | ||
| 29 | + private Load midLoad; | ||
| 30 | + private Load longLoad; | ||
| 31 | + private Load unknownLoad; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * Creates a new summary flow entry having load for the given connect point and total load. | ||
| 35 | + * | ||
| 36 | + * @param cp connect point | ||
| 37 | + * @param totalLoad total load | ||
| 38 | + */ | ||
| 39 | + public SummaryFlowEntryWithLoad(ConnectPoint cp, Load totalLoad) { | ||
| 40 | + this.cp = cp; | ||
| 41 | + this.totalLoad = totalLoad; | ||
| 42 | + this.immediateLoad = new DefaultLoad(); | ||
| 43 | + this.shortLoad = new DefaultLoad(); | ||
| 44 | + this.midLoad = new DefaultLoad(); | ||
| 45 | + this.longLoad = new DefaultLoad(); | ||
| 46 | + this.unknownLoad = new DefaultLoad(); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * Creates a new summary flow entry having load for the given connect point | ||
| 51 | + * and total, immediate, short, mid, and long load. | ||
| 52 | + * | ||
| 53 | + * @param cp connect point | ||
| 54 | + * @param totalLoad total load | ||
| 55 | + * @param immediateLoad immediate load | ||
| 56 | + * @param shortLoad short load | ||
| 57 | + * @param midLoad mid load | ||
| 58 | + * @param longLoad long load | ||
| 59 | + */ | ||
| 60 | + public SummaryFlowEntryWithLoad(ConnectPoint cp, | ||
| 61 | + Load totalLoad, Load immediateLoad, Load shortLoad, Load midLoad, Load longLoad) { | ||
| 62 | + this.cp = cp; | ||
| 63 | + this.totalLoad = totalLoad; | ||
| 64 | + this.immediateLoad = immediateLoad; | ||
| 65 | + this.shortLoad = shortLoad; | ||
| 66 | + this.midLoad = midLoad; | ||
| 67 | + this.longLoad = longLoad; | ||
| 68 | + this.unknownLoad = new DefaultLoad(); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * Creates a new summary flow entry having load for the given connect point | ||
| 73 | + * and total, immediate, short, mid, long, and unknown load. | ||
| 74 | + * | ||
| 75 | + * @param cp connect point | ||
| 76 | + * @param totalLoad total load | ||
| 77 | + * @param immediateLoad immediate load | ||
| 78 | + * @param shortLoad short load | ||
| 79 | + * @param midLoad mid load | ||
| 80 | + * @param longLoad long load | ||
| 81 | + * @param unknownLoad long load | ||
| 82 | + */ | ||
| 83 | + public SummaryFlowEntryWithLoad(ConnectPoint cp, | ||
| 84 | + Load totalLoad, Load immediateLoad, | ||
| 85 | + Load shortLoad, Load midLoad, Load longLoad, Load unknownLoad) { | ||
| 86 | + this.cp = cp; | ||
| 87 | + this.totalLoad = totalLoad; | ||
| 88 | + this.immediateLoad = immediateLoad; | ||
| 89 | + this.shortLoad = shortLoad; | ||
| 90 | + this.midLoad = midLoad; | ||
| 91 | + this.longLoad = longLoad; | ||
| 92 | + this.unknownLoad = unknownLoad; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + /** | ||
| 96 | + * Returns connect point. | ||
| 97 | + */ | ||
| 98 | + public ConnectPoint connectPoint() { | ||
| 99 | + return cp; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * Returns total load of connect point. | ||
| 104 | + */ | ||
| 105 | + public Load totalLoad() { | ||
| 106 | + return totalLoad; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + /** | ||
| 110 | + * Returns immediate load of connect point. | ||
| 111 | + */ | ||
| 112 | + public Load immediateLoad() { | ||
| 113 | + return immediateLoad; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + /** | ||
| 117 | + * Returns short load of connect point. | ||
| 118 | + */ | ||
| 119 | + public Load shortLoad() { | ||
| 120 | + return shortLoad; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * Returns mid load of connect point. | ||
| 125 | + */ | ||
| 126 | + public Load midLoad() { | ||
| 127 | + return midLoad; | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + /** | ||
| 131 | + * Returns long load of connect point. | ||
| 132 | + */ | ||
| 133 | + public Load longLoad() { | ||
| 134 | + return longLoad; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * Returns unknown load of connect point. | ||
| 139 | + */ | ||
| 140 | + public Load unknownLoad() { | ||
| 141 | + return unknownLoad; | ||
| 142 | + } | ||
| 143 | +} |
| 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.statistic; | ||
| 18 | + | ||
| 19 | +import org.onosproject.net.ConnectPoint; | ||
| 20 | +import org.onosproject.net.flow.FlowEntry; | ||
| 21 | +import org.onosproject.net.flow.TypedStoredFlowEntry; | ||
| 22 | +import org.onosproject.net.flow.DefaultTypedFlowEntry; | ||
| 23 | + | ||
| 24 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * Load of flow entry of flow live type. | ||
| 28 | + */ | ||
| 29 | +public class TypedFlowEntryWithLoad { | ||
| 30 | + private ConnectPoint cp; | ||
| 31 | + private TypedStoredFlowEntry tfe; | ||
| 32 | + private Load load; | ||
| 33 | + | ||
| 34 | + //TODO: make this variables class, and share with NewAdaptivceFlowStatsCollector class | ||
| 35 | + private static final int CAL_AND_POLL_INTERVAL = 5; // means SHORT_POLL_INTERVAL | ||
| 36 | + private static final int MID_POLL_INTERVAL = 10; | ||
| 37 | + private static final int LONG_POLL_INTERVAL = 15; | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + public TypedFlowEntryWithLoad(ConnectPoint cp, TypedStoredFlowEntry tfe, Load load) { | ||
| 41 | + this.cp = cp; | ||
| 42 | + this.tfe = tfe; | ||
| 43 | + this.load = load; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public TypedFlowEntryWithLoad(ConnectPoint cp, TypedStoredFlowEntry tfe) { | ||
| 47 | + this.cp = cp; | ||
| 48 | + this.tfe = tfe; | ||
| 49 | + this.load = new DefaultLoad(tfe.bytes(), 0, typedPollInterval(tfe)); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public TypedFlowEntryWithLoad(ConnectPoint cp, FlowEntry fe) { | ||
| 53 | + this.cp = cp; | ||
| 54 | + this.tfe = newTypedStoredFlowEntry(fe); | ||
| 55 | + this.load = new DefaultLoad(fe.bytes(), 0, typedPollInterval(this.tfe)); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public ConnectPoint connectPoint() { | ||
| 59 | + return cp; | ||
| 60 | + } | ||
| 61 | + public TypedStoredFlowEntry typedStoredFlowEntry() { | ||
| 62 | + return tfe; | ||
| 63 | + } | ||
| 64 | + public Load load() { | ||
| 65 | + return load; | ||
| 66 | + } | ||
| 67 | + public void setLoad(Load load) { | ||
| 68 | + this.load = load; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * Returns short polling interval. | ||
| 73 | + */ | ||
| 74 | + public static int shortPollInterval() { | ||
| 75 | + return CAL_AND_POLL_INTERVAL; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * Returns mid polling interval. | ||
| 80 | + */ | ||
| 81 | + public static int midPollInterval() { | ||
| 82 | + return MID_POLL_INTERVAL; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * Returns long polling interval. | ||
| 87 | + */ | ||
| 88 | + public static int longPollInterval() { | ||
| 89 | + return LONG_POLL_INTERVAL; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * Returns average polling interval. | ||
| 94 | + */ | ||
| 95 | + public static int avgPollInterval() { | ||
| 96 | + return (CAL_AND_POLL_INTERVAL + MID_POLL_INTERVAL + LONG_POLL_INTERVAL) / 3; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * Returns current typed flow entry's polling interval. | ||
| 101 | + * | ||
| 102 | + * @param tfe typed flow entry | ||
| 103 | + */ | ||
| 104 | + public static long typedPollInterval(TypedStoredFlowEntry tfe) { | ||
| 105 | + checkNotNull(tfe, "TypedStoredFlowEntry cannot be null"); | ||
| 106 | + | ||
| 107 | + switch (tfe.flowLiveType()) { | ||
| 108 | + case LONG_FLOW: | ||
| 109 | + return LONG_POLL_INTERVAL; | ||
| 110 | + case MID_FLOW: | ||
| 111 | + return MID_POLL_INTERVAL; | ||
| 112 | + case SHORT_FLOW: | ||
| 113 | + case IMMEDIATE_FLOW: | ||
| 114 | + default: | ||
| 115 | + return CAL_AND_POLL_INTERVAL; | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + /** | ||
| 120 | + * Creates a new typed flow entry with the given flow entry fe. | ||
| 121 | + * | ||
| 122 | + * @param fe flow entry | ||
| 123 | + */ | ||
| 124 | + public static TypedStoredFlowEntry newTypedStoredFlowEntry(FlowEntry fe) { | ||
| 125 | + if (fe == null) { | ||
| 126 | + return null; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + long life = fe.life(); | ||
| 130 | + | ||
| 131 | + if (life >= LONG_POLL_INTERVAL) { | ||
| 132 | + return new DefaultTypedFlowEntry(fe, TypedStoredFlowEntry.FlowLiveType.LONG_FLOW); | ||
| 133 | + } else if (life >= MID_POLL_INTERVAL) { | ||
| 134 | + return new DefaultTypedFlowEntry(fe, TypedStoredFlowEntry.FlowLiveType.MID_FLOW); | ||
| 135 | + } else if (life >= CAL_AND_POLL_INTERVAL) { | ||
| 136 | + return new DefaultTypedFlowEntry(fe, TypedStoredFlowEntry.FlowLiveType.SHORT_FLOW); | ||
| 137 | + } else if (life >= 0) { | ||
| 138 | + return new DefaultTypedFlowEntry(fe, TypedStoredFlowEntry.FlowLiveType.IMMEDIATE_FLOW); | ||
| 139 | + } else { // life < 0 | ||
| 140 | + return new DefaultTypedFlowEntry(fe, TypedStoredFlowEntry.FlowLiveType.UNKNOWN_FLOW); | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | +} |
| ... | @@ -52,6 +52,20 @@ | ... | @@ -52,6 +52,20 @@ |
| 52 | 52 | ||
| 53 | <dependency> | 53 | <dependency> |
| 54 | <groupId>org.onosproject</groupId> | 54 | <groupId>org.onosproject</groupId> |
| 55 | + <version>${project.version}</version> | ||
| 56 | + <artifactId>onos-cli</artifactId> | ||
| 57 | + </dependency> | ||
| 58 | + | ||
| 59 | + <dependency> | ||
| 60 | + <groupId>org.onosproject</groupId> | ||
| 61 | + <artifactId>onos-cli</artifactId> | ||
| 62 | + <version>${project.version}</version> | ||
| 63 | + <classifier>tests</classifier> | ||
| 64 | + <scope>test</scope> | ||
| 65 | + </dependency> | ||
| 66 | + | ||
| 67 | + <dependency> | ||
| 68 | + <groupId>org.onosproject</groupId> | ||
| 55 | <artifactId>onos-core-common</artifactId> | 69 | <artifactId>onos-core-common</artifactId> |
| 56 | <version>${project.version}</version> | 70 | <version>${project.version}</version> |
| 57 | <classifier>tests</classifier> | 71 | <classifier>tests</classifier> | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
| ... | @@ -717,25 +717,9 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -717,25 +717,9 @@ public class NewAdaptiveFlowStatsCollector { |
| 717 | long curTime = (cTime > 0 ? cTime : System.currentTimeMillis()); | 717 | long curTime = (cTime > 0 ? cTime : System.currentTimeMillis()); |
| 718 | // For latency adjustment(default=500 millisecond) between FlowStatsRequest and Reply | 718 | // For latency adjustment(default=500 millisecond) between FlowStatsRequest and Reply |
| 719 | long fromLastSeen = ((curTime - fe.lastSeen() + latencyFlowStatsRequestAndReplyMillis) / 1000); | 719 | long fromLastSeen = ((curTime - fe.lastSeen() + latencyFlowStatsRequestAndReplyMillis) / 1000); |
| 720 | - | ||
| 721 | // fe.life() unit is SECOND! | 720 | // fe.life() unit is SECOND! |
| 722 | long liveTime = fe.life() + fromLastSeen; | 721 | long liveTime = fe.life() + fromLastSeen; |
| 723 | 722 | ||
| 724 | - // check flow timeout | ||
| 725 | - if (fe.timeout() > calAndPollInterval && fromLastSeen > fe.timeout()) { | ||
| 726 | - if (!fe.isPermanent()) { | ||
| 727 | - log.debug("checkAndMoveLiveFlowInternal, FlowId=" + Long.toHexString(fe.id().value()) | ||
| 728 | - + ", liveType=" + fe.flowLiveType() | ||
| 729 | - + ", liveTime=" + liveTime | ||
| 730 | - + ", life=" + fe.life() | ||
| 731 | - + ", fromLastSeen=" + fromLastSeen | ||
| 732 | - + ", timeout=" + fe.timeout() | ||
| 733 | - + ", isPermanent=" + fe.isPermanent() | ||
| 734 | - + " AdaptiveStats collection thread for {}", | ||
| 735 | - sw.getStringId()); | ||
| 736 | - return false; | ||
| 737 | - } | ||
| 738 | - } | ||
| 739 | 723 | ||
| 740 | switch (fe.flowLiveType()) { | 724 | switch (fe.flowLiveType()) { |
| 741 | case IMMEDIATE_FLOW: | 725 | case IMMEDIATE_FLOW: | ... | ... |
-
Please register or login to post a comment