import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
+import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.transportpce.common.ServiceRateConstant;
import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.synchronization.info.SynchronizationBuilder;
import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.synchronization.info.synchronization.Svec;
import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.synchronization.info.synchronization.SvecBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev211210.FrequencyTHz;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev230526.FrequencyTHz;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.ModulationFormat;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirection;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirection;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ztoa.direction.ZToA;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.Resource;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToA;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.Resource;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.Link;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.Node;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//Create a new resource node or link
private Long createResource(@Nullable Resource resource, Long index) throws GnpyException {
Long idx = index;
- if (resource
- instanceof
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705
- .pce.resource.resource.resource.Node) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705
- .pce.resource.resource.resource.Node node =
- (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705
- .pce.resource.resource.resource.Node) resource;
+ if (resource instanceof Node) {
+ Node node = (Node) resource;
if (node.getNodeId() == null) {
throw new GnpyException("In gnpyServiceImpl: nodeId is null");
}
idx = addNodeToRouteObject(this.mapDisgNodeRefNode.get(node.getNodeId()),idx);
}
- if (resource
- instanceof
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705
- .pce.resource.resource.resource.Link) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705
- .pce.resource.resource.resource.Link link =
- (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705
- .pce.resource.resource.resource.Link) resource;
+ if (resource instanceof Link) {
+ Link link = (Link) resource;
idx = addLinkToRouteObject(link.getLinkId(),idx);
}
return idx;
Type type1 = new NumUnnumHopBuilder().setNumUnnumHop(numUnnumHop).build();
// Create routeObjectIncludeExclude element
return new RouteObjectIncludeExcludeBuilder()
- .setIndex(Uint32.valueOf(index)).setExplicitRouteUsage(RouteIncludeEro.class).setType(type1).build();
+ .setIndex(Uint32.valueOf(index)).setExplicitRouteUsage(RouteIncludeEro.VALUE).setType(type1).build();
}
//Create the path constraints
if (minFrequency != null && maxFrequency != null && modulationFormat != null) {
LOG.info("Creating path constraints for rate {}, modulationFormat {}, min freq {}, max freq {}", rate,
modulationFormat, minFrequency, maxFrequency);
- ModulationFormat mformat = ModulationFormat.DpQpsk;
- Optional<ModulationFormat> optionalModulationFormat = ModulationFormat.forName(modulationFormat);
- if (optionalModulationFormat.isPresent()) {
- mformat = optionalModulationFormat.get();
+ ModulationFormat mformat = ModulationFormat.forName(modulationFormat);
+ if (mformat == null) {
+ mformat = ModulationFormat.DpQpsk;
}
spacing = GridConstant.FREQUENCY_SLOT_WIDTH_TABLE.get(Uint32.valueOf(rate), mformat);
- FrequencyTHz centralFrequency = GridUtils
- .getCentralFrequency(minFrequency.getValue(), maxFrequency.getValue());
+ FrequencyTHz centralFrequency = GridUtils.getCentralFrequency(
+ minFrequency.getValue().decimalValue(),
+ maxFrequency.getValue().decimalValue());
int centralFrequencyBitSetIndex = GridUtils.getIndexFromFrequency(centralFrequency.getValue());
mvalue = (int) Math.ceil(spacing.doubleValue() / (GridConstant.GRANULARITY));
nvalue = GridUtils.getNFromFrequencyIndex(centralFrequencyBitSetIndex);
.setM(Uint32.valueOf(mvalue / 2)).setN(nvalue).build();
TeBandwidth teBandwidth = new TeBandwidthBuilder()
- .setPathBandwidth(BigDecimal.valueOf(rate * 1e9))
+ .setPathBandwidth(Decimal64.valueOf(BigDecimal.valueOf(rate * 1e9)))
.setTechnology("flexi-grid").setTrxType("OpenROADM MSA ver. 5.0")
.setTrxMode(TRX_MODE_TABLE.get(Uint32.valueOf(rate), spacing))
- .setOutputPower(GridUtils.convertDbmW(GridConstant.OUTPUT_POWER_100GB_DBM
- + 10 * Math.log10(mvalue / (double)GridConstant.NB_SLOTS_100G)))
+ .setOutputPower(Decimal64.valueOf(GridUtils.convertDbmW(GridConstant.OUTPUT_POWER_100GB_DBM
+ + 10 * Math.log10(mvalue / (double)GridConstant.NB_SLOTS_100G))
+ .setScale(6, RoundingMode.CEILING)))
.setEffectiveFreqSlot(Map.of(effectiveFreqSlot.key(), effectiveFreqSlot))
- .setSpacing(spacing.multiply(BigDecimal.valueOf(1e9))).build();
+ .setSpacing(Decimal64.valueOf(spacing.multiply(BigDecimal.valueOf(1e9))))
+ .build();
return new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
}
//Create the synchronization
private List<Synchronization> extractSynchronization(Uint32 requestId) {
// Create RequestIdNumber
- List<String> requestIdNumber = new ArrayList<>();
+ Set<String> requestIdNumber = new HashSet<>();
requestIdNumber.add(requestId.toString());
// Create a synchronization
Svec svec = new SvecBuilder().setRelaxable(true)