Skip to content
Snippets Groups Projects
Commit 2cb1aee6 authored by Subrata Banerjee's avatar Subrata Banerjee
Browse files

Cleanup of performance monitoring, custom json serializers, and CLI display support.

parent 80f17738
No related branches found
No related tags found
No related merge requests found
Showing with 502 additions and 311 deletions
......@@ -24,6 +24,8 @@ import net.floodlightcontroller.core.web.serializers.EventHistoryBaseInfoJSONSer
import net.floodlightcontroller.core.web.serializers.OFFeaturesReplyJSONSerializer;
import net.floodlightcontroller.core.web.serializers.OFMatchJSONSerializer;
import net.floodlightcontroller.core.web.serializers.OFPhysicalPortJSONSerializer;
import net.floodlightcontroller.core.web.serializers.PerfMonCumulativeTimeBucketJSONSerializer;
import net.floodlightcontroller.core.web.serializers.PerfMonOneComponentTimeJSONSerializer;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.Version;
......@@ -62,6 +64,9 @@ public class JacksonCustomConverter extends JacksonConverter {
jsonModule.addSerializer(new EventHistoryBaseInfoJSONSerializer());
jsonModule.addSerializer(
new EventHistoryAttachmentPointJSONSerializer());
jsonModule.addSerializer(new PerfMonOneComponentTimeJSONSerializer());
jsonModule.addSerializer(
new PerfMonCumulativeTimeBucketJSONSerializer());
jsonObjectMapper.registerModule(jsonModule);
}
......
......@@ -39,32 +39,46 @@ public class OFMatchJSONSerializer extends JsonSerializer<OFMatch> {
((i >> 8 ) & 0xFF) + "." +
( i & 0xFF);
}
/**
* Performs the serialization of a OFMatch object
*/
@Override
public void serialize(OFMatch match, JsonGenerator jGen, SerializerProvider serializer) throws IOException, JsonProcessingException {
public void serialize(OFMatch match, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
jGen.writeStartObject();
jGen.writeStringField("dataLayerDestination", HexString.toHexString(match.getDataLayerDestination()));
jGen.writeStringField("dataLayerSource", HexString.toHexString(match.getDataLayerSource()));
jGen.writeStringField("dataLayerDestination",
HexString.toHexString(match.getDataLayerDestination()));
jGen.writeStringField("dataLayerSource",
HexString.toHexString(match.getDataLayerSource()));
String dataType = Integer.toHexString(match.getDataLayerType());
while (dataType.length() < 4) {
dataType = "0".concat(dataType);
}
jGen.writeStringField("dataLayerType", "0x" + dataType);
jGen.writeNumberField("dataLayerVirtualLan", match.getDataLayerVirtualLan());
jGen.writeNumberField("dataLayerVirtualLanPriorityCodePoint", match.getDataLayerVirtualLanPriorityCodePoint());
jGen.writeStringField("inputSwitch", HexString.toHexString(match.getSwitchDataPathId()));
jGen.writeNumberField("dataLayerVirtualLan",
match.getDataLayerVirtualLan());
jGen.writeNumberField("dataLayerVirtualLanPriorityCodePoint",
match.getDataLayerVirtualLanPriorityCodePoint());
jGen.writeStringField("inputSwitch",
HexString.toHexString(match.getSwitchDataPathId()));
jGen.writeNumberField("inputPort", match.getInputPort());
jGen.writeStringField("networkDestination", intToIp(match.getNetworkDestination()));
jGen.writeNumberField("networkDestinationMaskLen", match.getNetworkDestinationMaskLen());
jGen.writeStringField("networkDestination",
intToIp(match.getNetworkDestination()));
jGen.writeNumberField("networkDestinationMaskLen",
match.getNetworkDestinationMaskLen());
jGen.writeNumberField("networkProtocol", match.getNetworkProtocol());
jGen.writeStringField("networkSource", intToIp(match.getNetworkSource()));
jGen.writeNumberField("networkSourceMaskLen", match.getNetworkSourceMaskLen());
jGen.writeNumberField("networkTypeOfService", match.getNetworkTypeOfService());
jGen.writeNumberField("transportDestination", match.getTransportDestination());
jGen.writeNumberField("transportSource", match.getTransportSource());
jGen.writeStringField("networkSource",
intToIp(match.getNetworkSource()));
jGen.writeNumberField("networkSourceMaskLen",
match.getNetworkSourceMaskLen());
jGen.writeNumberField("networkTypeOfService",
match.getNetworkTypeOfService());
jGen.writeNumberField("transportDestination",
match.getTransportDestination());
jGen.writeNumberField("transportSource",
match.getTransportSource());
jGen.writeNumberField("wildcards", match.getWildcards());
jGen.writeEndObject();
}
......
......@@ -45,7 +45,7 @@ public class OFPhysicalPortJSONSerializer extends JsonSerializer<OFPhysicalPort>
jGen.writeNumberField("supportedFeatures", port.getSupportedFeatures());
jGen.writeEndObject();
}
/**
* Tells SimpleModule that we are the serializer for OFPhysicalPort
*/
......
package net.floodlightcontroller.core.web.serializers;
import java.io.IOException;
import java.sql.Timestamp;
import net.floodlightcontroller.perfmon.CumulativeTimeBucket;
import net.floodlightcontroller.perfmon.OneComponentTime;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
public class PerfMonCumulativeTimeBucketJSONSerializer
extends JsonSerializer<CumulativeTimeBucket> {
/**
* Performs the serialization of a OneComponentTime object
*/
@Override
public void serialize(CumulativeTimeBucket cTB,
JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
// Skip if the number of packets processed is zero
if (cTB.getTotalPktCnt() != 0) {
jGen.writeStartObject();
jGen.writeNumberField("BktNo", cTB.getBucketNo());
Timestamp ts = new Timestamp(cTB.getStartTime_ms());
String tsStr = ts.toString();
while (tsStr.length() < 23) {
tsStr = tsStr.concat("0");
}
jGen.writeStringField("StartTime", tsStr);
jGen.writeNumberField("Duration", cTB.getDuration_s());
jGen.writeNumberField("TotPkts", cTB.getTotalPktCnt());
jGen.writeNumberField("Avg", cTB.getAvgTotalProcTime_us());
jGen.writeNumberField("Min", cTB.getMinTotalProcTime_us());
jGen.writeNumberField("Max", cTB.getMaxTotalProcTime_us());
jGen.writeNumberField("StdDev", cTB.getSigmaTotalProcTime_us());
int numComps = cTB.getNumComps();
for (int idx=0; idx < numComps; idx++) {
OneComponentTime oCT = cTB.getTComps().getOneComp()[idx];
if (oCT.getPktCnt() != 0) {
serializer.defaultSerializeField(
Integer.toString(idx), oCT, jGen);
}
}
jGen.writeEndObject();
}
}
/**
* Tells SimpleModule that we are the serializer for OFMatch
*/
@Override
public Class<CumulativeTimeBucket> handledType() {
return CumulativeTimeBucket.class;
}
}
package net.floodlightcontroller.core.web.serializers;
import java.io.IOException;
import net.floodlightcontroller.perfmon.OneComponentTime;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
public class PerfMonOneComponentTimeJSONSerializer
extends JsonSerializer<OneComponentTime> {
/**
* Performs the serialization of a OneComponentTime object
*/
@Override
public void serialize(OneComponentTime oCT,
JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
// Skip if the number of packets processed is zero
if (oCT.getPktCnt() != 0) {
jGen.writeStartObject(); // Called from higher layer
jGen.writeStringField("CompName", oCT.getCompName());
jGen.writeNumberField("Pkts", oCT.getPktCnt());
jGen.writeNumberField("Avg", oCT.getAvgProcTime_us());
jGen.writeNumberField("Max", oCT.getMaxProcTime_us());
jGen.writeNumberField("Min", oCT.getMinProcTime_us());
jGen.writeNumberField("StdDev", oCT.getSigmaProcTime_us());
//jGen.writeNumberField("Sum", oCT.getSumProcTime_us());
//jGen.writeNumberField("SumSq", oCT.getSumSquaredProcTime_us2());
jGen.writeEndObject();
}
}
/**
* Tells SimpleModule that we are the serializer for OFMatch
*/
@Override
public Class<OneComponentTime> handledType() {
return OneComponentTime.class;
}
}
package net.floodlightcontroller.perfmon;
import net.floodlightcontroller.core.IOFMessageListener.FlListenerID;
public class CumulativeTimeBucket {
int bucketNo;
long startTime_ms;
long startTime_ns; // First pkt time-stamp in this bucket
// duration for which pkts are put into this bucket in seconds
int duration_s;
ProcTime tComps; // processing times of each component
int totalPktCnt;
int totalSumProcTime_us; // total processing time for one pkt in
long totalSumSquaredProcTime_us;
int maxTotalProcTime_us;
int minTotalProcTime_us;
int avgTotalProcTime_us;
int sigmaTotalProcTime_us; // std. deviation
int numComps;
public int getBucketNo() {
return bucketNo;
}
public void setBucketNo(int bucketNo) {
this.bucketNo = bucketNo;
}
public long getStartTime_ms() {
return startTime_ms;
}
public void setStartTime_ms(long startTime_ms) {
this.startTime_ms = startTime_ms;
}
public long getStartTime_ns() {
return startTime_ns;
}
public void setStartTime_ns(long startTime_ns) {
this.startTime_ns = startTime_ns;
}
public int getDuration_s() {
return duration_s;
}
public void setDuration_s(int duration_s) {
this.duration_s = duration_s;
}
public ProcTime getTComps() {
return tComps;
}
public void setTComps(ProcTime tComps) {
this.tComps = tComps;
}
public int getTotalPktCnt() {
return totalPktCnt;
}
public void setTotalPktCnt(int totalPktCnt) {
this.totalPktCnt = totalPktCnt;
}
public int getTotalSumProcTime_us() {
return totalSumProcTime_us;
}
public void setTotalSumProcTime_us(int totalSumProcTime_us) {
this.totalSumProcTime_us = totalSumProcTime_us;
}
public Long getTotalSumSquaredProcTime_us() {
return totalSumSquaredProcTime_us;
}
public void setTotalSumSquaredProcTime_us(
Long totalSumSquaredProcTime_us) {
this.totalSumSquaredProcTime_us = totalSumSquaredProcTime_us;
}
public int getMaxTotalProcTime_us() {
return maxTotalProcTime_us;
}
public void setMaxTotalProcTime_us(int maxTotalProcTime_us) {
this.maxTotalProcTime_us = maxTotalProcTime_us;
}
public int getMinTotalProcTime_us() {
return minTotalProcTime_us;
}
public void setMinTotalProcTime_us(int minTotalProcTime_us) {
this.minTotalProcTime_us = minTotalProcTime_us;
}
public int getAvgTotalProcTime_us() {
return avgTotalProcTime_us;
}
public void setAvgTotalProcTime_us(int avgTotalProcTime_us) {
this.avgTotalProcTime_us = avgTotalProcTime_us;
}
public int getSigmaTotalProcTime_us() {
return sigmaTotalProcTime_us;
}
public void setSigmaTotalProcTime_us(int sigmaTotalProcTime_us) {
this.sigmaTotalProcTime_us = sigmaTotalProcTime_us;
}
public ProcTime gettComps() {
return tComps;
}
public void settComps(ProcTime tComps) {
this.tComps = tComps;
}
public int getNumComps() {
return numComps;
}
public void setNumComps(int numComps) {
this.numComps = numComps;
}
public void setTotalSumSquaredProcTime_us(long totalSumSquaredProcTime_us) {
this.totalSumSquaredProcTime_us = totalSumSquaredProcTime_us;
}
public class ProcTime {
OneComponentTime [] oneComp;
public OneComponentTime[] getOneComp() {
return oneComp;
}
public void setOneComp(OneComponentTime[] oneComp) {
this.oneComp = oneComp;
}
public ProcTime(int numComponents) {
oneComp = new OneComponentTime[numComponents];
for (int idx = FlListenerID.FL_FIRST_LISTENER_ID;
idx < numComponents; idx++) {
oneComp[idx] = new OneComponentTime();
// Initialize the min and max values;
oneComp[idx].maxProcTime_us = Integer.MIN_VALUE;
oneComp[idx].minProcTime_us = Integer.MAX_VALUE;
// Set the component id and name
oneComp[idx].setCompId(idx);
oneComp[idx].setCompName(
FlListenerID.getListenerNameFromId(idx));
}
}
}
public CumulativeTimeBucket(int numComponents) {
duration_s = 0;
maxTotalProcTime_us = Integer.MIN_VALUE;
minTotalProcTime_us = Integer.MAX_VALUE;
tComps = new ProcTime(numComponents);
numComps = numComponents;
}
// Initialize the time bucket so that it can be reused for the next
// interval, thus not
// creating lots of garbage
public void initializeCumulativeTimeBucket(
CumulativeTimeBucket cumulativeTimeBkt) {
assert(cumulativeTimeBkt != null);
if (cumulativeTimeBkt == null) {
return;
}
cumulativeTimeBkt.startTime_ms = System.currentTimeMillis();
cumulativeTimeBkt.startTime_ns = System.nanoTime();
cumulativeTimeBkt.duration_s = 0;
cumulativeTimeBkt.totalPktCnt = 0;
cumulativeTimeBkt.totalSumProcTime_us = 0;
cumulativeTimeBkt.totalSumSquaredProcTime_us = 0L;
cumulativeTimeBkt.maxTotalProcTime_us = Integer.MIN_VALUE;
cumulativeTimeBkt.minTotalProcTime_us = Integer.MAX_VALUE;
cumulativeTimeBkt.avgTotalProcTime_us = 0;
cumulativeTimeBkt.sigmaTotalProcTime_us = 0;
for (int idx = FlListenerID.FL_FIRST_LISTENER_ID;
idx <= PktinProcessingTime.BB_LAST_LISTENER_ID; idx++) {
OneComponentTime oct = cumulativeTimeBkt.tComps.oneComp[idx];
oct.pktCnt = 0;
oct.sumProcTime_us = 0;
oct.sumSquaredProcTime_us2 = 0;
oct.maxProcTime_us = Integer.MIN_VALUE;
oct.minProcTime_us = Integer.MAX_VALUE;
oct.avgProcTime_us = 0;
oct.sigmaProcTime_us = 0;
}
}
}
\ No newline at end of file
package net.floodlightcontroller.perfmon;
public class OneComponentTime {
int compId;
String compName;
int pktCnt;
int sumProcTime_us;
long sumSquaredProcTime_us2;
int maxProcTime_us;
int minProcTime_us;
int avgProcTime_us;
int sigmaProcTime_us; // std. deviation
public int getCompId() {
return compId;
}
public void setCompId(int compId) {
this.compId = compId;
}
public String getCompName() {
return compName;
}
public void setCompName(String compName) {
this.compName = compName;
}
public int getPktCnt() {
return pktCnt;
}
public void setPktCnt(int pktCnt) {
this.pktCnt = pktCnt;
}
public int getSumProcTime_us() {
return sumProcTime_us;
}
public void setSumProcTime_us(int sumProcTime_us) {
this.sumProcTime_us = sumProcTime_us;
}
public long getSumSquaredProcTime_us2() {
return sumSquaredProcTime_us2;
}
public void setSumSquaredProcTime_us2(long sumSquaredProcTime_us2) {
this.sumSquaredProcTime_us2 = sumSquaredProcTime_us2;
}
public int getMaxProcTime_us() {
return maxProcTime_us;
}
public void setMaxProcTime_us(int maxProcTime_us) {
this.maxProcTime_us = maxProcTime_us;
}
public int getMinProcTime_us() {
return minProcTime_us;
}
public void setMinProcTime_us(int minProcTime_us) {
this.minProcTime_us = minProcTime_us;
}
public int getAvgProcTime_us() {
return avgProcTime_us;
}
public void setAvgProcTime_us(int avgProcTime_us) {
this.avgProcTime_us = avgProcTime_us;
}
public int getSigmaProcTime_us() {
return sigmaProcTime_us;
}
public void setSigmaProcTime_us(int sigmaProcTime_us) {
this.sigmaProcTime_us = sigmaProcTime_us;
}
}
\ No newline at end of file
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