/** * 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(); }
/** * 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; } }
/** * 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()); } }
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))) } 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())
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; }
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()) )); }
mBuilder.setExact(MatchField.EXP_OCH_SIG_ID, new CircuitSignalID(gridType, channelSpacing, (short) signal.spacingMultiplier(), (short) signal.slotGranularity())); } catch (NoMappingFoundException e) { log.warn(e.getMessage());