private void updatePortData(DeviceId deviceId, PortStatistics stats) { ConnectPoint cp = new ConnectPoint(deviceId, portNumber(stats.port())); DataPoint c = current.get(cp); // Create a new data point and make it the current one current.put(cp, new DataPoint(stats)); // If we have a current data point, demote it to previous if (c != null) { previous.put(cp, c); } }
@Override public ConnectPoint read(Kryo kryo, Input input, Class<ConnectPoint> type) { ElementId elementId = (ElementId) kryo.readClassAndObject(input); PortNumber portNumber = (PortNumber) kryo.readClassAndObject(input); return new ConnectPoint(elementId, portNumber); } }
/** * Merges the appropriate PortConfig with the description. * * @param did ID of the Device where the port is attached * @param desc {@link PortDescription} * @return merged {@link PortDescription} */ private PortDescription applyAllPortOps(DeviceId did, PortDescription desc) { return applyAllPortOps(new ConnectPoint(did, desc.portNumber()), desc); }
private ConnectPoint buildConnectPoint(FlowRule rule) { PortNumber port = getOutput(rule); if (port == null) { return null; } ConnectPoint cp = new ConnectPoint(rule.deviceId(), port); return cp; }
@Override public SummaryFlowEntryWithLoad loadSummary(Device device, PortNumber pNumber) { checkPermission(STATISTIC_READ); ConnectPoint cp = new ConnectPoint(device.id(), pNumber); return loadSummaryPortInternal(cp); }
@Override public ConnectPoint decode(ObjectNode json, CodecContext context) { if (json == null || !json.isObject()) { return null; } ElementId elementId; if (json.has(ELEMENT_DEVICE)) { elementId = DeviceId.deviceId(json.get(ELEMENT_DEVICE).asText()); } else if (json.has(ELEMENT_HOST)) { elementId = HostId.hostId(json.get(ELEMENT_HOST).asText()); } else { // invalid JSON return null; } PortNumber portNumber = portNumber(json.get(PORT).asText()); return new ConnectPoint(elementId, portNumber); } }
@Override public List<FlowEntryWithLoad> loadAllByType(Device device, PortNumber pNumber, FlowEntry.FlowLiveType liveType, Instruction.Type instType) { checkPermission(STATISTIC_READ); ConnectPoint cp = new ConnectPoint(device.id(), pNumber); return loadAllPortInternal(cp, liveType, instType); }
@Override public List<FlowEntryWithLoad> loadTopnByType(Device device, PortNumber pNumber, FlowEntry.FlowLiveType liveType, Instruction.Type instType, int topn) { checkPermission(STATISTIC_READ); ConnectPoint cp = new ConnectPoint(device.id(), pNumber); return loadTopnPortInternal(cp, liveType, instType, topn); }
private ConnectPoint connectPoint(PcepDpid id, long port) { return new ConnectPoint(deviceId(uri(id)), portNumber(port)); }
private ConnectPoint createConnectPoint(String devicePortString) { String[] splitted = devicePortString.split("/"); checkArgument(splitted.length == 2, "Connect point must be in \"deviceUri/portNumber\" format"); DeviceId deviceId = DeviceId.deviceId(splitted[0]); DeviceService deviceService = get(DeviceService.class); List<Port> ports = deviceService.getPorts(deviceId); for (Port port : ports) { if (splitted[1].equals(port.number().name())) { return new ConnectPoint(deviceId, port.number()); } } return null; }
@Override public Map<ConnectPoint, SummaryFlowEntryWithLoad> loadSummary(Device device) { checkPermission(STATISTIC_READ); Map<ConnectPoint, SummaryFlowEntryWithLoad> summaryLoad = new TreeMap<>(Comparators.CONNECT_POINT_COMPARATOR); if (device == null) { return summaryLoad; } List<Port> ports = new ArrayList<>(deviceService.getPorts(device.id())); for (Port port : ports) { ConnectPoint cp = new ConnectPoint(device.id(), port.number()); SummaryFlowEntryWithLoad sfe = loadSummaryPortInternal(cp); summaryLoad.put(cp, sfe); } return summaryLoad; }
private void loadAllEdgePorts() { deviceService.getAvailableDevices().forEach(d -> deviceService.getPorts(d.id()) .forEach(p -> addEdgePort(new ConnectPoint(d.id(), p.number())))); }
private boolean isBlacklisted(Port port) { return isBlacklisted(new ConnectPoint(port.element().id(), port.number())); }
@Override public void handlePacket(OpenFlowPacketContext pktCtx) { DeviceId id = DeviceId.deviceId(Dpid.uri(pktCtx.dpid().value())); DefaultInboundPacket inPkt = new DefaultInboundPacket( new ConnectPoint(id, PortNumber.portNumber(pktCtx.inPort())), pktCtx.parsed(), ByteBuffer.wrap(pktCtx.unparsed()), pktCtx.cookie()); DefaultOutboundPacket outPkt = null; if (!pktCtx.isBuffered()) { outPkt = new DefaultOutboundPacket(id, null, ByteBuffer.wrap(pktCtx.unparsed())); } OpenFlowCorePacketContext corePktCtx = new OpenFlowCorePacketContext(System.currentTimeMillis(), inPkt, outPkt, pktCtx.isHandled(), pktCtx); providerService.processPacket(corePktCtx); }
@Override public void handlePacketIn(Bmv2Device device, int inputPort, ImmutableByteSequence packet) { Ethernet ethPkt = new Ethernet(); ethPkt.deserialize(packet.asArray(), 0, packet.size()); DeviceId deviceId = device.asDeviceId(); ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(inputPort)); ByteBuffer rawData = ByteBuffer.wrap(packet.asArray()); InboundPacket inPkt = new DefaultInboundPacket(receivedFrom, ethPkt, rawData); OutboundPacket outPkt = new DefaultOutboundPacket(deviceId, null, rawData); PacketContext pktCtx = new Bmv2PacketContext(System.currentTimeMillis(), inPkt, outPkt, false); providerService.processPacket(pktCtx); } }
@Override protected void doExecute() { StatisticService service = get(StatisticService.class); DeviceId ingressDeviceId = deviceId(getDeviceId(connectPoint)); PortNumber ingressPortNumber = portNumber(getPortNumber(connectPoint)); ConnectPoint cp = new ConnectPoint(ingressDeviceId, ingressPortNumber); Load load = service.load(cp); print("Load on %s -> %s", cp, load); }
private ConnectPoint staticPort(ConnectPoint connectPoint) { Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); String staticPort = port.annotations().value(AnnotationKeys.STATIC_PORT); // FIXME: need a better way to match the port if (staticPort != null) { for (Port p : deviceService.getPorts(connectPoint.deviceId())) { if (staticPort.equals(p.number().name())) { return new ConnectPoint(p.element().id(), p.number()); } } } return null; }
private ConnectPoint staticPort(ConnectPoint connectPoint) { Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); String staticPort = port.annotations().value(AnnotationKeys.STATIC_PORT); // FIXME: need a better way to match the port if (staticPort != null) { for (Port p : deviceService.getPorts(connectPoint.deviceId())) { if (staticPort.equals(p.number().name())) { return new ConnectPoint(p.element().id(), p.number()); } } } return null; }
@Override public void event(DeviceEvent event) { if (event.type() == DeviceEvent.Type.DEVICE_REMOVED) { removeLinks(event.subject().id()); } else if (event.type() == DeviceEvent.Type.PORT_REMOVED) { removeLinks(new ConnectPoint(event.subject().id(), event.port().number())); } } }
private FilteredConnectPoint output(DeviceId did, String portNumberStr, String vlanStr) { ConnectPoint cp = new ConnectPoint(did, PortNumber.fromString(portNumberStr)); if (deviceService.getPort(cp) == null) { print("Unknown port: %s", cp); } if (vlanStr == null) { return new FilteredConnectPoint(cp); } else { VlanId vlan = VlanId.vlanId(vlanStr); TrafficSelector sel = DefaultTrafficSelector.builder() .matchVlanId(vlan) .build(); return new FilteredConnectPoint(cp, sel); } }