Search in sources :

Example 11 with CacheException

use of org.openkilda.messaging.error.CacheException in project open-kilda by telstra.

the class NetworkCache method deleteSwitch.

/**
 * Deletes {@link SwitchInfoData} instance.
 *
 * @param switchId {@link SwitchInfoData} instance id
 * @return removed {@link SwitchInfoData} instance
 * @throws CacheException if {@link SwitchInfoData} instance with specified id does not exist
 */
public SwitchInfoData deleteSwitch(String switchId) throws CacheException {
    logger.debug("Delete {} switch", switchId);
    SwitchInfoData node = switchPool.remove(switchId);
    if (node == null) {
        throw new CacheException(ErrorType.NOT_FOUND, "Can not delete switch", String.format("Switch %s not found", switchId));
    }
    network.removeNode(node);
    return node;
}
Also used : CacheException(org.openkilda.messaging.error.CacheException) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData)

Aggregations

CacheException (org.openkilda.messaging.error.CacheException)11 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)8 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)4 IOException (java.io.IOException)2 InfoMessage (org.openkilda.messaging.info.InfoMessage)2 ImmutablePair (org.openkilda.messaging.model.ImmutablePair)2 MutableNetwork (com.google.common.graph.MutableNetwork)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Values (org.apache.storm.tuple.Values)1 BaseMessage (org.openkilda.messaging.BaseMessage)1 Message (org.openkilda.messaging.Message)1