@Test public void testCounterHierarchy() { S1.updateCounterNoFlush(); S2.updateCounterNoFlush(2); L_t.updateCounterNoFlush(3); S1_pi.updateCounterNoFlush(10); S1_po.updateCounterNoFlush(20); S1_pi_d.updateCounterNoFlush(100); S1_pi_e.updateCounterNoFlush(105); dc.flushCounters(); checkCounters(1, 2, 3, 10, 20, 100, 105); }
@Override public void flushCounters() { LocalCounterInfo[] thiscounters = this.threadlocalCounters.get(); Set<Integer> thisset = this.threadlocalCurrentCounters.get(); ArrayList<Integer> temp = new ArrayList<Integer>(); for (int counterId : thisset) { LocalCounterInfo lc = thiscounters[counterId]; if (lc.cvalue.get() > 0) { DebugCounterInfo dc = allCounters[counterId]; if (dc.cinfo.enabled) { dc.cvalue.addAndGet(lc.cvalue.get()); lc.cvalue.set(0); } else { lc.enabled = false; temp.add(counterId); } } } for (int cId : temp) { thisset.remove(cId); } Sets.SetView<Integer> sv = Sets.difference(currentCounters, thisset); for (int counterId : sv) { if (thiscounters[counterId] != null) { thiscounters[counterId].enabled = true; thisset.add(counterId); } } }
DebugCounter implements IFloodlightModule, IDebugCounterService { @Override public void flushCounters() { LocalCounterInfo[] thiscounters = this.threadlocalCounters.get(); Set<Integer> thisset = this.threadlocalCurrentCounters.get(); ArrayList<Integer> temp = new ArrayList<Integer>(); for (int counterId : thisset) { LocalCounterInfo lc = thiscounters[counterId]; if (lc.cvalue.get() > 0) { DebugCounterInfo dc = allCounters[counterId]; if (dc.cinfo.enabled) { dc.cvalue.addAndGet(lc.cvalue.get()); lc.cvalue.set(0); } else { lc.enabled = false; temp.add(counterId); } } } for (int cId : temp) { thisset.remove(cId); } Sets.SetView<Integer> sv = Sets.difference(currentCounters, thisset); for (int counterId : sv) { if (thiscounters[counterId] != null) { thiscounters[counterId].enabled = true; thisset.add(counterId); } } } }
DebugCounter implements IFloodlightModule, IDebugCounterService { @Override public void flushCounters() { LocalCounterInfo[] thiscounters = this.threadlocalCounters.get(); Set<Integer> thisset = this.threadlocalCurrentCounters.get(); ArrayList<Integer> temp = new ArrayList<Integer>(); for (int counterId : thisset) { LocalCounterInfo lc = thiscounters[counterId]; if (lc.cvalue.get() > 0) { DebugCounterInfo dc = allCounters[counterId]; if (dc.cinfo.enabled) { dc.cvalue.addAndGet(lc.cvalue.get()); lc.cvalue.set(0); } else { lc.enabled = false; temp.add(counterId); } } } for (int cId : temp) { thisset.remove(cId); } Sets.SetView<Integer> sv = Sets.difference(currentCounters, thisset); for (int counterId : sv) { if (thiscounters[counterId] != null) { thiscounters[counterId].enabled = true; thisset.add(counterId); } } }  }
DebugCounter implements IFloodlightModule, IDebugCounterService { @Override public void flushCounters() { LocalCounterInfo[] thiscounters = this.threadlocalCounters.get(); Set<Integer> thisset = this.threadlocalCurrentCounters.get(); ArrayList<Integer> temp = new ArrayList<Integer>(); for (int counterId : thisset) { LocalCounterInfo lc = thiscounters[counterId]; if (lc.cvalue.get() > 0) { DebugCounterInfo dc = allCounters[counterId]; if (dc.cinfo.enabled) { dc.cvalue.addAndGet(lc.cvalue.get()); lc.cvalue.set(0); } else { lc.enabled = false; temp.add(counterId); } } } for (int cId : temp) { thisset.remove(cId); } Sets.SetView<Integer> sv = Sets.difference(currentCounters, thisset); for (int counterId : sv) { if (thiscounters[counterId] != null) { thiscounters[counterId].enabled = true; thisset.add(counterId); } } }  @Override IDebugCounter registerCounter(String moduleName, String counterHierarchy,
                           String counterDescription, CounterType counterType,
                           String... metaData); @Override void flushCounters(); @Override void resetCounterHierarchy(String moduleName, String counterHierarchy); @Override void resetAllCounters(); @Override void resetAllModuleCounters(String moduleName); @Override void enableCtrOnDemand(String moduleName, String counterHierarchy); @Override void disableCtrOnDemand(String moduleName, String counterHierarchy); @Override List<DebugCounterInfo> getCounterHierarchy(String moduleName,
                                                     String counterHierarchy); @Override List<DebugCounterInfo> getAllCounterValues(); @Override List<DebugCounterInfo> getModuleCounterValues(String moduleName); @Override boolean containsModuleCounterHierarchy(String moduleName,
                                                 String counterHierarchy); @Override boolean containsModuleName(String moduleName); @Override List<String> getModuleList(); @Override List<String> getModuleCounterList(String moduleName); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); }
DebugCounter implements IFloodlightModule, IDebugCounterService { @Override public void flushCounters() { LocalCounterInfo[] thiscounters = this.threadlocalCounters.get(); Set<Integer> thisset = this.threadlocalCurrentCounters.get(); ArrayList<Integer> temp = new ArrayList<Integer>(); for (int counterId : thisset) { LocalCounterInfo lc = thiscounters[counterId]; if (lc.cvalue.get() > 0) { DebugCounterInfo dc = allCounters[counterId]; if (dc.cinfo.enabled) { dc.cvalue.addAndGet(lc.cvalue.get()); lc.cvalue.set(0); } else { lc.enabled = false; temp.add(counterId); } } } for (int cId : temp) { thisset.remove(cId); } Sets.SetView<Integer> sv = Sets.difference(currentCounters, thisset); for (int counterId : sv) { if (thiscounters[counterId] != null) { thiscounters[counterId].enabled = true; thisset.add(counterId); } } }  @Override IDebugCounter registerCounter(String moduleName, String counterHierarchy,
                           String counterDescription, CounterType counterType,
                           String... metaData); @Override void flushCounters(); @Override void resetCounterHierarchy(String moduleName, String counterHierarchy); @Override void resetAllCounters(); @Override void resetAllModuleCounters(String moduleName); @Override void enableCtrOnDemand(String moduleName, String counterHierarchy); @Override void disableCtrOnDemand(String moduleName, String counterHierarchy); @Override List<DebugCounterInfo> getCounterHierarchy(String moduleName,
                                                     String counterHierarchy); @Override List<DebugCounterInfo> getAllCounterValues(); @Override List<DebugCounterInfo> getModuleCounterValues(String moduleName); @Override boolean containsModuleCounterHierarchy(String moduleName,
                                                 String counterHierarchy); @Override boolean containsModuleName(String moduleName); @Override List<String> getModuleList(); @Override List<String> getModuleCounterList(String moduleName); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context);  }