diff options
Diffstat (limited to 'framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier')
2 files changed, 63 insertions, 36 deletions
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java index c160d221..c5911ff2 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java @@ -24,49 +24,59 @@ import org.onosproject.vtnrsc.FlowClassifierId; public interface FlowClassifierService { /** - * Store Flow Classifier. + * Check whether Flow Classifier is present based on given Flow Classifier + * Id. * - * @param flowClassifier Flow Classifier - * @return true if adding Flow Classifier into store is success otherwise return false. + * @param id flow classifier identifier + * @return true if flow classifier is present otherwise return false */ - boolean createFlowClassifier(FlowClassifier flowClassifier); + boolean exists(FlowClassifierId id); /** - * Return the existing collection of Flow Classifier. + * Returns the number of flow classifiers known to the system. * - * @return Flow Classifier collections. + * @return number of flow classifiers */ - Iterable<FlowClassifier> getFlowClassifiers(); + int getFlowClassifierCount(); + + /** + * Store Flow Classifier. + * + * @param flowClassifier flow classifier + * @return true if adding flow classifier into store is success otherwise + * return false + */ + boolean createFlowClassifier(FlowClassifier flowClassifier); /** - * Check whether Flow Classifier is present based on given Flow Classifier Id. + * Return the existing collection of Flow Classifier. * - * @param id Flow Classifier. - * @return true if Flow Classifier is present otherwise return false. + * @return flow classifier collections */ - boolean hasFlowClassifier(FlowClassifierId id); + Iterable<FlowClassifier> getFlowClassifiers(); /** * Retrieve the Flow Classifier based on given Flow Classifier id. * - * @param id Flow Classifier Id. - * @return Flow Classifier if present otherwise returns null. + * @param id flow classifier identifier + * @return flow classifier if present otherwise returns null */ FlowClassifier getFlowClassifier(FlowClassifierId id); /** * Update Flow Classifier based on given Flow Classifier Id. * - * @param flowClassifier Flow Classifier. - * @return true if update is success otherwise return false. + * @param flowClassifier flow classifier + * @return true if flow classifier update is success otherwise return false */ boolean updateFlowClassifier(FlowClassifier flowClassifier); /** * Remove Flow Classifier from store based on given Flow Classifier Id. * - * @param id Flow Classifier Id. - * @return true if Flow Classifier removal is success otherwise return false. + * @param id flow classifier identifier + * @return true if flow classifier removal is success otherwise return + * false */ boolean removeFlowClassifier(FlowClassifierId id); } diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java index ee5873d6..4a60cd34 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java @@ -54,7 +54,7 @@ public class FlowClassifierManager implements FlowClassifierService { protected StorageService storageService; @Activate - private void activate() { + protected void activate() { KryoNamespace.Builder serializer = KryoNamespace.newBuilder() .register(KryoNamespaces.API) .register(MultiValuedTimestamp.class) @@ -67,34 +67,25 @@ public class FlowClassifierManager implements FlowClassifierService { } @Deactivate - private void deactivate() { + protected void deactivate() { flowClassifierStore.destroy(); log.info("Flow Classifier service deactivated"); } @Override - public boolean createFlowClassifier(FlowClassifier flowClassifier) { - log.debug("createFlowClassifier"); - checkNotNull(flowClassifier, FLOW_CLASSIFIER_NOT_NULL); - FlowClassifierId id = flowClassifier.flowClassifierId(); - - flowClassifierStore.put(id, flowClassifier); - if (!flowClassifierStore.containsKey(id)) { - log.debug("Flow Classifier creation is failed whose identifier is {}.", id.toString()); - return false; - } - return true; + public boolean exists(FlowClassifierId id) { + checkNotNull(id, FLOW_CLASSIFIER_ID_NOT_NULL); + return flowClassifierStore.containsKey(id); } @Override - public Iterable<FlowClassifier> getFlowClassifiers() { - return ImmutableList.copyOf(flowClassifierStore.values()); + public int getFlowClassifierCount() { + return flowClassifierStore.size(); } @Override - public boolean hasFlowClassifier(FlowClassifierId id) { - checkNotNull(id, FLOW_CLASSIFIER_ID_NOT_NULL); - return flowClassifierStore.containsKey(id); + public Iterable<FlowClassifier> getFlowClassifiers() { + return ImmutableList.copyOf(flowClassifierStore.values()); } @Override @@ -104,10 +95,36 @@ public class FlowClassifierManager implements FlowClassifierService { } @Override - public boolean updateFlowClassifier(FlowClassifier flowClassifier) { + public boolean createFlowClassifier(FlowClassifier flowClassifier) { + log.debug("createFlowClassifier"); checkNotNull(flowClassifier, FLOW_CLASSIFIER_NOT_NULL); FlowClassifierId id = flowClassifier.flowClassifierId(); + flowClassifierStore.put(id, flowClassifier); + if (!flowClassifierStore.containsKey(id)) { + log.debug("Flow Classifier creation is failed whose identifier is {}.", id.toString()); + return false; + } + return true; + } + + @Override + public boolean updateFlowClassifier(FlowClassifier flowClassifier) { + checkNotNull(flowClassifier, FLOW_CLASSIFIER_NOT_NULL); + + if (!flowClassifierStore.containsKey(flowClassifier.flowClassifierId())) { + log.debug("The flowClassifier is not exist whose identifier was {} ", flowClassifier.flowClassifierId() + .toString()); + return false; + } + + flowClassifierStore.put(flowClassifier.flowClassifierId(), flowClassifier); + + if (!flowClassifier.equals(flowClassifierStore.get(flowClassifier.flowClassifierId()))) { + log.debug("Updation of flowClassifier is failed whose identifier was {} ", flowClassifier + .flowClassifierId().toString()); + return false; + } return true; } |