mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-23 13:21:21 +02:00
[ONOS-3117] adding listener to Port-Pair-Group Manager
Change-Id: I33dcdc6172e4a5a596d0e376e224ee3eb42387cd
This commit is contained in:
parent
147f0b8abf
commit
2e4cd65a1b
@ -77,4 +77,18 @@ public interface PortPairGroupService {
|
|||||||
* @return true if the give port pair group is deleted successfully.
|
* @return true if the give port pair group is deleted successfully.
|
||||||
*/
|
*/
|
||||||
boolean removePortPairGroup(PortPairGroupId portPairGroupId);
|
boolean removePortPairGroup(PortPairGroupId portPairGroupId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the specified listener to Port-Pair-Group manager.
|
||||||
|
*
|
||||||
|
* @param listener Port-Pair-Group listener
|
||||||
|
*/
|
||||||
|
void addListener(PortPairGroupListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the specified listener to Port-Pair-Group manager.
|
||||||
|
*
|
||||||
|
* @param listener Port-Pair-Group listener
|
||||||
|
*/
|
||||||
|
void removeListener(PortPairGroupListener listener);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.felix.scr.annotations.Activate;
|
import org.apache.felix.scr.annotations.Activate;
|
||||||
import org.apache.felix.scr.annotations.Component;
|
import org.apache.felix.scr.annotations.Component;
|
||||||
@ -34,9 +35,12 @@ import org.onosproject.store.service.StorageService;
|
|||||||
import org.onosproject.store.service.WallClockTimestamp;
|
import org.onosproject.store.service.WallClockTimestamp;
|
||||||
import org.onosproject.vtnrsc.PortPairGroup;
|
import org.onosproject.vtnrsc.PortPairGroup;
|
||||||
import org.onosproject.vtnrsc.PortPairGroupId;
|
import org.onosproject.vtnrsc.PortPairGroupId;
|
||||||
|
import org.onosproject.vtnrsc.portpairgroup.PortPairGroupListener;
|
||||||
import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
|
import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides implementation of the portPairGroupService.
|
* Provides implementation of the portPairGroupService.
|
||||||
*/
|
*/
|
||||||
@ -44,11 +48,12 @@ import org.slf4j.Logger;
|
|||||||
@Service
|
@Service
|
||||||
public class PortPairGroupManager implements PortPairGroupService {
|
public class PortPairGroupManager implements PortPairGroupService {
|
||||||
|
|
||||||
private final Logger log = getLogger(getClass());
|
|
||||||
|
|
||||||
private static final String PORT_PAIR_GROUP_ID_NULL = "PortPairGroup ID cannot be null";
|
private static final String PORT_PAIR_GROUP_ID_NULL = "PortPairGroup ID cannot be null";
|
||||||
private static final String PORT_PAIR_GROUP_NULL = "PortPairGroup cannot be null";
|
private static final String PORT_PAIR_GROUP_NULL = "PortPairGroup cannot be null";
|
||||||
|
private static final String LISTENER_NOT_NULL = "Listener cannot be null";
|
||||||
|
|
||||||
|
private final Logger log = getLogger(getClass());
|
||||||
|
private final Set<PortPairGroupListener> listeners = Sets.newCopyOnWriteArraySet();
|
||||||
private EventuallyConsistentMap<PortPairGroupId, PortPairGroup> portPairGroupStore;
|
private EventuallyConsistentMap<PortPairGroupId, PortPairGroup> portPairGroupStore;
|
||||||
|
|
||||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
@ -73,6 +78,7 @@ public class PortPairGroupManager implements PortPairGroupService {
|
|||||||
@Deactivate
|
@Deactivate
|
||||||
public void deactivate() {
|
public void deactivate() {
|
||||||
portPairGroupStore.destroy();
|
portPairGroupStore.destroy();
|
||||||
|
listeners.clear();
|
||||||
log.info("Stopped");
|
log.info("Stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,4 +149,16 @@ public class PortPairGroupManager implements PortPairGroupService {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addListener(PortPairGroupListener listener) {
|
||||||
|
checkNotNull(listener, LISTENER_NOT_NULL);
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeListener(PortPairGroupListener listener) {
|
||||||
|
checkNotNull(listener, LISTENER_NOT_NULL);
|
||||||
|
listeners.remove(listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user