New packages simplifying picking service frequency 82/113982/20
authorJoakim Törnqvist <joakim.tornqvist@smartoptics.com>
Mon, 14 Oct 2024 12:41:23 +0000 (14:41 +0200)
committerGilles Thouenon <gilles.thouenon@orange.com>
Thu, 19 Dec 2024 12:20:15 +0000 (13:20 +0100)
commit538ab0421c7ac8b79585a5a6a7431001e7500ab9
treed0122abc1d9ce9a8a3a57fdca527dc1a371a7650
parent48eb8e430dcde33afe2dd5a0bd2a44829cf85548
New packages simplifying picking service frequency

The intention behind the packages is to simplify selecting
an available frequency range from which a subset may be setup
for a new service.

Choosing a frequency range depends on these criteria:

1) Is the "customer" limited to a certain range?
2) The available range on the nodes for the service.
3) The service format (type).
4) The requested frequency range presented in the service
   create request (i.e. API body).
5) The requested center frequency presented in the
   service create request (i.e. API body).

The class FrequencySelectionFactory in the 'frequency' package brings
all the pieces together solving the requirements above.

There is also a new package 'input' dealing with input validation.

Example #1: Determine the available spectrum for the new service
----------------------------------------------------------------

/**
 * Determine the available spectrum for the new service.
 * A frequence range from a service may be picked from
 * the output of this method.
 *
 * @param input API input.
 * @param availableSpectrumOnNodes
 *             The available spectrum on the nodes
 *             selected for the new service.
 * @param customerSpectrumConstraint
 *             The customer may be restricted to this
 *             spectrum.
 * @return The spectrum that is available for the new
 *         service.
 */
BitSet availableSpectrum(
        PathComputationRequestInput input,
        BitSet availableSpectrumOnNodes,
        BitSet customerSpectrumConstraint) {

    ClientInput clientInput = new ApiClientInput(
            input,
            new FrequencyIntervalFactory(768, 6.25),
            new FrequencySpectrum(
                    new SpectrumIndex(
                            191.325,
                            6.25,
                            768
                    )
            ),
            new ServiceFrequency(),
            6.25
    );

    Select frequencyFactory =
            new FrequencySelectionFactory(768);

    BitSet availableSpectrum =
            frequencyFactory.availableFrequencyRange(
                    clientInput,
                    customerSpectrumConstraint,
                    availableSpectrumOnNodes
    );

    return availableSpectrum;
}

Example #2:Validate PathComputationRequestInput
-----------------------------------------------
The intent with this example code is to validate this part of
the service-create api body:

"service-format": "other",
"frequency-slot": {
    "center-frequency": 193.1,
    "slot-width": 37.5
},

In short, slot-width need to be in 12.5 GHz increments and
center-frequency in 6.25 GHz increments. i.e. center-frequency
is expected to be 6.25 GHz increments from the anchor frequency
193.1 (e.g.  ..., 193.09375, 193.1, 193.10625, ...).

Also, frequency-slot is only valid together with service-format = other.

public void validateInput(PathComputationRequestInput input) {
    Factory inputValidationFactory = new ValidInputFactory();
    Valid validInput = inputValidationFactory.instantiate(
            191.325,
            193.1,
            6.25,
            12.5,
            768
    );

    if (!validInput.isValid(input)) {
        LOG.error(
                "PCEInput validation failed: {}",
                validInput.lastErrorMessage()
        );
    }
}

JIRA: TRNSPRTPCE-833
Change-Id: I565198a5906ac600ada204b100f41eb9fe7aeb82
Signed-off-by: Joakim Törnqvist <joakim.tornqvist@smartoptics.com>
43 files changed:
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/FrequencySelectionException.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/FrequencySelectionFactory.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/Select.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/interval/Collection.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/interval/EntireSpectrum.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/interval/FrequencyInterval.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/interval/FrequencyIntervalFactory.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/interval/Interval.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/interval/IntervalCollection.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/interval/IntervalFactory.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/interval/InvalidIntervalException.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/service/Service.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/service/ServiceFrequency.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/spectrum/FrequencySpectrum.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/spectrum/Spectrum.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/spectrum/index/FrequencySpectrumSet.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/spectrum/index/Index.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/spectrum/index/SpectrumIndex.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/frequency/spectrum/index/SpectrumSet.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/ClientInput.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/InvalidClientInputException.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/ServiceCreateClientInput.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/valid/Factory.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/valid/Format.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/valid/Observer.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/valid/Slot.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/valid/Valid.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/valid/ValidFormat.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/valid/ValidInput.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/valid/ValidInputFactory.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/input/valid/ValidSlot.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/frequency/FrequencyIntervalFactoryTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/frequency/FrequencySelectionFactoryTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/frequency/interval/EntireSpectrumTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/frequency/interval/FrequencyIntervalTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/frequency/interval/IntervalCollectionTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/frequency/service/ServiceFrequencyTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/frequency/spectrum/FrequencySpectrumTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/frequency/spectrum/index/FrequencySpectrumSetTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/frequency/spectrum/index/SpectrumIndexTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/input/valid/ValidFormatTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/input/valid/ValidInputTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/input/valid/ValidSlotTest.java [new file with mode: 0644]