Thomas Vachuska

Fixed a few blemishes in the packet processor GUI view code.

Change-Id: I9e109b9d8432de52862809719284d627320d5d6f
......@@ -67,6 +67,8 @@ import java.util.concurrent.ScheduledExecutorService;
import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.onlab.packet.Ethernet.TYPE_BSN;
import static org.onlab.packet.Ethernet.TYPE_LLDP;
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.net.Link.Type.DIRECT;
......@@ -326,10 +328,10 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
*/
private void requestIntercepts() {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(Ethernet.TYPE_LLDP);
selector.matchEthType(TYPE_LLDP);
packetService.requestPackets(selector.build(), PacketPriority.CONTROL, appId);
selector.matchEthType(Ethernet.TYPE_BSN);
selector.matchEthType(TYPE_BSN);
if (useBDDP) {
packetService.requestPackets(selector.build(), PacketPriority.CONTROL, appId);
} else {
......@@ -342,9 +344,9 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
*/
private void withdrawIntercepts() {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(Ethernet.TYPE_LLDP);
selector.matchEthType(TYPE_LLDP);
packetService.cancelPackets(selector.build(), PacketPriority.CONTROL, appId);
selector.matchEthType(Ethernet.TYPE_BSN);
selector.matchEthType(TYPE_BSN);
packetService.cancelPackets(selector.build(), PacketPriority.CONTROL, appId);
}
......@@ -474,9 +476,15 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
private class InternalPacketProcessor implements PacketProcessor {
@Override
public void process(PacketContext context) {
if (context == null) {
if (context == null || context.isHandled()) {
return;
}
Ethernet eth = context.inPacket().parsed();
if (eth == null || (eth.getEtherType() != TYPE_LLDP && eth.getEtherType() != TYPE_BSN)) {
return;
}
LinkDiscovery ld = discoverers.get(context.inPacket().receivedFrom().deviceId());
if (ld == null) {
return;
......
......@@ -40,6 +40,10 @@ public class ProcessorViewMessageHandler extends UiMessageHandler {
private static final String PROCESSOR_DATA_RESP = "processorDataResponse";
private static final String PROCESSORS = "processors";
private static final String OBSERVER = "observer";
private static final String DIRECTOR = "director";
private static final String ADVISOR = "advisor";
private static final String ID = "id";
private static final String TYPE = "type";
private static final String PRIORITY = "priority";
......@@ -58,7 +62,7 @@ public class ProcessorViewMessageHandler extends UiMessageHandler {
return ImmutableSet.of(new ProcessorDataRequest());
}
// handler for link table requests
// handler for packet processor table requests
private final class ProcessorDataRequest extends TableRequestHandler {
private ProcessorDataRequest() {
super(PROCESSOR_DATA_REQ, PROCESSOR_DATA_RESP, PROCESSORS);
......@@ -70,11 +74,6 @@ public class ProcessorViewMessageHandler extends UiMessageHandler {
}
@Override
protected String defaultColumnId() {
return ID;
}
@Override
protected TableModel createTableModel() {
TableModel tm = super.createTableModel();
tm.setFormatter(AVG_MS, new NumberFormatter());
......@@ -93,12 +92,11 @@ public class ProcessorViewMessageHandler extends UiMessageHandler {
.cell(PRIORITY, processorPriority(entry.priority()))
.cell(PROCESSOR, entry.processor().getClass().getName())
.cell(PACKETS, entry.invocations())
.cell(AVG_MS, entry.averageNanos() / NANOS_IN_MS);
.cell(AVG_MS, (double) entry.averageNanos() / NANOS_IN_MS);
}
private String processorType(int p) {
return p > DIRECTOR_MAX ? "observer" :
p > ADVISOR_MAX ? "director" : "observer";
return p > DIRECTOR_MAX ? OBSERVER : p > ADVISOR_MAX ? DIRECTOR : ADVISOR;
}
private int processorPriority(int p) {
......
......@@ -44,10 +44,6 @@
text-align: right;
}
#ov-processor td.type {
text-align: center;
}
#ov-processor tr.no-data td {
text-align: center;
}
......
......@@ -16,7 +16,7 @@
icon icon-id="processorTable" icon-size="36"></div>
<div class="active"
icon icon-id="requestTable" icon-size="36"
icon icon-id="requestTable" icon-size="36"git sta
tooltip tt-msg="requestTip"
ng-click="nav('request')"></div>
-->
......@@ -30,11 +30,11 @@
<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="type" sortable col-width="80px">Type </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>
<td class="number" colId="avgMillis" sortable col-width="100px">Average (ms) </td>
</tr>
</table>
</div>
......@@ -49,8 +49,8 @@
<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.type}}</td>
<td>{{processor.processor}}</td>
<td class="number">{{processor.packets}}</td>
<td class="number">{{processor.avgMillis}}</td>
......