Search in sources :

Example 21 with ProviderId

use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.

the class SimpleDeviceStore method removeDevice.

@Override
public DeviceEvent removeDevice(DeviceId deviceId) {
    Map<ProviderId, DeviceDescriptions> descs = getOrCreateDeviceDescriptions(deviceId);
    synchronized (descs) {
        Device device = devices.remove(deviceId);
        // should DEVICE_REMOVED carry removed ports?
        Map<PortNumber, Port> ports = devicePorts.get(deviceId);
        if (ports != null) {
            ports.clear();
        }
        availableDevices.remove(deviceId);
        descs.clear();
        return device == null ? null : new DeviceEvent(DEVICE_REMOVED, device, null);
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) DeviceEvent(org.onosproject.net.device.DeviceEvent) DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device) Port(org.onosproject.net.Port) DefaultPort(org.onosproject.net.DefaultPort) PortNumber(org.onosproject.net.PortNumber)

Example 22 with ProviderId

use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.

the class SimpleDeviceStore method updatePortStatus.

@Override
public DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId, PortDescription portDescription) {
    Device device = devices.get(deviceId);
    checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
    Map<ProviderId, DeviceDescriptions> descsMap = deviceDescs.get(deviceId);
    checkArgument(descsMap != null, DEVICE_NOT_FOUND, deviceId);
    synchronized (descsMap) {
        DeviceDescriptions descs = descsMap.get(providerId);
        // assuming all providers must give DeviceDescription first
        checkArgument(descs != null, "Device description for Device ID %s from Provider %s was not found", deviceId, providerId);
        ConcurrentMap<PortNumber, Port> ports = getPortMap(deviceId);
        final PortNumber number = portDescription.portNumber();
        final Port oldPort = ports.get(number);
        final Port newPort;
        // update description
        descs.putPortDesc(portDescription);
        newPort = composePort(device, number, descsMap);
        if (oldPort == null) {
            return createPort(device, newPort, ports);
        } else {
            return updatePort(device, oldPort, newPort, ports);
        }
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device) Port(org.onosproject.net.Port) DefaultPort(org.onosproject.net.DefaultPort) PortNumber(org.onosproject.net.PortNumber)

Example 23 with ProviderId

use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.

the class SimpleDeviceStore method createOrUpdateDevice.

@Override
public DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId, DeviceDescription deviceDescription) {
    Map<ProviderId, DeviceDescriptions> providerDescs = getOrCreateDeviceDescriptions(deviceId);
    synchronized (providerDescs) {
        // locking per device
        DeviceDescriptions descs = getOrCreateProviderDeviceDescriptions(providerDescs, providerId, deviceDescription);
        Device oldDevice = devices.get(deviceId);
        // update description
        descs.putDeviceDesc(deviceDescription);
        Device newDevice = composeDevice(deviceId, providerDescs);
        DeviceEvent event = null;
        if (oldDevice == null) {
            // ADD
            event = createDevice(providerId, newDevice);
        } else {
            // UPDATE or ignore (no change or stale)
            event = updateDevice(providerId, oldDevice, newDevice);
        }
        notifyDelegateIfNotNull(event);
        return event;
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) DeviceEvent(org.onosproject.net.device.DeviceEvent) DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device)

Example 24 with ProviderId

use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.

the class SimpleLinkStore method removeLink.

@Override
public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) {
    final LinkKey key = linkKey(src, dst);
    Map<ProviderId, LinkDescription> descs = getOrCreateLinkDescriptions(key);
    synchronized (descs) {
        Link link = links.remove(key);
        descs.clear();
        if (link != null) {
            srcLinks.remove(link.src().deviceId(), key);
            dstLinks.remove(link.dst().deviceId(), key);
            return new LinkEvent(LINK_REMOVED, link);
        }
        return null;
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) LinkKey(org.onosproject.net.LinkKey) LinkEvent(org.onosproject.net.link.LinkEvent) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink)

Example 25 with ProviderId

use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.

the class SimpleLinkStore method composeLink.

// Guarded by linkDescs value (=locking each Link)
private Link composeLink(Map<ProviderId, LinkDescription> descs) {
    ProviderId primary = getBaseProviderId(descs);
    LinkDescription base = descs.get(verifyNotNull(primary));
    ConnectPoint src = base.src();
    ConnectPoint dst = base.dst();
    Type type = base.type();
    DefaultAnnotations annotations = DefaultAnnotations.builder().build();
    annotations = merge(annotations, base.annotations());
    for (Entry<ProviderId, LinkDescription> e : descs.entrySet()) {
        if (primary.equals(e.getKey())) {
            continue;
        }
        // TODO: should keep track of Description timestamp
        // and only merge conflicting keys when timestamp is newer
        // Currently assuming there will never be a key conflict between
        // providers
        // annotation merging. not so efficient, should revisit later
        annotations = merge(annotations, e.getValue().annotations());
    }
    boolean isDurable = Objects.equals(annotations.value(AnnotationKeys.DURABLE), "true");
    return DefaultLink.builder().providerId(primary).src(src).dst(dst).type(type).state(ACTIVE).isExpected(isDurable).annotations(annotations).build();
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) Type(org.onosproject.net.Link.Type) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

ProviderId (org.onosproject.net.provider.ProviderId)62 DefaultDevice (org.onosproject.net.DefaultDevice)15 DeviceId (org.onosproject.net.DeviceId)13 Tunnel (org.onosproject.incubator.net.tunnel.Tunnel)12 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)12 Device (org.onosproject.net.Device)12 PortDescription (org.onosproject.net.device.PortDescription)12 TunnelProvider (org.onosproject.incubator.net.tunnel.TunnelProvider)10 DefaultPort (org.onosproject.net.DefaultPort)10 Port (org.onosproject.net.Port)10 DeviceEvent (org.onosproject.net.device.DeviceEvent)10 MastershipBasedTimestamp (org.onosproject.store.impl.MastershipBasedTimestamp)10 PortNumber (org.onosproject.net.PortNumber)9 DeviceDescription (org.onosproject.net.device.DeviceDescription)9 Timestamp (org.onosproject.store.Timestamp)9 MultiValuedTimestamp (org.onosproject.store.service.MultiValuedTimestamp)9 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)9 DefaultTunnel (org.onosproject.incubator.net.tunnel.DefaultTunnel)7 TunnelId (org.onosproject.incubator.net.tunnel.TunnelId)7 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)7