Skip to content
Snippets Groups Projects
Commit b48ab136 authored by Ryan Izard's avatar Ryan Izard
Browse files

Merge pull request #2 from hwchiu/openlow-1.3#Serializer

Openlow 1.3#serializer
parents 04b75d0d e2119450
No related branches found
No related tags found
No related merge requests found
package net.floodlightcontroller.core.web;
import net.floodlightcontroller.core.web.serializers.StatsReplySerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@JsonSerialize(using=StatsReplySerializer.class)
public class StatsReply {
private String datapath;
private Object values;
private String statType;
public StatsReply() {}
public StatsReply(String dpid,Object values,String type){
this.datapath = dpid;
this.values = values;
this.statType = type;
}
public void setDatapathId(String dpid){
this.datapath = dpid;
}
public void setValues(Object values){
this.values = values;
}
public void setStatType(String type){
this.statType = type;
}
public String getDatapathId(){
return datapath;
}
public Object getValues(){
return values;
}
public String getStatType(){
return statType;
}
}
......@@ -19,13 +19,16 @@ package net.floodlightcontroller.core.web;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import net.floodlightcontroller.core.web.serializers.StatsReplySerializer;
import net.floodlightcontroller.core.web.StatsReply;
import org.projectfloodlight.openflow.protocol.OFStatsType;
import org.projectfloodlight.openflow.types.DatapathId;
import org.restlet.resource.Get;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.projectfloodlight.openflow.protocol.OFStatsReply;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
/**
* Return switch statistics information for specific switches
* @author readams
......@@ -35,10 +38,9 @@ public class SwitchStatisticsResource extends SwitchResourceBase {
LoggerFactory.getLogger(SwitchStatisticsResource.class);
@Get("json")
public Map<String, Object> retrieve() {
HashMap<String,Object> result = new HashMap<String,Object>();
public StatsReply retrieve(){
StatsReply result = new StatsReply();
Object values = null;
String switchId = (String) getRequestAttributes().get("switchId");
String statType = (String) getRequestAttributes().get("statType");
......@@ -57,8 +59,10 @@ public class SwitchStatisticsResource extends SwitchResourceBase {
} else if (statType.equals("features")) {
values = getSwitchFeaturesReply(switchId);
}
result.put(switchId, values);
result.setDatapathId(switchId);
result.setValues(values);
result.setStatType(statType);
return result;
}
}
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