alshabib

stats reply in progress

1 package org.onlab.onos.net.flow; 1 package org.onlab.onos.net.flow;
2 2
3 -import org.onlab.onos.net.DeviceId;
4 import org.onlab.onos.net.provider.Provider; 3 import org.onlab.onos.net.provider.Provider;
5 4
6 /** 5 /**
...@@ -27,13 +26,4 @@ public interface FlowRuleProvider extends Provider { ...@@ -27,13 +26,4 @@ public interface FlowRuleProvider extends Provider {
27 void removeFlowRule(FlowRule... flowRules); 26 void removeFlowRule(FlowRule... flowRules);
28 27
29 28
30 - /**
31 - * Returns the collection of flow entries currently applied on the given
32 - * device.
33 - *
34 - * @param deviceId device identifier
35 - * @return collection of flow entries
36 - */
37 - Iterable<FlowEntry> getFlowMetrics(DeviceId deviceId);
38 -
39 } 29 }
......
...@@ -29,4 +29,13 @@ public interface FlowRuleProviderService extends ProviderService<FlowRuleProvide ...@@ -29,4 +29,13 @@ public interface FlowRuleProviderService extends ProviderService<FlowRuleProvide
29 */ 29 */
30 void flowAdded(FlowRule flowRule); 30 void flowAdded(FlowRule flowRule);
31 31
32 + /**
33 + * Pushes the collection of flow entries currently applied on the given
34 + * device.
35 + *
36 + * @param deviceId device identifier
37 + * @return collection of flow entries
38 + */
39 + void pushFlowMetrics(Iterable<FlowEntry> flowEntries);
40 +
32 } 41 }
......
1 package org.onlab.onos.net.trivial.flow.impl; 1 package org.onlab.onos.net.trivial.flow.impl;
2 2
3 +import static com.google.common.base.Preconditions.checkNotNull;
3 import static org.slf4j.LoggerFactory.getLogger; 4 import static org.slf4j.LoggerFactory.getLogger;
4 5
5 import java.util.ArrayList; 6 import java.util.ArrayList;
...@@ -28,8 +29,6 @@ import org.onlab.onos.net.provider.AbstractProviderRegistry; ...@@ -28,8 +29,6 @@ import org.onlab.onos.net.provider.AbstractProviderRegistry;
28 import org.onlab.onos.net.provider.AbstractProviderService; 29 import org.onlab.onos.net.provider.AbstractProviderService;
29 import org.slf4j.Logger; 30 import org.slf4j.Logger;
30 31
31 -import static com.google.common.base.Preconditions.checkNotNull;
32 -
33 @Component(immediate = true) 32 @Component(immediate = true)
34 @Service 33 @Service
35 public class SimpleFlowRuleManager 34 public class SimpleFlowRuleManager
...@@ -111,8 +110,8 @@ implements FlowRuleService, FlowRuleProviderRegistry { ...@@ -111,8 +110,8 @@ implements FlowRuleService, FlowRuleProviderRegistry {
111 } 110 }
112 111
113 private class InternalFlowRuleProviderService 112 private class InternalFlowRuleProviderService
114 - extends AbstractProviderService<FlowRuleProvider> 113 + extends AbstractProviderService<FlowRuleProvider>
115 - implements FlowRuleProviderService { 114 + implements FlowRuleProviderService {
116 115
117 protected InternalFlowRuleProviderService(FlowRuleProvider provider) { 116 protected InternalFlowRuleProviderService(FlowRuleProvider provider) {
118 super(provider); 117 super(provider);
...@@ -158,6 +157,12 @@ implements FlowRuleService, FlowRuleProviderRegistry { ...@@ -158,6 +157,12 @@ implements FlowRuleService, FlowRuleProviderRegistry {
158 eventDispatcher.post(event); 157 eventDispatcher.post(event);
159 } 158 }
160 } 159 }
160 +
161 + @Override
162 + public void pushFlowMetrics(Iterable<FlowEntry> flowEntries) {
163 + // TODO Auto-generated method stub
164 +
165 + }
161 } 166 }
162 167
163 } 168 }
......
...@@ -11,7 +11,6 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -11,7 +11,6 @@ import org.apache.felix.scr.annotations.Reference;
11 import org.apache.felix.scr.annotations.ReferenceCardinality; 11 import org.apache.felix.scr.annotations.ReferenceCardinality;
12 import org.onlab.onos.net.DeviceId; 12 import org.onlab.onos.net.DeviceId;
13 import org.onlab.onos.net.flow.DefaultFlowRule; 13 import org.onlab.onos.net.flow.DefaultFlowRule;
14 -import org.onlab.onos.net.flow.FlowEntry;
15 import org.onlab.onos.net.flow.FlowRule; 14 import org.onlab.onos.net.flow.FlowRule;
16 import org.onlab.onos.net.flow.FlowRuleProvider; 15 import org.onlab.onos.net.flow.FlowRuleProvider;
17 import org.onlab.onos.net.flow.FlowRuleProviderRegistry; 16 import org.onlab.onos.net.flow.FlowRuleProviderRegistry;
...@@ -25,10 +24,18 @@ import org.onlab.onos.openflow.controller.OpenFlowEventListener; ...@@ -25,10 +24,18 @@ import org.onlab.onos.openflow.controller.OpenFlowEventListener;
25 import org.onlab.onos.openflow.controller.OpenFlowSwitch; 24 import org.onlab.onos.openflow.controller.OpenFlowSwitch;
26 import org.onlab.onos.openflow.controller.OpenFlowSwitchListener; 25 import org.onlab.onos.openflow.controller.OpenFlowSwitchListener;
27 import org.projectfloodlight.openflow.protocol.OFFlowRemoved; 26 import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
27 +import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry;
28 +import org.projectfloodlight.openflow.protocol.OFFlowStatsReply;
28 import org.projectfloodlight.openflow.protocol.OFMessage; 29 import org.projectfloodlight.openflow.protocol.OFMessage;
29 import org.projectfloodlight.openflow.protocol.OFPortStatus; 30 import org.projectfloodlight.openflow.protocol.OFPortStatus;
31 +import org.projectfloodlight.openflow.protocol.OFStatsReply;
32 +import org.projectfloodlight.openflow.protocol.OFStatsType;
30 import org.slf4j.Logger; 33 import org.slf4j.Logger;
31 34
35 +import com.google.common.collect.Lists;
36 +import com.google.common.collect.Maps;
37 +rt org.slf4j.Logger;
38 +
32 import com.google.common.collect.Maps; 39 import com.google.common.collect.Maps;
33 40
34 /** 41 /**
...@@ -95,12 +102,6 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -95,12 +102,6 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
95 102
96 } 103 }
97 104
98 - @Override
99 - public Iterable<FlowEntry> getFlowMetrics(DeviceId deviceId) {
100 - // TODO Auto-generated method stub
101 - return null;
102 - }
103 -
104 105
105 //TODO: InternalFlowRuleProvider listening to stats and error and flowremoved. 106 //TODO: InternalFlowRuleProvider listening to stats and error and flowremoved.
106 // possibly barriers as well. May not be internal at all... 107 // possibly barriers as well. May not be internal at all...
...@@ -119,7 +120,6 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -119,7 +120,6 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
119 @Override 120 @Override
120 public void switchRemoved(Dpid dpid) { 121 public void switchRemoved(Dpid dpid) {
121 collectors.remove(dpid).stop(); 122 collectors.remove(dpid).stop();
122 -
123 } 123 }
124 124
125 @Override 125 @Override
...@@ -137,6 +137,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -137,6 +137,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
137 providerService.flowRemoved(fr); 137 providerService.flowRemoved(fr);
138 break; 138 break;
139 case STATS_REPLY: 139 case STATS_REPLY:
140 + pushFlowMetrics((OFStatsReply) msg);
140 break; 141 break;
141 case BARRIER_REPLY: 142 case BARRIER_REPLY:
142 case ERROR: 143 case ERROR:
...@@ -146,6 +147,19 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -146,6 +147,19 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
146 147
147 } 148 }
148 149
150 + private void pushFlowMetrics(OFStatsReply stats) {
151 + if (stats.getStatsType() != OFStatsType.FLOW) {
152 + return;
153 + }
154 + final OFFlowStatsReply replies = (OFFlowStatsReply) stats;
155 + final List<FlowEntry> entries = Lists.newLinkedList();
156 + for (OFFlowStatsEntry reply : replies.getEntries()) {
157 +
158 + }
159 +
160 +
161 + }
162 +
149 } 163 }
150 164
151 165
......