Committed by
Phaneendra-Huawei
[ONOS-3114] Added service for storing list of classifier devices for sfc
Change-Id: I780b1c8d289e4cba8cce76dde2439e95f88fa9a0
Showing
5 changed files
with
165 additions
and
0 deletions
| ... | @@ -61,6 +61,12 @@ | ... | @@ -61,6 +61,12 @@ |
| 61 | <scope>test</scope> | 61 | <scope>test</scope> |
| 62 | </dependency> | 62 | </dependency> |
| 63 | <dependency> | 63 | <dependency> |
| 64 | + <groupId>org.onosproject</groupId> | ||
| 65 | + <artifactId>onos-api</artifactId> | ||
| 66 | + <scope>test</scope> | ||
| 67 | + <classifier>tests</classifier> | ||
| 68 | + </dependency> | ||
| 69 | + <dependency> | ||
| 64 | <groupId>com.sun.jersey</groupId> | 70 | <groupId>com.sun.jersey</groupId> |
| 65 | <artifactId>jersey-servlet</artifactId> | 71 | <artifactId>jersey-servlet</artifactId> |
| 66 | </dependency> | 72 | </dependency> | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.vtnrsc.classifier; | ||
| 17 | + | ||
| 18 | +import org.onosproject.net.DeviceId; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Provides Services for Classifier. | ||
| 22 | + */ | ||
| 23 | +public interface ClassifierService { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * Get Classifier devices for sfc. | ||
| 27 | + * | ||
| 28 | + * @return list of device id's for classifiers | ||
| 29 | + */ | ||
| 30 | + Iterable<DeviceId> getClassifiers(); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * Add Classifier device for sfc. | ||
| 34 | + */ | ||
| 35 | + void addClassifier(DeviceId deviceId); | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Remove Classifier device for sfc. | ||
| 39 | + */ | ||
| 40 | + void removeClassifier(DeviceId deviceId); | ||
| 41 | +} |
apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/impl/ClassifierManager.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.vtnrsc.classifier.impl; | ||
| 17 | + | ||
| 18 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 19 | + | ||
| 20 | +import org.apache.felix.scr.annotations.Activate; | ||
| 21 | +import org.apache.felix.scr.annotations.Component; | ||
| 22 | +import org.apache.felix.scr.annotations.Deactivate; | ||
| 23 | +import org.apache.felix.scr.annotations.Reference; | ||
| 24 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 25 | +import org.apache.felix.scr.annotations.Service; | ||
| 26 | +import org.onosproject.net.DeviceId; | ||
| 27 | +import org.onosproject.store.serializers.KryoNamespaces; | ||
| 28 | +import org.onosproject.store.service.DistributedSet; | ||
| 29 | +import org.onosproject.store.service.Serializer; | ||
| 30 | +import org.onosproject.store.service.StorageService; | ||
| 31 | +import org.onosproject.vtnrsc.classifier.ClassifierService; | ||
| 32 | +import org.slf4j.Logger; | ||
| 33 | + | ||
| 34 | +import com.google.common.collect.ImmutableList; | ||
| 35 | + | ||
| 36 | +/** | ||
| 37 | + * Provides implementation of the Classifier Service. | ||
| 38 | + */ | ||
| 39 | +@Component(immediate = true) | ||
| 40 | +@Service | ||
| 41 | +public class ClassifierManager implements ClassifierService { | ||
| 42 | + | ||
| 43 | + private final Logger log = getLogger(ClassifierManager.class); | ||
| 44 | + | ||
| 45 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 46 | + protected StorageService storageService; | ||
| 47 | + | ||
| 48 | + private DistributedSet<DeviceId> classifierList; | ||
| 49 | + | ||
| 50 | + @Activate | ||
| 51 | + protected void activate() { | ||
| 52 | + classifierList = storageService.<DeviceId>setBuilder() | ||
| 53 | + .withName("classifier") | ||
| 54 | + .withSerializer(Serializer.using(KryoNamespaces.API)) | ||
| 55 | + .build(); | ||
| 56 | + log.info("Started"); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Deactivate | ||
| 60 | + protected void deactivate() { | ||
| 61 | + log.info("Stopped"); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public void addClassifier(DeviceId deviceId) { | ||
| 66 | + classifierList.add(deviceId); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Override | ||
| 70 | + public Iterable<DeviceId> getClassifiers() { | ||
| 71 | + return ImmutableList.copyOf(classifierList); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Override | ||
| 75 | + public void removeClassifier(DeviceId deviceId) { | ||
| 76 | + classifierList.remove(deviceId); | ||
| 77 | + } | ||
| 78 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Provides implementation of the Classifier service. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.vtnrsc.classifier.impl; |
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Service for interacting with Classifier of SFC. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.vtnrsc.classifier; |
-
Please register or login to post a comment