From 55d4a1b251e1b2e36b9036b3d0b033abc38acbec Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Fri, 13 Nov 2015 17:25:44 -0800 Subject: ONOS commit d9df7bd278935c3d72ac6eeb0ff44efe1edde567 Change-Id: I319f3a3765db55034b894238fb9391eee56c6dd4 Signed-off-by: Ashlee Young --- .../src/main/java/org/onosproject/acl/AclRule.java | 6 +- .../java/org/onosproject/acl/AclWebResource.java | 4 +- .../java/org/onosproject/acl/impl/AclManager.java | 20 +- .../org/onosproject/bgprouter/IcmpHandler.java | 4 +- .../onosproject/cordfabric/CordFabricManager.java | 4 +- .../optical/testapp/MPLSForwarding.java | 180 -------------- .../optical/testapp/MplsForwarding.java | 180 ++++++++++++++ .../main/java/org/onosproject/demo/DemoAPI.java | 49 ---- .../main/java/org/onosproject/demo/DemoApi.java | 49 ++++ .../java/org/onosproject/demo/DemoInstaller.java | 2 +- .../java/org/onosproject/demo/DemoResource.java | 8 +- .../cli/net/ConnectivityIntentCommand.java | 24 +- .../org/onosproject/cli/net/GetFlowStatistics.java | 18 +- .../cli/net/LinkResourceTestCommand.java | 17 +- .../net/device/DefaultDeviceDescription.java | 6 +- .../onosproject/net/device/DeviceDescription.java | 2 +- .../net/device/DefaultDeviceDescriptionTest.java | 2 +- .../net/driver/XmlDriverLoaderTest.java | 4 +- .../ui/table/cell/DefaultCellComparatorTest.java | 8 +- .../org/onosproject/common/DefaultTopology.java | 12 +- .../store/trivial/SimpleDeviceStore.java | 6 +- .../net/device/impl/BasicDeviceOperator.java | 2 +- .../net/statistic/impl/FlowStatisticManager.java | 18 +- .../net/proxyarp/impl/ProxyArpManagerTest.java | 106 ++++----- .../messaging/impl/NettyMessagingManager.java | 18 +- .../store/device/impl/GossipDeviceStore.java | 8 +- .../store/device/impl/GossipDeviceStoreTest.java | 4 +- .../store/serializers/KryoNamespaces.java | 2 +- .../store/serializers/URISerializer.java | 46 ---- .../store/serializers/UriSerializer.java | 46 ++++ .../handshaker/OFOpticalSwitchImplLINC13.java | 261 --------------------- .../handshaker/OfOpticalSwitchImplLinc13.java | 261 +++++++++++++++++++++ .../drivers/src/main/resources/onos-drivers.xml | 2 +- .../main/java/org/onlab/graph/SRLGGraphSearch.java | 253 -------------------- .../main/java/org/onlab/graph/SrlgGraphSearch.java | 253 ++++++++++++++++++++ .../java/org/onlab/graph/TarjanGraphSearch.java | 12 +- .../java/org/onlab/graph/SRLGGraphSearchTest.java | 174 -------------- .../java/org/onlab/graph/SrlgGraphSearchTest.java | 174 ++++++++++++++ .../org/onlab/graph/TarjanGraphSearchTest.java | 16 +- .../test/java/org/onlab/util/HexStringTest.java | 2 +- .../main/java/org/onlab/netty/NettyMessaging.java | 72 +++--- .../onosproject/rest/resources/ConfigProvider.java | 4 +- 42 files changed, 1167 insertions(+), 1172 deletions(-) delete mode 100644 framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MPLSForwarding.java create mode 100644 framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MplsForwarding.java delete mode 100644 framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java create mode 100644 framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoApi.java delete mode 100644 framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/URISerializer.java create mode 100644 framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/UriSerializer.java delete mode 100644 framework/src/onos/drivers/src/main/java/org/onosproject/driver/handshaker/OFOpticalSwitchImplLINC13.java create mode 100644 framework/src/onos/drivers/src/main/java/org/onosproject/driver/handshaker/OfOpticalSwitchImplLinc13.java delete mode 100644 framework/src/onos/utils/misc/src/main/java/org/onlab/graph/SRLGGraphSearch.java create mode 100644 framework/src/onos/utils/misc/src/main/java/org/onlab/graph/SrlgGraphSearch.java delete mode 100644 framework/src/onos/utils/misc/src/test/java/org/onlab/graph/SRLGGraphSearchTest.java create mode 100644 framework/src/onos/utils/misc/src/test/java/org/onlab/graph/SrlgGraphSearchTest.java diff --git a/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclRule.java b/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclRule.java index 8c91da4c..cd85dea7 100644 --- a/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclRule.java +++ b/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclRule.java @@ -86,7 +86,7 @@ public final class AclRule { /** * Check if the first CIDR address is in (or the same as) the second CIDR address. */ - private boolean checkCIDRinCIDR(Ip4Prefix cidrAddr1, Ip4Prefix cidrAddr2) { + private boolean checkCidrInCidr(Ip4Prefix cidrAddr1, Ip4Prefix cidrAddr2) { if (cidrAddr2 == null) { return true; } else if (cidrAddr1 == null) { @@ -116,8 +116,8 @@ public final class AclRule { public boolean checkMatch(AclRule r) { return (this.dstTpPort == r.dstTpPort || r.dstTpPort == 0) && (this.ipProto == r.ipProto || r.ipProto == 0) - && (checkCIDRinCIDR(this.srcIp(), r.srcIp())) - && (checkCIDRinCIDR(this.dstIp(), r.dstIp())); + && (checkCidrInCidr(this.srcIp(), r.srcIp())) + && (checkCidrInCidr(this.dstIp(), r.dstIp())); } /** diff --git a/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java b/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java index 9ec4c883..bdbcc693 100644 --- a/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java +++ b/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java @@ -129,7 +129,7 @@ public class AclWebResource extends AbstractWebResource { * @return 200 OK */ @DELETE - public Response clearACL() { + public Response clearAcl() { get(AclService.class).clearAcl(); return Response.ok().build(); } @@ -189,4 +189,4 @@ public class AclWebResource extends AbstractWebResource { return rule.build(); } -} \ No newline at end of file +} diff --git a/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/impl/AclManager.java b/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/impl/AclManager.java index f5c0c204..638f0799 100644 --- a/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/impl/AclManager.java +++ b/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/impl/AclManager.java @@ -90,7 +90,7 @@ public class AclManager implements AclService { /** * Checks if the given IP address is in the given CIDR address. */ - private boolean checkIpInCIDR(Ip4Address ip, Ip4Prefix cidr) { + private boolean checkIpInCidr(Ip4Address ip, Ip4Prefix cidr) { int offset = 32 - cidr.prefixLength(); int cidrPrefix = cidr.address().toInt(); int ipIntValue = ip.toInt(); @@ -111,17 +111,17 @@ public class AclManager implements AclService { DeviceId deviceId = event.subject().location().deviceId(); for (IpAddress address : event.subject().ipAddresses()) { if ((rule.srcIp() != null) ? - (checkIpInCIDR(address.getIp4Address(), rule.srcIp())) : - (checkIpInCIDR(address.getIp4Address(), rule.dstIp()))) { + (checkIpInCidr(address.getIp4Address(), rule.srcIp())) : + (checkIpInCidr(address.getIp4Address(), rule.dstIp()))) { if (!aclStore.checkIfRuleWorksInDevice(rule.id(), deviceId)) { List allowingRuleList = aclStore .getAllowingRuleByDenyingRule(rule.id()); if (allowingRuleList != null) { for (RuleId allowingRuleId : allowingRuleList) { - generateACLFlow(aclStore.getAclRule(allowingRuleId), deviceId); + generateAclFlow(aclStore.getAclRule(allowingRuleId), deviceId); } } - generateACLFlow(rule, deviceId); + generateAclFlow(rule, deviceId); } } } @@ -212,7 +212,7 @@ public class AclManager implements AclService { if (cidrAddr.prefixLength() != 32) { for (Host h : hosts) { for (IpAddress a : h.ipAddresses()) { - if (checkIpInCIDR(a.getIp4Address(), cidrAddr)) { + if (checkIpInCidr(a.getIp4Address(), cidrAddr)) { deviceIdSet.add(h.location().deviceId()); } } @@ -220,7 +220,7 @@ public class AclManager implements AclService { } else { for (Host h : hosts) { for (IpAddress a : h.ipAddresses()) { - if (checkIpInCIDR(a.getIp4Address(), cidrAddr)) { + if (checkIpInCidr(a.getIp4Address(), cidrAddr)) { deviceIdSet.add(h.location().deviceId()); return deviceIdSet; } @@ -245,10 +245,10 @@ public class AclManager implements AclService { List allowingRuleList = aclStore.getAllowingRuleByDenyingRule(rule.id()); if (allowingRuleList != null) { for (RuleId allowingRuleId : allowingRuleList) { - generateACLFlow(aclStore.getAclRule(allowingRuleId), deviceId); + generateAclFlow(aclStore.getAclRule(allowingRuleId), deviceId); } } - generateACLFlow(rule, deviceId); + generateAclFlow(rule, deviceId); } } @@ -256,7 +256,7 @@ public class AclManager implements AclService { * Generates ACL flow rule according to ACL rule * and install it into related device. */ - private void generateACLFlow(AclRule rule, DeviceId deviceId) { + private void generateAclFlow(AclRule rule, DeviceId deviceId) { if (rule == null || aclStore.checkIfRuleWorksInDevice(rule.id(), deviceId)) { return; } diff --git a/framework/src/onos/apps/bgprouter/src/main/java/org/onosproject/bgprouter/IcmpHandler.java b/framework/src/onos/apps/bgprouter/src/main/java/org/onosproject/bgprouter/IcmpHandler.java index 6130a2e2..be4499e9 100644 --- a/framework/src/onos/apps/bgprouter/src/main/java/org/onosproject/bgprouter/IcmpHandler.java +++ b/framework/src/onos/apps/bgprouter/src/main/java/org/onosproject/bgprouter/IcmpHandler.java @@ -83,11 +83,11 @@ public class IcmpHandler { if (((ICMP) ipv4.getPayload()).getIcmpType() == ICMP.TYPE_ECHO_REQUEST && ipMatches) { - sendICMPResponse(ethernet, connectPoint); + sendIcmpResponse(ethernet, connectPoint); } } - private void sendICMPResponse(Ethernet icmpRequest, ConnectPoint outport) { + private void sendIcmpResponse(Ethernet icmpRequest, ConnectPoint outport) { Ethernet icmpReplyEth = new Ethernet(); diff --git a/framework/src/onos/apps/cordfabric/src/main/java/org/onosproject/cordfabric/CordFabricManager.java b/framework/src/onos/apps/cordfabric/src/main/java/org/onosproject/cordfabric/CordFabricManager.java index fa916865..690a3581 100644 --- a/framework/src/onos/apps/cordfabric/src/main/java/org/onosproject/cordfabric/CordFabricManager.java +++ b/framework/src/onos/apps/cordfabric/src/main/java/org/onosproject/cordfabric/CordFabricManager.java @@ -268,7 +268,7 @@ public class CordFabricManager implements FabricService { removeVlan(vlan.vlan()); if (vlan.iptv()) { - provisionIPTV(); + provisionIpTv(); } vlan.ports().forEach(cp -> { @@ -283,7 +283,7 @@ public class CordFabricManager implements FabricService { } //FIXME: pass iptv vlan in here. - private void provisionIPTV() { + private void provisionIpTv() { TrafficSelector ipTvUp = DefaultTrafficSelector.builder() .matchVlanId(VlanId.vlanId((short) 7)) .matchInPort(PortNumber.portNumber(2)) diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MPLSForwarding.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MPLSForwarding.java deleted file mode 100644 index c784c82f..00000000 --- a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MPLSForwarding.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2014-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.optical.testapp; - -import static org.slf4j.LoggerFactory.getLogger; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.onosproject.core.ApplicationId; -import org.onosproject.core.CoreService; -import org.onosproject.net.Device; -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; -import org.onosproject.net.device.DeviceEvent; -import org.onosproject.net.device.DeviceListener; -import org.onosproject.net.device.DeviceService; -import org.onosproject.net.flow.DefaultFlowRule; -import org.onosproject.net.flow.DefaultTrafficSelector; -import org.onosproject.net.flow.DefaultTrafficTreatment; -import org.onosproject.net.flow.FlowRule; -import org.onosproject.net.flow.FlowRuleService; -import org.onosproject.net.flow.TrafficSelector; -import org.onosproject.net.flow.TrafficTreatment; -import org.onlab.packet.Ethernet; -import org.onlab.packet.MplsLabel; -import org.slf4j.Logger; - -/** - * Sample reactive forwarding application. - */ -//@Component(immediate = true) -public class MPLSForwarding { - - private final Logger log = getLogger(getClass()); - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected FlowRuleService flowRuleService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected CoreService coreService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected DeviceService deviceService; - - private ApplicationId appId; - - private final InternalDeviceListener listener = new InternalDeviceListener(); - - private final Map uglyMap = new HashMap<>(); - - @Activate - public void activate() { - appId = coreService.registerApplication("org.onosproject.testapp" + - ".mplsfwd"); - - uglyMap.put(DeviceId.deviceId("of:0000000000000001"), 1); - uglyMap.put(DeviceId.deviceId("of:0000000000000002"), 2); - uglyMap.put(DeviceId.deviceId("of:0000000000000003"), 3); - - deviceService.addListener(listener); - - for (Device d : deviceService.getDevices()) { - pushRules(d); - } - - - log.info("Started with Application ID {}", appId.id()); - } - - @Deactivate - public void deactivate() { - flowRuleService.removeFlowRulesById(appId); - - log.info("Stopped"); - } - - - private void pushRules(Device device) { - - TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); - TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); - int inport = 1; - int outport = 2; - MplsLabel mplsLabel = MplsLabel.mplsLabel(101); - Integer switchNumber = uglyMap.get(device.id()); - if (switchNumber == null) { - return; - } - - switch (switchNumber) { - case 1: - sbuilder.matchInPort(PortNumber.portNumber(inport)); - tbuilder.setOutput(PortNumber.portNumber(outport)) - .pushMpls() - .setMpls(mplsLabel); - break; - case 2: - sbuilder.matchMplsLabel(mplsLabel) - .matchEthType(Ethernet.MPLS_UNICAST) - .matchInPort(PortNumber.portNumber(inport)); - tbuilder.setOutput(PortNumber.portNumber(outport)); - break; - case 3: - sbuilder.matchMplsLabel(mplsLabel) - .matchEthType(Ethernet.MPLS_UNICAST) - .matchInPort(PortNumber.portNumber(inport)); - tbuilder.popMpls().setOutput(PortNumber.portNumber(outport)); - break; - default: - } - - TrafficTreatment treatement = tbuilder.build(); - TrafficSelector selector = sbuilder.build(); - - FlowRule f = DefaultFlowRule.builder() - .forDevice(device.id()) - .withSelector(selector) - .withTreatment(treatement) - .withPriority(100) - .fromApp(appId) - .makeTemporary(600) - .build(); - - flowRuleService.applyFlowRules(f); - } - - - public class InternalDeviceListener implements DeviceListener { - - @Override - public void event(DeviceEvent event) { - switch (event.type()) { - case DEVICE_ADDED: - pushRules(event.subject()); - break; - case DEVICE_AVAILABILITY_CHANGED: - break; - case DEVICE_REMOVED: - break; - case DEVICE_SUSPENDED: - break; - case DEVICE_UPDATED: - break; - case PORT_ADDED: - break; - case PORT_REMOVED: - break; - case PORT_UPDATED: - break; - default: - break; - - } - - } - - } - - -} - - diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MplsForwarding.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MplsForwarding.java new file mode 100644 index 00000000..b9a4b0ca --- /dev/null +++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MplsForwarding.java @@ -0,0 +1,180 @@ +/* + * Copyright 2014-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.optical.testapp; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.onlab.packet.Ethernet; +import org.onlab.packet.MplsLabel; +import org.onosproject.core.ApplicationId; +import org.onosproject.core.CoreService; +import org.onosproject.net.Device; +import org.onosproject.net.DeviceId; +import org.onosproject.net.PortNumber; +import org.onosproject.net.device.DeviceEvent; +import org.onosproject.net.device.DeviceListener; +import org.onosproject.net.device.DeviceService; +import org.onosproject.net.flow.DefaultFlowRule; +import org.onosproject.net.flow.DefaultTrafficSelector; +import org.onosproject.net.flow.DefaultTrafficTreatment; +import org.onosproject.net.flow.FlowRule; +import org.onosproject.net.flow.FlowRuleService; +import org.onosproject.net.flow.TrafficSelector; +import org.onosproject.net.flow.TrafficTreatment; +import org.slf4j.Logger; + +import java.util.HashMap; +import java.util.Map; + +import static org.slf4j.LoggerFactory.getLogger; + +/** + * Sample reactive forwarding application. + */ +//@Component(immediate = true) +public class MplsForwarding { + + private final Logger log = getLogger(getClass()); + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected FlowRuleService flowRuleService; + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected CoreService coreService; + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected DeviceService deviceService; + + private ApplicationId appId; + + private final InternalDeviceListener listener = new InternalDeviceListener(); + + private final Map uglyMap = new HashMap<>(); + + @Activate + public void activate() { + appId = coreService.registerApplication("org.onosproject.testapp" + + ".mplsfwd"); + + uglyMap.put(DeviceId.deviceId("of:0000000000000001"), 1); + uglyMap.put(DeviceId.deviceId("of:0000000000000002"), 2); + uglyMap.put(DeviceId.deviceId("of:0000000000000003"), 3); + + deviceService.addListener(listener); + + for (Device d : deviceService.getDevices()) { + pushRules(d); + } + + + log.info("Started with Application ID {}", appId.id()); + } + + @Deactivate + public void deactivate() { + flowRuleService.removeFlowRulesById(appId); + + log.info("Stopped"); + } + + + private void pushRules(Device device) { + + TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); + TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); + int inport = 1; + int outport = 2; + MplsLabel mplsLabel = MplsLabel.mplsLabel(101); + Integer switchNumber = uglyMap.get(device.id()); + if (switchNumber == null) { + return; + } + + switch (switchNumber) { + case 1: + sbuilder.matchInPort(PortNumber.portNumber(inport)); + tbuilder.setOutput(PortNumber.portNumber(outport)) + .pushMpls() + .setMpls(mplsLabel); + break; + case 2: + sbuilder.matchMplsLabel(mplsLabel) + .matchEthType(Ethernet.MPLS_UNICAST) + .matchInPort(PortNumber.portNumber(inport)); + tbuilder.setOutput(PortNumber.portNumber(outport)); + break; + case 3: + sbuilder.matchMplsLabel(mplsLabel) + .matchEthType(Ethernet.MPLS_UNICAST) + .matchInPort(PortNumber.portNumber(inport)); + tbuilder.popMpls().setOutput(PortNumber.portNumber(outport)); + break; + default: + } + + TrafficTreatment treatement = tbuilder.build(); + TrafficSelector selector = sbuilder.build(); + + FlowRule f = DefaultFlowRule.builder() + .forDevice(device.id()) + .withSelector(selector) + .withTreatment(treatement) + .withPriority(100) + .fromApp(appId) + .makeTemporary(600) + .build(); + + flowRuleService.applyFlowRules(f); + } + + + public class InternalDeviceListener implements DeviceListener { + + @Override + public void event(DeviceEvent event) { + switch (event.type()) { + case DEVICE_ADDED: + pushRules(event.subject()); + break; + case DEVICE_AVAILABILITY_CHANGED: + break; + case DEVICE_REMOVED: + break; + case DEVICE_SUSPENDED: + break; + case DEVICE_UPDATED: + break; + case PORT_ADDED: + break; + case PORT_REMOVED: + break; + case PORT_UPDATED: + break; + default: + break; + + } + + } + + } + + +} + + diff --git a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java deleted file mode 100644 index 00956763..00000000 --- a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2014-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.demo; - -import com.fasterxml.jackson.databind.JsonNode; - -import java.util.Optional; - -/** - * Simple demo api interface. - */ -public interface DemoAPI { - - enum InstallType { MESH, RANDOM } - - /** - * Tests flow subsystem based on the parameters supplied. - * - * @param params the test parameters - * @return JSON representation - */ - JsonNode flowTest(Optional params); - - /** - * Installs intents based on the installation type. - * @param type the installation type. - * @param runParams run params - */ - void setup(InstallType type, Optional runParams); - - /** - * Uninstalls all existing intents. - */ - void tearDown(); - -} diff --git a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoApi.java b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoApi.java new file mode 100644 index 00000000..1e594157 --- /dev/null +++ b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoApi.java @@ -0,0 +1,49 @@ +/* + * Copyright 2014-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.demo; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.Optional; + +/** + * Simple demo api interface. + */ +public interface DemoApi { + + enum InstallType { MESH, RANDOM } + + /** + * Tests flow subsystem based on the parameters supplied. + * + * @param params the test parameters + * @return JSON representation + */ + JsonNode flowTest(Optional params); + + /** + * Installs intents based on the installation type. + * @param type the installation type. + * @param runParams run params + */ + void setup(InstallType type, Optional runParams); + + /** + * Uninstalls all existing intents. + */ + void tearDown(); + +} diff --git a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java index a408e695..0bddc083 100644 --- a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java +++ b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java @@ -87,7 +87,7 @@ import static org.slf4j.LoggerFactory.getLogger; */ @Component(immediate = true) @Service -public class DemoInstaller implements DemoAPI { +public class DemoInstaller implements DemoApi { private final Logger log = getLogger(getClass()); diff --git a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoResource.java b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoResource.java index e0c97dd8..e3a5a2d8 100644 --- a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoResource.java +++ b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoResource.java @@ -51,7 +51,7 @@ public class DemoResource extends BaseResource { public Response flowTest(InputStream input) throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode cfg = mapper.readTree(input); - DemoAPI demo = get(DemoAPI.class); + DemoApi demo = get(DemoApi.class); return Response.ok(demo.flowTest(Optional.ofNullable(cfg)).toString()).build(); } @@ -75,9 +75,9 @@ public class DemoResource extends BaseResource { } - DemoAPI.InstallType type = DemoAPI.InstallType.valueOf( + DemoApi.InstallType type = DemoApi.InstallType.valueOf( cfg.get("type").asText().toUpperCase()); - DemoAPI demo = get(DemoAPI.class); + DemoApi demo = get(DemoApi.class); demo.setup(type, Optional.ofNullable(cfg.get("runParams"))); return Response.ok(mapper.createObjectNode().toString()).build(); @@ -93,7 +93,7 @@ public class DemoResource extends BaseResource { @Produces(MediaType.APPLICATION_JSON) public Response tearDown() { ObjectMapper mapper = new ObjectMapper(); - DemoAPI demo = get(DemoAPI.class); + DemoApi demo = get(DemoApi.class); demo.tearDown(); return Response.ok(mapper.createObjectNode().toString()).build(); } diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java index a33af769..fbce9648 100644 --- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java @@ -15,12 +15,6 @@ */ package org.onosproject.cli.net; -import static com.google.common.base.Strings.isNullOrEmpty; -import static org.onosproject.net.flow.DefaultTrafficTreatment.builder; - -import java.util.LinkedList; -import java.util.List; - import org.apache.karaf.shell.commands.Option; import org.onlab.packet.Ip6Address; import org.onlab.packet.IpAddress; @@ -47,6 +41,12 @@ import org.onosproject.net.intent.constraint.LinkTypeConstraint; import org.onosproject.net.intent.constraint.PartialFailureConstraint; import org.onosproject.net.resource.link.BandwidthResource; +import java.util.LinkedList; +import java.util.List; + +import static com.google.common.base.Strings.isNullOrEmpty; +import static org.onosproject.net.flow.DefaultTrafficTreatment.builder; + /** * Base class for command line operations for connectivity based intents. */ @@ -99,11 +99,11 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { @Option(name = "--ndSLL", description = "IPv6 Neighbor Discovery Source Link-Layer", required = false, multiValued = false) - private String ndSLLString = null; + private String ndSllString = null; @Option(name = "--ndTLL", description = "IPv6 Neighbor Discovery Target Link-Layer", required = false, multiValued = false) - private String ndTLLString = null; + private String ndTllString = null; @Option(name = "--tcpSrc", description = "Source TCP Port", required = false, multiValued = false) @@ -264,12 +264,12 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { selectorBuilder.matchIPv6NDTargetAddress(Ip6Address.valueOf(ndTargetString)); } - if (!isNullOrEmpty(ndSLLString)) { - selectorBuilder.matchIPv6NDSourceLinkLayerAddress(MacAddress.valueOf(ndSLLString)); + if (!isNullOrEmpty(ndSllString)) { + selectorBuilder.matchIPv6NDSourceLinkLayerAddress(MacAddress.valueOf(ndSllString)); } - if (!isNullOrEmpty(ndTLLString)) { - selectorBuilder.matchIPv6NDTargetLinkLayerAddress(MacAddress.valueOf(ndTLLString)); + if (!isNullOrEmpty(ndTllString)) { + selectorBuilder.matchIPv6NDTargetLinkLayerAddress(MacAddress.valueOf(ndTllString)); } if (!isNullOrEmpty(srcTcpString)) { diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetFlowStatistics.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetFlowStatistics.java index cafe87f9..4bbf4f10 100644 --- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetFlowStatistics.java +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetFlowStatistics.java @@ -82,15 +82,15 @@ public class GetFlowStatistics extends AbstractShellCommand { DeviceService deviceService = get(DeviceService.class); FlowStatisticService flowStatsService = get(FlowStatisticService.class); - String deviceURI = getDeviceId(devicePort); - String portURI = getPortNumber(devicePort); + String deviceUri = getDeviceId(devicePort); + String portUri = getPortNumber(devicePort); - DeviceId ingressDeviceId = deviceId(deviceURI); + DeviceId ingressDeviceId = deviceId(deviceUri); PortNumber ingressPortNumber; - if (portURI.length() == 0) { + if (portUri.length() == 0) { ingressPortNumber = null; } else { - ingressPortNumber = portNumber(portURI); + ingressPortNumber = portNumber(portUri); } Device device = deviceService.getDevice(ingressDeviceId); @@ -102,7 +102,7 @@ public class GetFlowStatistics extends AbstractShellCommand { if (ingressPortNumber != null) { Port port = deviceService.getPort(ingressDeviceId, ingressPortNumber); if (port == null) { - error("No such port %s on device %s", portURI, ingressDeviceId.uri()); + error("No such port %s on device %s", portUri, ingressDeviceId.uri()); return; } } @@ -148,7 +148,7 @@ public class GetFlowStatistics extends AbstractShellCommand { // print show topn head line with type print("deviceId=%s, show TOPN=%s flows, live type=%s, instruction type=%s", - deviceURI, + deviceUri, Integer.toString(topn), flowLiveType == null ? "ALL" : flowLiveType, instructionType == null ? "ALL" : instructionType); @@ -169,7 +169,7 @@ public class GetFlowStatistics extends AbstractShellCommand { } else if (showAll) { // is true? // print show all head line with type print("deviceId=%s, show ALL flows, live type=%s, instruction type=%s", - deviceURI, + deviceUri, flowLiveType == null ? "ALL" : flowLiveType, instructionType == null ? "ALL" : instructionType); if (ingressPortNumber == null) { @@ -188,7 +188,7 @@ public class GetFlowStatistics extends AbstractShellCommand { } } else { // if (showSummary == true) //always is true // print show summary head line - print("deviceId=%s, show SUMMARY flows", deviceURI); + print("deviceId=%s, show SUMMARY flows", deviceUri); if (ingressPortNumber == null) { Map summaryFlowLoadMap = flowStatsService.loadSummary(device); diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java index 12e9ab5f..a1a76925 100644 --- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java @@ -15,24 +15,23 @@ */ package org.onosproject.cli.net; -import java.util.Set; -import java.util.List; - +import com.google.common.collect.Lists; import org.apache.karaf.shell.commands.Argument; import org.apache.karaf.shell.commands.Command; import org.apache.karaf.shell.commands.Option; import org.onosproject.cli.AbstractShellCommand; +import org.onosproject.net.DeviceId; +import org.onosproject.net.Link; +import org.onosproject.net.Path; import org.onosproject.net.intent.IntentId; import org.onosproject.net.resource.link.DefaultLinkResourceRequest; import org.onosproject.net.resource.link.LinkResourceAllocations; import org.onosproject.net.resource.link.LinkResourceRequest; import org.onosproject.net.resource.link.LinkResourceService; import org.onosproject.net.topology.PathService; -import org.onosproject.net.DeviceId; -import org.onosproject.net.Link; -import org.onosproject.net.Path; -import com.google.common.collect.Lists; +import java.util.List; +import java.util.Set; /** * Commands to test out LinkResourceManager directly. @@ -44,7 +43,7 @@ public class LinkResourceTestCommand extends AbstractShellCommand { // default is bandwidth. @Option(name = "-m", aliases = "--mpls", description = "MPLS resource", required = false, multiValued = false) - private boolean isMPLS = false; + private boolean isMpls = false; @Option(name = "-o", aliases = "--optical", description = "Optical resource", required = false, multiValued = false) @@ -96,7 +95,7 @@ public class LinkResourceTestCommand extends AbstractShellCommand { for (Path p : paths) { List links = p.links(); LinkResourceRequest.Builder request = null; - if (isMPLS) { + if (isMpls) { List nlinks = Lists.newArrayList(); try { nlinks.addAll(links.subList(1, links.size() - 2)); diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java index 3a8c8c1f..0fcc800d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java @@ -71,7 +71,7 @@ public class DefaultDeviceDescription extends AbstractDescription */ public DefaultDeviceDescription(DeviceDescription base, SparseAnnotations... annotations) { - this(base.deviceURI(), base.type(), base.manufacturer(), + this(base.deviceUri(), base.type(), base.manufacturer(), base.hwVersion(), base.swVersion(), base.serialNumber(), base.chassisId(), annotations); } @@ -83,13 +83,13 @@ public class DefaultDeviceDescription extends AbstractDescription * @param annotations Annotations to use. */ public DefaultDeviceDescription(DeviceDescription base, Type type, SparseAnnotations... annotations) { - this(base.deviceURI(), type, base.manufacturer(), + this(base.deviceUri(), type, base.manufacturer(), base.hwVersion(), base.swVersion(), base.serialNumber(), base.chassisId(), annotations); } @Override - public URI deviceURI() { + public URI deviceUri() { return uri; } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java index 64b84b5a..f206b080 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java @@ -33,7 +33,7 @@ public interface DeviceDescription extends Description { * * @return provider specific URI for the device */ - URI deviceURI(); + URI deviceUri(); /** * Returns the type of the infrastructure device. diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DefaultDeviceDescriptionTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DefaultDeviceDescriptionTest.java index 3dcdc22d..c00a6de0 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DefaultDeviceDescriptionTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DefaultDeviceDescriptionTest.java @@ -41,7 +41,7 @@ public class DefaultDeviceDescriptionTest { public void basics() { DeviceDescription device = new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN, CID); - assertEquals("incorrect uri", DURI, device.deviceURI()); + assertEquals("incorrect uri", DURI, device.deviceUri()); assertEquals("incorrect type", SWITCH, device.type()); assertEquals("incorrect manufacturer", MFR, device.manufacturer()); assertEquals("incorrect hw", HW, device.hwVersion()); diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/driver/XmlDriverLoaderTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/driver/XmlDriverLoaderTest.java index f54e7411..15abc2bf 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/driver/XmlDriverLoaderTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/driver/XmlDriverLoaderTest.java @@ -57,7 +57,7 @@ public class XmlDriverLoaderTest { } @Test(expected = IOException.class) - public void badXML() throws IOException { + public void badXml() throws IOException { XmlDriverLoader loader = new XmlDriverLoader(getClass().getClassLoader()); loader.loadDrivers(getClass().getResourceAsStream("drivers.bad.xml"), null); } @@ -77,4 +77,4 @@ public class XmlDriverLoaderTest { driver.createBehaviour(new DefaultDriverData(driver, DEVICE_ID), TestBehaviour.class); } -} \ No newline at end of file +} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellComparatorTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellComparatorTest.java index d77c1b2b..b870d483 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellComparatorTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellComparatorTest.java @@ -115,19 +115,19 @@ public class DefaultCellComparatorTest { } @Test - public void swEpisodeII() { + public void swEpisodeIi() { assertTrue("r2d2 c3po", cmp.compare(SmallStarWars.R2D2, SmallStarWars.C3PO) > 0); } @Test - public void swEpisodeIII() { + public void swEpisodeIii() { assertTrue("luke c3po", cmp.compare(SmallStarWars.LUKE, SmallStarWars.C3PO) > 0); } @Test - public void swEpisodeIV() { + public void swEpisodeIv() { assertTrue("c3po luke", cmp.compare(SmallStarWars.C3PO, SmallStarWars.LUKE) < 0); } @@ -139,7 +139,7 @@ public class DefaultCellComparatorTest { } @Test - public void swEpisodeVI() { + public void swEpisodeVi() { assertTrue("r2d2 luke", cmp.compare(SmallStarWars.R2D2, SmallStarWars.LUKE) < 0); } diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/common/DefaultTopology.java b/framework/src/onos/core/common/src/main/java/org/onosproject/common/DefaultTopology.java index 3c5c540d..84cde424 100644 --- a/framework/src/onos/core/common/src/main/java/org/onosproject/common/DefaultTopology.java +++ b/framework/src/onos/core/common/src/main/java/org/onosproject/common/DefaultTopology.java @@ -26,10 +26,10 @@ import org.onlab.graph.DijkstraGraphSearch; import org.onlab.graph.DisjointPathPair; import org.onlab.graph.GraphPathSearch; import org.onlab.graph.GraphPathSearch.Result; -import org.onlab.graph.SRLGGraphSearch; +import org.onlab.graph.SrlgGraphSearch; import org.onlab.graph.SuurballeGraphSearch; import org.onlab.graph.TarjanGraphSearch; -import org.onlab.graph.TarjanGraphSearch.SCCResult; +import org.onlab.graph.TarjanGraphSearch.SccResult; import org.onosproject.net.AbstractModel; import org.onosproject.net.ConnectPoint; import org.onosproject.net.DefaultDisjointPath; @@ -83,7 +83,7 @@ public class DefaultTopology extends AbstractModel implements Topology { private final TopologyGraph graph; private final LinkWeight weight; - private final Supplier> clusterResults; + private final Supplier> clusterResults; private final Supplier> clusters; private final Supplier> infrastructurePoints; private final Supplier> broadcastSets; @@ -385,7 +385,7 @@ public class DefaultTopology extends AbstractModel implements Topology { return ImmutableSet.of(); } - SRLGGraphSearch srlg = new SRLGGraphSearch<>(riskProfile); + SrlgGraphSearch srlg = new SrlgGraphSearch<>(riskProfile); GraphPathSearch.Result result = srlg.search(graph, srcV, dstV, weight, ALL_PATHS); ImmutableSet.Builder builder = ImmutableSet.builder(); @@ -455,14 +455,14 @@ public class DefaultTopology extends AbstractModel implements Topology { // Searches for SCC clusters in the network topology graph using Tarjan // algorithm. - private SCCResult searchForClusters() { + private SccResult searchForClusters() { return TARJAN.search(graph, new NoIndirectLinksWeight()); } // Builds the topology clusters and returns the id-cluster bindings. private ImmutableMap buildTopologyClusters() { ImmutableMap.Builder clusterBuilder = ImmutableMap.builder(); - SCCResult results = clusterResults.get(); + SccResult results = clusterResults.get(); // Extract both vertexes and edges from the results; the lists form // pairs along the same index. diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java index 72fc1b05..11a12040 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java @@ -532,7 +532,7 @@ public class SimpleDeviceStore checkArgument(!providerDescs.isEmpty(), "No Device descriptions supplied"); - ProviderId primary = pickPrimaryPID(providerDescs); + ProviderId primary = pickPrimaryPid(providerDescs); DeviceDescriptions desc = providerDescs.get(primary); @@ -575,7 +575,7 @@ public class SimpleDeviceStore private Port composePort(Device device, PortNumber number, Map descsMap) { - ProviderId primary = pickPrimaryPID(descsMap); + ProviderId primary = pickPrimaryPid(descsMap); DeviceDescriptions primDescs = descsMap.get(primary); // if no primary, assume not enabled // TODO: revisit this default port enabled/disabled behavior @@ -613,7 +613,7 @@ public class SimpleDeviceStore /** * @return primary ProviderID, or randomly chosen one if none exists */ - private ProviderId pickPrimaryPID(Map descsMap) { + private ProviderId pickPrimaryPid(Map descsMap) { ProviderId fallBackPrimary = null; for (Entry e : descsMap.entrySet()) { if (!e.getKey().isAncillary()) { diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/BasicDeviceOperator.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/BasicDeviceOperator.java index 32403421..a498b3f4 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/BasicDeviceOperator.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/BasicDeviceOperator.java @@ -61,7 +61,7 @@ public final class BasicDeviceOperator implements ConfigOperator { } SparseAnnotations sa = combine(bdc, descr.annotations()); - return new DefaultDeviceDescription(descr.deviceURI(), type, descr.manufacturer(), + return new DefaultDeviceDescription(descr.deviceUri(), type, descr.manufacturer(), descr.hwVersion(), descr.swVersion(), descr.serialNumber(), descr.chassisId(), sa); } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/FlowStatisticManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/FlowStatisticManager.java index 6515ef31..f18c56dc 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/FlowStatisticManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/FlowStatisticManager.java @@ -255,7 +255,7 @@ public class FlowStatisticManager implements FlowStatisticService { Instruction.Type instType) { checkPermission(STATISTIC_READ); - List retTFEL = new ArrayList<>(); + List retTfel = new ArrayList<>(); Set currentStats; Set previousStats; @@ -264,11 +264,11 @@ public class FlowStatisticManager implements FlowStatisticService { synchronized (flowStatisticStore) { currentStats = flowStatisticStore.getCurrentFlowStatistic(cp); if (currentStats == null) { - return retTFEL; + return retTfel; } previousStats = flowStatisticStore.getPreviousFlowStatistic(cp); if (previousStats == null) { - return retTFEL; + return retTfel; } // copy to local flow entry set typedStatistics = new TypedStatistics(currentStats, previousStats); @@ -291,7 +291,7 @@ public class FlowStatisticManager implements FlowStatisticService { List fel = typedFlowEntryLoadByInstInternal(cp, currentMap, previousMap, isAllInstType, instType, TypedFlowEntryWithLoad.shortPollInterval()); if (fel.size() > 0) { - retTFEL.addAll(fel); + retTfel.addAll(fel); } } @@ -302,7 +302,7 @@ public class FlowStatisticManager implements FlowStatisticService { List fel = typedFlowEntryLoadByInstInternal(cp, currentMap, previousMap, isAllInstType, instType, TypedFlowEntryWithLoad.shortPollInterval()); if (fel.size() > 0) { - retTFEL.addAll(fel); + retTfel.addAll(fel); } } @@ -313,7 +313,7 @@ public class FlowStatisticManager implements FlowStatisticService { List fel = typedFlowEntryLoadByInstInternal(cp, currentMap, previousMap, isAllInstType, instType, TypedFlowEntryWithLoad.midPollInterval()); if (fel.size() > 0) { - retTFEL.addAll(fel); + retTfel.addAll(fel); } } @@ -324,7 +324,7 @@ public class FlowStatisticManager implements FlowStatisticService { List fel = typedFlowEntryLoadByInstInternal(cp, currentMap, previousMap, isAllInstType, instType, TypedFlowEntryWithLoad.longPollInterval()); if (fel.size() > 0) { - retTFEL.addAll(fel); + retTfel.addAll(fel); } } @@ -335,11 +335,11 @@ public class FlowStatisticManager implements FlowStatisticService { List fel = typedFlowEntryLoadByInstInternal(cp, currentMap, previousMap, isAllInstType, instType, TypedFlowEntryWithLoad.avgPollInterval()); if (fel.size() > 0) { - retTFEL.addAll(fel); + retTfel.addAll(fel); } } - return retTFEL; + return retTfel; } private List typedFlowEntryLoadByInstInternal(ConnectPoint cp, diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/proxyarp/impl/ProxyArpManagerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/proxyarp/impl/ProxyArpManagerTest.java index ee9dc8fb..70fdb406 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/proxyarp/impl/ProxyArpManagerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/proxyarp/impl/ProxyArpManagerTest.java @@ -495,15 +495,15 @@ public class ProxyArpManagerTest { replay(hostService); replay(interfaceService); - Ethernet ndpRequest = buildNDP(ICMP6.NEIGHBOR_SOLICITATION, - MAC4, SOLICITED_MAC3, - IP4, IP3); + Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION, + MAC4, SOLICITED_MAC3, + IP4, IP3); proxyArp.reply(ndpRequest, getLocation(5)); assertEquals(1, packetService.packets.size()); - Ethernet ndpReply = buildNDP(ICMP6.NEIGHBOR_ADVERTISEMENT, - MAC3, MAC4, IP3, IP4); + Ethernet ndpReply = buildNdp(ICMP6.NEIGHBOR_ADVERTISEMENT, + MAC3, MAC4, IP3, IP4); verifyPacketOut(ndpReply, getLocation(5), packetService.packets.get(0)); } @@ -556,9 +556,9 @@ public class ProxyArpManagerTest { replay(hostService); replay(interfaceService); - Ethernet ndpRequest = buildNDP(ICMP6.NEIGHBOR_SOLICITATION, - MAC4, SOLICITED_MAC3, - IP4, IP3); + Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION, + MAC4, SOLICITED_MAC3, + IP4, IP3); proxyArp.reply(ndpRequest, getLocation(NUM_DEVICES)); @@ -686,9 +686,9 @@ public class ProxyArpManagerTest { replay(hostService); replay(interfaceService); - Ethernet ndpRequest = buildNDP(ICMP6.NEIGHBOR_SOLICITATION, - MAC4, SOLICITED_MAC3, - IP4, IP3); + Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION, + MAC4, SOLICITED_MAC3, + IP4, IP3); proxyArp.reply(ndpRequest, getLocation(NUM_DEVICES)); @@ -752,37 +752,37 @@ public class ProxyArpManagerTest { replay(hostService); replay(interfaceService); - Ethernet ndpRequest = buildNDP(ICMP6.NEIGHBOR_SOLICITATION, - MAC2, - MacAddress.valueOf("33:33:ff:00:00:01"), - theirIp, - ourFirstIp); + Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION, + MAC2, + MacAddress.valueOf("33:33:ff:00:00:01"), + theirIp, + ourFirstIp); proxyArp.reply(ndpRequest, LOC1); assertEquals(1, packetService.packets.size()); - Ethernet ndpReply = buildNDP(ICMP6.NEIGHBOR_ADVERTISEMENT, - firstMac, - MAC2, - ourFirstIp, - theirIp); + Ethernet ndpReply = buildNdp(ICMP6.NEIGHBOR_ADVERTISEMENT, + firstMac, + MAC2, + ourFirstIp, + theirIp); verifyPacketOut(ndpReply, LOC1, packetService.packets.get(0)); // Test a request for the second address on that port packetService.packets.clear(); - ndpRequest = buildNDP(ICMP6.NEIGHBOR_SOLICITATION, - MAC2, - MacAddress.valueOf("33:33:ff:00:00:01"), - theirIp, - ourSecondIp); + ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION, + MAC2, + MacAddress.valueOf("33:33:ff:00:00:01"), + theirIp, + ourSecondIp); proxyArp.reply(ndpRequest, LOC1); assertEquals(1, packetService.packets.size()); - ndpReply = buildNDP(ICMP6.NEIGHBOR_ADVERTISEMENT, - secondMac, - MAC2, - ourSecondIp, - theirIp); + ndpReply = buildNdp(ICMP6.NEIGHBOR_ADVERTISEMENT, + secondMac, + MAC2, + ourSecondIp, + theirIp); verifyPacketOut(ndpReply, LOC1, packetService.packets.get(0)); } @@ -819,21 +819,21 @@ public class ProxyArpManagerTest { Ip6Address theirIp = Ip6Address.valueOf("1000::ffff"); - Ethernet ndpRequest = buildNDP(ICMP6.NEIGHBOR_SOLICITATION, - MAC1, - MacAddress.valueOf("33:33:ff:00:00:01"), - theirIp, - Ip6Address.valueOf("3000::1")); + Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION, + MAC1, + MacAddress.valueOf("33:33:ff:00:00:01"), + theirIp, + Ip6Address.valueOf("3000::1")); proxyArp.reply(ndpRequest, LOC1); assertEquals(0, packetService.packets.size()); // Request for a valid internal IP address but coming in an external port packetService.packets.clear(); - ndpRequest = buildNDP(ICMP6.NEIGHBOR_SOLICITATION, - MAC1, - MacAddress.valueOf("33:33:ff:00:00:01"), - theirIp, - IP3); + ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION, + MAC1, + MacAddress.valueOf("33:33:ff:00:00:01"), + theirIp, + IP3); proxyArp.reply(ndpRequest, LOC1); assertEquals(0, packetService.packets.size()); } @@ -894,11 +894,11 @@ public class ProxyArpManagerTest { // This is a request from something inside our network (like a BGP // daemon) to an external host. - Ethernet ndpRequest = buildNDP(ICMP6.NEIGHBOR_SOLICITATION, - ourMac, - MacAddress.valueOf("33:33:ff:00:00:01"), - ourIp, - theirIp); + Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION, + ourMac, + MacAddress.valueOf("33:33:ff:00:00:01"), + ourIp, + theirIp); proxyArp.reply(ndpRequest, getLocation(5)); assertEquals(1, packetService.packets.size()); @@ -954,9 +954,9 @@ public class ProxyArpManagerTest { replay(hostService); replay(interfaceService); - Ethernet ndpRequest = buildNDP(ICMP6.NEIGHBOR_SOLICITATION, - MAC4, SOLICITED_MAC3, - IP4, IP3); + Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION, + MAC4, SOLICITED_MAC3, + IP4, IP3); proxyArp.forward(ndpRequest, LOC2); @@ -995,9 +995,9 @@ public class ProxyArpManagerTest { replay(hostService); replay(interfaceService); - Ethernet ndpRequest = buildNDP(ICMP6.NEIGHBOR_SOLICITATION, - MAC4, SOLICITED_MAC3, - IP4, IP3); + Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION, + MAC4, SOLICITED_MAC3, + IP4, IP3); proxyArp.forward(ndpRequest, getLocation(NUM_DEVICES)); @@ -1113,7 +1113,7 @@ public class ProxyArpManagerTest { * @param dstIp destination IP address * @return the NDP packet */ - private Ethernet buildNDP(byte type, MacAddress srcMac, MacAddress dstMac, + private Ethernet buildNdp(byte type, MacAddress srcMac, MacAddress dstMac, Ip6Address srcIp, Ip6Address dstIp) { assertThat(type, anyOf( is(ICMP6.NEIGHBOR_SOLICITATION), diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java index 23c81869..d61d7dcf 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java @@ -47,7 +47,7 @@ public class NettyMessagingManager extends NettyMessaging { @Activate public void activate() throws Exception { ControllerNode localNode = clusterMetadataService.getLocalNode(); - getTLSParameters(); + getTlsParameters(); super.start(new Endpoint(localNode.ip(), localNode.tcpPort())); log.info("Started"); } @@ -58,29 +58,29 @@ public class NettyMessagingManager extends NettyMessaging { log.info("Stopped"); } - private void getTLSParameters() { + private void getTlsParameters() { String tempString = System.getProperty("enableNettyTLS"); - enableNettyTLS = Strings.isNullOrEmpty(tempString) ? TLS_DISABLED : Boolean.parseBoolean(tempString); - log.info("enableNettyTLS = {}", enableNettyTLS); - if (enableNettyTLS) { + enableNettyTls = Strings.isNullOrEmpty(tempString) ? TLS_DISABLED : Boolean.parseBoolean(tempString); + log.info("enableNettyTLS = {}", enableNettyTls); + if (enableNettyTls) { ksLocation = System.getProperty("javax.net.ssl.keyStore"); if (Strings.isNullOrEmpty(ksLocation)) { - enableNettyTLS = TLS_DISABLED; + enableNettyTls = TLS_DISABLED; return; } tsLocation = System.getProperty("javax.net.ssl.trustStore"); if (Strings.isNullOrEmpty(tsLocation)) { - enableNettyTLS = TLS_DISABLED; + enableNettyTls = TLS_DISABLED; return; } ksPwd = System.getProperty("javax.net.ssl.keyStorePassword").toCharArray(); if (MIN_KS_LENGTH > ksPwd.length) { - enableNettyTLS = TLS_DISABLED; + enableNettyTls = TLS_DISABLED; return; } tsPwd = System.getProperty("javax.net.ssl.trustStorePassword").toCharArray(); if (MIN_KS_LENGTH > tsPwd.length) { - enableNettyTLS = TLS_DISABLED; + enableNettyTls = TLS_DISABLED; return; } } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java index 85e67dec..a9a9098e 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java @@ -1040,7 +1040,7 @@ public class GossipDeviceStore checkArgument(!providerDescs.isEmpty(), "No device descriptions supplied"); - ProviderId primary = pickPrimaryPID(providerDescs); + ProviderId primary = pickPrimaryPid(providerDescs); DeviceDescriptions desc = providerDescs.get(primary); @@ -1103,7 +1103,7 @@ public class GossipDeviceStore private Port composePort(Device device, PortNumber number, Map descsMap) { - ProviderId primary = pickPrimaryPID(descsMap); + ProviderId primary = pickPrimaryPid(descsMap); DeviceDescriptions primDescs = descsMap.get(primary); // if no primary, assume not enabled boolean isEnabled = false; @@ -1149,7 +1149,7 @@ public class GossipDeviceStore /** * @return primary ProviderID, or randomly chosen one if none exists */ - private ProviderId pickPrimaryPID( + private ProviderId pickPrimaryPid( Map providerDescs) { ProviderId fallBackPrimary = null; for (Entry e : providerDescs.entrySet()) { @@ -1165,7 +1165,7 @@ public class GossipDeviceStore private DeviceDescriptions getPrimaryDescriptions( Map providerDescs) { - ProviderId pid = pickPrimaryPID(providerDescs); + ProviderId pid = pickPrimaryPid(providerDescs); return providerDescs.get(pid); } diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java index 3a168936..5cbf360a 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java @@ -232,7 +232,7 @@ public class GossipDeviceStoreTest { if (expected == actual) { return; } - assertEquals(expected.deviceURI(), actual.deviceURI()); + assertEquals(expected.deviceUri(), actual.deviceUri()); assertEquals(expected.hwVersion(), actual.hwVersion()); assertEquals(expected.manufacturer(), actual.manufacturer()); assertEquals(expected.serialNumber(), actual.serialNumber()); @@ -247,7 +247,7 @@ public class GossipDeviceStoreTest { if (expected == actual) { return; } - assertEquals(expected.deviceURI(), actual.deviceURI()); + assertEquals(expected.deviceUri(), actual.deviceUri()); assertEquals(expected.hwVersion(), actual.hwVersion()); assertEquals(expected.manufacturer(), actual.manufacturer()); assertEquals(expected.serialNumber(), actual.serialNumber()); diff --git a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java index 0312bafd..b2199f70 100644 --- a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java +++ b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java @@ -438,7 +438,7 @@ public final class KryoNamespaces { DefaultTableStatisticsEntry.class ) .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class) - .register(new URISerializer(), URI.class) + .register(new UriSerializer(), URI.class) .register(new NodeIdSerializer(), NodeId.class) .register(new ProviderIdSerializer(), ProviderId.class) .register(new DeviceIdSerializer(), DeviceId.class) diff --git a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/URISerializer.java b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/URISerializer.java deleted file mode 100644 index 43969666..00000000 --- a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/URISerializer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2014 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.store.serializers; - -import java.net.URI; - -import com.esotericsoftware.kryo.Kryo; -import com.esotericsoftware.kryo.Serializer; -import com.esotericsoftware.kryo.io.Input; -import com.esotericsoftware.kryo.io.Output; - -/** - * Serializer for {@link URI}. - */ -public class URISerializer extends Serializer { - - /** - * Creates {@link URI} serializer instance. - */ - public URISerializer() { - super(false); - } - - @Override - public void write(Kryo kryo, Output output, URI object) { - output.writeString(object.toString()); - } - - @Override - public URI read(Kryo kryo, Input input, Class type) { - return URI.create(input.readString()); - } -} diff --git a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/UriSerializer.java b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/UriSerializer.java new file mode 100644 index 00000000..1d146a55 --- /dev/null +++ b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/UriSerializer.java @@ -0,0 +1,46 @@ +/* + * Copyright 2014 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.store.serializers; + +import com.esotericsoftware.kryo.Kryo; +import com.esotericsoftware.kryo.Serializer; +import com.esotericsoftware.kryo.io.Input; +import com.esotericsoftware.kryo.io.Output; + +import java.net.URI; + +/** + * Serializer for {@link URI}. + */ +public class UriSerializer extends Serializer { + + /** + * Creates {@link URI} serializer instance. + */ + public UriSerializer() { + super(false); + } + + @Override + public void write(Kryo kryo, Output output, URI object) { + output.writeString(object.toString()); + } + + @Override + public URI read(Kryo kryo, Input input, Class type) { + return URI.create(input.readString()); + } +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/handshaker/OFOpticalSwitchImplLINC13.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/handshaker/OFOpticalSwitchImplLINC13.java deleted file mode 100644 index 7faee374..00000000 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/handshaker/OFOpticalSwitchImplLINC13.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * 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.driver.handshaker; - -import org.onosproject.net.Device; -import com.google.common.collect.ImmutableSet; -import org.onosproject.openflow.controller.OpenFlowOpticalSwitch; -import org.onosproject.openflow.controller.PortDescPropertyType; -import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; -import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeAlreadyStarted; -import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeCompleted; -import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotStarted; -import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus; -import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply; -import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest; -import org.projectfloodlight.openflow.protocol.OFMessage; -import org.projectfloodlight.openflow.protocol.OFObject; -import org.projectfloodlight.openflow.protocol.OFPortDesc; -import org.projectfloodlight.openflow.protocol.OFPortDescPropOpticalTransport; -import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; -import org.projectfloodlight.openflow.protocol.OFPortOptical; -import org.projectfloodlight.openflow.protocol.OFStatsReply; -import org.projectfloodlight.openflow.protocol.OFStatsType; -import org.projectfloodlight.openflow.types.OFPort; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * LINC-OE Optical Emulator switch class. - * - * The LINC ROADM emulator exposes two types of ports: OCh ports connect to ports in the packet layer, - * while OMS ports connect to an OMS port on a neighbouring ROADM. - * - * LINC sends the tap ports (OCh for our purposes) in the regular port desc stats reply, - * while it sends *all* ports (both tap and WDM ports, i.e., OCh and OMS) in the experimenter port desc stats reply. - * - */ -public class OFOpticalSwitchImplLINC13 - extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch { - - private final AtomicBoolean driverHandshakeComplete = new AtomicBoolean(false); - private long barrierXidToWaitFor = -1; - - private List opticalPorts; - - @Override - public void startDriverHandshake() { - log.warn("Starting driver handshake for sw {}", getStringId()); - if (startDriverHandshakeCalled) { - throw new SwitchDriverSubHandshakeAlreadyStarted(); - } - startDriverHandshakeCalled = true; - try { - sendHandshakeOFExperimenterPortDescRequest(); - } catch (IOException e) { - log.error("LINC-OE exception while sending experimenter port desc:", - e.getMessage()); - e.printStackTrace(); - } - } - - @Override - public boolean isDriverHandshakeComplete() { - return driverHandshakeComplete.get(); - } - - @Override - public void processDriverHandshakeMessage(OFMessage m) { - if (!startDriverHandshakeCalled) { - throw new SwitchDriverSubHandshakeNotStarted(); - } - if (driverHandshakeComplete.get()) { - throw new SwitchDriverSubHandshakeCompleted(m); - } - - switch (m.getType()) { - case BARRIER_REPLY: - if (m.getXid() == barrierXidToWaitFor) { - log.debug("LINC-OE Received barrier response"); - } - break; - case ERROR: - log.error("Switch {} Error {}", getStringId(), m); - break; - case FEATURES_REPLY: - break; - case FLOW_REMOVED: - break; - case GET_ASYNC_REPLY: - break; - case PACKET_IN: - break; - case PORT_STATUS: - log.warn("****LINC-OE Port Status {} {}", getStringId(), m); - processOFPortStatus((OFCircuitPortStatus) m); - break; - case QUEUE_GET_CONFIG_REPLY: - break; - case ROLE_REPLY: - break; - case STATS_REPLY: - OFStatsReply stats = (OFStatsReply) m; - if (stats.getStatsType() == OFStatsType.EXPERIMENTER) { - log.warn("LINC-OE : Received stats reply message {}", m); - createOpticalPortList((OFCircuitPortsReply) m); - driverHandshakeComplete.set(true); - } - break; - default: - log.warn("Received message {} during switch-driver " + - "subhandshake " + "from switch {} ... " + - "Ignoring message", m, - getStringId()); - - } - } - - public void processOFPortStatus(OFCircuitPortStatus ps) { - log.debug("LINC-OE ..OF Port Status :", ps); - } - - private void sendHandshakeOFExperimenterPortDescRequest() throws - IOException { - // send multi part message for port description for optical switches - OFCircuitPortsRequest circuitPortsRequest = factory() - .buildCircuitPortsRequest().setXid(getNextTransactionId()) - .build(); - log.warn("LINC-OE : Sending experimented circuit port stats " + - "message " + - "{}", - circuitPortsRequest.toString()); - this.sendHandshakeMessage(circuitPortsRequest); - } - - @Override - /** - * Returns a list of standard (Ethernet) ports. - * - * @return List of ports - */ - public List getPorts() { - return Collections.EMPTY_LIST; - } - - - @Override - public Boolean supportNxRole() { - return false; - } - - @Override - public Device.Type deviceType() { - return Device.Type.ROADM; - } - - /** - * Checks if given port is also part of the regular port desc stats, i.e., is the port a tap port. - * - * @param port given OF port - * @return true if the port is a tap (OCh), false otherwise (OMS port) - */ - private boolean hasPort(OFPort port) { - for (OFPortDescStatsReply reply : this.ports) { - for (OFPortDesc p : reply.getEntries()) { - if (p.getPortNo().equals(port)) { - return true; - } - } - } - - return false; - } - - /** - * Creates an OpenFlow optical port based on the given port and transport type. - * - * @param port OpenFlow optical port - * @param type transport type - * @return OpenFlow optical port - */ - private OFPortOptical createOpticalPort(OFPortOptical port, short type) { - List descList = new ArrayList<>(port.getDesc().size()); - - for (OFPortDescPropOpticalTransport desc : port.getDesc()) { - OFPortDescPropOpticalTransport newDesc = desc.createBuilder() - .setType(desc.getType()) - .setPortSignalType(type) - .setPortType(desc.getPortType()) - .setReserved(desc.getReserved()) - .build(); - descList.add(newDesc); - } - - OFPortOptical newPort = port.createBuilder() - .setConfig(port.getConfig()) - .setDesc(descList) - .setHwAddr(port.getHwAddr()) - .setName(port.getName()) - .setPortNo(port.getPortNo()) - .setState(port.getState()) - .build(); - - return newPort; - } - - /** - * Builds list of OFPortOptical ports based on the multi-part circuit ports reply. - * - * Ensure the optical transport port's signal type is configured correctly. - * - * @param wPorts OF reply with circuit ports - */ - private void createOpticalPortList(OFCircuitPortsReply wPorts) { - opticalPorts = new ArrayList<>(wPorts.getEntries().size()); - - for (OFPortOptical p : wPorts.getEntries()) { - short signalType; - - // FIXME: use constants once loxi has full optical extensions - if (hasPort(p.getPortNo())) { - signalType = 5; // OCH port - } else { - signalType = 2; // OMS port - } - - opticalPorts.add(createOpticalPort(p, signalType)); - } - } - - @Override - public List getPortsOf(PortDescPropertyType type) { - if (!type.equals(PortDescPropertyType.OPTICAL_TRANSPORT)) { - return Collections.EMPTY_LIST; - } - - return opticalPorts; - } - - @Override - public Set getPortTypes() { - return ImmutableSet.of(PortDescPropertyType.OPTICAL_TRANSPORT); - } -} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/handshaker/OfOpticalSwitchImplLinc13.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/handshaker/OfOpticalSwitchImplLinc13.java new file mode 100644 index 00000000..ff65e0c6 --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/handshaker/OfOpticalSwitchImplLinc13.java @@ -0,0 +1,261 @@ +/* + * 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.driver.handshaker; + +import org.onosproject.net.Device; +import com.google.common.collect.ImmutableSet; +import org.onosproject.openflow.controller.OpenFlowOpticalSwitch; +import org.onosproject.openflow.controller.PortDescPropertyType; +import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; +import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeAlreadyStarted; +import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeCompleted; +import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotStarted; +import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus; +import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply; +import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest; +import org.projectfloodlight.openflow.protocol.OFMessage; +import org.projectfloodlight.openflow.protocol.OFObject; +import org.projectfloodlight.openflow.protocol.OFPortDesc; +import org.projectfloodlight.openflow.protocol.OFPortDescPropOpticalTransport; +import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; +import org.projectfloodlight.openflow.protocol.OFPortOptical; +import org.projectfloodlight.openflow.protocol.OFStatsReply; +import org.projectfloodlight.openflow.protocol.OFStatsType; +import org.projectfloodlight.openflow.types.OFPort; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * LINC-OE Optical Emulator switch class. + * + * The LINC ROADM emulator exposes two types of ports: OCh ports connect to ports in the packet layer, + * while OMS ports connect to an OMS port on a neighbouring ROADM. + * + * LINC sends the tap ports (OCh for our purposes) in the regular port desc stats reply, + * while it sends *all* ports (both tap and WDM ports, i.e., OCh and OMS) in the experimenter port desc stats reply. + * + */ +public class OfOpticalSwitchImplLinc13 + extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch { + + private final AtomicBoolean driverHandshakeComplete = new AtomicBoolean(false); + private long barrierXidToWaitFor = -1; + + private List opticalPorts; + + @Override + public void startDriverHandshake() { + log.warn("Starting driver handshake for sw {}", getStringId()); + if (startDriverHandshakeCalled) { + throw new SwitchDriverSubHandshakeAlreadyStarted(); + } + startDriverHandshakeCalled = true; + try { + sendHandshakeOFExperimenterPortDescRequest(); + } catch (IOException e) { + log.error("LINC-OE exception while sending experimenter port desc:", + e.getMessage()); + e.printStackTrace(); + } + } + + @Override + public boolean isDriverHandshakeComplete() { + return driverHandshakeComplete.get(); + } + + @Override + public void processDriverHandshakeMessage(OFMessage m) { + if (!startDriverHandshakeCalled) { + throw new SwitchDriverSubHandshakeNotStarted(); + } + if (driverHandshakeComplete.get()) { + throw new SwitchDriverSubHandshakeCompleted(m); + } + + switch (m.getType()) { + case BARRIER_REPLY: + if (m.getXid() == barrierXidToWaitFor) { + log.debug("LINC-OE Received barrier response"); + } + break; + case ERROR: + log.error("Switch {} Error {}", getStringId(), m); + break; + case FEATURES_REPLY: + break; + case FLOW_REMOVED: + break; + case GET_ASYNC_REPLY: + break; + case PACKET_IN: + break; + case PORT_STATUS: + log.warn("****LINC-OE Port Status {} {}", getStringId(), m); + processOFPortStatus((OFCircuitPortStatus) m); + break; + case QUEUE_GET_CONFIG_REPLY: + break; + case ROLE_REPLY: + break; + case STATS_REPLY: + OFStatsReply stats = (OFStatsReply) m; + if (stats.getStatsType() == OFStatsType.EXPERIMENTER) { + log.warn("LINC-OE : Received stats reply message {}", m); + createOpticalPortList((OFCircuitPortsReply) m); + driverHandshakeComplete.set(true); + } + break; + default: + log.warn("Received message {} during switch-driver " + + "subhandshake " + "from switch {} ... " + + "Ignoring message", m, + getStringId()); + + } + } + + public void processOFPortStatus(OFCircuitPortStatus ps) { + log.debug("LINC-OE ..OF Port Status :", ps); + } + + private void sendHandshakeOFExperimenterPortDescRequest() throws + IOException { + // send multi part message for port description for optical switches + OFCircuitPortsRequest circuitPortsRequest = factory() + .buildCircuitPortsRequest().setXid(getNextTransactionId()) + .build(); + log.warn("LINC-OE : Sending experimented circuit port stats " + + "message " + + "{}", + circuitPortsRequest.toString()); + this.sendHandshakeMessage(circuitPortsRequest); + } + + @Override + /** + * Returns a list of standard (Ethernet) ports. + * + * @return List of ports + */ + public List getPorts() { + return Collections.EMPTY_LIST; + } + + + @Override + public Boolean supportNxRole() { + return false; + } + + @Override + public Device.Type deviceType() { + return Device.Type.ROADM; + } + + /** + * Checks if given port is also part of the regular port desc stats, i.e., is the port a tap port. + * + * @param port given OF port + * @return true if the port is a tap (OCh), false otherwise (OMS port) + */ + private boolean hasPort(OFPort port) { + for (OFPortDescStatsReply reply : this.ports) { + for (OFPortDesc p : reply.getEntries()) { + if (p.getPortNo().equals(port)) { + return true; + } + } + } + + return false; + } + + /** + * Creates an OpenFlow optical port based on the given port and transport type. + * + * @param port OpenFlow optical port + * @param type transport type + * @return OpenFlow optical port + */ + private OFPortOptical createOpticalPort(OFPortOptical port, short type) { + List descList = new ArrayList<>(port.getDesc().size()); + + for (OFPortDescPropOpticalTransport desc : port.getDesc()) { + OFPortDescPropOpticalTransport newDesc = desc.createBuilder() + .setType(desc.getType()) + .setPortSignalType(type) + .setPortType(desc.getPortType()) + .setReserved(desc.getReserved()) + .build(); + descList.add(newDesc); + } + + OFPortOptical newPort = port.createBuilder() + .setConfig(port.getConfig()) + .setDesc(descList) + .setHwAddr(port.getHwAddr()) + .setName(port.getName()) + .setPortNo(port.getPortNo()) + .setState(port.getState()) + .build(); + + return newPort; + } + + /** + * Builds list of OFPortOptical ports based on the multi-part circuit ports reply. + * + * Ensure the optical transport port's signal type is configured correctly. + * + * @param wPorts OF reply with circuit ports + */ + private void createOpticalPortList(OFCircuitPortsReply wPorts) { + opticalPorts = new ArrayList<>(wPorts.getEntries().size()); + + for (OFPortOptical p : wPorts.getEntries()) { + short signalType; + + // FIXME: use constants once loxi has full optical extensions + if (hasPort(p.getPortNo())) { + signalType = 5; // OCH port + } else { + signalType = 2; // OMS port + } + + opticalPorts.add(createOpticalPort(p, signalType)); + } + } + + @Override + public List getPortsOf(PortDescPropertyType type) { + if (!type.equals(PortDescPropertyType.OPTICAL_TRANSPORT)) { + return Collections.EMPTY_LIST; + } + + return opticalPorts; + } + + @Override + public Set getPortTypes() { + return ImmutableSet.of(PortDescPropertyType.OPTICAL_TRANSPORT); + } +} diff --git a/framework/src/onos/drivers/src/main/resources/onos-drivers.xml b/framework/src/onos/drivers/src/main/resources/onos-drivers.xml index af498832..ff5db296 100644 --- a/framework/src/onos/drivers/src/main/resources/onos-drivers.xml +++ b/framework/src/onos/drivers/src/main/resources/onos-drivers.xml @@ -61,7 +61,7 @@ manufacturer="FlowForwarding.org" hwVersion="Unknown" swVersion="LINC-OE OpenFlow Software Switch 1.1"> + impl="org.onosproject.driver.handshaker.OfOpticalSwitchImplLinc13"/> diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/SRLGGraphSearch.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/SRLGGraphSearch.java deleted file mode 100644 index 21f687a3..00000000 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/SRLGGraphSearch.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright 2014 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.onlab.graph; - - -import java.util.Map; -import java.util.List; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; -import java.util.Random; - - -/** - * SRLG Graph Search finds a pair of paths with disjoint risk groups; i.e - * if one path goes through an edge in risk group 1, the other path will go - * through no edges in risk group 1. - */ -public class SRLGGraphSearch> - extends AbstractGraphPathSearch { - - static final int ITERATIONS = 100; - static final int POPSIZE = 50; - - boolean useSuurballe = false; - - static final double INF = 100000000.0; - - int numGroups; - Map riskGrouping; - - Graph orig; - V src, dst; - EdgeWeight weight; - - /** - * Creates an SRLG graph search object with the given number - * of groups and given risk mapping. - * - * @param groups the number of disjoint risk groups - * @param grouping map linking edges to integral group assignments - */ - public SRLGGraphSearch(int groups, Map grouping) { - numGroups = groups; - riskGrouping = grouping; - } - - /** - * Creates an SRLG graph search object from a map, inferring - * the number of groups and creating an integral mapping. - * - * @param grouping map linking edges to object group assignments, - * with same-group status linked to equality - */ - public SRLGGraphSearch(Map grouping) { - if (grouping == null) { - useSuurballe = true; - return; - } - numGroups = 0; - HashMap tmpMap = new HashMap<>(); - riskGrouping = new HashMap<>(); - for (E key: grouping.keySet()) { - Object value = grouping.get(key); - if (!tmpMap.containsKey(value)) { - tmpMap.put(value, numGroups); - numGroups++; - } - riskGrouping.put(key, tmpMap.get(value)); - } - } - - @Override - public Result search(Graph graph, V src, V dst, - EdgeWeight weight, int maxPaths) { - if (maxPaths == ALL_PATHS) { - maxPaths = POPSIZE; - } - if (useSuurballe) { - return new SuurballeGraphSearch().search(graph, src, dst, weight, ALL_PATHS); - } - if (weight == null) { - weight = edge -> 1; - } - checkArguments(graph, src, dst); - orig = graph; - this.src = src; - this.dst = dst; - this.weight = weight; - List best = new GAPopulation() - .runGA(ITERATIONS, POPSIZE, maxPaths, new Subset(new boolean[numGroups])); - Set dpps = new HashSet(); - for (Subset s: best) { - dpps.addAll(s.buildPaths()); - } - Result firstDijkstra = new DijkstraGraphSearch() - .search(orig, src, dst, weight, 1); - return new Result() { - final DefaultResult search = (DefaultResult) firstDijkstra; - - public V src() { - return src; - } - public V dst() { - return dst; - - } - public Set> paths() { - Set> pathsD = new HashSet<>(); - for (DisjointPathPair path: dpps) { - pathsD.add(path); - } - return pathsD; - } - public Map costs() { - return search.costs(); - - } - public Map> parents() { - return search.parents(); - - } - }; - } - - //finds the shortest path in the graph given a subset of edge types to use - private Result findShortestPathFromSubset(boolean[] subset) { - Graph graph = orig; - EdgeWeight modified = new EdgeWeight() { - final boolean[] subsetF = subset; - - @Override - public double weight(E edge) { - if (subsetF[riskGrouping.get(edge)]) { - return weight.weight(edge); - } - return INF; - } - }; - - Result res = new DijkstraGraphSearch().search(graph, src, dst, modified, 1); - return res; - } - /** - * A subset is a type of GA organism that represents a subset of allowed shortest - * paths (and its complement). Its fitness is determined by the sum of the weights - * of the first two shortest paths. - */ - class Subset implements GAOrganism { - - boolean[] subset; - boolean[] not; - Random r = new Random(); - - /** - * Creates a Subset from the given subset array. - * - * @param sub subset array - */ - public Subset(boolean[] sub) { - subset = sub.clone(); - not = new boolean[subset.length]; - for (int i = 0; i < subset.length; i++) { - not[i] = !subset[i]; - } - } - - @Override - public double fitness() { - Set> paths1 = findShortestPathFromSubset(subset).paths(); - Set> paths2 = findShortestPathFromSubset(not).paths(); - if (paths1.size() == 0 || paths2.size() == 0) { - return INF; - } - return paths1.iterator().next().cost() + paths2.iterator().next().cost(); - } - - @Override - public void mutate() { - int turns = r.nextInt((int) Math.sqrt(subset.length)); - while (turns > 0) { - int choose = r.nextInt(subset.length); - subset[choose] = !subset[choose]; - not[choose] = !not[choose]; - turns--; - } - } - - @Override - public GAOrganism crossWith(GAOrganism org) { - if (!(org.getClass().equals(getClass()))) { - return this; - } - Subset other = (Subset) (org); - boolean[] sub = new boolean[subset.length]; - for (int i = 0; i < subset.length; i++) { - sub[i] = subset[i]; - if (r.nextBoolean()) { - sub[i] = other.subset[i]; - } - } - return new Subset(sub); - } - - @Override - public GAOrganism random() { - boolean[] sub = new boolean[subset.length]; - for (int i = 0; i < sub.length; i++) { - sub[i] = r.nextBoolean(); - } - return new Subset(sub); - } - - /** - * Builds the set of disjoint path pairs for a given subset - * using Dijkstra's algorithm on both the subset and complement - * and returning all pairs with one from each set. - * - * @return all shortest disjoint paths given this subset - */ - public Set buildPaths() { - Set dpps = new HashSet<>(); - for (Path path1: findShortestPathFromSubset(subset).paths()) { - if (path1.cost() >= INF) { - continue; - } - for (Path path2: findShortestPathFromSubset(not).paths()) { - if (path2.cost() >= INF) { - continue; - } - DisjointPathPair dpp = new DisjointPathPair<>(path1, path2); - dpps.add(dpp); - } - } - return dpps; - } - } -} diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/SrlgGraphSearch.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/SrlgGraphSearch.java new file mode 100644 index 00000000..fa3d0ddf --- /dev/null +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/SrlgGraphSearch.java @@ -0,0 +1,253 @@ +/* + * Copyright 2014 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.onlab.graph; + + +import java.util.Map; +import java.util.List; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; +import java.util.Random; + + +/** + * SRLG Graph Search finds a pair of paths with disjoint risk groups; i.e + * if one path goes through an edge in risk group 1, the other path will go + * through no edges in risk group 1. + */ +public class SrlgGraphSearch> + extends AbstractGraphPathSearch { + + static final int ITERATIONS = 100; + static final int POPSIZE = 50; + + boolean useSuurballe = false; + + static final double INF = 100000000.0; + + int numGroups; + Map riskGrouping; + + Graph orig; + V src, dst; + EdgeWeight weight; + + /** + * Creates an SRLG graph search object with the given number + * of groups and given risk mapping. + * + * @param groups the number of disjoint risk groups + * @param grouping map linking edges to integral group assignments + */ + public SrlgGraphSearch(int groups, Map grouping) { + numGroups = groups; + riskGrouping = grouping; + } + + /** + * Creates an SRLG graph search object from a map, inferring + * the number of groups and creating an integral mapping. + * + * @param grouping map linking edges to object group assignments, + * with same-group status linked to equality + */ + public SrlgGraphSearch(Map grouping) { + if (grouping == null) { + useSuurballe = true; + return; + } + numGroups = 0; + HashMap tmpMap = new HashMap<>(); + riskGrouping = new HashMap<>(); + for (E key: grouping.keySet()) { + Object value = grouping.get(key); + if (!tmpMap.containsKey(value)) { + tmpMap.put(value, numGroups); + numGroups++; + } + riskGrouping.put(key, tmpMap.get(value)); + } + } + + @Override + public Result search(Graph graph, V src, V dst, + EdgeWeight weight, int maxPaths) { + if (maxPaths == ALL_PATHS) { + maxPaths = POPSIZE; + } + if (useSuurballe) { + return new SuurballeGraphSearch().search(graph, src, dst, weight, ALL_PATHS); + } + if (weight == null) { + weight = edge -> 1; + } + checkArguments(graph, src, dst); + orig = graph; + this.src = src; + this.dst = dst; + this.weight = weight; + List best = new GAPopulation() + .runGA(ITERATIONS, POPSIZE, maxPaths, new Subset(new boolean[numGroups])); + Set dpps = new HashSet(); + for (Subset s: best) { + dpps.addAll(s.buildPaths()); + } + Result firstDijkstra = new DijkstraGraphSearch() + .search(orig, src, dst, weight, 1); + return new Result() { + final DefaultResult search = (DefaultResult) firstDijkstra; + + public V src() { + return src; + } + public V dst() { + return dst; + + } + public Set> paths() { + Set> pathsD = new HashSet<>(); + for (DisjointPathPair path: dpps) { + pathsD.add(path); + } + return pathsD; + } + public Map costs() { + return search.costs(); + + } + public Map> parents() { + return search.parents(); + + } + }; + } + + //finds the shortest path in the graph given a subset of edge types to use + private Result findShortestPathFromSubset(boolean[] subset) { + Graph graph = orig; + EdgeWeight modified = new EdgeWeight() { + final boolean[] subsetF = subset; + + @Override + public double weight(E edge) { + if (subsetF[riskGrouping.get(edge)]) { + return weight.weight(edge); + } + return INF; + } + }; + + Result res = new DijkstraGraphSearch().search(graph, src, dst, modified, 1); + return res; + } + /** + * A subset is a type of GA organism that represents a subset of allowed shortest + * paths (and its complement). Its fitness is determined by the sum of the weights + * of the first two shortest paths. + */ + class Subset implements GAOrganism { + + boolean[] subset; + boolean[] not; + Random r = new Random(); + + /** + * Creates a Subset from the given subset array. + * + * @param sub subset array + */ + public Subset(boolean[] sub) { + subset = sub.clone(); + not = new boolean[subset.length]; + for (int i = 0; i < subset.length; i++) { + not[i] = !subset[i]; + } + } + + @Override + public double fitness() { + Set> paths1 = findShortestPathFromSubset(subset).paths(); + Set> paths2 = findShortestPathFromSubset(not).paths(); + if (paths1.size() == 0 || paths2.size() == 0) { + return INF; + } + return paths1.iterator().next().cost() + paths2.iterator().next().cost(); + } + + @Override + public void mutate() { + int turns = r.nextInt((int) Math.sqrt(subset.length)); + while (turns > 0) { + int choose = r.nextInt(subset.length); + subset[choose] = !subset[choose]; + not[choose] = !not[choose]; + turns--; + } + } + + @Override + public GAOrganism crossWith(GAOrganism org) { + if (!(org.getClass().equals(getClass()))) { + return this; + } + Subset other = (Subset) (org); + boolean[] sub = new boolean[subset.length]; + for (int i = 0; i < subset.length; i++) { + sub[i] = subset[i]; + if (r.nextBoolean()) { + sub[i] = other.subset[i]; + } + } + return new Subset(sub); + } + + @Override + public GAOrganism random() { + boolean[] sub = new boolean[subset.length]; + for (int i = 0; i < sub.length; i++) { + sub[i] = r.nextBoolean(); + } + return new Subset(sub); + } + + /** + * Builds the set of disjoint path pairs for a given subset + * using Dijkstra's algorithm on both the subset and complement + * and returning all pairs with one from each set. + * + * @return all shortest disjoint paths given this subset + */ + public Set buildPaths() { + Set dpps = new HashSet<>(); + for (Path path1: findShortestPathFromSubset(subset).paths()) { + if (path1.cost() >= INF) { + continue; + } + for (Path path2: findShortestPathFromSubset(not).paths()) { + if (path2.cost() >= INF) { + continue; + } + DisjointPathPair dpp = new DisjointPathPair<>(path1, path2); + dpps.add(dpp); + } + } + return dpps; + } + } +} diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/TarjanGraphSearch.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/TarjanGraphSearch.java index 5bf305e6..1c436d94 100644 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/TarjanGraphSearch.java +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/TarjanGraphSearch.java @@ -42,8 +42,8 @@ public class TarjanGraphSearch> *

*/ @Override - public SCCResult search(Graph graph, EdgeWeight weight) { - SCCResult result = new SCCResult<>(graph); + public SccResult search(Graph graph, EdgeWeight weight) { + SccResult result = new SccResult<>(graph); for (V vertex : graph.getVertexes()) { VertexData data = result.data(vertex); if (data == null) { @@ -64,7 +64,7 @@ public class TarjanGraphSearch> */ private VertexData connect(Graph graph, V vertex, EdgeWeight weight, - SCCResult result) { + SccResult result) { VertexData data = result.addData(vertex); // Scan through all egress edges of the current vertex. @@ -99,7 +99,7 @@ public class TarjanGraphSearch> /** * Graph search result augmented with SCC vertexData. */ - public static final class SCCResult> + public static final class SccResult> implements Result { private final Graph graph; @@ -110,7 +110,7 @@ public class TarjanGraphSearch> private final Map> vertexData = new HashMap<>(); private final List> visited = new ArrayList<>(); - private SCCResult(Graph graph) { + private SccResult(Graph graph) { this.graph = graph; } @@ -189,7 +189,7 @@ public class TarjanGraphSearch> return Collections.unmodifiableSet(edges); } - public SCCResult build() { + public SccResult build() { clusterVertexes = Collections.unmodifiableList(clusterVertexes); clusterEdges = Collections.unmodifiableList(clusterEdges); return this; diff --git a/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/SRLGGraphSearchTest.java b/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/SRLGGraphSearchTest.java deleted file mode 100644 index 8bfd270c..00000000 --- a/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/SRLGGraphSearchTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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.onlab.graph; - -import org.junit.Test; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static com.google.common.collect.ImmutableSet.of; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.onlab.graph.GraphPathSearch.ALL_PATHS; - -/** - * Test of the Suurballe backup path algorithm. - */ -public class SRLGGraphSearchTest extends BreadthFirstSearchTest { - - @Override - protected AbstractGraphPathSearch graphSearch() { - return new SRLGGraphSearch<>(null); - } - - public void setDefaultWeights() { - weight = null; - } - - @Override - public void defaultGraphTest() { - } - - @Override - public void defaultHopCountWeight() { - } - - @Test - public void onePathPair() { - setDefaultWeights(); - TestEdge aB = new TestEdge(A, B, 1); - TestEdge bC = new TestEdge(B, C, 1); - TestEdge aD = new TestEdge(A, D, 1); - TestEdge dC = new TestEdge(D, C, 1); - Graph graph = new AdjacencyListsGraph<>(of(A, B, C, D), - of(aB, bC, aD, dC)); - Map riskProfile = new HashMap<>(); - riskProfile.put(aB, 0); - riskProfile.put(bC, 0); - riskProfile.put(aD, 1); - riskProfile.put(dC, 1); - SRLGGraphSearch search = new SRLGGraphSearch<>(2, riskProfile); - Set> paths = search.search(graph, A, C, weight, ALL_PATHS).paths(); - System.out.println("\n\n\n" + paths + "\n\n\n"); - assertEquals("one disjoint path pair found", 1, paths.size()); - checkIsDisjoint(paths.iterator().next(), riskProfile); - } - - public void checkIsDisjoint(Path p, Map risks) { - assertTrue("The path is not a DisjointPathPair", (p instanceof DisjointPathPair)); - DisjointPathPair q = (DisjointPathPair) p; - Set p1Risks = new HashSet<>(); - for (TestEdge e : q.edges()) { - p1Risks.add(risks.get(e)); - } - if (!q.hasBackup()) { - return; - } - Path pq = q.secondary(); - for (TestEdge e: pq.edges()) { - assertTrue("The paths are not disjoint", !p1Risks.contains(risks.get(e))); - } - } - - @Test - public void complexGraphTest() { - setDefaultWeights(); - TestEdge aB = new TestEdge(A, B, 1); - TestEdge bC = new TestEdge(B, C, 1); - TestEdge aD = new TestEdge(A, D, 1); - TestEdge dC = new TestEdge(D, C, 1); - TestEdge cE = new TestEdge(C, E, 1); - TestEdge bE = new TestEdge(B, E, 1); - Graph graph = new AdjacencyListsGraph<>(of(A, B, C, D, E), - of(aB, bC, aD, dC, cE, bE)); - Map riskProfile = new HashMap<>(); - riskProfile.put(aB, 0); - riskProfile.put(bC, 0); - riskProfile.put(aD, 1); - riskProfile.put(dC, 1); - riskProfile.put(cE, 2); - riskProfile.put(bE, 3); - SRLGGraphSearch search = new SRLGGraphSearch<>(4, riskProfile); - search.search(graph, A, E, weight, ALL_PATHS).paths(); - } - - @Test - public void multiplePathGraphTest() { - setDefaultWeights(); - TestEdge aB = new TestEdge(A, B, 1); - TestEdge bE = new TestEdge(B, E, 1); - TestEdge aD = new TestEdge(A, D, 1); - TestEdge dE = new TestEdge(D, E, 1); - TestEdge aC = new TestEdge(A, C, 1); - TestEdge cE = new TestEdge(C, E, 1); - Graph graph = new AdjacencyListsGraph<>(of(A, B, C, D, E), - of(aB, bE, aD, dE, aC, cE)); - Map riskProfile = new HashMap<>(); - riskProfile.put(aB, 0); - riskProfile.put(bE, 1); - riskProfile.put(aD, 2); - riskProfile.put(dE, 3); - riskProfile.put(aC, 4); - riskProfile.put(cE, 5); - SRLGGraphSearch search = new SRLGGraphSearch<>(6, riskProfile); - Set> paths = search.search(graph, A, E, weight, ALL_PATHS).paths(); - assertTrue("> one disjoint path pair found", paths.size() >= 1); - checkIsDisjoint(paths.iterator().next(), riskProfile); - } - - @Test - public void onePath() { - setDefaultWeights(); - TestEdge aB = new TestEdge(A, B, 1); - TestEdge bC = new TestEdge(B, C, 1); - TestEdge aD = new TestEdge(A, D, 1); - TestEdge dC = new TestEdge(D, C, 1); - Graph graph = new AdjacencyListsGraph<>(of(A, B, C, D), - of(aB, bC, aD, dC)); - Map riskProfile = new HashMap<>(); - riskProfile.put(aB, 0); - riskProfile.put(bC, 0); - riskProfile.put(aD, 1); - riskProfile.put(dC, 0); - SRLGGraphSearch search = new SRLGGraphSearch<>(2, riskProfile); - Set> paths = search.search(graph, A, C, weight, ALL_PATHS).paths(); - System.out.println(paths); - assertTrue("no disjoint path pairs found", paths.size() == 0); - } - - @Test - public void noPath() { - setDefaultWeights(); - TestEdge aB = new TestEdge(A, B, 1); - TestEdge bC = new TestEdge(B, C, 1); - TestEdge aD = new TestEdge(A, D, 1); - TestEdge dC = new TestEdge(D, C, 1); - Graph graph = new AdjacencyListsGraph<>(of(A, B, C, D, E), - of(aB, bC, aD, dC)); - Map riskProfile = new HashMap<>(); - riskProfile.put(aB, 0); - riskProfile.put(bC, 0); - riskProfile.put(aD, 1); - riskProfile.put(dC, 0); - SRLGGraphSearch search = new SRLGGraphSearch<>(2, riskProfile); - Set> paths = search.search(graph, A, E, weight, ALL_PATHS).paths(); - assertTrue("no disjoint path pairs found", paths.size() == 0); - } -} diff --git a/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/SrlgGraphSearchTest.java b/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/SrlgGraphSearchTest.java new file mode 100644 index 00000000..26d50364 --- /dev/null +++ b/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/SrlgGraphSearchTest.java @@ -0,0 +1,174 @@ +/* + * 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.onlab.graph; + +import org.junit.Test; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static com.google.common.collect.ImmutableSet.of; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.onlab.graph.GraphPathSearch.ALL_PATHS; + +/** + * Test of the Suurballe backup path algorithm. + */ +public class SrlgGraphSearchTest extends BreadthFirstSearchTest { + + @Override + protected AbstractGraphPathSearch graphSearch() { + return new SrlgGraphSearch<>(null); + } + + public void setDefaultWeights() { + weight = null; + } + + @Override + public void defaultGraphTest() { + } + + @Override + public void defaultHopCountWeight() { + } + + @Test + public void onePathPair() { + setDefaultWeights(); + TestEdge aB = new TestEdge(A, B, 1); + TestEdge bC = new TestEdge(B, C, 1); + TestEdge aD = new TestEdge(A, D, 1); + TestEdge dC = new TestEdge(D, C, 1); + Graph graph = new AdjacencyListsGraph<>(of(A, B, C, D), + of(aB, bC, aD, dC)); + Map riskProfile = new HashMap<>(); + riskProfile.put(aB, 0); + riskProfile.put(bC, 0); + riskProfile.put(aD, 1); + riskProfile.put(dC, 1); + SrlgGraphSearch search = new SrlgGraphSearch<>(2, riskProfile); + Set> paths = search.search(graph, A, C, weight, ALL_PATHS).paths(); + System.out.println("\n\n\n" + paths + "\n\n\n"); + assertEquals("one disjoint path pair found", 1, paths.size()); + checkIsDisjoint(paths.iterator().next(), riskProfile); + } + + public void checkIsDisjoint(Path p, Map risks) { + assertTrue("The path is not a DisjointPathPair", (p instanceof DisjointPathPair)); + DisjointPathPair q = (DisjointPathPair) p; + Set p1Risks = new HashSet<>(); + for (TestEdge e : q.edges()) { + p1Risks.add(risks.get(e)); + } + if (!q.hasBackup()) { + return; + } + Path pq = q.secondary(); + for (TestEdge e: pq.edges()) { + assertTrue("The paths are not disjoint", !p1Risks.contains(risks.get(e))); + } + } + + @Test + public void complexGraphTest() { + setDefaultWeights(); + TestEdge aB = new TestEdge(A, B, 1); + TestEdge bC = new TestEdge(B, C, 1); + TestEdge aD = new TestEdge(A, D, 1); + TestEdge dC = new TestEdge(D, C, 1); + TestEdge cE = new TestEdge(C, E, 1); + TestEdge bE = new TestEdge(B, E, 1); + Graph graph = new AdjacencyListsGraph<>(of(A, B, C, D, E), + of(aB, bC, aD, dC, cE, bE)); + Map riskProfile = new HashMap<>(); + riskProfile.put(aB, 0); + riskProfile.put(bC, 0); + riskProfile.put(aD, 1); + riskProfile.put(dC, 1); + riskProfile.put(cE, 2); + riskProfile.put(bE, 3); + SrlgGraphSearch search = new SrlgGraphSearch<>(4, riskProfile); + search.search(graph, A, E, weight, ALL_PATHS).paths(); + } + + @Test + public void multiplePathGraphTest() { + setDefaultWeights(); + TestEdge aB = new TestEdge(A, B, 1); + TestEdge bE = new TestEdge(B, E, 1); + TestEdge aD = new TestEdge(A, D, 1); + TestEdge dE = new TestEdge(D, E, 1); + TestEdge aC = new TestEdge(A, C, 1); + TestEdge cE = new TestEdge(C, E, 1); + Graph graph = new AdjacencyListsGraph<>(of(A, B, C, D, E), + of(aB, bE, aD, dE, aC, cE)); + Map riskProfile = new HashMap<>(); + riskProfile.put(aB, 0); + riskProfile.put(bE, 1); + riskProfile.put(aD, 2); + riskProfile.put(dE, 3); + riskProfile.put(aC, 4); + riskProfile.put(cE, 5); + SrlgGraphSearch search = new SrlgGraphSearch<>(6, riskProfile); + Set> paths = search.search(graph, A, E, weight, ALL_PATHS).paths(); + assertTrue("> one disjoint path pair found", paths.size() >= 1); + checkIsDisjoint(paths.iterator().next(), riskProfile); + } + + @Test + public void onePath() { + setDefaultWeights(); + TestEdge aB = new TestEdge(A, B, 1); + TestEdge bC = new TestEdge(B, C, 1); + TestEdge aD = new TestEdge(A, D, 1); + TestEdge dC = new TestEdge(D, C, 1); + Graph graph = new AdjacencyListsGraph<>(of(A, B, C, D), + of(aB, bC, aD, dC)); + Map riskProfile = new HashMap<>(); + riskProfile.put(aB, 0); + riskProfile.put(bC, 0); + riskProfile.put(aD, 1); + riskProfile.put(dC, 0); + SrlgGraphSearch search = new SrlgGraphSearch<>(2, riskProfile); + Set> paths = search.search(graph, A, C, weight, ALL_PATHS).paths(); + System.out.println(paths); + assertTrue("no disjoint path pairs found", paths.size() == 0); + } + + @Test + public void noPath() { + setDefaultWeights(); + TestEdge aB = new TestEdge(A, B, 1); + TestEdge bC = new TestEdge(B, C, 1); + TestEdge aD = new TestEdge(A, D, 1); + TestEdge dC = new TestEdge(D, C, 1); + Graph graph = new AdjacencyListsGraph<>(of(A, B, C, D, E), + of(aB, bC, aD, dC)); + Map riskProfile = new HashMap<>(); + riskProfile.put(aB, 0); + riskProfile.put(bC, 0); + riskProfile.put(aD, 1); + riskProfile.put(dC, 0); + SrlgGraphSearch search = new SrlgGraphSearch<>(2, riskProfile); + Set> paths = search.search(graph, A, E, weight, ALL_PATHS).paths(); + assertTrue("no disjoint path pairs found", paths.size() == 0); + } +} diff --git a/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/TarjanGraphSearchTest.java b/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/TarjanGraphSearchTest.java index 624c5781..40f90513 100644 --- a/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/TarjanGraphSearchTest.java +++ b/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/TarjanGraphSearchTest.java @@ -19,20 +19,20 @@ import org.junit.Test; import static com.google.common.collect.ImmutableSet.of; import static org.junit.Assert.assertEquals; -import static org.onlab.graph.TarjanGraphSearch.SCCResult; +import static org.onlab.graph.TarjanGraphSearch.SccResult; /** * Tarjan graph search tests. */ public class TarjanGraphSearchTest extends GraphTest { - private void validate(SCCResult result, int cc) { + private void validate(SccResult result, int cc) { System.out.println("Cluster count: " + result.clusterVertexes().size()); System.out.println("Clusters: " + result.clusterVertexes()); assertEquals("incorrect cluster count", cc, result.clusterCount()); } - private void validate(SCCResult result, + private void validate(SccResult result, int i, int vc, int ec) { assertEquals("incorrect cluster count", vc, result.clusterVertexes().get(i).size()); assertEquals("incorrect edge count", ec, result.clusterEdges().get(i).size()); @@ -42,7 +42,7 @@ public class TarjanGraphSearchTest extends GraphTest { public void basic() { graph = new AdjacencyListsGraph<>(vertexes(), edges()); TarjanGraphSearch gs = new TarjanGraphSearch<>(); - SCCResult result = gs.search(graph, null); + SccResult result = gs.search(graph, null); validate(result, 6); } @@ -59,7 +59,7 @@ public class TarjanGraphSearchTest extends GraphTest { new TestEdge(H, A, 1))); TarjanGraphSearch gs = new TarjanGraphSearch<>(); - SCCResult result = gs.search(graph, null); + SccResult result = gs.search(graph, null); validate(result, 1); validate(result, 0, 8, 8); } @@ -76,7 +76,7 @@ public class TarjanGraphSearchTest extends GraphTest { new TestEdge(G, H, 1), new TestEdge(H, E, 1))); TarjanGraphSearch gs = new TarjanGraphSearch<>(); - SCCResult result = gs.search(graph, null); + SccResult result = gs.search(graph, null); validate(result, 2); validate(result, 0, 4, 4); validate(result, 1, 4, 4); @@ -95,7 +95,7 @@ public class TarjanGraphSearchTest extends GraphTest { new TestEdge(H, E, 1), new TestEdge(B, E, 1))); TarjanGraphSearch gs = new TarjanGraphSearch<>(); - SCCResult result = gs.search(graph, null); + SccResult result = gs.search(graph, null); validate(result, 2); validate(result, 0, 4, 4); validate(result, 1, 4, 4); @@ -116,7 +116,7 @@ public class TarjanGraphSearchTest extends GraphTest { new TestEdge(E, B, -1))); TarjanGraphSearch gs = new TarjanGraphSearch<>(); - SCCResult result = gs.search(graph, weight); + SccResult result = gs.search(graph, weight); validate(result, 2); validate(result, 0, 4, 4); validate(result, 1, 4, 4); diff --git a/framework/src/onos/utils/misc/src/test/java/org/onlab/util/HexStringTest.java b/framework/src/onos/utils/misc/src/test/java/org/onlab/util/HexStringTest.java index e04e29a2..f4aadd15 100644 --- a/framework/src/onos/utils/misc/src/test/java/org/onlab/util/HexStringTest.java +++ b/framework/src/onos/utils/misc/src/test/java/org/onlab/util/HexStringTest.java @@ -47,7 +47,7 @@ public class HexStringTest { } @Test - public void testToLongMSB() { + public void testToLongMsb() { String dpidStr = "ca:7c:5e:d1:64:7a:95:9b"; long valid = -3856102927509056101L; long testLong = HexString.toLong(dpidStr); diff --git a/framework/src/onos/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java b/framework/src/onos/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java index 8c759d14..1cd7ca7b 100644 --- a/framework/src/onos/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java +++ b/framework/src/onos/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java @@ -15,6 +15,10 @@ */ package org.onlab.netty; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.PooledByteBufAllocator; @@ -34,11 +38,20 @@ import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; +import org.apache.commons.pool.KeyedPoolableObjectFactory; +import org.apache.commons.pool.impl.GenericKeyedObjectPool; +import org.onosproject.store.cluster.messaging.Endpoint; +import org.onosproject.store.cluster.messaging.MessagingService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; +import javax.net.ssl.TrustManagerFactory; import java.io.FileInputStream; import java.io.IOException; import java.security.KeyStore; - import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; @@ -51,23 +64,6 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; import java.util.function.Function; -import org.apache.commons.pool.KeyedPoolableObjectFactory; -import org.apache.commons.pool.impl.GenericKeyedObjectPool; -import org.onosproject.store.cluster.messaging.Endpoint; -import org.onosproject.store.cluster.messaging.MessagingService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; - -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; -import javax.net.ssl.TrustManagerFactory; - /** * Implementation of MessagingService based on Netty framework. */ @@ -102,7 +98,7 @@ public class NettyMessaging implements MessagingService { private Class clientChannelClass; protected static final boolean TLS_DISABLED = false; - protected boolean enableNettyTLS = TLS_DISABLED; + protected boolean enableNettyTls = TLS_DISABLED; protected String ksLocation; protected String tsLocation; @@ -259,8 +255,8 @@ public class NettyMessaging implements MessagingService { b.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); b.group(serverGroup, clientGroup); b.channel(serverChannelClass); - if (enableNettyTLS) { - b.childHandler(new SSLServerCommunicationChannelInitializer()); + if (enableNettyTls) { + b.childHandler(new SslServerCommunicationChannelInitializer()); } else { b.childHandler(new OnosCommunicationChannelInitializer()); } @@ -303,8 +299,8 @@ public class NettyMessaging implements MessagingService { // http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0 bootstrap.channel(clientChannelClass); bootstrap.option(ChannelOption.SO_KEEPALIVE, true); - if (enableNettyTLS) { - bootstrap.handler(new SSLClientCommunicationChannelInitializer()); + if (enableNettyTls) { + bootstrap.handler(new SslClientCommunicationChannelInitializer()); } else { bootstrap.handler(new OnosCommunicationChannelInitializer()); } @@ -325,7 +321,7 @@ public class NettyMessaging implements MessagingService { } } - private class SSLServerCommunicationChannelInitializer extends ChannelInitializer { + private class SslServerCommunicationChannelInitializer extends ChannelInitializer { private final ChannelHandler dispatcher = new InboundMessageDispatcher(); private final ChannelHandler encoder = new MessageEncoder(); @@ -345,15 +341,15 @@ public class NettyMessaging implements MessagingService { SSLContext serverContext = SSLContext.getInstance("TLS"); serverContext.init(kmf.getKeyManagers(), tmFactory.getTrustManagers(), null); - SSLEngine serverSSLEngine = serverContext.createSSLEngine(); + SSLEngine serverSslEngine = serverContext.createSSLEngine(); - serverSSLEngine.setNeedClientAuth(true); - serverSSLEngine.setUseClientMode(false); - serverSSLEngine.setEnabledProtocols(serverSSLEngine.getSupportedProtocols()); - serverSSLEngine.setEnabledCipherSuites(serverSSLEngine.getSupportedCipherSuites()); - serverSSLEngine.setEnableSessionCreation(true); + serverSslEngine.setNeedClientAuth(true); + serverSslEngine.setUseClientMode(false); + serverSslEngine.setEnabledProtocols(serverSslEngine.getSupportedProtocols()); + serverSslEngine.setEnabledCipherSuites(serverSslEngine.getSupportedCipherSuites()); + serverSslEngine.setEnableSessionCreation(true); - channel.pipeline().addLast("ssl", new io.netty.handler.ssl.SslHandler(serverSSLEngine)) + channel.pipeline().addLast("ssl", new io.netty.handler.ssl.SslHandler(serverSslEngine)) .addLast("encoder", encoder) .addLast("decoder", new MessageDecoder()) .addLast("handler", dispatcher); @@ -361,7 +357,7 @@ public class NettyMessaging implements MessagingService { } - private class SSLClientCommunicationChannelInitializer extends ChannelInitializer { + private class SslClientCommunicationChannelInitializer extends ChannelInitializer { private final ChannelHandler dispatcher = new InboundMessageDispatcher(); private final ChannelHandler encoder = new MessageEncoder(); @@ -381,14 +377,14 @@ public class NettyMessaging implements MessagingService { SSLContext clientContext = SSLContext.getInstance("TLS"); clientContext.init(kmf.getKeyManagers(), tmFactory.getTrustManagers(), null); - SSLEngine clientSSLEngine = clientContext.createSSLEngine(); + SSLEngine clientSslEngine = clientContext.createSSLEngine(); - clientSSLEngine.setUseClientMode(true); - clientSSLEngine.setEnabledProtocols(clientSSLEngine.getSupportedProtocols()); - clientSSLEngine.setEnabledCipherSuites(clientSSLEngine.getSupportedCipherSuites()); - clientSSLEngine.setEnableSessionCreation(true); + clientSslEngine.setUseClientMode(true); + clientSslEngine.setEnabledProtocols(clientSslEngine.getSupportedProtocols()); + clientSslEngine.setEnabledCipherSuites(clientSslEngine.getSupportedCipherSuites()); + clientSslEngine.setEnableSessionCreation(true); - channel.pipeline().addLast("ssl", new io.netty.handler.ssl.SslHandler(clientSSLEngine)) + channel.pipeline().addLast("ssl", new io.netty.handler.ssl.SslHandler(clientSslEngine)) .addLast("encoder", encoder) .addLast("decoder", new MessageDecoder()) .addLast("handler", dispatcher); diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java index dbd80cca..06c73d39 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java @@ -327,7 +327,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { String value = annotations.value("optical.waves").trim(); try { int numChls = Integer.parseInt(value); - updateOMSPorts(numChls, src, dst); + updateOmsPorts(numChls, src, dst); } catch (NumberFormatException e) { log.warn("Invalid channel ({}), can't configure port(s)", value); return; @@ -373,7 +373,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { } } - private void updateOMSPorts(int numChls, ConnectPoint srcCp, ConnectPoint dstCp) { + private void updateOmsPorts(int numChls, ConnectPoint srcCp, ConnectPoint dstCp) { // round down to largest slot that allows numChl channels to fit into C band range ChannelSpacing chl = null; Frequency perChl = TOTAL.floorDivision(numChls); -- cgit 1.2.3-korg