Skip to content
Snippets Groups Projects
Commit af5c33b0 authored by Alex Reimers's avatar Alex Reimers
Browse files

Some cleanups to IPktInProcessingTimeService.

parent d5284ed5
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,6 @@ package net.floodlightcontroller.perfmon; ...@@ -2,7 +2,6 @@ package net.floodlightcontroller.perfmon;
import net.floodlightcontroller.core.module.IFloodlightService; import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.perfmon.CircularTimeBucketSet; import net.floodlightcontroller.perfmon.CircularTimeBucketSet;
import net.floodlightcontroller.perfmon.PerfMonConfigs;
public interface IPktInProcessingTimeService extends IFloodlightService { public interface IPktInProcessingTimeService extends IFloodlightService {
...@@ -10,8 +9,6 @@ public interface IPktInProcessingTimeService extends IFloodlightService { ...@@ -10,8 +9,6 @@ public interface IPktInProcessingTimeService extends IFloodlightService {
public CircularTimeBucketSet getCtbs(); public CircularTimeBucketSet getCtbs();
public PerfMonConfigs getPerfMonCfgs();
public long getStartTimeOnePkt(); public long getStartTimeOnePkt();
// Component refers to software component like forwarding // Component refers to software component like forwarding
......
...@@ -10,7 +10,6 @@ import net.floodlightcontroller.core.module.FloodlightModuleException; ...@@ -10,7 +10,6 @@ import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.core.module.IFloodlightModule; import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.module.IFloodlightService; import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.perfmon.CircularTimeBucketSet; import net.floodlightcontroller.perfmon.CircularTimeBucketSet;
import net.floodlightcontroller.perfmon.PerfMonConfigs;
/** /**
* An IPktInProcessingTimeService implementation that does nothing. * An IPktInProcessingTimeService implementation that does nothing.
...@@ -23,7 +22,6 @@ public class NullPktInProcessingTime ...@@ -23,7 +22,6 @@ public class NullPktInProcessingTime
implements IFloodlightModule, IPktInProcessingTimeService { implements IFloodlightModule, IPktInProcessingTimeService {
private CircularTimeBucketSet emptyBucket; private CircularTimeBucketSet emptyBucket;
private PerfMonConfigs emptyConfig;
public Collection<Class<? extends IFloodlightService>> getModuleServices() { public Collection<Class<? extends IFloodlightService>> getModuleServices() {
Collection<Class<? extends IFloodlightService>> l = Collection<Class<? extends IFloodlightService>> l =
...@@ -54,7 +52,6 @@ public class NullPktInProcessingTime ...@@ -54,7 +52,6 @@ public class NullPktInProcessingTime
public void init(FloodlightModuleContext context) public void init(FloodlightModuleContext context)
throws FloodlightModuleException { throws FloodlightModuleException {
emptyBucket = new CircularTimeBucketSet(0, 0); emptyBucket = new CircularTimeBucketSet(0, 0);
emptyConfig = new PerfMonConfigs();
} }
@Override @Override
...@@ -67,11 +64,6 @@ public class NullPktInProcessingTime ...@@ -67,11 +64,6 @@ public class NullPktInProcessingTime
return emptyBucket; return emptyBucket;
} }
@Override
public PerfMonConfigs getPerfMonCfgs() {
return emptyConfig;
}
@Override @Override
public long getStartTimeOnePkt() { public long getStartTimeOnePkt() {
return 0; return 0;
......
package net.floodlightcontroller.perfmon;
public class PerfMonConfigs {
/***
* procTimeMonitoringState: true if monitoring is on, default is false
*/
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
...@@ -52,7 +52,8 @@ public class PktInProcessingTime ...@@ -52,7 +52,8 @@ public class PktInProcessingTime
protected static Logger logger = protected static Logger logger =
LoggerFactory.getLogger(PktInProcessingTime.class); LoggerFactory.getLogger(PktInProcessingTime.class);
protected PerfMonConfigs perfMonCfgs; // Turn on or off
protected boolean isEnabled;
// Maintains the time when the last packet was processed // Maintains the time when the last packet was processed
protected long lastPktTime_ns; protected long lastPktTime_ns;
protected long curBucketStartTime; protected long curBucketStartTime;
...@@ -64,31 +65,11 @@ public class PktInProcessingTime ...@@ -64,31 +65,11 @@ public class PktInProcessingTime
@Override @Override
public boolean isEnabled() { public boolean isEnabled() {
return perfMonCfgs.isProcTimeMonitoringState(); return isEnabled;
} }
public Long getLastPktTime_ns() { public void setEnabled(boolean enabled) {
return lastPktTime_ns; isEnabled = enabled;
}
public void setLastPktTime_ns(Long lastPktTime_ns) {
this.lastPktTime_ns = lastPktTime_ns;
}
public long getCurBucketStartTime() {
return curBucketStartTime;
}
public void setCurBucketStartTime(long curBucketStartTime) {
this.curBucketStartTime = curBucketStartTime;
}
public CumulativeTimeBucket getCtb() {
return ctb;
}
public void setCtb(CumulativeTimeBucket ctb) {
this.ctb = ctb;
} }
/* (non-Javadoc) /* (non-Javadoc)
...@@ -98,36 +79,6 @@ public class PktInProcessingTime ...@@ -98,36 +79,6 @@ public class PktInProcessingTime
public CircularTimeBucketSet getCtbs() { public CircularTimeBucketSet getCtbs() {
return ctbs; return ctbs;
} }
public void setCtbs(CircularTimeBucketSet ctbs) {
this.ctbs = ctbs;
}
/* (non-Javadoc)
* @see net.floodlightcontroller.perfmon.IPktInProcessingTimeService#getPerfMonCfgs()
*/
@Override
public PerfMonConfigs getPerfMonCfgs() {
return perfMonCfgs;
}
public void setPerfMonCfgs(PerfMonConfigs perfMonCfgs) {
this.perfMonCfgs = perfMonCfgs;
}
public int getNumComponents() {
return numComponents;
}
public void setNumComponents(int numComponents) {
this.numComponents = numComponents;
}
public int getNumBuckets() {
return numBuckets;
}
public void setNumBuckets(int numBuckets) {
this.numBuckets = numBuckets;
}
/*** /***
* BUCKET_SET_SIZE buckets each holding 10s of processing time data, a total * BUCKET_SET_SIZE buckets each holding 10s of processing time data, a total
...@@ -199,7 +150,7 @@ public class PktInProcessingTime ...@@ -199,7 +150,7 @@ public class PktInProcessingTime
*/ */
@Override @Override
public long getStartTimeOnePkt() { public long getStartTimeOnePkt() {
if (this.perfMonCfgs.procTimeMonitoringState) { if (this.isEnabled) {
long startTime_ns = System.nanoTime(); long startTime_ns = System.nanoTime();
checkAndStartNextBucket(startTime_ns); checkAndStartNextBucket(startTime_ns);
return startTime_ns; return startTime_ns;
...@@ -213,7 +164,7 @@ public class PktInProcessingTime ...@@ -213,7 +164,7 @@ public class PktInProcessingTime
*/ */
@Override @Override
public long getStartTimeOneComponent() { public long getStartTimeOneComponent() {
if (this.perfMonCfgs.procTimeMonitoringState) { if (this.isEnabled) {
return System.nanoTime(); return System.nanoTime();
} }
return 0L; return 0L;
...@@ -225,7 +176,7 @@ public class PktInProcessingTime ...@@ -225,7 +176,7 @@ public class PktInProcessingTime
@Override @Override
public void updateCumulativeTimeOneComp( public void updateCumulativeTimeOneComp(
long onePktOneCompProcTime_ns, int id) { long onePktOneCompProcTime_ns, int id) {
if (this.perfMonCfgs.procTimeMonitoringState) { if (this.isEnabled) {
int onePktOneCompProcTime_us = int onePktOneCompProcTime_us =
(int)((System.nanoTime() - onePktOneCompProcTime_ns) / 1000); (int)((System.nanoTime() - onePktOneCompProcTime_ns) / 1000);
OneComponentTime t_temp = this.ctb.tComps.oneComp[id]; OneComponentTime t_temp = this.ctb.tComps.oneComp[id];
...@@ -247,7 +198,7 @@ public class PktInProcessingTime ...@@ -247,7 +198,7 @@ public class PktInProcessingTime
*/ */
@Override @Override
public void updateCumulativeTimeTotal(long onePktStartTime_ns) { public void updateCumulativeTimeTotal(long onePktStartTime_ns) {
if (this.perfMonCfgs.procTimeMonitoringState) { if (this.isEnabled) {
// There is no api to get time in microseconds, milliseconds is // There is no api to get time in microseconds, milliseconds is
// too coarse hence we have to use nanoseconds and then divide by // too coarse hence we have to use nanoseconds and then divide by
// 1000 to get microseconds // 1000 to get microseconds
...@@ -270,12 +221,6 @@ public class PktInProcessingTime ...@@ -270,12 +221,6 @@ public class PktInProcessingTime
} }
} }
public PktInProcessingTime() {
perfMonCfgs = new PerfMonConfigs();
}
// IFloodlightModule methods // IFloodlightModule methods
...@@ -315,10 +260,9 @@ public class PktInProcessingTime ...@@ -315,10 +260,9 @@ public class PktInProcessingTime
public void startUp(FloodlightModuleContext context) { public void startUp(FloodlightModuleContext context) {
// Our 'constructor' // Our 'constructor'
FlListenerID.populateCompNames(); FlListenerID.populateCompNames();
setNumComponents(BB_LAST_LISTENER_ID + 1); numComponents = BB_LAST_LISTENER_ID + 1;
perfMonCfgs = new PerfMonConfigs();
numBuckets = BUCKET_SET_SIZE; numBuckets = BUCKET_SET_SIZE;
ctbs = new CircularTimeBucketSet(getNumComponents(), numBuckets); ctbs = new CircularTimeBucketSet(numComponents, numBuckets);
ctb = ctbs.timeBucketSet[ctbs.curBucketIdx]; ctb = ctbs.timeBucketSet[ctbs.curBucketIdx];
ctb.startTime_ms = System.currentTimeMillis(); ctb.startTime_ms = System.currentTimeMillis();
ctb.startTime_ns = System.nanoTime(); ctb.startTime_ns = System.nanoTime();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment