diff options
author | Ashlee Young <ashlee@onosfw.com> | 2015-09-22 12:49:09 -0700 |
---|---|---|
committer | Ashlee Young <ashlee@onosfw.com> | 2015-09-22 12:49:09 -0700 |
commit | 81391595dca425ae58e2294898f09f11d9a32dbc (patch) | |
tree | f5d65c39a732150b2b29daa8de98a35d1236d3fb /framework/src/onos/core | |
parent | 0aa37e73dcb3a55b8d889b0c32ff74055551b1f3 (diff) |
bringing src to commit tag 65d551b50e782b0c1ea76c1a9ed1c5a801a5a7e4
Change-Id: Ib2da78962eaef856f418636c31b0f5c84286244f
Diffstat (limited to 'framework/src/onos/core')
177 files changed, 1539 insertions, 1398 deletions
diff --git a/framework/src/onos/core/api/pom.xml b/framework/src/onos/core/api/pom.xml index 7cfb4acc..23a051c4 100644 --- a/framework/src/onos/core/api/pom.xml +++ b/framework/src/onos/core/api/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onosproject</groupId> <artifactId>onos-core</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterDefinitionService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterDefinitionService.java index dbe5f71c..1ee78b15 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterDefinitionService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterDefinitionService.java @@ -1,3 +1,18 @@ +/* + * 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.cluster; import java.util.Set; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java index 3cfc9367..2f74ae69 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java @@ -23,7 +23,7 @@ import org.onlab.packet.IpAddress; public interface ControllerNode { /** Represents the operational state of the instance. */ - public enum State { + enum State { /** * Signifies that the instance is active and operating normally. */ diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java index 3dfc6b26..303ad395 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java @@ -27,12 +27,12 @@ public interface CoreService { /** * Name of the core "application". */ - static final String CORE_APP_NAME = "org.onosproject.core"; + String CORE_APP_NAME = "org.onosproject.core"; /** * Identifier of the core "provider". */ - static final ProviderId CORE_PROVIDER_ID = new ProviderId("core", CORE_APP_NAME); + ProviderId CORE_PROVIDER_ID = new ProviderId("core", CORE_APP_NAME); /** * Returns the product version. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java index b5be0944..8de05439 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java @@ -32,7 +32,7 @@ public interface MetricsHelper { * * @return MetricService instance */ - abstract MetricsService metricsService(); + MetricsService metricsService(); /** diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/Device.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/Device.java index d9001825..ffbf7f96 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/Device.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/Device.java @@ -25,7 +25,7 @@ public interface Device extends Element { /** * Coarse classification of the type of the infrastructure device. */ - public enum Type { + enum Type { SWITCH, ROUTER, ROADM, OTN, ROADM_OTN, FIREWALL, BALANCER, IPS, IDS, CONTROLLER, VIRTUAL, FIBER_SWITCH, MICROWAVE, OTHER } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/IpElementId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/IpElementId.java index 9e19b624..aba8ae47 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/IpElementId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/IpElementId.java @@ -1,3 +1,18 @@ +/* + * 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.net; import java.util.Objects; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java index b6068ee7..e962110c 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java @@ -17,6 +17,7 @@ package org.onosproject.net.config.basics; import org.onosproject.net.Link; import org.onosproject.net.LinkKey; +import com.fasterxml.jackson.databind.JsonNode; import java.time.Duration; @@ -28,6 +29,7 @@ public class BasicLinkConfig extends AllowedEntityConfig<LinkKey> { public static final String TYPE = "type"; public static final String LATENCY = "latency"; public static final String BANDWIDTH = "bandwidth"; + public static final String IS_DURABLE = "durable"; /** * Returns the link type. @@ -87,4 +89,26 @@ public class BasicLinkConfig extends AllowedEntityConfig<LinkKey> { return (BasicLinkConfig) setOrClear(BANDWIDTH, bandwidth); } + /** + * Returns if link is durable in the network model or not. + * + * @return true for durable, false otherwise + */ + public Boolean isDurable() { + JsonNode res = object.path(IS_DURABLE); + if (res.isMissingNode()) { + return null; + } + return res.asBoolean(); + } + + /** + * Sets durability for this link. + * + * @param isDurable true for durable, false otherwise + * @return this BasicLinkConfig + */ + public BasicLinkConfig isDurable(Boolean isDurable) { + return (BasicLinkConfig) setOrClear(IS_DURABLE, isDurable); + } } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/OpticalPortConfig.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/OpticalPortConfig.java index b06c4228..dfb494d6 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/OpticalPortConfig.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/OpticalPortConfig.java @@ -1,3 +1,18 @@ +/* + * 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.net.config.basics; import java.util.Optional; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java index 44a4d364..5492fa98 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java @@ -291,6 +291,7 @@ public class DefaultFlowRule implements FlowRule { public static final class Builder implements FlowRule.Builder { private FlowId flowId; + private ApplicationId appId; private Integer priority; private DeviceId deviceId; private Integer tableId = 0; @@ -307,7 +308,7 @@ public class DefaultFlowRule implements FlowRule { @Override public FlowRule.Builder fromApp(ApplicationId appId) { - this.flowId = computeFlowId(appId); + this.appId = appId; return this; } @@ -357,16 +358,22 @@ public class DefaultFlowRule implements FlowRule { @Override public FlowRule build() { - checkNotNull(flowId != null, "Either an application" + + checkArgument(flowId != null || appId != null, "Either an application" + " id or a cookie must be supplied"); - checkNotNull(selector != null, "Traffic selector cannot be null"); - checkNotNull(timeout != null || permanent != null, "Must either have " + + checkNotNull(selector, "Traffic selector cannot be null"); + checkArgument(timeout != null || permanent != null, "Must either have " + "a timeout or be permanent"); - checkNotNull(deviceId != null, "Must refer to a device"); - checkNotNull(priority != null, "Priority cannot be null"); + checkNotNull(deviceId, "Must refer to a device"); + checkNotNull(priority, "Priority cannot be null"); checkArgument(priority >= MIN_PRIORITY, "Priority cannot be less than " + MIN_PRIORITY); + // Computing a flow ID based on appId takes precedence over setting + // the flow ID directly + if (appId != null) { + flowId = computeFlowId(appId); + } + return new DefaultFlowRule(deviceId, selector, treatment, priority, flowId, permanent, timeout, tableId); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java index e446a9fe..a487cbc4 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java @@ -25,8 +25,8 @@ import org.onosproject.net.DeviceId; */ public interface FlowRule { - static final int MAX_TIMEOUT = 60; - static final int MIN_PRIORITY = 0; + int MAX_TIMEOUT = 60; + int MIN_PRIORITY = 0; /** * The FlowRule type is used to determine in which table the flow rule needs @@ -36,7 +36,7 @@ public interface FlowRule { * @deprecated in Cardinal Release */ @Deprecated - static enum Type { + enum Type { /* * Default type - used in flow rule for single table switch NOTE: this * setting should not be used as Table 0 in a multi-table pipeline diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java index 8d36be49..d4d2d9ec 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java @@ -1,3 +1,18 @@ +/* + * 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.net.flow; import static com.google.common.base.MoreObjects.toStringHelper; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java index e2971158..d4f959c3 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java @@ -32,7 +32,7 @@ public interface FlowRuleService /** * The topic used for obtaining globally unique ids. */ - static String FLOW_OP_TOPIC = "flow-ops-ids"; + String FLOW_OP_TOPIC = "flow-ops-ids"; /** * Returns the number of flow rules in the system. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java index f2de9a0f..534f6b9e 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java @@ -24,7 +24,6 @@ import org.onlab.packet.MplsLabel; import org.onlab.packet.TpPort; import org.onlab.packet.VlanId; import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.DefaultTrafficSelector.Builder; import org.onosproject.net.flow.criteria.Criterion; /** diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java index 1ace8931..c8b6690d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java @@ -1,3 +1,18 @@ +/* + * 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.net.flow.criteria; import static com.google.common.base.MoreObjects.toStringHelper; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java index 090c298c..6ac7a7a2 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java @@ -26,9 +26,9 @@ import java.util.Optional; @Beta public interface Objective { - static final boolean DEFAULT_PERMANENT = true; - static final int DEFAULT_TIMEOUT = 0; - static final int DEFAULT_PRIORITY = 32768; + boolean DEFAULT_PERMANENT = true; + int DEFAULT_TIMEOUT = 0; + int DEFAULT_PRIORITY = 32768; /** * Type of operation. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostAdminService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostAdminService.java index d620fedb..8676e46a 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostAdminService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostAdminService.java @@ -15,7 +15,6 @@ */ package org.onosproject.net.host; -import org.onosproject.net.ConnectPoint; import org.onosproject.net.HostId; /** @@ -30,37 +29,4 @@ public interface HostAdminService extends HostService { */ void removeHost(HostId hostId); - /** - * Binds IP and MAC addresses to the given connection point. - * <p> - * The addresses are added to the set of addresses already bound to the - * connection point. - * - * @param addresses address object containing addresses to add and the port - * to add them to - * @deprecated in Drake release: address info now stored in InterfaceService - */ - @Deprecated - void bindAddressesToPort(PortAddresses addresses); - - /** - * Removes the addresses contained in the given PortAddresses object from - * the set of addresses bound to the port. - * - * @param portAddresses set of addresses to remove and port to remove them - * from - * @deprecated in Drake release: address info now stored in InterfaceService - */ - @Deprecated - void unbindAddressesFromPort(PortAddresses portAddresses); - - /** - * Removes all address information for the given connection point. - * - * @param connectPoint the connection point to remove address information - * @deprecated in Drake release: address info now stored in InterfaceService - */ - @Deprecated - void clearAddresses(ConnectPoint connectPoint); - } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java index 8678a297..f7b7c499 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java @@ -30,7 +30,20 @@ public interface HostProviderService extends ProviderService<HostProvider> { * @param hostId id of the host that been detected * @param hostDescription description of host and its location */ - void hostDetected(HostId hostId, HostDescription hostDescription); + @Deprecated + default void hostDetected(HostId hostId, HostDescription hostDescription) { + hostDetected(hostId, hostDescription, false); + } + + /** + * Notifies the core when a host has been detected on a network along with + * information that identifies the host location. + * + * @param hostId id of the host that been detected + * @param hostDescription description of host and its location + * @param replaceIps replace IP set if true, merge IP set otherwise + */ + void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps); /** * Notifies the core when a host is no longer detected on a network. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostService.java index be114f05..39012159 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostService.java @@ -123,24 +123,4 @@ public interface HostService */ void requestMac(IpAddress ip); - /** - * Returns the addresses information for all connection points. - * - * @return the set of address bindings for all connection points - * @deprecated in Drake release: use InterfaceService instead - */ - @Deprecated - Set<PortAddresses> getAddressBindings(); - - /** - * Retrieves the addresses that have been bound to the given connection - * point. - * - * @param connectPoint the connection point to retrieve address bindings for - * @return addresses bound to the port - * @deprecated in Drake release: use InterfaceService instead - */ - @Deprecated - Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint); - } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostStore.java index ca11a942..5894fe92 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostStore.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostStore.java @@ -39,12 +39,13 @@ public interface HostStore extends Store<HostEvent, HostStoreDelegate> { * @param providerId provider identification * @param hostId host identification * @param hostDescription host description data + * @param replaceIps replace IP set if true, merge IP set otherwise * @return appropriate event or null if no change resulted */ HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId, - HostDescription hostDescription); + HostDescription hostDescription, + boolean replaceIps); - // FIXME: API to remove only IpAddress is missing /** * Removes the specified host from the inventory. * @@ -115,53 +116,4 @@ public interface HostStore extends Store<HostEvent, HostStoreDelegate> { */ Set<Host> getConnectedHosts(DeviceId deviceId); - /** - * Updates the address information for a given port. The given address - * information is added to any previously held information for the port. - * - * @param addresses the port and address information - * @deprecated in Drake release: address info now stored in InterfaceService - */ - @Deprecated - void updateAddressBindings(PortAddresses addresses); - - /** - * Removes the given addresses from the set of address information held for - * a port. - * - * @param addresses the port and address information - * @deprecated in Drake release: address info now stored in InterfaceService - */ - @Deprecated - void removeAddressBindings(PortAddresses addresses); - - /** - * Removes any previously stored address information for a given connection - * point. - * - * @param connectPoint the connection point - * @deprecated in Drake release: address info now stored in InterfaceService - */ - @Deprecated - void clearAddressBindings(ConnectPoint connectPoint); - - /** - * Returns the address bindings stored for all connection points. - * - * @return the set of address bindings - * @deprecated in Drake release: address info now stored in InterfaceService - */ - @Deprecated - Set<PortAddresses> getAddressBindings(); - - /** - * Returns the address bindings for a particular connection point. - * - * @param connectPoint the connection point to return address information - * for - * @return address information for the connection point - * @deprecated in Drake release: address info now stored in InterfaceService - */ - @Deprecated - Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java index bf469dbe..7df3c81e 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java @@ -1,3 +1,18 @@ +/* + * 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.net.intent; import java.util.Collections; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java index 3c3c45ce..caa5fbb9 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java @@ -1,3 +1,18 @@ +/* + * 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.net.intent; import java.util.List; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java index dffbabfe..0c831fd5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java @@ -25,7 +25,6 @@ import org.onosproject.net.flow.TrafficSelector; import org.onosproject.net.flow.TrafficTreatment; import com.google.common.base.MoreObjects; -import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import static com.google.common.base.Preconditions.checkArgument; @@ -159,12 +158,8 @@ public class PathIntent extends ConnectivityIntent { * @param links links to be validated */ public static void validate(List<Link> links) { - checkArgument(Iterables.all(links, new Predicate<Link>() { - @Override - public boolean apply(Link link) { - return !link.src().elementId().equals(link.dst().elementId()); - } - }), "element of src and dst in a link must be different: {}", links); + checkArgument(Iterables.all(links, link -> !link.src().elementId().equals(link.dst().elementId())), + "element of src and dst in a link must be different: {}", links); boolean adjacentSame = true; for (int i = 0; i < links.size() - 1; i++) { diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java index fc2eba70..5a034b4d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java @@ -1,3 +1,18 @@ +/* + * 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.net.newresource; import com.google.common.annotations.Beta; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketPriority.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketPriority.java index 68c0a838..3eab9386 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketPriority.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketPriority.java @@ -34,7 +34,7 @@ public enum PacketPriority { private final int priorityValue; - private PacketPriority(int priorityValue) { + PacketPriority(int priorityValue) { this.priorityValue = priorityValue; } @@ -50,4 +50,4 @@ public enum PacketPriority { public String toString() { return String.valueOf(priorityValue); } -}
\ No newline at end of file +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketProcessor.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketProcessor.java index 98886775..0eba1b4e 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketProcessor.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketProcessor.java @@ -22,9 +22,9 @@ import static com.google.common.base.Preconditions.checkArgument; */ public interface PacketProcessor { - static final int ADVISOR_MAX = Integer.MAX_VALUE / 3; - static final int DIRECTOR_MAX = (Integer.MAX_VALUE / 3) * 2; - static final int OBSERVER_MAX = Integer.MAX_VALUE; + int ADVISOR_MAX = Integer.MAX_VALUE / 3; + int DIRECTOR_MAX = (Integer.MAX_VALUE / 3) * 2; + int OBSERVER_MAX = Integer.MAX_VALUE; /** * Returns a priority in the ADVISOR range, where processors can take early action and @@ -38,7 +38,7 @@ public interface PacketProcessor { static int advisor(int priority) { int overallPriority = priority + 1; checkArgument(overallPriority > 0 && overallPriority <= ADVISOR_MAX, - "Priority not within ADVISOR range"); + "Priority not within ADVISOR range"); return overallPriority; } @@ -53,7 +53,7 @@ public interface PacketProcessor { static int director(int priority) { int overallPriority = ADVISOR_MAX + priority + 1; checkArgument(overallPriority > ADVISOR_MAX && overallPriority <= DIRECTOR_MAX, - "Priority not within DIRECTOR range"); + "Priority not within DIRECTOR range"); return overallPriority; } @@ -68,8 +68,8 @@ public interface PacketProcessor { */ static int observer(int priority) { int overallPriority = DIRECTOR_MAX + priority + 1; - checkArgument(overallPriority > DIRECTOR_MAX && overallPriority <= OBSERVER_MAX, - "Priority not within OBSERVER range"); + checkArgument(overallPriority > DIRECTOR_MAX, + "Priority not within OBSERVER range"); return overallPriority; } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketService.java index 06c416ec..98f4d8e0 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketService.java @@ -15,9 +15,13 @@ */ package org.onosproject.net.packet; +import com.google.common.annotations.Beta; import org.onosproject.core.ApplicationId; import org.onosproject.net.flow.TrafficSelector; +import java.util.List; +import java.util.Map; + /** * Service for intercepting data plane packets and for emitting synthetic * outbound packets. @@ -48,6 +52,15 @@ public interface PacketService { void removeProcessor(PacketProcessor processor); /** + * Returns priority bindings of all registered packet processors. + * + * @return list of existing packet processors + */ + @Beta + // TODO: Consider returning list of PacketProcessorEntry with processor, priority and stats + Map<Integer, PacketProcessor> getProcessors(); + + /** * Requests that packets matching the given selector are punted from the * dataplane to the controller. * @@ -70,6 +83,13 @@ public interface PacketService { ApplicationId appId); /** + * Returns list of all existing requests ordered by priority. + * + * @return list of existing packet requests + */ + List<PacketRequest> getRequests(); + + /** * Emits the specified outbound packet onto the network. * * @param packet outbound packet diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketStore.java index ff45cc0c..97f7cb55 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketStore.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketStore.java @@ -17,7 +17,7 @@ package org.onosproject.net.packet; import org.onosproject.store.Store; -import java.util.Set; +import java.util.List; /** * Manages routing of outbound packets. @@ -52,8 +52,8 @@ public interface PacketStore extends Store<PacketEvent, PacketStoreDelegate> { /** * Obtains all existing requests in the system. * - * @return a set of packet requests + * @return list of packet requests in order of priority */ - Set<PacketRequest> existingRequests(); + List<PacketRequest> existingRequests(); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/proxyarp/ProxyArpService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/proxyarp/ProxyArpService.java index 8ffe17a4..9b27f4f8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/proxyarp/ProxyArpService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/proxyarp/ProxyArpService.java @@ -21,7 +21,7 @@ import org.onosproject.net.ConnectPoint; import org.onosproject.net.packet.PacketContext; /** - * Service for processing arp requests on behalf of applications. + * Service for processing ARP or NDP requests on behalf of applications. */ // TODO: move to the peer host package public interface ProxyArpService { diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppGuard.java b/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppGuard.java index 800135f4..4b80dfcd 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppGuard.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppGuard.java @@ -17,9 +17,12 @@ package org.onosproject.security; +import com.google.common.annotations.Beta; + /** * Aids SM-ONOS to perform API-level permission checking. */ +@Beta public final class AppGuard { private AppGuard() { diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppPermission.java b/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppPermission.java index 21a70d2b..09fe17a8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppPermission.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppPermission.java @@ -16,11 +16,14 @@ package org.onosproject.security; +import com.google.common.annotations.Beta; + import java.security.BasicPermission; /** * Implementation of API access permission. */ +@Beta public class AppPermission extends BasicPermission { public enum Type { diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/security/Permission.java b/framework/src/onos/core/api/src/main/java/org/onosproject/security/Permission.java index 75d9433f..0c874c9d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/security/Permission.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/security/Permission.java @@ -16,6 +16,9 @@ package org.onosproject.security; +import com.google.common.annotations.Beta; + +@Beta public class Permission { protected String classname; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityAdminService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityAdminService.java index 16ea94d1..30d143c0 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityAdminService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityAdminService.java @@ -16,6 +16,7 @@ package org.onosproject.security; +import com.google.common.annotations.Beta; import org.onosproject.core.ApplicationId; import java.security.Permission; @@ -25,6 +26,7 @@ import java.util.Map; /** * Security-Mode ONOS service. */ +@Beta public interface SecurityAdminService { /** diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityUtil.java b/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityUtil.java index 34b4e78a..444b6bb5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityUtil.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityUtil.java @@ -16,6 +16,7 @@ package org.onosproject.security; +import com.google.common.annotations.Beta; import org.onlab.osgi.DefaultServiceDirectory; import org.onlab.osgi.ServiceDirectory; import org.onlab.osgi.ServiceNotFoundException; @@ -24,6 +25,7 @@ import org.onosproject.core.ApplicationId; /** * Utility class to aid Security-Mode ONOS. */ +@Beta public final class SecurityUtil { protected static ServiceDirectory serviceDirectory = new DefaultServiceDirectory(); diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java index 8cac5968..a62d3823 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java @@ -31,7 +31,7 @@ public final class DatabaseUpdate { /** * Type of database update operation. */ - public static enum Type { + public enum Type { /** * Insert/Update entry without any checks. */ diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java index 2889422a..e0d7d239 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlayFactory.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlayFactory.java index bd2f2fe6..61bc0c23 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlayFactory.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlayFactory.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java index 84d11344..1c42c97a 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellFormatter.java index 854ac27f..895c9d93 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellFormatter.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java index 6113fc3f..31d9f634 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java index 33ce2ab5..08822b7b 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java index 42d684b6..0e1c248b 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java index fee26154..4af6fe2f 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java index 093a20d3..2386f8f3 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java index 0efa2ebd..8309c545 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java index e09982ea..981a81bb 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java index fe87c61b..95a7cc23 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java index 44dc1940..58c70930 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java index ab2ced36..d30ba2f6 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java index c37c129b..a40383b8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java index 720eca49..cc2cf4af 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java index 8c95e15d..1217faae 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java index 7bc0e65d..9a42e107 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java index ca2ecccd..05b7317d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java index 2985d3d4..0ce6592c 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java index be59c26b..12d3b629 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java index 76669a84..48959496 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java index b4e43304..a734c6b7 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java index d21a8724..b11ddecd 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java index 735f8166..61e10c56 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java index b284de1b..4aed9038 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java index 121e0834..a165be33 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java index 38a8f036..0f42b628 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java index dc327464..39947440 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java index a94068ee..8df03169 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java index f92d5798..b38a7f7d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java index 6d5e8934..b81155e6 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java @@ -17,8 +17,6 @@ package org.onosproject.event; import java.util.Set; -import static org.junit.Assert.*; - /** * Testing adapter for the event delivery service. */ diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/OchSignalTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/OchSignalTest.java index c171d523..1ab17293 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/OchSignalTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/OchSignalTest.java @@ -18,8 +18,6 @@ package org.onosproject.net; import com.google.common.testing.EqualsTester; import org.junit.Test; -import static org.junit.Assert.*; - /** * Test for OchSignal. */ diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java index 5bfdd76b..7b43da6a 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java @@ -1,3 +1,18 @@ +/* + * 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.net.device; import org.onosproject.net.DeviceId; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java index 795e4c0a..5f52f6db 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java @@ -15,7 +15,6 @@ */ package org.onosproject.net.device; -import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; import org.onosproject.net.Device; @@ -45,13 +44,7 @@ public class DeviceServiceAdapter implements DeviceService { @Override public Iterable<Device> getAvailableDevices() { return FluentIterable.from(getDevices()) - .filter(new Predicate<Device>() { - - @Override - public boolean apply(Device input) { - return isAvailable(input.id()); - } - }); + .filter(input -> isAvailable(input.id())); } @Override diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java index 30326a2e..7a61f823 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java @@ -1,3 +1,18 @@ +/* + * 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.net.flow; import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/HostServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/HostServiceAdapter.java index 226dad06..0fad54a8 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/HostServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/HostServiceAdapter.java @@ -15,15 +15,15 @@ */ package org.onosproject.net.host; -import java.util.Set; - +import org.onlab.packet.IpAddress; +import org.onlab.packet.MacAddress; +import org.onlab.packet.VlanId; import org.onosproject.net.ConnectPoint; import org.onosproject.net.DeviceId; import org.onosproject.net.Host; import org.onosproject.net.HostId; -import org.onlab.packet.IpAddress; -import org.onlab.packet.MacAddress; -import org.onlab.packet.VlanId; + +import java.util.Set; /** * Test adapter for host service. @@ -89,14 +89,4 @@ public class HostServiceAdapter implements HostService { public void removeListener(HostListener listener) { } - @Override - public Set<PortAddresses> getAddressBindings() { - return null; - } - - @Override - public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) { - return null; - } - } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java index 9b9f7cec..a33d3692 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java @@ -49,30 +49,23 @@ public class FakeIntentManager implements TestableIntentService { // Provides an out-of-thread simulation of intent submit life-cycle private void executeSubmit(final Intent intent) { registerSubclassCompilerIfNeeded(intent); - executor.execute(new Runnable() { - @Override - public void run() { - try { - executeCompilingPhase(intent); - } catch (IntentException e) { - exceptions.add(e); - } + executor.execute(() -> { + try { + executeCompilingPhase(intent); + } catch (IntentException e) { + exceptions.add(e); } }); } // Provides an out-of-thread simulation of intent withdraw life-cycle private void executeWithdraw(final Intent intent) { - executor.execute(new Runnable() { - @Override - public void run() { - try { - List<Intent> installable = getInstallable(intent.key()); - executeWithdrawingPhase(intent, installable); - } catch (IntentException e) { - exceptions.add(e); - } - + executor.execute(() -> { + try { + List<Intent> installable = getInstallable(intent.key()); + executeWithdrawingPhase(intent, installable); + } catch (IntentException e) { + exceptions.add(e); } }); } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java index 60857cac..0067fb2d 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java @@ -79,13 +79,8 @@ public class IntentServiceTest { service.submit(intent); // Allow a small window of time until the intent is in the expected state - TestTools.assertAfter(GRACE_MS, new Runnable() { - @Override - public void run() { - assertEquals("incorrect intent state", IntentState.INSTALLED, - service.getIntentState(intent.key())); - } - }); + TestTools.assertAfter(GRACE_MS, () -> + assertEquals("incorrect intent state", IntentState.INSTALLED, service.getIntentState(intent.key()))); // Make sure that all expected events have been emitted validateEvents(intent, INSTALL_REQ, INSTALLED); @@ -100,13 +95,8 @@ public class IntentServiceTest { service.withdraw(intent); // Allow a small window of time until the event is in the expected state - TestTools.assertAfter(GRACE_MS, new Runnable() { - @Override - public void run() { - assertEquals("incorrect intent state", IntentState.WITHDRAWN, - service.getIntentState(intent.key())); - } - }); + TestTools.assertAfter(GRACE_MS, () -> + assertEquals("incorrect intent state", IntentState.WITHDRAWN, service.getIntentState(intent.key()))); // Make sure that all expected events have been emitted validateEvents(intent, WITHDRAWN); @@ -128,13 +118,8 @@ public class IntentServiceTest { service.submit(intent); // Allow a small window of time until the intent is in the expected state - TestTools.assertAfter(GRACE_MS, new Runnable() { - @Override - public void run() { - assertEquals("incorrect intent state", IntentState.FAILED, - service.getIntentState(intent.key())); - } - }); + TestTools.assertAfter(GRACE_MS, () -> + assertEquals("incorrect intent state", IntentState.FAILED, service.getIntentState(intent.key()))); // Make sure that all expected events have been emitted validateEvents(intent, INSTALL_REQ, FAILED); @@ -196,13 +181,8 @@ public class IntentServiceTest { service.submit(intent); // Allow some time for the intent to be compiled and installed - TestTools.assertAfter(GRACE_MS, new Runnable() { - @Override - public void run() { - assertEquals("incorrect intent state", IntentState.INSTALLED, - service.getIntentState(intent.key())); - } - }); + TestTools.assertAfter(GRACE_MS, () -> + assertEquals("incorrect intent state", IntentState.INSTALLED, service.getIntentState(intent.key()))); // Make sure that now we have an implicit registration of the compiler // under the intent subclass diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PartitionServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PartitionServiceAdapter.java index ffb2635e..2a38cbb3 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PartitionServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PartitionServiceAdapter.java @@ -17,8 +17,6 @@ package org.onosproject.net.intent; import org.onosproject.cluster.NodeId; -import static org.junit.Assert.*; - /** * Testing adapter for the partition service. */ diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java index 5cb84b31..7cd87cd1 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java @@ -22,7 +22,6 @@ import org.onosproject.net.DeviceId; import org.onosproject.net.Link; import org.onosproject.net.Link.State; -import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; /** @@ -42,13 +41,7 @@ public class LinkServiceAdapter implements LinkService { @Override public Iterable<Link> getActiveLinks() { return FluentIterable.from(getLinks()) - .filter(new Predicate<Link>() { - - @Override - public boolean apply(Link input) { - return input.state() == State.ACTIVE; - } - }); + .filter(input -> input.state() == State.ACTIVE); } @Override diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java index afe936b7..c4386593 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java @@ -18,6 +18,9 @@ package org.onosproject.net.packet; import org.onosproject.core.ApplicationId; import org.onosproject.net.flow.TrafficSelector; +import java.util.List; +import java.util.Map; + /** * Test adapter for packet service. */ @@ -31,6 +34,16 @@ public class PacketServiceAdapter implements PacketService { } @Override + public Map<Integer, PacketProcessor> getProcessors() { + return null; + } + + @Override + public List<PacketRequest> getRequests() { + return null; + } + + @Override public void requestPackets(TrafficSelector selector, PacketPriority priority, ApplicationId appId) { } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/DatabaseUpdateTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/DatabaseUpdateTest.java index b498c1c7..ad439d66 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/DatabaseUpdateTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/DatabaseUpdateTest.java @@ -16,7 +16,6 @@ package org.onosproject.store.service; import com.google.common.testing.EqualsTester; -import junit.framework.TestCase; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -26,7 +25,7 @@ import static org.hamcrest.Matchers.is; * Unit Tests for DatabseUpdate class. */ -public class DatabaseUpdateTest extends TestCase { +public class DatabaseUpdateTest { private final DatabaseUpdate stats1 = DatabaseUpdate.newBuilder() .withCurrentValue("1".getBytes()) @@ -124,4 +123,4 @@ public class DatabaseUpdateTest extends TestCase { assertThat(stats1.toString(), is(stats1.toString())); } -}
\ No newline at end of file +} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java index c241c0e0..47fba6c9 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java @@ -16,7 +16,6 @@ package org.onosproject.store.service; import com.google.common.testing.EqualsTester; -import junit.framework.TestCase; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -25,7 +24,7 @@ import static org.hamcrest.Matchers.is; /** * MapEvent unit tests. */ -public class MapEventTest extends TestCase { +public class MapEventTest { private final Versioned<Integer> vStats = new Versioned<>(2, 1); @@ -58,4 +57,4 @@ public class MapEventTest extends TestCase { .testEquals(); } -}
\ No newline at end of file +} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MultiValuedTimestampTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MultiValuedTimestampTest.java index 5d991a26..43475e45 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MultiValuedTimestampTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MultiValuedTimestampTest.java @@ -16,7 +16,6 @@ package org.onosproject.store.service; import com.google.common.testing.EqualsTester; -import junit.framework.TestCase; import org.junit.Assert; import org.junit.Test; @@ -31,7 +30,7 @@ import static org.hamcrest.Matchers.notNullValue; /** * MultiValuedTimestamp unit tests. */ -public class MultiValuedTimestampTest extends TestCase { +public class MultiValuedTimestampTest { private final MultiValuedTimestamp<Integer, Integer> stats1 = new MultiValuedTimestamp<>(1, 3); @@ -91,4 +90,4 @@ public class MultiValuedTimestampTest extends TestCase { Assert.fail("Exception looking up constructors"); } } -}
\ No newline at end of file +} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/VersionedTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/VersionedTest.java index 8a401db2..fbe3271b 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/VersionedTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/VersionedTest.java @@ -16,7 +16,6 @@ package org.onosproject.store.service; import com.google.common.testing.EqualsTester; -import junit.framework.TestCase; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -25,7 +24,7 @@ import static org.hamcrest.Matchers.is; /** * Versioned unit tests. */ -public class VersionedTest extends TestCase { +public class VersionedTest { private final Versioned<Integer> stats1 = new Versioned<>(1, 2, 3); diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/TableUtilsTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/TableUtilsTest.java index 7c2f2d73..4456dd3d 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/TableUtilsTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/TableUtilsTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellComparatorTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellComparatorTest.java index 0b9af23d..30125afb 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellComparatorTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellComparatorTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellFormatterTest.java index 7a3c34bc..41fefd65 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellFormatterTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AppIdFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AppIdFormatterTest.java index e74fb47c..a7befbdb 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AppIdFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AppIdFormatterTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/ConnectPointFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/ConnectPointFormatterTest.java index 65fd7843..f7ad2751 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/ConnectPointFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/ConnectPointFormatterTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; 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 87c95288..d77c1b2b 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 @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellFormatterTest.java index 6351a1f4..b63793b9 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellFormatterTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HexFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HexFormatterTest.java index ad23b02c..2f70d43c 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HexFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HexFormatterTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HostLocationFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HostLocationFormatterTest.java index bfbe4541..25ec89cd 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HostLocationFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HostLocationFormatterTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java index f41d82b3..1e05ded1 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.table.cell; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkMapTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkMapTest.java index 17fcc229..83f4809c 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkMapTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkMapTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTest.java index 1acc06fa..55f31ac9 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTestBase.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTestBase.java index b5bd41ef..a6beec86 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTestBase.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTestBase.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ButtonIdTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ButtonIdTest.java index 04c6dc18..01a1b975 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ButtonIdTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ButtonIdTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/HighlightsTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/HighlightsTest.java index 7d6dfe67..fe663a5b 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/HighlightsTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/HighlightsTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/LinkHighlightTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/LinkHighlightTest.java index 205f08ce..a88de33a 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/LinkHighlightTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/LinkHighlightTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ModTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ModTest.java index bb40279c..03a18f97 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ModTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ModTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/NodeSelectionTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/NodeSelectionTest.java index 60cada45..06a78580 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/NodeSelectionTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/NodeSelectionTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java index b08ee4dc..7e6cc227 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/TopoJsonTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/TopoJsonTest.java index 6a3bfa43..ac0051cd 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/TopoJsonTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/TopoJsonTest.java @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.onosproject.ui.topo; diff --git a/framework/src/onos/core/common/pom.xml b/framework/src/onos/core/common/pom.xml index 71c0fe40..e4d25eed 100644 --- a/framework/src/onos/core/common/pom.xml +++ b/framework/src/onos/core/common/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onosproject</groupId> <artifactId>onos-core</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/MockCodecContext.java b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/MockCodecContext.java index 6a9b6708..c3b6d821 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/MockCodecContext.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/MockCodecContext.java @@ -30,7 +30,7 @@ public class MockCodecContext implements CodecContext { private final ObjectMapper mapper = new ObjectMapper(); private final CodecManager manager = new CodecManager(); - private final Map<Class<? extends Object>, Object> services = new HashMap<>(); + private final Map<Class<?>, Object> services = new HashMap<>(); /** * Constructs a new mock codec context. 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 fc90dfad..72fc1b05 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 @@ -15,7 +15,6 @@ */ package org.onosproject.store.trivial; -import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; @@ -134,13 +133,7 @@ public class SimpleDeviceStore @Override public Iterable<Device> getAvailableDevices() { return FluentIterable.from(getDevices()) - .filter(new Predicate<Device>() { - - @Override - public boolean apply(Device input) { - return isAvailable(input.id()); - } - }); + .filter(input -> isAvailable(input.id())); } @Override diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java index 562e6f3c..c9e135d9 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java @@ -479,31 +479,22 @@ public class SimpleDeviceStoreTest { @Test public final void testEvents() throws InterruptedException { final CountDownLatch addLatch = new CountDownLatch(1); - DeviceStoreDelegate checkAdd = new DeviceStoreDelegate() { - @Override - public void notify(DeviceEvent event) { - assertEquals(DEVICE_ADDED, event.type()); - assertDevice(DID1, SW1, event.subject()); - addLatch.countDown(); - } + DeviceStoreDelegate checkAdd = event -> { + assertEquals(DEVICE_ADDED, event.type()); + assertDevice(DID1, SW1, event.subject()); + addLatch.countDown(); }; final CountDownLatch updateLatch = new CountDownLatch(1); - DeviceStoreDelegate checkUpdate = new DeviceStoreDelegate() { - @Override - public void notify(DeviceEvent event) { - assertEquals(DEVICE_UPDATED, event.type()); - assertDevice(DID1, SW2, event.subject()); - updateLatch.countDown(); - } + DeviceStoreDelegate checkUpdate = event -> { + assertEquals(DEVICE_UPDATED, event.type()); + assertDevice(DID1, SW2, event.subject()); + updateLatch.countDown(); }; final CountDownLatch removeLatch = new CountDownLatch(1); - DeviceStoreDelegate checkRemove = new DeviceStoreDelegate() { - @Override - public void notify(DeviceEvent event) { - assertEquals(DEVICE_REMOVED, event.type()); - assertDevice(DID1, SW2, event.subject()); - removeLatch.countDown(); - } + DeviceStoreDelegate checkRemove = event -> { + assertEquals(DEVICE_REMOVED, event.type()); + assertDevice(DID1, SW2, event.subject()); + removeLatch.countDown(); }; DeviceDescription description = diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java index 3b8f1d35..c8c92aa5 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java @@ -15,7 +15,6 @@ */ package org.onosproject.store.trivial; -import com.google.common.base.Function; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.RemovalListener; @@ -162,15 +161,7 @@ public class SimpleFlowRuleStore public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { // flatten and make iterator unmodifiable return FluentIterable.from(getFlowTable(deviceId).values()) - .transformAndConcat( - new Function<List<StoredFlowEntry>, Iterable<? extends FlowEntry>>() { - - @Override - public Iterable<? extends FlowEntry> apply( - List<StoredFlowEntry> input) { - return Collections.unmodifiableList(input); - } - }); + .transformAndConcat(Collections::unmodifiableList); } @Override diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java index 71de3e13..230fa339 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java @@ -55,7 +55,6 @@ import org.onosproject.net.group.StoredGroupEntry; import org.onosproject.store.AbstractStore; import org.slf4j.Logger; -import com.google.common.base.Function; import com.google.common.collect.FluentIterable; import com.google.common.collect.Sets; @@ -83,8 +82,7 @@ public class SimpleGroupStore private final ConcurrentMap<DeviceId, ConcurrentMap<GroupId, Group>> extraneousGroupEntriesById = new ConcurrentHashMap<>(); - private final HashMap<DeviceId, Boolean> deviceAuditStatus = - new HashMap<DeviceId, Boolean>(); + private final HashMap<DeviceId, Boolean> deviceAuditStatus = new HashMap<>(); private final AtomicInteger groupIdGen = new AtomicInteger(); @@ -189,15 +187,7 @@ public class SimpleGroupStore public Iterable<Group> getGroups(DeviceId deviceId) { // flatten and make iterator unmodifiable return FluentIterable.from(getGroupKeyTable(deviceId).values()) - .transform( - new Function<StoredGroupEntry, Group>() { - - @Override - public Group apply( - StoredGroupEntry input) { - return input; - } - }); + .transform(input -> input); } /** @@ -358,8 +348,7 @@ public class SimpleGroupStore UpdateType type, GroupBuckets buckets) { GroupBuckets oldBuckets = oldGroup.buckets(); - List<GroupBucket> newBucketList = new ArrayList<GroupBucket>( - oldBuckets.buckets()); + List<GroupBucket> newBucketList = new ArrayList<>(oldBuckets.buckets()); boolean groupDescUpdated = false; if (type == UpdateType.ADD) { diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStoreTest.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStoreTest.java index dd6c8a58..b10fca5c 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStoreTest.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStoreTest.java @@ -205,10 +205,10 @@ public class SimpleGroupStoreTest { private void testStoreAndGetGroup(GroupKey key) { PortNumber[] ports = {PortNumber.portNumber(31), PortNumber.portNumber(32)}; - List<PortNumber> outPorts = new ArrayList<PortNumber>(); + List<PortNumber> outPorts = new ArrayList<>(); outPorts.addAll(Arrays.asList(ports)); - List<GroupBucket> buckets = new ArrayList<GroupBucket>(); + List<GroupBucket> buckets = new ArrayList<>(); for (PortNumber portNumber: outPorts) { TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); tBuilder.setOutput(portNumber) @@ -271,7 +271,7 @@ public class SimpleGroupStoreTest { Group existingGroup = simpleGroupStore.getGroup(D1, currKey); int totalPkts = 0; int totalBytes = 0; - List<GroupBucket> newBucketList = new ArrayList<GroupBucket>(); + List<GroupBucket> newBucketList = new ArrayList<>(); for (GroupBucket bucket:existingGroup.buckets().buckets()) { StoredGroupBucketEntry newBucket = (StoredGroupBucketEntry) @@ -302,15 +302,15 @@ public class SimpleGroupStoreTest { // Testing updateGroupDescription for ADD operation from northbound private void testAddBuckets(GroupKey currKey, GroupKey addKey) { Group existingGroup = simpleGroupStore.getGroup(D1, currKey); - List<GroupBucket> buckets = new ArrayList<GroupBucket>(); + List<GroupBucket> buckets = new ArrayList<>(); buckets.addAll(existingGroup.buckets().buckets()); PortNumber[] newNeighborPorts = {PortNumber.portNumber(41), PortNumber.portNumber(42)}; - List<PortNumber> newOutPorts = new ArrayList<PortNumber>(); + List<PortNumber> newOutPorts = new ArrayList<>(); newOutPorts.addAll(Collections.singletonList(newNeighborPorts[0])); - List<GroupBucket> toAddBuckets = new ArrayList<GroupBucket>(); + List<GroupBucket> toAddBuckets = new ArrayList<>(); for (PortNumber portNumber: newOutPorts) { TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); tBuilder.setOutput(portNumber) @@ -340,10 +340,10 @@ public class SimpleGroupStoreTest { // Testing updateGroupDescription for REMOVE operation from northbound private void testRemoveBuckets(GroupKey currKey, GroupKey removeKey) { Group existingGroup = simpleGroupStore.getGroup(D1, currKey); - List<GroupBucket> buckets = new ArrayList<GroupBucket>(); + List<GroupBucket> buckets = new ArrayList<>(); buckets.addAll(existingGroup.buckets().buckets()); - List<GroupBucket> toRemoveBuckets = new ArrayList<GroupBucket>(); + List<GroupBucket> toRemoveBuckets = new ArrayList<>(); // There should be 4 buckets in the current group toRemoveBuckets.add(buckets.remove(0)); @@ -405,11 +405,11 @@ public class SimpleGroupStoreTest { GroupKey key = new DefaultGroupKey("group1".getBytes()); PortNumber[] ports = {PortNumber.portNumber(31), PortNumber.portNumber(32)}; - List<PortNumber> outPorts = new ArrayList<PortNumber>(); + List<PortNumber> outPorts = new ArrayList<>(); outPorts.add(ports[0]); outPorts.add(ports[1]); - List<GroupBucket> buckets = new ArrayList<GroupBucket>(); + List<GroupBucket> buckets = new ArrayList<>(); for (PortNumber portNumber: outPorts) { TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); tBuilder.setOutput(portNumber) diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java index f5604f68..264d0493 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java @@ -15,23 +15,16 @@ */ package org.onosproject.store.trivial; -import static org.onosproject.net.DefaultAnnotations.merge; -import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; -import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED; -import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED; -import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED; -import static org.slf4j.LoggerFactory.getLogger; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Multimap; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; import org.apache.felix.scr.annotations.Service; +import org.onlab.packet.IpAddress; +import org.onlab.packet.MacAddress; +import org.onlab.packet.VlanId; import org.onosproject.net.Annotations; import org.onosproject.net.ConnectPoint; import org.onosproject.net.DefaultAnnotations; @@ -44,19 +37,21 @@ import org.onosproject.net.host.HostDescription; import org.onosproject.net.host.HostEvent; import org.onosproject.net.host.HostStore; import org.onosproject.net.host.HostStoreDelegate; -import org.onosproject.net.host.PortAddresses; import org.onosproject.net.provider.ProviderId; import org.onosproject.store.AbstractStore; -import org.onlab.packet.IpAddress; -import org.onlab.packet.MacAddress; -import org.onlab.packet.VlanId; import org.slf4j.Logger; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; -import com.google.common.collect.SetMultimap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import static org.onosproject.net.DefaultAnnotations.merge; +import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; +import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED; +import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED; +import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED; +import static org.slf4j.LoggerFactory.getLogger; // TODO: multi-provider, annotation not supported. /** @@ -77,10 +72,6 @@ public class SimpleHostStore // Hosts tracked by their location private final Multimap<ConnectPoint, Host> locations = HashMultimap.create(); - private final SetMultimap<ConnectPoint, PortAddresses> portAddresses = - Multimaps.synchronizedSetMultimap( - HashMultimap.<ConnectPoint, PortAddresses>create()); - @Activate public void activate() { log.info("Started"); @@ -93,12 +84,14 @@ public class SimpleHostStore @Override public HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId, - HostDescription hostDescription) { + HostDescription hostDescription, + boolean replaceIps) { + //TODO We need a way to detect conflicting changes and abort update. StoredHost host = hosts.get(hostId); if (host == null) { return createHost(providerId, hostId, hostDescription); } - return updateHost(providerId, host, hostDescription); + return updateHost(providerId, host, hostDescription, replaceIps); } // creates a new host and sends HOST_ADDED @@ -119,7 +112,7 @@ public class SimpleHostStore // checks for type of update to host, sends appropriate event private HostEvent updateHost(ProviderId providerId, StoredHost host, - HostDescription descr) { + HostDescription descr, boolean replaceIps) { HostEvent event; if (!host.location().equals(descr.location())) { host.setLocation(descr.location()); @@ -131,8 +124,14 @@ public class SimpleHostStore return null; } - Set<IpAddress> addresses = new HashSet<>(host.ipAddresses()); - addresses.addAll(descr.ipAddress()); + final Set<IpAddress> addresses; + if (replaceIps) { + addresses = ImmutableSet.copyOf(descr.ipAddress()); + } else { + addresses = new HashSet<>(host.ipAddresses()); + addresses.addAll(descr.ipAddress()); + } + Annotations annotations = merge((DefaultAnnotations) host.annotations(), descr.annotations()); StoredHost updated = new StoredHost(providerId, host.id(), @@ -224,41 +223,6 @@ public class SimpleHostStore return hostset; } - @Override - public void updateAddressBindings(PortAddresses addresses) { - portAddresses.put(addresses.connectPoint(), addresses); - } - - @Override - public void removeAddressBindings(PortAddresses addresses) { - portAddresses.remove(addresses.connectPoint(), addresses); - } - - @Override - public void clearAddressBindings(ConnectPoint connectPoint) { - portAddresses.removeAll(connectPoint); - } - - @Override - public Set<PortAddresses> getAddressBindings() { - synchronized (portAddresses) { - return ImmutableSet.copyOf(portAddresses.values()); - } - } - - @Override - public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) { - synchronized (portAddresses) { - Set<PortAddresses> addresses = portAddresses.get(connectPoint); - - if (addresses == null) { - return Collections.emptySet(); - } else { - return ImmutableSet.copyOf(addresses); - } - } - } - // Auxiliary extension to allow location to mutate. private static final class StoredHost extends DefaultHost { private HostLocation location; diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStore.java index d0be2b1f..92b882a6 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStore.java @@ -44,7 +44,6 @@ import org.onosproject.net.provider.ProviderId; import org.onosproject.store.AbstractStore; import org.slf4j.Logger; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -280,7 +279,7 @@ public class SimpleLinkStore */ private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { return synchronizedSetMultimap( - Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(), + Multimaps.newSetMultimap(new ConcurrentHashMap<>(), () -> Sets.newConcurrentHashSet())); } diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java index 2d2b2759..40649aa5 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java @@ -498,31 +498,22 @@ public class SimpleLinkStoreTest { final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2); final CountDownLatch addLatch = new CountDownLatch(1); - LinkStoreDelegate checkAdd = new LinkStoreDelegate() { - @Override - public void notify(LinkEvent event) { - assertEquals(LINK_ADDED, event.type()); - assertLink(linkId1, INDIRECT, event.subject()); - addLatch.countDown(); - } + LinkStoreDelegate checkAdd = event -> { + assertEquals(LINK_ADDED, event.type()); + assertLink(linkId1, INDIRECT, event.subject()); + addLatch.countDown(); }; final CountDownLatch updateLatch = new CountDownLatch(1); - LinkStoreDelegate checkUpdate = new LinkStoreDelegate() { - @Override - public void notify(LinkEvent event) { - assertEquals(LINK_UPDATED, event.type()); - assertLink(linkId1, DIRECT, event.subject()); - updateLatch.countDown(); - } + LinkStoreDelegate checkUpdate = event -> { + assertEquals(LINK_UPDATED, event.type()); + assertLink(linkId1, DIRECT, event.subject()); + updateLatch.countDown(); }; final CountDownLatch removeLatch = new CountDownLatch(1); - LinkStoreDelegate checkRemove = new LinkStoreDelegate() { - @Override - public void notify(LinkEvent event) { - assertEquals(LINK_REMOVED, event.type()); - assertLink(linkId1, DIRECT, event.subject()); - removeLatch.countDown(); - } + LinkStoreDelegate checkRemove = event -> { + assertEquals(LINK_REMOVED, event.type()); + assertLink(linkId1, DIRECT, event.subject()); + removeLatch.countDown(); }; linkStore.setDelegate(checkAdd); diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java index ef92ded2..61db2e66 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java @@ -375,14 +375,10 @@ public class SimpleMastershipStore .filter(entry -> entry.getValue().contains(nodeId)) .forEach(entry -> toRelinquish.add(entry.getKey())); - toRelinquish.forEach(deviceId -> { - eventFutures.add(relinquishRole(nodeId, deviceId)); - }); + toRelinquish.forEach(deviceId -> eventFutures.add(relinquishRole(nodeId, deviceId))); eventFutures.forEach(future -> { - future.whenComplete((event, error) -> { - notifyDelegate(event); - }); + future.whenComplete((event, error) -> notifyDelegate(event)); }); } } diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimplePacketStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimplePacketStore.java index 4345abaf..f8359262 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimplePacketStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimplePacketStore.java @@ -15,6 +15,7 @@ */ package org.onosproject.store.trivial; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; @@ -26,8 +27,7 @@ import org.onosproject.net.packet.PacketStore; import org.onosproject.net.packet.PacketStoreDelegate; import org.onosproject.store.AbstractStore; - -import java.util.Collections; +import java.util.List; import java.util.Set; /** @@ -57,8 +57,8 @@ public class SimplePacketStore } @Override - public Set<PacketRequest> existingRequests() { - return Collections.unmodifiableSet(requests); + public List<PacketRequest> existingRequests() { + return ImmutableList.copyOf(requests); } } diff --git a/framework/src/onos/core/net/pom.xml b/framework/src/onos/core/net/pom.xml index 4ba04c50..9ea00070 100644 --- a/framework/src/onos/core/net/pom.xml +++ b/framework/src/onos/core/net/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onosproject</groupId> <artifactId>onos-core</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java index 07612292..8a441f61 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java @@ -59,7 +59,7 @@ public class CoreManager implements CoreService { private final Logger log = LoggerFactory.getLogger(getClass()); private static final File VERSION_FILE = new File("../VERSION"); - private static Version version = Version.version("1.3.0-SNAPSHOT"); + private static Version version = Version.version("1.4.0-SNAPSHOT"); @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected ApplicationIdStore applicationIdStore; diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/package-info.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/package-info.java index fd867326..fa5f2480 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/package-info.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/package-info.java @@ -1,3 +1,19 @@ +/* + * 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. + */ + /** * Core subsystem for interacting with network edges. */ diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java index 99263381..43f346b7 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java @@ -25,6 +25,7 @@ import org.onlab.packet.IpAddress; import org.onlab.packet.MacAddress; import org.onlab.packet.VlanId; import org.onosproject.incubator.net.intf.InterfaceService; +import org.onosproject.net.edge.EdgePortService; import org.onosproject.net.provider.AbstractListenerProviderRegistry; import org.onosproject.net.config.NetworkConfigEvent; import org.onosproject.net.config.NetworkConfigListener; @@ -45,7 +46,6 @@ import org.onosproject.net.host.HostProviderService; import org.onosproject.net.host.HostService; import org.onosproject.net.host.HostStore; import org.onosproject.net.host.HostStoreDelegate; -import org.onosproject.net.host.PortAddresses; import org.onosproject.net.packet.PacketService; import org.onosproject.net.provider.AbstractProviderService; import org.slf4j.Logger; @@ -90,6 +90,9 @@ public class HostManager @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected InterfaceService interfaceService; + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected EdgePortService edgePortService; + private HostMonitor monitor; @Activate @@ -97,7 +100,7 @@ public class HostManager store.setDelegate(delegate); eventDispatcher.addSink(HostEvent.class, listenerRegistry); networkConfigService.addListener(networkConfigListener); - monitor = new HostMonitor(packetService, this, interfaceService); + monitor = new HostMonitor(packetService, this, interfaceService, edgePortService); monitor.start(); log.info("Started"); } @@ -195,33 +198,6 @@ public class HostManager } } - @Override - public void bindAddressesToPort(PortAddresses addresses) { - store.updateAddressBindings(addresses); - } - - @Override - public void unbindAddressesFromPort(PortAddresses portAddresses) { - store.removeAddressBindings(portAddresses); - } - - @Override - public void clearAddresses(ConnectPoint connectPoint) { - store.clearAddressBindings(connectPoint); - } - - @Override - public Set<PortAddresses> getAddressBindings() { - checkPermission(HOST_READ); - return store.getAddressBindings(); - } - - @Override - public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) { - checkPermission(HOST_READ); - return store.getAddressBindingsForPort(connectPoint); - } - // Personalized host provider service issued to the supplied provider. private class InternalHostProviderService extends AbstractProviderService<HostProvider> @@ -231,12 +207,12 @@ public class HostManager } @Override - public void hostDetected(HostId hostId, HostDescription hostDescription) { + public void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps) { checkNotNull(hostId, HOST_ID_NULL); checkValidity(); hostDescription = validateHost(hostDescription, hostId); HostEvent event = store.createOrUpdateHost(provider().id(), hostId, - hostDescription); + hostDescription, replaceIps); if (event != null) { post(event); } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java index fe252368..44f8cbf0 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java @@ -31,21 +31,20 @@ import org.onosproject.incubator.net.intf.Interface; import org.onosproject.incubator.net.intf.InterfaceService; import org.onosproject.net.ConnectPoint; import org.onosproject.net.Host; +import org.onosproject.net.edge.EdgePortService; import org.onosproject.net.flow.DefaultTrafficTreatment; import org.onosproject.net.flow.TrafficTreatment; -import org.onosproject.net.flow.instructions.Instruction; -import org.onosproject.net.flow.instructions.Instructions; import org.onosproject.net.host.HostProvider; import org.onosproject.net.host.InterfaceIpAddress; import org.onosproject.net.packet.DefaultOutboundPacket; import org.onosproject.net.packet.OutboundPacket; import org.onosproject.net.packet.PacketService; import org.onosproject.net.provider.ProviderId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.nio.ByteBuffer; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -60,9 +59,13 @@ import java.util.concurrent.TimeUnit; * </p> */ public class HostMonitor implements TimerTask { + + private Logger log = LoggerFactory.getLogger(getClass()); + private PacketService packetService; private HostManager hostManager; private InterfaceService interfaceService; + private EdgePortService edgePortService; private final Set<IpAddress> monitoredAddresses; @@ -83,11 +86,13 @@ public class HostMonitor implements TimerTask { * @param interfaceService interface service for interface information */ public HostMonitor(PacketService packetService, HostManager hostManager, - InterfaceService interfaceService) { + InterfaceService interfaceService, + EdgePortService edgePortService) { this.packetService = packetService; this.hostManager = hostManager; this.interfaceService = interfaceService; + this.edgePortService = edgePortService; monitoredAddresses = Collections.newSetFromMap(new ConcurrentHashMap<>()); hostProviders = new ConcurrentHashMap<>(); @@ -149,7 +154,7 @@ public class HostMonitor implements TimerTask { Set<Host> hosts = hostManager.getHostsByIp(ip); if (hosts.isEmpty()) { - sendArpNdpRequest(ip); + sendRequest(ip); } else { for (Host host : hosts) { HostProvider provider = hostProviders.get(host.providerId()); @@ -166,45 +171,44 @@ public class HostMonitor implements TimerTask { } /** - * Sends an ARP or Neighbor Discovery Protocol request for the given IP - * address. + * Sends an ARP or NDP request for the given IP address. * * @param targetIp IP address to send the request for */ - private void sendArpNdpRequest(IpAddress targetIp) { + private void sendRequest(IpAddress targetIp) { Interface intf = interfaceService.getMatchingInterface(targetIp); if (intf == null) { return; } + if (!edgePortService.isEdgePoint(intf.connectPoint())) { + log.warn("Attempt to send probe out non-edge port: {}", intf); + return; + } + for (InterfaceIpAddress ia : intf.ipAddresses()) { if (ia.subnetAddress().contains(targetIp)) { - sendArpNdpProbe(intf.connectPoint(), targetIp, ia.ipAddress(), + sendProbe(intf.connectPoint(), targetIp, ia.ipAddress(), intf.mac(), intf.vlan()); } } } - private void sendArpNdpProbe(ConnectPoint connectPoint, - IpAddress targetIp, - IpAddress sourceIp, MacAddress sourceMac, - VlanId vlan) { + private void sendProbe(ConnectPoint connectPoint, + IpAddress targetIp, + IpAddress sourceIp, MacAddress sourceMac, + VlanId vlan) { Ethernet probePacket = null; if (targetIp.isIp4()) { // IPv4: Use ARP - probePacket = buildArpRequest(targetIp, sourceIp, sourceMac, - vlan); + probePacket = buildArpRequest(targetIp, sourceIp, sourceMac, vlan); } else { // IPv6: Use Neighbor Discovery - probePacket = buildNdpRequest(targetIp, sourceIp, sourceMac, - vlan); + probePacket = buildNdpRequest(targetIp, sourceIp, sourceMac, vlan); } - List<Instruction> instructions = new ArrayList<>(); - instructions.add(Instructions.createOutput(connectPoint.port())); - TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setOutput(connectPoint.port()) .build(); @@ -273,7 +277,7 @@ public class HostMonitor implements TimerTask { icmp6.setIcmpType(ICMP6.NEIGHBOR_SOLICITATION); icmp6.setIcmpCode((byte) 0); - // Create the Neighbor Solication packet + // Create the Neighbor Solicitation packet NeighborSolicitation ns = new NeighborSolicitation(); ns.setTargetAddress(targetIp.toOctets()); ns.addOption(NeighborDiscoveryOptions.TYPE_SOURCE_LL_ADDRESS, diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java index 609f9a34..52621e2f 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java @@ -1,3 +1,18 @@ +/* + * 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.net.intent.impl.compiler; import static java.util.Arrays.asList; diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java index c60325a7..05a20f96 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java @@ -51,7 +51,6 @@ import org.onosproject.net.resource.link.LinkResourceRequest; import org.onosproject.net.resource.link.LinkResourceService; import org.onosproject.net.topology.LinkWeight; import org.onosproject.net.topology.Topology; -import org.onosproject.net.topology.TopologyEdge; import org.onosproject.net.topology.TopologyService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -265,34 +264,31 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical private Set<Path> getOpticalPaths(OpticalConnectivityIntent intent) { // Route in WDM topology Topology topology = topologyService.currentTopology(); - LinkWeight weight = new LinkWeight() { - @Override - public double weight(TopologyEdge edge) { - // Disregard inactive or non-optical links - if (edge.link().state() == Link.State.INACTIVE) { - return -1; - } - if (edge.link().type() != Link.Type.OPTICAL) { - return -1; - } - // Adhere to static port mappings - DeviceId srcDeviceId = edge.link().src().deviceId(); - if (srcDeviceId.equals(intent.getSrc().deviceId())) { - ConnectPoint srcStaticPort = staticPort(intent.getSrc()); - if (srcStaticPort != null) { - return srcStaticPort.equals(edge.link().src()) ? 1 : -1; - } + LinkWeight weight = edge -> { + // Disregard inactive or non-optical links + if (edge.link().state() == Link.State.INACTIVE) { + return -1; + } + if (edge.link().type() != Link.Type.OPTICAL) { + return -1; + } + // Adhere to static port mappings + DeviceId srcDeviceId = edge.link().src().deviceId(); + if (srcDeviceId.equals(intent.getSrc().deviceId())) { + ConnectPoint srcStaticPort = staticPort(intent.getSrc()); + if (srcStaticPort != null) { + return srcStaticPort.equals(edge.link().src()) ? 1 : -1; } - DeviceId dstDeviceId = edge.link().dst().deviceId(); - if (dstDeviceId.equals(intent.getDst().deviceId())) { - ConnectPoint dstStaticPort = staticPort(intent.getDst()); - if (dstStaticPort != null) { - return dstStaticPort.equals(edge.link().dst()) ? 1 : -1; - } + } + DeviceId dstDeviceId = edge.link().dst().deviceId(); + if (dstDeviceId.equals(intent.getDst().deviceId())) { + ConnectPoint dstStaticPort = staticPort(intent.getDst()); + if (dstStaticPort != null) { + return dstStaticPort.equals(edge.link().dst()) ? 1 : -1; } - - return 1; } + + return 1; }; ConnectPoint start = intent.getSrc(); diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java index a6b08f62..801092f4 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java @@ -16,12 +16,14 @@ package org.onosproject.net.link.impl; import static org.slf4j.LoggerFactory.getLogger; +import static com.google.common.base.Preconditions.checkNotNull; import java.time.Duration; import org.onosproject.net.AnnotationKeys; import org.onosproject.net.config.ConfigOperator; import org.onosproject.net.config.basics.BasicLinkConfig; +import org.onosproject.net.ConnectPoint; import org.onosproject.net.DefaultAnnotations; import org.onosproject.net.Link; import org.onosproject.net.SparseAnnotations; @@ -81,6 +83,46 @@ public final class BasicLinkOperator implements ConfigOperator { if (cfg.bandwidth() != DEF_BANDWIDTH) { b.set(AnnotationKeys.BANDWIDTH, String.valueOf(cfg.bandwidth())); } + if (cfg.isDurable() != null) { + b.set(AnnotationKeys.DURABLE, String.valueOf(cfg.isDurable())); + } return DefaultAnnotations.union(an, b.build()); } + + /** + * Generates a link description from a link description entity. The endpoints + * must be specified to indicate directionality. + * + * @param src the source ConnectPoint + * @param dst the destination ConnectPoint + * @param link the link config entity + * @return a linkDescription based on the config + */ + public static LinkDescription descriptionOf( + ConnectPoint src, ConnectPoint dst, Link link) { + checkNotNull(src, "Must supply a source endpoint"); + checkNotNull(dst, "Must supply a destination endpoint"); + checkNotNull(link, "Must supply a link"); + return new DefaultLinkDescription( + src, dst, link.type(), (SparseAnnotations) link.annotations()); + } + + /** + * Generates a link description from a link config entity. This is for + * links that cannot be discovered and has to be injected. The endpoints + * must be specified to indicate directionality. + * + * @param src the source ConnectPoint + * @param dst the destination ConnectPoint + * @param link the link config entity + * @return a linkDescription based on the config + */ + public static LinkDescription descriptionOf( + ConnectPoint src, ConnectPoint dst, BasicLinkConfig link) { + checkNotNull(src, "Must supply a source endpoint"); + checkNotNull(dst, "Must supply a destination endpoint"); + checkNotNull(link, "Must supply a link config"); + return new DefaultLinkDescription( + src, dst, link.type(), combine(link, DefaultAnnotations.EMPTY)); + } } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java index 157288a4..d6f72fd9 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java @@ -15,9 +15,9 @@ */ package org.onosproject.net.link.impl; -import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; import com.google.common.collect.Sets; + import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @@ -25,6 +25,7 @@ import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.Service; import org.onosproject.net.provider.AbstractListenerProviderRegistry; +import org.onosproject.net.provider.ProviderId; import org.onosproject.net.config.NetworkConfigEvent; import org.onosproject.net.config.NetworkConfigListener; import org.onosproject.net.config.NetworkConfigService; @@ -54,7 +55,6 @@ import org.slf4j.Logger; import java.util.Set; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; import static org.onosproject.net.LinkKey.linkKey; import static org.onosproject.security.AppGuard.checkPermission; import static org.slf4j.LoggerFactory.getLogger; @@ -125,13 +125,7 @@ public class LinkManager public Iterable<Link> getActiveLinks() { checkPermission(LINK_READ); return FluentIterable.from(getLinks()) - .filter(new Predicate<Link>() { - - @Override - public boolean apply(Link input) { - return input.state() == State.ACTIVE; - } - }); + .filter(input -> input.state() == State.ACTIVE); } @Override @@ -207,6 +201,10 @@ public class LinkManager post(store.removeLink(src, dst)); } + private boolean isAllowed(BasicLinkConfig cfg) { + return (cfg == null || cfg.isAllowed()); + } + // Auxiliary interceptor for device remove events to prune links that // are associated with the removed device or its port. private class InternalDeviceListener implements DeviceListener { @@ -240,11 +238,12 @@ public class LinkManager checkNotNull(linkDescription, LINK_DESC_NULL); checkValidity(); linkDescription = validateLink(linkDescription); - LinkEvent event = store.createOrUpdateLink(provider().id(), - linkDescription); - if (event != null) { - log.info("Link {} detected", linkDescription); - post(event); + if (linkDescription != null) { + LinkEvent event = store.createOrUpdateLink(provider().id(), linkDescription); + if (event != null) { + log.info("Link {} detected", linkDescription); + post(event); + } } } @@ -258,11 +257,12 @@ public class LinkManager BasicLinkConfig cfgTwo = networkConfigService.getConfig(linkKey(linkDescription.dst(), linkDescription.src()), BasicLinkConfig.class); - - checkState(cfg == null || cfg.isAllowed(), "Link " + linkDescription.toString() + " is not allowed"); - checkState(cfgTwo == null || cfgTwo.isAllowed(), "Link " + linkDescription.toString() + " is not allowed"); - - return BasicLinkOperator.combine(cfg, linkDescription); + if (isAllowed(cfg) && isAllowed(cfgTwo)) { + return BasicLinkOperator.combine(cfg, linkDescription); + } else { + log.trace("Link " + linkDescription.toString() + " is not allowed"); + return null; + } } @Override @@ -324,20 +324,41 @@ public class LinkManager // listens for NetworkConfigEvents of type BasicLinkConfig and removes // links that the config does not allow private class InternalNetworkConfigListener implements NetworkConfigListener { + + @Override + public boolean isRelevant(NetworkConfigEvent event) { + return event.configClass().equals(BasicLinkConfig.class) + && (event.type() == NetworkConfigEvent.Type.CONFIG_ADDED + || event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED); + } + @Override public void event(NetworkConfigEvent event) { - if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED || - event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) && - event.configClass().equals(BasicLinkConfig.class)) { - log.info("Detected Link network config event {}", event.type()); - LinkKey lk = (LinkKey) event.subject(); - BasicLinkConfig cfg = networkConfigService.getConfig(lk, BasicLinkConfig.class); - if (cfg != null && !cfg.isAllowed()) { - log.info("Kicking out links between {} and {}", lk.src(), lk.dst()); - removeLink(lk.src(), lk.dst()); - removeLink(lk.dst(), lk.src()); - } + LinkKey lk = (LinkKey) event.subject(); + BasicLinkConfig cfg = networkConfigService.getConfig(lk, BasicLinkConfig.class); + + if (!isAllowed(cfg)) { + log.info("Kicking out links between {} and {}", lk.src(), lk.dst()); + removeLink(lk.src(), lk.dst()); + removeLink(lk.dst(), lk.src()); + return; } + Link link = getLink(lk.src(), lk.dst()); + LinkDescription fldesc; + LinkDescription rldesc; + if (link == null) { + fldesc = BasicLinkOperator.descriptionOf(lk.src(), lk.dst(), cfg); + rldesc = BasicLinkOperator.descriptionOf(lk.dst(), lk.src(), cfg); + } else { + fldesc = BasicLinkOperator.combine(cfg, + BasicLinkOperator.descriptionOf(lk.src(), lk.dst(), link)); + rldesc = BasicLinkOperator.combine(cfg, + BasicLinkOperator.descriptionOf(lk.dst(), lk.src(), link)); + } + // XXX think of sane way to fetch the LinkProvider + store.createOrUpdateLink(ProviderId.NONE, fldesc); + store.createOrUpdateLink(ProviderId.NONE, rldesc); } + } } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java index 75239fdd..a0bc693c 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java @@ -15,6 +15,7 @@ */ package org.onosproject.net.packet.impl; +import com.google.common.collect.ImmutableMap; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @@ -53,6 +54,7 @@ import org.onosproject.net.provider.AbstractProviderRegistry; import org.onosproject.net.provider.AbstractProviderService; import org.slf4j.Logger; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; @@ -61,8 +63,8 @@ import java.util.concurrent.Executors; import static com.google.common.base.Preconditions.checkNotNull; import static org.onlab.util.Tools.groupedThreads; import static org.onosproject.security.AppGuard.checkPermission; -import static org.slf4j.LoggerFactory.getLogger; import static org.onosproject.security.AppPermission.Type.*; +import static org.slf4j.LoggerFactory.getLogger; /** * Provides a basic implementation of the packet SB & NB APIs. @@ -138,6 +140,11 @@ public class PacketManager } @Override + public Map<Integer, PacketProcessor> getProcessors() { + return ImmutableMap.copyOf(processors); + } + + @Override public void requestPackets(TrafficSelector selector, PacketPriority priority, ApplicationId appId) { checkPermission(PACKET_READ); @@ -163,6 +170,11 @@ public class PacketManager } } + @Override + public List<PacketRequest> getRequests() { + return store.existingRequests(); + } + /** * Pushes a packet request flow rule to all devices. * diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/proxyarp/impl/ProxyArpManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/proxyarp/impl/ProxyArpManager.java index 398260ff..25a2640d 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/proxyarp/impl/ProxyArpManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/proxyarp/impl/ProxyArpManager.java @@ -69,11 +69,9 @@ public class ProxyArpManager implements ProxyArpService { private final Logger log = getLogger(getClass()); - private static final String MAC_ADDR_NULL = "Mac address cannot be null."; + private static final String MAC_ADDR_NULL = "MAC address cannot be null."; private static final String REQUEST_NULL = "ARP or NDP request cannot be null."; - private static final String REQUEST_NOT_ARP = "Ethernet frame does not contain ARP request."; - private static final String NOT_ARP_REQUEST = "ARP is not a request."; - private static final String NOT_ARP_REPLY = "ARP is not a reply."; + private static final String MSG_NOT_REQUEST = "Message is not an ARP or NDP request"; @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected EdgePortService edgeService; @@ -96,6 +94,14 @@ public class ProxyArpManager implements ProxyArpService { @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected InterfaceService interfaceService; + private enum Protocol { + ARP, NDP + } + + private enum MessageType { + REQUEST, REPLY + } + @Activate public void activate() { store.setDelegate(this::sendTo); @@ -123,46 +129,48 @@ public class ProxyArpManager implements ProxyArpService { checkNotNull(eth, REQUEST_NULL); - if (eth.getEtherType() == Ethernet.TYPE_ARP) { - replyArp(eth, inPort); - } else if (eth.getEtherType() == Ethernet.TYPE_IPV6) { - replyNdp(eth, inPort); + MessageContext context = createContext(eth, inPort); + if (context != null) { + replyInternal(context); } } - private void replyArp(Ethernet eth, ConnectPoint inPort) { - ARP arp = (ARP) eth.getPayload(); - checkArgument(arp.getOpCode() == ARP.OP_REQUEST, NOT_ARP_REQUEST); - checkNotNull(inPort); - Ip4Address targetAddress = Ip4Address.valueOf(arp.getTargetProtocolAddress()); - - VlanId vlan = vlanId(eth.getVlanID()); + /** + * Handles a request message. + * + * If the MAC address of the target is known, we can reply directly to the + * requestor. Otherwise, we forward the request out other ports in an + * attempt to find the correct host. + * + * @param context request message context to process + */ + private void replyInternal(MessageContext context) { + checkNotNull(context); + checkArgument(context.type() == MessageType.REQUEST, MSG_NOT_REQUEST); - if (hasIpAddress(inPort)) { + if (hasIpAddress(context.inPort())) { // If the request came from outside the network, only reply if it was // for one of our external addresses. - interfaceService.getInterfacesByPort(inPort) + interfaceService.getInterfacesByPort(context.inPort()) .stream() .filter(intf -> intf.ipAddresses() .stream() - .anyMatch(ia -> ia.ipAddress().equals(targetAddress))) - .forEach(intf -> buildAndSendArp(targetAddress, intf.mac(), eth, inPort)); + .anyMatch(ia -> ia.ipAddress().equals(context.target()))) + .forEach(intf -> buildAndSendReply(context, intf.mac())); // Stop here and don't proxy ARPs if the port has an IP address return; } // See if we have the target host in the host store - - Set<Host> hosts = hostService.getHostsByIp(targetAddress); + Set<Host> hosts = hostService.getHostsByIp(context.target()); Host dst = null; - Host src = hostService.getHost(hostId(eth.getSourceMAC(), - vlanId(eth.getVlanID()))); + Host src = hostService.getHost(hostId(context.srcMac(), context.vlan())); for (Host host : hosts) { - if (host.vlan().equals(vlan)) { + if (host.vlan().equals(context.vlan())) { dst = host; break; } @@ -170,22 +178,19 @@ public class ProxyArpManager implements ProxyArpService { if (src != null && dst != null) { // We know the target host so we can respond - buildAndSendArp(targetAddress, dst.mac(), eth, inPort); + buildAndSendReply(context, dst.mac()); return; } // If the source address matches one of our external addresses // it could be a request from an internal host to an external // address. Forward it over to the correct port. - Ip4Address source = - Ip4Address.valueOf(arp.getSenderProtocolAddress()); - boolean matched = false; - Set<Interface> interfaces = interfaceService.getInterfacesByIp(source); + Set<Interface> interfaces = interfaceService.getInterfacesByIp(context.sender()); for (Interface intf : interfaces) { - if (intf.vlan().equals(vlan)) { + if (intf.vlan().equals(context.vlan())) { matched = true; - sendTo(eth, intf.connectPoint()); + sendTo(context.packet(), intf.connectPoint()); break; } } @@ -196,89 +201,33 @@ public class ProxyArpManager implements ProxyArpService { // The request couldn't be resolved. // Flood the request on all ports except the incoming port. - flood(eth, inPort); + flood(context.packet(), context.inPort()); } - private void replyNdp(Ethernet eth, ConnectPoint inPort) { - IPv6 ipv6 = (IPv6) eth.getPayload(); - ICMP6 icmpv6 = (ICMP6) ipv6.getPayload(); - NeighborSolicitation nsol = (NeighborSolicitation) icmpv6.getPayload(); - Ip6Address targetAddress = Ip6Address.valueOf(nsol.getTargetAddress()); - - VlanId vlan = vlanId(eth.getVlanID()); - - // If the request came from outside the network, only reply if it was - // for one of our external addresses. - if (hasIpAddress(inPort)) { - interfaceService.getInterfacesByPort(inPort) - .stream() - .filter(intf -> intf.ipAddresses() - .stream() - .anyMatch(ia -> ia.ipAddress().equals(targetAddress))) - .forEach(intf -> buildAndSendNdp(targetAddress, intf.mac(), eth, inPort)); - return; - } - - // Continue with normal proxy ARP case - - Set<Host> hosts = hostService.getHostsByIp(targetAddress); - - Host dst = null; - Host src = hostService.getHost(hostId(eth.getSourceMAC(), - vlanId(eth.getVlanID()))); - - for (Host host : hosts) { - if (host.vlan().equals(vlan)) { - dst = host; - break; - } - } - - if (src != null && dst != null) { - // We know the target host so we can respond - buildAndSendNdp(targetAddress, dst.mac(), eth, inPort); - return; - } - - // If the source address matches one of our external addresses - // it could be a request from an internal host to an external - // address. Forward it over to the correct port. - Ip6Address source = - Ip6Address.valueOf(ipv6.getSourceAddress()); - - boolean matched = false; - - Set<Interface> interfaces = interfaceService.getInterfacesByIp(source); - for (Interface intf : interfaces) { - if (intf.vlan().equals(vlan)) { - matched = true; - sendTo(eth, intf.connectPoint()); - break; - } - } - - if (matched) { - return; + /** + * Builds and sends a reply message given a request context and the resolved + * MAC address to answer with. + * + * @param context message context of request + * @param targetMac MAC address to be given in the response + */ + private void buildAndSendReply(MessageContext context, MacAddress targetMac) { + switch (context.protocol()) { + case ARP: + sendTo(ARP.buildArpReply((Ip4Address) context.target(), + targetMac, context.packet()), context.inPort()); + break; + case NDP: + sendTo(buildNdpReply((Ip6Address) context.target(), targetMac, + context.packet()), context.inPort()); + break; + default: + break; } - - // The request couldn't be resolved. - // Flood the request on all ports except the incoming ports. - flood(eth, inPort); - } - //TODO checkpoint - - private void buildAndSendArp(Ip4Address srcIp, MacAddress srcMac, - Ethernet request, ConnectPoint port) { - sendTo(ARP.buildArpReply(srcIp, srcMac, request), port); - } - - private void buildAndSendNdp(Ip6Address srcIp, MacAddress srcMac, - Ethernet request, ConnectPoint port) { - sendTo(buildNdpReply(srcIp, srcMac, request), port); } /** - * Outputs the given packet out the given port. + * Outputs a packet out a specific port. * * @param packet the packet to send * @param outPort the port to send it out @@ -287,6 +236,12 @@ public class ProxyArpManager implements ProxyArpService { sendTo(outPort, ByteBuffer.wrap(packet.serialize())); } + /** + * Outputs a packet out a specific port. + * + * @param outPort port to send it out + * @param packet packet to send + */ private void sendTo(ConnectPoint outPort, ByteBuffer packet) { if (!edgeService.isEdgePoint(outPort)) { // Sanity check to make sure we don't send the packet out an @@ -298,7 +253,7 @@ public class ProxyArpManager implements ProxyArpService { TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); builder.setOutput(outPort.port()); packetService.emit(new DefaultOutboundPacket(outPort.deviceId(), - builder.build(), packet)); + builder.build(), packet)); } /** @@ -323,7 +278,7 @@ public class ProxyArpManager implements ProxyArpService { checkNotNull(eth, REQUEST_NULL); Host h = hostService.getHost(hostId(eth.getDestinationMAC(), - vlanId(eth.getVlanID()))); + vlanId(eth.getVlanID()))); if (h == null) { flood(eth, inPort); @@ -344,42 +299,24 @@ public class ProxyArpManager implements ProxyArpService { if (ethPkt == null) { return false; } - if (ethPkt.getEtherType() == Ethernet.TYPE_ARP) { - return handleArp(context, ethPkt); - } else if (ethPkt.getEtherType() == Ethernet.TYPE_IPV6) { - return handleNdp(context, ethPkt); - } - return false; - } - private boolean handleArp(PacketContext context, Ethernet ethPkt) { - ARP arp = (ARP) ethPkt.getPayload(); + MessageContext msgContext = createContext(ethPkt, pkt.receivedFrom()); - if (arp.getOpCode() == ARP.OP_REPLY) { - forward(ethPkt, context.inPacket().receivedFrom()); - } else if (arp.getOpCode() == ARP.OP_REQUEST) { - reply(ethPkt, context.inPacket().receivedFrom()); - } else { + if (msgContext == null) { return false; } - context.block(); - return true; - } - private boolean handleNdp(PacketContext context, Ethernet ethPkt) { - IPv6 ipv6 = (IPv6) ethPkt.getPayload(); - - if (ipv6.getNextHeader() != IPv6.PROTOCOL_ICMP6) { - return false; - } - ICMP6 icmpv6 = (ICMP6) ipv6.getPayload(); - if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_ADVERTISEMENT) { - forward(ethPkt, context.inPacket().receivedFrom()); - } else if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_SOLICITATION) { - reply(ethPkt, context.inPacket().receivedFrom()); - } else { + switch (msgContext.type()) { + case REPLY: + forward(msgContext.packet(), msgContext.inPort()); + break; + case REQUEST: + replyInternal(msgContext); + break; + default: return false; } + context.block(); return true; } @@ -444,4 +381,148 @@ public class ProxyArpManager implements ProxyArpService { eth.setPayload(ipv6); return eth; } + + /** + * Attempts to create a MessageContext for the given Ethernet frame. If the + * frame is a valid ARP or NDP request or response, a context will be + * created. + * + * @param eth input Ethernet frame + * @param inPort in port + * @return MessageContext if the packet was ARP or NDP, otherwise null + */ + private MessageContext createContext(Ethernet eth, ConnectPoint inPort) { + if (eth.getEtherType() == Ethernet.TYPE_ARP) { + return createArpContext(eth, inPort); + } else if (eth.getEtherType() == Ethernet.TYPE_IPV6) { + return createNdpContext(eth, inPort); + } + + return null; + } + + /** + * Extracts context information from ARP packets. + * + * @param eth input Ethernet frame that is thought to be ARP + * @param inPort in port + * @return MessageContext object if the packet was a valid ARP packet, + * otherwise null + */ + private MessageContext createArpContext(Ethernet eth, ConnectPoint inPort) { + if (eth.getEtherType() != Ethernet.TYPE_ARP) { + return null; + } + + ARP arp = (ARP) eth.getPayload(); + + IpAddress target = Ip4Address.valueOf(arp.getTargetProtocolAddress()); + IpAddress sender = Ip4Address.valueOf(arp.getSenderProtocolAddress()); + + MessageType type; + if (arp.getOpCode() == ARP.OP_REQUEST) { + type = MessageType.REQUEST; + } else if (arp.getOpCode() == ARP.OP_REPLY) { + type = MessageType.REPLY; + } else { + return null; + } + + return new MessageContext(eth, inPort, Protocol.ARP, type, target, sender); + } + + /** + * Extracts context information from NDP packets. + * + * @param eth input Ethernet frame that is thought to be NDP + * @param inPort in port + * @return MessageContext object if the packet was a valid NDP packet, + * otherwise null + */ + private MessageContext createNdpContext(Ethernet eth, ConnectPoint inPort) { + if (eth.getEtherType() != Ethernet.TYPE_IPV6) { + return null; + } + IPv6 ipv6 = (IPv6) eth.getPayload(); + + if (ipv6.getNextHeader() != IPv6.PROTOCOL_ICMP6) { + return null; + } + ICMP6 icmpv6 = (ICMP6) ipv6.getPayload(); + + IpAddress sender = Ip6Address.valueOf(ipv6.getSourceAddress()); + IpAddress target = null; + + MessageType type; + if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_SOLICITATION) { + type = MessageType.REQUEST; + NeighborSolicitation nsol = (NeighborSolicitation) icmpv6.getPayload(); + target = Ip6Address.valueOf(nsol.getTargetAddress()); + } else if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_ADVERTISEMENT) { + type = MessageType.REPLY; + } else { + return null; + } + + return new MessageContext(eth, inPort, Protocol.NDP, type, target, sender); + } + + /** + * Provides context information for a particular ARP or NDP message, with + * a unified interface to access data regardless of protocol. + */ + private class MessageContext { + private Protocol protocol; + private MessageType type; + + private IpAddress target; + private IpAddress sender; + + private Ethernet eth; + private ConnectPoint inPort; + + + public MessageContext(Ethernet eth, ConnectPoint inPort, + Protocol protocol, MessageType type, + IpAddress target, IpAddress sender) { + this.eth = eth; + this.inPort = inPort; + this.protocol = protocol; + this.type = type; + this.target = target; + this.sender = sender; + } + + public ConnectPoint inPort() { + return inPort; + } + + public Ethernet packet() { + return eth; + } + + public Protocol protocol() { + return protocol; + } + + public MessageType type() { + return type; + } + + public VlanId vlan() { + return VlanId.vlanId(eth.getVlanID()); + } + + public MacAddress srcMac() { + return MacAddress.valueOf(eth.getSourceMACAddress()); + } + + public IpAddress target() { + return target; + } + + public IpAddress sender() { + return sender; + } + } } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java index 996ad14e..57964d69 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java @@ -348,12 +348,7 @@ public class StatisticManager implements StatisticService { * @return predicate */ private static Predicate<FlowEntry> hasApplicationId(ApplicationId appId) { - return new Predicate<FlowEntry>() { - @Override - public boolean apply(FlowEntry flowEntry) { - return flowEntry.appId() == appId.id(); - } - }; + return flowEntry -> flowEntry.appId() == appId.id(); } /** @@ -364,16 +359,13 @@ public class StatisticManager implements StatisticService { * @return predicate */ private static Predicate<FlowEntry> hasGroupId(Optional<GroupId> groupId) { - return new Predicate<FlowEntry>() { - @Override - public boolean apply(FlowEntry flowEntry) { - if (!groupId.isPresent()) { - return false; - } - // FIXME: The left hand type and right hand type don't match - // FlowEntry.groupId() still returns a short value, not int. - return flowEntry.groupId().equals(groupId.get()); + return flowEntry -> { + if (!groupId.isPresent()) { + return false; } + // FIXME: The left hand type and right hand type don't match + // FlowEntry.groupId() still returns a short value, not int. + return flowEntry.groupId().equals(groupId.get()); }; } } diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java index 8827c558..2be0df7a 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java @@ -24,7 +24,6 @@ import java.net.URI; import org.junit.Before; import org.junit.Test; import org.onlab.packet.ChassisId; -import org.onosproject.net.config.Config; import org.onosproject.net.config.ConfigApplyDelegate; import org.onosproject.net.config.basics.BasicDeviceConfig; import org.onosproject.net.AnnotationKeys; @@ -55,11 +54,7 @@ public class BasicDeviceOperatorTest { private static final DeviceDescription DEV1 = new DefaultDeviceDescription( DURI, SWITCH, MFR, HW, SW, SN, CID, SA); - private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() { - @Override - public void onApply(Config config) { - } - }; + private final ConfigApplyDelegate delegate = config -> { }; private final ObjectMapper mapper = new ObjectMapper(); private static final BasicDeviceConfig SW_BDC = new BasicDeviceConfig(); diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/OpticalPortOperatorTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/OpticalPortOperatorTest.java index 78bc08e0..ba40b2b1 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/OpticalPortOperatorTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/OpticalPortOperatorTest.java @@ -1,3 +1,18 @@ +/* + * 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.net.device.impl; import org.junit.Before; diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java index ae7cc874..73ce3936 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java @@ -276,10 +276,10 @@ public class GroupManagerTest { PortNumber[] addPorts = {PortNumber.portNumber(51), PortNumber.portNumber(52)}; List<PortNumber> outPorts; - outPorts = new ArrayList<PortNumber>(); + outPorts = new ArrayList<>(); outPorts.addAll(Arrays.asList(addPorts)); List<GroupBucket> addBuckets; - addBuckets = new ArrayList<GroupBucket>(); + addBuckets = new ArrayList<>(); for (PortNumber portNumber: outPorts) { TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); tBuilder.setOutput(portNumber) diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java index e7f14b5d..940ed919 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java @@ -22,7 +22,6 @@ import org.junit.Test; import org.onlab.packet.IpAddress; import org.onlab.packet.MacAddress; import org.onlab.packet.VlanId; -import org.onosproject.net.config.Config; import org.onosproject.net.config.ConfigApplyDelegate; import org.onosproject.net.config.basics.BasicHostConfig; import org.onosproject.net.AnnotationKeys; @@ -49,11 +48,7 @@ public class BasicHostOperatorTest { ); private static final HostDescription HOST = new DefaultHostDescription(MAC, VLAN, LOC, IP); - private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() { - @Override - public void onApply(Config config) { - } - }; + private final ConfigApplyDelegate delegate = config -> { }; private final ObjectMapper mapper = new ObjectMapper(); private static final BasicHostConfig BHC = new BasicHostConfig(); diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostManagerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostManagerTest.java index dbb807f8..92c6c931 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostManagerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostManagerTest.java @@ -15,36 +15,22 @@ */ package org.onosproject.net.host.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.onosproject.net.NetTestTools.injectEventDispatcher; -import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; -import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED; -import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED; -import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED; - -import java.util.List; -import java.util.Set; - +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onlab.packet.IpAddress; -import org.onlab.packet.IpPrefix; import org.onlab.packet.MacAddress; import org.onlab.packet.VlanId; -import org.onosproject.event.Event; import org.onosproject.common.event.impl.TestEventDispatcher; -import org.onosproject.net.config.NetworkConfigServiceAdapter; -import org.onosproject.net.ConnectPoint; +import org.onosproject.event.Event; import org.onosproject.net.DeviceId; import org.onosproject.net.Host; import org.onosproject.net.HostId; import org.onosproject.net.HostLocation; import org.onosproject.net.PortNumber; +import org.onosproject.net.config.NetworkConfigServiceAdapter; import org.onosproject.net.host.DefaultHostDescription; import org.onosproject.net.host.HostDescription; import org.onosproject.net.host.HostEvent; @@ -52,14 +38,23 @@ import org.onosproject.net.host.HostListener; import org.onosproject.net.host.HostProvider; import org.onosproject.net.host.HostProviderRegistry; import org.onosproject.net.host.HostProviderService; -import org.onosproject.net.host.InterfaceIpAddress; -import org.onosproject.net.host.PortAddresses; import org.onosproject.net.provider.AbstractProvider; import org.onosproject.net.provider.ProviderId; import org.onosproject.store.trivial.SimpleHostStore; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; +import java.util.List; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.onosproject.net.NetTestTools.injectEventDispatcher; +import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; +import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED; +import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED; +import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED; /** * Test codifying the host service & host provider service contracts. @@ -90,27 +85,6 @@ public class HostManagerTest { private static final PortNumber P2 = PortNumber.portNumber(200); private static final HostLocation LOC1 = new HostLocation(DID1, P1, 123L); private static final HostLocation LOC2 = new HostLocation(DID1, P2, 123L); - private static final ConnectPoint CP1 = new ConnectPoint(DID1, P1); - private static final ConnectPoint CP2 = new ConnectPoint(DID2, P2); - - private static final InterfaceIpAddress IA1 = - new InterfaceIpAddress(IpAddress.valueOf("10.1.1.1"), - IpPrefix.valueOf("10.1.1.0/24")); - private static final InterfaceIpAddress IA2 = - new InterfaceIpAddress(IpAddress.valueOf("10.2.2.2"), - IpPrefix.valueOf("10.2.0.0/16")); - private static final InterfaceIpAddress IA3 = - new InterfaceIpAddress(IpAddress.valueOf("10.3.3.3"), - IpPrefix.valueOf("10.3.3.0/24")); - private static final InterfaceIpAddress IA4 = - new InterfaceIpAddress(IpAddress.valueOf("2001:100::1"), - IpPrefix.valueOf("2001:100::/56")); - private static final InterfaceIpAddress IA5 = - new InterfaceIpAddress(IpAddress.valueOf("2001:200::1"), - IpPrefix.valueOf("2001:200::/48")); - private static final InterfaceIpAddress IA6 = - new InterfaceIpAddress(IpAddress.valueOf("2001:300::1"), - IpPrefix.valueOf("2001:300::/56")); private HostManager mgr; @@ -290,240 +264,6 @@ public class HostManagerTest { } - @Test - public void bindAddressesToPort() { - PortAddresses add1 = - new PortAddresses(CP1, Sets.newHashSet(IA1, IA2), MAC1, VlanId.NONE); - - mgr.bindAddressesToPort(add1); - Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - - // Add some more addresses and check that they're added correctly - PortAddresses add2 = - new PortAddresses(CP1, Sets.newHashSet(IA3), null, - VlanId.vlanId((short) 2)); - - mgr.bindAddressesToPort(add2); - storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(2, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - assertTrue(storedAddresses.contains(add2)); - - PortAddresses add3 = new PortAddresses(CP1, null, MAC2, VlanId.NONE); - - mgr.bindAddressesToPort(add3); - storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(3, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - assertTrue(storedAddresses.contains(add2)); - assertTrue(storedAddresses.contains(add3)); - } - - @Test - public void bindAddressesToPortIPv6() { - PortAddresses add1 = - new PortAddresses(CP1, Sets.newHashSet(IA4, IA5), MAC3, VlanId.NONE); - - mgr.bindAddressesToPort(add1); - Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - - // Add some more addresses and check that they're added correctly - PortAddresses add2 = - new PortAddresses(CP1, Sets.newHashSet(IA6), null, - VlanId.vlanId((short) 2)); - - mgr.bindAddressesToPort(add2); - storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(2, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - assertTrue(storedAddresses.contains(add2)); - - PortAddresses add3 = new PortAddresses(CP1, null, MAC4, VlanId.NONE); - - mgr.bindAddressesToPort(add3); - storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(3, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - assertTrue(storedAddresses.contains(add2)); - assertTrue(storedAddresses.contains(add3)); - } - - @Test - public void unbindAddressesFromPort() { - PortAddresses add1 = - new PortAddresses(CP1, Sets.newHashSet(IA1, IA2), MAC1, VlanId.NONE); - - mgr.bindAddressesToPort(add1); - Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - - PortAddresses rem1 = - new PortAddresses(CP1, Sets.newHashSet(IA1), null, VlanId.NONE); - - mgr.unbindAddressesFromPort(rem1); - storedAddresses = mgr.getAddressBindingsForPort(CP1); - - // It shouldn't have been removed because it didn't match the originally - // submitted address object - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - - mgr.unbindAddressesFromPort(add1); - storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertTrue(storedAddresses.isEmpty()); - } - - @Test - public void unbindAddressesFromPortIPv6() { - PortAddresses add1 = - new PortAddresses(CP1, Sets.newHashSet(IA4, IA5), MAC3, VlanId.NONE); - - mgr.bindAddressesToPort(add1); - Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - - PortAddresses rem1 = - new PortAddresses(CP1, Sets.newHashSet(IA4), null, VlanId.NONE); - - mgr.unbindAddressesFromPort(rem1); - storedAddresses = mgr.getAddressBindingsForPort(CP1); - - // It shouldn't have been removed because it didn't match the originally - // submitted address object - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - - mgr.unbindAddressesFromPort(add1); - storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertTrue(storedAddresses.isEmpty()); - } - - @Test - public void clearAddresses() { - PortAddresses add1 = - new PortAddresses(CP1, Sets.newHashSet(IA1, IA2), MAC1, VlanId.NONE); - - mgr.bindAddressesToPort(add1); - Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - - mgr.clearAddresses(CP1); - storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertTrue(storedAddresses.isEmpty()); - } - - @Test - public void clearAddressesIPv6() { - PortAddresses add1 = - new PortAddresses(CP1, Sets.newHashSet(IA4, IA5), MAC3, VlanId.NONE); - - mgr.bindAddressesToPort(add1); - Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - - mgr.clearAddresses(CP1); - storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertTrue(storedAddresses.isEmpty()); - } - - @Test - public void getAddressBindingsForPort() { - PortAddresses add1 = - new PortAddresses(CP1, Sets.newHashSet(IA1, IA2), MAC1, VlanId.NONE); - - mgr.bindAddressesToPort(add1); - Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - } - - @Test - public void getAddressBindingsForPortIPv6() { - PortAddresses add1 = - new PortAddresses(CP1, Sets.newHashSet(IA4, IA5), MAC3, VlanId.NONE); - - mgr.bindAddressesToPort(add1); - Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - } - - @Test - public void getAddressBindings() { - Set<PortAddresses> storedAddresses = mgr.getAddressBindings(); - - assertTrue(storedAddresses.isEmpty()); - - PortAddresses add1 = - new PortAddresses(CP1, Sets.newHashSet(IA1, IA2), MAC1, VlanId.NONE); - - mgr.bindAddressesToPort(add1); - - storedAddresses = mgr.getAddressBindings(); - - assertTrue(storedAddresses.size() == 1); - - PortAddresses add2 = - new PortAddresses(CP2, Sets.newHashSet(IA3), MAC2, VlanId.NONE); - - mgr.bindAddressesToPort(add2); - - storedAddresses = mgr.getAddressBindings(); - - assertTrue(storedAddresses.size() == 2); - assertTrue(storedAddresses.equals(Sets.newHashSet(add1, add2))); - } - - @Test - public void getAddressBindingsIPv6() { - Set<PortAddresses> storedAddresses = mgr.getAddressBindings(); - - assertTrue(storedAddresses.isEmpty()); - - PortAddresses add1 = - new PortAddresses(CP1, Sets.newHashSet(IA4, IA5), MAC3, VlanId.NONE); - - mgr.bindAddressesToPort(add1); - - storedAddresses = mgr.getAddressBindings(); - - assertTrue(storedAddresses.size() == 1); - - PortAddresses add2 = - new PortAddresses(CP2, Sets.newHashSet(IA5), MAC4, VlanId.NONE); - - mgr.bindAddressesToPort(add2); - - storedAddresses = mgr.getAddressBindings(); - - assertTrue(storedAddresses.size() == 2); - assertTrue(storedAddresses.equals(Sets.newHashSet(add1, add2))); - } - private class TestNetworkConfigService extends NetworkConfigServiceAdapter { } } diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java index d6ff473a..d167197a 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java @@ -19,6 +19,7 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.onlab.packet.ARP; import org.onlab.packet.Ethernet; @@ -37,11 +38,11 @@ import org.onosproject.net.Port; import org.onosproject.net.PortNumber; import org.onosproject.net.device.DeviceListener; import org.onosproject.net.device.DeviceServiceAdapter; +import org.onosproject.net.edge.EdgePortService; import org.onosproject.net.flow.instructions.Instruction; import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; import org.onosproject.net.host.HostProvider; import org.onosproject.net.host.InterfaceIpAddress; -import org.onosproject.net.host.PortAddresses; import org.onosproject.net.packet.OutboundPacket; import org.onosproject.net.packet.PacketServiceAdapter; import org.onosproject.net.provider.ProviderId; @@ -51,6 +52,7 @@ import java.util.Collections; import java.util.List; import java.util.Set; +import static org.easymock.EasyMock.anyObject; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.expectLastCall; @@ -70,8 +72,18 @@ public class HostMonitorTest { new InterfaceIpAddress(SOURCE_ADDR, IpPrefix.valueOf("10.0.0.0/24")); private MacAddress sourceMac = MacAddress.valueOf(1L); + private EdgePortService edgePortService; + private HostMonitor hostMonitor; + @Before + public void setUp() { + edgePortService = createMock(EdgePortService.class); + expect(edgePortService.isEdgePoint(anyObject(ConnectPoint.class))) + .andReturn(true).anyTimes(); + replay(edgePortService); + } + @After public void shutdown() { hostMonitor.shutdown(); @@ -96,7 +108,7 @@ public class HostMonitorTest { expectLastCall().once(); replay(hostProvider); - hostMonitor = new HostMonitor(null, hostManager, null); + hostMonitor = new HostMonitor(null, hostManager, null, edgePortService); hostMonitor.registerHostProvider(hostProvider); hostMonitor.addMonitoringFor(TARGET_IP_ADDR); @@ -127,8 +139,6 @@ public class HostMonitorTest { deviceService.addDevice(device, Collections.singleton(port)); ConnectPoint cp = new ConnectPoint(devId, portNum); - PortAddresses pa = - new PortAddresses(cp, Collections.singleton(IA1), sourceMac, VlanId.NONE); expect(hostManager.getHostsByIp(TARGET_IP_ADDR)) .andReturn(Collections.emptySet()).anyTimes(); @@ -144,7 +154,7 @@ public class HostMonitorTest { // Run the test - hostMonitor = new HostMonitor(packetService, hostManager, interfaceService); + hostMonitor = new HostMonitor(packetService, hostManager, interfaceService, edgePortService); hostMonitor.addMonitoringFor(TARGET_IP_ADDR); hostMonitor.run(null); @@ -198,9 +208,6 @@ public class HostMonitorTest { deviceService.addDevice(device, Collections.singleton(port)); ConnectPoint cp = new ConnectPoint(devId, portNum); - PortAddresses pa = - new PortAddresses(cp, Collections.singleton(IA1), sourceMac, - VlanId.vlanId(vlan)); expect(hostManager.getHostsByIp(TARGET_IP_ADDR)) .andReturn(Collections.emptySet()).anyTimes(); @@ -216,7 +223,7 @@ public class HostMonitorTest { // Run the test - hostMonitor = new HostMonitor(packetService, hostManager, interfaceService); + hostMonitor = new HostMonitor(packetService, hostManager, interfaceService, edgePortService); hostMonitor.addMonitoringFor(TARGET_IP_ADDR); hostMonitor.run(null); diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java index 8bd29bf8..f23a049d 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java @@ -24,13 +24,11 @@ import org.onosproject.net.flow.FlowRule; import org.onosproject.net.flow.FlowRuleOperations; import org.onosproject.net.flow.FlowRuleServiceAdapter; +import java.util.Collections; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; -import static org.onosproject.net.flow.FlowRuleOperation.Type.REMOVE; - - public class MockFlowRuleService extends FlowRuleServiceAdapter { final Set<FlowRule> flows = Sets.newHashSet(); @@ -87,9 +85,7 @@ public class MockFlowRuleService extends FlowRuleServiceAdapter { @Override public void applyFlowRules(FlowRule... flowRules) { - for (FlowRule flow : flowRules) { - flows.add(flow); - } + Collections.addAll(flows, flowRules); } @Override diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java index 76b26f46..03a38a5a 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java @@ -1,3 +1,18 @@ +/* + * 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.net.intent.impl.compiler; import java.util.List; diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java index fe9e37cd..eadbb5c9 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals; import java.time.Duration; import org.junit.Before; import org.junit.Test; -import org.onosproject.net.config.Config; import org.onosproject.net.config.ConfigApplyDelegate; import org.onosproject.net.config.basics.BasicLinkConfig; import org.onosproject.net.AnnotationKeys; @@ -53,11 +52,7 @@ public class BasicLinkOperatorTest { private static final SparseAnnotations SA = DefaultAnnotations.builder() .set(AnnotationKeys.DURABLE, "true").build(); private static final LinkDescription LD = new DefaultLinkDescription(SRC, DST, Link.Type.DIRECT, SA); - private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() { - @Override - public void onApply(Config config) { - } - }; + private final ConfigApplyDelegate delegate = config -> { }; private final ObjectMapper mapper = new ObjectMapper(); private static final BasicLinkConfig BLC = new BasicLinkConfig(); diff --git a/framework/src/onos/core/pom.xml b/framework/src/onos/core/pom.xml index 0f7dd8c8..c4f25545 100644 --- a/framework/src/onos/core/pom.xml +++ b/framework/src/onos/core/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onosproject</groupId> <artifactId>onos</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/framework/src/onos/core/security/pom.xml b/framework/src/onos/core/security/pom.xml index 67e74a1e..8dbc6c0d 100644 --- a/framework/src/onos/core/security/pom.xml +++ b/framework/src/onos/core/security/pom.xml @@ -1,4 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> @@ -7,7 +22,7 @@ <parent> <artifactId>onos-core</artifactId> <groupId>org.onosproject</groupId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/DefaultPolicyBuilder.java b/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/DefaultPolicyBuilder.java index 8ae1a1ae..b043765a 100644 --- a/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/DefaultPolicyBuilder.java +++ b/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/DefaultPolicyBuilder.java @@ -1,3 +1,18 @@ +/* + * 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.security.impl; diff --git a/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/SecurityModeManager.java b/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/SecurityModeManager.java index 30b0f8bb..325f49be 100644 --- a/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/SecurityModeManager.java +++ b/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/SecurityModeManager.java @@ -1,3 +1,18 @@ +/* + * 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.security.impl; import com.google.common.collect.Lists; @@ -43,10 +58,11 @@ import org.slf4j.Logger; import static org.slf4j.LoggerFactory.getLogger; - - /** * Security-Mode ONOS management implementation. + * + * Note: Activating Security-Mode ONOS has significant performance implications in Drake. + * See the wiki for instructions on how to activate it. */ @Component(immediate = true) diff --git a/framework/src/onos/core/security/src/main/java/org/onosproject/security/store/package-info.java b/framework/src/onos/core/security/src/main/java/org/onosproject/security/store/package-info.java new file mode 100644 index 00000000..a47f8eaf --- /dev/null +++ b/framework/src/onos/core/security/src/main/java/org/onosproject/security/store/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** + * Security-Mode ONOS distributed store. + */ +package org.onosproject.security.store; diff --git a/framework/src/onos/core/store/dist/pom.xml b/framework/src/onos/core/store/dist/pom.xml index eb9c38a5..cc293da4 100644 --- a/framework/src/onos/core/store/dist/pom.xml +++ b/framework/src/onos/core/store/dist/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onosproject</groupId> <artifactId>onos-core-store</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/ClusterDefinitionManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/ClusterDefinitionManager.java index 4e28e3c2..8b0001d8 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/ClusterDefinitionManager.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/ClusterDefinitionManager.java @@ -1,3 +1,18 @@ +/* + * 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.store.cluster.impl; import com.google.common.collect.ImmutableSet; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/IOLoopMessagingManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/IOLoopMessagingManager.java index 9e52c3e3..ffdd25f2 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/IOLoopMessagingManager.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/IOLoopMessagingManager.java @@ -1,3 +1,18 @@ +/* + * 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.store.cluster.messaging.impl; import org.apache.felix.scr.annotations.Activate; 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 8b2cc8e2..9328817b 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 @@ -1,3 +1,18 @@ +/* + * 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.store.cluster.messaging.impl; import com.google.common.base.Strings; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapBackedJavaMap.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapBackedJavaMap.java index 58aca31a..5183924c 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapBackedJavaMap.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapBackedJavaMap.java @@ -1,3 +1,18 @@ +/* + * 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.store.consistent.impl; import java.util.Collection; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DatabaseManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DatabaseManager.java index b7c3794b..fbc2c88d 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DatabaseManager.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DatabaseManager.java @@ -47,7 +47,6 @@ import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.ReferencePolicy; import org.apache.felix.scr.annotations.Service; - import org.onosproject.app.ApplicationEvent; import org.onosproject.app.ApplicationListener; import org.onosproject.app.ApplicationService; @@ -252,7 +251,7 @@ public class DatabaseManager implements StorageService, StorageAdminService { log.info("Successfully closed databases."); } }); - maps.values().forEach(this::unregisterMap); + ImmutableList.copyOf(maps.values()).forEach(this::unregisterMap); if (applicationService != null) { applicationService.removeListener(appListener); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultDatabaseState.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultDatabaseState.java index 9d3505bd..9a55ffb1 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultDatabaseState.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultDatabaseState.java @@ -84,7 +84,7 @@ public class DefaultDatabaseState implements DatabaseState<String, byte[]> { } nextVersion = context.get("nextVersion"); if (nextVersion == null) { - nextVersion = new Long(0); + nextVersion = 0L; context.put("nextVersion", nextVersion); } } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java index e54b0ee5..7c3769a3 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java @@ -19,8 +19,6 @@ import static org.slf4j.LoggerFactory.getLogger; import java.util.Map; import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; - import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @@ -61,7 +59,6 @@ public class ConsistentApplicationIdStore implements ApplicationIdStore { private ConsistentMap<String, ApplicationId> registeredIds; private Map<String, ApplicationId> nameToAppIdCache = Maps.newConcurrentMap(); private Map<Short, ApplicationId> idToAppIdCache = Maps.newConcurrentMap(); - private ScheduledExecutorService executor; private static final Serializer SERIALIZER = Serializer.using(new KryoNamespace.Builder() .register(KryoNamespaces.API) @@ -88,7 +85,6 @@ public class ConsistentApplicationIdStore implements ApplicationIdStore { @Deactivate public void deactivate() { - executor.shutdown(); log.info("Stopped"); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java index 8913742d..c6f48a44 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java @@ -1,3 +1,18 @@ +/* + * 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.store.core.impl; import com.google.common.collect.Maps; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java index ccf0f326..6a667e32 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java @@ -1,3 +1,18 @@ +/* + * 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.store.core.impl; import static org.slf4j.LoggerFactory.getLogger; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java index fd7fcd80..23206725 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java @@ -82,7 +82,7 @@ class DeviceDescriptions { if (oldOne != null) { SparseAnnotations merged = union(oldOne.value().annotations(), newDesc.value().annotations()); - newOne = new Timestamped<DeviceDescription>( + newOne = new Timestamped<>( new DefaultDeviceDescription(newDesc.value(), merged), newDesc.timestamp()); } @@ -104,27 +104,27 @@ class DeviceDescriptions { switch (newDesc.value().type()) { case OMS: OmsPortDescription omsDesc = (OmsPortDescription) (newDesc.value()); - newOne = new Timestamped<PortDescription>( + newOne = new Timestamped<>( new OmsPortDescription( omsDesc, omsDesc.minFrequency(), omsDesc.maxFrequency(), omsDesc.grid(), merged), newDesc.timestamp()); break; case OCH: OchPortDescription ochDesc = (OchPortDescription) (newDesc.value()); - newOne = new Timestamped<PortDescription>( + newOne = new Timestamped<>( new OchPortDescription( ochDesc, ochDesc.signalType(), ochDesc.isTunable(), ochDesc.lambda(), merged), newDesc.timestamp()); break; case ODUCLT: OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value()); - newOne = new Timestamped<PortDescription>( + newOne = new Timestamped<>( new OduCltPortDescription( ocDesc, ocDesc.signalType(), merged), newDesc.timestamp()); break; default: - newOne = new Timestamped<PortDescription>( + newOne = new Timestamped<>( new DefaultPortDescription(newDesc.value(), merged), newDesc.timestamp()); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java index 6f93963a..3c3bbb65 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java @@ -1,3 +1,18 @@ +/* + * 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.store.device.impl; import com.google.common.base.MoreObjects; 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 63456433..973db494 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 @@ -15,7 +15,6 @@ */ package org.onosproject.store.device.impl; -import com.google.common.base.Function; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; @@ -564,13 +563,10 @@ public class GossipDeviceStore final DeviceDescriptions descs = device.get(providerId); List<PortDescription> mergedList = FluentIterable.from(portDescriptions) - .transform(new Function<PortDescription, PortDescription>() { - @Override - public PortDescription apply(PortDescription input) { - // lookup merged port description - return descs.getPortDesc(input.portNumber()).value(); - } - }).toList(); + .transform(input -> + // lookup merged port description + descs.getPortDesc(input.portNumber()).value() + ).toList(); merged = new Timestamped<>(mergedList, newTimestamp); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortFragmentId.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortFragmentId.java index ed0ccaa1..1ff05198 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortFragmentId.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortFragmentId.java @@ -41,7 +41,7 @@ public final class PortFragmentId { @Override public int hashCode() { return Objects.hash(providerId, deviceId, portNumber); - }; + } @Override public boolean equals(Object obj) { diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java index c80f8105..971f53db 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java @@ -1,3 +1,18 @@ +/* + * 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.store.device.impl; import com.google.common.base.MoreObjects; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/ReplicaInfoEvent.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/ReplicaInfoEvent.java index 5eafc7ed..962fe8f4 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/ReplicaInfoEvent.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/ReplicaInfoEvent.java @@ -60,5 +60,5 @@ public class ReplicaInfoEvent extends AbstractEvent<ReplicaInfoEvent.Type, Devic */ public ReplicaInfo replicaInfo() { return replicaInfo; - }; + } } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java index cf48dcb8..97333ebf 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java @@ -131,8 +131,7 @@ public class DistributedGroupStore private ExecutorService messageHandlingExecutor; private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 1; - private final HashMap<DeviceId, Boolean> deviceAuditStatus = - new HashMap<DeviceId, Boolean>(); + private final HashMap<DeviceId, Boolean> deviceAuditStatus = new HashMap<>(); private final AtomicInteger groupIdGen = new AtomicInteger(); @@ -685,8 +684,7 @@ public class DistributedGroupStore UpdateType type, GroupBuckets buckets) { GroupBuckets oldBuckets = oldGroup.buckets(); - List<GroupBucket> newBucketList = new ArrayList<GroupBucket>( - oldBuckets.buckets()); + List<GroupBucket> newBucketList = new ArrayList<>(oldBuckets.buckets()); boolean groupDescUpdated = false; if (type == UpdateType.ADD) { diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java index d8b9daca..d0b827cd 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java @@ -1,267 +1,263 @@ -package org.onosproject.store.host.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.net.DefaultAnnotations.merge;
-import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;
-import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED;
-import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED;
-import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT;
-import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.REMOVE;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Objects;
-import java.util.Set;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultHost;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.host.HostDescription;
-import org.onosproject.net.host.HostEvent;
-import org.onosproject.net.host.HostStore;
-import org.onosproject.net.host.HostStoreDelegate;
-import org.onosproject.net.host.PortAddresses;
-import org.onosproject.net.host.HostEvent.Type;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.store.AbstractStore;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-import org.onosproject.store.service.LogicalClockService;
-import org.onosproject.store.service.StorageService;
-import org.slf4j.Logger;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Multimaps;
-import com.google.common.collect.SetMultimap;
-import com.google.common.collect.Sets;
-
-/**
- * Manages the inventory of hosts using a {@code EventuallyConsistentMap}.
- */
-@Component(immediate = true)
-@Service
-public class ECHostStore
- extends AbstractStore<HostEvent, HostStoreDelegate>
- implements HostStore {
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LogicalClockService clockService;
-
- // Hosts tracked by their location
- private final SetMultimap<ConnectPoint, Host> locations =
- Multimaps.synchronizedSetMultimap(
- HashMultimap.<ConnectPoint, Host>create());
-
- private final SetMultimap<ConnectPoint, PortAddresses> portAddresses =
- Multimaps.synchronizedSetMultimap(
- HashMultimap.<ConnectPoint, PortAddresses>create());
-
- private EventuallyConsistentMap<HostId, DefaultHost> hosts;
-
- private EventuallyConsistentMapListener<HostId, DefaultHost> hostLocationTracker =
- new HostLocationTracker();
-
- @Activate
- public void activate() {
- KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API);
-
- hosts = storageService.<HostId, DefaultHost>eventuallyConsistentMapBuilder()
- .withName("onos-hosts")
- .withSerializer(hostSerializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- hosts.addListener(hostLocationTracker);
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- hosts.removeListener(hostLocationTracker);
- hosts.destroy();
- locations.clear();
- portAddresses.clear();
-
- log.info("Stopped");
- }
-
- @Override
- public HostEvent createOrUpdateHost(ProviderId providerId,
- HostId hostId,
- HostDescription hostDescription) {
- DefaultHost currentHost = hosts.get(hostId);
- if (currentHost == null) {
- DefaultHost newhost = new DefaultHost(
- providerId,
- hostId,
- hostDescription.hwAddress(),
- hostDescription.vlan(),
- hostDescription.location(),
- ImmutableSet.copyOf(hostDescription.ipAddress()),
- hostDescription.annotations());
- hosts.put(hostId, newhost);
- return new HostEvent(HOST_ADDED, newhost);
- }
- return updateHost(providerId, hostId, hostDescription, currentHost);
- }
-
- @Override
- public HostEvent removeHost(HostId hostId) {
- Host host = hosts.remove(hostId);
- return host != null ? new HostEvent(HOST_REMOVED, host) : null;
- }
-
- @Override
- public int getHostCount() {
- return hosts.size();
- }
-
- @Override
- public Iterable<Host> getHosts() {
- return ImmutableSet.copyOf(hosts.values());
- }
-
- @Override
- public Host getHost(HostId hostId) {
- return hosts.get(hostId);
- }
-
- @Override
- public Set<Host> getHosts(VlanId vlanId) {
- return filter(hosts.values(), host -> Objects.equals(host.vlan(), vlanId));
- }
-
- @Override
- public Set<Host> getHosts(MacAddress mac) {
- return filter(hosts.values(), host -> Objects.equals(host.mac(), mac));
- }
-
- @Override
- public Set<Host> getHosts(IpAddress ip) {
- return filter(hosts.values(), host -> host.ipAddresses().contains(ip));
- }
-
- @Override
- public Set<Host> getConnectedHosts(ConnectPoint connectPoint) {
- return ImmutableSet.copyOf(locations.get(connectPoint));
- }
-
- @Override
- public Set<Host> getConnectedHosts(DeviceId deviceId) {
- return ImmutableMultimap.copyOf(locations)
- .entries()
- .stream()
- .filter(entry -> entry.getKey().deviceId().equals(deviceId))
- .map(entry -> entry.getValue())
- .collect(Collectors.toSet());
- }
-
- @Override
- public void updateAddressBindings(PortAddresses addresses) {
- portAddresses.put(addresses.connectPoint(), addresses);
- }
-
- @Override
- public void removeAddressBindings(PortAddresses addresses) {
- portAddresses.remove(addresses.connectPoint(), addresses);
- }
-
- @Override
- public void clearAddressBindings(ConnectPoint connectPoint) {
- portAddresses.removeAll(connectPoint);
- }
-
- @Override
- public Set<PortAddresses> getAddressBindings() {
- return ImmutableSet.copyOf(portAddresses.values());
- }
-
- @Override
- public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) {
- synchronized (portAddresses) {
- Set<PortAddresses> addresses = portAddresses.get(connectPoint);
- return addresses == null ? Collections.emptySet() : ImmutableSet.copyOf(addresses);
- }
- }
-
- private Set<Host> filter(Collection<DefaultHost> collection, Predicate<DefaultHost> predicate) {
- return collection.stream().filter(predicate).collect(Collectors.toSet());
- }
-
- // checks for type of update to host, sends appropriate event
- private HostEvent updateHost(ProviderId providerId,
- HostId hostId,
- HostDescription descr,
- DefaultHost currentHost) {
-
- final boolean hostMoved = !currentHost.location().equals(descr.location());
- if (hostMoved ||
- !currentHost.ipAddresses().containsAll(descr.ipAddress()) ||
- !descr.annotations().keys().isEmpty()) {
-
- Set<IpAddress> addresses = Sets.newHashSet(currentHost.ipAddresses());
- addresses.addAll(descr.ipAddress());
- Annotations annotations = merge((DefaultAnnotations) currentHost.annotations(),
- descr.annotations());
-
- DefaultHost updatedHost = new DefaultHost(providerId, currentHost.id(),
- currentHost.mac(), currentHost.vlan(),
- descr.location(),
- addresses,
- annotations);
-
- // TODO: We need a way to detect conflicting changes and abort update.
- hosts.put(hostId, updatedHost);
- locations.remove(currentHost.location(), currentHost);
- locations.put(updatedHost.location(), updatedHost);
-
- HostEvent.Type eventType = hostMoved ? Type.HOST_MOVED : Type.HOST_UPDATED;
- return new HostEvent(eventType, updatedHost);
- }
- return null;
- }
-
- private class HostLocationTracker implements EventuallyConsistentMapListener<HostId, DefaultHost> {
- @Override
- public void event(EventuallyConsistentMapEvent<HostId, DefaultHost> event) {
- DefaultHost host = checkNotNull(event.value());
- if (event.type() == PUT) {
- boolean isNew = locations.put(host.location(), host);
- notifyDelegate(new HostEvent(isNew ? HOST_ADDED : HOST_UPDATED, host));
- } else if (event.type() == REMOVE) {
- if (locations.remove(host.location(), host)) {
- notifyDelegate(new HostEvent(HOST_REMOVED, host));
- }
-
- }
- }
- }
-}
+/* + * 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.store.host.impl; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static org.onosproject.net.DefaultAnnotations.merge; +import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; +import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED; +import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED; +import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED; +import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT; +import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.REMOVE; +import static org.slf4j.LoggerFactory.getLogger; + +import java.util.Collection; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.apache.felix.scr.annotations.Service; +import org.onlab.packet.IpAddress; +import org.onlab.packet.MacAddress; +import org.onlab.packet.VlanId; +import org.onlab.util.KryoNamespace; +import org.onosproject.net.Annotations; +import org.onosproject.net.ConnectPoint; +import org.onosproject.net.DefaultAnnotations; +import org.onosproject.net.DefaultHost; +import org.onosproject.net.DeviceId; +import org.onosproject.net.Host; +import org.onosproject.net.HostId; +import org.onosproject.net.HostLocation; +import org.onosproject.net.host.HostDescription; +import org.onosproject.net.host.HostEvent; +import org.onosproject.net.host.HostStore; +import org.onosproject.net.host.HostStoreDelegate; +import org.onosproject.net.host.HostEvent.Type; +import org.onosproject.net.provider.ProviderId; +import org.onosproject.store.AbstractStore; +import org.onosproject.store.serializers.KryoNamespaces; +import org.onosproject.store.service.EventuallyConsistentMap; +import org.onosproject.store.service.EventuallyConsistentMapEvent; +import org.onosproject.store.service.EventuallyConsistentMapListener; +import org.onosproject.store.service.LogicalClockService; +import org.onosproject.store.service.StorageService; +import org.slf4j.Logger; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Multimaps; +import com.google.common.collect.SetMultimap; +import com.google.common.collect.Sets; + +/** + * Manages the inventory of hosts using a {@code EventuallyConsistentMap}. + */ +@Component(immediate = true) +@Service +public class ECHostStore + extends AbstractStore<HostEvent, HostStoreDelegate> + implements HostStore { + + private final Logger log = getLogger(getClass()); + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected StorageService storageService; + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected LogicalClockService clockService; + + // Hosts tracked by their location + private final SetMultimap<ConnectPoint, Host> locations = + Multimaps.synchronizedSetMultimap( + HashMultimap.<ConnectPoint, Host>create()); + + private EventuallyConsistentMap<HostId, DefaultHost> hosts; + + private EventuallyConsistentMapListener<HostId, DefaultHost> hostLocationTracker = + new HostLocationTracker(); + + @Activate + public void activate() { + KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder() + .register(KryoNamespaces.API); + + hosts = storageService.<HostId, DefaultHost>eventuallyConsistentMapBuilder() + .withName("onos-hosts") + .withSerializer(hostSerializer) + .withTimestampProvider((k, v) -> clockService.getTimestamp()) + .build(); + + hosts.addListener(hostLocationTracker); + + log.info("Started"); + } + + @Deactivate + public void deactivate() { + hosts.removeListener(hostLocationTracker); + hosts.destroy(); + locations.clear(); + + log.info("Stopped"); + } + + @Override + public HostEvent createOrUpdateHost(ProviderId providerId, + HostId hostId, + HostDescription hostDescription, + boolean replaceIPs) { + // TODO: We need a way to detect conflicting changes and abort update. + // (BOC) Compute might do this for us. + + final AtomicReference<Type> eventType = new AtomicReference<>(); + final AtomicReference<DefaultHost> oldHost = new AtomicReference<>(); + DefaultHost host = hosts.compute(hostId, (id, existingHost) -> { + if (existingHost != null) { + oldHost.set(existingHost); + checkState(Objects.equals(hostDescription.hwAddress(), existingHost.mac()), + "Existing and new MAC addresses differ."); + checkState(Objects.equals(hostDescription.vlan(), existingHost.vlan()), + "Existing and new VLANs differ."); + } + + // TODO do we ever want the existing location? + HostLocation location = hostDescription.location(); + + final Set<IpAddress> addresses; + if (existingHost == null || replaceIPs) { + addresses = ImmutableSet.copyOf(hostDescription.ipAddress()); + } else { + addresses = Sets.newHashSet(existingHost.ipAddresses()); + addresses.addAll(hostDescription.ipAddress()); + } + + final Annotations annotations; + if (existingHost != null) { + annotations = merge((DefaultAnnotations) existingHost.annotations(), + hostDescription.annotations()); + } else { + annotations = hostDescription.annotations(); + } + + if (existingHost == null) { + eventType.set(HOST_ADDED); + } else if (!Objects.equals(existingHost.location(), hostDescription.location())) { + eventType.set(HOST_MOVED); + } else if (!existingHost.ipAddresses().containsAll(hostDescription.ipAddress()) || + !hostDescription.annotations().keys().isEmpty()) { + eventType.set(HOST_UPDATED); + } // else, eventType == null; this means we don't send an event + + return new DefaultHost(providerId, + hostId, + hostDescription.hwAddress(), + hostDescription.vlan(), + location, + addresses, + annotations); + }); + + if (oldHost.get() != null) { + DefaultHost old = oldHost.get(); + locations.remove(old.location(), old); + } + locations.put(host.location(), host); + + return eventType.get() != null ? new HostEvent(eventType.get(), host) : null; + } + + @Override + public HostEvent removeHost(HostId hostId) { + Host host = hosts.remove(hostId); + return host != null ? new HostEvent(HOST_REMOVED, host) : null; + } + + @Override + public int getHostCount() { + return hosts.size(); + } + + @Override + public Iterable<Host> getHosts() { + return ImmutableSet.copyOf(hosts.values()); + } + + @Override + public Host getHost(HostId hostId) { + return hosts.get(hostId); + } + + @Override + public Set<Host> getHosts(VlanId vlanId) { + return filter(hosts.values(), host -> Objects.equals(host.vlan(), vlanId)); + } + + @Override + public Set<Host> getHosts(MacAddress mac) { + return filter(hosts.values(), host -> Objects.equals(host.mac(), mac)); + } + + @Override + public Set<Host> getHosts(IpAddress ip) { + return filter(hosts.values(), host -> host.ipAddresses().contains(ip)); + } + + @Override + public Set<Host> getConnectedHosts(ConnectPoint connectPoint) { + return ImmutableSet.copyOf(locations.get(connectPoint)); + } + + @Override + public Set<Host> getConnectedHosts(DeviceId deviceId) { + return ImmutableMultimap.copyOf(locations) + .entries() + .stream() + .filter(entry -> entry.getKey().deviceId().equals(deviceId)) + .map(entry -> entry.getValue()) + .collect(Collectors.toSet()); + } + + private Set<Host> filter(Collection<DefaultHost> collection, Predicate<DefaultHost> predicate) { + return collection.stream().filter(predicate).collect(Collectors.toSet()); + } + + private class HostLocationTracker implements EventuallyConsistentMapListener<HostId, DefaultHost> { + @Override + public void event(EventuallyConsistentMapEvent<HostId, DefaultHost> event) { + DefaultHost host = checkNotNull(event.value()); + if (event.type() == PUT) { + boolean isNew = locations.put(host.location(), host); + notifyDelegate(new HostEvent(isNew ? HOST_ADDED : HOST_UPDATED, host)); + } else if (event.type() == REMOVE) { + if (locations.remove(host.location(), host)) { + notifyDelegate(new HostEvent(HOST_REMOVED, host)); + } + + } + } + } +} diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java index 5ae8b4f4..9382960f 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java @@ -1,3 +1,18 @@ +/* + * 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.store.impl; import static com.google.common.base.Preconditions.checkArgument; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java index 4577086c..243caf80 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java @@ -211,7 +211,10 @@ public class ECLinkStore // otherwise signal the actual master. if (clusterService.getLocalNode().id().equals(dstNodeId)) { LinkKey linkKey = linkKey(linkDescription.src(), linkDescription.dst()); - Provided<LinkKey> internalLinkKey = new Provided<>(linkKey, providerId); + Provided<LinkKey> internalLinkKey = getProvided(linkKey, providerId); + if (internalLinkKey == null) { + return null; + } linkDescriptions.compute(internalLinkKey, (k, v) -> createOrUpdateLinkInternal(v , linkDescription)); return refreshLinkCache(linkKey); } else { @@ -226,6 +229,18 @@ public class ECLinkStore } } + private Provided<LinkKey> getProvided(LinkKey linkKey, ProviderId provId) { + ProviderId bpid = getBaseProviderId(linkKey); + if (provId == null) { + // The LinkService didn't know who this LinkKey belongs to. + // A fix is to either modify the getProvider() in LinkService classes + // or expose the contents of linkDescriptions to the LinkService. + return (bpid == null) ? null : new Provided<>(linkKey, bpid); + } else { + return new Provided<>(linkKey, provId); + } + } + private LinkDescription createOrUpdateLinkInternal(LinkDescription current, LinkDescription updated) { if (current != null) { // we only allow transition from INDIRECT -> DIRECT diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java index 767ede54..105c77df 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java @@ -62,7 +62,6 @@ import org.onosproject.store.serializers.custom.DistributedStoreSerializers; import org.slf4j.Logger; import java.io.IOException; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -551,7 +550,7 @@ public class GossipLinkStore */ private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { return synchronizedSetMultimap( - Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(), + Multimaps.newSetMultimap(new ConcurrentHashMap<>(), () -> Sets.newConcurrentHashSet())); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/LinkInjectedEvent.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/LinkInjectedEvent.java index 356033b0..b353208d 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/LinkInjectedEvent.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/LinkInjectedEvent.java @@ -1,3 +1,18 @@ +/* + * 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.store.link.impl; import com.google.common.base.MoreObjects; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/mastership/impl/RoleValue.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/mastership/impl/RoleValue.java index 9d3b1686..5a38a34a 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/mastership/impl/RoleValue.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/mastership/impl/RoleValue.java @@ -45,9 +45,9 @@ final class RoleValue { * Constructs empty RoleValue. */ public RoleValue() { - value.put(MastershipRole.MASTER, new LinkedList<NodeId>()); - value.put(MastershipRole.STANDBY, new LinkedList<NodeId>()); - value.put(MastershipRole.NONE, new LinkedList<NodeId>()); + value.put(MastershipRole.MASTER, new LinkedList<>()); + value.put(MastershipRole.STANDBY, new LinkedList<>()); + value.put(MastershipRole.NONE, new LinkedList<>()); } /** diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java index 24ce2155..d4c89c93 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java @@ -15,7 +15,7 @@ */ package org.onosproject.store.packet.impl; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @@ -45,6 +45,7 @@ import org.onosproject.store.service.Versioned; import org.slf4j.Logger; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -152,7 +153,7 @@ public class DistributedPacketStore } @Override - public Set<PacketRequest> existingRequests() { + public List<PacketRequest> existingRequests() { return tracker.requests(); } @@ -197,10 +198,11 @@ public class DistributedPacketStore return requests.replace(request.selector(), old.version(), newSet); } - public Set<PacketRequest> requests() { - ImmutableSet.Builder<PacketRequest> builder = ImmutableSet.builder(); - requests.values().forEach(v -> builder.addAll(v.value())); - return builder.build(); + public List<PacketRequest> requests() { + List<PacketRequest> list = Lists.newArrayList(); + requests.values().forEach(v -> list.addAll(v.value())); + list.sort((o1, o2) -> o1.priority().priorityValue() - o2.priority().priorityValue()); + return list; } } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/proxyarp/impl/package-info.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/proxyarp/impl/package-info.java new file mode 100644 index 00000000..e3675524 --- /dev/null +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/proxyarp/impl/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** + * Implementation of proxy ARP distribution mechanism. + */ +package org.onosproject.store.proxyarp.impl; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java index ce25f868..3a296353 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java @@ -1,3 +1,18 @@ +/* + * 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.store.resource.impl; import java.util.ArrayList; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/statistic/impl/DistributedStatisticStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/statistic/impl/DistributedStatisticStore.java index d5434730..35bdad14 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/statistic/impl/DistributedStatisticStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/statistic/impl/DistributedStatisticStore.java @@ -97,7 +97,7 @@ public class DistributedStatisticStore implements StatisticStore { // register this store specific classes here .build(); } - };; + }; private ExecutorService messageHandlingExecutor; diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManagerTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManagerTest.java index 0dcc6a10..daeaa12c 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManagerTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManagerTest.java @@ -109,7 +109,7 @@ public class ClusterCommunicationManagerTest { assertEquals("incorrect event node", nodeId, delegate.nodeId); } - enum Op { DETECTED, VANISHED, REMOVED }; + enum Op { DETECTED, VANISHED, REMOVED } private class TestDelegate implements ClusterNodesDelegate { diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/MatchTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/MatchTest.java index 7ff94c88..952393aa 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/MatchTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/MatchTest.java @@ -1,3 +1,18 @@ +/* + * 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.store.consistent.impl; import static junit.framework.TestCase.assertEquals; diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/ResultTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/ResultTest.java index 2a3bab87..2d329d14 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/ResultTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/ResultTest.java @@ -1,3 +1,18 @@ +/* + * 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.store.consistent.impl; import static junit.framework.TestCase.assertEquals; diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/UpdateResultTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/UpdateResultTest.java index 84dc9153..ab53710b 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/UpdateResultTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/UpdateResultTest.java @@ -1,3 +1,18 @@ +/* + * 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.store.consistent.impl; import static junit.framework.TestCase.assertEquals; @@ -15,8 +30,8 @@ public class UpdateResultTest { @Test public void testGetters() { - Versioned<String> oldValue = new Versioned<String>("a", 1); - Versioned<String> newValue = new Versioned<String>("b", 2); + Versioned<String> oldValue = new Versioned<>("a", 1); + Versioned<String> newValue = new Versioned<>("b", 2); UpdateResult<String, String> ur = new UpdateResult<>(true, "foo", "k", oldValue, newValue); @@ -29,8 +44,8 @@ public class UpdateResultTest { @Test public void testToMapEvent() { - Versioned<String> oldValue = new Versioned<String>("a", 1); - Versioned<String> newValue = new Versioned<String>("b", 2); + Versioned<String> oldValue = new Versioned<>("a", 1); + Versioned<String> newValue = new Versioned<>("b", 2); UpdateResult<String, String> ur1 = new UpdateResult<>(true, "foo", "k", oldValue, newValue); MapEvent<String, String> event1 = ur1.toMapEvent(); @@ -59,8 +74,8 @@ public class UpdateResultTest { @Test public void testMap() { - Versioned<String> oldValue = new Versioned<String>("a", 1); - Versioned<String> newValue = new Versioned<String>("b", 2); + Versioned<String> oldValue = new Versioned<>("a", 1); + Versioned<String> newValue = new Versioned<>("b", 2); UpdateResult<String, String> ur1 = new UpdateResult<>(true, "foo", "k", oldValue, newValue); UpdateResult<Integer, Integer> ur2 = ur1.map(s -> s.length(), s -> s.length()); 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 43b11f52..3a168936 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 @@ -802,31 +802,22 @@ public class GossipDeviceStoreTest { @Test public final void testEvents() throws InterruptedException { final CountDownLatch addLatch = new CountDownLatch(1); - DeviceStoreDelegate checkAdd = new DeviceStoreDelegate() { - @Override - public void notify(DeviceEvent event) { - assertEquals(DEVICE_ADDED, event.type()); - assertDevice(DID1, SW1, event.subject()); - addLatch.countDown(); - } + DeviceStoreDelegate checkAdd = event -> { + assertEquals(DEVICE_ADDED, event.type()); + assertDevice(DID1, SW1, event.subject()); + addLatch.countDown(); }; final CountDownLatch updateLatch = new CountDownLatch(1); - DeviceStoreDelegate checkUpdate = new DeviceStoreDelegate() { - @Override - public void notify(DeviceEvent event) { - assertEquals(DEVICE_UPDATED, event.type()); - assertDevice(DID1, SW2, event.subject()); - updateLatch.countDown(); - } + DeviceStoreDelegate checkUpdate = event -> { + assertEquals(DEVICE_UPDATED, event.type()); + assertDevice(DID1, SW2, event.subject()); + updateLatch.countDown(); }; final CountDownLatch removeLatch = new CountDownLatch(1); - DeviceStoreDelegate checkRemove = new DeviceStoreDelegate() { - @Override - public void notify(DeviceEvent event) { - assertEquals(DEVICE_REMOVED, event.type()); - assertDevice(DID1, SW2, event.subject()); - removeLatch.countDown(); - } + DeviceStoreDelegate checkRemove = event -> { + assertEquals(DEVICE_REMOVED, event.type()); + assertDevice(DID1, SW2, event.subject()); + removeLatch.countDown(); }; DeviceDescription description = diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/flow/impl/ReplicaInfoManagerTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/flow/impl/ReplicaInfoManagerTest.java index d429752c..76ff8045 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/flow/impl/ReplicaInfoManagerTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/flow/impl/ReplicaInfoManagerTest.java @@ -101,7 +101,7 @@ public class ReplicaInfoManagerTest { // fake MastershipEvent eventDispatcher.post(new MastershipEvent(Type.MASTER_CHANGED, DID1, - new RoleInfo(NID1, new LinkedList<NodeId>()))); + new RoleInfo(NID1, new LinkedList<>()))); assertTrue(latch.await(1, TimeUnit.SECONDS)); } diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/impl/TimestampedTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/impl/TimestampedTest.java index 0f67572f..c47eb27a 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/impl/TimestampedTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/impl/TimestampedTest.java @@ -65,7 +65,7 @@ public class TimestampedTest { @Test public final void testValue() { - final Integer n = Integer.valueOf(42); + final Integer n = 42; Timestamped<Integer> tsv = new Timestamped<>(n, TS_1_1); assertSame(n, tsv.value()); diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java index bf7af464..f8b5b860 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java @@ -548,31 +548,22 @@ public class GossipLinkStoreTest { final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2); final CountDownLatch addLatch = new CountDownLatch(1); - LinkStoreDelegate checkAdd = new LinkStoreDelegate() { - @Override - public void notify(LinkEvent event) { - assertEquals(LINK_ADDED, event.type()); - assertLink(linkId1, INDIRECT, event.subject()); - addLatch.countDown(); - } + LinkStoreDelegate checkAdd = event -> { + assertEquals(LINK_ADDED, event.type()); + assertLink(linkId1, INDIRECT, event.subject()); + addLatch.countDown(); }; final CountDownLatch updateLatch = new CountDownLatch(1); - LinkStoreDelegate checkUpdate = new LinkStoreDelegate() { - @Override - public void notify(LinkEvent event) { - assertEquals(LINK_UPDATED, event.type()); - assertLink(linkId1, DIRECT, event.subject()); - updateLatch.countDown(); - } + LinkStoreDelegate checkUpdate = event -> { + assertEquals(LINK_UPDATED, event.type()); + assertLink(linkId1, DIRECT, event.subject()); + updateLatch.countDown(); }; final CountDownLatch removeLatch = new CountDownLatch(1); - LinkStoreDelegate checkRemove = new LinkStoreDelegate() { - @Override - public void notify(LinkEvent event) { - assertEquals(LINK_REMOVED, event.type()); - assertLink(linkId1, DIRECT, event.subject()); - removeLatch.countDown(); - } + LinkStoreDelegate checkRemove = event -> { + assertEquals(LINK_REMOVED, event.type()); + assertLink(linkId1, DIRECT, event.subject()); + removeLatch.countDown(); }; linkStore.setDelegate(checkAdd); diff --git a/framework/src/onos/core/store/pom.xml b/framework/src/onos/core/store/pom.xml index 59d66642..2b246b83 100644 --- a/framework/src/onos/core/store/pom.xml +++ b/framework/src/onos/core/store/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onosproject</groupId> <artifactId>onos-core</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/framework/src/onos/core/store/serializers/pom.xml b/framework/src/onos/core/store/serializers/pom.xml index d869f60c..867ce0f0 100644 --- a/framework/src/onos/core/store/serializers/pom.xml +++ b/framework/src/onos/core/store/serializers/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onosproject</groupId> <artifactId>onos-core-store</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/AnnotationsSerializer.java b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/AnnotationsSerializer.java index febb4adb..ed02c3e3 100644 --- a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/AnnotationsSerializer.java +++ b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/AnnotationsSerializer.java @@ -1,3 +1,18 @@ +/* + * 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.store.serializers; import org.onosproject.net.DefaultAnnotations; |