private OchSignal createLambda(int i) { return new OchSignal(GridType.FLEX, ChannelSpacing.CHL_6P25GHZ, i, 1); }
/** * Returns a JSON Object representation of this instance. * * @param j Och signal object * @return JSON Object representing OchSignal */ public static ObjectNode encode(OchSignal j) { ObjectNode obj = MAPPER.createObjectNode(); obj.put("channelSpacing", j.channelSpacing().toString()); obj.put("gridType", j.gridType().toString()); obj.put("slotGranularity", j.slotGranularity()); obj.put("spacingMultiplier", j.spacingMultiplier()); return obj; }
/** * Convert {@link OchSignal} into gridtype used to track Resource. * * @param ochSignal {@link OchSignal} * @return {@code ochSignal} mapped to Stream of flex grid slots with 6.25 GHz spacing * and 12.5 GHz slot width. */ private static Stream<OchSignal> toResourceGrid(OchSignal ochSignal) { if (ochSignal.gridType() != GridType.FLEX) { return OchSignal.toFlexGrid(ochSignal).stream(); } if (ochSignal.gridType() == GridType.FLEX && ochSignal.channelSpacing() == ChannelSpacing.CHL_6P25GHZ && ochSignal.slotGranularity() == 1) { // input was already flex grid slots with 6.25 GHz spacing and 12.5 GHz slot width. return Stream.of(ochSignal); } // FIXME handle FLEX but not 6.25 GHz spacing or 12.5 GHz slot width case. log.error("Converting {} to resource tracking grid not supported yet.", ochSignal); return Stream.<OchSignal>builder().build(); }
/** * Returns list of consecutive resources in given set of lambdas. * * @param lambdas list of lambdas * @param count number of consecutive lambdas to return * @return list of consecutive lambdas */ private List<OchSignal> findFirstLambda(Set<OchSignal> lambdas, int count) { // Sort available lambdas List<OchSignal> lambdaList = new ArrayList<>(lambdas); lambdaList.sort(new DefaultOchSignalComparator()); // Look ahead by count and ensure spacing multiplier is as expected (i.e., no gaps) for (int i = 0; i < lambdaList.size() - count; i++) { if (lambdaList.get(i).spacingMultiplier() + 2 * count == lambdaList.get(i + count).spacingMultiplier()) { return lambdaList.subList(i, i + count); } } return Collections.emptyList(); }
if (criterionMap.containsKey(Criterion.Type.OCH_SIGID)) { if (((OchSignalCriterion) criterionMap.get((Criterion.Type.OCH_SIGID))).lambda() .equals(((L0ModificationInstruction.ModOchSignalInstruction) l0).lambda())) { criterionMap.remove(Criterion.Type.OCH_SIGID); } else {
@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { OchSignal ochSignal = ((OchSignalCriterion) criterion).lambda(); ObjectNode child = root.putObject(CriterionCodec.OCH_SIGNAL_ID); child.put(CriterionCodec.GRID_TYPE, ochSignal.gridType().name()); child.put(CriterionCodec.CHANNEL_SPACING, ochSignal.channelSpacing().name()); child.put(CriterionCodec.SPACING_MULIPLIER, ochSignal.spacingMultiplier()); child.put(CriterionCodec.SLOT_GRANULARITY, ochSignal.slotGranularity()); return root; } }
/** * Creates an instance of {@link OchSignal} from JSON representation. * * @param obj JSON Object representing OchSignal * @return OchSignal * @throws IllegalArgumentException - if JSON object is ill-formed * @see OchSignalCodec#encode(OchSignal) */ public static OchSignal decode(ObjectNode obj) { final GridType gridType; final ChannelSpacing channelSpacing; final int spacingMultiplier; final int slotGranularity; String s; s = obj.get("channelSpacing").textValue(); checkArgument(s != null, "ill-formed channelSpacing"); channelSpacing = Enum.valueOf(ChannelSpacing.class, s); s = obj.get("gridType").textValue(); checkArgument(s != null, "ill-formed gridType"); gridType = Enum.valueOf(GridType.class, s); JsonNode node; node = obj.get("spacingMultiplier"); checkArgument(node.canConvertToInt(), "ill-formed spacingMultiplier"); spacingMultiplier = node.asInt(); node = obj.get("slotGranularity"); checkArgument(node.canConvertToInt(), "ill-formed slotGranularity"); slotGranularity = node.asInt(); return new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity); }
if (ochSignal.gridType() == GridType.FLEX) { int startMultiplier = ochSignal.spacingMultiplier() - (ochSignal.slotGranularity() / 2); return IntStream.range(0, ochSignal.slotGranularity()) .mapToObj(x -> OchSignal.newFlexGridSlot(startMultiplier + (2 * x))) .collect(Collectors.toList()); } else if (ochSignal.gridType() == GridType.DWDM) { int startMultiplier = (int) (1 - ochSignal.slotGranularity() + ochSignal.spacingMultiplier() * ochSignal.channelSpacing().frequency().asHz() / ChannelSpacing.CHL_6P25GHZ.frequency().asHz()); return IntStream.range(0, ochSignal.slotGranularity()) .mapToObj(x -> OchSignal.newFlexGridSlot(startMultiplier + (2 * x))) .collect(Collectors.toList()); log.error("Grid type: {} not supported for user defined signal intents", ochSignal.gridType()); return Collections.emptyList();
private OchSignal createOchSignal() throws IllegalArgumentException { if (signal == null) { return null; } try { String[] splitted = signal.split("/"); checkArgument(splitted.length == 4, "signal requires 4 parameters: " + SIGNAL_FORMAT); int slotGranularity = Integer.parseInt(splitted[0]); String chSpacing = splitted[1]; ChannelSpacing channelSpacing = checkNotNull(CHANNEL_SPACING_MAP.get(chSpacing), String.format("invalid channel spacing: %s", chSpacing)); int multiplier = Integer.parseInt(splitted[2]); String gdType = splitted[3].toUpperCase(); GridType gridType = GridType.valueOf(gdType); return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity); } catch (RuntimeException e) { /* catching RuntimeException as both NullPointerException (thrown by * checkNotNull) and IllegalArgumentException (thrown by checkArgument) * are subclasses of RuntimeException. */ String msg = String.format("Invalid signal format: %s, expected format is %s.", signal, SIGNAL_FORMAT); print(msg); throw new IllegalArgumentException(msg, e); } }
/** * Encode an L0 modification instruction. * * @param result json node that the instruction attributes are added to */ private void encodeL0(ObjectNode result) { L0ModificationInstruction l0Instruction = (L0ModificationInstruction) instruction; result.put(InstructionCodec.SUBTYPE, l0Instruction.subtype().name()); switch (l0Instruction.subtype()) { case OCH: L0ModificationInstruction.ModOchSignalInstruction ochSignalInstruction = (L0ModificationInstruction.ModOchSignalInstruction) l0Instruction; OchSignal ochSignal = ochSignalInstruction.lambda(); result.put(InstructionCodec.GRID_TYPE, ochSignal.gridType().name()); result.put(InstructionCodec.CHANNEL_SPACING, ochSignal.channelSpacing().name()); result.put(InstructionCodec.SPACING_MULTIPLIER, ochSignal.spacingMultiplier()); result.put(InstructionCodec.SLOT_GRANULARITY, ochSignal.slotGranularity()); break; default: log.info("Cannot convert L0 subtype of {}", l0Instruction.subtype()); } }
int slotGranularity = nullIsIllegal(json.get(InstructionCodec.SLOT_GRANULARITY), InstructionCodec.SLOT_GRANULARITY + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt(); return Instructions.modL0Lambda(new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity));
private OFAction buildModOchSignalInstruction(ModOchSignalInstruction instruction) { OchSignal signal = instruction.lambda(); byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType()); byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing()); return factory().actions().circuit(factory().oxms().expOchSigId( new CircuitSignalID(gridType, channelSpacing, (short) signal.spacingMultiplier(), (short) signal.slotGranularity()) )); }
Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations); case 5: // OCH port OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4); return ochPortDescription(portNo, enabled, OduSignalType.ODU4, true, signal, annotations);
private OFAction buildL0Modification(Instruction i) { L0ModificationInstruction l0m = (L0ModificationInstruction) i; OFOxm<?> oxm = null; switch (l0m.subtype()) { case OCH: try { ModOchSignalInstruction modOchSignalInstruction = (ModOchSignalInstruction) l0m; OchSignal signal = modOchSignalInstruction.lambda(); byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType()); byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing()); oxm = factory().oxms().expOchSigId( new CircuitSignalID(gridType, channelSpacing, (short) signal.spacingMultiplier(), (short) signal.slotGranularity())); } catch (NoMappingFoundException e) { log.warn(e.getMessage()); break; } break; default: log.warn("Unimplemented action type {}.", l0m.subtype()); break; } if (oxm != null) { return factory().actions().buildSetField().setField(oxm).build(); } return null; }
OchSignal signalId = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 1, 1);
OchSignalCriterion ochSignalCriterion = (OchSignalCriterion) c; OchSignal signal = ochSignalCriterion.lambda(); byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType()); byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing()); mBuilder.setExact(MatchField.EXP_OCH_SIG_ID, new CircuitSignalID(gridType, channelSpacing, (short) signal.spacingMultiplier(), (short) signal.slotGranularity())); } catch (NoMappingFoundException e) { log.warn(e.getMessage());