Committed by
Gerrit Code Review
Static optical madness. Fix in device resource store. Javadoc.
Change-Id: Iaba6b62094b3d2023f352d52037c6d1535c31b88
Showing
6 changed files
with
59 additions
and
43 deletions
| ... | @@ -378,8 +378,10 @@ public class OpticalPathProvisioner { | ... | @@ -378,8 +378,10 @@ public class OpticalPathProvisioner { |
| 378 | LinkResourceAllocations lra = linkResourceService.getAllocations(intent.id()); | 378 | LinkResourceAllocations lra = linkResourceService.getAllocations(intent.id()); |
| 379 | if (intent instanceof OpticalConnectivityIntent) { | 379 | if (intent instanceof OpticalConnectivityIntent) { |
| 380 | deviceResourceService.releasePorts(intent.id()); | 380 | deviceResourceService.releasePorts(intent.id()); |
| 381 | - linkResourceService.releaseResources(lra); | 381 | + if (lra != null) { |
| 382 | - } else if (intent instanceof OpticalCircuitIntent) { | 382 | + linkResourceService.releaseResources(lra); |
| 383 | + } | ||
| 384 | + } else if (intent instanceof OpticalCircuitIntent) { | ||
| 383 | deviceResourceService.releasePorts(intent.id()); | 385 | deviceResourceService.releasePorts(intent.id()); |
| 384 | deviceResourceService.releaseMapping(intent.id()); | 386 | deviceResourceService.releaseMapping(intent.id()); |
| 385 | if (lra != null) { | 387 | if (lra != null) { | ... | ... |
| ... | @@ -17,6 +17,7 @@ package org.onosproject.net; | ... | @@ -17,6 +17,7 @@ package org.onosproject.net; |
| 17 | 17 | ||
| 18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
| 19 | import org.onlab.util.Frequency; | 19 | import org.onlab.util.Frequency; |
| 20 | +import org.onosproject.net.resource.link.LambdaResourceAllocation; | ||
| 20 | 21 | ||
| 21 | import java.util.Objects; | 22 | import java.util.Objects; |
| 22 | 23 | ||
| ... | @@ -34,6 +35,9 @@ public class OchSignal implements Lambda { | ... | @@ -34,6 +35,9 @@ public class OchSignal implements Lambda { |
| 34 | 35 | ||
| 35 | public static final Frequency CENTER_FREQUENCY = Frequency.ofTHz(193.1); | 36 | public static final Frequency CENTER_FREQUENCY = Frequency.ofTHz(193.1); |
| 36 | public static final Frequency FLEX_GRID_SLOT = Frequency.ofGHz(12.5); | 37 | public static final Frequency FLEX_GRID_SLOT = Frequency.ofGHz(12.5); |
| 38 | + private static final GridType DEFAULT_OCH_GRIDTYPE = GridType.DWDM; | ||
| 39 | + private static final ChannelSpacing DEFAULT_CHANNEL_SPACING = ChannelSpacing.CHL_50GHZ; | ||
| 40 | + | ||
| 37 | 41 | ||
| 38 | private final GridType gridType; | 42 | private final GridType gridType; |
| 39 | private final ChannelSpacing channelSpacing; | 43 | private final ChannelSpacing channelSpacing; |
| ... | @@ -63,6 +67,33 @@ public class OchSignal implements Lambda { | ... | @@ -63,6 +67,33 @@ public class OchSignal implements Lambda { |
| 63 | } | 67 | } |
| 64 | 68 | ||
| 65 | /** | 69 | /** |
| 70 | + * Create OCh signal from lambda resource allocation. | ||
| 71 | + * | ||
| 72 | + * @param alloc lambda resource allocation | ||
| 73 | + * @param maxFrequency maximum frequency | ||
| 74 | + * @param grid grid spacing frequency | ||
| 75 | + */ | ||
| 76 | + public OchSignal(LambdaResourceAllocation alloc, Frequency maxFrequency, Frequency grid) { | ||
| 77 | + int channel = alloc.lambda().toInt(); | ||
| 78 | + | ||
| 79 | + // Calculate center frequency | ||
| 80 | + Frequency centerFrequency = maxFrequency.subtract(grid.multiply(channel - 1)); | ||
| 81 | + | ||
| 82 | + this.gridType = DEFAULT_OCH_GRIDTYPE; | ||
| 83 | + this.channelSpacing = DEFAULT_CHANNEL_SPACING; | ||
| 84 | + this.spacingMultiplier = (int) (centerFrequency.subtract(OchSignal.CENTER_FREQUENCY).asHz() / grid.asHz()); | ||
| 85 | + this.slotGranularity = (int) Math.round((double) grid.asHz() / ChannelSpacing.CHL_12P5GHZ.frequency().asHz()); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public OchSignal(Frequency centerFrequency, ChannelSpacing channelSpacing, int slotGranularity) { | ||
| 89 | + this.gridType = DEFAULT_OCH_GRIDTYPE; | ||
| 90 | + this.channelSpacing = channelSpacing; | ||
| 91 | + this.spacingMultiplier = (int) Math.round((double) centerFrequency. | ||
| 92 | + subtract(OchSignal.CENTER_FREQUENCY).asHz() / channelSpacing().frequency().asHz()); | ||
| 93 | + this.slotGranularity = slotGranularity; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + /** | ||
| 66 | * Returns grid type. | 97 | * Returns grid type. |
| 67 | * | 98 | * |
| 68 | * @return grid type | 99 | * @return grid type | ... | ... |
| ... | @@ -165,9 +165,9 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -165,9 +165,9 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
| 165 | * Checks if current allocations on given resource can satisfy request. | 165 | * Checks if current allocations on given resource can satisfy request. |
| 166 | * If the resource is null, return true. | 166 | * If the resource is null, return true. |
| 167 | * | 167 | * |
| 168 | - * @param request | 168 | + * @param request the intent making the request |
| 169 | - * @param resource | 169 | + * @param resource the resource on which to map the intent |
| 170 | - * @return | 170 | + * @return true if the resource can accept the request, false otherwise |
| 171 | */ | 171 | */ |
| 172 | private boolean isAvailable(Intent request, IntentId resource) { | 172 | private boolean isAvailable(Intent request, IntentId resource) { |
| 173 | if (resource == null) { | 173 | if (resource == null) { | ... | ... |
| ... | @@ -27,10 +27,8 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -27,10 +27,8 @@ import org.apache.felix.scr.annotations.Reference; |
| 27 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 27 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 28 | import org.onlab.util.Frequency; | 28 | import org.onlab.util.Frequency; |
| 29 | import org.onosproject.net.AnnotationKeys; | 29 | import org.onosproject.net.AnnotationKeys; |
| 30 | -import org.onosproject.net.ChannelSpacing; | ||
| 31 | import org.onosproject.net.ConnectPoint; | 30 | import org.onosproject.net.ConnectPoint; |
| 32 | import org.onosproject.net.DeviceId; | 31 | import org.onosproject.net.DeviceId; |
| 33 | -import org.onosproject.net.GridType; | ||
| 34 | import org.onosproject.net.Link; | 32 | import org.onosproject.net.Link; |
| 35 | import org.onosproject.net.OchPort; | 33 | import org.onosproject.net.OchPort; |
| 36 | import org.onosproject.net.OchSignal; | 34 | import org.onosproject.net.OchSignal; |
| ... | @@ -73,9 +71,6 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical | ... | @@ -73,9 +71,6 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical |
| 73 | 71 | ||
| 74 | protected static final Logger log = LoggerFactory.getLogger(OpticalConnectivityIntentCompiler.class); | 72 | protected static final Logger log = LoggerFactory.getLogger(OpticalConnectivityIntentCompiler.class); |
| 75 | 73 | ||
| 76 | - private static final GridType DEFAULT_OCH_GRIDTYPE = GridType.DWDM; | ||
| 77 | - private static final ChannelSpacing DEFAULT_CHANNEL_SPACING = ChannelSpacing.CHL_50GHZ; | ||
| 78 | - | ||
| 79 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 74 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 80 | protected IntentExtensionService intentManager; | 75 | protected IntentExtensionService intentManager; |
| 81 | 76 | ||
| ... | @@ -127,24 +122,31 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical | ... | @@ -127,24 +122,31 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical |
| 127 | for (Path path : paths) { | 122 | for (Path path : paths) { |
| 128 | 123 | ||
| 129 | // Static or dynamic lambda allocation | 124 | // Static or dynamic lambda allocation |
| 130 | - LambdaResourceAllocation lambdaAlloc; | ||
| 131 | String staticLambda = srcPort.annotations().value(AnnotationKeys.STATIC_LAMBDA); | 125 | String staticLambda = srcPort.annotations().value(AnnotationKeys.STATIC_LAMBDA); |
| 126 | + OchPort srcOchPort = (OchPort) srcPort; | ||
| 127 | + OchPort dstOchPort = (OchPort) dstPort; | ||
| 128 | + OchSignal ochSignal; | ||
| 129 | + | ||
| 130 | + // FIXME: need to actually reserve the lambda for static lambda's | ||
| 132 | if (staticLambda != null) { | 131 | if (staticLambda != null) { |
| 133 | - // FIXME: need to actually reserve the lambda | 132 | + ochSignal = new OchSignal(Frequency.ofHz(Long.valueOf(staticLambda)), |
| 134 | - lambdaAlloc = new LambdaResourceAllocation(LambdaResource.valueOf(Integer.parseInt(staticLambda))); | 133 | + srcOchPort.lambda().channelSpacing(), |
| 134 | + srcOchPort.lambda().slotGranularity()); | ||
| 135 | + } else if (!srcOchPort.isTunable() || !dstOchPort.isTunable()) { | ||
| 136 | + // FIXME: also check OCh port | ||
| 137 | + ochSignal = srcOchPort.lambda(); | ||
| 135 | } else { | 138 | } else { |
| 136 | // Request and reserve lambda on path | 139 | // Request and reserve lambda on path |
| 137 | LinkResourceAllocations linkAllocs = assignWavelength(intent, path); | 140 | LinkResourceAllocations linkAllocs = assignWavelength(intent, path); |
| 138 | if (linkAllocs == null) { | 141 | if (linkAllocs == null) { |
| 139 | continue; | 142 | continue; |
| 140 | } | 143 | } |
| 141 | - lambdaAlloc = getWavelength(path, linkAllocs); | 144 | + LambdaResourceAllocation lambdaAlloc = getWavelength(path, linkAllocs); |
| 145 | + OmsPort omsPort = (OmsPort) deviceService.getPort(path.src().deviceId(), path.src().port()); | ||
| 146 | + ochSignal = new OchSignal(lambdaAlloc, omsPort.maxFrequency(), omsPort.grid()); | ||
| 142 | } | 147 | } |
| 143 | 148 | ||
| 144 | - OmsPort omsPort = (OmsPort) deviceService.getPort(path.src().deviceId(), path.src().port()); | ||
| 145 | - | ||
| 146 | // Create installable optical path intent | 149 | // Create installable optical path intent |
| 147 | - OchSignal ochSignal = getOchSignal(lambdaAlloc, omsPort.maxFrequency(), omsPort.grid()); | ||
| 148 | // Only support fixed grid for now | 150 | // Only support fixed grid for now |
| 149 | OchSignalType signalType = OchSignalType.FIXED_GRID; | 151 | OchSignalType signalType = OchSignalType.FIXED_GRID; |
| 150 | 152 | ||
| ... | @@ -239,29 +241,6 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical | ... | @@ -239,29 +241,6 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical |
| 239 | return true; | 241 | return true; |
| 240 | } | 242 | } |
| 241 | 243 | ||
| 242 | - /** | ||
| 243 | - * Convert lambda resource allocation in OCh signal. | ||
| 244 | - * | ||
| 245 | - * @param alloc lambda resource allocation | ||
| 246 | - * @param maxFrequency maximum frequency | ||
| 247 | - * @param grid grid spacing frequency | ||
| 248 | - * @return OCh signal | ||
| 249 | - */ | ||
| 250 | - private OchSignal getOchSignal(LambdaResourceAllocation alloc, Frequency maxFrequency, Frequency grid) { | ||
| 251 | - int channel = alloc.lambda().toInt(); | ||
| 252 | - | ||
| 253 | - // Calculate center frequency | ||
| 254 | - Frequency centerFrequency = maxFrequency.subtract(grid.multiply(channel - 1)); | ||
| 255 | - | ||
| 256 | - // Build OCh signal object | ||
| 257 | - int spacingMultiplier = (int) (centerFrequency.subtract(OchSignal.CENTER_FREQUENCY).asHz() / grid.asHz()); | ||
| 258 | - int slotGranularity = (int) (grid.asHz() / ChannelSpacing.CHL_12P5GHZ.frequency().asHz()); | ||
| 259 | - OchSignal ochSignal = new OchSignal(DEFAULT_OCH_GRIDTYPE, DEFAULT_CHANNEL_SPACING, | ||
| 260 | - spacingMultiplier, slotGranularity); | ||
| 261 | - | ||
| 262 | - return ochSignal; | ||
| 263 | - } | ||
| 264 | - | ||
| 265 | private ConnectPoint staticPort(ConnectPoint connectPoint) { | 244 | private ConnectPoint staticPort(ConnectPoint connectPoint) { |
| 266 | Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); | 245 | Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); |
| 267 | 246 | ... | ... |
core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
| ... | @@ -167,7 +167,7 @@ public class ConsistentDeviceResourceStore implements DeviceResourceStore { | ... | @@ -167,7 +167,7 @@ public class ConsistentDeviceResourceStore implements DeviceResourceStore { |
| 167 | public Set<IntentId> getMapping(IntentId intentId) { | 167 | public Set<IntentId> getMapping(IntentId intentId) { |
| 168 | Versioned<Set<IntentId>> result = intentMapping.get(intentId); | 168 | Versioned<Set<IntentId>> result = intentMapping.get(intentId); |
| 169 | 169 | ||
| 170 | - if (result == null) { | 170 | + if (result != null) { |
| 171 | return result.value(); | 171 | return result.value(); |
| 172 | } | 172 | } |
| 173 | 173 | ||
| ... | @@ -178,7 +178,6 @@ public class ConsistentDeviceResourceStore implements DeviceResourceStore { | ... | @@ -178,7 +178,6 @@ public class ConsistentDeviceResourceStore implements DeviceResourceStore { |
| 178 | public boolean allocateMapping(IntentId keyIntentId, IntentId valIntentId) { | 178 | public boolean allocateMapping(IntentId keyIntentId, IntentId valIntentId) { |
| 179 | Versioned<Set<IntentId>> versionedIntents = intentMapping.get(keyIntentId); | 179 | Versioned<Set<IntentId>> versionedIntents = intentMapping.get(keyIntentId); |
| 180 | 180 | ||
| 181 | - | ||
| 182 | if (versionedIntents == null) { | 181 | if (versionedIntents == null) { |
| 183 | Set<IntentId> newSet = new HashSet<>(); | 182 | Set<IntentId> newSet = new HashSet<>(); |
| 184 | newSet.add(valIntentId); | 183 | newSet.add(valIntentId); |
| ... | @@ -216,6 +215,7 @@ public class ConsistentDeviceResourceStore implements DeviceResourceStore { | ... | @@ -216,6 +215,7 @@ public class ConsistentDeviceResourceStore implements DeviceResourceStore { |
| 216 | for (Port port : ports) { | 215 | for (Port port : ports) { |
| 217 | portAllocs.remove(port); | 216 | portAllocs.remove(port); |
| 218 | } | 217 | } |
| 218 | + tx.commit(); | ||
| 219 | } catch (Exception e) { | 219 | } catch (Exception e) { |
| 220 | log.error("Exception thrown, rolling back", e); | 220 | log.error("Exception thrown, rolling back", e); |
| 221 | tx.abort(); | 221 | tx.abort(); | ... | ... |
| ... | @@ -235,7 +235,11 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -235,7 +235,11 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
| 235 | port = portNumber(node.path("port").asLong(0)); | 235 | port = portNumber(node.path("port").asLong(0)); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | - checkNotNull(port); | 238 | + if (port == null) { |
| 239 | + log.error("Cannot find port given in node {}", node); | ||
| 240 | + return null; | ||
| 241 | + } | ||
| 242 | + | ||
| 239 | String portName = Strings.emptyToNull(port.name()); | 243 | String portName = Strings.emptyToNull(port.name()); |
| 240 | SparseAnnotations annotations = null; | 244 | SparseAnnotations annotations = null; |
| 241 | if (portName != null) { | 245 | if (portName != null) { | ... | ... |
-
Please register or login to post a comment