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;
import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.perfmon.CircularTimeBucketSet;
import net.floodlightcontroller.perfmon.PerfMonConfigs;
public interface IPktInProcessingTimeService extends IFloodlightService {
......@@ -10,8 +9,6 @@ public interface IPktInProcessingTimeService extends IFloodlightService {
public CircularTimeBucketSet getCtbs();
public PerfMonConfigs getPerfMonCfgs();
public long getStartTimeOnePkt();
// Component refers to software component like forwarding
......
......@@ -10,7 +10,6 @@ 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.
......@@ -23,7 +22,6 @@ public class NullPktInProcessingTime
implements IFloodlightModule, IPktInProcessingTimeService {
private CircularTimeBucketSet emptyBucket;
private PerfMonConfigs emptyConfig;
public Collection<Class<? extends IFloodlightService>> getModuleServices() {
Collection<Class<? extends IFloodlightService>> l =
......@@ -54,7 +52,6 @@ public class NullPktInProcessingTime
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
emptyBucket = new CircularTimeBucketSet(0, 0);
emptyConfig = new PerfMonConfigs();
}
@Override
......@@ -67,11 +64,6 @@ public class NullPktInProcessingTime
return emptyBucket;
}
@Override
public PerfMonConfigs getPerfMonCfgs() {
return emptyConfig;
}
@Override
public long getStartTimeOnePkt() {
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
protected static Logger logger =
LoggerFactory.getLogger(PktInProcessingTime.class);
protected PerfMonConfigs perfMonCfgs;
// Turn on or off
protected boolean isEnabled;
// Maintains the time when the last packet was processed
protected long lastPktTime_ns;
protected long curBucketStartTime;
......@@ -64,31 +65,11 @@ public class PktInProcessingTime
@Override
public boolean isEnabled() {
return perfMonCfgs.isProcTimeMonitoringState();
return isEnabled;
}
public Long getLastPktTime_ns() {
return lastPktTime_ns;
}
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;
public void setEnabled(boolean enabled) {
isEnabled = enabled;
}
/* (non-Javadoc)
......@@ -98,36 +79,6 @@ public class PktInProcessingTime
public CircularTimeBucketSet getCtbs() {
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
......@@ -199,7 +150,7 @@ public class PktInProcessingTime
*/
@Override
public long getStartTimeOnePkt() {
if (this.perfMonCfgs.procTimeMonitoringState) {
if (this.isEnabled) {
long startTime_ns = System.nanoTime();
checkAndStartNextBucket(startTime_ns);
return startTime_ns;
......@@ -213,7 +164,7 @@ public class PktInProcessingTime
*/
@Override
public long getStartTimeOneComponent() {
if (this.perfMonCfgs.procTimeMonitoringState) {
if (this.isEnabled) {
return System.nanoTime();
}
return 0L;
......@@ -225,7 +176,7 @@ public class PktInProcessingTime
@Override
public void updateCumulativeTimeOneComp(
long onePktOneCompProcTime_ns, int id) {
if (this.perfMonCfgs.procTimeMonitoringState) {
if (this.isEnabled) {
int onePktOneCompProcTime_us =
(int)((System.nanoTime() - onePktOneCompProcTime_ns) / 1000);
OneComponentTime t_temp = this.ctb.tComps.oneComp[id];
......@@ -247,7 +198,7 @@ public class PktInProcessingTime
*/
@Override
public void updateCumulativeTimeTotal(long onePktStartTime_ns) {
if (this.perfMonCfgs.procTimeMonitoringState) {
if (this.isEnabled) {
// There is no api to get time in microseconds, milliseconds is
// too coarse hence we have to use nanoseconds and then divide by
// 1000 to get microseconds
......@@ -270,12 +221,6 @@ public class PktInProcessingTime
}
}
public PktInProcessingTime() {
perfMonCfgs = new PerfMonConfigs();
}
// IFloodlightModule methods
......@@ -315,10 +260,9 @@ public class PktInProcessingTime
public void startUp(FloodlightModuleContext context) {
// Our 'constructor'
FlListenerID.populateCompNames();
setNumComponents(BB_LAST_LISTENER_ID + 1);
perfMonCfgs = new PerfMonConfigs();
numComponents = BB_LAST_LISTENER_ID + 1;
numBuckets = BUCKET_SET_SIZE;
ctbs = new CircularTimeBucketSet(getNumComponents(), numBuckets);
ctbs = new CircularTimeBucketSet(numComponents, numBuckets);
ctb = ctbs.timeBucketSet[ctbs.curBucketIdx];
ctb.startTime_ms = System.currentTimeMillis();
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