Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.counter; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.Collection; |
| 5 | import java.util.Date; |
| 6 | import java.util.HashMap; |
| 7 | import java.util.List; |
| 8 | import java.util.Map; |
| 9 | |
| 10 | import org.openflow.protocol.OFMessage; |
| 11 | |
| 12 | import net.floodlightcontroller.core.IOFSwitch; |
| 13 | import net.floodlightcontroller.core.module.FloodlightModuleContext; |
| 14 | import net.floodlightcontroller.core.module.FloodlightModuleException; |
| 15 | import net.floodlightcontroller.core.module.IFloodlightModule; |
| 16 | import net.floodlightcontroller.core.module.IFloodlightService; |
| 17 | import net.floodlightcontroller.counter.CounterStore.NetworkLayer; |
| 18 | import net.floodlightcontroller.counter.CounterValue.CounterType; |
| 19 | import net.floodlightcontroller.packet.Ethernet; |
| 20 | |
| 21 | /** |
| 22 | * An ICounsterStoreService implementation that does nothing. |
| 23 | * This is used mainly for performance testing or if you don't |
| 24 | * want to use the counterstore. |
| 25 | * @author alexreimers |
| 26 | * |
| 27 | */ |
| 28 | public class NullCounterStore implements IFloodlightModule, |
| 29 | ICounterStoreService { |
| 30 | |
| 31 | private ICounter emptyCounter; |
| 32 | private List<String> emptyList; |
| 33 | private Map<String, ICounter> emptyMap; |
| 34 | |
| 35 | @Override |
| 36 | public void updatePacketInCounters(IOFSwitch sw, OFMessage m, Ethernet eth) { |
| 37 | // no-op |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public void updatePktOutFMCounterStore(IOFSwitch sw, OFMessage ofMsg) { |
| 42 | // no-op |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public List<String> |
| 47 | getAllCategories(String counterName, NetworkLayer layer) { |
| 48 | return emptyList; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public ICounter createCounter(String key, CounterType type) { |
| 53 | return emptyCounter; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public ICounter getCounter(String key) { |
| 58 | return emptyCounter; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public Map<String, ICounter> getAll() { |
| 63 | return emptyMap; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public Collection<Class<? extends IFloodlightService>> getModuleServices() { |
| 68 | Collection<Class<? extends IFloodlightService>> services = |
| 69 | new ArrayList<Class<? extends IFloodlightService>>(1); |
| 70 | services.add(ICounterStoreService.class); |
| 71 | return services; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public Map<Class<? extends IFloodlightService>, IFloodlightService> |
| 76 | getServiceImpls() { |
| 77 | Map<Class<? extends IFloodlightService>, |
| 78 | IFloodlightService> m = |
| 79 | new HashMap<Class<? extends IFloodlightService>, |
| 80 | IFloodlightService>(); |
| 81 | m.put(ICounterStoreService.class, this); |
| 82 | return m; |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public Collection<Class<? extends IFloodlightService>> |
| 87 | getModuleDependencies() { |
| 88 | // None, return null |
| 89 | return null; |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public void init(FloodlightModuleContext context) |
| 94 | throws FloodlightModuleException { |
| 95 | emptyCounter = new SimpleCounter(new Date(), CounterType.LONG); |
| 96 | emptyList = new ArrayList<String>(); |
| 97 | emptyMap = new HashMap<String, ICounter>(); |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public void startUp(FloodlightModuleContext context) { |
| 102 | // no-op |
| 103 | } |
| 104 | } |