Expose PolicyService through API package
Change-Id: I2166e14a0dd256b3f8ab680c8f2ad59cce8a3678
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/cli/TrafficMatchRemoveCommand.java b/impl/src/main/java/org/onosproject/segmentrouting/cli/TrafficMatchRemoveCommand.java
index f6f0212..bda4468 100644
--- a/impl/src/main/java/org/onosproject/segmentrouting/cli/TrafficMatchRemoveCommand.java
+++ b/impl/src/main/java/org/onosproject/segmentrouting/cli/TrafficMatchRemoveCommand.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.segmentrouting.cli;
-
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Service;
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/AbstractPolicy.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/AbstractPolicy.java
deleted file mode 100644
index 0ba6d05..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/AbstractPolicy.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-/**
- * Abstract implementation of the policy interface.
- */
-public abstract class AbstractPolicy implements Policy {
- // Shared state among policies
- protected PolicyId policyId;
- private PolicyType policyType;
-
- /**
- * Init the basic information of a policy.
- *
- * @param pType the policy type
- */
- protected AbstractPolicy(PolicyType pType) {
- policyType = pType;
- }
-
- @Override
- public PolicyId policyId() {
- return policyId;
- }
-
- @Override
- public PolicyType policyType() {
- return policyType;
- }
-
- /**
- * Computes the policy id. The actual computation is left to
- * the implementation class that can decide how to generate the
- * policy id.
- *
- * @return the computed policy id
- */
- protected abstract PolicyId computePolicyId();
-
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/DropPolicy.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/DropPolicy.java
deleted file mode 100644
index ac2e05e..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/DropPolicy.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Implementation of the drop policy.
- */
-public final class DropPolicy extends AbstractPolicy {
- /**
- * Builds up a DROP policy.
- */
- public DropPolicy() {
- super(PolicyType.DROP);
- policyId = computePolicyId();
- }
-
- @Override
- protected PolicyId computePolicyId() {
- return PolicyId.of(policyType().name());
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof DropPolicy)) {
- return false;
- }
- final DropPolicy other = (DropPolicy) obj;
- return Objects.equals(policyType(), other.policyType()) &&
- Objects.equals(policyId(), other.policyId());
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(policyId(), policyType());
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("policyId", policyId())
- .add("policyType", policyType())
- .toString();
- }
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/Policy.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/Policy.java
deleted file mode 100644
index bc1acf0..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/Policy.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-/**
- * Represents a policy in TOST.
- */
-public interface Policy {
- /**
- * Represents the type of a policy.
- */
- enum PolicyType {
- /**
- * The policy drops the associated traffic.
- */
- DROP,
-
- /**
- * The policy redirects traffic using custom routing.
- */
- REDIRECT
- }
-
- /**
- * Returns the policy id.
- *
- * @return the policy id
- */
- PolicyId policyId();
-
- /**
- * Returns the policy type.
- *
- * @return the type of a policy
- */
- PolicyType policyType();
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyData.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyData.java
deleted file mode 100644
index 5e207ae..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyData.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-import java.util.List;
-
-/**
- * Policy data retrieved from the system.
- */
-public final class PolicyData {
- // We want to provide access to the policy data as well as
- // the policy operations in the system and their status
- private final PolicyState policyState;
- private final Policy policy;
- private final List<String> operations;
-
- /**
- * Creates a policy data.
- *
- * @param pState the policy state
- * @param pol the policy
- * @param ops the operations associated
- */
- public PolicyData(PolicyState pState, Policy pol, List<String> ops) {
- policy = pol;
- policyState = pState;
- operations = ops;
- }
-
- /**
- * Returns the current state of the policy.
- *
- * @return the policy state
- */
- public PolicyState policyState() {
- return policyState;
- }
-
-
- /**
- * Returns the policy associated.
- *
- * @return the policy
- */
- public Policy policy() {
- return policy;
- }
-
- /**
- * Returns the operations in the system in form of strings.
- *
- * @return the operations
- */
- public List<String> operations() {
- return operations;
- }
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyId.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyId.java
deleted file mode 100644
index e3e0cc1..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyId.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Representation of a policy id.
- */
-public final class PolicyId extends Identifier<String> {
-
- protected PolicyId(String id) {
- super(id);
- }
-
- /**
- * Returns the id of the policy given the value.
- *
- * @param name policy id value
- * @return policy id
- */
- public static PolicyId of(String name) {
- checkNotNull(name);
- checkArgument(!name.isEmpty(), "Name cannot be empty");
- return new PolicyId(name);
- }
-
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyService.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyService.java
deleted file mode 100644
index 2e188ab..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyService.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-import java.util.Set;
-
-/**
- * Policies to drop, reroute, apply QoS and overlay the traffic.
- */
-public interface PolicyService {
- /**
- * Traffic match priority.
- */
- int TRAFFIC_MATCH_PRIORITY = 60000;
-
- /**
- * Creates or updates a policy.
- *
- * @param policy the policy to create
- * @return the id of the policy being created. Otherwise null.
- */
- PolicyId addOrUpdatePolicy(Policy policy);
-
- /**
- * Issues a policy removal.
- *
- * @param policyId the id of the policy to remove
- * @return whether or not the operation was successful
- */
- boolean removePolicy(PolicyId policyId);
-
- /**
- * Returns a set of policies. The policy types can be used
- * as filter.
- *
- * @param filter the policy types
- * @return the policies stored in the system observing
- * the filtering rule
- */
- Set<PolicyData> policies(Set<Policy.PolicyType> filter);
-
- /**
- * Attaches a traffic match to a policy.
- *
- * @param trafficMatch the traffic match
- * @return the traffic match id or null if not successful
- */
- TrafficMatchId addOrUpdateTrafficMatch(TrafficMatch trafficMatch);
-
- /**
- * Issues a traffic match removal.
- *
- * @param trafficMatchId the id of the traffic match to remove
- * @return whether or not the operation was successful
- */
- boolean removeTrafficMatch(TrafficMatchId trafficMatchId);
-
- /**
- * Returns a set of traffic matches.
- *
- * @return the traffic matches stored in the system
- */
- Set<TrafficMatchData> trafficMatches();
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyState.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyState.java
deleted file mode 100644
index 290852d..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/PolicyState.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-/**
- * Represents the state of a policy as seen by the system.
- */
-// TODO consider to add a FAILED state for an invalid policy that cannot be fulfilled even after a retry
-public enum PolicyState {
- /**
- * The policy is in the process of being added.
- */
- PENDING_ADD,
-
- /**
- * The policy has been added.
- */
- ADDED,
-
- /**
- * The policy is in the process of being removed.
- */
- PENDING_REMOVE
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/RedirectPolicy.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/RedirectPolicy.java
deleted file mode 100644
index d64d487..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/RedirectPolicy.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import org.onosproject.net.DeviceId;
-
-import java.util.Comparator;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import java.util.TreeSet;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkArgument;
-
-/**
- * Implementation of the redirect policy.
- */
-public final class RedirectPolicy extends AbstractPolicy {
- private List<DeviceId> spinesToEnforce = Lists.newArrayList();
-
- /**
- * Builds up a REDIRECT policy.
- *
- * @param spines the spines to enforce
- */
- public RedirectPolicy(Set<DeviceId> spines) {
- super(PolicyType.REDIRECT);
- checkArgument(!spines.isEmpty(), "Must have at least one spine");
- // Creates an ordered set
- TreeSet<DeviceId> sortedSpines = Sets.newTreeSet(Comparator.comparing(DeviceId::toString));
- sortedSpines.addAll(spines);
- spinesToEnforce.addAll(sortedSpines);
- policyId = computePolicyId();
- }
-
- /**
- * Returns the spines to be enforced during the path computation.
- *
- * @return the spines to be enforced
- */
- public List<DeviceId> spinesToEnforce() {
- return spinesToEnforce;
- }
-
- @Override
- protected PolicyId computePolicyId() {
- return PolicyId.of(policyType().name() + spinesToEnforce);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof RedirectPolicy)) {
- return false;
- }
- final RedirectPolicy other = (RedirectPolicy) obj;
- return Objects.equals(policyType(), other.policyType()) &&
- Objects.equals(policyId(), other.policyId()) &&
- Objects.equals(spinesToEnforce, other.spinesToEnforce);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(policyId(), policyType(), spinesToEnforce);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("policyId", policyId())
- .add("policyType", policyType())
- .add("spinesToEnforce", spinesToEnforce)
- .toString();
- }
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatch.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatch.java
deleted file mode 100644
index 83098fe..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatch.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-
-import com.google.common.hash.Funnel;
-import com.google.common.hash.HashCode;
-import com.google.common.hash.HashFunction;
-import com.google.common.hash.Hashing;
-import org.onosproject.net.flow.TrafficSelector;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Representation of a traffic match.
- */
-public final class TrafficMatch {
- // Traffic match internal state
- private TrafficMatchId trafficMatchId;
- private TrafficSelector trafficSelector;
- private PolicyId policyId;
-
- /**
- * Builds a traffic match.
- *
- * @param trafficselector the traffic selector
- * @param policyid the associated policy id
- */
- public TrafficMatch(TrafficSelector trafficselector, PolicyId policyid) {
- trafficSelector = trafficselector;
- trafficMatchId = TrafficMatchId.trafficMatchId(computeTrafficMatchId());
- policyId = policyid;
- }
-
- /**
- * Returns the traffic match id.
- *
- * @return the id of the traffic match
- */
- public TrafficMatchId trafficMatchId() {
- return trafficMatchId;
- }
-
- /**
- * Returns the id of the policy associated with.
- *
- * @return the policy id
- */
- public PolicyId policyId() {
- return policyId;
- }
-
- /**
- * Returns the traffic selector associated with.
- *
- * @return the traffic selector
- */
- public TrafficSelector trafficSelector() {
- return trafficSelector;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(trafficMatchId, trafficSelector, policyId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof TrafficMatch) {
- final TrafficMatch other = (TrafficMatch) obj;
- return Objects.equals(this.trafficMatchId, other.trafficMatchId) &&
- Objects.equals(trafficSelector, other.trafficSelector) &&
- Objects.equals(policyId, other.policyId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("trafficMatchId", trafficMatchId)
- .add("trafficSelector", trafficSelector)
- .add("policyId", policyId)
- .toString();
- }
-
- // Compute the id using the traffic selector. This method results to be consistent across the cluster.
- private int computeTrafficMatchId() {
- Funnel<TrafficSelector> selectorFunnel = (from, into) -> from.criteria()
- .forEach(c -> into.putUnencodedChars(c.toString()));
- HashFunction hashFunction = Hashing.murmur3_32();
- HashCode hashCode = hashFunction.newHasher()
- .putObject(trafficSelector, selectorFunnel)
- .hash();
- return hashCode.asInt();
- }
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchData.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchData.java
deleted file mode 100644
index 3932b4c..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchData.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-import java.util.List;
-
-/**
- * Traffic match data retrieved from the system.
- */
-public final class TrafficMatchData {
- // We want to provide access to the traffic match data as well as
- // the traffic match operations in the system and their status
- private final TrafficMatchState trafficMatchState;
- private final TrafficMatch trafficMatch;
- private final List<String> operations;
-
-
- public TrafficMatchData(TrafficMatchState tState, TrafficMatch tMatch, List<String> ops) {
- trafficMatch = tMatch;
- trafficMatchState = tState;
- operations = ops;
- }
-
- /**
- * Returns the current state of the traffic match.
- *
- * @return the traffic match state
- */
- public TrafficMatchState trafficMatchState() {
- return trafficMatchState;
- }
-
-
- /**
- * Returns the traffic match associated.
- *
- * @return the traffic match
- */
- public TrafficMatch trafficMatch() {
- return trafficMatch;
- }
-
- /**
- * Returns the operations in the system in form of strings.
- *
- * @return the operations
- */
- public List<String> operations() {
- return operations;
- }
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchId.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchId.java
deleted file mode 100644
index 5833f66..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchId.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Representation of a traffic match id.
- */
-public final class TrafficMatchId extends Identifier<Integer> {
-
- protected TrafficMatchId(int value) {
- super(value);
- }
-
- /**
- * Converts an int into a traffic match id.
- *
- * @param value the value of the id
- * @return the traffic match id
- */
- public static TrafficMatchId trafficMatchId(int value) {
- return new TrafficMatchId(value);
- }
-
- /**
- * Returns the id of the traffic match given the value.
- *
- * @param name traffic match id value
- * @return traffic match id
- */
- public static TrafficMatchId of(String name) {
- checkNotNull(name);
- checkArgument(!name.isEmpty(), "Name cannot be empty");
- return new TrafficMatchId(Integer.parseInt(name));
- }
-
- @Override
- public String toString() {
- return String.valueOf(this.identifier);
- }
-
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchState.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchState.java
deleted file mode 100644
index ab79e2f..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchState.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2021-present Open Networking Foundation
- *
- * 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.policy.api;
-
-/**
- * Represents the state of a traffic match as seen by the system.
- */
-// TODO consider to add a FAILED state for an invalid traffic match that cannot be fulfilled even after a retry
-public enum TrafficMatchState {
- /**
- * The traffic match is in the process of being added.
- */
- PENDING_ADD,
-
- /**
- * The traffic match has been added.
- */
- ADDED,
-
- /**
- * The traffic match is in the process of being removed.
- */
- PENDING_REMOVE
-}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/package-info.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/api/package-info.java
deleted file mode 100644
index cfbaa28..0000000
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.
- */
-
-/**
- * Policy API.
- */
-package org.onosproject.segmentrouting.policy.api;
\ No newline at end of file
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/DropPolicyCodec.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/impl/DropPolicyCodec.java
similarity index 92%
rename from impl/src/main/java/org/onosproject/segmentrouting/policy/api/DropPolicyCodec.java
rename to impl/src/main/java/org/onosproject/segmentrouting/policy/impl/DropPolicyCodec.java
index 407bd08..2d6f321 100644
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/DropPolicyCodec.java
+++ b/impl/src/main/java/org/onosproject/segmentrouting/policy/impl/DropPolicyCodec.java
@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.segmentrouting.policy.api;
+package org.onosproject.segmentrouting.policy.impl;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
+import org.onosproject.segmentrouting.policy.api.DropPolicy;
/**
* Codec of DropPolicy class.
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/impl/PolicyManager.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/impl/PolicyManager.java
index 87fa61a..f1dc285 100644
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/impl/PolicyManager.java
+++ b/impl/src/main/java/org/onosproject/segmentrouting/policy/impl/PolicyManager.java
@@ -47,22 +47,19 @@
import org.onosproject.net.intent.WorkPartitionService;
import org.onosproject.net.link.LinkService;
import org.onosproject.segmentrouting.SegmentRoutingService;
-import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
import org.onosproject.segmentrouting.policy.api.DropPolicy;
-import org.onosproject.segmentrouting.policy.api.DropPolicyCodec;
import org.onosproject.segmentrouting.policy.api.Policy;
-import org.onosproject.segmentrouting.policy.api.Policy.PolicyType;
import org.onosproject.segmentrouting.policy.api.PolicyData;
import org.onosproject.segmentrouting.policy.api.PolicyId;
import org.onosproject.segmentrouting.policy.api.PolicyService;
import org.onosproject.segmentrouting.policy.api.PolicyState;
import org.onosproject.segmentrouting.policy.api.RedirectPolicy;
-import org.onosproject.segmentrouting.policy.api.RedirectPolicyCodec;
import org.onosproject.segmentrouting.policy.api.TrafficMatch;
-import org.onosproject.segmentrouting.policy.api.TrafficMatchCodec;
import org.onosproject.segmentrouting.policy.api.TrafficMatchData;
import org.onosproject.segmentrouting.policy.api.TrafficMatchId;
import org.onosproject.segmentrouting.policy.api.TrafficMatchState;
+import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
+import org.onosproject.segmentrouting.policy.api.Policy.PolicyType;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.MapEvent;
@@ -101,7 +98,7 @@
static final String KEY_SEPARATOR = "|";
// Supported policies
- private static final Set<Policy.PolicyType> SUPPORTED_POLICIES = ImmutableSet.of(
+ private static final Set<PolicyType> SUPPORTED_POLICIES = ImmutableSet.of(
PolicyType.DROP, PolicyType.REDIRECT);
// Driver should use this meta to match port_is_edge field in the ACL table
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/RedirectPolicyCodec.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/impl/RedirectPolicyCodec.java
similarity index 95%
rename from impl/src/main/java/org/onosproject/segmentrouting/policy/api/RedirectPolicyCodec.java
rename to impl/src/main/java/org/onosproject/segmentrouting/policy/impl/RedirectPolicyCodec.java
index efb2828..f3c4ab9 100644
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/RedirectPolicyCodec.java
+++ b/impl/src/main/java/org/onosproject/segmentrouting/policy/impl/RedirectPolicyCodec.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.segmentrouting.policy.api;
+package org.onosproject.segmentrouting.policy.impl;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -21,6 +21,7 @@
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.net.DeviceId;
+import org.onosproject.segmentrouting.policy.api.RedirectPolicy;
import java.util.LinkedList;
import java.util.List;
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchCodec.java b/impl/src/main/java/org/onosproject/segmentrouting/policy/impl/TrafficMatchCodec.java
similarity index 93%
rename from impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchCodec.java
rename to impl/src/main/java/org/onosproject/segmentrouting/policy/impl/TrafficMatchCodec.java
index 1f4f8be..fe6d464 100644
--- a/impl/src/main/java/org/onosproject/segmentrouting/policy/api/TrafficMatchCodec.java
+++ b/impl/src/main/java/org/onosproject/segmentrouting/policy/impl/TrafficMatchCodec.java
@@ -13,13 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.segmentrouting.policy.api;
+package org.onosproject.segmentrouting.policy.impl;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.segmentrouting.policy.api.PolicyId;
+import org.onosproject.segmentrouting.policy.api.TrafficMatch;
import static org.onlab.util.Tools.nullIsIllegal;
diff --git a/impl/src/test/java/org/onosproject/segmentrouting/policy/api/DropPolicyCodecTest.java b/impl/src/test/java/org/onosproject/segmentrouting/policy/impl/DropPolicyCodecTest.java
similarity index 95%
rename from impl/src/test/java/org/onosproject/segmentrouting/policy/api/DropPolicyCodecTest.java
rename to impl/src/test/java/org/onosproject/segmentrouting/policy/impl/DropPolicyCodecTest.java
index 5d95625..e9af865 100644
--- a/impl/src/test/java/org/onosproject/segmentrouting/policy/api/DropPolicyCodecTest.java
+++ b/impl/src/test/java/org/onosproject/segmentrouting/policy/impl/DropPolicyCodecTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.segmentrouting.policy.api;
+package org.onosproject.segmentrouting.policy.impl;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -24,6 +24,7 @@
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.codec.impl.MockCodecContext;
+import org.onosproject.segmentrouting.policy.api.DropPolicy;
import java.io.InputStream;
diff --git a/impl/src/test/java/org/onosproject/segmentrouting/policy/api/RedirectPolicyCodecTest.java b/impl/src/test/java/org/onosproject/segmentrouting/policy/impl/RedirectPolicyCodecTest.java
similarity index 95%
rename from impl/src/test/java/org/onosproject/segmentrouting/policy/api/RedirectPolicyCodecTest.java
rename to impl/src/test/java/org/onosproject/segmentrouting/policy/impl/RedirectPolicyCodecTest.java
index 7541436..ff75769 100644
--- a/impl/src/test/java/org/onosproject/segmentrouting/policy/api/RedirectPolicyCodecTest.java
+++ b/impl/src/test/java/org/onosproject/segmentrouting/policy/impl/RedirectPolicyCodecTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.segmentrouting.policy.api;
+package org.onosproject.segmentrouting.policy.impl;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -25,6 +25,7 @@
import org.onosproject.codec.JsonCodec;
import org.onosproject.codec.impl.MockCodecContext;
import org.onosproject.net.DeviceId;
+import org.onosproject.segmentrouting.policy.api.RedirectPolicy;
import java.io.InputStream;
import java.util.LinkedList;
diff --git a/impl/src/test/java/org/onosproject/segmentrouting/policy/api/TrafficMatchCodecTest.java b/impl/src/test/java/org/onosproject/segmentrouting/policy/impl/TrafficMatchCodecTest.java
similarity index 94%
rename from impl/src/test/java/org/onosproject/segmentrouting/policy/api/TrafficMatchCodecTest.java
rename to impl/src/test/java/org/onosproject/segmentrouting/policy/impl/TrafficMatchCodecTest.java
index c70eb7c..f78fb80 100644
--- a/impl/src/test/java/org/onosproject/segmentrouting/policy/api/TrafficMatchCodecTest.java
+++ b/impl/src/test/java/org/onosproject/segmentrouting/policy/impl/TrafficMatchCodecTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.segmentrouting.policy.api;
+package org.onosproject.segmentrouting.policy.impl;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -28,6 +28,8 @@
import org.onosproject.codec.impl.MockCodecContext;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.segmentrouting.policy.api.PolicyId;
+import org.onosproject.segmentrouting.policy.api.TrafficMatch;
import java.io.InputStream;