aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core
diff options
context:
space:
mode:
authorAshlee Young <ashlee@wildernessvoice.com>2015-11-05 14:00:42 -0800
committerAshlee Young <ashlee@wildernessvoice.com>2015-11-05 14:00:42 -0800
commitb34f82bf11934fc6b938ef997d536a7ccea76c36 (patch)
tree10559ebf65962abb741883ca9d23aec241ced504 /framework/src/onos/core
parent2cdecb8c41956d7dd8ab5d59591ebc21f3c64a9e (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')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/app/ApplicationService.java7
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/cfg/ConfigProperty.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java5
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java17
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java7
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java9
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java34
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java5
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiView.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java26
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/app/ApplicationServiceAdapter.java4
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/core/CoreServiceAdapter.java7
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java5
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java25
-rw-r--r--framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java2
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java30
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java21
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java3
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java2
-rw-r--r--framework/src/onos/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java13
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java2
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java2
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java154
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java11
46 files changed, 273 insertions, 166 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 -&gt; "1,000"
+ * Locale.FRENCH : 1000 -&gt; "1 000"
+ * Locale.GERMAN : 1000 -&gt; "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());
diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java
index 2ee41945..500a09c7 100644
--- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java
+++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java
@@ -51,7 +51,7 @@ public class SystemClockTimestamp implements Timestamp {
}
@Override
public int hashCode() {
- return Objects.hash(nanoTimestamp);
+ return Long.hashCode(nanoTimestamp);
}
@Override
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
index 161659f9..a9e928e5 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.app.impl;
+import com.google.common.collect.Maps;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -30,20 +31,21 @@ import org.onosproject.app.ApplicationService;
import org.onosproject.app.ApplicationState;
import org.onosproject.app.ApplicationStore;
import org.onosproject.app.ApplicationStoreDelegate;
-import org.onosproject.event.AbstractListenerManager;
import org.onosproject.core.Application;
import org.onosproject.core.ApplicationId;
+import org.onosproject.event.AbstractListenerManager;
import org.onosproject.security.Permission;
import org.onosproject.security.SecurityUtil;
import org.slf4j.Logger;
import java.io.InputStream;
+import java.util.Map;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.app.ApplicationEvent.Type.*;
-import static org.onosproject.security.AppPermission.Type.*;
import static org.onosproject.security.AppGuard.checkPermission;
+import static org.onosproject.security.AppPermission.Type.APP_READ;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -69,6 +71,9 @@ public class ApplicationManager
private boolean initializing;
+ // Application supplied hooks for pre-activation processing.
+ private final Map<String, Runnable> deactivateHooks = Maps.newConcurrentMap();
+
@Activate
public void activate() {
eventDispatcher.addSink(ApplicationEvent.class, listenerRegistry);
@@ -122,6 +127,14 @@ public class ApplicationManager
}
@Override
+ public void registerDeactivateHook(ApplicationId appId, Runnable hook) {
+ checkPermission(APP_READ);
+ checkNotNull(appId, APP_ID_NULL);
+ checkNotNull(hook, "Hook cannot be null");
+ deactivateHooks.put(appId.name(), hook);
+ }
+
+ @Override
public Application install(InputStream appDescStream) {
checkNotNull(appDescStream, "Application archive stream cannot be null");
Application app = store.create(appDescStream);
@@ -235,6 +248,7 @@ public class ApplicationManager
private synchronized boolean uninstallAppFeatures(Application app) throws Exception {
boolean changed = false;
+ invokeHook(deactivateHooks.get(app.id().name()), app.id());
for (String name : app.features()) {
Feature feature = featuresService.getFeature(name);
if (feature != null && featuresService.isInstalled(feature)) {
@@ -247,4 +261,16 @@ public class ApplicationManager
return changed;
}
+ // Invokes the specified function, if not null.
+ private void invokeHook(Runnable hook, ApplicationId appId) {
+ if (hook != null) {
+ try {
+ hook.run();
+ } catch (Exception e) {
+ log.warn("Deactivate hook for application {} encountered an error",
+ appId.name(), e);
+ }
+ }
+ }
+
}
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 f4d560a4..ec99c18b 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
@@ -24,6 +24,7 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.util.SharedExecutors;
+import org.onosproject.app.ApplicationService;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.ApplicationIdStore;
@@ -48,7 +49,7 @@ import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onosproject.security.AppGuard.checkPermission;
-import static org.onosproject.security.AppPermission.Type.*;
+import static org.onosproject.security.AppPermission.Type.APP_READ;
@@ -71,6 +72,9 @@ public class CoreManager implements CoreService {
protected IdBlockStore idBlockStore;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ApplicationService appService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentConfigService cfgService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -111,28 +115,24 @@ public class CoreManager implements CoreService {
@Override
public Version version() {
checkPermission(APP_READ);
-
return version;
}
@Override
public Set<ApplicationId> getAppIds() {
checkPermission(APP_READ);
-
return applicationIdStore.getAppIds();
}
@Override
public ApplicationId getAppId(Short id) {
checkPermission(APP_READ);
-
return applicationIdStore.getAppId(id);
}
@Override
public ApplicationId getAppId(String name) {
checkPermission(APP_READ);
-
return applicationIdStore.getAppId(name);
}
@@ -144,6 +144,13 @@ public class CoreManager implements CoreService {
}
@Override
+ public ApplicationId registerApplication(String name, Runnable preDeactivate) {
+ ApplicationId id = registerApplication(name);
+ appService.registerDeactivateHook(id, preDeactivate);
+ return id;
+ }
+
+ @Override
public IdGenerator getIdGenerator(String topic) {
IdBlockAllocator allocator = new StoreBasedIdBlockAllocator(topic, idBlockStore);
return new BlockAllocatorBasedIdGenerator(allocator);
@@ -185,10 +192,10 @@ public class CoreManager implements CoreService {
*/
private static Integer getIntegerProperty(Dictionary<?, ?> properties,
String propertyName) {
- Integer value = null;
+ Integer value;
try {
String s = (String) properties.get(propertyName);
- value = isNullOrEmpty(s) ? value : Integer.parseInt(s.trim());
+ value = isNullOrEmpty(s) ? null : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
value = null;
}
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
index 10fe75ea..1f55b157 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
@@ -55,9 +55,6 @@ public final class ResourceManager implements ResourceService, ResourceAdminServ
checkNotNull(consumer);
checkNotNull(resources);
- // TODO: implement support of resource hierarchy
- // allocation for a particular resource implies allocations for all of the sub-resources need to be done
-
boolean success = store.allocate(resources, consumer);
if (!success) {
return ImmutableList.of();
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java
index 4067d017..143f8c2b 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java
@@ -36,7 +36,7 @@ import static org.onlab.util.Tools.groupedThreads;
/**
* A class registering resources when they are detected.
*/
-@Component(immediate = true, enabled = false)
+@Component(immediate = true)
@Beta
public final class ResourceRegistrar {
diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java
index 1ce31ac3..5461cf01 100644
--- a/framework/src/onos/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java
+++ b/framework/src/onos/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java
@@ -24,11 +24,11 @@ import org.onosproject.app.ApplicationListener;
import org.onosproject.app.ApplicationState;
import org.onosproject.app.ApplicationStoreAdapter;
import org.onosproject.common.app.ApplicationArchive;
+import org.onosproject.common.event.impl.TestEventDispatcher;
import org.onosproject.core.Application;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.DefaultApplication;
import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.common.event.impl.TestEventDispatcher;
import java.io.InputStream;
import java.net.URI;
@@ -36,7 +36,7 @@ import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
import static org.onosproject.app.ApplicationEvent.Type.*;
import static org.onosproject.app.ApplicationState.ACTIVE;
import static org.onosproject.app.ApplicationState.INSTALLED;
@@ -53,6 +53,8 @@ public class ApplicationManagerTest {
private ApplicationManager mgr = new ApplicationManager();
private ApplicationListener listener = new TestListener();
+ private boolean deactivated = false;
+
@Before
public void setUp() {
injectEventDispatcher(mgr, new TestEventDispatcher());
@@ -88,6 +90,11 @@ public class ApplicationManagerTest {
assertEquals("incorrect app count", 1, mgr.getApplications().size());
assertEquals("incorrect app", app, mgr.getApplication(APP_ID));
assertEquals("incorrect app state", INSTALLED, mgr.getState(APP_ID));
+ mgr.registerDeactivateHook(app.id(), this::deactivateHook);
+ }
+
+ private void deactivateHook() {
+ deactivated = true;
}
@Test
@@ -102,6 +109,7 @@ public class ApplicationManagerTest {
install();
mgr.activate(APP_ID);
assertEquals("incorrect app state", ACTIVE, mgr.getState(APP_ID));
+ assertFalse("preDeactivate hook wrongly called", deactivated);
}
@Test
@@ -109,6 +117,7 @@ public class ApplicationManagerTest {
activate();
mgr.deactivate(APP_ID);
assertEquals("incorrect app state", INSTALLED, mgr.getState(APP_ID));
+ assertTrue("preDeactivate hook not called", deactivated);
}
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 9382960f..dfee9980 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
@@ -50,7 +50,7 @@ public class LogicalTimestamp implements Timestamp {
@Override
public int hashCode() {
- return Objects.hash(value);
+ return Long.hashCode(value);
}
@Override
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java
index 885361f0..f6cd198f 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java
@@ -56,7 +56,7 @@ public class PartitionId {
@Override
public int hashCode() {
- return Objects.hash(id);
+ return id;
}
@Override
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
index 687576c3..c9aaba5a 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
@@ -29,7 +29,6 @@ import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.TransactionContext;
-import org.onosproject.store.service.TransactionException;
import org.onosproject.store.service.TransactionalMap;
import org.onosproject.store.service.Versioned;
import org.slf4j.Logger;
@@ -100,29 +99,24 @@ public class ConsistentResourceStore implements ResourceStore {
TransactionContext tx = service.transactionContextBuilder().build();
tx.begin();
- try {
- TransactionalMap<ResourcePath, List<ResourcePath>> childTxMap =
- tx.getTransactionalMap(CHILD_MAP, SERIALIZER);
+ TransactionalMap<ResourcePath, List<ResourcePath>> childTxMap =
+ tx.getTransactionalMap(CHILD_MAP, SERIALIZER);
- Map<ResourcePath, List<ResourcePath>> resourceMap = resources.stream()
- .filter(x -> x.parent().isPresent())
- .collect(Collectors.groupingBy(x -> x.parent().get()));
+ Map<ResourcePath, List<ResourcePath>> resourceMap = resources.stream()
+ .filter(x -> x.parent().isPresent())
+ .collect(Collectors.groupingBy(x -> x.parent().get()));
- for (Map.Entry<ResourcePath, List<ResourcePath>> entry: resourceMap.entrySet()) {
- if (!isRegistered(childTxMap, entry.getKey())) {
- return abortTransaction(tx);
- }
-
- if (!appendValues(childTxMap, entry.getKey(), entry.getValue())) {
- return abortTransaction(tx);
- }
+ for (Map.Entry<ResourcePath, List<ResourcePath>> entry: resourceMap.entrySet()) {
+ if (!isRegistered(childTxMap, entry.getKey())) {
+ return abortTransaction(tx);
}
- return commitTransaction(tx);
- } catch (TransactionException e) {
- log.error("Exception thrown, abort the transaction", e);
- return abortTransaction(tx);
+ if (!appendValues(childTxMap, entry.getKey(), entry.getValue())) {
+ return abortTransaction(tx);
+ }
}
+
+ return tx.commit();
}
@Override
@@ -132,33 +126,28 @@ public class ConsistentResourceStore implements ResourceStore {
TransactionContext tx = service.transactionContextBuilder().build();
tx.begin();
- try {
- TransactionalMap<ResourcePath, List<ResourcePath>> childTxMap =
- tx.getTransactionalMap(CHILD_MAP, SERIALIZER);
- TransactionalMap<ResourcePath, ResourceConsumer> consumerTxMap =
- tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER);
-
- Map<ResourcePath, List<ResourcePath>> resourceMap = resources.stream()
- .filter(x -> x.parent().isPresent())
- .collect(Collectors.groupingBy(x -> x.parent().get()));
-
- // even if one of the resources is allocated to a consumer,
- // all unregistrations are regarded as failure
- for (Map.Entry<ResourcePath, List<ResourcePath>> entry: resourceMap.entrySet()) {
- if (entry.getValue().stream().anyMatch(x -> consumerTxMap.get(x) != null)) {
- return abortTransaction(tx);
- }
-
- if (!removeValues(childTxMap, entry.getKey(), entry.getValue())) {
- return abortTransaction(tx);
- }
+ TransactionalMap<ResourcePath, List<ResourcePath>> childTxMap =
+ tx.getTransactionalMap(CHILD_MAP, SERIALIZER);
+ TransactionalMap<ResourcePath, ResourceConsumer> consumerTxMap =
+ tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER);
+
+ Map<ResourcePath, List<ResourcePath>> resourceMap = resources.stream()
+ .filter(x -> x.parent().isPresent())
+ .collect(Collectors.groupingBy(x -> x.parent().get()));
+
+ // even if one of the resources is allocated to a consumer,
+ // all unregistrations are regarded as failure
+ for (Map.Entry<ResourcePath, List<ResourcePath>> entry: resourceMap.entrySet()) {
+ if (entry.getValue().stream().anyMatch(x -> consumerTxMap.get(x) != null)) {
+ return abortTransaction(tx);
}
- return commitTransaction(tx);
- } catch (TransactionException e) {
- log.error("Exception thrown, abort the transaction", e);
- return abortTransaction(tx);
+ if (!removeValues(childTxMap, entry.getKey(), entry.getValue())) {
+ return abortTransaction(tx);
+ }
}
+
+ return tx.commit();
}
@Override
@@ -169,28 +158,23 @@ public class ConsistentResourceStore implements ResourceStore {
TransactionContext tx = service.transactionContextBuilder().build();
tx.begin();
- try {
- TransactionalMap<ResourcePath, List<ResourcePath>> childTxMap =
- tx.getTransactionalMap(CHILD_MAP, SERIALIZER);
- TransactionalMap<ResourcePath, ResourceConsumer> consumerTxMap =
- tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER);
-
- for (ResourcePath resource: resources) {
- if (!isRegistered(childTxMap, resource)) {
- return abortTransaction(tx);
- }
-
- ResourceConsumer oldValue = consumerTxMap.put(resource, consumer);
- if (oldValue != null) {
- return abortTransaction(tx);
- }
+ TransactionalMap<ResourcePath, List<ResourcePath>> childTxMap =
+ tx.getTransactionalMap(CHILD_MAP, SERIALIZER);
+ TransactionalMap<ResourcePath, ResourceConsumer> consumerTxMap =
+ tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER);
+
+ for (ResourcePath resource: resources) {
+ if (!isRegistered(childTxMap, resource)) {
+ return abortTransaction(tx);
}
- return commitTransaction(tx);
- } catch (TransactionException e) {
- log.error("Exception thrown, abort the transaction", e);
- return abortTransaction(tx);
+ ResourceConsumer oldValue = consumerTxMap.put(resource, consumer);
+ if (oldValue != null) {
+ return abortTransaction(tx);
+ }
}
+
+ return tx.commit();
}
@Override
@@ -202,28 +186,23 @@ public class ConsistentResourceStore implements ResourceStore {
TransactionContext tx = service.transactionContextBuilder().build();
tx.begin();
- try {
- TransactionalMap<ResourcePath, ResourceConsumer> consumerTxMap =
- tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER);
- Iterator<ResourcePath> resourceIte = resources.iterator();
- Iterator<ResourceConsumer> consumerIte = consumers.iterator();
-
- while (resourceIte.hasNext() && consumerIte.hasNext()) {
- ResourcePath resource = resourceIte.next();
- ResourceConsumer consumer = consumerIte.next();
-
- // if this single release fails (because the resource is allocated to another consumer,
- // the whole release fails
- if (!consumerTxMap.remove(resource, consumer)) {
- return abortTransaction(tx);
- }
- }
+ TransactionalMap<ResourcePath, ResourceConsumer> consumerTxMap =
+ tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER);
+ Iterator<ResourcePath> resourceIte = resources.iterator();
+ Iterator<ResourceConsumer> consumerIte = consumers.iterator();
+
+ while (resourceIte.hasNext() && consumerIte.hasNext()) {
+ ResourcePath resource = resourceIte.next();
+ ResourceConsumer consumer = consumerIte.next();
- return commitTransaction(tx);
- } catch (TransactionException e) {
- log.error("Exception thrown, abort the transaction", e);
- return abortTransaction(tx);
+ // if this single release fails (because the resource is allocated to another consumer,
+ // the whole release fails
+ if (!consumerTxMap.remove(resource, consumer)) {
+ return abortTransaction(tx);
+ }
}
+
+ return tx.commit();
}
@Override
@@ -278,17 +257,6 @@ public class ConsistentResourceStore implements ResourceStore {
}
/**
- * Commit the transaction.
- *
- * @param tx transaction context
- * @return always true
- */
- private boolean commitTransaction(TransactionContext tx) {
- tx.commit();
- return true;
- }
-
- /**
* Appends the values to the existing values associated with the specified key.
* If the map already has all the given values, appending will not happen.
*
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 c332ada5..a38550e4 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
@@ -59,7 +59,6 @@ import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.TransactionContext;
-import org.onosproject.store.service.TransactionException;
import org.onosproject.store.service.TransactionalMap;
import org.onosproject.store.service.Versioned;
@@ -294,7 +293,7 @@ public class ConsistentLinkResourceStore extends
intentAllocs.put(allocations.intentId(), allocations);
allocations.links().forEach(link -> allocateLinkResource(tx, link, allocations));
tx.commit();
- } catch (TransactionException | ResourceAllocationException e) {
+ } catch (ResourceAllocationException e) {
log.error("Exception thrown, rolling back", e);
tx.abort();
} catch (Exception e) {
@@ -407,12 +406,8 @@ public class ConsistentLinkResourceStore extends
after.remove(allocations);
linkAllocs.replace(linkId, before, after);
});
- tx.commit();
- success = true;
- } catch (TransactionException e) {
- log.debug("Transaction failed, retrying", e);
- tx.abort();
- } catch (Exception e) {
+ success = tx.commit();
+ } catch (Exception e) {
log.error("Exception thrown during releaseResource {}", allocations, e);
tx.abort();
throw e;