Segment Routing refactoring
- Change name: McastEventHandler -> McastHandler
- Separate HostHandler from SRManager
- Move storekeys to a dedicated package
- Replace SRObjevtiveContext and BridgeTableObjectiveContext with DefaultObjectiveContext
Change-Id: Iab25529487004759105e5ba60c1d2a3852ac45e6
diff --git a/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java b/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
index cb58f84..457be6d 100644
--- a/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
+++ b/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
@@ -53,6 +53,10 @@
import org.onosproject.segmentrouting.SegmentRoutingManager;
import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
import org.onosproject.segmentrouting.config.DeviceProperties;
+import org.onosproject.segmentrouting.storekey.NeighborSetNextObjectiveStoreKey;
+import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey;
+import org.onosproject.segmentrouting.storekey.SubnetNextObjectiveStoreKey;
+import org.onosproject.segmentrouting.storekey.XConnectNextObjectiveStoreKey;
import org.onosproject.store.service.EventuallyConsistentMap;
import org.slf4j.Logger;
diff --git a/src/main/java/org/onosproject/segmentrouting/grouphandler/McastNextObjectiveStoreKey.java b/src/main/java/org/onosproject/segmentrouting/grouphandler/McastNextObjectiveStoreKey.java
deleted file mode 100644
index 526db72..0000000
--- a/src/main/java/org/onosproject/segmentrouting/grouphandler/McastNextObjectiveStoreKey.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2015-present 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.segmentrouting.grouphandler;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.net.DeviceId;
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import java.util.Objects;
-
-/**
- * Key of multicast next objective store.
- */
-public class McastNextObjectiveStoreKey {
- private final IpAddress mcastIp;
- private final DeviceId deviceId;
-
- /**
- * Constructs the key of multicast next objective store.
- *
- * @param mcastIp multicast group IP address
- * @param deviceId device ID
- */
- public McastNextObjectiveStoreKey(IpAddress mcastIp, DeviceId deviceId) {
- checkNotNull(mcastIp, "mcastIp cannot be null");
- checkNotNull(deviceId, "deviceId cannot be null");
- checkArgument(mcastIp.isMulticast(), "mcastIp must be a multicast address");
- this.mcastIp = mcastIp;
- this.deviceId = deviceId;
- }
-
- /**
- * Returns the multicast IP address of this key.
- *
- * @return multicast IP
- */
- public IpAddress mcastIp() {
- return this.mcastIp;
- }
-
- /**
- * Returns the device ID of this key.
- *
- * @return device ID
- */
- public DeviceId deviceId() {
- return this.deviceId;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof McastNextObjectiveStoreKey)) {
- return false;
- }
- McastNextObjectiveStoreKey that =
- (McastNextObjectiveStoreKey) o;
- return (Objects.equals(this.mcastIp, that.mcastIp) &&
- Objects.equals(this.deviceId, that.deviceId));
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(mcastIp, deviceId);
- }
-
- @Override
- public String toString() {
- return toStringHelper(getClass())
- .add("mcastIp", mcastIp)
- .add("deviceId", deviceId)
- .toString();
- }
-}
diff --git a/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSetNextObjectiveStoreKey.java b/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSetNextObjectiveStoreKey.java
deleted file mode 100644
index f1fa614..0000000
--- a/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSetNextObjectiveStoreKey.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2015-present 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.segmentrouting.grouphandler;
-
-import java.util.Objects;
-
-import org.onosproject.net.DeviceId;
-
-/**
- * Key of Neighborset next objective store.
- */
-public class NeighborSetNextObjectiveStoreKey {
- private final DeviceId deviceId;
- private final NeighborSet ns;
-
- /**
- * Constructs the key of neighbor set next objective store.
- *
- * @param deviceId device ID
- * @param ns neighbor set
- */
- public NeighborSetNextObjectiveStoreKey(DeviceId deviceId,
- NeighborSet ns) {
- this.deviceId = deviceId;
- this.ns = ns;
- }
-
- /**
- * Returns the device ID in the key.
- *
- * @return device ID
- */
- public DeviceId deviceId() {
- return this.deviceId;
- }
-
- /**
- * Returns the neighbor set in the key.
- *
- * @return neighbor set
- */
- public NeighborSet neighborSet() {
- return this.ns;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof NeighborSetNextObjectiveStoreKey)) {
- return false;
- }
- NeighborSetNextObjectiveStoreKey that =
- (NeighborSetNextObjectiveStoreKey) o;
- return (Objects.equals(this.deviceId, that.deviceId) &&
- Objects.equals(this.ns, that.ns));
- }
-
- // The list of neighbor ids and label are used for comparison.
- @Override
- public int hashCode() {
- int result = 17;
- result = 31 * result + Objects.hashCode(this.deviceId)
- + Objects.hashCode(this.ns);
-
- return result;
- }
-
- @Override
- public String toString() {
- return "Device: " + deviceId + " Neighborset: " + ns;
- }
-}
diff --git a/src/main/java/org/onosproject/segmentrouting/grouphandler/PortNextObjectiveStoreKey.java b/src/main/java/org/onosproject/segmentrouting/grouphandler/PortNextObjectiveStoreKey.java
deleted file mode 100644
index a8b7de9..0000000
--- a/src/main/java/org/onosproject/segmentrouting/grouphandler/PortNextObjectiveStoreKey.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2015-present 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.segmentrouting.grouphandler;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.TrafficTreatment;
-
-import java.util.Objects;
-
-/**
- * Key of Device/Port to NextObjective store.
- *
- * Since there can be multiple next objectives to the same physical port,
- * we differentiate between them by including the treatment in the key.
- */
-public class PortNextObjectiveStoreKey {
- private final DeviceId deviceId;
- private final PortNumber portNum;
- private final TrafficTreatment treatment;
-
- /**
- * Constructs the key of port next objective store.
- *
- * @param deviceId device ID
- * @param portNum port number
- * @param treatment treatment that will be applied to the interface
- */
- public PortNextObjectiveStoreKey(DeviceId deviceId, PortNumber portNum,
- TrafficTreatment treatment) {
- this.deviceId = deviceId;
- this.portNum = portNum;
- this.treatment = treatment;
- }
-
- /**
- * Gets device id in this PortNextObjectiveStoreKey.
- *
- * @return device id
- */
- public DeviceId deviceId() {
- return deviceId;
- }
-
- /**
- * Gets port information in this PortNextObjectiveStoreKey.
- *
- * @return port information
- */
- public PortNumber portNumber() {
- return portNum;
- }
-
- /**
- * Gets treatment information in this PortNextObjectiveStoreKey.
- *
- * @return treatment information
- */
- public TrafficTreatment treatment() {
- return treatment;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof PortNextObjectiveStoreKey)) {
- return false;
- }
- PortNextObjectiveStoreKey that =
- (PortNextObjectiveStoreKey) o;
- return (Objects.equals(this.deviceId, that.deviceId) &&
- Objects.equals(this.portNum, that.portNum) &&
- Objects.equals(this.treatment, that.treatment));
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(deviceId, portNum, treatment);
- }
-
- @Override
- public String toString() {
- return "Device: " + deviceId + " Port: " + portNum + " Treatment: " + treatment;
- }
-}
diff --git a/src/main/java/org/onosproject/segmentrouting/grouphandler/SubnetNextObjectiveStoreKey.java b/src/main/java/org/onosproject/segmentrouting/grouphandler/SubnetNextObjectiveStoreKey.java
deleted file mode 100644
index c83a3dd..0000000
--- a/src/main/java/org/onosproject/segmentrouting/grouphandler/SubnetNextObjectiveStoreKey.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2015-present 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.segmentrouting.grouphandler;
-
-import org.onlab.packet.IpPrefix;
-import org.onosproject.net.DeviceId;
-
-import java.util.Objects;
-
-/**
- * Key of Subnet to NextObjective store.
- */
-public class SubnetNextObjectiveStoreKey {
- private final DeviceId deviceId;
- private final IpPrefix prefix;
-
- /**
- * Constructs the key of subnet next objective store.
- *
- * @param deviceId device ID
- * @param prefix subnet information
- */
- public SubnetNextObjectiveStoreKey(DeviceId deviceId,
- IpPrefix prefix) {
- this.deviceId = deviceId;
- this.prefix = prefix;
- }
-
- /**
- * Gets device id in this SubnetNextObjectiveStoreKey.
- *
- * @return device id
- */
- public DeviceId deviceId() {
- return this.deviceId;
- }
-
- /**
- * Gets subnet information in this SubnetNextObjectiveStoreKey.
- *
- * @return subnet information
- */
- public IpPrefix prefix() {
- return this.prefix;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof SubnetNextObjectiveStoreKey)) {
- return false;
- }
- SubnetNextObjectiveStoreKey that =
- (SubnetNextObjectiveStoreKey) o;
- return (Objects.equals(this.deviceId, that.deviceId) &&
- Objects.equals(this.prefix, that.prefix));
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(deviceId, prefix);
- }
-
- @Override
- public String toString() {
- return "Device: " + deviceId + " Subnet: " + prefix;
- }
-}
diff --git a/src/main/java/org/onosproject/segmentrouting/grouphandler/XConnectNextObjectiveStoreKey.java b/src/main/java/org/onosproject/segmentrouting/grouphandler/XConnectNextObjectiveStoreKey.java
deleted file mode 100644
index a85c572..0000000
--- a/src/main/java/org/onosproject/segmentrouting/grouphandler/XConnectNextObjectiveStoreKey.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2016-present 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.segmentrouting.grouphandler;
-
-import org.onlab.packet.VlanId;
-import org.onosproject.net.DeviceId;
-
-import java.util.Objects;
-
-/**
- * Key of VLAN cross-connect next objective store.
- */
-public class XConnectNextObjectiveStoreKey {
- private final DeviceId deviceId;
- private final VlanId vlanId;
-
- /**
- * Constructs the key of cross-connect next objective store.
- *
- * @param deviceId device ID of the VLAN cross-connection
- * @param vlanId VLAN ID of the VLAN cross-connection
- */
- public XConnectNextObjectiveStoreKey(DeviceId deviceId, VlanId vlanId) {
- this.deviceId = deviceId;
- this.vlanId = vlanId;
- }
-
- /**
- * Returns the device ID of this key.
- *
- * @return device ID
- */
- public DeviceId deviceId() {
- return this.deviceId;
- }
-
- /**
- * Returns the VLAN ID of this key.
- *
- * @return VLAN ID
- */
- public VlanId vlanId() {
- return this.vlanId;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof XConnectNextObjectiveStoreKey)) {
- return false;
- }
- XConnectNextObjectiveStoreKey that =
- (XConnectNextObjectiveStoreKey) o;
- return (Objects.equals(this.deviceId, that.deviceId) &&
- Objects.equals(this.vlanId, that.vlanId));
- }
-
- // The list of neighbor ids and label are used for comparison.
- @Override
- public int hashCode() {
- return Objects.hash(deviceId, vlanId);
- }
-
- @Override
- public String toString() {
- return "Device: " + deviceId + " VlanId: " + vlanId;
- }
-}