mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-26 22:01:13 +01:00
Added a new GUI view for packet processors.
Change-Id: Ia0c6a23b389c4033b94deefdc32a2543b9c9cfa5
This commit is contained in:
parent
8aa8611539
commit
3ece373c81
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Open Networking Laboratory
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.onosproject.ui.table.cell;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats number using the specified format string".
|
||||||
|
*/
|
||||||
|
public final class NumberFormatter extends AbstractCellFormatter {
|
||||||
|
|
||||||
|
private final NumberFormat format;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a formatter using a default decimal format.
|
||||||
|
*/
|
||||||
|
public NumberFormatter() {
|
||||||
|
this(new DecimalFormat("#,##0.00000"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a formatter using the specified format.
|
||||||
|
*
|
||||||
|
* @param format number format
|
||||||
|
*/
|
||||||
|
public NumberFormatter(NumberFormat format) {
|
||||||
|
this.format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String nonNullFormat(Object value) {
|
||||||
|
return format.format(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Open Networking Laboratory
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.onosproject.ui.impl;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.onosproject.net.packet.PacketProcessorEntry;
|
||||||
|
import org.onosproject.net.packet.PacketService;
|
||||||
|
import org.onosproject.ui.RequestHandler;
|
||||||
|
import org.onosproject.ui.UiMessageHandler;
|
||||||
|
import org.onosproject.ui.table.TableModel;
|
||||||
|
import org.onosproject.ui.table.TableRequestHandler;
|
||||||
|
import org.onosproject.ui.table.cell.NumberFormatter;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import static org.onosproject.net.packet.PacketProcessor.ADVISOR_MAX;
|
||||||
|
import static org.onosproject.net.packet.PacketProcessor.DIRECTOR_MAX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message handler for packet processor view related messages.
|
||||||
|
*/
|
||||||
|
public class ProcessorViewMessageHandler extends UiMessageHandler {
|
||||||
|
|
||||||
|
private static final String PROCESSOR_DATA_REQ = "processorDataRequest";
|
||||||
|
private static final String PROCESSOR_DATA_RESP = "processorDataResponse";
|
||||||
|
private static final String PROCESSORS = "processors";
|
||||||
|
|
||||||
|
private static final String ID = "id";
|
||||||
|
private static final String TYPE = "type";
|
||||||
|
private static final String PRIORITY = "priority";
|
||||||
|
private static final String PROCESSOR = "processor";
|
||||||
|
private static final String PACKETS = "packets";
|
||||||
|
private static final String AVG_MS = "avgMillis";
|
||||||
|
|
||||||
|
private static final long NANOS_IN_MS = 1_000_000;
|
||||||
|
|
||||||
|
private static final String[] COL_IDS = {
|
||||||
|
ID, TYPE, PRIORITY, PROCESSOR, PACKETS, AVG_MS
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<RequestHandler> createRequestHandlers() {
|
||||||
|
return ImmutableSet.of(new ProcessorDataRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
// handler for link table requests
|
||||||
|
private final class ProcessorDataRequest extends TableRequestHandler {
|
||||||
|
private ProcessorDataRequest() {
|
||||||
|
super(PROCESSOR_DATA_REQ, PROCESSOR_DATA_RESP, PROCESSORS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getColumnIds() {
|
||||||
|
return COL_IDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String defaultColumnId() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TableModel createTableModel() {
|
||||||
|
TableModel tm = super.createTableModel();
|
||||||
|
tm.setFormatter(AVG_MS, new NumberFormatter());
|
||||||
|
return tm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void populateTable(TableModel tm, ObjectNode payload) {
|
||||||
|
PacketService ps = get(PacketService.class);
|
||||||
|
ps.getProcessors().forEach(entry -> populateRow(tm.addRow(), entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateRow(TableModel.Row row, PacketProcessorEntry entry) {
|
||||||
|
row.cell(ID, entry.priority())
|
||||||
|
.cell(TYPE, processorType(entry.priority()))
|
||||||
|
.cell(PRIORITY, processorPriority(entry.priority()))
|
||||||
|
.cell(PROCESSOR, entry.processor().getClass().getName())
|
||||||
|
.cell(PACKETS, entry.invocations())
|
||||||
|
.cell(AVG_MS, entry.averageNanos() / NANOS_IN_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String processorType(int p) {
|
||||||
|
return p > DIRECTOR_MAX ? "observer" :
|
||||||
|
p > ADVISOR_MAX ? "director" : "observer";
|
||||||
|
}
|
||||||
|
|
||||||
|
private int processorPriority(int p) {
|
||||||
|
return p > DIRECTOR_MAX ? (p - DIRECTOR_MAX - 1) :
|
||||||
|
p > ADVISOR_MAX ? (p - ADVISOR_MAX - 1) : (p - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -77,6 +77,7 @@ public class UiExtensionManager implements UiExtensionService, SpriteService {
|
|||||||
new UiView(PLATFORM, "app", "Applications", "nav_apps"),
|
new UiView(PLATFORM, "app", "Applications", "nav_apps"),
|
||||||
new UiView(PLATFORM, "settings", "Settings", "nav_settings"),
|
new UiView(PLATFORM, "settings", "Settings", "nav_settings"),
|
||||||
new UiView(PLATFORM, "cluster", "Cluster Nodes", "nav_cluster"),
|
new UiView(PLATFORM, "cluster", "Cluster Nodes", "nav_cluster"),
|
||||||
|
new UiView(PLATFORM, "processor", "Packet Processors", "nav_processors"),
|
||||||
new UiView(NETWORK, "topo", "Topology", "nav_topo"),
|
new UiView(NETWORK, "topo", "Topology", "nav_topo"),
|
||||||
new UiView(NETWORK, "device", "Devices", "nav_devs"),
|
new UiView(NETWORK, "device", "Devices", "nav_devs"),
|
||||||
new UiViewHidden("flow"),
|
new UiViewHidden("flow"),
|
||||||
@ -102,6 +103,7 @@ public class UiExtensionManager implements UiExtensionService, SpriteService {
|
|||||||
new ApplicationViewMessageHandler(),
|
new ApplicationViewMessageHandler(),
|
||||||
new SettingsViewMessageHandler(),
|
new SettingsViewMessageHandler(),
|
||||||
new ClusterViewMessageHandler(),
|
new ClusterViewMessageHandler(),
|
||||||
|
new ProcessorViewMessageHandler(),
|
||||||
new TunnelViewMessageHandler()
|
new TunnelViewMessageHandler()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,8 @@
|
|||||||
nav_devs: 'switch',
|
nav_devs: 'switch',
|
||||||
nav_links: 'ports',
|
nav_links: 'ports',
|
||||||
nav_hosts: 'endstation',
|
nav_hosts: 'endstation',
|
||||||
nav_intents: 'relatedIntents'
|
nav_intents: 'relatedIntents',
|
||||||
|
nav_processors: 'allTraffic'
|
||||||
};
|
};
|
||||||
|
|
||||||
function ensureIconLibDefs() {
|
function ensureIconLibDefs() {
|
||||||
|
|||||||
53
web/gui/src/main/webapp/app/view/processor/processor.css
Normal file
53
web/gui/src/main/webapp/app/view/processor/processor.css
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Open Networking Laboratory
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
ONOS GUI -- Processor View -- CSS file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ov-processor h2 {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ov-processor div.ctrl-btns {
|
||||||
|
width: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.light #ov-processor .current-view use {
|
||||||
|
fill: white;
|
||||||
|
}
|
||||||
|
.dark #ov-processor .current-view use {
|
||||||
|
fill: #304860;
|
||||||
|
}
|
||||||
|
|
||||||
|
.light #ov-processor .current-view rect {
|
||||||
|
fill: deepskyblue;
|
||||||
|
}
|
||||||
|
.dark #ov-processor .current-view rect {
|
||||||
|
fill: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ov-processor td.number {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ov-processor td.type {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ov-processor tr.no-data td {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
63
web/gui/src/main/webapp/app/view/processor/processor.html
Normal file
63
web/gui/src/main/webapp/app/view/processor/processor.html
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<!-- processor partial HTML -->
|
||||||
|
<div id="ov-processor">
|
||||||
|
<div class="tabular-header">
|
||||||
|
<h2>
|
||||||
|
Packet Processors ({{tableData.length}} Processors total)
|
||||||
|
</h2>
|
||||||
|
<div class="ctrl-btns">
|
||||||
|
<div class="refresh" ng-class="{active: autoRefresh}"
|
||||||
|
icon icon-size="36" icon-id="refresh"
|
||||||
|
tooltip tt-msg="autoRefreshTip"
|
||||||
|
ng-click="toggleRefresh()"></div>
|
||||||
|
<!--
|
||||||
|
<div class="separator"></div>
|
||||||
|
|
||||||
|
<div class="current-view"
|
||||||
|
icon icon-id="processorTable" icon-size="36"></div>
|
||||||
|
|
||||||
|
<div class="active"
|
||||||
|
icon icon-id="requestTable" icon-size="36"
|
||||||
|
tooltip tt-msg="requestTip"
|
||||||
|
ng-click="nav('request')"></div>
|
||||||
|
-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="summary-list" onos-table-resize>
|
||||||
|
<div ng-show="loading" class="loading-wheel"
|
||||||
|
icon icon-id="loading" icon-size="75"></div>
|
||||||
|
|
||||||
|
<div class="table-header" onos-sortable-header>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="type" colId="type" sortable col-width="80px">Type </td>
|
||||||
|
<td class="number" colId="priority" sortable col-width="80px">Priority </td>
|
||||||
|
<td colId="processor" sortable col-width="500px">Class </td>
|
||||||
|
<td class="number" colId="packets" sortable col-width="100px">Packets </td>
|
||||||
|
<td class="number" colId="avgMillis" sortable col-width="80px">Average (ms) </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-body">
|
||||||
|
<table onos-flash-changes id-prop="id">
|
||||||
|
<tr ng-if="!tableData.length" class="no-data">
|
||||||
|
<td colspan="5">
|
||||||
|
No Processors found
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr ng-repeat="processor in tableData track by $index"
|
||||||
|
ng-repeat-complete row-id="{{processor.id}}">
|
||||||
|
<td class="type">{{processor.type}}</td>
|
||||||
|
<td class="number">{{processor.priority}}</td>
|
||||||
|
<td>{{processor.processor}}</td>
|
||||||
|
<td class="number">{{processor.packets}}</td>
|
||||||
|
<td class="number">{{processor.avgMillis}}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
58
web/gui/src/main/webapp/app/view/processor/processor.js
Normal file
58
web/gui/src/main/webapp/app/view/processor/processor.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Open Networking Laboratory
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
ONOS GUI -- Packet Processor View Module
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// injected references
|
||||||
|
var $log, $scope, $location, fs, tbs, ns;
|
||||||
|
|
||||||
|
angular.module('ovProcessor', [])
|
||||||
|
.controller('OvProcessorCtrl',
|
||||||
|
['$log', '$scope', '$location',
|
||||||
|
'FnService', 'TableBuilderService', 'NavService',
|
||||||
|
|
||||||
|
function (_$log_, _$scope_, _$location_, _fs_, _tbs_, _ns_) {
|
||||||
|
var params;
|
||||||
|
$log = _$log_;
|
||||||
|
$scope = _$scope_;
|
||||||
|
$location = _$location_;
|
||||||
|
fs = _fs_;
|
||||||
|
tbs = _tbs_;
|
||||||
|
ns = _ns_;
|
||||||
|
$scope.requestTip = 'Show packet requests';
|
||||||
|
|
||||||
|
params = $location.search();
|
||||||
|
|
||||||
|
tbs.buildTable({
|
||||||
|
scope: $scope,
|
||||||
|
tag: 'processor',
|
||||||
|
query: params
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.nav = function (path) {
|
||||||
|
if ($scope.devId) {
|
||||||
|
ns.navTo(path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$log.log('OvProcessorCtrl has been created');
|
||||||
|
}]);
|
||||||
|
}());
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<div class="table-header" onos-sortable-header>
|
<div class="table-header" onos-sortable-header>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td colId="component" sortable col-width="200px">Component </td>
|
<td colId="component" sortable col-width="300px">Component </td>
|
||||||
<td colId="id" sortable>Property </td>
|
<td colId="id" sortable>Property </td>
|
||||||
<td colId="type" sortable col-width="70px">Type </td>
|
<td colId="type" sortable col-width="70px">Type </td>
|
||||||
<td colId="value" sortable>Value </td>
|
<td colId="value" sortable>Value </td>
|
||||||
|
|||||||
@ -121,6 +121,7 @@
|
|||||||
<script src="app/view/app/app.js"></script>
|
<script src="app/view/app/app.js"></script>
|
||||||
<script src="app/view/settings/settings.js"></script>
|
<script src="app/view/settings/settings.js"></script>
|
||||||
<script src="app/view/cluster/cluster.js"></script>
|
<script src="app/view/cluster/cluster.js"></script>
|
||||||
|
<script src="app/view/processor/processor.js"></script>
|
||||||
<script src="app/view/tunnel/tunnel.js"></script>
|
<script src="app/view/tunnel/tunnel.js"></script>
|
||||||
|
|
||||||
<!-- This is where contributed javascript will get injected -->
|
<!-- This is where contributed javascript will get injected -->
|
||||||
@ -139,6 +140,7 @@
|
|||||||
<link rel="stylesheet" href="app/view/app/app.css">
|
<link rel="stylesheet" href="app/view/app/app.css">
|
||||||
<link rel="stylesheet" href="app/view/settings/settings.css">
|
<link rel="stylesheet" href="app/view/settings/settings.css">
|
||||||
<link rel="stylesheet" href="app/view/cluster/cluster.css">
|
<link rel="stylesheet" href="app/view/cluster/cluster.css">
|
||||||
|
<link rel="stylesheet" href="app/view/processor/processor.css">
|
||||||
<link rel="stylesheet" href="app/view/tunnel/tunnel.css">
|
<link rel="stylesheet" href="app/view/tunnel/tunnel.css">
|
||||||
|
|
||||||
<!-- This is where contributed stylesheets will get injected -->
|
<!-- This is where contributed stylesheets will get injected -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user