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.transportpce.pce.constraints.PceConstraints.ResourcePair;
import org.opendaylight.transportpce.pce.gnpy.utils.AToZComparator;
import org.opendaylight.transportpce.pce.gnpy.utils.ZToAComparator;
-import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev220221.topo.Elements;
-import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev220221.topo.ElementsKey;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.RouteIncludeEro;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.TeHopType;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.TePathDisjointness;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.common.constraints_config.TeBandwidth;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.common.constraints_config.TeBandwidthBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.explicit.route.hop.Type;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.explicit.route.hop.type.NumUnnumHopBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.explicit.route.hop.type.num.unnum.hop.NumUnnumHop;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.generic.path.constraints.PathConstraints;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.generic.path.constraints.PathConstraintsBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.gnpy.specific.parameters.EffectiveFreqSlot;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.gnpy.specific.parameters.EffectiveFreqSlotBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.path.route.objects.ExplicitRouteObjects;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.path.route.objects.ExplicitRouteObjectsBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.path.route.objects.explicit.route.objects.RouteObjectIncludeExclude;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.path.route.objects.explicit.route.objects.RouteObjectIncludeExcludeBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.path.route.objects.explicit.route.objects.RouteObjectIncludeExcludeKey;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.service.PathRequest;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.service.PathRequestBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.service.PathRequestKey;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.synchronization.info.Synchronization;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.synchronization.info.SynchronizationBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.synchronization.info.synchronization.Svec;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.synchronization.info.synchronization.SvecBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev210701.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.FrequencyTHz;
+import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev220615.topo.Elements;
+import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev220615.topo.ElementsKey;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.RouteIncludeEro;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.TeHopType;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.TePathDisjointness;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.common.constraints_config.TeBandwidth;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.common.constraints_config.TeBandwidthBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.explicit.route.hop.Type;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.explicit.route.hop.type.NumUnnumHopBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.explicit.route.hop.type.num.unnum.hop.NumUnnumHop;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.constraints.PathConstraints;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.constraints.PathConstraintsBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.gnpy.specific.parameters.EffectiveFreqSlot;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.gnpy.specific.parameters.EffectiveFreqSlotBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.path.route.objects.ExplicitRouteObjects;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.path.route.objects.ExplicitRouteObjectsBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.path.route.objects.explicit.route.objects.RouteObjectIncludeExclude;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.path.route.objects.explicit.route.objects.RouteObjectIncludeExcludeBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.path.route.objects.explicit.route.objects.RouteObjectIncludeExcludeKey;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.service.PathRequest;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.service.PathRequestBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.service.PathRequestKey;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.synchronization.info.Synchronization;
+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.rev220615.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev211210.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.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.mapDisgNodeRefNode = gnpyTopo.getMapDisgNodeRefNode();
this.mapLinkFiber = gnpyTopo.getMapLinkFiber();
this.trxList = gnpyTopo.getTrxList();
- try {
- this.pathRequest = extractPathRequest(input, atoz, requestId.toJava(), pceHardConstraints);
- this.synchronization = extractSynchronization(requestId);
- } catch (NullPointerException e) {
- throw new GnpyException("In GnpyServiceImpl: one of the elements is null",e);
- }
+ this.pathRequest = extractPathRequest(input, atoz, requestId.toJava(), pceHardConstraints);
+ this.synchronization = extractSynchronization(requestId);
}
public GnpyServiceImpl(PathComputationRequestInput input, ZToADirection ztoa, Uint32 requestId,
this.mapDisgNodeRefNode = gnpyTopo.getMapDisgNodeRefNode();
this.mapLinkFiber = gnpyTopo.getMapLinkFiber();
this.trxList = gnpyTopo.getTrxList();
- try {
- pathRequest = extractPathRequest(input, ztoa, requestId.toJava(), pceHardConstraints);
- synchronization = extractSynchronization(requestId);
- } catch (NullPointerException e) {
- throw new GnpyException("In GnpyServiceImpl: one of the elements of service is null",e);
- }
+ pathRequest = extractPathRequest(input, ztoa, requestId.toJava(), pceHardConstraints);
+ synchronization = extractSynchronization(requestId);
}
private Map<PathRequestKey, PathRequest> extractPathRequest(
// Add routeObjectIncludeExclude
private RouteObjectIncludeExclude addRouteObjectIncludeExclude(String nodeId, Uint32 teTpValue, Long index) {
- NumUnnumHop numUnnumHop = new org.opendaylight.yang.gen.v1.gnpy.path.rev220221.explicit.route.hop.type.num
+ NumUnnumHop numUnnumHop = new org.opendaylight.yang.gen.v1.gnpy.path.rev220615.explicit.route.hop.type.num
.unnum.hop.NumUnnumHopBuilder()
.setNodeId(nodeId)
.setLinkTpId(teTpValue.toString())
mformat = optionalModulationFormat.get();
}
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)