Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next
Showing
11 changed files
with
78 additions
and
28 deletions
1 | +package org.onlab.onos.cli; | ||
2 | + | ||
3 | +import org.apache.karaf.shell.commands.Command; | ||
4 | +import org.onlab.onos.cluster.ClusterService; | ||
5 | +import org.onlab.onos.net.device.DeviceService; | ||
6 | +import org.onlab.onos.net.flow.FlowRuleService; | ||
7 | +import org.onlab.onos.net.host.HostService; | ||
8 | +import org.onlab.onos.net.intent.IntentService; | ||
9 | +import org.onlab.onos.net.link.LinkService; | ||
10 | +import org.onlab.onos.net.topology.Topology; | ||
11 | +import org.onlab.onos.net.topology.TopologyService; | ||
12 | + | ||
13 | +/** | ||
14 | + * Provides summary of ONOS model. | ||
15 | + */ | ||
16 | +@Command(scope = "onos", name = "summary", | ||
17 | + description = "Provides summary of ONOS model") | ||
18 | +public class SummaryCommand extends AbstractShellCommand { | ||
19 | + | ||
20 | + @Override | ||
21 | + protected void execute() { | ||
22 | + TopologyService topologyService = get(TopologyService.class); | ||
23 | + Topology topology = topologyService.currentTopology(); | ||
24 | + print("nodes=%d, devices=%d, links=%d, hosts=%d, clusters=%s, paths=%d, flows=%d, intents=%d", | ||
25 | + get(ClusterService.class).getNodes().size(), | ||
26 | + get(DeviceService.class).getDeviceCount(), | ||
27 | + get(LinkService.class).getLinkCount(), | ||
28 | + get(HostService.class).getHostCount(), | ||
29 | + topologyService.getClusters(topology).size(), | ||
30 | + topology.pathCount(), | ||
31 | + get(FlowRuleService.class).getFlowRuleCount(), | ||
32 | + get(IntentService.class).getIntentCount()); | ||
33 | + } | ||
34 | + | ||
35 | +} |
... | @@ -2,6 +2,9 @@ | ... | @@ -2,6 +2,9 @@ |
2 | 2 | ||
3 | <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> | 3 | <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> |
4 | <command> | 4 | <command> |
5 | + <action class="org.onlab.onos.cli.SummaryCommand"/> | ||
6 | + </command> | ||
7 | + <command> | ||
5 | <action class="org.onlab.onos.cli.NodesListCommand"/> | 8 | <action class="org.onlab.onos.cli.NodesListCommand"/> |
6 | </command> | 9 | </command> |
7 | <command> | 10 | <command> | ... | ... |
... | @@ -13,6 +13,13 @@ import org.onlab.onos.net.DeviceId; | ... | @@ -13,6 +13,13 @@ import org.onlab.onos.net.DeviceId; |
13 | public interface FlowRuleService { | 13 | public interface FlowRuleService { |
14 | 14 | ||
15 | /** | 15 | /** |
16 | + * Returns the number of flow rules in the system. | ||
17 | + * | ||
18 | + * @return flow rule count | ||
19 | + */ | ||
20 | + int getFlowRuleCount(); | ||
21 | + | ||
22 | + /** | ||
16 | * Returns the collection of flow entries applied on the specified device. | 23 | * Returns the collection of flow entries applied on the specified device. |
17 | * This will include flow rules which may not yet have been applied to | 24 | * This will include flow rules which may not yet have been applied to |
18 | * the device. | 25 | * the device. |
... | @@ -72,7 +79,4 @@ public interface FlowRuleService { | ... | @@ -72,7 +79,4 @@ public interface FlowRuleService { |
72 | * @param listener flow rule listener | 79 | * @param listener flow rule listener |
73 | */ | 80 | */ |
74 | void removeListener(FlowRuleListener listener); | 81 | void removeListener(FlowRuleListener listener); |
75 | - | ||
76 | - | ||
77 | - | ||
78 | } | 82 | } | ... | ... |
... | @@ -10,7 +10,15 @@ import org.onlab.onos.store.Store; | ... | @@ -10,7 +10,15 @@ import org.onlab.onos.store.Store; |
10 | public interface FlowRuleStore extends Store<FlowRuleEvent, FlowRuleStoreDelegate> { | 10 | public interface FlowRuleStore extends Store<FlowRuleEvent, FlowRuleStoreDelegate> { |
11 | 11 | ||
12 | /** | 12 | /** |
13 | + * Returns the number of flow rule in the store. | ||
14 | + * | ||
15 | + * @return number of flow rules | ||
16 | + */ | ||
17 | + int getFlowRuleCount(); | ||
18 | + | ||
19 | + /** | ||
13 | * Returns the stored flow. | 20 | * Returns the stored flow. |
21 | + * | ||
14 | * @param rule the rule to look for | 22 | * @param rule the rule to look for |
15 | * @return a flow rule | 23 | * @return a flow rule |
16 | */ | 24 | */ |
... | @@ -60,5 +68,4 @@ public interface FlowRuleStore extends Store<FlowRuleEvent, FlowRuleStoreDelegat | ... | @@ -60,5 +68,4 @@ public interface FlowRuleStore extends Store<FlowRuleEvent, FlowRuleStoreDelegat |
60 | * @return flow_removed event, or null if nothing removed | 68 | * @return flow_removed event, or null if nothing removed |
61 | */ | 69 | */ |
62 | FlowRuleEvent removeFlowRule(FlowEntry rule); | 70 | FlowRuleEvent removeFlowRule(FlowEntry rule); |
63 | - | ||
64 | } | 71 | } | ... | ... |
... | @@ -40,8 +40,8 @@ import com.google.common.collect.Lists; | ... | @@ -40,8 +40,8 @@ import com.google.common.collect.Lists; |
40 | @Component(immediate = true) | 40 | @Component(immediate = true) |
41 | @Service | 41 | @Service |
42 | public class FlowRuleManager | 42 | public class FlowRuleManager |
43 | -extends AbstractProviderRegistry<FlowRuleProvider, FlowRuleProviderService> | 43 | + extends AbstractProviderRegistry<FlowRuleProvider, FlowRuleProviderService> |
44 | -implements FlowRuleService, FlowRuleProviderRegistry { | 44 | + implements FlowRuleService, FlowRuleProviderRegistry { |
45 | 45 | ||
46 | public static final String FLOW_RULE_NULL = "FlowRule cannot be null"; | 46 | public static final String FLOW_RULE_NULL = "FlowRule cannot be null"; |
47 | private final Logger log = getLogger(getClass()); | 47 | private final Logger log = getLogger(getClass()); |
... | @@ -75,6 +75,11 @@ implements FlowRuleService, FlowRuleProviderRegistry { | ... | @@ -75,6 +75,11 @@ implements FlowRuleService, FlowRuleProviderRegistry { |
75 | } | 75 | } |
76 | 76 | ||
77 | @Override | 77 | @Override |
78 | + public int getFlowRuleCount() { | ||
79 | + return store.getFlowRuleCount(); | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
78 | public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { | 83 | public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { |
79 | return store.getFlowEntries(deviceId); | 84 | return store.getFlowEntries(deviceId); |
80 | } | 85 | } |
... | @@ -98,11 +103,13 @@ implements FlowRuleService, FlowRuleProviderRegistry { | ... | @@ -98,11 +103,13 @@ implements FlowRuleService, FlowRuleProviderRegistry { |
98 | for (int i = 0; i < flowRules.length; i++) { | 103 | for (int i = 0; i < flowRules.length; i++) { |
99 | f = flowRules[i]; | 104 | f = flowRules[i]; |
100 | device = deviceService.getDevice(f.deviceId()); | 105 | device = deviceService.getDevice(f.deviceId()); |
101 | - frp = getProvider(device.providerId()); | ||
102 | store.deleteFlowRule(f); | 106 | store.deleteFlowRule(f); |
107 | + if (device != null) { | ||
108 | + frp = getProvider(device.providerId()); | ||
103 | frp.removeFlowRule(f); | 109 | frp.removeFlowRule(f); |
104 | } | 110 | } |
105 | } | 111 | } |
112 | + } | ||
106 | 113 | ||
107 | @Override | 114 | @Override |
108 | public void removeFlowRulesById(ApplicationId id) { | 115 | public void removeFlowRulesById(ApplicationId id) { | ... | ... |
... | @@ -115,12 +115,7 @@ public class FlowTracker implements FlowTrackerService { | ... | @@ -115,12 +115,7 @@ public class FlowTracker implements FlowTrackerService { |
115 | for (Event reason : event.reasons()) { | 115 | for (Event reason : event.reasons()) { |
116 | if (reason instanceof LinkEvent) { | 116 | if (reason instanceof LinkEvent) { |
117 | LinkEvent linkEvent = (LinkEvent) reason; | 117 | LinkEvent linkEvent = (LinkEvent) reason; |
118 | - if (linkEvent.type() == LinkEvent.Type.LINK_ADDED || | ||
119 | - linkEvent.type() == LinkEvent.Type.LINK_UPDATED) { | ||
120 | delegate.bumpIntents(intentsByLink.get(new LinkKey(linkEvent.subject()))); | 118 | delegate.bumpIntents(intentsByLink.get(new LinkKey(linkEvent.subject()))); |
121 | - } else if (linkEvent.type() == LinkEvent.Type.LINK_REMOVED) { | ||
122 | - delegate.failIntents(intentsByLink.get(new LinkKey(linkEvent.subject()))); | ||
123 | - } | ||
124 | } | 119 | } |
125 | } | 120 | } |
126 | } | 121 | } | ... | ... |
... | @@ -359,13 +359,5 @@ public class IntentManager | ... | @@ -359,13 +359,5 @@ public class IntentManager |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | - @Override | ||
363 | - public void failIntents(Iterable<IntentId> intentIds) { | ||
364 | - for (IntentId intentId : intentIds) { | ||
365 | - Intent intent = getIntent(intentId); | ||
366 | - uninstallIntent(intent); | ||
367 | - compileIntent(intent); | ||
368 | - } | ||
369 | - } | ||
370 | } | 362 | } |
371 | } | 363 | } | ... | ... |
... | @@ -15,12 +15,4 @@ public interface TopologyChangeDelegate { | ... | @@ -15,12 +15,4 @@ public interface TopologyChangeDelegate { |
15 | */ | 15 | */ |
16 | void bumpIntents(Iterable<IntentId> intentIds); | 16 | void bumpIntents(Iterable<IntentId> intentIds); |
17 | 17 | ||
18 | - /** | ||
19 | - * Notifies that topology has changed in such a way that the specified | ||
20 | - * intents should be marked failed and then recompiled. | ||
21 | - * | ||
22 | - * @param intentIds intents that should be failed and recompiled | ||
23 | - */ | ||
24 | - void failIntents(Iterable<IntentId> intentIds); | ||
25 | - | ||
26 | } | 18 | } | ... | ... |
... | @@ -58,6 +58,11 @@ public class DistributedFlowRuleStore | ... | @@ -58,6 +58,11 @@ public class DistributedFlowRuleStore |
58 | 58 | ||
59 | 59 | ||
60 | @Override | 60 | @Override |
61 | + public int getFlowRuleCount() { | ||
62 | + return flowEntries.size(); | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
61 | public synchronized FlowEntry getFlowEntry(FlowRule rule) { | 66 | public synchronized FlowEntry getFlowEntry(FlowRule rule) { |
62 | for (FlowEntry f : flowEntries.get(rule.deviceId())) { | 67 | for (FlowEntry f : flowEntries.get(rule.deviceId())) { |
63 | if (f.equals(rule)) { | 68 | if (f.equals(rule)) { | ... | ... |
... | @@ -58,6 +58,11 @@ public class DistributedFlowRuleStore | ... | @@ -58,6 +58,11 @@ public class DistributedFlowRuleStore |
58 | 58 | ||
59 | 59 | ||
60 | @Override | 60 | @Override |
61 | + public int getFlowRuleCount() { | ||
62 | + return flowEntries.size(); | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
61 | public synchronized FlowEntry getFlowEntry(FlowRule rule) { | 66 | public synchronized FlowEntry getFlowEntry(FlowRule rule) { |
62 | for (FlowEntry f : flowEntries.get(rule.deviceId())) { | 67 | for (FlowEntry f : flowEntries.get(rule.deviceId())) { |
63 | if (f.equals(rule)) { | 68 | if (f.equals(rule)) { | ... | ... |
... | @@ -57,6 +57,11 @@ public class SimpleFlowRuleStore | ... | @@ -57,6 +57,11 @@ public class SimpleFlowRuleStore |
57 | 57 | ||
58 | 58 | ||
59 | @Override | 59 | @Override |
60 | + public int getFlowRuleCount() { | ||
61 | + return flowEntries.size(); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
60 | public synchronized FlowEntry getFlowEntry(FlowRule rule) { | 65 | public synchronized FlowEntry getFlowEntry(FlowRule rule) { |
61 | for (FlowEntry f : flowEntries.get(rule.deviceId())) { | 66 | for (FlowEntry f : flowEntries.get(rule.deviceId())) { |
62 | if (f.equals(rule)) { | 67 | if (f.equals(rule)) { | ... | ... |
-
Please register or login to post a comment