Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
croft1
floodlight
Commits
999714b2
Commit
999714b2
authored
10 years ago
by
hwchiu
Browse files
Options
Downloads
Patches
Plain Diff
serialize the portStatsReply and modify the webui
parent
ec6fc333
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/net/floodlightcontroller/core/web/serializers/StatsReplySerializer.java
+40
-2
40 additions, 2 deletions
...controller/core/web/serializers/StatsReplySerializer.java
src/main/resources/web/js/models/switchmodel.js
+3
-2
3 additions, 2 deletions
src/main/resources/web/js/models/switchmodel.js
with
43 additions
and
4 deletions
src/main/java/net/floodlightcontroller/core/web/serializers/StatsReplySerializer.java
+
40
−
2
View file @
999714b2
...
...
@@ -36,6 +36,8 @@ import net.floodlightcontroller.util.MatchUtils;
import
org.projectfloodlight.openflow.protocol.OFFlowStatsReply
;
import
org.projectfloodlight.openflow.protocol.OFFlowStatsEntry
;
import
org.projectfloodlight.openflow.protocol.OFDescStatsReply
;
import
org.projectfloodlight.openflow.protocol.OFPortStatsReply
;
import
org.projectfloodlight.openflow.protocol.OFPortStatsEntry
;
import
org.projectfloodlight.openflow.protocol.OFAggregateStatsReply
;
import
org.projectfloodlight.openflow.protocol.OFVersion
;
import
org.projectfloodlight.openflow.protocol.match.*
;
...
...
@@ -87,6 +89,7 @@ public class StatsReplySerializer extends JsonSerializer<StatsReply> {
switch
(
reply
.
getStatType
())
{
case
PORT:
// handle port
serializePortReply
((
List
<
OFPortStatsReply
>)
reply
.
getValues
(),
jGen
);
break
;
case
QUEUE:
// handle queue
...
...
@@ -132,6 +135,43 @@ public class StatsReplySerializer extends JsonSerializer<StatsReply> {
jGen
.
writeEndObject
();
}
public
void
serializePortReply
(
List
<
OFPortStatsReply
>
portReplies
,
JsonGenerator
jGen
)
throws
IOException
,
JsonProcessingException
{
OFPortStatsReply
portReply
=
portReplies
.
get
(
0
);
// we will get only one PortReply and it will contains many OFPortStatsEntry ?
jGen
.
writeStringField
(
"version"
,
portReply
.
getVersion
().
toString
());
//return the enum name
jGen
.
writeFieldName
(
"port"
);
jGen
.
writeStartArray
();
for
(
OFPortStatsEntry
entry
:
portReply
.
getEntries
())
{
jGen
.
writeStartObject
();
jGen
.
writeStringField
(
"portNumber"
,
entry
.
getPortNo
().
toString
());
jGen
.
writeNumberField
(
"receive_packets"
,
entry
.
getRxPackets
().
getValue
());
jGen
.
writeNumberField
(
"transmit_packets"
,
entry
.
getTxPackets
().
getValue
());
jGen
.
writeNumberField
(
"receive_bytes"
,
entry
.
getRxBytes
().
getValue
());
jGen
.
writeNumberField
(
"transmit_bytes"
,
entry
.
getTxBytes
().
getValue
());
jGen
.
writeNumberField
(
"receive_dropped"
,
entry
.
getRxDropped
().
getValue
());
jGen
.
writeNumberField
(
"transmit_dropped"
,
entry
.
getTxDropped
().
getValue
());
jGen
.
writeNumberField
(
"receive_errors"
,
entry
.
getRxErrors
().
getValue
());
jGen
.
writeNumberField
(
"transmit_errors"
,
entry
.
getTxErrors
().
getValue
());
jGen
.
writeNumberField
(
"receive_frame_err"
,
entry
.
getRxFrameErr
().
getValue
());
jGen
.
writeNumberField
(
"receive_over_err"
,
entry
.
getRxOverErr
().
getValue
());
jGen
.
writeNumberField
(
"receive_crc_err"
,
entry
.
getRxCrcErr
().
getValue
());
jGen
.
writeNumberField
(
"collisions"
,
entry
.
getCollisions
().
getValue
());
if
(
OFVersion
.
OF_10
==
entry
.
getVersion
())
{
jGen
.
writeNumberField
(
"durationSec"
,
entry
.
getDurationSec
());
jGen
.
writeNumberField
(
"durationNsec"
,
entry
.
getDurationNsec
());
}
jGen
.
writeEndObject
();
}
jGen
.
writeEndArray
();
//v10
//10,11,12 use same format
// OF message fields
/*
private final OFPort portNo;
//v13 has two additional fields
private final long durationSec;
private final long durationNsec;
*/
}
public
void
serializeFlowReply
(
List
<
OFFlowStatsReply
>
flowReplies
,
JsonGenerator
jGen
)
throws
IOException
,
JsonProcessingException
{
int
flowCount
=
0
;
for
(
OFFlowStatsReply
flowReply
:
flowReplies
)
{
// for each flow stats reply
...
...
@@ -507,7 +547,6 @@ public class StatsReplySerializer extends JsonSerializer<StatsReply> {
public
void
serializeDescReply
(
List
<
OFDescStatsReply
>
descReplies
,
JsonGenerator
jGen
)
throws
IOException
,
JsonProcessingException
{
OFDescStatsReply
descReply
=
descReplies
.
get
(
0
);
// There are only one descReply from the switch
logger
.
error
(
"reply = {}"
,
descReply
);
jGen
.
writeObjectFieldStart
(
"desc"
);
jGen
.
writeStringField
(
"version"
,
descReply
.
getVersion
().
toString
());
//return the enum name
jGen
.
writeStringField
(
"manufacturerDescription"
,
descReply
.
getMfrDesc
());
...
...
@@ -519,7 +558,6 @@ public class StatsReplySerializer extends JsonSerializer<StatsReply> {
}
public
void
serializeAggregateReply
(
List
<
OFAggregateStatsReply
>
aggregateReplies
,
JsonGenerator
jGen
)
throws
IOException
,
JsonProcessingException
{
OFAggregateStatsReply
aggregateReply
=
aggregateReplies
.
get
(
0
);
// There are only one aggregateReply from the switch
logger
.
error
(
"reply = {}"
,
aggregateReply
);
jGen
.
writeObjectFieldStart
(
"aggregate"
);
jGen
.
writeStringField
(
"version"
,
aggregateReply
.
getVersion
().
toString
());
//return the enum name
jGen
.
writeNumberField
(
"flowCount"
,
aggregateReply
.
getFlowCount
());
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/web/js/models/switchmodel.js
+
3
−
2
View file @
999714b2
...
...
@@ -73,12 +73,12 @@ window.Switch = Backbone.Model.extend({
dataType
:
"
json
"
,
success
:
function
(
data
)
{
//console.log("fetched switch " + self.id + " ports");
//
console.log(data[
self.id
]);
console
.
log
(
data
[
'
port
'
]);
var
old_ids
=
self
.
ports
.
pluck
(
'
id
'
);
//console.log("old_ids" + old_ids);
// create port models
_
.
each
(
data
[
self
.
id
],
function
(
p
)
{
_
.
each
(
data
[
'
port
'
],
function
(
p
)
{
// workaround for REST serialization signed/unsigned bug
if
(
p
.
portNumber
<
0
)
{
p
.
portNumber
=
65536
+
p
.
portNumber
};
...
...
@@ -103,6 +103,7 @@ window.Switch = Backbone.Model.extend({
console
.
log
(
"
removing port
"
+
p
);
self
.
remove
({
id
:
p
});
});
console
.
log
(
self
.
ports
);
}
}),
$
.
ajax
({
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment