diff options
author | 2015-11-05 14:00:42 -0800 | |
---|---|---|
committer | 2015-11-05 14:00:42 -0800 | |
commit | b34f82bf11934fc6b938ef997d536a7ccea76c36 (patch) | |
tree | 10559ebf65962abb741883ca9d23aec241ced504 /framework/src/onos/core/api | |
parent | 2cdecb8c41956d7dd8ab5d59591ebc21f3c64a9e (diff) |
Updates ONOS tree to checkin id ca9cc8e28eba18da77f4fa021fb7c3a3f76e5d44
upstream.
Change-Id: I49f8e41733afea8101ec50c0102213c8d18949ae
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/core/api')
36 files changed, 152 insertions, 47 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/app/ApplicationService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/app/ApplicationService.java index 73dcc86c..1e543b85 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/app/ApplicationService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/app/ApplicationService.java @@ -67,4 +67,11 @@ public interface ApplicationService */ Set<Permission> getPermissions(ApplicationId appId); + /** + * Registers application pre-deactivation processing hook. + * + * @param appId application identifier + * @param hook pre-deactivation hook + */ + void registerDeactivateHook(ApplicationId appId, Runnable hook); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cfg/ConfigProperty.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cfg/ConfigProperty.java index 36cd22b5..f1b602e8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cfg/ConfigProperty.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/cfg/ConfigProperty.java @@ -245,7 +245,7 @@ public final class ConfigProperty { @Override public int hashCode() { - return Objects.hash(name); + return name.hashCode(); } /** diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java index 5f3e0e19..3787daa5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java @@ -20,6 +20,7 @@ import org.onlab.packet.IpAddress; import java.util.Objects; import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; /** * Default implementation of a controller instance descriptor. @@ -57,7 +58,7 @@ public class DefaultControllerNode implements ControllerNode { * @param tcpPort TCP port */ public DefaultControllerNode(NodeId id, IpAddress ip, int tcpPort) { - this.id = id; + this.id = checkNotNull(id); this.ip = ip; this.tcpPort = tcpPort; } @@ -79,7 +80,7 @@ public class DefaultControllerNode implements ControllerNode { @Override public int hashCode() { - return Objects.hash(id); + return id.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java index 6cfb42c7..e5ab9dc8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java @@ -35,7 +35,7 @@ public class NodeId implements Comparable<NodeId> { @Override public int hashCode() { - return Objects.hash(id); + return id.hashCode(); } @Override 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 303ad395..0825a6d1 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 @@ -50,6 +50,7 @@ public interface CoreService { /** * Returns an existing application id from a given id. + * * @param id the short value of the id * @return an application id */ @@ -57,6 +58,7 @@ public interface CoreService { /** * Returns an existing application id from a given id. + * * @param name the name portion of the ID to look up * @return an application id */ @@ -67,10 +69,21 @@ public interface CoreService { * to follow the reverse DNS convention, e.g. * {@code org.flying.circus.app} * - * @param identifier string identifier + * @param name string identifier + * @return the application id + */ + ApplicationId registerApplication(String name); + + /** + * Registers a new application by its name, which is expected + * to follow the reverse DNS convention, e.g. + * {@code org.flying.circus.app}, along with its pre-deactivation hook. + * + * @param name string identifier + * @param preDeactivate pre-deactivation hook * @return the application id */ - ApplicationId registerApplication(String identifier); + ApplicationId registerApplication(String name, Runnable preDeactivate); /** * Returns an id generator for a given topic. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java index c7b5b2da..aedfb0d3 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java @@ -58,7 +58,7 @@ public class DefaultApplicationId implements ApplicationId { @Override public int hashCode() { - return Objects.hash(id); + return Short.hashCode(id); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java index 9fa8d2b6..243e5216 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java @@ -42,7 +42,7 @@ public class DefaultGroupId implements GroupId { @Override public int hashCode() { - return Objects.hash(id); + return id; } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java index a5377016..06e9e206 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java @@ -127,7 +127,7 @@ public final class Version { @Override public int hashCode() { - return Objects.hash(format); + return format.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java index a4789cac..2da2463a 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java @@ -88,7 +88,7 @@ public class DefaultPath extends DefaultLink implements Path { @Override public int hashCode() { - return Objects.hash(links); + return links.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java index 5331342e..e2c1214f 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java @@ -75,7 +75,7 @@ public final class DeviceId extends ElementId { @Override public int hashCode() { - return Objects.hash(str); + return str.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java index 3f782954..a15217c6 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java @@ -52,7 +52,7 @@ public final class BridgeName { @Override public int hashCode() { - return Objects.hash(name); + return name.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java index 6beeecc9..4615a82b 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java @@ -388,7 +388,12 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { @Override public Builder setQueue(long queueId) { - return add(Instructions.setQueue(queueId)); + return add(Instructions.setQueue(queueId, null)); + } + + @Override + public Builder setQueue(long queueId, PortNumber port) { + return add(Instructions.setQueue(queueId, port)); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java index b14ab99c..f1a676ab 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java @@ -271,6 +271,15 @@ public interface TrafficTreatment { Builder setQueue(long queueId); /** + * Sets the Queue ID for a specific port. + * + * @param queueId a queue ID + * @param port a port number + * @return a treatment builder + */ + Builder setQueue(long queueId, PortNumber port); + + /** * Sets a meter to be used by this flow. * * @param meterId a meter id diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java index aad407c8..4e5d39ab 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java @@ -15,6 +15,7 @@ */ package org.onosproject.net.flow.instructions; +import com.google.common.base.MoreObjects; import org.onlab.packet.EthType; import org.onlab.packet.IpAddress; import org.onlab.packet.MacAddress; @@ -99,11 +100,12 @@ public final class Instructions { * Creates a set-queue instruction. * * @param queueId Queue Id + * @param port Port number * @return set-queue instruction */ - public static SetQueueInstruction setQueue(final long queueId) { + public static SetQueueInstruction setQueue(final long queueId, final PortNumber port) { checkNotNull(queueId, "queue ID cannot be null"); - return new SetQueueInstruction(queueId); + return new SetQueueInstruction(queueId, port); } public static MeterInstruction meterTraffic(final MeterId meterId) { @@ -514,7 +516,7 @@ public final class Instructions { @Override public int hashCode() { - return Objects.hash(type().ordinal()); + return type().ordinal(); } @Override @@ -548,7 +550,7 @@ public final class Instructions { @Override public int hashCode() { - return Objects.hash(type().ordinal()); + return type().ordinal(); } @Override @@ -655,15 +657,26 @@ public final class Instructions { */ public static final class SetQueueInstruction implements Instruction { private final long queueId; + private final PortNumber port; private SetQueueInstruction(long queueId) { this.queueId = queueId; + this.port = null; + } + + private SetQueueInstruction(long queueId, PortNumber port) { + this.queueId = queueId; + this.port = port; } public long queueId() { return queueId; } + public PortNumber port() { + return port; + } + @Override public Type type() { return Type.QUEUE; @@ -671,13 +684,18 @@ public final class Instructions { @Override public String toString() { - return toStringHelper(type().toString()) - .add("queueId", queueId).toString(); + MoreObjects.ToStringHelper toStringHelper = toStringHelper(type().toString()); + toStringHelper.add("queueId", queueId); + + if (port() != null) { + toStringHelper.add("port", port); + } + return toStringHelper.toString(); } @Override public int hashCode() { - return Objects.hash(type().ordinal(), queueId); + return Objects.hash(type().ordinal(), queueId, port); } @Override @@ -687,7 +705,7 @@ public final class Instructions { } if (obj instanceof SetQueueInstruction) { SetQueueInstruction that = (SetQueueInstruction) obj; - return Objects.equals(queueId, that.queueId); + return Objects.equals(queueId, that.queueId) && Objects.equals(port, that.port); } return false; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java index a6e5903c..4af3d168 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java @@ -114,7 +114,7 @@ public abstract class L0ModificationInstruction implements Instruction { @Override public int hashCode() { - return Objects.hash(lambda); + return lambda.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java index c6847d1c..b72dd7bc 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java @@ -62,7 +62,7 @@ public abstract class L1ModificationInstruction implements Instruction { @Override public int hashCode() { - return Objects.hash(oduSignalId); + return oduSignalId.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java index 546a4513..97f8aedf 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java @@ -186,7 +186,7 @@ public class DefaultGroup extends DefaultGroupDescription */ @Override public int hashCode() { - return super.hashCode() + Objects.hash(id); + return Objects.hash(super.hashCode(), id); } /* diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java index 20ccb55d..444feee4 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java @@ -87,7 +87,7 @@ public final class BandwidthConstraint extends BooleanConstraint { @Override public int hashCode() { - return Objects.hash(bandwidth); + return bandwidth.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java index 9dd813b2..7811a004 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java @@ -69,7 +69,7 @@ public class LambdaConstraint extends BooleanConstraint { @Override public int hashCode() { - return Objects.hash(lambda); + return Objects.hashCode(lambda); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java index 54eb4ea5..aecef879 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java @@ -67,7 +67,7 @@ public class LatencyConstraint implements Constraint { @Override public int hashCode() { - return Objects.hash(latency); + return latency.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java index cb1e6b2b..ca4f3fd3 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java @@ -66,7 +66,7 @@ public class ObstacleConstraint extends BooleanConstraint { @Override public int hashCode() { - return Objects.hash(obstacles); + return obstacles.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java index 1acf6dfe..4839feec 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java @@ -91,7 +91,7 @@ public class WaypointConstraint implements Constraint { @Override public int hashCode() { - return Objects.hash(waypoints); + return waypoints.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java index 74f6e102..05cf28f5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java @@ -53,7 +53,7 @@ public class BandwidthResourceAllocation implements ResourceAllocation { @Override public int hashCode() { - return Objects.hash(bandwidth); + return bandwidth.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java index e07309cb..722b870f 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java @@ -53,7 +53,7 @@ public class BandwidthResourceRequest implements ResourceRequest { @Override public int hashCode() { - return Objects.hash(bandwidth); + return bandwidth.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java index 545f025f..161cf455 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java @@ -53,7 +53,7 @@ public class LambdaResourceAllocation implements ResourceAllocation { @Override public int hashCode() { - return Objects.hash(lambda); + return Objects.hashCode(lambda); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java index 10911539..cc9edc2a 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java @@ -54,7 +54,7 @@ public class MplsLabelResourceAllocation implements ResourceAllocation { @Override public int hashCode() { - return Objects.hash(mplsLabel); + return Objects.hashCode(mplsLabel); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java index 676f0068..1e6780fa 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java @@ -53,7 +53,7 @@ public final class ClusterId { @Override public int hashCode() { - return Objects.hash(id); + return id; } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java index dacb5fd8..99d700e1 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java @@ -20,6 +20,7 @@ import org.onosproject.net.Link; import java.util.Objects; import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; /** * Implementation of the topology edge backed by a link. @@ -40,7 +41,7 @@ public class DefaultTopologyEdge implements TopologyEdge { public DefaultTopologyEdge(TopologyVertex src, TopologyVertex dst, Link link) { this.src = src; this.dst = dst; - this.link = link; + this.link = checkNotNull(link); } @Override @@ -60,7 +61,7 @@ public class DefaultTopologyEdge implements TopologyEdge { @Override public int hashCode() { - return Objects.hash(link); + return link.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java index 07a09cbd..4782bc95 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java @@ -42,7 +42,7 @@ public class DefaultTopologyVertex implements TopologyVertex { @Override public int hashCode() { - return Objects.hash(deviceId); + return deviceId.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java index 0cc7b453..4be7ede7 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java @@ -52,7 +52,7 @@ public class WallClockTimestamp implements Timestamp { } @Override public int hashCode() { - return Objects.hash(unixTimestamp); + return Long.hashCode(unixTimestamp); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiView.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiView.java index 2b8b7fa2..c8671159 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiView.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiView.java @@ -138,7 +138,7 @@ public class UiView { @Override public int hashCode() { - return Objects.hash(id); + return id.hashCode(); } @Override 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 a165be33..c75eccf9 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 @@ -18,7 +18,7 @@ package org.onosproject.ui.topo; import com.google.common.collect.Sets; -import java.text.DecimalFormat; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -28,7 +28,7 @@ import java.util.Set; */ public class PropertyPanel { - private static final DecimalFormat DF0 = new DecimalFormat("#,###"); + private static final NumberFormat NF = NumberFormat.getInstance(); private String title; private String typeId; @@ -49,6 +49,24 @@ public class PropertyPanel { } /** + * Returns a number formatter to use for formatting integer and long + * property values. + * <p> + * This default implementation uses a formatter for the default + * locale. For example: + * <pre> + * Locale.ENGLISH : 1000 -> "1,000" + * Locale.FRENCH : 1000 -> "1 000" + * Locale.GERMAN : 1000 -> "1.000" + * </pre> + * + * @return the number formatter + */ + protected NumberFormat formatter() { + return NF; + } + + /** * Adds an ID field to the panel data, to be included in * the returned JSON data to the client. * @@ -80,7 +98,7 @@ public class PropertyPanel { * @return self, for chaining */ public PropertyPanel addProp(String key, int value) { - properties.add(new Prop(key, DF0.format(value))); + properties.add(new Prop(key, formatter().format(value))); return this; } @@ -92,7 +110,7 @@ public class PropertyPanel { * @return self, for chaining */ public PropertyPanel addProp(String key, long value) { - properties.add(new Prop(key, DF0.format(value))); + properties.add(new Prop(key, formatter().format(value))); return this; } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/app/ApplicationServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/app/ApplicationServiceAdapter.java index 479cc59a..96324a91 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/app/ApplicationServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/app/ApplicationServiceAdapter.java @@ -51,6 +51,10 @@ public class ApplicationServiceAdapter implements ApplicationService { } @Override + public void registerDeactivateHook(ApplicationId appId, Runnable hook) { + } + + @Override public void addListener(ApplicationListener listener) { } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/core/CoreServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/core/CoreServiceAdapter.java index 0f6abd68..6d45e8c5 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/core/CoreServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/core/CoreServiceAdapter.java @@ -43,7 +43,12 @@ public class CoreServiceAdapter implements CoreService { } @Override - public ApplicationId registerApplication(String identifier) { + public ApplicationId registerApplication(String name) { + return null; + } + + @Override + public ApplicationId registerApplication(String name, Runnable preDeactivate) { return null; } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java index d42e22fa..14201472 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java @@ -192,14 +192,17 @@ public class IntentTestsMocks { new MplsLabelResourceAllocation(MplsLabel.valueOf(10))); } + @Override public IntentId intentId() { return null; } + @Override public Collection<Link> links() { return null; } + @Override public Set<ResourceRequest> resources() { return null; } @@ -408,7 +411,7 @@ public class IntentTestsMocks { @Override public int hashCode() { - return Objects.hash(priority); + return priority; } @Override 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 7e6cc227..157cdc74 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 @@ -20,17 +20,38 @@ import org.junit.BeforeClass; import org.junit.Test; import org.onosproject.ui.topo.PropertyPanel.Prop; +import java.text.NumberFormat; import java.util.HashMap; import java.util.Iterator; +import java.util.Locale; import java.util.Map; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; /** * Unit tests for {@link PropertyPanel}. */ public class PropertyPanelTest { + // Modified property panel subclass to use ENGLISH locale formatter so + // we know formatted numbers will use comma for the thousand separator. + private static final class EnglishPropertyPanel extends PropertyPanel { + private static final NumberFormat ENGLISH_FORMATTER = + NumberFormat.getInstance(Locale.ENGLISH); + + public EnglishPropertyPanel(String title, String typeId) { + super(title, typeId); + } + + @Override + protected NumberFormat formatter() { + return ENGLISH_FORMATTER; + } + } + private static final String TITLE_ORIG = "Original Title"; private static final String TYPE_ORIG = "Original type ID"; private static final String TITLE_NEW = "New Title"; @@ -76,7 +97,7 @@ public class PropertyPanelTest { @Test public void basic() { - pp = new PropertyPanel(TITLE_ORIG, TYPE_ORIG); + pp = new EnglishPropertyPanel(TITLE_ORIG, TYPE_ORIG); assertEquals("wrong title", TITLE_ORIG, pp.title()); assertEquals("wrong type", TYPE_ORIG, pp.typeId()); assertNull("id?", pp.id()); |