Committed by
Gerrit Code Review
[ONOS-3111] port-pair-group manager modification
Change-Id: I37df58e8589147624393a84efdf28e0bb8dfa29c
Showing
2 changed files
with
8 additions
and
34 deletions
... | @@ -15,13 +15,14 @@ | ... | @@ -15,13 +15,14 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.vtnrsc.portpairgroup; | 16 | package org.onosproject.vtnrsc.portpairgroup; |
17 | 17 | ||
18 | +import org.onosproject.event.ListenerService; | ||
18 | import org.onosproject.vtnrsc.PortPairGroup; | 19 | import org.onosproject.vtnrsc.PortPairGroup; |
19 | import org.onosproject.vtnrsc.PortPairGroupId; | 20 | import org.onosproject.vtnrsc.PortPairGroupId; |
20 | 21 | ||
21 | /** | 22 | /** |
22 | * Service for interacting with the inventory of port pair groups. | 23 | * Service for interacting with the inventory of port pair groups. |
23 | */ | 24 | */ |
24 | -public interface PortPairGroupService { | 25 | +public interface PortPairGroupService extends ListenerService<PortPairGroupEvent, PortPairGroupListener> { |
25 | 26 | ||
26 | /** | 27 | /** |
27 | * Returns if the port pair group is existed. | 28 | * Returns if the port pair group is existed. |
... | @@ -77,18 +78,4 @@ public interface PortPairGroupService { | ... | @@ -77,18 +78,4 @@ public interface PortPairGroupService { |
77 | * @return true if the give port pair group is deleted successfully. | 78 | * @return true if the give port pair group is deleted successfully. |
78 | */ | 79 | */ |
79 | boolean removePortPairGroup(PortPairGroupId portPairGroupId); | 80 | boolean removePortPairGroup(PortPairGroupId portPairGroupId); |
80 | - | ||
81 | - /** | ||
82 | - * Adds the specified listener to Port-Pair-Group manager. | ||
83 | - * | ||
84 | - * @param listener Port-Pair-Group listener | ||
85 | - */ | ||
86 | - void addListener(PortPairGroupListener listener); | ||
87 | - | ||
88 | - /** | ||
89 | - * Removes the specified listener to Port-Pair-Group manager. | ||
90 | - * | ||
91 | - * @param listener Port-Pair-Group listener | ||
92 | - */ | ||
93 | - void removeListener(PortPairGroupListener listener); | ||
94 | } | 81 | } | ... | ... |
... | @@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkNotNull; |
19 | import static org.slf4j.LoggerFactory.getLogger; | 19 | import static org.slf4j.LoggerFactory.getLogger; |
20 | 20 | ||
21 | import java.util.Collections; | 21 | import java.util.Collections; |
22 | -import java.util.Set; | ||
23 | 22 | ||
24 | import org.apache.felix.scr.annotations.Activate; | 23 | import org.apache.felix.scr.annotations.Activate; |
25 | import org.apache.felix.scr.annotations.Component; | 24 | import org.apache.felix.scr.annotations.Component; |
... | @@ -28,6 +27,7 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -28,6 +27,7 @@ import org.apache.felix.scr.annotations.Reference; |
28 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 27 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
29 | import org.apache.felix.scr.annotations.Service; | 28 | import org.apache.felix.scr.annotations.Service; |
30 | import org.onlab.util.KryoNamespace; | 29 | import org.onlab.util.KryoNamespace; |
30 | +import org.onosproject.event.AbstractListenerManager; | ||
31 | import org.onosproject.store.serializers.KryoNamespaces; | 31 | import org.onosproject.store.serializers.KryoNamespaces; |
32 | import org.onosproject.store.service.EventuallyConsistentMap; | 32 | import org.onosproject.store.service.EventuallyConsistentMap; |
33 | import org.onosproject.store.service.MultiValuedTimestamp; | 33 | import org.onosproject.store.service.MultiValuedTimestamp; |
... | @@ -35,25 +35,25 @@ import org.onosproject.store.service.StorageService; | ... | @@ -35,25 +35,25 @@ import org.onosproject.store.service.StorageService; |
35 | import org.onosproject.store.service.WallClockTimestamp; | 35 | import org.onosproject.store.service.WallClockTimestamp; |
36 | import org.onosproject.vtnrsc.PortPairGroup; | 36 | import org.onosproject.vtnrsc.PortPairGroup; |
37 | import org.onosproject.vtnrsc.PortPairGroupId; | 37 | import org.onosproject.vtnrsc.PortPairGroupId; |
38 | +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupEvent; | ||
38 | import org.onosproject.vtnrsc.portpairgroup.PortPairGroupListener; | 39 | import org.onosproject.vtnrsc.portpairgroup.PortPairGroupListener; |
39 | import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; | 40 | import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; |
40 | import org.slf4j.Logger; | 41 | import org.slf4j.Logger; |
41 | 42 | ||
42 | -import com.google.common.collect.Sets; | ||
43 | - | ||
44 | /** | 43 | /** |
45 | * Provides implementation of the portPairGroupService. | 44 | * Provides implementation of the portPairGroupService. |
46 | */ | 45 | */ |
47 | @Component(immediate = true) | 46 | @Component(immediate = true) |
48 | @Service | 47 | @Service |
49 | -public class PortPairGroupManager implements PortPairGroupService { | 48 | +public class PortPairGroupManager extends AbstractListenerManager<PortPairGroupEvent, PortPairGroupListener> implements |
49 | + PortPairGroupService { | ||
50 | 50 | ||
51 | private static final String PORT_PAIR_GROUP_ID_NULL = "PortPairGroup ID cannot be null"; | 51 | private static final String PORT_PAIR_GROUP_ID_NULL = "PortPairGroup ID cannot be null"; |
52 | private static final String PORT_PAIR_GROUP_NULL = "PortPairGroup cannot be null"; | 52 | private static final String PORT_PAIR_GROUP_NULL = "PortPairGroup cannot be null"; |
53 | private static final String LISTENER_NOT_NULL = "Listener cannot be null"; | 53 | private static final String LISTENER_NOT_NULL = "Listener cannot be null"; |
54 | 54 | ||
55 | private final Logger log = getLogger(getClass()); | 55 | private final Logger log = getLogger(getClass()); |
56 | - private final Set<PortPairGroupListener> listeners = Sets.newCopyOnWriteArraySet(); | 56 | + |
57 | private EventuallyConsistentMap<PortPairGroupId, PortPairGroup> portPairGroupStore; | 57 | private EventuallyConsistentMap<PortPairGroupId, PortPairGroup> portPairGroupStore; |
58 | 58 | ||
59 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 59 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
... | @@ -78,7 +78,6 @@ public class PortPairGroupManager implements PortPairGroupService { | ... | @@ -78,7 +78,6 @@ public class PortPairGroupManager implements PortPairGroupService { |
78 | @Deactivate | 78 | @Deactivate |
79 | public void deactivate() { | 79 | public void deactivate() { |
80 | portPairGroupStore.destroy(); | 80 | portPairGroupStore.destroy(); |
81 | - listeners.clear(); | ||
82 | log.info("Stopped"); | 81 | log.info("Stopped"); |
83 | } | 82 | } |
84 | 83 | ||
... | @@ -111,7 +110,7 @@ public class PortPairGroupManager implements PortPairGroupService { | ... | @@ -111,7 +110,7 @@ public class PortPairGroupManager implements PortPairGroupService { |
111 | portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup); | 110 | portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup); |
112 | if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) { | 111 | if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) { |
113 | log.debug("The portPairGroup is created failed which identifier was {}", portPairGroup.portPairGroupId() | 112 | log.debug("The portPairGroup is created failed which identifier was {}", portPairGroup.portPairGroupId() |
114 | - .toString()); | 113 | + .toString()); |
115 | return false; | 114 | return false; |
116 | } | 115 | } |
117 | return true; | 116 | return true; |
... | @@ -149,16 +148,4 @@ public class PortPairGroupManager implements PortPairGroupService { | ... | @@ -149,16 +148,4 @@ public class PortPairGroupManager implements PortPairGroupService { |
149 | } | 148 | } |
150 | return true; | 149 | return true; |
151 | } | 150 | } |
152 | - | ||
153 | - @Override | ||
154 | - public void addListener(PortPairGroupListener listener) { | ||
155 | - checkNotNull(listener, LISTENER_NOT_NULL); | ||
156 | - listeners.add(listener); | ||
157 | - } | ||
158 | - | ||
159 | - @Override | ||
160 | - public void removeListener(PortPairGroupListener listener) { | ||
161 | - checkNotNull(listener, LISTENER_NOT_NULL); | ||
162 | - listeners.remove(listener); | ||
163 | - } | ||
164 | } | 151 | } | ... | ... |
-
Please register or login to post a comment