diff --git a/src/main/java/net/floodlightcontroller/core/CoreModule.java b/src/main/java/net/floodlightcontroller/core/CoreModule.java index be4ebc25e644ca7794cc2930c5125e961f363f82..4ca2026b04c1fb0e8ea1349aedcab80d56e8934b 100644 --- a/src/main/java/net/floodlightcontroller/core/CoreModule.java +++ b/src/main/java/net/floodlightcontroller/core/CoreModule.java @@ -10,7 +10,6 @@ import net.floodlightcontroller.core.module.FloodlightModuleContext; import net.floodlightcontroller.core.module.FloodlightModuleException; import net.floodlightcontroller.core.module.IFloodlightModule; import net.floodlightcontroller.core.module.IFloodlightService; -import net.floodlightcontroller.counter.CounterStore; import net.floodlightcontroller.counter.ICounterStoreService; import net.floodlightcontroller.perfmon.IPktInProcessingTimeService; import net.floodlightcontroller.restserver.IRestApiService; @@ -22,9 +21,8 @@ public class CoreModule implements IFloodlightModule { @Override public Collection<Class<? extends IFloodlightService>> getModuleServices() { Collection<Class<? extends IFloodlightService>> services = - new ArrayList<Class<? extends IFloodlightService>>(2); + new ArrayList<Class<? extends IFloodlightService>>(1); services.add(IFloodlightProviderService.class); - services.add(ICounterStoreService.class); return services; } @@ -32,26 +30,24 @@ public class CoreModule implements IFloodlightModule { public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() { controller = new Controller(); - ICounterStoreService counterStore = new CounterStore(); - controller.setCounterStore(counterStore); Map<Class<? extends IFloodlightService>, IFloodlightService> m = new HashMap<Class<? extends IFloodlightService>, IFloodlightService>(); m.put(IFloodlightProviderService.class, controller); - m.put(ICounterStoreService.class, counterStore); return m; } @Override public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { Collection<Class<? extends IFloodlightService>> dependencies = - new ArrayList<Class<? extends IFloodlightService>>(4); + new ArrayList<Class<? extends IFloodlightService>>(5); dependencies.add(IStorageSourceService.class); dependencies.add(IOFMessageFilterManagerService.class); dependencies.add(IPktInProcessingTimeService.class); dependencies.add(IRestApiService.class); + dependencies.add(ICounterStoreService.class); return dependencies; } diff --git a/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleLoader.java b/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleLoader.java index 9781c398f85404b8055887d34f63953239b54cc8..e8bf4ac7443e3b07d30f1c2a5100aec3654dae9a 100644 --- a/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleLoader.java +++ b/src/main/java/net/floodlightcontroller/core/module/FloodlightModuleLoader.java @@ -96,9 +96,9 @@ public class FloodlightModuleLoader { } /** - * Loads - * @param fName - * @return + * Loads the modules from a specified configuration file. + * @param fName The configuration file path + * @return An IFloodlightModuleContext with all the modules to be started * @throws FloodlightModuleException */ public IFloodlightModuleContext loadModulesFromConfig(String fName) diff --git a/src/main/java/net/floodlightcontroller/core/module/IFloodlightModule.java b/src/main/java/net/floodlightcontroller/core/module/IFloodlightModule.java index 003e0a119d1eeda8abc1a7ee45798e552622956f..23f1ad71dd06d1e5c9b9518210eb950ce87843c0 100644 --- a/src/main/java/net/floodlightcontroller/core/module/IFloodlightModule.java +++ b/src/main/java/net/floodlightcontroller/core/module/IFloodlightModule.java @@ -71,7 +71,4 @@ public interface IFloodlightModule { */ void startUp(FloodlightModuleContext context); - - // TODO add getName() getId() - } diff --git a/src/main/java/net/floodlightcontroller/core/module/IFloodlightService.java b/src/main/java/net/floodlightcontroller/core/module/IFloodlightService.java index 8bf26cca38d3d8a8d0ec0b80f23ea19616fb8327..5974b3a71d0d7d839226864c470cb46f1f78f3b3 100644 --- a/src/main/java/net/floodlightcontroller/core/module/IFloodlightService.java +++ b/src/main/java/net/floodlightcontroller/core/module/IFloodlightService.java @@ -6,7 +6,6 @@ package net.floodlightcontroller.core.module; * @author alexreimers * */ -// TODO change this to IFloodlightExclusiveService public abstract interface IFloodlightService { // This space is intentionally left blank....don't touch it } diff --git a/src/main/java/net/floodlightcontroller/counter/CounterStore.java b/src/main/java/net/floodlightcontroller/counter/CounterStore.java index 6f497e7683000983eedb7eea9413a528b5d3d58b..bcbb2b0951035b27108e8eb737897d54184fead4 100644 --- a/src/main/java/net/floodlightcontroller/counter/CounterStore.java +++ b/src/main/java/net/floodlightcontroller/counter/CounterStore.java @@ -21,7 +21,9 @@ package net.floodlightcontroller.counter; import java.util.ArrayList; +import java.util.Collection; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -31,6 +33,10 @@ import java.util.concurrent.TimeUnit; import javax.annotation.PostConstruct; import net.floodlightcontroller.core.IOFSwitch; +import net.floodlightcontroller.core.module.FloodlightModuleContext; +import net.floodlightcontroller.core.module.FloodlightModuleException; +import net.floodlightcontroller.core.module.IFloodlightModule; +import net.floodlightcontroller.core.module.IFloodlightService; import net.floodlightcontroller.counter.CounterValue.CounterType; import net.floodlightcontroller.packet.Ethernet; import net.floodlightcontroller.packet.IPv4; @@ -45,7 +51,7 @@ import org.slf4j.LoggerFactory; * @author kyle * */ -public class CounterStore implements ICounterStoreService { +public class CounterStore implements IFloodlightModule, ICounterStoreService { protected static Logger log = LoggerFactory.getLogger(CounterStore.class); public enum NetworkLayer { @@ -432,4 +438,39 @@ public class CounterStore implements ICounterStoreService { return ret; } + @Override + public Collection<Class<? extends IFloodlightService>> getModuleServices() { + Collection<Class<? extends IFloodlightService>> services = + new ArrayList<Class<? extends IFloodlightService>>(1); + services.add(ICounterStoreService.class); + return services; + } + + @Override + public Map<Class<? extends IFloodlightService>, IFloodlightService> + getServiceImpls() { + Map<Class<? extends IFloodlightService>, + IFloodlightService> m = + new HashMap<Class<? extends IFloodlightService>, + IFloodlightService>(); + m.put(ICounterStoreService.class, this); + return m; + } + + @Override + public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { + // no-op, no dependencies + return null; + } + + @Override + public void init(FloodlightModuleContext context) + throws FloodlightModuleException { + // no-op for now + } + + @Override + public void startUp(FloodlightModuleContext context) { + // no-op for now + } } diff --git a/src/main/java/net/floodlightcontroller/counter/NullCounterStore.java b/src/main/java/net/floodlightcontroller/counter/NullCounterStore.java new file mode 100644 index 0000000000000000000000000000000000000000..fed8c1e4ec4cee3d9b66d997e4648a36a2222e0e --- /dev/null +++ b/src/main/java/net/floodlightcontroller/counter/NullCounterStore.java @@ -0,0 +1,104 @@ +package net.floodlightcontroller.counter; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.openflow.protocol.OFMessage; + +import net.floodlightcontroller.core.IOFSwitch; +import net.floodlightcontroller.core.module.FloodlightModuleContext; +import net.floodlightcontroller.core.module.FloodlightModuleException; +import net.floodlightcontroller.core.module.IFloodlightModule; +import net.floodlightcontroller.core.module.IFloodlightService; +import net.floodlightcontroller.counter.CounterStore.NetworkLayer; +import net.floodlightcontroller.counter.CounterValue.CounterType; +import net.floodlightcontroller.packet.Ethernet; + +/** + * An ICounsterStoreService implementation that does nothing. + * This is used mainly for performance testing or if you don't + * want to use the counterstore. + * @author alexreimers + * + */ +public class NullCounterStore implements IFloodlightModule, + ICounterStoreService { + + private ICounter emptyCounter; + private List<String> emptyList; + private Map<String, ICounter> emptyMap; + + @Override + public void updatePacketInCounters(IOFSwitch sw, OFMessage m, Ethernet eth) { + // no-op + } + + @Override + public void updatePktOutFMCounterStore(IOFSwitch sw, OFMessage ofMsg) { + // no-op + } + + @Override + public List<String> + getAllCategories(String counterName, NetworkLayer layer) { + return emptyList; + } + + @Override + public ICounter createCounter(String key, CounterType type) { + return emptyCounter; + } + + @Override + public ICounter getCounter(String key) { + return emptyCounter; + } + + @Override + public Map<String, ICounter> getAll() { + return emptyMap; + } + + @Override + public Collection<Class<? extends IFloodlightService>> getModuleServices() { + Collection<Class<? extends IFloodlightService>> services = + new ArrayList<Class<? extends IFloodlightService>>(1); + services.add(ICounterStoreService.class); + return services; + } + + @Override + public Map<Class<? extends IFloodlightService>, IFloodlightService> + getServiceImpls() { + Map<Class<? extends IFloodlightService>, + IFloodlightService> m = + new HashMap<Class<? extends IFloodlightService>, + IFloodlightService>(); + m.put(ICounterStoreService.class, this); + return m; + } + + @Override + public Collection<Class<? extends IFloodlightService>> + getModuleDependencies() { + // None, return null + return null; + } + + @Override + public void init(FloodlightModuleContext context) + throws FloodlightModuleException { + emptyCounter = new SimpleCounter(new Date(), CounterType.LONG); + emptyList = new ArrayList<String>(); + emptyMap = new HashMap<String, ICounter>(); + } + + @Override + public void startUp(FloodlightModuleContext context) { + // no-op + } +} diff --git a/src/main/java/net/floodlightcontroller/perfmon/CircularTimeBucketSet.java b/src/main/java/net/floodlightcontroller/perfmon/CircularTimeBucketSet.java new file mode 100644 index 0000000000000000000000000000000000000000..f52d90b1d835cdfbce17a8d5eb8a6a69e7feb179 --- /dev/null +++ b/src/main/java/net/floodlightcontroller/perfmon/CircularTimeBucketSet.java @@ -0,0 +1,103 @@ +package net.floodlightcontroller.perfmon; + +import net.floodlightcontroller.core.IOFMessageListener.FlListenerID; + +public class CircularTimeBucketSet { + + /** + * How many timer buckets have valid data, initially it is false then it + * stays at true after the circle is completed + */ + boolean allBucketsValid; + int curBucketIdx; // most recent bucket *being* filled + int numComps; + CumulativeTimeBucket [] timeBucketSet; + // TBD: Somehow need to get BB last listener id from BB + protected static final int BB_LAST_LISTENER_ID = 13; + protected static final int ONE_BUCKET_DURATION_SECONDS_INT = 10;// seconds + + public boolean isAllBucketsValid() { + return allBucketsValid; + } + + public void setAllBucketsValid(boolean allBucketsValid) { + this.allBucketsValid = allBucketsValid; + } + + public int getCurBucketIdx() { + return curBucketIdx; + } + + public void setCurBucketIdx(int curBucketIdx) { + this.curBucketIdx = curBucketIdx; + } + + public int getNumComps() { + return numComps; + } + + public CumulativeTimeBucket[] getTimeBucketSet() { + return timeBucketSet; + } + + public void setTimeBucketSet(CumulativeTimeBucket[] timeBucketSet) { + this.timeBucketSet = timeBucketSet; + } + + private int computeSigma(int sum, Long sumSquared, int count) { + // Computes std. deviation from the sum of count numbers and from + // the sum of the squares of count numbers + Long temp = (long) sum; + temp = temp * temp / count; + temp = (sumSquared - temp) / count; + return (int) Math.sqrt((double)temp); + } + + public CircularTimeBucketSet(int numComps, int numBuckets) { + timeBucketSet = new CumulativeTimeBucket[numBuckets]; + for (int idx= 0; idx < numBuckets; idx++) { + timeBucketSet[idx] = new CumulativeTimeBucket(numComps); + timeBucketSet[idx].setBucketNo(idx); + } + allBucketsValid = false; + curBucketIdx = 0; + this.numComps = numComps; + } + + // Called when the bucket time ends + public void fillTimeBucket(CumulativeTimeBucket ctb, int numBuckets) { + // Wrap up computations on the current bucket data + // The following operation can be done in the front end instead of + // here if it turns out to be a performance issue + if (ctb.totalPktCnt > 0) { + ctb.avgTotalProcTime_us = + ctb.totalSumProcTime_us / ctb.totalPktCnt; + ctb.sigmaTotalProcTime_us = + computeSigma(ctb.totalSumProcTime_us, + ctb.totalSumSquaredProcTime_us, ctb.totalPktCnt); + + // Find the avg and std. dev. of each component's proc. time + for (int idx = FlListenerID.FL_FIRST_LISTENER_ID; + idx <= BB_LAST_LISTENER_ID; idx++) { + OneComponentTime oct = ctb.tComps.oneComp[idx]; + if (oct.pktCnt > 0) { + oct.avgProcTime_us = oct.sumProcTime_us / oct.pktCnt; + oct.sigmaProcTime_us = computeSigma(oct.sumProcTime_us, + oct.sumSquaredProcTime_us2, oct.pktCnt); + } + } + } + ctb.duration_s = ONE_BUCKET_DURATION_SECONDS_INT; + + // Move to the new bucket + if (curBucketIdx >= numBuckets-1) { + curBucketIdx = 0; + allBucketsValid = true; + } else { + curBucketIdx++; + } + // Get the next bucket to be filled ready + ctb = timeBucketSet[curBucketIdx]; + ctb.initializeCumulativeTimeBucket(ctb); + } +} \ No newline at end of file diff --git a/src/main/java/net/floodlightcontroller/perfmon/IPktInProcessingTimeService.java b/src/main/java/net/floodlightcontroller/perfmon/IPktInProcessingTimeService.java index b6bf1dd9e8349e3810b818532715a54f6eed1778..92eaca4e8250fc2d9b988fcf871a563a1dcd8437 100644 --- a/src/main/java/net/floodlightcontroller/perfmon/IPktInProcessingTimeService.java +++ b/src/main/java/net/floodlightcontroller/perfmon/IPktInProcessingTimeService.java @@ -1,35 +1,15 @@ package net.floodlightcontroller.perfmon; import net.floodlightcontroller.core.module.IFloodlightService; -import net.floodlightcontroller.perfmon.PktInProcessingTime.CircularTimeBucketSet; -import net.floodlightcontroller.perfmon.PktInProcessingTime.PerfMonConfigs; +import net.floodlightcontroller.perfmon.CircularTimeBucketSet; +import net.floodlightcontroller.perfmon.PerfMonConfigs; public interface IPktInProcessingTimeService extends IFloodlightService { - public Long getLastPktTime_ns(); - - public void setLastPktTime_ns(Long lastPktTime_ns); - - public long getCurBucketStartTime(); - - public void setCurBucketStartTime(long curBucketStartTime); - - public CumulativeTimeBucket getCtb(); - - public void setCtb(CumulativeTimeBucket ctb); - public CircularTimeBucketSet getCtbs(); - public void setCtbs(CircularTimeBucketSet ctbs); - public PerfMonConfigs getPerfMonCfgs(); - public void setPerfMonCfgs(PerfMonConfigs perfMonCfgs); - - public int getNumComponents(); - - public void setNumComponents(int numComponents); - public long getStartTimeOnePkt(); // Component refers to software component like forwarding diff --git a/src/main/java/net/floodlightcontroller/perfmon/NullPktInProcessingTime.java b/src/main/java/net/floodlightcontroller/perfmon/NullPktInProcessingTime.java new file mode 100644 index 0000000000000000000000000000000000000000..41df42886336bf3e69f4e4a2bf16b16aeff7bc05 --- /dev/null +++ b/src/main/java/net/floodlightcontroller/perfmon/NullPktInProcessingTime.java @@ -0,0 +1,95 @@ +package net.floodlightcontroller.perfmon; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import net.floodlightcontroller.core.module.FloodlightModuleContext; +import net.floodlightcontroller.core.module.FloodlightModuleException; +import net.floodlightcontroller.core.module.IFloodlightModule; +import net.floodlightcontroller.core.module.IFloodlightService; +import net.floodlightcontroller.perfmon.CircularTimeBucketSet; +import net.floodlightcontroller.perfmon.PerfMonConfigs; + +/** + * An IPktInProcessingTimeService implementation that does nothing. + * This is used mainly for performance testing or if you don't + * want to use the IPktInProcessingTimeService features. + * @author alexreimers + * + */ +public class NullPktInProcessingTime + implements IFloodlightModule, IPktInProcessingTimeService { + + private CircularTimeBucketSet emptyBucket; + private PerfMonConfigs emptyConfig; + + public Collection<Class<? extends IFloodlightService>> getModuleServices() { + Collection<Class<? extends IFloodlightService>> l = + new ArrayList<Class<? extends IFloodlightService>>(); + l.add(IPktInProcessingTimeService.class); + return l; + } + + @Override + public Map<Class<? extends IFloodlightService>, IFloodlightService> + getServiceImpls() { + Map<Class<? extends IFloodlightService>, + IFloodlightService> m = + new HashMap<Class<? extends IFloodlightService>, + IFloodlightService>(); + // We are the class that implements the service + m.put(IPktInProcessingTimeService.class, this); + return m; + } + + @Override + public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { + // We don't have any dependencies + return null; + } + + @Override + public void init(FloodlightModuleContext context) + throws FloodlightModuleException { + emptyBucket = new CircularTimeBucketSet(0, 0); + emptyConfig = new PerfMonConfigs(); + } + + @Override + public void startUp(FloodlightModuleContext context) { + // no-op + } + + @Override + public CircularTimeBucketSet getCtbs() { + return emptyBucket; + } + + @Override + public PerfMonConfigs getPerfMonCfgs() { + return emptyConfig; + } + + @Override + public long getStartTimeOnePkt() { + return 0; + } + + @Override + public long getStartTimeOneComponent() { + return 0; + } + + @Override + public void updateCumulativeTimeOneComp(long onePktOneCompProcTime_ns, + int id) { + // no-op + } + + @Override + public void updateCumulativeTimeTotal(long onePktStartTime_ns) { + // no-op + } +} diff --git a/src/main/java/net/floodlightcontroller/perfmon/PerfMonConfigs.java b/src/main/java/net/floodlightcontroller/perfmon/PerfMonConfigs.java new file mode 100644 index 0000000000000000000000000000000000000000..fb6330a4cb3789e63e56f2931427101ced8b78b6 --- /dev/null +++ b/src/main/java/net/floodlightcontroller/perfmon/PerfMonConfigs.java @@ -0,0 +1,42 @@ +package net.floodlightcontroller.perfmon; + +public class PerfMonConfigs { + /*** + * procTimeMonitoringState: true if monitoring is on, default is false + * this variable is controller using a cli under the controller node + * (config-controller)> [no] performance-monitor processing-time + */ + protected boolean procTimeMonitoringState; + // overall per-component performance monitoring knob; off by default + protected boolean procTimePerCompMonitoringState; + // knob for database performance monitoring + protected boolean dbTimePerfMonState; + + public boolean isProcTimeMonitoringState() { + return procTimeMonitoringState; + } + public void setProcTimeMonitoringState( + boolean procTimeMonitoringState) { + this.procTimeMonitoringState = procTimeMonitoringState; + } + public boolean isProcTimePerCompMonitoringState() { + return procTimePerCompMonitoringState; + } + public void setProcTimePerCompMonitoringState( + boolean procTimePerCompMonitoringState) { + this.procTimePerCompMonitoringState = + procTimePerCompMonitoringState; + } + public boolean isDbTimePerfMonState() { + return dbTimePerfMonState; + } + public void setDbTimePerfMonState(boolean dbTimePerfMonState) { + this.dbTimePerfMonState = dbTimePerfMonState; + } + + public PerfMonConfigs() { + procTimeMonitoringState = false; + procTimePerCompMonitoringState = false; + dbTimePerfMonState = false; + } +} \ No newline at end of file diff --git a/src/main/java/net/floodlightcontroller/perfmon/PktInProcessingTime.java b/src/main/java/net/floodlightcontroller/perfmon/PktInProcessingTime.java index ea89fd824200f4da76e10827118bec859bf57095..0e60d0b6e1bf283444cdf68f20fbc0cac7166b61 100644 --- a/src/main/java/net/floodlightcontroller/perfmon/PktInProcessingTime.java +++ b/src/main/java/net/floodlightcontroller/perfmon/PktInProcessingTime.java @@ -52,49 +52,6 @@ public class PktInProcessingTime protected static Logger logger = LoggerFactory.getLogger(PktInProcessingTime.class); - /*** - * procTimeMonitoringState: true if monitoring is on, default is false - * this variable is controller using a cli under the controller node - * (config-controller)> [no] performance-monitor processing-time - */ - - public class PerfMonConfigs { - // overall performance monitoring knob; turned off by default - protected boolean procTimeMonitoringState; - // overall per-component performance monitoring knob; off by default - protected boolean procTimePerCompMonitoringState; - // knob for database performance monitoring - protected boolean dbTimePerfMonState; - - public boolean isProcTimeMonitoringState() { - return procTimeMonitoringState; - } - public void setProcTimeMonitoringState( - boolean procTimeMonitoringState) { - this.procTimeMonitoringState = procTimeMonitoringState; - } - public boolean isProcTimePerCompMonitoringState() { - return procTimePerCompMonitoringState; - } - public void setProcTimePerCompMonitoringState( - boolean procTimePerCompMonitoringState) { - this.procTimePerCompMonitoringState = - procTimePerCompMonitoringState; - } - public boolean isDbTimePerfMonState() { - return dbTimePerfMonState; - } - public void setDbTimePerfMonState(boolean dbTimePerfMonState) { - this.dbTimePerfMonState = dbTimePerfMonState; - } - - public PerfMonConfigs() { - procTimeMonitoringState = false; - procTimePerCompMonitoringState = false; - dbTimePerfMonState = false; - } - } - protected PerfMonConfigs perfMonCfgs; // Maintains the time when the last packet was processed protected long lastPktTime_ns; @@ -106,48 +63,31 @@ public class PktInProcessingTime private int numBuckets; // number of time buckets, each 10s long - /* (non-Javadoc) - * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#getLastPktTime_ns() - */ - @Override + public Long getLastPktTime_ns() { return lastPktTime_ns; } - /* (non-Javadoc) - * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#setLastPktTime_ns(java.lang.Long) - */ - @Override + public void setLastPktTime_ns(Long lastPktTime_ns) { this.lastPktTime_ns = lastPktTime_ns; } - /* (non-Javadoc) - * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#getCurBucketStartTime() - */ - @Override + public long getCurBucketStartTime() { return curBucketStartTime; } - /* (non-Javadoc) - * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#setCurBucketStartTime(long) - */ - @Override + public void setCurBucketStartTime(long curBucketStartTime) { this.curBucketStartTime = curBucketStartTime; } - /* (non-Javadoc) - * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#getCtb() - */ - @Override + public CumulativeTimeBucket getCtb() { return ctb; } - /* (non-Javadoc) - * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#setCtb(net.floodlightcontroller.perfmon.CumulativeTimeBucket) - */ - @Override + public void setCtb(CumulativeTimeBucket ctb) { this.ctb = ctb; } + /* (non-Javadoc) * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#getCtbs() */ @@ -155,10 +95,7 @@ public class PktInProcessingTime public CircularTimeBucketSet getCtbs() { return ctbs; } - /* (non-Javadoc) - * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#setCtbs(net.floodlightcontroller.perfmon.PktinProcessingTime.CircularTimeBucketSet) - */ - @Override + public void setCtbs(CircularTimeBucketSet ctbs) { this.ctbs = ctbs; } @@ -169,24 +106,15 @@ public class PktInProcessingTime public PerfMonConfigs getPerfMonCfgs() { return perfMonCfgs; } - /* (non-Javadoc) - * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#setPerfMonCfgs(net.floodlightcontroller.perfmon.PktinProcessingTime.PerfMonConfigs) - */ - @Override + public void setPerfMonCfgs(PerfMonConfigs perfMonCfgs) { this.perfMonCfgs = perfMonCfgs; } - /* (non-Javadoc) - * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#getNumComponents() - */ - @Override + public int getNumComponents() { return numComponents; } - /* (non-Javadoc) - * @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#setNumComponents(int) - */ - @Override + public void setNumComponents(int numComponents) { this.numComponents = numComponents; } @@ -203,7 +131,6 @@ public class PktInProcessingTime * of 30*10s = 5mins of processing time data is maintained */ protected static final long ONE_BUCKET_DURATION_SECONDS_LONG = 10;// seconds - protected static final int ONE_BUCKET_DURATION_SECONDS_INT = 10;// seconds protected static final long ONE_BUCKET_DURATION_NANOSECONDS = ONE_BUCKET_DURATION_SECONDS_LONG * 1000000000; protected static final int BUCKET_SET_SIZE = 360; // 1hr (=1*60*60/10) @@ -253,7 +180,7 @@ public class PktInProcessingTime if ((curTime_ns - this.ctb.startTime_ns) > ONE_BUCKET_DURATION_NANOSECONDS) { // Go to next bucket - this.ctbs.fillTimeBucket(); + this.ctbs.fillTimeBucket(ctb, numBuckets); /*** * We might not have received packets for long time, in which case * there would be a gap in the start-time of the timer buckets @@ -341,102 +268,7 @@ public class PktInProcessingTime } - public class CircularTimeBucketSet { - - /** - * How many timer buckets have valid data, initially it is false then it - * stays at true after the circle is completed - */ - boolean allBucketsValid; - int curBucketIdx; // most recent bucket *being* filled - int numComps; - CumulativeTimeBucket [] timeBucketSet; - - public boolean isAllBucketsValid() { - return allBucketsValid; - } - - public void setAllBucketsValid(boolean allBucketsValid) { - this.allBucketsValid = allBucketsValid; - } - - public int getCurBucketIdx() { - return curBucketIdx; - } - - public void setCurBucketIdx(int curBucketIdx) { - this.curBucketIdx = curBucketIdx; - } - - public int getNumComps() { - return numComps; - } - - public CumulativeTimeBucket[] getTimeBucketSet() { - return timeBucketSet; - } - - public void setTimeBucketSet(CumulativeTimeBucket[] timeBucketSet) { - this.timeBucketSet = timeBucketSet; - } - - private int computeSigma(int sum, Long sumSquared, int count) { - // Computes std. deviation from the sum of count numbers and from - // the sum of the squares of count numbers - Long temp = (long) sum; - temp = temp * temp / count; - temp = (sumSquared - temp) / count; - return (int) Math.sqrt((double)temp); - } - - public CircularTimeBucketSet(int numComps, int numBuckets) { - timeBucketSet = new CumulativeTimeBucket[numBuckets]; - for (int idx= 0; idx < numBuckets; idx++) { - timeBucketSet[idx] = new CumulativeTimeBucket(numComps); - timeBucketSet[idx].setBucketNo(idx); - } - allBucketsValid = false; - curBucketIdx = 0; - this.numComps = numComps; - } - - // Called when the bucket time ends - public void fillTimeBucket() { - // Wrap up computations on the current bucket data - // The following operation can be done in the front end instead of - // here if it turns out to be a performance issue - if (ctb.totalPktCnt > 0) { - ctb.avgTotalProcTime_us = - ctb.totalSumProcTime_us / ctb.totalPktCnt; - ctb.sigmaTotalProcTime_us = - computeSigma(ctb.totalSumProcTime_us, - ctb.totalSumSquaredProcTime_us, ctb.totalPktCnt); - - // Find the avg and std. dev. of each component's proc. time - for (int idx = FlListenerID.FL_FIRST_LISTENER_ID; - idx <= BB_LAST_LISTENER_ID; idx++) { - OneComponentTime oct = ctb.tComps.oneComp[idx]; - if (oct.pktCnt > 0) { - oct.avgProcTime_us = oct.sumProcTime_us / oct.pktCnt; - oct.sigmaProcTime_us = computeSigma(oct.sumProcTime_us, - oct.sumSquaredProcTime_us2, oct.pktCnt); - } - } - } - ctb.duration_s = ONE_BUCKET_DURATION_SECONDS_INT; - - // Move to the new bucket - if (curBucketIdx >= numBuckets-1) { - curBucketIdx = 0; - allBucketsValid = true; - } else { - curBucketIdx++; - } - // Get the next bucket to be filled ready - ctb = timeBucketSet[curBucketIdx]; - ctb.initializeCumulativeTimeBucket(ctb); - } - } + public PktInProcessingTime() { perfMonCfgs = new PerfMonConfigs(); diff --git a/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule b/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule index 5050ab43615797c9d4c0e9fe4c0e26bb96e08b4e..4230fd5274a18d2af4fba7a9120deadc04b31049 100644 --- a/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule +++ b/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule @@ -7,7 +7,10 @@ net.floodlightcontroller.forwarding.Forwarding net.floodlightcontroller.core.OFMessageFilterManager net.floodlightcontroller.staticflowentry.StaticFlowEntryPusher net.floodlightcontroller.perfmon.PktInProcessingTime +net.floodlightcontroller.perfmon.NullPktInProcessingTime net.floodlightcontroller.restserver.RestApiServer net.floodlightcontroller.learningswitch.LearningSwitch net.floodlightcontroller.hub.Hub -net.floodlightcontroller.jython.JythonDebugInterface \ No newline at end of file +net.floodlightcontroller.jython.JythonDebugInterface +net.floodlightcontroller.counter.CounterStore +net.floodlightcontroller.counter.NullCounterStore \ No newline at end of file diff --git a/src/main/resources/floodlightdefault.properties b/src/main/resources/floodlightdefault.properties index dd01ea837a13f7e6cef2ed4095df2cb43d4f0a7e..113a74a544c0906eb3c186bb148c2b3a977ddefb 100644 --- a/src/main/resources/floodlightdefault.properties +++ b/src/main/resources/floodlightdefault.properties @@ -1,3 +1,5 @@ floodlight.modules = net.floodlightcontroller.staticflowentry.StaticFlowEntryPusher,\ net.floodlightcontroller.forwarding.Forwarding,\ -net.floodlightcontroller.jython.JythonDebugInterface +net.floodlightcontroller.jython.JythonDebugInterface,\ +net.floodlightcontroller.counter.CounterStore,\ +net.floodlightcontroller.perfmon.PktInProcessingTime diff --git a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusherTest.java b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusherTest.java index 783d5700cad17c7650a5ca9670e07f2f62d185ae..1b2249cd88a0cd70cbc114a9ba88fcd7956dbf27 100644 --- a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusherTest.java +++ b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusherTest.java @@ -59,7 +59,7 @@ public class StaticFlowEntryPusherTest extends FloodlightTestCase { staticFlowEntryPusher = new StaticFlowEntryPusher(); staticFlowEntryPusher.init(fmc); restApi.init(fmc); - staticFlowEntryPusher.setFlowPushTime(200); + staticFlowEntryPusher.setFlowPushTime(500); staticFlowEntryPusher.startUp(fmc); restApi.startUp(fmc); }