/** * 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; }
@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; } }
/** * 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(); }
if (ochSignal.gridType() == GridType.FLEX) { .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() / log.error("Grid type: {} not supported for user defined signal intents", ochSignal.gridType()); return Collections.emptyList();
/** * 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()); } }
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()) )); }
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; }
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,