Use Optional.orElseThrow() instead.
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
Change-Id: I65031d77602d1c66bcdc1d33c3852ad117670e63
LOG.error("readMdSal: Error reading Operational Mode Catalog {} , empty list", omCatalogIid);
return 0.0;
}
- XponderPluggableOpenroadmOperationalMode orTspOM = omOptional.get();
+ XponderPluggableOpenroadmOperationalMode orTspOM = omOptional.orElseThrow();
maxRollOff = orTspOM.getMaxRollOff() == null ? 0 : orTspOM.getMaxRollOff().doubleValue();
baudRate = orTspOM.getBaudRate().doubleValue();
} catch (InterruptedException | ExecutionException e) {
LOG.error("readMdSal: Error reading Operational Mode Catalog {} , empty list", omCatalogIid);
return 0.0;
}
- SpecificOperationalMode speTspOM = somOptional.get();
+ SpecificOperationalMode speTspOM = somOptional.orElseThrow();
maxRollOff = speTspOM.getMaxRollOff() == null ? 0 : speTspOM.getMaxRollOff().doubleValue();
baudRate = speTspOM.getBaudRate().doubleValue();
} catch (InterruptedException | ExecutionException e) {
LOG.error("readMdSal: Error reading Operational Mode Catalog {} , empty list", omCatalogIid);
return 0.0;
}
- orTspOM = omOptional.get();
+ orTspOM = omOptional.orElseThrow();
LOG.debug("readMdSal: Operational Mode Catalog: omOptional.isPresent = true {}", orTspOM);
TXOOBOsnrKey key = new TXOOBOsnrKey(addDropMuxOperationalModeId);
if (orTspOM.getMinTXOsnr() != null) {
LOG.error("readMdSal: Error reading Operational Mode Catalog {} , empty list", omCatalogIid);
return 0.0;
}
- speTspOM = somOptional.get();
+ speTspOM = somOptional.orElseThrow();
LOG.debug("readMdSal: Operational Mode Catalog: omOptional.isPresent = true {}", speTspOM);
TXOOBOsnrKey key = new TXOOBOsnrKey(addDropMuxOperationalModeId);
if (speTspOM.getMinTXOsnr() != null) {
Optional<XponderPluggableOpenroadmOperationalMode> omOptional = networkTransactionService
.read(LogicalDatastoreType.CONFIGURATION, omCatalogIid).get();
if (omOptional.isPresent()) {
- orTspOM = omOptional.get();
+ orTspOM = omOptional.orElseThrow();
LOG.debug("readMdSal: Operational Mode Catalog: omOptional.isPresent = true {}", orTspOM);
if (orTspOM.getMinRXOsnrTolerance() != null) {
rxOsnrdB = orTspOM.getMinRXOsnrTolerance().getValue().doubleValue();
Optional<SpecificOperationalMode> somOptional = networkTransactionService
.read(LogicalDatastoreType.CONFIGURATION, omCatalogIid).get();
if (somOptional.isPresent()) {
- speTspOM = somOptional.get();
+ speTspOM = somOptional.orElseThrow();
LOG.debug("readMdSal: Operational Mode Catalog: omOptional.isPresent = true {}", speTspOM);
if (speTspOM.getMinRXOsnrTolerance() != null) {
rxOsnrdB = speTspOM.getMinRXOsnrTolerance().getValue().doubleValue();
LOG.error(OPMODE_MISMATCH_MSG, operationalModeId);
return new HashMap<>();
}
- var orAddOM = omOptional.get();
+ var orAddOM = omOptional.orElseThrow();
LOG.debug("readMdSal: Operational Mode Catalog: omOptional.isPresent = true {}", orAddOM);
maxIntroducedCd = orAddOM.getMaxIntroducedCd().doubleValue();
// As per current OpenROADM Spec
LOG.error(OPMODE_MISMATCH_MSG, operationalModeId);
return new HashMap<>();
}
- var orDropOM = omOptional.get();
+ var orDropOM = omOptional.orElseThrow();
LOG.debug("readMdSal: Operational Mode Catalog: omOptional.isPresent = true {}", orDropOM);
maxIntroducedCd = orDropOM.getMaxIntroducedCd().doubleValue();
// As per current OpenROADM Spec
LOG.error(OPMODE_MISMATCH_MSG, operationalModeId);
return new HashMap<>();
}
- var orExpressOM = omOptional.get();
+ var orExpressOM = omOptional.orElseThrow();
LOG.debug("readMdSal: Operational Mode Catalog: omOptional.isPresent = true {}", orExpressOM);
maxIntroducedCd = orExpressOM.getMaxIntroducedCd().doubleValue();
// As per current OpenROADM Spec
LOG.error(OPMODE_MISMATCH_MSG, operationalModeId);
return new HashMap<>();
}
- var orAmpOM = omOptional.get();
+ var orAmpOM = omOptional.orElseThrow();
LOG.debug("readMdSal: Operational Mode Catalog: omOptional.isPresent = true {}", orAmpOM);
maxIntroducedCd = orAmpOM.getMaxIntroducedCd().doubleValue();
// As per current OpenROADM Spec
LOG.error(OPMODE_MISMATCH_MSG, operationalModeId);
return pout;
}
- var orAddOM = omOptional.get();
+ var orAddOM = omOptional.orElseThrow();
LOG.debug("readMdSal: Operational Mode Catalog: omOptional.isPresent = true {}", orAddOM);
var mask = orAddOM.getMaskPowerVsPin();
for (Map.Entry<MaskPowerVsPinKey, MaskPowerVsPin> pw : mask.entrySet()) {
LOG.error(OPMODE_MISMATCH_MSG, operationalModeId);
return pout;
}
- var orExpressOM = omOptional.get();
+ var orExpressOM = omOptional.orElseThrow();
LOG.debug("readMdSal: Operational Mode Catalog: omOptional.isPresent = true {}", orExpressOM);
var mask = orExpressOM.getMaskPowerVsPin();
for (Map.Entry<MaskPowerVsPinKey, MaskPowerVsPin> pw : mask.entrySet()) {
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Device transaction for device {} was not found!", deviceId);
return Optional.empty();
Optional<RoadmConnections> xc = getCrossConnect(deviceId, connectionNumber);
//Check if cross connect exists before delete
if (xc.isPresent()) {
- interfList.add(xc.get().getSource().getSrcIf());
- interfList.add(xc.get().getDestination().getDstIf());
+ interfList.add(xc.orElseThrow().getSource().getSrcIf());
+ interfList.add(xc.orElseThrow().getDestination().getDstIf());
} else {
LOG.warn("Cross connect does not exist, halting delete");
return null;
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Device transaction for device {} was not found!", deviceId);
return null;
List<Ports> ports = null;
MountPoint mountPoint;
if (mountPointOpt.isPresent()) {
- mountPoint = mountPointOpt.get();
+ mountPoint = mountPointOpt.orElseThrow();
} else {
LOG.error("Failed to obtain mount point for device {}!", nodeId);
return Collections.emptyList();
if (!service.isPresent()) {
LOG.error("Failed to get RpcService for node {}", nodeId);
}
- final OrgOpenroadmDeviceService rpcService = service.get().getRpcService(OrgOpenroadmDeviceService.class);
+ final OrgOpenroadmDeviceService rpcService = service.orElseThrow()
+ .getRpcService(OrgOpenroadmDeviceService.class);
final GetConnectionPortTrailInputBuilder portTrainInputBuilder = new GetConnectionPortTrailInputBuilder();
portTrainInputBuilder.setConnectionNumber(connectionName);
final Future<RpcResult<GetConnectionPortTrailOutput>> portTrailOutput = rpcService.getConnectionPortTrail(
Optional<RoadmConnections> rdmConnOpt = getCrossConnect(deviceId, ctNumber);
if (rdmConnOpt.isPresent()) {
- RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.get())
+ RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.orElseThrow())
.setOpticalControlMode(mode);
if (powerValue != null) {
rdmConnBldr.setTargetOutputPower(new PowerDBm(powerValue));
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Transaction for device {} was not found!", deviceId);
return false;
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error(DEV_TRANSACTION_NOT_FOUND, deviceId);
return Optional.empty();
.openroadm.device.OduConnection> otnXc = getOtnCrossConnect(deviceId, connectionName);
//Check if cross connect exists before delete
if (xc.isPresent()) {
- interfList.add(xc.get().getSource().getSrcIf());
- interfList.add(xc.get().getDestination().getDstIf());
- interfList.add(xc.get().getSource().getSrcIf().replace("nmc", "mc"));
- interfList.add(xc.get().getDestination().getDstIf().replace("nmc", "mc"));
+ interfList.add(xc.orElseThrow().getSource().getSrcIf());
+ interfList.add(xc.orElseThrow().getDestination().getDstIf());
+ interfList.add(xc.orElseThrow().getSource().getSrcIf().replace("nmc", "mc"));
+ interfList.add(xc.orElseThrow().getDestination().getDstIf().replace("nmc", "mc"));
} else if (otnXc.isPresent()) {
- interfList.add(otnXc.get().getSource().getSrcIf());
- interfList.add(otnXc.get().getDestination().getDstIf());
+ interfList.add(otnXc.orElseThrow().getSource().getSrcIf());
+ interfList.add(otnXc.orElseThrow().getDestination().getDstIf());
} else {
LOG.warn("Cross connect {} does not exist, halting delete", connectionName);
return null;
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error(DEV_TRANSACTION_NOT_FOUND, deviceId);
return null;
List<Ports> ports = null;
MountPoint mountPoint;
if (mountPointOpt.isPresent()) {
- mountPoint = mountPointOpt.get();
+ mountPoint = mountPointOpt.orElseThrow();
} else {
LOG.error("Failed to obtain mount point for device {}!", nodeId);
return Collections.emptyList();
if (!service.isPresent()) {
LOG.error("Failed to get RpcService for node {}", nodeId);
}
- final OrgOpenroadmDeviceService rpcService = service.get().getRpcService(OrgOpenroadmDeviceService.class);
+ final OrgOpenroadmDeviceService rpcService = service.orElseThrow()
+ .getRpcService(OrgOpenroadmDeviceService.class);
final GetConnectionPortTrailInputBuilder portTrainInputBuilder = new GetConnectionPortTrailInputBuilder();
portTrainInputBuilder.setConnectionName(connectionName);
final Future<RpcResult<GetConnectionPortTrailOutput>> portTrailOutput = rpcService.getConnectionPortTrail(
public boolean setPowerLevel(String deviceId, OpticalControlMode mode, Decimal64 powerValue, String ctName) {
Optional<RoadmConnections> rdmConnOpt = getCrossConnect(deviceId, ctName);
if (rdmConnOpt.isPresent()) {
- RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.get());
+ RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.orElseThrow());
rdmConnBldr.setOpticalControlMode(mode);
if (powerValue != null) {
rdmConnBldr.setTargetOutputPower(new PowerDBm(powerValue));
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Transaction for device {} was not found!", deviceId);
return false;
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error(DEV_TRANSACTION_NOT_FOUND, deviceId);
return Optional.empty();
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Device transaction for device {} was not found!", deviceId);
return Optional.empty();
.container.org.openroadm.device.OduConnection> otnXc = getOtnCrossConnect(deviceId, connectionName);
if (otnXc.isPresent()) {
- interfList.add(otnXc.get().getSource().getSrcIf());
- interfList.add(otnXc.get().getDestination().getDstIf());
+ interfList.add(otnXc.orElseThrow().getSource().getSrcIf());
+ interfList.add(otnXc.orElseThrow().getDestination().getDstIf());
} else {
LOG.warn("Cross connect {} does not exist, halting delete", connectionName);
return null;
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Device transaction for device {} was not found!", deviceId);
return null;
Optional<DataBroker> deviceDataBrokerOpt = getDeviceDataBroker(deviceId);
DataBroker deviceDataBroker;
if (deviceDataBrokerOpt.isPresent()) {
- deviceDataBroker = deviceDataBrokerOpt.get();
+ deviceDataBroker = deviceDataBrokerOpt.orElseThrow();
} else {
newLock.countDown();
return Optional.empty();
// if time will run out and transaction was not closed then it will be cancelled (and unlocked)
checkingExecutor.schedule(() -> {
if (deviceTransactionOptional.isPresent()) {
- DeviceTransaction deviceTx = deviceTransactionOptional.get();
+ DeviceTransaction deviceTx = deviceTransactionOptional.orElseThrow();
LOG.debug("Timeout to submit transaction run out! Transaction was {} submitted or canceled.",
deviceTx.wasSubmittedOrCancelled().get() ? "" : "not");
if (!deviceTx.wasSubmittedOrCancelled().get()) {
private Optional<DataBroker> getDeviceDataBroker(String deviceId) {
Optional<MountPoint> netconfNode = getDeviceMountPoint(deviceId);
if (netconfNode.isPresent()) {
- return netconfNode.get().getService(DataBroker.class);
+ return netconfNode.orElseThrow().getService(DataBroker.class);
} else {
LOG.error("Device mount point not found for : {}", deviceId);
return Optional.empty();
return Optional.empty();
}
if (deviceTxOpt.isPresent()) {
- DeviceTransaction deviceTx = deviceTxOpt.get();
+ DeviceTransaction deviceTx = deviceTxOpt.orElseThrow();
try {
return deviceTx.read(logicalDatastoreType, path).get(timeout, timeUnit);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
Optional<NodeInfo> nodeInfoObj =
readTx.read(LogicalDatastoreType.CONFIGURATION, nodeInfoIID).get();
if (nodeInfoObj.isPresent()) {
- NodeInfo nodInfo = nodeInfoObj.get();
+ NodeInfo nodInfo = nodeInfoObj.orElseThrow();
switch (nodInfo.getOpenroadmVersion()) {
case _71:
return StringConstants.OPENROADM_DEVICE_VERSION_7_1;
.get();
if (nodePortMapObject.isPresent()) {
LOG.debug("Found node {}", nodeId);
- Nodes node = nodePortMapObject.get();
+ Nodes node = nodePortMapObject.orElseThrow();
mcCapabilities.addAll(node.nonnullMcCapabilities().values());
}
} catch (ExecutionException e) {
try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
Optional<Mapping> mapObject = readTx.read(LogicalDatastoreType.CONFIGURATION, portMappingIID).get();
if (mapObject.isPresent()) {
- Mapping mapping = mapObject.get();
+ Mapping mapping = mapObject.orElseThrow();
LOG.info("Found mapping for {} - {}. Mapping: {}", nodeId, logicalConnPoint, mapping.toString());
return mapping;
}
LOG.warn("Could not get portMapping for node {}", nodeId);
return null;
}
- Map<MappingKey, Mapping> mappings = portMapppingOpt.get().getMapping();
+ Map<MappingKey, Mapping> mappings = portMapppingOpt.orElseThrow().getMapping();
for (Mapping mapping : mappings.values()) {
if (circuitPackName.equals(mapping.getSupportingCircuitPackName())
&& portName.equals(mapping.getSupportingPort())) {
Optional<McCapabilities> mcCapObject = readTx.read(LogicalDatastoreType.CONFIGURATION,
mcCapabilitiesIID).get();
if (mcCapObject.isPresent()) {
- McCapabilities mcCap = mcCapObject.get();
+ McCapabilities mcCap = mcCapObject.orElseThrow();
LOG.info("Found MC-cap for {} - {}. Mapping: {}", nodeId, mcLcp, mcCap.toString());
return mcCap;
}
Optional<Nodes> nodePortMapObject =
readTx.read(LogicalDatastoreType.CONFIGURATION, nodePortMappingIID).get();
if (nodePortMapObject.isPresent()) {
- Nodes node = nodePortMapObject.get();
+ Nodes node = nodePortMapObject.orElseThrow();
LOG.info("Found node {} in portmapping.", nodeId);
return node;
}
LOG.warn("Could not get portMapping for node {}", nodeId);
return null;
}
- Map<MappingKey, Mapping> mappings = nodePortmapppingOpt.get().getMapping();
+ Map<MappingKey, Mapping> mappings = nodePortmapppingOpt.orElseThrow().getMapping();
for (Mapping mapping : mappings.values()) {
if (interfName.equals(mapping.getSupportingOts())) {
return mapping;
LOG.warn(PortMappingUtils.DEVICE_HAS_LOGMSG, nodeId, "no info", "subtree");
return false;
}
- Info deviceInfo = deviceInfoOptional.get();
+ Info deviceInfo = deviceInfoOptional.orElseThrow();
NodeInfo nodeInfo = createNodeInfo(deviceInfo);
if (nodeInfo == null) {
return false;
.build();
try {
Ports port = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL,
- portId, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).get();
+ portId, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).orElseThrow();
Mapping newMapping = updateMappingObject(nodeId, port, oldMapping);
LOG.debug(PortMappingUtils.UPDATE_MAPPING_LOGMSG,
nodeId, oldMapping, oldMapping.getLogicalConnectionPoint(), newMapping);
LOG.error(PortMappingUtils.CANNOT_GET_DEV_CONF_LOGMSG, nodeId);
return false;
}
- OrgOpenroadmDevice device = deviceObject.get();
+ OrgOpenroadmDevice device = deviceObject.orElseThrow();
if (device.getCircuitPacks() == null) {
LOG.warn(PortMappingUtils.MISSING_CP_LOGMSG, nodeId, PortMappingUtils.FOUND);
return false;
}
}
- for (ConnectionMap cm : deviceObject.get().nonnullConnectionMap().values()) {
+ for (ConnectionMap cm : deviceObject.orElseThrow().nonnullConnectionMap().values()) {
String skey = cm.getSource().getCircuitPackName() + "+" + cm.getSource().getPortName();
Destination destination0 = cm.nonnullDestination().values().iterator().next();
String dkey = destination0.getCircuitPackName() + "+" + destination0.getPortName();
LogicalDatastoreType.OPERATIONAL, srgIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (ordmSrgObject.isPresent()) {
- srgCps.addAll(ordmSrgObject.get().nonnullCircuitPacks().values());
- cpPerSrg.put(ordmSrgObject.get().getSrgNumber().toJava(), srgCps);
+ srgCps.addAll(ordmSrgObject.orElseThrow().nonnullCircuitPacks().values());
+ cpPerSrg.put(ordmSrgObject.orElseThrow().getSrgNumber().toJava(), srgCps);
}
}
LOG.info(PortMappingUtils.DEVICE_HAS_LOGMSG, deviceId, cpPerSrg.size(), "SRG");
.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, port2ID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (port2Object.isEmpty()
- || port2Object.get().getPortQual().getIntValue() != Port.PortQual.RoadmExternal.getIntValue()) {
+ || port2Object.orElseThrow().getPortQual().getIntValue() != Port.PortQual.RoadmExternal.getIntValue()) {
LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_GET_ERROR_LOGMSG,
nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName(),
port.getPortName(), circuitPackName);
return null;
}
- Ports port2 = port2Object.get();
+ Ports port2 = port2Object.orElseThrow();
if (!checkPartnerPort(circuitPackName, port, port2)) {
LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_CONF_ERROR_LOGMSG,
nodeId, port2.getPortName(), port.getPartnerPort().getCircuitPackName(),
nodeId, circuitPackName);
return new ArrayList<>();
}
- if (circuitPackObject.get().getPorts() == null) {
+ if (circuitPackObject.orElseThrow().getPorts() == null) {
LOG.warn(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, PortMappingUtils.FOUND, circuitPackName);
return new ArrayList<>();
}
- return new ArrayList<>(circuitPackObject.get().nonnullPorts().values());
+ return new ArrayList<>(circuitPackObject.orElseThrow().nonnullPorts().values());
}
private String createLogicalConnectionPort(Ports port, int index, int portIndex) {
LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (ordmDegreeObject.isPresent()) {
- degrees.put(degreeCounter, ordmDegreeObject.get());
+ degrees.put(degreeCounter, ordmDegreeObject.orElseThrow());
}
}
LOG.info(PortMappingUtils.DEVICE_HAS_LOGMSG,
Optional<Protocols> protocolObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, protocoliid, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (protocolObject.isEmpty() || protocolObject.get().augmentation(Protocols1.class).getLldp() == null) {
+ if (protocolObject.isEmpty() || protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp() == null) {
LOG.warn(PortMappingUtils.PROCESSING_DONE_LOGMSG, nodeId, PortMappingUtils.CANNOT_GET_LLDP_CONF_LOGMSG);
return new HashMap<>();
}
Map<String, String> cpToInterfaceMap = new HashMap<>();
- Lldp lldp = protocolObject.get().augmentation(Protocols1.class).getLldp();
+ Lldp lldp = protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp();
for (PortConfig portConfig : lldp.nonnullPortConfig().values()) {
if (!portConfig.getAdminStatus().equals(PortConfig.AdminStatus.Txandrx)) {
continue;
Optional<Interface> interfaceObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, interfaceIID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (interfaceObject.isEmpty() || interfaceObject.get().getSupportingCircuitPackName() == null) {
+ if (interfaceObject.isEmpty() || interfaceObject.orElseThrow().getSupportingCircuitPackName() == null) {
continue;
}
- String supportingCircuitPackName = interfaceObject.get().getSupportingCircuitPackName();
+ String supportingCircuitPackName = interfaceObject.orElseThrow().getSupportingCircuitPackName();
cpToInterfaceMap.put(supportingCircuitPackName, portConfig.getIfName());
InstanceIdentifier<CircuitPacks> circuitPacksIID = InstanceIdentifier
.builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
Optional<CircuitPacks> circuitPackObject = this.deviceTransactionManager.getDataFromDevice(
nodeId, LogicalDatastoreType.OPERATIONAL, circuitPacksIID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (circuitPackObject.isEmpty() || circuitPackObject.get().getParentCircuitPack() == null) {
+ if (circuitPackObject.isEmpty() || circuitPackObject.orElseThrow().getParentCircuitPack() == null) {
continue;
}
- cpToInterfaceMap.put(circuitPackObject.get().getParentCircuitPack().getCircuitPackName(),
+ cpToInterfaceMap.put(circuitPackObject.orElseThrow().getParentCircuitPack().getCircuitPackName(),
portConfig.getIfName());
}
LOG.info(PortMappingUtils.PROCESSING_DONE_LOGMSG, nodeId, " - success");
nodeId, interfaces.getInterfaceName() + "- empty interface");
continue;
}
- InterfaceType interfaceType = openRoadmInterface.get().getType();
- LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG, nodeId, openRoadmInterface.get().getName(), interfaceType);
+ InterfaceType interfaceType = openRoadmInterface.orElseThrow().getType();
+ LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG, nodeId, openRoadmInterface.orElseThrow().getName(),
+ interfaceType);
// Switch/Case might be more indicated here but is not possible in jdk17 w/o enable-preview
if (interfaceType.equals(OpenROADMOpticalMultiplex.VALUE)) {
mpBldr.setSupportingOms(interfaces.getInterfaceName());
LOG.error(PortMappingUtils.MISSING_CP_LOGMSG, nodeId, port.getPartnerPort().getCircuitPackName());
return null;
}
- Optional<Ports> poOpt = cpOpt.get().nonnullPorts().values().stream()
+ Optional<Ports> poOpt = cpOpt.orElseThrow().nonnullPorts().values().stream()
.filter(p -> p.getPortName().equals(port.getPartnerPort().getPortName()))
.findFirst();
if (poOpt.isEmpty()) {
nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName());
return null;
}
- Ports port2 = poOpt.get();
- circuitPackName2.append(cpOpt.get().getCircuitPackName());
+ Ports port2 = poOpt.orElseThrow();
+ circuitPackName2.append(cpOpt.orElseThrow().getCircuitPackName());
if (!checkPartnerPort(circuitPackName, port, port2)) {
LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
nodeId, port2.getPortName(), circuitPackName2, port.getPortName(), circuitPackName);
LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp.getPortName(), cpName);
return null;
}
- return portObject.get();
+ return portObject.orElseThrow();
}
private boolean checkPortQual(Ports port, String cpName, String nodeId) {
LOG.warn(PortMappingUtils.DEVICE_HAS_LOGMSG, nodeId, "no info", "subtree");
return false;
}
- Info deviceInfo = deviceInfoOptional.get();
+ Info deviceInfo = deviceInfoOptional.orElseThrow();
NodeInfo nodeInfo = createNodeInfo(deviceInfo);
if (nodeInfo == null) {
return false;
.child(Ports.class, new PortsKey(oldMapping.getSupportingPort()))
.build(),
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)
- .get(),
+ .orElseThrow(),
oldMapping,
//otsInterface
oldMapping.getSupportingOts() == null
.build(),
Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT)
- .get()
+ .orElseThrow()
);
LOG.debug(PortMappingUtils.UPDATE_MAPPING_LOGMSG,
nodeId, oldMapping, oldMapping.getLogicalConnectionPoint(), newMapping);
LOG.error(PortMappingUtils.CANNOT_GET_DEV_CONF_LOGMSG, nodeId);
return null;
}
- OrgOpenroadmDevice device = deviceObject.get();
+ OrgOpenroadmDevice device = deviceObject.orElseThrow();
if (device.getCircuitPacks() == null) {
LOG.warn(PortMappingUtils.MISSING_CP_LOGMSG, nodeId, PortMappingUtils.FOUND);
return null;
nodeId, circuitPackName);
return null;
}
- Optional<Ports> portsList = cpList.get().nonnullPorts().values().stream()
+ Optional<Ports> portsList = cpList.orElseThrow().nonnullPorts().values().stream()
.filter(p -> p.getPortName().equals(portName)).findFirst();
if (portsList.isEmpty()) {
LOG.warn(PortMappingUtils.NO_ASSOC_FOUND_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
nodeId, portName, circuitPackName, "in the device");
return null;
}
- return portsList.get();
+ return portsList.orElseThrow();
}
private List<SwitchingPoolLcp> getSwitchingPoolList(OrgOpenroadmDevice device,
LogicalDatastoreType.OPERATIONAL, srgIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (ordmSrgObject.isPresent()) {
- srgCps.addAll(ordmSrgObject.get().nonnullCircuitPacks().values());
- cpPerSrg.put(ordmSrgObject.get().getSrgNumber().toJava(), srgCps);
+ srgCps.addAll(ordmSrgObject.orElseThrow().nonnullCircuitPacks().values());
+ cpPerSrg.put(ordmSrgObject.orElseThrow().getSrgNumber().toJava(), srgCps);
}
}
LOG.info(PortMappingUtils.DEVICE_HAS_LOGMSG, deviceId, cpPerSrg.size(), "SRG");
.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, port2ID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (port2Object.isEmpty()
- || port2Object.get().getPortQual().getIntValue() != PortQual.RoadmExternal.getIntValue()) {
+ || port2Object.orElseThrow().getPortQual().getIntValue() != PortQual.RoadmExternal.getIntValue()) {
LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_GET_ERROR_LOGMSG,
nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName(),
port.getPortName(), circuitPackName);
return null;
}
- Ports port2 = port2Object.get();
+ Ports port2 = port2Object.orElseThrow();
if (!checkPartnerPort(circuitPackName, port, port2)) {
LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_CONF_ERROR_LOGMSG,
nodeId, port2.getPortName(), port.getPartnerPort().getCircuitPackName(),
nodeId, circuitPackName);
return new ArrayList<>();
}
- if (circuitPackObject.get().getPorts() == null) {
+ if (circuitPackObject.orElseThrow().getPorts() == null) {
LOG.warn(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, PortMappingUtils.FOUND, circuitPackName);
return new ArrayList<>();
}
- return new ArrayList<>(circuitPackObject.get().nonnullPorts().values());
+ return new ArrayList<>(circuitPackObject.orElseThrow().nonnullPorts().values());
}
private String createLogicalConnectionPort(Ports port, int index, int portIndex) {
LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (ordmDegreeObject.isPresent()) {
- degrees.put(degreeCounter, ordmDegreeObject.get());
+ degrees.put(degreeCounter, ordmDegreeObject.orElseThrow());
}
}
LOG.info(PortMappingUtils.DEVICE_HAS_LOGMSG,
LogicalDatastoreType.OPERATIONAL, srgIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (ordmSrgObject.isPresent()) {
- srgs.add(ordmSrgObject.get());
+ srgs.add(ordmSrgObject.orElseThrow());
}
}
Optional<Protocols> protocolObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, protocoliid, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (protocolObject.isEmpty() || protocolObject.get().augmentation(Protocols1.class).getLldp() == null) {
+ if (protocolObject.isEmpty() || protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp() == null) {
LOG.warn(PortMappingUtils.PROCESSING_DONE_LOGMSG, nodeId, PortMappingUtils.CANNOT_GET_LLDP_CONF_LOGMSG);
return new HashMap<>();
}
Map<String, String> cpToInterfaceMap = new HashMap<>();
- Lldp lldp = protocolObject.get().augmentation(Protocols1.class).getLldp();
+ Lldp lldp = protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp();
for (PortConfig portConfig : lldp.nonnullPortConfig().values()) {
if (!portConfig.getAdminStatus().equals(PortConfig.AdminStatus.Txandrx)) {
continue;
Optional<Interface> interfaceObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, interfaceIID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (interfaceObject.isEmpty() || interfaceObject.get().getSupportingCircuitPackName() == null) {
+ if (interfaceObject.isEmpty() || interfaceObject.orElseThrow().getSupportingCircuitPackName() == null) {
continue;
}
- String supportingCircuitPackName = interfaceObject.get().getSupportingCircuitPackName();
+ String supportingCircuitPackName = interfaceObject.orElseThrow().getSupportingCircuitPackName();
cpToInterfaceMap.put(supportingCircuitPackName, portConfig.getIfName());
InstanceIdentifier<CircuitPacks> circuitPacksIID = InstanceIdentifier
.builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
Optional<CircuitPacks> circuitPackObject = this.deviceTransactionManager.getDataFromDevice(
nodeId, LogicalDatastoreType.OPERATIONAL, circuitPacksIID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (circuitPackObject.isEmpty() || circuitPackObject.get().getParentCircuitPack() == null) {
+ if (circuitPackObject.isEmpty() || circuitPackObject.orElseThrow().getParentCircuitPack() == null) {
continue;
}
- cpToInterfaceMap.put(circuitPackObject.get().getParentCircuitPack().getCircuitPackName(),
+ cpToInterfaceMap.put(circuitPackObject.orElseThrow().getParentCircuitPack().getCircuitPackName(),
portConfig.getIfName());
}
LOG.info(PortMappingUtils.PROCESSING_DONE_LOGMSG, nodeId, " - success");
nodeId, interfaces.getInterfaceName() + "- empty interface");
continue;
}
- InterfaceType interfaceType = openRoadmInterface.get().getType();
- LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG, nodeId, openRoadmInterface.get().getName(), interfaceType);
+ InterfaceType interfaceType = openRoadmInterface.orElseThrow().getType();
+ LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG, nodeId, openRoadmInterface.orElseThrow().getName(),
+ interfaceType);
// Check if interface type is OMS or OTS
// Switch/Case might be more indicated here but is not possible in jdk17 w/o enable-preview
if (interfaceType.equals(OpenROADMOpticalMultiplex.VALUE)) {
LOG.error(PortMappingUtils.MISSING_CP_LOGMSG, nodeId, port.getPartnerPort().getCircuitPackName());
return null;
}
- Optional<Ports> poOpt = cpOpt.get().nonnullPorts().values().stream()
+ Optional<Ports> poOpt = cpOpt.orElseThrow().nonnullPorts().values().stream()
.filter(p -> p.getPortName().equals(port.getPartnerPort().getPortName()))
.findFirst();
if (poOpt.isEmpty()) {
nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName());
return null;
}
- Ports port2 = poOpt.get();
- circuitPackName2.append(cpOpt.get().getCircuitPackName());
+ Ports port2 = poOpt.orElseThrow();
+ circuitPackName2.append(cpOpt.orElseThrow().getCircuitPackName());
if (!checkPartnerPort(circuitPackName, port, port2)) {
LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
nodeId, port2.getPortName(), circuitPackName2, port.getPortName(), circuitPackName);
LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp.getPortName(), cpName);
return null;
}
- return portObject.get();
+ return portObject.orElseThrow();
}
private boolean checkPortQual(Ports port, String cpName, String nodeId) {
LOG.warn(PortMappingUtils.DEVICE_HAS_LOGMSG, nodeId, "no info", "subtree");
return false;
}
- Info deviceInfo = deviceInfoOptional.get();
+ Info deviceInfo = deviceInfoOptional.orElseThrow();
NodeInfo nodeInfo = createNodeInfo(deviceInfo);
if (nodeInfo == null) {
return false;
.build();
try {
Ports port = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL,
- portId, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).get();
+ portId, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).orElseThrow();
Mapping newMapping = updateMappingObject(nodeId, port, oldMapping);
LOG.debug(PortMappingUtils.UPDATE_MAPPING_LOGMSG,
nodeId, oldMapping, oldMapping.getLogicalConnectionPoint(), newMapping);
InstanceIdentifier.create(Network.class).child(Nodes.class, new NodesKey(nodeId));
Nodes portmappingNode = null;
try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
- portmappingNode = readTx.read(LogicalDatastoreType.CONFIGURATION, portMappingNodeIID).get().get();
+ portmappingNode = readTx.read(LogicalDatastoreType.CONFIGURATION, portMappingNodeIID).get().orElseThrow();
} catch (InterruptedException | ExecutionException ex) {
LOG.error("Unable to read the port-mapping for nodeId {}", nodeId, ex);
}
}
OduSwitchingPools osp = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL,
- ospIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).get();
+ ospIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).orElseThrow();
Uint16 ospNumber = osp.getSwitchingPoolNumber();
Map<SwitchingPoolLcpKey, SwitchingPoolLcp> splMap =
new HashMap<SwitchingPoolLcpKey, SwitchingPoolLcp>(portmappingNode.nonnullSwitchingPoolLcp());
Set<String> lcpList = nblBldr.getLcpList() != null ? nblBldr.getLcpList() : new HashSet<>();
for (InstanceIdentifier<PortList> id : entry.getValue()) {
PortList portList = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL,
- id, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).get();
+ id, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).orElseThrow();
String lcp = getLcpFromCpAndPort(mappings, portList.getCircuitPackName(), portList.getPortName());
if (lcp == null || lcpList.contains(lcp)) {
return null;
LOG.error(PortMappingUtils.CANNOT_GET_DEV_CONF_LOGMSG, nodeId);
return null;
}
- OrgOpenroadmDevice device = deviceObject.get();
+ OrgOpenroadmDevice device = deviceObject.orElseThrow();
if (device.getCircuitPacks() == null) {
LOG.warn(PortMappingUtils.MISSING_CP_LOGMSG, nodeId, PortMappingUtils.FOUND);
return null;
nodeId, circuitPackName);
return null;
}
- Optional<Ports> portsList = cpList.get().nonnullPorts().values().stream()
+ Optional<Ports> portsList = cpList.orElseThrow().nonnullPorts().values().stream()
.filter(p -> p.getPortName().equals(portName)).findFirst();
if (portsList.isEmpty()) {
LOG.warn(PortMappingUtils.NO_ASSOC_FOUND_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
nodeId, portName, circuitPackName, "in the device");
return null;
}
- return portsList.get();
+ return portsList.orElseThrow();
}
private List<SwitchingPoolLcp> getSwitchingPoolList(OrgOpenroadmDevice device,
LogicalDatastoreType.OPERATIONAL, srgIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (ordmSrgObject.isPresent()) {
- srgCps.addAll(ordmSrgObject.get().nonnullCircuitPacks().values());
- cpPerSrg.put(ordmSrgObject.get().getSrgNumber().toJava(), srgCps);
+ srgCps.addAll(ordmSrgObject.orElseThrow().nonnullCircuitPacks().values());
+ cpPerSrg.put(ordmSrgObject.orElseThrow().getSrgNumber().toJava(), srgCps);
}
}
LOG.info(PortMappingUtils.DEVICE_HAS_LOGMSG, deviceId, cpPerSrg.size(), "SRG");
.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, port2ID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (port2Object.isEmpty()
- || port2Object.get().getPortQual().getIntValue() != PortQual.RoadmExternal.getIntValue()) {
+ || port2Object.orElseThrow().getPortQual().getIntValue() != PortQual.RoadmExternal.getIntValue()) {
LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_GET_ERROR_LOGMSG,
nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName(),
port.getPortName(), circuitPackName);
return null;
}
- Ports port2 = port2Object.get();
+ Ports port2 = port2Object.orElseThrow();
if (!checkPartnerPort(circuitPackName, port, port2)) {
LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_CONF_ERROR_LOGMSG,
nodeId, port2.getPortName(), port.getPartnerPort().getCircuitPackName(),
nodeId, circuitPackName);
return new ArrayList<>();
}
- if (circuitPackObject.get().getPorts() == null) {
+ if (circuitPackObject.orElseThrow().getPorts() == null) {
LOG.warn(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, PortMappingUtils.FOUND, circuitPackName);
return new ArrayList<>();
}
- return new ArrayList<>(circuitPackObject.get().nonnullPorts().values());
+ return new ArrayList<>(circuitPackObject.orElseThrow().nonnullPorts().values());
}
private String createLogicalConnectionPort(Ports port, int index, int portIndex) {
LOG.warn("MC-capabilities profile will be empty for node {}", deviceId);
return mcCapabilityProfiles;
}
- device = deviceObject.get();
+ device = deviceObject.orElseThrow();
mcCapabilityProfiles = device.getMcCapabilityProfile();
return mcCapabilityProfiles;
}
LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (ordmDegreeObject.isPresent()) {
- degrees.put(degreeCounter, ordmDegreeObject.get());
+ degrees.put(degreeCounter, ordmDegreeObject.orElseThrow());
}
}
LOG.info(PortMappingUtils.DEVICE_HAS_LOGMSG,
LogicalDatastoreType.OPERATIONAL, srgIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (ordmSrgObject.isPresent()) {
- srgs.add(ordmSrgObject.get());
+ srgs.add(ordmSrgObject.orElseThrow());
}
}
Optional<Protocols> protocolObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, protocoliid, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (protocolObject.isEmpty() || protocolObject.get().augmentation(Protocols1.class).getLldp() == null) {
+ if (protocolObject.isEmpty() || protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp() == null) {
LOG.warn(PortMappingUtils.PROCESSING_DONE_LOGMSG, nodeId, PortMappingUtils.CANNOT_GET_LLDP_CONF_LOGMSG);
return new HashMap<>();
}
Map<String, String> cpToInterfaceMap = new HashMap<>();
- Lldp lldp = protocolObject.get().augmentation(Protocols1.class).getLldp();
+ Lldp lldp = protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp();
for (PortConfig portConfig : lldp.nonnullPortConfig().values()) {
if (!portConfig.getAdminStatus().equals(PortConfig.AdminStatus.Txandrx)) {
continue;
Optional<Interface> interfaceObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, interfaceIID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (interfaceObject.isEmpty() || interfaceObject.get().getSupportingCircuitPackName() == null) {
+ if (interfaceObject.isEmpty() || interfaceObject.orElseThrow().getSupportingCircuitPackName() == null) {
continue;
}
- String supportingCircuitPackName = interfaceObject.get().getSupportingCircuitPackName();
+ String supportingCircuitPackName = interfaceObject.orElseThrow().getSupportingCircuitPackName();
cpToInterfaceMap.put(supportingCircuitPackName, portConfig.getIfName());
InstanceIdentifier<CircuitPacks> circuitPacksIID = InstanceIdentifier
.builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
Optional<CircuitPacks> circuitPackObject = this.deviceTransactionManager.getDataFromDevice(
nodeId, LogicalDatastoreType.OPERATIONAL, circuitPacksIID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (circuitPackObject.isEmpty() || circuitPackObject.get().getParentCircuitPack() == null) {
+ if (circuitPackObject.isEmpty() || circuitPackObject.orElseThrow().getParentCircuitPack() == null) {
continue;
}
- cpToInterfaceMap.put(circuitPackObject.get().getParentCircuitPack().getCircuitPackName(),
+ cpToInterfaceMap.put(circuitPackObject.orElseThrow().getParentCircuitPack().getCircuitPackName(),
portConfig.getIfName());
}
LOG.info(PortMappingUtils.PROCESSING_DONE_LOGMSG, nodeId, " - success");
nodeId, interfaces.getInterfaceName() + "- empty interface");
continue;
}
- InterfaceType interfaceType = openRoadmInterface.get().getType();
- LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG, nodeId, openRoadmInterface.get().getName(), interfaceType);
+ InterfaceType interfaceType = openRoadmInterface.orElseThrow().getType();
+ LOG.debug(PortMappingUtils.GOT_INTF_LOGMSG, nodeId, openRoadmInterface.orElseThrow().getName(),
+ interfaceType);
// Check if interface type is OMS or OTS
// Switch/Case might be more indicated here but is not possible in jdk17 w/o enable-preview
if (interfaceType.equals(OpenROADMOpticalMultiplex.VALUE)) {
// Here we assume all the supported-interfaces has the support same rates, and the
// trib-slot numbers are assumed to be the same
String mxpProfileName = sic1.getOtnCapability().getMpdrClientRestriction().get(0).getMuxpProfileName()
- .stream().findFirst().get();
+ .stream().findFirst().orElseThrow();
// From this muxponder-profile get the min-trib-slot and the max-trib-slot
LOG.info("{}: Muxp-profile used for trib information {}", nodeId, mxpProfileName);
// This provides the tribSlot information from muxProfile
LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- Set<OpucnTribSlotDef> ntwHoOduOpucnTribSlots = muxpProfileObject.get().getNetworkHoOduOpucnTribSlots();
+ Set<OpucnTribSlotDef> ntwHoOduOpucnTribSlots = muxpProfileObject.orElseThrow().getNetworkHoOduOpucnTribSlots();
// Sort the tib-slots in ascending order and pick min and max
List<OpucnTribSlotDef> sortedNtwHoOduOpucnTribSlots = ntwHoOduOpucnTribSlots.stream().sorted(
Comparator.comparingDouble(x -> Double.parseDouble(
LOG.error(PortMappingUtils.MISSING_CP_LOGMSG, nodeId, port.getPartnerPort().getCircuitPackName());
return null;
}
- Optional<Ports> poOpt = cpOpt.get().nonnullPorts().values().stream()
+ Optional<Ports> poOpt = cpOpt.orElseThrow().nonnullPorts().values().stream()
.filter(p -> p.getPortName().equals(port.getPartnerPort().getPortName()))
.findFirst();
if (poOpt.isEmpty()) {
nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName());
return null;
}
- Ports port2 = poOpt.get();
- circuitPackName2.append(cpOpt.get().getCircuitPackName());
+ Ports port2 = poOpt.orElseThrow();
+ circuitPackName2.append(cpOpt.orElseThrow().getCircuitPackName());
if (!checkPartnerPort(circuitPackName, port, port2)) {
LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG,
nodeId, port2.getPortName(), circuitPackName2, port.getPortName(), circuitPackName);
LOG.error(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, cp.getPortName(), cpName);
return null;
}
- return portObject.get();
+ return portObject.orElseThrow();
}
private boolean checkPortQual(Ports port, String cpName, String nodeId) {
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
nodeId));
interfaceName, nodeId), e);
}
if (intf2DeleteOpt.isPresent()) {
- Interface intf2Delete = intf2DeleteOpt.get();
+ Interface intf2Delete = intf2DeleteOpt.orElseThrow();
// State admin state to out of service
InterfaceBuilder ifBuilder = new InterfaceBuilder()
.setAdministrativeState(AdminStates.OutOfService)
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
nodeId));
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
CircuitPacks cp = null;
if (cpOpt.isPresent()) {
- cp = cpOpt.get();
+ cp = cpOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format(
"Could not find CircuitPack %s in equipment config datastore for node %s", circuitPackName, nodeId));
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
nodeId));
try {
supInterfOpt = getInterface(nodeId, interf);
if (supInterfOpt.isPresent()) {
- return supInterfOpt.get().getSupportingInterface();
+ return supInterfOpt.orElseThrow().getSupportingInterface();
} else {
return null;
}
.child(Ports.class, new PortsKey(ifBuilder.getSupportingPort()))
.build();
Ports port = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL,
- portIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).get();
+ portIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).orElseThrow();
if (port.getInterfaces() == null) {
return false;
}
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
nodeId));
interfaceName, nodeId), e);
}
if (intf2DeleteOpt.isPresent()) {
- Interface intf2Delete = intf2DeleteOpt.get();
+ Interface intf2Delete = intf2DeleteOpt.orElseThrow();
// State admin state to out of service
InterfaceBuilder ifBuilder = new InterfaceBuilder()
.setAdministrativeState(AdminStates.OutOfService)
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
nodeId));
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
CircuitPacks cp = null;
if (cpOpt.isPresent()) {
- cp = cpOpt.get();
+ cp = cpOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format(
"Could not find CircuitPack %s in equipment config datastore for node %s", circuitPackName, nodeId));
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
nodeId));
try {
supInterfOpt = getInterface(nodeId, interf);
if (supInterfOpt.isPresent()) {
- return supInterfOpt.get().getSupportingInterface();
+ return supInterfOpt.orElseThrow().getSupportingInterface();
} else {
return null;
}
.child(Ports.class, new PortsKey(ifBuilder.getSupportingPort()))
.build();
Ports port = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL,
- portIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).get();
+ portIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).orElseThrow();
if (port.getInterfaces() == null) {
return false;
}
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
nodeId));
interfaceName, nodeId), e);
}
if (intf2DeleteOpt.isPresent()) {
- Interface intf2Delete = intf2DeleteOpt.get();
+ Interface intf2Delete = intf2DeleteOpt.orElseThrow();
// set the name and set the type. Having these two lines will post the interface with just
// name, type and admin-state, without all the default values such as maint-testsignal
// delete the interfaces successfully
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
nodeId));
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
CircuitPacks cp = null;
if (cpOpt.isPresent()) {
- cp = cpOpt.get();
+ cp = cpOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format(
"Could not find CircuitPack %s in equipment config datastore for node %s", circuitPackName, nodeId));
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
throw new OpenRoadmInterfaceException(String.format("Device transaction was not found for node %s!",
nodeId));
try {
supInterfOpt = getInterface(nodeId, interf);
if (supInterfOpt.isPresent()) {
- return supInterfOpt.get().getSupportingInterfaceList().stream().findFirst().get();
+ return supInterfOpt.orElseThrow().getSupportingInterfaceList().stream().findFirst().orElseThrow();
} else {
return null;
}
.child(Ports.class, new PortsKey(ifBuilder.getSupportingPort()))
.build();
Ports port = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL,
- portIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).get();
+ portIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).orElseThrow();
if (port.getInterfaces() == null) {
return false;
}
.createWithDataStoreUtil(getDataStoreContextUtil());
try (Reader reader = new FileReader(CATALOG_FILE, StandardCharsets.UTF_8)) {
NormalizedNode normalizedNode = dataObjectConverter
- .transformIntoNormalizedNode(reader).get();
+ .transformIntoNormalizedNode(reader).orElseThrow();
omCatalog = (OperationalModeCatalog) getDataStoreContextUtil()
.getBindingDOMCodecServices().fromNormalizedNode(YangInstanceIdentifier
.of(OperationalModeCatalog.QNAME), normalizedNode)
JSONDataObjectConverter
.createWithDataStoreUtil(getDataStoreContextUtil())
.transformIntoNormalizedNode(reader)
- .get())
+ .orElseThrow())
.getValue(),
JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02),
"Should be a valid request");
spectrumInformation.setLowerSpectralSlotNumber(761);
spectrumInformation.setHigherSpectralSlotNumber(768);
Optional<String> res = crossConnectImpl121.postCrossConnect("deviceId", "srcTp", "destTp", spectrumInformation);
- assertEquals(res.get(), "srcTp-destTp-761:768");
+ assertEquals(res.orElseThrow(), "srcTp-destTp-761:768");
}
@Test
spectrumInformation.setLowerSpectralSlotNumber(761);
spectrumInformation.setHigherSpectralSlotNumber(768);
Optional<String> res = crossConnectImpl221.postCrossConnect("deviceId", "srcTp", "destTp", spectrumInformation);
- assertEquals(res.get(), "srcTp-destTp-761:768");
+ assertEquals(res.orElseThrow(), "srcTp-destTp-761:768");
}
@Test
try {
Future<java.util.Optional<DeviceTransaction>> firstDeviceTxFuture =
transactionManager.getDeviceTransaction(defaultDeviceId);
- DeviceTransaction firstDeviceTx = firstDeviceTxFuture.get().get();
+ DeviceTransaction firstDeviceTx = firstDeviceTxFuture.get().orElseThrow();
Future<java.util.Optional<DeviceTransaction>> secondDeviceTxFuture =
transactionManager.getDeviceTransaction(defaultDeviceId);
transactionManager.getDeviceTransaction("another-id");
Thread.sleep(50);
assertTrue(anotherDeviceTxFuture.isDone());
- anotherDeviceTxFuture.get().get().commit(defaultTimeout, defaultTimeUnit);
+ anotherDeviceTxFuture.get().orElseThrow().commit(defaultTimeout, defaultTimeUnit);
firstDeviceTx.commit(defaultTimeout, defaultTimeUnit);
Thread.sleep(200);
assertTrue(secondDeviceTxFuture.isDone());
assertFalse(thirdDeviceTxFuture.isDone());
- DeviceTransaction secondDeviceTx = secondDeviceTxFuture.get().get();
+ DeviceTransaction secondDeviceTx = secondDeviceTxFuture.get().orElseThrow();
secondDeviceTx.put(defaultDatastore, defaultIid, defaultData);
assertFalse(thirdDeviceTxFuture.isDone());
Thread.sleep(200);
assertTrue(thirdDeviceTxFuture.isDone());
- DeviceTransaction thirdDeviceTx = thirdDeviceTxFuture.get().get();
+ DeviceTransaction thirdDeviceTx = thirdDeviceTxFuture.get().orElseThrow();
thirdDeviceTx.put(defaultDatastore, defaultIid, defaultData);
thirdDeviceTx.commit(defaultTimeout, defaultTimeUnit);
try {
for (Future<java.util.Optional<DeviceTransaction>> futureTx : deviceTransactionFutures) {
- DeviceTransaction deviceTx = futureTx.get().get();
+ DeviceTransaction deviceTx = futureTx.get().orElseThrow();
deviceTx.commit(defaultTimeout, defaultTimeUnit);
deviceTransactions.add(deviceTx);
}
try {
for (int i = 0; i < numberOfTxs; i++) {
- deviceTransactions.add(transactionManager.getDeviceTransaction(defaultDeviceId + " " + i).get().get());
+ deviceTransactions.add(transactionManager.getDeviceTransaction(defaultDeviceId + " " + i).get()
+ .orElseThrow());
}
} catch (InterruptedException | ExecutionException e) {
fail("Exception catched! " + e);
try {
for (int i = 0; i < numberOfTxs; i++) {
- deviceTransactions.add(transactionManager.getDeviceTransaction(defaultDeviceId + " " + i).get().get());
+ deviceTransactions.add(transactionManager.getDeviceTransaction(defaultDeviceId + " " + i).get()
+ .orElseThrow());
}
} catch (InterruptedException | ExecutionException e) {
fail("Exception catched! " + e);
LogicalDatastoreType store, InstanceIdentifier<T> path, T data)
throws ExecutionException, InterruptedException {
Future<java.util.Optional<DeviceTransaction>> deviceTxFuture = deviceTxManager.getDeviceTransaction(deviceId);
- DeviceTransaction deviceTx = deviceTxFuture.get().get();
+ DeviceTransaction deviceTx = deviceTxFuture.get().orElseThrow();
deviceTx.put(store, path, data);
deviceTx.commit(defaultTimeout, defaultTimeUnit);
}
.createWithDataStoreUtil(getDataStoreContextUtil());
try (Reader reader = new FileReader("src/test/resources/network.json", StandardCharsets.UTF_8)) {
NormalizedNode normalizedNode = dataObjectConverter
- .transformIntoNormalizedNode(reader).get();
+ .transformIntoNormalizedNode(reader).orElseThrow();
Network network = (Network) getDataStoreContextUtil()
.getBindingDOMCodecServices().fromNormalizedNode(YangInstanceIdentifier
.of(Network.QNAME), normalizedNode).getValue();
try {
Optional<Network> optionalNetwork = rr.read(LogicalDatastoreType.CONFIGURATION, mappingIID).get();
if (optionalNetwork.isPresent()) {
- network = optionalNetwork.get();
+ network = optionalNetwork.orElseThrow();
}
} catch (ExecutionException | InterruptedException e) {
try {
Optional<Network> optionalNetwork = rr.read(LogicalDatastoreType.CONFIGURATION, mappingIID).get();
if (optionalNetwork.isPresent()) {
- network = optionalNetwork.get();
+ network = optionalNetwork.orElseThrow();
}
} catch (ExecutionException | InterruptedException e) {
LOG.warn("Could not get device info from DataBroker");
return false;
}
- deviceInfo = infoOpt.get();
+ deviceInfo = infoOpt.orElseThrow();
boolean sqlResult = false;
String query = Queries.getQuery().deviceInfoInsert().get();
LOG.info("Running {} query ", query);
if (!deviceObject.isPresent()) {
return;
}
- Map<ShelvesKey, Shelves> shelvesMap = deviceObject.get().nonnullShelves();
+ Map<ShelvesKey, Shelves> shelvesMap = deviceObject.orElseThrow().nonnullShelves();
LOG.info("Shelves size {}", shelvesMap.size());
try (Connection connection = requireNonNull(dataSource.getConnection())) {
for (Map.Entry<ShelvesKey, Shelves> shelveEntry : shelvesMap.entrySet()) {
LOG.warn("Device object {} was not found", nodeId);
return;
}
- Map<CircuitPacksKey, CircuitPacks> circuitPacksMap = deviceObject.get().nonnullCircuitPacks();
+ Map<CircuitPacksKey, CircuitPacks> circuitPacksMap = deviceObject.orElseThrow().nonnullCircuitPacks();
LOG.info("Circuit pack size {}", circuitPacksMap.size());
try (Connection connection = requireNonNull(dataSource.getConnection())) {
if (!deviceObject.isPresent()) {
return;
}
- Map<InterfaceKey, Interface> interfaceMap = deviceObject.get().nonnullInterface();
+ Map<InterfaceKey, Interface> interfaceMap = deviceObject.orElseThrow().nonnullInterface();
for (Map.Entry<InterfaceKey, Interface> interfaceEntrySet : interfaceMap.entrySet()) {
Interface deviceInterface = interfaceEntrySet.getValue();
Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
Optional<Protocols> protocolObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
+ if (!protocolObject.isPresent() || protocolObject.orElseThrow().augmentation(Protocols1.class) == null) {
LOG.error("LLDP subtree is missing");
return;
}
- String adminstatusEnu = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
+ String adminstatusEnu = protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getGlobalConfig()
.getAdminStatus().getName();
- String msgTxtInterval = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
+ String msgTxtInterval = protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getGlobalConfig()
.getMsgTxInterval().toString();
- String mxgTxHoldMultiplier = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
- .getMsgTxHoldMultiplier().toString();
+ String mxgTxHoldMultiplier = protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp()
+ .getGlobalConfig().getMsgTxHoldMultiplier().toString();
String startTimestamp = getCurrentTimestamp();
persistDevProtocolLldpPortConfig(nodeId, connection);
persistDevProtocolLldpNbrList(nodeId, connection);
Optional<Protocols> protocolObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
+ if (!protocolObject.isPresent() || protocolObject.orElseThrow().augmentation(Protocols1.class) == null) {
LOG.error("LLDP subtree is missing");
return;
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<PortConfigKey, PortConfig> portConfigMap = protocolObject.get()
+ Map<PortConfigKey, PortConfig> portConfigMap = protocolObject.orElseThrow()
.augmentation(Protocols1.class).getLldp().nonnullPortConfig();
for (Map.Entry<PortConfigKey, PortConfig> entry : portConfigMap.entrySet()) {
PortConfig portConfig = entry.getValue();
LOG.error("Protocols is missing");
return;
}
- if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
+ if (protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
protocolObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, protocolsIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
+ if (protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
LOG.error("LLDP nbrlist subtree is missing for {}", nodeId);
return;
}
}
String startTimestamp = getCurrentTimestamp();
Map<IfNameKey, IfName> ifNameMap =
- protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().nonnullIfName();
+ protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getNbrList().nonnullIfName();
for (Map.Entry<IfNameKey, IfName> ifNameEntry : ifNameMap.entrySet()) {
IfName ifNameObj = ifNameEntry.getValue();
if (!deviceObject.isPresent()) {
return;
}
- if (deviceObject.get().getInternalLink() == null) {
+ if (deviceObject.orElseThrow().getInternalLink() == null) {
deviceObject = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION,
deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (deviceObject.get().getInternalLink() == null) {
+ if (deviceObject.orElseThrow().getInternalLink() == null) {
LOG.info("External links not found for {}", nodeId);
return;
}
}
@NonNull
- Map<InternalLinkKey, InternalLink> internalLinkMap = deviceObject.get().nonnullInternalLink();
+ Map<InternalLinkKey, InternalLink> internalLinkMap = deviceObject.orElseThrow().nonnullInternalLink();
String startTimestamp = getCurrentTimestamp();
for (Map.Entry<InternalLinkKey, InternalLink> internalLinkEntry: internalLinkMap.entrySet()) {
InternalLink internalLink = internalLinkEntry.getValue();
if (!deviceObject.isPresent()) {
return;
}
- if (deviceObject.get().getExternalLink() == null) {
+ if (deviceObject.orElseThrow().getExternalLink() == null) {
deviceObject = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION,
deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (deviceObject.get().getExternalLink() == null) {
+ if (deviceObject.orElseThrow().getExternalLink() == null) {
LOG.info("External links not found for {}", nodeId);
return;
}
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<ExternalLinkKey, ExternalLink> externalLinkMap = deviceObject.get().nonnullExternalLink();
+ Map<ExternalLinkKey, ExternalLink> externalLinkMap = deviceObject.orElseThrow().nonnullExternalLink();
for (Map.Entry<ExternalLinkKey, ExternalLink> externalLinkEntry: externalLinkMap.entrySet()) {
ExternalLink externalLink = externalLinkEntry.getValue();
String externalLinkName = externalLink.getExternalLinkName();
LOG.error("No device with node Id {}", nodeId);
return;
}
- if (deviceObject.get().getPhysicalLink() == null) {
+ if (deviceObject.orElseThrow().getPhysicalLink() == null) {
deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
LOG.error("No device with node Id {}", nodeId);
return;
}
- if (deviceObject.get().getPhysicalLink() == null) {
+ if (deviceObject.orElseThrow().getPhysicalLink() == null) {
LOG.info("Physical links not found for {}", nodeId);
return;
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<PhysicalLinkKey, PhysicalLink> physicalLinkMap = deviceObject.get().nonnullPhysicalLink();
+ Map<PhysicalLinkKey, PhysicalLink> physicalLinkMap = deviceObject.orElseThrow().nonnullPhysicalLink();
for (Map.Entry<PhysicalLinkKey, PhysicalLink> physicalLinkEntry : physicalLinkMap.entrySet()) {
PhysicalLink physicalLink = physicalLinkEntry.getValue();
String physicalLinkName = physicalLink.getPhysicalLinkName();
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<DegreeKey, Degree> degreeMap = deviceObject.get().nonnullDegree();
+ Map<DegreeKey, Degree> degreeMap = deviceObject.orElseThrow().nonnullDegree();
for (Map.Entry<DegreeKey, Degree> degreeEntry : degreeMap.entrySet()) {
Degree degree = degreeEntry.getValue();
String degreeNumber = degree.getDegreeNumber().toString();
return;
}
- if (deviceObject.get().getSharedRiskGroup() == null) {
+ if (deviceObject.orElseThrow().getSharedRiskGroup() == null) {
deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
}
@NonNull
- Map<SharedRiskGroupKey, SharedRiskGroup> sharedRiskGroupMap = deviceObject.get().nonnullSharedRiskGroup();
+ Map<SharedRiskGroupKey, SharedRiskGroup> sharedRiskGroupMap = deviceObject.orElseThrow()
+ .nonnullSharedRiskGroup();
if (sharedRiskGroupMap.isEmpty()) {
LOG.info("no srg found for node {} ", nodeId);
return;
LOG.error("No device found in operational datastore for node {}", nodeId);
return;
}
- if (deviceObject.get().getRoadmConnections() == null) {
+ if (deviceObject.orElseThrow().getRoadmConnections() == null) {
deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
}
@NonNull
- Map<RoadmConnectionsKey, RoadmConnections> connectionsMap = deviceObject.get().nonnullRoadmConnections();
+ Map<RoadmConnectionsKey, RoadmConnections> connectionsMap = deviceObject.orElseThrow()
+ .nonnullRoadmConnections();
if (connectionsMap.isEmpty()) {
LOG.info("ROADM Dev Connections not found!! for {}", nodeId);
return;
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<ConnectionMapKey, ConnectionMap> connectionsMap = deviceObject.get().nonnullConnectionMap();
+ Map<ConnectionMapKey, ConnectionMap> connectionsMap = deviceObject.orElseThrow().nonnullConnectionMap();
for (Map.Entry<ConnectionMapKey, ConnectionMap> entry : connectionsMap.entrySet()) {
ConnectionMap connectionMap = entry.getValue();
String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<WavelengthsKey, Wavelengths> wavelengthsMap = deviceObject.get().getWavelengthMap().nonnullWavelengths();
+ Map<WavelengthsKey, Wavelengths> wavelengthsMap = deviceObject.orElseThrow().getWavelengthMap()
+ .nonnullWavelengths();
for (Map.Entry<WavelengthsKey, Wavelengths> entry : wavelengthsMap.entrySet()) {
Wavelengths wavelengths = entry.getValue();
String wavelengthNumber = wavelengths.getWavelengthNumber().toString();
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
Info deviceInfo;
if (infoOpt.isPresent()) {
- deviceInfo = infoOpt.get();
+ deviceInfo = infoOpt.orElseThrow();
} else {
LOG.warn("Could not get device info from DataBroker");
return false;
return;
}
@NonNull
- Map<ShelvesKey, Shelves> shelvesMap = deviceObject.get().nonnullShelves();
+ Map<ShelvesKey, Shelves> shelvesMap = deviceObject.orElseThrow().nonnullShelves();
LOG.info("Shelves size {}", shelvesMap.size());
try (Connection connection = requireNonNull(dataSource.getConnection())) {
for (Map.Entry<ShelvesKey, Shelves> entry : shelvesMap.entrySet()) {
return;
}
@NonNull
- Map<CircuitPacksKey, CircuitPacks> circuitPacksMap = deviceObject.get().nonnullCircuitPacks();
+ Map<CircuitPacksKey, CircuitPacks> circuitPacksMap = deviceObject.orElseThrow().nonnullCircuitPacks();
LOG.info("Circuit pack size {}", circuitPacksMap.size());
try (Connection connection = requireNonNull(dataSource.getConnection())) {
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); */
@NonNull
- Map<InterfaceKey, Interface> interfaceMap = deviceObject.get().nonnullInterface();
+ Map<InterfaceKey, Interface> interfaceMap = deviceObject.orElseThrow().nonnullInterface();
for (Map.Entry<InterfaceKey, Interface> entry : interfaceMap.entrySet()) {
Interface deviceInterface;
Optional<Protocols> protocolObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
+ if (!protocolObject.isPresent() || protocolObject.orElseThrow().augmentation(Protocols1.class) == null) {
LOG.error("LLDP subtree is missing");
return;
}
int adminstatusEnu =
- protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getAdminStatus()
- .getIntValue();
+ protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getGlobalConfig().getAdminStatus()
+ .getIntValue();
String msgTxtInterval =
- protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getMsgTxInterval()
- .toString();
+ protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getGlobalConfig().getMsgTxInterval()
+ .toString();
String mxgTxHoldMultiplier =
- protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getMsgTxHoldMultiplier()
- .toString();
+ protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getGlobalConfig()
+ .getMsgTxHoldMultiplier().toString();
String startTimestamp = getCurrentTimestamp();
persistDevProtocolLldpPortConfig(nodeId, connection);
persistDevProtocolLldpNbrList(nodeId, connection);
Optional<Protocols> protocolObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
+ if (!protocolObject.isPresent() || protocolObject.orElseThrow().augmentation(Protocols1.class) == null) {
LOG.error("LLDP subtree is missing");
return;
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<PortConfigKey, PortConfig> portConfigMap = protocolObject.get()
+ Map<PortConfigKey, PortConfig> portConfigMap = protocolObject.orElseThrow()
.augmentation(Protocols1.class).getLldp().nonnullPortConfig();
for (Map.Entry<PortConfigKey, PortConfig> entry : portConfigMap.entrySet()) {
Optional<Protocols> protocolObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
+ if (!protocolObject.isPresent() || protocolObject.orElseThrow().augmentation(Protocols1.class) == null) {
LOG.error("LLDP subtree is missing");
return;
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<IfNameKey, IfName> ifNameMap = protocolObject.get()
+ Map<IfNameKey, IfName> ifNameMap = protocolObject.orElseThrow()
.augmentation(Protocols1.class).getLldp().getNbrList().nonnullIfName();
for (Map.Entry<IfNameKey, IfName> entry : ifNameMap.entrySet()) {
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<InternalLinkKey, InternalLink> internalLinkMap = deviceObject.get().nonnullInternalLink();
+ Map<InternalLinkKey, InternalLink> internalLinkMap = deviceObject.orElseThrow().nonnullInternalLink();
for (Map.Entry<InternalLinkKey, InternalLink> entry : internalLinkMap.entrySet()) {
InternalLink internalLink = entry.getValue();
String internalLinkName = internalLink.getInternalLinkName();
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<ExternalLinkKey, ExternalLink> externalLinkMap = deviceObject.get().nonnullExternalLink();
+ Map<ExternalLinkKey, ExternalLink> externalLinkMap = deviceObject.orElseThrow().nonnullExternalLink();
for (Map.Entry<ExternalLinkKey, ExternalLink> entry : externalLinkMap.entrySet()) {
ExternalLink externalLink = entry.getValue();
String externalLinkName = externalLink.getExternalLinkName();
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<PhysicalLinkKey, PhysicalLink> physicalLinkMap = deviceObject.get().nonnullPhysicalLink();
+ Map<PhysicalLinkKey, PhysicalLink> physicalLinkMap = deviceObject.orElseThrow().nonnullPhysicalLink();
for (Map.Entry<PhysicalLinkKey, PhysicalLink> entry : physicalLinkMap.entrySet()) {
PhysicalLink physicalLink = entry.getValue();
String physicalLinkName = physicalLink.getPhysicalLinkName();
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<DegreeKey, Degree> degreeMap = deviceObject.get().nonnullDegree();
+ Map<DegreeKey, Degree> degreeMap = deviceObject.orElseThrow().nonnullDegree();
for (Map.Entry<DegreeKey, Degree> entry : degreeMap.entrySet()) {
Degree degree = entry.getValue();
String degreeNumber = degree.getDegreeNumber().toString();
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<SharedRiskGroupKey, SharedRiskGroup> sharedRiskGroupMap = deviceObject.get().nonnullSharedRiskGroup();
+ Map<SharedRiskGroupKey, SharedRiskGroup> sharedRiskGroupMap = deviceObject.orElseThrow()
+ .nonnullSharedRiskGroup();
for (Map.Entry<SharedRiskGroupKey, SharedRiskGroup> entry : sharedRiskGroupMap.entrySet()) {
SharedRiskGroup sharedRiskGroup = entry.getValue();
String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<RoadmConnectionsKey, RoadmConnections> roadmConnectionsMap = deviceObject.get().nonnullRoadmConnections();
+ Map<RoadmConnectionsKey, RoadmConnections> roadmConnectionsMap = deviceObject.orElseThrow()
+ .nonnullRoadmConnections();
for (Map.Entry<RoadmConnectionsKey, RoadmConnections> entry : roadmConnectionsMap.entrySet()) {
RoadmConnections roadmConnections = entry.getValue();
int opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getIntValue();
}
String startTimestamp = getCurrentTimestamp();
@NonNull
- Map<ConnectionMapKey, ConnectionMap> connectionMapMap = deviceObject.get().nonnullConnectionMap();
+ Map<ConnectionMapKey, ConnectionMap> connectionMapMap = deviceObject.orElseThrow().nonnullConnectionMap();
for (Map.Entry<ConnectionMapKey, ConnectionMap> entry : connectionMapMap.entrySet()) {
ConnectionMap connectionMap = entry.getValue();
String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
.withError(ErrorType.APPLICATION,
"Notification subscription doesnt exist").buildFuture();
}
- NotifSubscription notifSubscription = optionalNotifSub.get();
+ NotifSubscription notifSubscription = optionalNotifSub.orElseThrow();
this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, notifSubscriptionIID);
this.networkTransactionService.commit().get();
for (Uuid objectUuid:notifSubscription.getSubscriptionFilter().getRequestedObjectIdentifier()) {
.withError(ErrorType.APPLICATION,
"Notification subscription doesnt exist").buildFuture();
}
- NotifSubscription notifSubscription = optionalNotifSub.get();
+ NotifSubscription notifSubscription = optionalNotifSub.orElseThrow();
List<Notification> notificationTapiList = new ArrayList<>();
for (Uuid objectUuid:notifSubscription.getSubscriptionFilter().getRequestedObjectIdentifier()) {
if (!this.topicManager.getTapiTopicMap().containsKey(objectUuid.getValue())) {
LOG.error("Could not get TAPI notification context");
return null;
}
- return notificationContextOptional.get();
+ return notificationContextOptional.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Could not get TAPI notification context");
}
return;
}
this.networkModelService
- .createOpenRoadmNode(nodeId, deviceCapabilityOpt.get().getCapability());
- onDeviceConnected(nodeId, deviceCapabilityOpt.get().getCapability());
+ .createOpenRoadmNode(nodeId, deviceCapabilityOpt.orElseThrow().getCapability());
+ onDeviceConnected(nodeId, deviceCapabilityOpt.orElseThrow().getCapability());
LOG.info("Device {} correctly connected to controller", nodeId);
}
if (ConnectionStatus.Connected.equals(netconfNodeBefore.getConnectionStatus())
LOG.error("Failed to get mount point for node {}", nodeId);
return;
}
- MountPoint mountPoint = mountPointOpt.get();
+ MountPoint mountPoint = mountPointOpt.orElseThrow();
final Optional<NotificationService> notificationService = mountPoint.getService(NotificationService.class);
if (notificationService.isEmpty()) {
LOG.error(RPC_SERVICE_FAILED, nodeId);
}
NodeRegistration nodeRegistration =
new NodeRegistration(
- nodeId, openRoadmVersion, notificationService.get(), this.dataBroker, this.portMapping);
+ nodeId, openRoadmVersion, notificationService.orElseThrow(), this.dataBroker, this.portMapping);
nodeRegistration.registerListeners();
registrations.put(nodeId, nodeRegistration);
if (service.isEmpty()) {
return false;
}
- final NotificationsService rpcService = service.get().getRpcService(NotificationsService.class);
+ final NotificationsService rpcService = service.orElseThrow().getRpcService(NotificationsService.class);
if (rpcService == null) {
LOG.error(RPC_SERVICE_FAILED, nodeId);
return false;
Optional<Streams> ordmInfoObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, streamsIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (ordmInfoObject == null || ordmInfoObject.isEmpty() || ordmInfoObject.get().getStream().isEmpty()) {
+ if (ordmInfoObject == null || ordmInfoObject.isEmpty() || ordmInfoObject.orElseThrow().getStream().isEmpty()) {
LOG.error("List of streams supports by device is not present");
return List.of("OPENROADM","NETCONF");
}
List<String> streams = new ArrayList<>();
List<String> netconfStreams = new ArrayList<>();
- for (Stream strm : ordmInfoObject.get().getStream().values()) {
+ for (Stream strm : ordmInfoObject.orElseThrow().getStream().values()) {
LOG.debug("Streams are {}", strm);
if ("OPENROADM".equalsIgnoreCase(strm.getName().getValue())) {
streams.add(strm.getName().getValue());
Optional<TerminationPoint> tpOpt;
tpOpt = tpFf.get();
if (tpOpt.isPresent()) {
- return tpOpt.get();
+ return tpOpt.orElseThrow();
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Impossible to get tp-id {} of node {} from {}", srcTp, srcNode,
return false;
}
// get neighbor list
- NbrList nbr121List = protocol121Object.get().augmentation(Protocols1.class).getLldp().getNbrList();
+ NbrList nbr121List = protocol121Object.orElseThrow().augmentation(Protocols1.class).getLldp()
+ .getNbrList();
LOG.info("LLDP subtree is present. Device has {} neighbours", nbr121List.getIfName().size());
// try to create rdm2rdm link
return rdm2rdmLinkCreatedv121(nodeId, nbr121List);
LOG.warn("LLDP subtree is missing or incomplete: isolated openroadm device");
return false;
}
- var nbr221List = protocol221Object.get().augmentation(
+ var nbr221List = protocol221Object.orElseThrow().augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class)
.getLldp().getNbrList();
LOG.info("LLDP subtree is present. Device has {} neighbours", nbr221List.getIfName().size());
private boolean hasNoNeighbor121(Optional<Protocols> protocol121Object) {
return protocol121Object.isEmpty()
- || protocol121Object.get().augmentation(Protocols1.class) == null
- || protocol121Object.get().augmentation(Protocols1.class).getLldp() == null
- || protocol121Object.get().augmentation(Protocols1.class).getLldp().getNbrList() == null;
+ || protocol121Object.orElseThrow().augmentation(Protocols1.class) == null
+ || protocol121Object.orElseThrow().augmentation(Protocols1.class).getLldp() == null
+ || protocol121Object.orElseThrow().augmentation(Protocols1.class).getLldp().getNbrList() == null;
}
private boolean hasNoNeighbor221(Optional<
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org
.openroadm.device.Protocols> protocol221Object) {
return protocol221Object.isEmpty()
- || protocol221Object.get().augmentation(
+ || protocol221Object.orElseThrow().augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class) == null
- || protocol221Object.get().augmentation(
+ || protocol221Object.orElseThrow().augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class)
.getLldp() == null
- || protocol221Object.get().augmentation(
+ || protocol221Object.orElseThrow().augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class)
.getLldp().getNbrList() == null;
}
.child(Nodes.class, new NodesKey(nodeId.getValue())).build();
try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
Optional<Nodes> nodesObject = readTx.read(LogicalDatastoreType.CONFIGURATION, nodesIID).get();
- if (nodesObject.isPresent() && (nodesObject.get().getMapping() != null)) {
- Collection<Mapping> mappingList = nodesObject.get().nonnullMapping().values();
+ if (nodesObject.isPresent() && (nodesObject.orElseThrow().getMapping() != null)) {
+ Collection<Mapping> mappingList = nodesObject.orElseThrow().nonnullMapping().values();
mappingList = mappingList.stream().filter(mp -> mp.getLogicalConnectionPoint().contains("DEG"
+ degreeCounter)).collect(Collectors.toList());
if (mappingList.size() == 1) {
.child(Nodes.class, new NodesKey(nodeId.getValue())).build();
try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
Optional<Nodes> nodesObject = readTx.read(LogicalDatastoreType.CONFIGURATION, nodesIID).get();
- if (nodesObject.isPresent() && (nodesObject.get().getCpToDegree() != null)) {
- Collection<CpToDegree> cpToDeg = nodesObject.get().nonnullCpToDegree().values();
+ if (nodesObject.isPresent() && (nodesObject.orElseThrow().getCpToDegree() != null)) {
+ Collection<CpToDegree> cpToDeg = nodesObject.orElseThrow().nonnullCpToDegree().values();
Stream<CpToDegree> cpToDegStream = cpToDeg.stream().filter(cp -> cp.getInterfaceName() != null)
.filter(cp -> cp.getInterfaceName().equals(interfaceName));
if (cpToDegStream != null) {
@SuppressWarnings("unchecked") Optional<CpToDegree> firstCpToDegree = cpToDegStream.findFirst();
if (firstCpToDegree.isPresent() && (firstCpToDegree != null)) {
- LOG.debug("Found and returning {}",firstCpToDegree.get().getDegreeNumber().intValue());
- return firstCpToDegree.get().getDegreeNumber().intValue();
+ LOG.debug("Found and returning {}",firstCpToDegree.orElseThrow().getDegreeNumber().intValue());
+ return firstCpToDegree.orElseThrow().getDegreeNumber().intValue();
} else {
LOG.debug("Not found so returning nothing");
return null;
Optional<TerminationPoint> tpOpt;
tpOpt = tpFf.get();
if (tpOpt.isPresent()) {
- return tpOpt.get();
+ return tpOpt.orElseThrow();
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Impossible to get tp-id {} of node {} from {}", srcTp, srcNode,
Optional<ServiceNodelist> serviceListObject =
rtx.read(LogicalDatastoreType.OPERATIONAL, serviceNodeListIID).get();
if (serviceListObject.isPresent()) {
- for (Nodelist nodelist : serviceListObject.get().nonnullNodelist().values()) {
+ for (Nodelist nodelist : serviceListObject.orElseThrow().nonnullNodelist().values()) {
allNodeList.addAll(nodelist.nonnullNodes().values());
}
}
case CircuitPack:
Optional<CircuitPack> circuitPackOptional = tryCastToParticularResource(CircuitPack.class, resource);
if (circuitPackOptional.isPresent()) {
- circuitPack = circuitPackOptional.get().getCircuitPackName();
+ circuitPack = circuitPackOptional.orElseThrow().getCircuitPackName();
}
break;
case Connection:
Optional<Connection> connectionOptional = tryCastToParticularResource(Connection.class, resource);
if (connectionOptional.isPresent()) {
- connection = connectionOptional.get().getConnectionNumber();
+ connection = connectionOptional.orElseThrow().getConnectionNumber();
}
break;
case Degree:
Optional<Degree> degreeOptional = tryCastToParticularResource(Degree.class, resource);
if (degreeOptional.isPresent()) {
- degree = degreeOptional.get().getDegreeNumber().toString();
+ degree = degreeOptional.orElseThrow().getDegreeNumber().toString();
}
break;
case Interface:
Optional<Interface> interfaceOptional = tryCastToParticularResource(Interface.class, resource);
if (interfaceOptional.isPresent()) {
- iface = interfaceOptional.get().getInterfaceName();
+ iface = interfaceOptional.orElseThrow().getInterfaceName();
}
break;
case InternalLink:
Optional<InternalLink> internalLinkOptional = tryCastToParticularResource(InternalLink.class, resource);
if (internalLinkOptional.isPresent()) {
- internalLink = internalLinkOptional.get().getInternalLinkName();
+ internalLink = internalLinkOptional.orElseThrow().getInternalLinkName();
}
break;
case PhysicalLink:
Optional<PhysicalLink> physicalLinkOptional = tryCastToParticularResource(PhysicalLink.class, resource);
if (physicalLinkOptional.isPresent()) {
- physicalLink = physicalLinkOptional.get().getPhysicalLinkName();
+ physicalLink = physicalLinkOptional.orElseThrow().getPhysicalLinkName();
}
break;
case Service:
Optional<Service> serviceOptional = tryCastToParticularResource(Service.class, resource);
if (serviceOptional.isPresent()) {
- service = serviceOptional.get().getServiceName();
+ service = serviceOptional.orElseThrow().getServiceName();
}
break;
case Shelf:
Optional<Shelf> shelfOptional = tryCastToParticularResource(Shelf.class, resource);
if (shelfOptional.isPresent()) {
- shelf = shelfOptional.get().getShelfName();
+ shelf = shelfOptional.orElseThrow().getShelfName();
}
break;
case SharedRiskGroup:
Optional<Srg> sharedRiskGroupOptional = tryCastToParticularResource(Srg.class, resource);
if (sharedRiskGroupOptional.isPresent()) {
- sharedRiskGroup = sharedRiskGroupOptional.get().getSrgNumber().toString();
+ sharedRiskGroup = sharedRiskGroupOptional.orElseThrow().getSrgNumber().toString();
}
break;
case Port:
Optional<Port> portContainerOptional = tryCastToParticularResource(Port.class, resource);
if (portContainerOptional.isPresent()) {
- port = portContainerOptional.get().getPort().getPortName();
- portCircuitPack = portContainerOptional.get().getPort().getCircuitPackName();
+ port = portContainerOptional.orElseThrow().getPort().getPortName();
+ portCircuitPack = portContainerOptional.orElseThrow().getPort().getCircuitPackName();
}
break;
Optional<ServiceNodelist> serviceListObject =
rtx.read(LogicalDatastoreType.OPERATIONAL, serviceNodeListIID).get();
if (serviceListObject.isPresent()) {
- for (Nodelist nodelist : serviceListObject.get().nonnullNodelist().values()) {
+ for (Nodelist nodelist : serviceListObject.orElseThrow().nonnullNodelist().values()) {
allNodeList.addAll(nodelist.nonnullNodes().values());
}
}
case CircuitPack:
Optional<CircuitPack> circuitPackOptional = tryCastToParticularResource(CircuitPack.class, resource);
if (circuitPackOptional.isPresent()) {
- circuitPack = circuitPackOptional.get().getCircuitPackName();
+ circuitPack = circuitPackOptional.orElseThrow().getCircuitPackName();
}
break;
case Connection:
Optional<Connection> connectionOptional = tryCastToParticularResource(Connection.class, resource);
if (connectionOptional.isPresent()) {
- connection = connectionOptional.get().getConnectionName();
+ connection = connectionOptional.orElseThrow().getConnectionName();
}
break;
case Degree:
Optional<Degree> degreeOptional = tryCastToParticularResource(Degree.class, resource);
if (degreeOptional.isPresent()) {
- degree = degreeOptional.get().getDegreeNumber().toString();
+ degree = degreeOptional.orElseThrow().getDegreeNumber().toString();
}
break;
case Interface:
Optional<Interface> interfaceOptional = tryCastToParticularResource(Interface.class, resource);
if (interfaceOptional.isPresent()) {
- iface = interfaceOptional.get().getInterfaceName();
+ iface = interfaceOptional.orElseThrow().getInterfaceName();
}
break;
case InternalLink:
Optional<InternalLink> internalLinkOptional = tryCastToParticularResource(InternalLink.class, resource);
if (internalLinkOptional.isPresent()) {
- internalLink = internalLinkOptional.get().getInternalLinkName();
+ internalLink = internalLinkOptional.orElseThrow().getInternalLinkName();
}
break;
case PhysicalLink:
Optional<PhysicalLink> physicalLinkOptional = tryCastToParticularResource(PhysicalLink.class, resource);
if (physicalLinkOptional.isPresent()) {
- physicalLink = physicalLinkOptional.get().getPhysicalLinkName();
+ physicalLink = physicalLinkOptional.orElseThrow().getPhysicalLinkName();
}
break;
case Service:
Optional<Service> serviceOptional = tryCastToParticularResource(Service.class, resource);
if (serviceOptional.isPresent()) {
- service = serviceOptional.get().getServiceName();
+ service = serviceOptional.orElseThrow().getServiceName();
}
break;
case Shelf:
Optional<Shelf> shelfOptional = tryCastToParticularResource(Shelf.class, resource);
if (shelfOptional.isPresent()) {
- shelf = shelfOptional.get().getShelfName();
+ shelf = shelfOptional.orElseThrow().getShelfName();
}
break;
case SharedRiskGroup:
Optional<Srg> sharedRiskGroupOptional = tryCastToParticularResource(Srg.class, resource);
if (sharedRiskGroupOptional.isPresent()) {
- sharedRiskGroup = sharedRiskGroupOptional.get().getSrgNumber().toString();
+ sharedRiskGroup = sharedRiskGroupOptional.orElseThrow().getSrgNumber().toString();
}
break;
case Port:
Optional<Port> portContainerOptional = tryCastToParticularResource(Port.class, resource);
if (portContainerOptional.isPresent()) {
- port = portContainerOptional.get().getPort().getPortName();
- portCircuitPack = portContainerOptional.get().getPort().getCircuitPackName();
+ port = portContainerOptional.orElseThrow().getPort().getPortName();
+ portCircuitPack = portContainerOptional.orElseThrow().getPort().getCircuitPackName();
}
break;
Optional<ServiceNodelist> serviceListObject =
rtx.read(LogicalDatastoreType.OPERATIONAL, serviceNodeListIID).get();
if (serviceListObject.isPresent()) {
- for (Nodelist nodelist : serviceListObject.get().nonnullNodelist().values()) {
+ for (Nodelist nodelist : serviceListObject.orElseThrow().nonnullNodelist().values()) {
allNodeList.addAll(nodelist.nonnullNodes().values());
}
}
case CircuitPack:
Optional<CircuitPack> circuitPackOptional = tryCastToParticularResource(CircuitPack.class, resource);
if (circuitPackOptional.isPresent()) {
- circuitPack = circuitPackOptional.get().getCircuitPackName();
+ circuitPack = circuitPackOptional.orElseThrow().getCircuitPackName();
}
break;
case Connection:
Optional<Connection> connectionOptional = tryCastToParticularResource(Connection.class, resource);
if (connectionOptional.isPresent()) {
- connection = connectionOptional.get().getConnectionName();
+ connection = connectionOptional.orElseThrow().getConnectionName();
}
break;
case Degree:
Optional<Degree> degreeOptional = tryCastToParticularResource(Degree.class, resource);
if (degreeOptional.isPresent()) {
- degree = degreeOptional.get().getDegreeNumber().toString();
+ degree = degreeOptional.orElseThrow().getDegreeNumber().toString();
}
break;
case Interface:
Optional<Interface> interfaceOptional = tryCastToParticularResource(Interface.class, resource);
if (interfaceOptional.isPresent()) {
- iface = interfaceOptional.get().getInterfaceName();
+ iface = interfaceOptional.orElseThrow().getInterfaceName();
}
break;
case InternalLink:
Optional<InternalLink> internalLinkOptional = tryCastToParticularResource(InternalLink.class, resource);
if (internalLinkOptional.isPresent()) {
- internalLink = internalLinkOptional.get().getInternalLinkName();
+ internalLink = internalLinkOptional.orElseThrow().getInternalLinkName();
}
break;
case PhysicalLink:
Optional<PhysicalLink> physicalLinkOptional = tryCastToParticularResource(PhysicalLink.class, resource);
if (physicalLinkOptional.isPresent()) {
- physicalLink = physicalLinkOptional.get().getPhysicalLinkName();
+ physicalLink = physicalLinkOptional.orElseThrow().getPhysicalLinkName();
}
break;
case Service:
Optional<Service> serviceOptional = tryCastToParticularResource(Service.class, resource);
if (serviceOptional.isPresent()) {
- service = serviceOptional.get().getServiceName();
+ service = serviceOptional.orElseThrow().getServiceName();
}
break;
case Shelf:
Optional<Shelf> shelfOptional = tryCastToParticularResource(Shelf.class, resource);
if (shelfOptional.isPresent()) {
- shelf = shelfOptional.get().getShelfName();
+ shelf = shelfOptional.orElseThrow().getShelfName();
}
break;
case SharedRiskGroup:
Optional<Srg> sharedRiskGroupOptional = tryCastToParticularResource(Srg.class, resource);
if (sharedRiskGroupOptional.isPresent()) {
- sharedRiskGroup = sharedRiskGroupOptional.get().getSrgNumber().toString();
+ sharedRiskGroup = sharedRiskGroupOptional.orElseThrow().getSrgNumber().toString();
}
break;
case Port:
Optional<Port> portContainerOptional = tryCastToParticularResource(Port.class, resource);
if (portContainerOptional.isPresent()) {
- port = portContainerOptional.get().getPort().getPortName();
- portCircuitPack = portContainerOptional.get().getPort().getCircuitPackName();
+ port = portContainerOptional.orElseThrow().getPort().getPortName();
+ portCircuitPack = portContainerOptional.orElseThrow().getPort().getCircuitPackName();
}
break;
nodeId, NetworkUtils.OVERLAY_NETWORK_ID);
return null;
}
- return optionalNode.get();
+ return optionalNode.orElseThrow();
} catch (ExecutionException | TimeoutException e) {
LOG.warn("Exception while getting network node for node id {} from {} topology",
nodeId, NetworkUtils.OVERLAY_NETWORK_ID, e);
nodeId, NetworkUtils.OVERLAY_NETWORK_ID);
return null;
}
- return optionalNode.get();
+ return optionalNode.orElseThrow();
} catch (ExecutionException | TimeoutException e) {
LOG.warn("Exception while getting common network node for node id {} from {} topology",
nodeId, NetworkUtils.OVERLAY_NETWORK_ID, e);
Optional<TerminationPoint1> optionalTerminationPoint = readTx
.read(LogicalDatastoreType.CONFIGURATION, tpIID)
.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS);
- return optionalTerminationPoint.isEmpty() ? null : optionalTerminationPoint.get();
+ return optionalTerminationPoint.isEmpty() ? null : optionalTerminationPoint.orElseThrow();
} catch (ExecutionException | TimeoutException e) {
LOG.warn("Exception while getting termination {} for node id {} point from {} topology",
tpId, nodeId, NetworkUtils.OVERLAY_NETWORK_ID, e);
tpId, nodeId, NetworkUtils.OVERLAY_NETWORK_ID);
return null;
}
- return optionalTerminationPoint.get();
+ return optionalTerminationPoint.orElseThrow();
} catch (ExecutionException | TimeoutException e) {
LOG.warn("Exception while getting common-network termination {} for node id {} point from {} topology",
tpId, nodeId, NetworkUtils.OVERLAY_NETWORK_ID, e);
try {
openroadmTopology = this.networkTransactionService
.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifiers.OVERLAY_NETWORK_II)
- .get().get();
+ .get().orElseThrow();
if (openroadmTopology.augmentation(Network1.class) != null) {
openroadmTopologyLinks = openroadmTopology.augmentation(Network1.class).getLink();
}
otnTopology = this.networkTransactionService
.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifiers.OTN_NETWORK_II)
- .get().get();
+ .get().orElseThrow();
if (otnTopology.augmentation(Network1.class) != null) {
otnTopologyLinks = otnTopology.augmentation(Network1.class).getLink();
}
if (linkOptLf.isDone()) {
try {
if (linkOptLf.get().isPresent()) {
- links.add(linkOptLf.get().get());
+ links.add(linkOptLf.get().orElseThrow());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error retreiving OTN links from otn-topology", e);
}
if (tpAOpt.isPresent() && tpZOpt.isPresent()) {
- tps.add(tpAOpt.get());
- tps.add(tpZOpt.get());
+ tps.add(tpAOpt.orElseThrow());
+ tps.add(tpZOpt.orElseThrow());
}
return tps;
}
try {
tpOpt = networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, iiTp).get();
if (tpOpt.isPresent()) {
- tps.add(tpOpt.get());
+ tps.add(tpOpt.orElseThrow());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error retreiving tp {} of node {} from otn-topology", tp, nodeId, e);
}
}
List<Link> odu4links = null;
- if (netw1Opt.isPresent() && netw1Opt.get().getLink() != null) {
+ if (netw1Opt.isPresent() && netw1Opt.orElseThrow().getLink() != null) {
odu4links = netw1Opt
- .get()
+ .orElseThrow()
.nonnullLink().values()
.stream().filter(lk -> lk.getLinkId().getValue()
.startsWith(Uint32.valueOf(100).equals(serviceRate) ? "ODUC4" : "ODTU4"))
String nodeId = new StringBuilder(linkTp.getNodeId()).append("-")
.append(tp.split("-")[0]).toString();
Link slink = odu4links.stream().filter(lk -> lk.getSource().getSourceNode().getValue()
- .equals(nodeId) && lk.getSource().getSourceTp().getValue().equals(tp)).findFirst().get();
+ .equals(nodeId) && lk.getSource().getSourceTp().getValue().equals(tp)).findFirst().orElseThrow();
if (!links.contains(slink)) {
links.add(slink);
}
Link dlink = odu4links.stream().filter(lk -> lk.getDestination().getDestNode().getValue()
- .equals(nodeId) && lk.getDestination().getDestTp().getValue().equals(tp)).findFirst().get();
+ .equals(nodeId) && lk.getDestination().getDestTp().getValue().equals(tp)).findFirst().orElseThrow();
if (!links.contains(dlink)) {
links.add(dlink);
}
.ietf.network.topology.rev180226.Node1.class)
.nonnullTerminationPoint().values().stream()
.filter(tp -> tp.getTpId().getValue().contains("CP") || tp.getTpId().getValue().contains("CTP"))
- .findFirst().get().getTpId().getValue();
+ .findFirst().orElseThrow().getTpId().getValue();
destTp = nodes.get(j)
.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
.ietf.network.topology.rev180226.Node1.class)
.nonnullTerminationPoint().values().stream()
.filter(tp -> tp.getTpId().getValue().contains("CP") || tp.getTpId().getValue().contains("CTP"))
- .findFirst().get().getTpId().getValue();
+ .findFirst().orElseThrow().getTpId().getValue();
Link1Builder ocnAzLinkBldr = new Link1Builder();
Link1Builder ocnZaLinkBldr = new Link1Builder();
int srcNodeType = nodes.get(i).augmentation(org.opendaylight.yang.gen.v1.http
.ietf.network.topology.rev180226.Node1.class)
.getTerminationPoint().values().stream()
.filter(tp -> tp.getTpId().getValue().contains("CP") || tp.getTpId().getValue().contains("CTP"))
- .findFirst().get()
+ .findFirst().orElseThrow()
.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210
.TerminationPoint1.class)
.getOperationalState();
.ietf.network.topology.rev180226.Node1.class)
.getTerminationPoint().values().stream()
.filter(tp -> tp.getTpId().getValue().contains("CP") || tp.getTpId().getValue().contains("CTP"))
- .findFirst().get()
+ .findFirst().orElseThrow()
.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210
.TerminationPoint1.class)
.getOperationalState();
LOG.error("No link found for given LinkId: {}", linkId);
return false;
}
- LinkBuilder linkBuilder = new LinkBuilder(link.get());
+ LinkBuilder linkBuilder = new LinkBuilder(link.orElseThrow());
networkTransactionService.merge(
LogicalDatastoreType.CONFIGURATION,
linkIID.build(),
java.util.Optional<Link> link =
networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,linkIID.build()).get();
if (link.isPresent()) {
- LinkBuilder linkBuilder = new LinkBuilder(link.get());
+ LinkBuilder linkBuilder = new LinkBuilder(link.orElseThrow());
Link1Builder link1Builder = new Link1Builder(linkBuilder.augmentation(Link1.class));
linkBuilder.removeAugmentation(Link1.class);
linkBuilder.addAugmentation(link1Builder.build());
DataObjectConverter dataObjectConverter = JSONDataObjectConverter
.createWithDataStoreUtil(getDataStoreContextUtil());
try (Reader reader = new FileReader(PATH_DESCRIPTION_FILE, StandardCharsets.UTF_8)) {
- NormalizedNode normalizedNode = dataObjectConverter.transformIntoNormalizedNode(reader).get();
+ NormalizedNode normalizedNode = dataObjectConverter.transformIntoNormalizedNode(reader).orElseThrow();
pathDescription = (PathDescription) getDataStoreContextUtil()
.getBindingDOMCodecServices().fromNormalizedNode(YangInstanceIdentifier
.of(PathDescription.QNAME), normalizedNode).getValue();
.read(LogicalDatastoreType.CONFIGURATION, tpIID)
.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS);
if (optionalTerminationPoint.isPresent()) {
- return optionalTerminationPoint.get();
+ return optionalTerminationPoint.orElseThrow();
} else {
return null;
}
Optional<Node1> optionalNode = nodeReadTx.read(LogicalDatastoreType.CONFIGURATION, nodeIID)
.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS);
if (optionalNode.isPresent()) {
- return optionalNode.get();
+ return optionalNode.orElseThrow();
} else {
LOG.error("Unable to get network node for node id {}from topology {}", nodeId,
NetworkUtils.OVERLAY_NETWORK_ID);
tps.get(0).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
.getTpSupportedInterfaces().nonnullSupportedInterfaceCapability().values().stream().findFirst()
- .get().getIfCapType());
+ .orElseThrow().getIfCapType());
assertEquals(OpenroadmTpType.XPONDERCLIENT,tps.get(0).augmentation(TerminationPoint1.class).getTpType(),
"first TP must be of type client");
//tests network tp
IfOCH.VALUE,
tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst().get()
- .getIfCapType());
+ .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst()
+ .orElseThrow().getIfCapType());
assertNull(
tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
topoShard.getTps().get(0).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(),
+ .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
+ .getTpnPool(),
"after ODU4 creation, its termination point should contain a TpnPool list");
assertEquals(
80,
topoShard.getTps().get(0).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool()
- .size(),
+ .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
+ .getTpnPool().size(),
"Tpn pool list should be full, with 80 trib ports");
}
topoShard.getTps().get(0).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool()
- .size(),
+ .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
+ .getTpnPool().size(),
"after 10G creation, 1 (over 80) trib port should be occupied");
assertThat(
"trib port 1 should no longer be present",
topoShard.getTps().get(0).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(),
+ .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
+ .getTpnPool(),
not(hasItem(Uint16.valueOf(1))));
// tests update for 10G deletion
topoShard.getTps().get(0).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get()
+ .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
.getTpnPool().size(),
"after 10G deletion, trib port list should be full");
assertThat(
topoShard.getTps().get(0).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(),
+ .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
+ .getTpnPool(),
hasItem(Uint16.valueOf(1)));
}
topoShard.getTps().get(0).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool()
- .size(),
+ .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
+ .getTpnPool().size(),
"after 1G creation, 1 (over 80) trib port should be occupied");
assertThat(
"trib port 1 should no longer be present in Trib port list",
topoShard.getTps().get(0).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(),
+ .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
+ .getTpnPool(),
not(hasItem(Uint16.valueOf(1))));
// tests update for 1G deletion
topoShard.getTps().get(0).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool()
- .size(),
+ .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
+ .getTpnPool().size(),
"after 1G deletion, trib port list should be full");
assertThat(
"after 1G deletion, trib port list should contain items 1",
topoShard.getTps().get(0).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(),
+ .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().orElseThrow()
+ .getTpnPool(),
hasItem(Uint16.valueOf(1)));
}
tpList.get(4).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst().get()
- .getIfCapType(),
+ .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst()
+ .orElseThrow().getIfCapType(),
"only IfOCHOTU4ODU4 interface capabitily expected");
assertEquals(
ODU4.VALUE,
"the rate should be ODU4");
assertEquals(
"openroadm-topology",
- tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().get().getNetworkRef()
+ tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().orElseThrow().getNetworkRef()
.getValue());
assertEquals(
"SPDR-SA1-XPDR" + xpdrNb,
- tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().get().getNodeRef().getValue());
+ tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().orElseThrow().getNodeRef()
+ .getValue());
assertEquals(
"XPDR" + xpdrNb + "-NETWORK1",
- tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().get().getTpRef().getValue());
+ tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().orElseThrow().getTpRef()
+ .getValue());
if (xpdrNb.equals(Uint16.valueOf(1))) {
assertEquals(5, tpList.size(), "should contain 5 TPs");
assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue());
tpList.get(5).augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
.TerminationPoint1.class)
- .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst().get()
- .getIfCapType(),
+ .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst()
+ .orElseThrow().getIfCapType(),
"only IfOCHOTU4ODU4 interface capabitily expected");
assertEquals(
2,
InstanceIdentifier<Network> nwIID = InstanceIdentifier.create(Networks.class)
.child(Network.class, new NetworkKey(new NetworkId("clli-network")));
Network createdClli = getDataBroker().newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().get();
+ .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().orElseThrow();
assertNotNull(createdClli, "Clli layer should be created and not null");
Augmentation<NetworkTypes> ordClli = new NetworkTypes1Builder()
InstanceIdentifier<Network> nwIID = InstanceIdentifier.create(Networks.class)
.child(Network.class, new NetworkKey(new NetworkId("openroadm-network")));
Network createdOrdNetwork = getDataBroker().newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().get();
+ .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().orElseThrow();
assertNotNull(createdOrdNetwork, "openroadm-network layer should be created and not null");
commonNetworkAugmentationTest(createdOrdNetwork);
}
InstanceIdentifier<Network> nwIID = InstanceIdentifier.create(Networks.class)
.child(Network.class, new NetworkKey(new NetworkId("openroadm-topology")));
Network createdOrdNetwork = getDataBroker().newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().get();
+ .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().orElseThrow();
assertNotNull(createdOrdNetwork, "openroadm-logpology layer should be created and not null");
commonNetworkAugmentationTest(createdOrdNetwork);
}
InstanceIdentifier<Network> nwIID = InstanceIdentifier.create(Networks.class)
.child(Network.class, new NetworkKey(new NetworkId("otn-topology")));
Network createdOrdNetwork = getDataBroker().newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().get();
+ .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().orElseThrow();
assertNotNull(createdOrdNetwork, "otn-logpology layer should be created and not null");
commonNetworkAugmentationTest(createdOrdNetwork);
}
InstanceIdentifier<Network> nwIID = InstanceIdentifier.create(Networks.class)
.child(Network.class, new NetworkKey(new NetworkId("toto")));
Network createdOrdNetwork = getDataBroker().newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().get();
+ .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().orElseThrow();
assertNotNull(createdOrdNetwork, "toto layer should be created and not null");
assertNull(createdOrdNetwork.getNetworkTypes().augmentation(NetworkTypes1.class),
"toto layer should not have any network-type augmentation");
}
// TODO can it be return false rather than continue?
// in that case, mappingObjectOptional could be moved inside method getSpanLossTx()
- LOG.info("Dest point is Degree {}", mappingObjectOptional.get());
- BigDecimal spanLossTx = getSpanLossTx(mappingObjectOptional.get().getSupportingOts(),
+ LOG.info("Dest point is Degree {}", mappingObjectOptional.orElseThrow());
+ BigDecimal spanLossTx = getSpanLossTx(mappingObjectOptional.orElseThrow().getSupportingOts(),
destTpId, nodeId, openroadmVersion.getIntValue());
LOG.info("Spanloss TX is {}", spanLossTx);
// TODO Align protections with getSRGRxPowerRangeMap
}
- String circuitPackName = mappingObject.get().getSupportingCircuitPackName();
- String portName = mappingObject.get().getSupportingPort();
+ String circuitPackName = mappingObject.orElseThrow().getSupportingCircuitPackName();
+ String portName = mappingObject.orElseThrow().getSupportingPort();
switch (openroadmVersion) {
case 1:
return PowerMgmtVersion121.getXponderPowerRange(circuitPackName, portName,
// FIXME shouldn't it lead to a return false in setPower() ?
}
- String circuitPackName = mappingObject.get().getSupportingCircuitPackName();
- String portName = mappingObject.get().getSupportingPort();
+ String circuitPackName = mappingObject.orElseThrow().getSupportingCircuitPackName();
+ String portName = mappingObject.orElseThrow().getSupportingPort();
switch (rdmOpenroadmVersion) {
case 1:
return PowerMgmtVersion121.getSRGRxPowerRange(nodeId, srgId,
LOG.error(INTERFACE_NOT_PRESENT, supportingOts, nodeId);
return null;
}
- if (interfaceOpt.get().augmentation(Interface1.class).getOts()
+ if (interfaceOpt.orElseThrow().augmentation(Interface1.class).getOts()
.getSpanLossTransmit() == null) {
- LOG.error("interface {} has no spanloss value", interfaceOpt.get().getName());
+ LOG.error("interface {} has no spanloss value", interfaceOpt.orElseThrow().getName());
return null;
}
- return interfaceOpt.get()
+ return interfaceOpt.orElseThrow()
.augmentation(Interface1.class)
.getOts().getSpanLossTransmit().getValue().decimalValue();
case 2:
LOG.error(INTERFACE_NOT_PRESENT, supportingOts, nodeId);
return null;
}
- if (interfaceOpt1.get().augmentation(org.opendaylight.yang.gen.v1.http.org
+ if (interfaceOpt1.orElseThrow().augmentation(org.opendaylight.yang.gen.v1.http.org
.openroadm.optical.transport.interfaces.rev181019.Interface1.class).getOts()
.getSpanLossTransmit() == null) {
- LOG.error("interface {} has no spanloss value", interfaceOpt1.get().getName());
+ LOG.error("interface {} has no spanloss value", interfaceOpt1.orElseThrow().getName());
return null;
}
- return interfaceOpt1.get()
+ return interfaceOpt1.orElseThrow()
.augmentation(org.opendaylight.yang.gen.v1.http.org
.openroadm.optical.transport.interfaces.rev181019.Interface1.class)
.getOts().getSpanLossTransmit().getValue().decimalValue();
return false;
}
powerSetupResult = PowerMgmtVersion121.setTransponderPower(nodeId, interfaceName,
- txPower, deviceTransactionManager, interfaceOptional121.get());
+ txPower, deviceTransactionManager, interfaceOptional121.orElseThrow());
break;
case 2:
Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp
return false;
}
powerSetupResult = PowerMgmtVersion221.setTransponderPower(nodeId, interfaceName,
- txPower, deviceTransactionManager, interfaceOptional221.get());
+ txPower, deviceTransactionManager, interfaceOptional221.orElseThrow());
break;
case 3:
Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp
return false;
}
powerSetupResult = PowerMgmtVersion710.setTransponderPower(nodeId, interfaceName,
- txPower, deviceTransactionManager, interfaceOptional710.get());
+ txPower, deviceTransactionManager, interfaceOptional710.orElseThrow());
break;
default:
LOG.error("Unrecognized OpenRoadm version");
deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, portIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (portObject.isPresent()) {
- Ports port = portObject.get();
+ Ports port = portObject.orElseThrow();
if (port.getTransponderPort().getPortPowerCapabilityMaxTx() != null) {
powerRangeMap.put("MaxTx", port.getTransponderPort().getPortPowerCapabilityMaxTx().getValue()
.doubleValue());
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, portIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (portObject.isPresent()) {
- Ports port = portObject.get();
+ Ports port = portObject.orElseThrow();
if (port.getRoadmPort() != null) {
LOG.debug("Port found on the node ID");
powerRangeMap.put("MinRx", port.getRoadmPort()
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Transaction for device {} was not found during transponder"
+ " power setup for Node:", nodeId);
@SuppressWarnings("unchecked") Optional<RoadmConnections> rdmConnOpt =
(Optional<RoadmConnections>) crossConnect.getCrossConnect(deviceId, connectionNumber);
if (rdmConnOpt.isPresent()) {
- RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.get());
+ RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.orElseThrow());
rdmConnBldr.setOpticalControlMode(mode);
if (powerValue != null) {
rdmConnBldr.setTargetOutputPower(new PowerDBm(Decimal64.valueOf(powerValue)));
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Transaction for device {} was not found!", deviceId);
return false;
deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, portIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (portObject.isPresent()) {
- Ports port = portObject.get();
+ Ports port = portObject.orElseThrow();
if (port.getTransponderPort() != null && port.getTransponderPort().getPortPowerCapabilityMaxTx() != null) {
powerRangeMap.put("MaxTx", port.getTransponderPort().getPortPowerCapabilityMaxTx().getValue()
.doubleValue());
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, portIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (portObject.isPresent()) {
- Ports port = portObject.get();
+ Ports port = portObject.orElseThrow();
if (port.getRoadmPort() != null) {
LOG.debug("Port found on the node ID");
powerRangeMap.put("MinRx", port.getRoadmPort()
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Transaction for device {} was not found during transponder"
+ " power setup for Node:", nodeId);
@SuppressWarnings("unchecked") Optional<RoadmConnections> rdmConnOpt =
(Optional<RoadmConnections>) crossConnect.getCrossConnect(deviceId, connectionNumber);
if (rdmConnOpt.isPresent()) {
- RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.get());
+ RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.orElseThrow());
rdmConnBldr.setOpticalControlMode(mode);
if (powerValue != null) {
rdmConnBldr.setTargetOutputPower(new PowerDBm(Decimal64.valueOf(powerValue)));
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Transaction for device {} was not found!", deviceId);
return false;
if (!portObject.isPresent()) {
return new HashMap<>();
}
- Ports port = portObject.get();
+ Ports port = portObject.orElseThrow();
if (port.getTransponderPort() == null || port.getTransponderPort().getPortPowerCapabilityMaxTx() == null) {
LOG.warn("Logical Connection Point value missing for {} {}", circuitPackName, port.getPortName());
return new HashMap<>();
LOG.info("Port not found");
return new HashMap<>();
}
- Ports port = portObject.get();
+ Ports port = portObject.orElseThrow();
if (port.getRoadmPort() == null) {
LOG.warn("Roadm ports power value is missing for {} {}", circuitPackName, port.getPortName());
return new HashMap<>();
try {
Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
if (deviceTxOpt.isPresent()) {
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} else {
LOG.error("Transaction for device {} was not found during transponder power setup for Node:", nodeId);
return false;
LOG.warn("Roadm-Connection is null in set power level ({})", connectionNumber);
return false;
}
- RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.get());
+ RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.orElseThrow());
rdmConnBldr.setOpticalControlMode(mode);
if (powerValue != null) {
rdmConnBldr.setTargetOutputPower(new PowerDBm(Decimal64.valueOf(powerValue)));
LOG.error("Transaction for device {} was not found!", deviceId);
return false;
}
- deviceTx = deviceTxOpt.get();
+ deviceTx = deviceTxOpt.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Unable to get transaction for device {}!", deviceId, e);
return false;
return Collections.emptyList();
}
- @Nullable Map<LinkKey, Link> networkLinks = networkOptional.get().getLink();
+ @Nullable Map<LinkKey, Link> networkLinks = networkOptional.orElseThrow().getLink();
if ((networkLinks == null) || networkLinks.isEmpty()) {
LOG.warn("Links are not present in {} topology.", NetworkUtils.OVERLAY_NETWORK_ID);
return Collections.emptyList();
Optional<Interface> interfaceObject;
interfaceObject = openRoadmInterfaces.getInterface(realNodeId, interfaceName);
if (interfaceObject.isPresent()) {
- InterfaceBuilder interfaceBuilder = new InterfaceBuilder(interfaceObject.get());
+ InterfaceBuilder interfaceBuilder = new InterfaceBuilder(interfaceObject.orElseThrow());
OtsBuilder otsBuilder = new OtsBuilder();
- Interface intf = interfaceObject.get();
+ Interface intf = interfaceObject.orElseThrow();
if (intf.augmentation(Interface1.class) != null
&& intf.augmentation(Interface1.class).getOts() != null) {
Ots ots = intf.augmentation(Interface1.class).getOts();
org.opendaylight.yang.gen.v1.http.org.openroadm.device
.rev181019.interfaces.grp.InterfaceBuilder interfaceBuilder =
new org.opendaylight.yang.gen.v1.http.org.openroadm.device
- .rev181019.interfaces.grp.InterfaceBuilder(interfaceObject.get());
+ .rev181019.interfaces.grp.InterfaceBuilder(interfaceObject.orElseThrow());
org.opendaylight.yang.gen.v1.http.org.openroadm.optical
.transport.interfaces.rev181019.ots.container.OtsBuilder otsBuilder =
new org.opendaylight.yang.gen.v1.http.org.openroadm
.optical.transport.interfaces.rev181019.ots.container.OtsBuilder();
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.Interface intf =
- interfaceObject.get();
+ interfaceObject.orElseThrow();
if (intf.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.optical
.transport.interfaces.rev181019.Interface1.class) != null
&& intf.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport
LOG.error("Error on getRealNodeId {} :", mappedNodeId, e);
throw new IllegalStateException(e);
}
- if (!realNode.isPresent() || (realNode.get().getSupportingNode() == null)) {
+ if (!realNode.isPresent() || (realNode.orElseThrow().getSupportingNode() == null)) {
LOG.error("supporting node is null");
throw new IllegalArgumentException(
String.format("Could not find node %s, or supporting node is not present", mappedNodeId));
}
- List<SupportingNode> collect = realNode.get().nonnullSupportingNode().values().stream()
+ List<SupportingNode> collect = realNode.orElseThrow().nonnullSupportingNode().values().stream()
.filter(node -> (node.getNetworkRef() != null)
&& NetworkUtils.UNDERLAY_NETWORK_ID.equals(node.getNetworkRef().getValue())
&& (node.getNodeRef() != null) && !Strings.isNullOrEmpty(node.getNodeRef().getValue()))
//TODO change to constant from Timeouts class when it will be merged.
linkOptional = rtx.read(LogicalDatastoreType.CONFIGURATION, linkIID).get(Timeouts.DATASTORE_READ,
TimeUnit.MILLISECONDS);
- return linkOptional.get();
+ return linkOptional.orElseThrow();
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.warn("Read of {} topology failed", NetworkUtils.OVERLAY_NETWORK_ID);
return null;
//PmNamesEnum pmName = null;
List<org.opendaylight.yang.gen.v1.http
.org.opendaylight.transportpce.olm.rev210618.get.pm.output.Measurements> measurements =
- extractWantedMeasurements(currentPmList.get(),
+ extractWantedMeasurements(currentPmList.orElseThrow(),
ResourceTypeEnum.forValue(input.getResourceType().getIntValue()),
input.getResourceIdentifier(),
PmGranularity.forValue(input.getGranularity().getIntValue()),
LogicalDatastoreType.OPERATIONAL, iidCurrentPmList, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (currentPmListOpt.isPresent()) {
- CurrentPmList currentPmList = currentPmListOpt.get();
+ CurrentPmList currentPmList = currentPmListOpt.orElseThrow();
@NonNull
Map<CurrentPmEntryKey,CurrentPmEntry> currentPmEntryList = currentPmList.nonnullCurrentPmEntry();
LOG.info("Current PM list exists for node {} and contains {} entries.", input.getNodeId(),
LogicalDatastoreType.OPERATIONAL, iidCurrentPmList, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (currentPmListOpt.isPresent()) {
- CurrentPmList currentPmList = currentPmListOpt.get();
+ CurrentPmList currentPmList = currentPmListOpt.orElseThrow();
@NonNull
Map<CurrentPmEntryKey, CurrentPmEntry> currentPmEntryList = currentPmList.nonnullCurrentPmEntry();
LOG.info("Current PM list exists for node {} and contains {} entries.", input.getNodeId(),
result.getGranularity());
assertEquals(
PmNamesEnum.OpticalPowerInput.toString(),
- result.getMeasurements().stream().findFirst().get().getPmparameterName());
+ result.getMeasurements().stream().findFirst().orElseThrow().getPmparameterName());
assertEquals(
String.valueOf(3.0),
- result.getMeasurements().stream().findFirst().get().getPmparameterValue());
+ result.getMeasurements().stream().findFirst().orElseThrow().getPmparameterValue());
assertEquals(
"ots-deg1",
result.getResourceIdentifier().getResourceName());
ServiceApplicability serviceApplicability = serviceIdentifier.getServiceApplicability();
Optional<PathDescription> serviceOpt = getPathDescriptionFromDatastore(serviceId);
if (serviceOpt.isPresent()) {
- List<String> serviceNodes = getAToZNodeList(serviceOpt.get());
+ List<String> serviceNodes = getAToZNodeList(serviceOpt.orElseThrow());
if (serviceApplicability.getNode() && !serviceNodes.isEmpty()) {
constraints.setExcludeNodes(serviceNodes);
}
- List<String> serviceLinks = getSRLGList(serviceOpt.get());
+ List<String> serviceLinks = getSRLGList(serviceOpt.orElseThrow());
if (serviceApplicability.getLink() && !serviceLinks.isEmpty()) {
constraints.setExcludeSrlgLinks(serviceLinks);
}
LOG.info("PCE diversity constraints: Getting path description for service {}", serviceName);
ServicePaths servicePaths =
networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, pathDescriptionIID)
- .get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).get();
+ .get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).orElseThrow();
if (servicePaths != null) {
PathDescription path = servicePaths.getPathDescription();
if (path != null) {
throw new GnpyException("In gnpyTopoImpl: openRoadmNet or openRoadmTopo is not present");
}
// Create the list of nodes
- Collection<Node> openRoadmNetNodeList = openRoadmNet.get().nonnullNode().values();
- Collection<Node> openRoadmTopoNodeList = openRoadmTopo.get().nonnullNode().values();
+ Collection<Node> openRoadmNetNodeList = openRoadmNet.orElseThrow().nonnullNode().values();
+ Collection<Node> openRoadmTopoNodeList = openRoadmTopo.orElseThrow().nonnullNode().values();
if (openRoadmTopoNodeList.isEmpty() || openRoadmNetNodeList.isEmpty()) {
throw new GnpyException("In gnpyTopoImpl: no nodes in the openradm topology or openroadm network");
if (!openRoadmTopo.isPresent()) {
throw new GnpyException("In gnpyTopoImpl: openroadmTopo is not present");
}
- Network1 nw1 = openRoadmTopo.get().augmentation(Network1.class);
+ Network1 nw1 = openRoadmTopo.orElseThrow().augmentation(Network1.class);
Collection<Link> linksList = nw1.nonnullLink().values();
// 1:EXPRESS-LINK 2:ADD-LINK 3:DROP-LINK
// 4:ROADM-To-ROADM 5:XPONDER-INPUT 6:XPONDER-OUTPUT
if (commonEdgeTpnPool.isEmpty()) {
continue;
}
- Integer startTribSlot = tribSlotMap.values().stream().findFirst().get().get(0).toJava();
+ Integer startTribSlot = tribSlotMap.values().stream().findFirst().orElseThrow().get(0).toJava();
Integer tribPort = (int) Math.ceil((double)startTribSlot / nbSlot);
for (Uint16 commonTribPort : commonEdgeTpnPool) {
if (tribPort.equals(commonTribPort.toJava())) {
currentNode.getXponderOperationalMode(
networkTransactionService
.read(LogicalDatastoreType.CONFIGURATION, nwTpIid)
- .get().get().getXpdrNetworkAttributes()),
+ .get().orElseThrow().getXpdrNetworkAttributes()),
// Operational mode is found as an attribute of the network TP
opMode);
// Operational mode is retrieved from the service Type assuming it is supported
Optional<Network> nwOptional =
networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, nwInstanceIdentifier).get();
if (nwOptional.isPresent()) {
- nw = nwOptional.get();
+ nw = nwOptional.orElseThrow();
LOG.debug("readMdSal: network nodes: nwOptional.isPresent = true {}", nw);
}
} catch (InterruptedException | ExecutionException e) {
return null;
}
LOG.debug("getRdmSrgClient: client PP {} for CP {} found !", client, tp);
- return client.get();
+ return client.orElseThrow();
}
@Override
}
List<NonBlockingList> nblList = new ArrayList<>(
node1.getSwitchingPools().nonnullOduSwitchingPools()
- .values().stream().findFirst().get()
+ .values().stream().findFirst().orElseThrow()
.getNonBlockingList().values());
netwTps.sort(Comparator.comparing(TpId::getValue));
|| portConAttr.getOdtuTpnPool() == null) {
return false;
}
- return checkFirstOdtuTpn(portConAttr.getOdtuTpnPool().values().stream().findFirst().get());
+ return checkFirstOdtuTpn(portConAttr.getOdtuTpnPool().values().stream().findFirst().orElseThrow());
}
private boolean checkFirstOdtuTpn(OdtuTpnPool otPool) {
XpdrTpPortConnectionAttributes portConAttr =
tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes();
if (portConAttr != null && portConAttr.getOdtuTpnPool() != null) {
- OdtuTpnPool otPool = portConAttr.getOdtuTpnPool().values().stream().findFirst().get();
+ OdtuTpnPool otPool = portConAttr.getOdtuTpnPool().values().stream().findFirst().orElseThrow();
if (checkFirstOdtuTpn(otPool)) {
tpAvailableTribPort.put(tp.getTpId().getValue(), new ArrayList<>(otPool.getTpnPool()));
}
try (Reader reader = new FileReader(CATALOG_FILE, StandardCharsets.UTF_8)) {
NormalizedNode normalizedNode = dataObjectConverter
.transformIntoNormalizedNode(reader)
- .get();
+ .orElseThrow();
omCatalog = (OperationalModeCatalog) getDataStoreContextUtil()
.getBindingDOMCodecServices()
.fromNormalizedNode(
}
// The mapping corresponding to the topology is directly populated from a file in the Dta Store
try (Reader reader = new FileReader(MAPPING_FILE, StandardCharsets.UTF_8)) {
- NormalizedNode normalizedNode = dataObjectConverter.transformIntoNormalizedNode(reader).get();
+ NormalizedNode normalizedNode = dataObjectConverter.transformIntoNormalizedNode(reader).orElseThrow();
networkNode = (org.opendaylight.yang.gen.v1.http.org.opendaylight
.transportpce.portmapping.rev220922.Network) getDataStoreContextUtil()
.getBindingDOMCodecServices()
Optional<NormalizedNode> normalizedNode
= dataObjectConverter.transformIntoNormalizedNode(resourceAsStream);
DataContainerChild next
- = ((ContainerNode) normalizedNode.get()).body().iterator().next();
+ = ((ContainerNode) normalizedNode.orElseThrow()).body().iterator().next();
MapEntryNode mapNode = ((MapNode) next).body().iterator().next();
Optional<DataObject> dataObject = dataObjectConverter.getDataObject(mapNode, Network.QNAME);
InstanceIdentifier<Network> nwInstanceIdentifier = InstanceIdentifier.builder(Networks.class)
.child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
.build();
WriteTransaction dataWriteTransaction = dataBroker.newWriteOnlyTransaction();
- dataWriteTransaction.put(LogicalDatastoreType.CONFIGURATION, nwInstanceIdentifier, (Network) dataObject.get());
+ dataWriteTransaction.put(LogicalDatastoreType.CONFIGURATION, nwInstanceIdentifier,
+ (Network) dataObject.orElseThrow());
dataWriteTransaction.commit().get();
}
LOG.info("xd {} not found !", xc);
return false;
}
- RoadmConnections rc = crossconnection.get();
+ RoadmConnections rc = crossconnection.orElseThrow();
LOG.info("xd {} found", xc);
if (rc.getSource().getSrcIf().equals(interfaceName)
|| rc.getDestination().getDstIf().equals(interfaceName)) {
LOG.info("xd {} not found !", xc);
return false;
}
- RoadmConnections rc = crossconnection.get();
+ RoadmConnections rc = crossconnection.orElseThrow();
LOG.info("xd {} found", xc);
String supportedinter =
interfaceName.contains("nmc")
LOG.info("xc {} not found !", xc);
return false;
}
- OduConnection oduXc = oduConnectionOpt.get();
+ OduConnection oduXc = oduConnectionOpt.orElseThrow();
LOG.info("xc {} found", xc);
if (oduXc.getSource().getSrcIf().equals(interfaceName)
|| oduXc.getDestination().getDstIf().equals(interfaceName)) {
this.crossConnect.postCrossConnect(nodeId, srcTp, destTp, spectrumInformation);
if (connectionNameOpt.isPresent()) {
nodesProvisioned.add(nodeId);
- createdConnections.add(connectionNameOpt.get());
+ createdConnections.add(connectionNameOpt.orElseThrow());
} else {
processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
results);
}
if (services.isPresent()) {
LOG.info("service {} already exists", name);
- servicesBuilder = new ServicesBuilder(services.get()).setTopology(topo);
+ servicesBuilder = new ServicesBuilder(services.orElseThrow()).setTopology(topo);
WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, servicesBuilder.build());
writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
// Take the first and last value in the list of OpucnTribSlot (assuming SH would provide
// min and max value only, size two)
OpucnTribSlotDef minOpucnTs = input.getOpucnTribSlots().stream()
- .min((ts1, ts2) -> ts1.getValue().compareTo(ts2.getValue())).get();
+ .min((ts1, ts2) -> ts1.getValue().compareTo(ts2.getValue())).orElseThrow();
OpucnTribSlotDef maxOpucnTs = input.getOpucnTribSlots().stream()
- .max((ts1, ts2) -> ts1.getValue().compareTo(ts2.getValue())).get();
+ .max((ts1, ts2) -> ts1.getValue().compareTo(ts2.getValue())).orElseThrow();
if (node.getClientTp() != null) {
createdEthInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmEth100GInterface(
node.getNodeId(), node.getClientTp()));
Set<String> createdConnections = new HashSet<>();
if (!createdOduInterfaces.isEmpty()) {
Optional<String> connectionNameOpt = postCrossConnect(new ArrayList<>(createdOduInterfaces), node);
- createdConnections.add(connectionNameOpt.get());
+ createdConnections.add(connectionNameOpt.orElseThrow());
LOG.info("Created cross connects");
}
nodeInterfaces.add(new NodeInterfaceBuilder()
Set<String> createdConnections = new HashSet<>();
if (createdOduInterfaces.size() == 2) {
Optional<String> connectionNameOpt = postCrossConnect(new ArrayList<>(createdOduInterfaces), node);
- createdConnections.add(connectionNameOpt.get());
+ createdConnections.add(connectionNameOpt.orElseThrow());
LOG.info("Created cross connects");
}
nodeInterfaces.add(new NodeInterfaceBuilder()
return ModelMappingUtils
.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
}
- PathDescription pathDescription = pathDescriptionOpt.get();
+ PathDescription pathDescription = pathDescriptionOpt.orElseThrow();
String serviceType =
ServiceTypes.getServiceType(
service.getServiceAEnd().getServiceFormat().getName(),
service.getServiceAEnd().getServiceRate(),
service.getServiceAEnd().getTxDirection() == null
- || service.getServiceAEnd().getTxDirection().values().stream().findFirst().get()
+ || service.getServiceAEnd().getTxDirection().values().stream().findFirst().orElseThrow()
.getPort() == null
- || service.getServiceAEnd().getTxDirection().values().stream().findFirst().get()
+ || service.getServiceAEnd().getTxDirection().values().stream().findFirst().orElseThrow()
.getPort().getPortName() == null
? null
: portMapping.getMapping(
service.getServiceAEnd().getNodeId().getValue(),
- service.getServiceAEnd().getTxDirection().values().stream().findFirst().get()
- .getPort().getPortName()));
+ service.getServiceAEnd().getTxDirection().values().stream().findFirst()
+ .orElseThrow().getPort().getPortName()));
switch (serviceType) {
case StringConstants.SERVICE_TYPE_100GE_T:
case StringConstants.SERVICE_TYPE_400GE:
if (!deviceTxFuture.get().isPresent()) {
return false;
}
- DeviceTransaction deviceTx = deviceTxFuture.get().get();
+ DeviceTransaction deviceTx = deviceTxFuture.get().orElseThrow();
deviceTx.merge(logicalDatastoreType, instanceIdentifier, object);
deviceTx.commit(Timeouts.DEVICE_WRITE_TIMEOUT, Timeouts.DEVICE_WRITE_TIMEOUT_UNIT).get();
return true;
throws ExecutionException, InterruptedException {
Future<Optional<DeviceTransaction>> deviceTxFuture =
deviceTransactionManager.getDeviceTransaction(nodeId);
- if (!deviceTxFuture.get().isPresent()) {
- return null;
- }
- DeviceTransaction deviceTx = deviceTxFuture.get().get();
+ DeviceTransaction deviceTx = deviceTxFuture.get().orElseThrow(null);
Optional<? extends DataObject> readOpt
= deviceTx.read(logicalDatastoreType, instanceIdentifier).get();
- if (!readOpt.isPresent()) {
- return null;
- }
- return readOpt.get();
+ return readOpt.orElseThrow(null);
}
}
new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118
.service.endpoint.sp.TxDirectionBuilder()
.setPort(
- input.getServiceAEnd().getTxDirection().values().stream().findFirst().get().getPort())
+ input.getServiceAEnd().getTxDirection().values().stream().findFirst().orElseThrow()
+ .getPort())
.build())
.setRxDirection(
new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118
.service.endpoint.sp.RxDirectionBuilder()
.setPort(
- input.getServiceAEnd().getRxDirection().values().stream().findFirst().get().getPort())
+ input.getServiceAEnd().getRxDirection().values().stream().findFirst().orElseThrow()
+ .getPort())
.build())
.build())
.setServiceZEnd(
new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118
.service.endpoint.sp.TxDirectionBuilder()
.setPort(
- input.getServiceZEnd().getTxDirection().values().stream().findFirst().get().getPort())
+ input.getServiceZEnd().getTxDirection().values().stream().findFirst().orElseThrow()
+ .getPort())
.build())
.setRxDirection(
new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118
.service.endpoint.sp.RxDirectionBuilder()
.setPort(
- input.getServiceZEnd().getRxDirection().values().stream().findFirst().get().getPort())
+ input.getServiceZEnd().getRxDirection().values().stream().findFirst().orElseThrow()
+ .getPort())
.build())
.build())
.setConnectionType(input.getConnectionType())
return new ServiceAEndBuilder()
.setClli(serviceAEnd.getClli())
.setNodeId(serviceAEnd.getNodeId().getValue())
- .setRxDirection(createRxDirection(serviceAEnd.getRxDirection().values().stream().findFirst().get()))
+ .setRxDirection(createRxDirection(serviceAEnd.getRxDirection().values().stream().findFirst().orElseThrow()))
.setServiceFormat(serviceAEnd.getServiceFormat())
.setServiceRate(serviceAEnd.getServiceRate())
- .setTxDirection(createTxDirection(serviceAEnd.getTxDirection().values().stream().findFirst().get()))
+ .setTxDirection(createTxDirection(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow()))
.build();
}
.path.computation.reroute.request.input.ServiceAEndBuilder()
.setClli(serviceAEnd.getClli())
.setNodeId(serviceAEnd.getNodeId().getValue())
- .setRxDirection(createRxDirection(serviceAEnd.getRxDirection().values().stream().findFirst().get()))
+ .setRxDirection(createRxDirection(serviceAEnd.getRxDirection().values().stream().findFirst()
+ .orElseThrow()))
.setServiceFormat(serviceAEnd.getServiceFormat())
.setServiceRate(serviceAEnd.getServiceRate())
- .setTxDirection(createTxDirection(serviceAEnd.getTxDirection().values().stream().findFirst().get()))
+ .setTxDirection(createTxDirection(serviceAEnd.getTxDirection().values().stream().findFirst()
+ .orElseThrow()))
.build();
}
return new ServiceZEndBuilder()
.setClli(serviceZEnd.getClli())
.setNodeId(serviceZEnd.getNodeId().getValue())
- .setRxDirection(createRxDirection(serviceZEnd.getRxDirection().values().stream().findFirst().get()))
+ .setRxDirection(createRxDirection(serviceZEnd.getRxDirection().values().stream().findFirst().orElseThrow()))
.setServiceFormat(serviceZEnd.getServiceFormat())
.setServiceRate(serviceZEnd.getServiceRate())
- .setTxDirection(createTxDirection(serviceZEnd.getTxDirection().values().stream().findFirst().get()))
+ .setTxDirection(createTxDirection(serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow()))
.build();
}
.path.computation.reroute.request.input.ServiceZEndBuilder()
.setClli(serviceZEnd.getClli())
.setNodeId(serviceZEnd.getNodeId().getValue())
- .setRxDirection(createRxDirection(serviceZEnd.getRxDirection().values().stream().findFirst().get()))
+ .setRxDirection(createRxDirection(serviceZEnd.getRxDirection().values().stream().findFirst()
+ .orElseThrow()))
.setServiceFormat(serviceZEnd.getServiceFormat())
.setServiceRate(serviceZEnd.getServiceRate())
- .setTxDirection(createTxDirection(serviceZEnd.getTxDirection().values().stream().findFirst().get()))
+ .setTxDirection(createTxDirection(serviceZEnd.getTxDirection().values().stream().findFirst()
+ .orElseThrow()))
.build();
}
.service.endpoint.sp.TxDirectionBuilder()
.setPort(
serviceInput.getServiceAEnd().getTxDirection()
- .values().stream().findFirst().get().getPort())
+ .values().stream().findFirst().orElseThrow().getPort())
.build())
.setRxDirection(
new org.opendaylight.yang.gen.v1
.service.endpoint.sp.RxDirectionBuilder()
.setPort(
serviceInput.getServiceAEnd().getRxDirection()
- .values().stream().findFirst().get().getPort())
+ .values().stream().findFirst().orElseThrow().getPort())
.build())
.build())
.setServiceZEnd(
.service.endpoint.sp.TxDirectionBuilder()
.setPort(
serviceInput.getServiceZEnd().getTxDirection()
- .values().stream().findFirst().get().getPort())
+ .values().stream().findFirst().orElseThrow().getPort())
.build())
.setRxDirection(
new org.opendaylight.yang.gen.v1
.service.endpoint.sp.RxDirectionBuilder()
.setPort(
serviceInput.getServiceZEnd().getRxDirection()
- .values().stream().findFirst().get().getPort())
+ .values().stream().findFirst().orElseThrow().getPort())
.build())
.build())
.setServicePathName(serviceInput.getServiceName())
input, ResponseCodes.FINAL_ACK_YES,
LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
}
- service = serviceOpt.get();
+ service = serviceOpt.orElseThrow();
LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
this.pceListenerImpl.setInput(new ServiceInput(input));
this.pceListenerImpl.setServiceReconfigure(false);
LogMessages.serviceNotInDS(serviceName));
}
- Services service = servicesObject.get();
+ Services service = servicesObject.orElseThrow();
State state = service.getOperationalState();
if (state == State.InService) {
LogMessages.serviceNotInDS(serviceName),
ResponseCodes.RESPONSE_FAILED);
}
- Services service = servicesObject.get();
+ Services service = servicesObject.orElseThrow();
Optional<ServicePaths> servicePathsObject = this.serviceDataStoreOperations.getServicePath(serviceName);
if (servicePathsObject.isEmpty()) {
LOG.warn("serviceReroute: {}", LogMessages.servicePathNotInDS(serviceName));
LogMessages.servicePathNotInDS(serviceName),
ResponseCodes.RESPONSE_FAILED);
}
- ServicePaths servicePaths = servicePathsObject.get();
+ ServicePaths servicePaths = servicePathsObject.orElseThrow();
// serviceInput for later use maybe...
ServiceInput serviceInput = new ServiceInput(input);
serviceInput.setServiceAEnd(service.getServiceAEnd());
LOG.warn("Enable to retrieve service path list");
return;
}
- ServicePathList servicePathList = servicePathListOptional.get();
+ ServicePathList servicePathList = servicePathListOptional.orElseThrow();
for (ServicePaths servicePaths : servicePathList.getServicePaths().values()) {
String serviceName = servicePaths.getServicePathName();
PathDescription pathDescription = servicePaths.getPathDescription();
LOG.error("Couldn't retrieve service");
continue;
}
- Services services = serviceOptional.get();
+ Services services = serviceOptional.orElseThrow();
State newState;
switch (services.getOperationalState()) {
case InService:
LOG.error("PCE cancel returned an unknown RpcStatusEx code !");
return;
}
- Services service = serviceDataStoreOperations.getService(input.getServiceName()).get();
+ Services service = serviceDataStoreOperations.getService(input.getServiceName()).orElseThrow();
PublishNotificationProcessServiceBuilder nbiNotificationBuilder =
new PublishNotificationProcessServiceBuilder()
.setServiceName(service.getServiceName())
break;
case Failed:
LOG.error("Renderer service delete failed !");
- Services service = serviceDataStoreOperations.getService(input.getServiceName()).get();
+ Services service = serviceDataStoreOperations.getService(input.getServiceName()).orElseThrow();
sendNbiNotification(new PublishNotificationProcessServiceBuilder()
.setServiceName(service.getServiceName())
.setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
*/
private void onFailedServiceImplementation(String serviceName) {
LOG.error("Renderer implementation failed !");
- Services service = serviceDataStoreOperations.getService(input.getServiceName()).get();
+ Services service = serviceDataStoreOperations.getService(input.getServiceName()).orElseThrow();
sendNbiNotification(new PublishNotificationProcessServiceBuilder()
.setServiceName(service.getServiceName())
.setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
LOG.warn("Service '{}' does not exist in datastore", serviceNameToReroute);
return;
}
- Services service = serviceOpt.get();
+ Services service = serviceOpt.orElseThrow();
ListenableFuture<RpcResult<ServiceDeleteOutput>> res = this.servicehandlerImpl.serviceDelete(
new ServiceDeleteInputBuilder()
.setSdncRequestHeader(new SdncRequestHeaderBuilder(service.getSdncRequestHeader())
WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class)
.child(Services.class, new ServicesKey(serviceName));
- Services services = new ServicesBuilder(readService.get())
+ Services services = new ServicesBuilder(readService.orElseThrow())
.setOperationalState(operationalState)
.setAdministrativeState(administrativeState)
.build();
.temp.service.list.ServicesKey(serviceName));
org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service.list.Services services =
new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service.list.ServicesBuilder(
- readService.get())
+ readService.orElseThrow())
.setOperationalState(operationalState)
.setAdministrativeState(administrativeState)
.build();
InstanceIdentifier<ServicePaths> iid = InstanceIdentifier.create(ServicePathList.class)
.child(ServicePaths.class, new ServicePathsKey(serviceName));
ServicePaths servicePaths = new ServicePathsBuilder()
- .setServiceAEnd(readServicePath.get().getServiceAEnd())
- .setServiceHandlerHeader(readServicePath.get().getServiceHandlerHeader())
- .setServicePathName(readServicePath.get().getServicePathName())
- .setServiceZEnd(readServicePath.get().getServiceZEnd())
- .setSupportingServiceName(readServicePath.get().getSupportingServiceName())
- .setEquipmentSrgs(readServicePath.get().getEquipmentSrgs())
- .setFiberSpanSrlgs(readServicePath.get().getFiberSpanSrlgs())
- .setHardConstraints(readServicePath.get().getHardConstraints())
- .setLatency(readServicePath.get().getLatency())
+ .setServiceAEnd(readServicePath.orElseThrow().getServiceAEnd())
+ .setServiceHandlerHeader(readServicePath.orElseThrow().getServiceHandlerHeader())
+ .setServicePathName(readServicePath.orElseThrow().getServicePathName())
+ .setServiceZEnd(readServicePath.orElseThrow().getServiceZEnd())
+ .setSupportingServiceName(readServicePath.orElseThrow().getSupportingServiceName())
+ .setEquipmentSrgs(readServicePath.orElseThrow().getEquipmentSrgs())
+ .setFiberSpanSrlgs(readServicePath.orElseThrow().getFiberSpanSrlgs())
+ .setHardConstraints(readServicePath.orElseThrow().getHardConstraints())
+ .setLatency(readServicePath.orElseThrow().getLatency())
.setPathDescription(pathDescription)
- .setPceRoutingMetric(readServicePath.get().getPceRoutingMetric())
- .setSoftConstraints(readServicePath.get().getSoftConstraints())
+ .setPceRoutingMetric(readServicePath.orElseThrow().getPceRoutingMetric())
+ .setSoftConstraints(readServicePath.orElseThrow().getSoftConstraints())
.build();
writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, servicePaths);
*/
InstanceIdentifier<Services> iid =
InstanceIdentifier.create(ServiceList.class).child(Services.class, new ServicesKey(serviceName));
- ServicesBuilder service = new ServicesBuilder(readService.get());
+ ServicesBuilder service = new ServicesBuilder(readService.orElseThrow());
String action = null;
switch (choice) {
case 0 : /* Modify. */
assertEquals(1, genSoftConstraints.getExclude().getLinkIdentifier().values().size(),
"generated soft constraints should contain exclude constraint with one link-id");
assertEquals("link-id 1",
- genSoftConstraints.getExclude().getLinkIdentifier().values().stream().findAny().get().getLinkId());
+ genSoftConstraints.getExclude().getLinkIdentifier().values().stream().findAny().orElseThrow().getLinkId());
assertEquals("openroadm-topology",
- genSoftConstraints.getExclude().getLinkIdentifier().values().stream().findAny().get().getLinkNetworkId());
+ genSoftConstraints.getExclude().getLinkIdentifier().values().stream().findAny().orElseThrow()
+ .getLinkNetworkId());
assertNotNull(genSoftConstraints.getInclude(), "generated soft constraints should contain include constraint");
assertEquals(2, genSoftConstraints.getInclude().getNodeId().size(),
"generated soft constraints should contain include constraint with two node-id");
Optional<Services> optService = this.serviceDataStoreOperations.getService(createInput.getServiceName());
assertTrue(optService.isPresent());
- assertEquals(createInput.getServiceName(), optService.get().getServiceName());
+ assertEquals(createInput.getServiceName(), optService.orElseThrow().getServiceName());
}
@Test
Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service.list
.Services> optService = this.serviceDataStoreOperations.getTempService(createInput.getCommonId());
assertTrue(optService.isPresent());
- assertEquals(createInput.getCommonId(), optService.get().getCommonId());
+ assertEquals(createInput.getCommonId(), optService.orElseThrow().getCommonId());
}
@Test
.setTxDirection(
new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118
.service.endpoint.sp.TxDirectionBuilder()
- .setPort(input.getServiceAEnd().getTxDirection().values().stream().findFirst().get().getPort())
+ .setPort(input.getServiceAEnd().getTxDirection().values().stream().findFirst().orElseThrow()
+ .getPort())
.build())
.setRxDirection(
new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118
.service.endpoint.sp.RxDirectionBuilder()
- .setPort(input.getServiceAEnd().getRxDirection().values().stream().findFirst().get().getPort())
+ .setPort(input.getServiceAEnd().getRxDirection().values().stream().findFirst().orElseThrow()
+ .getPort())
.build());
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
.service.implementation.request.input.ServiceZEndBuilder serviceZEnd =
.setTxDirection(
new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118
.service.endpoint.sp.TxDirectionBuilder()
- .setPort(input.getServiceZEnd().getTxDirection().values().stream().findFirst().get().getPort())
+ .setPort(input.getServiceZEnd().getTxDirection().values().stream().findFirst().orElseThrow()
+ .getPort())
.build())
.setRxDirection(
new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118
.service.endpoint.sp.RxDirectionBuilder()
- .setPort(input.getServiceZEnd().getRxDirection().values().stream().findFirst().get().getPort())
+ .setPort(input.getServiceZEnd().getRxDirection().values().stream().findFirst().orElseThrow()
+ .getPort())
.build());
return serviceImplementationRequestInputBuilder
.setServiceAEnd(serviceAEnd.build())
.setClli(serviceAEnd.getClli())
.setNodeId(new NodeIdType(serviceAEnd.getNodeId().getValue()).getValue())
.setRxDirection(
- createRxDirection(serviceAEnd.getRxDirection().values().stream().findFirst().get()))
+ createRxDirection(serviceAEnd.getRxDirection().values().stream().findFirst().orElseThrow()))
.setServiceFormat(serviceAEnd.getServiceFormat())
.setServiceRate(serviceAEnd.getServiceRate())
.setTxDirection(
- createTxDirection(serviceAEnd.getTxDirection().values().stream().findFirst().get()))
+ createTxDirection(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow()))
.build();
}
.setClli(serviceZEnd.getClli())
.setNodeId(new NodeIdType(serviceZEnd.getNodeId().getValue()).getValue())
.setRxDirection(
- createRxDirection(serviceZEnd.getRxDirection().values().stream().findFirst().get()))
+ createRxDirection(serviceZEnd.getRxDirection().values().stream().findFirst().orElseThrow()))
.setServiceFormat(serviceZEnd.getServiceFormat())
.setServiceRate(serviceZEnd.getServiceRate())
.setTxDirection(
- createTxDirection(serviceZEnd.getTxDirection().values().stream().findFirst().get()))
+ createTxDirection(serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow()))
.build();
}
.service.endpoint.sp.TxDirectionBuilder()
.setPort(
serviceInput.getServiceAEnd().getTxDirection()
- .values().stream().findFirst().get().getPort())
+ .values().stream().findFirst().orElseThrow().getPort())
.build())
.setRxDirection(
new org.opendaylight.yang.gen.v1
.service.endpoint.sp.RxDirectionBuilder()
.setPort(
serviceInput.getServiceAEnd().getRxDirection()
- .values().stream().findFirst().get().getPort())
+ .values().stream().findFirst().orElseThrow().getPort())
.build())
.build())
.setServiceZEnd(
.service.endpoint.sp.TxDirectionBuilder()
.setPort(
serviceInput.getServiceZEnd().getTxDirection()
- .values().stream().findFirst().get().getPort())
+ .values().stream().findFirst().orElseThrow().getPort())
.build())
.setRxDirection(
new org.opendaylight.yang.gen.v1
.service.endpoint.sp.RxDirectionBuilder()
.setPort(
serviceInput.getServiceZEnd().getRxDirection()
- .values().stream().findFirst().get().getPort())
+ .values().stream().findFirst().orElseThrow().getPort())
.build())
.build())
.setServicePathName(serviceInput.getServiceName())
return new HashMap<>();
}
// get neighbor list
- NbrList nbr121List = protocol121Object.get().augmentation(Protocols1.class).getLldp().getNbrList();
+ NbrList nbr121List = protocol121Object.orElseThrow().augmentation(Protocols1.class).getLldp()
+ .getNbrList();
LOG.info("LLDP subtree is present. Device has {} neighbours", nbr121List.getIfName().size());
// try to create rdm2rdm link
return rdm2rdmLinkCreatev121(nodeId, tapiTopoUuid, nbr121List);
LOG.warn("LLDP subtree is missing or incomplete: isolated openroadm device");
return new HashMap<>();
}
- var nbr221List = protocol221Object.get().augmentation(
+ var nbr221List = protocol221Object.orElseThrow().augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class)
.getLldp().getNbrList();
LOG.info("LLDP subtree is present. Device has {} neighbours", nbr221List.getIfName().size());
private boolean hasNoNeighbor121(Optional<Protocols> protocol121Object) {
return protocol121Object.isEmpty()
- || protocol121Object.get().augmentation(Protocols1.class) == null
- || protocol121Object.get().augmentation(Protocols1.class).getLldp() == null
- || protocol121Object.get().augmentation(Protocols1.class).getLldp().getNbrList() == null;
+ || protocol121Object.orElseThrow().augmentation(Protocols1.class) == null
+ || protocol121Object.orElseThrow().augmentation(Protocols1.class).getLldp() == null
+ || protocol121Object.orElseThrow().augmentation(Protocols1.class).getLldp().getNbrList() == null;
}
private boolean hasNoNeighbor221(Optional<
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org
.openroadm.device.Protocols> protocol221Object) {
return protocol221Object.isEmpty()
- || protocol221Object.get().augmentation(
+ || protocol221Object.orElseThrow().augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class) == null
- || protocol221Object.get().augmentation(
+ || protocol221Object.orElseThrow().augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class)
.getLldp() == null
- || protocol221Object.get().augmentation(
+ || protocol221Object.orElseThrow().augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class)
.getLldp().getNbrList() == null;
}
Optional<Nodes> nodesObject = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
nodesIID).get();
- if (nodesObject.isEmpty() || (nodesObject.get().getCpToDegree() == null)) {
+ if (nodesObject.isEmpty() || (nodesObject.orElseThrow().getCpToDegree() == null)) {
LOG.warn("Could not find mapping for Interface {} for nodeId {}", interfaceName,
nodeId.getValue());
return null;
}
- Collection<CpToDegree> cpToDeg = nodesObject.get().nonnullCpToDegree().values();
+ Collection<CpToDegree> cpToDeg = nodesObject.orElseThrow().nonnullCpToDegree().values();
Stream<CpToDegree> cpToDegStream = cpToDeg.stream().filter(cp -> cp.getInterfaceName() != null)
.filter(cp -> cp.getInterfaceName().equals(interfaceName));
if (cpToDegStream != null) {
LOG.debug("Not found so returning nothing");
return null;
}
- LOG.debug("Found and returning {}",firstCpToDegree.get().getDegreeNumber().intValue());
- return firstCpToDegree.get().getDegreeNumber().intValue();
+ LOG.debug("Found and returning {}",firstCpToDegree.orElseThrow().getDegreeNumber().intValue());
+ return firstCpToDegree.orElseThrow().getDegreeNumber().intValue();
} else {
LOG.warn("CircuitPack stream couldnt find anything for nodeId: {} and interfaceName: {}",
nodeId.getValue(),interfaceName);
try {
Optional<Nodes> nodesObject = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
nodesIID).get();
- if (nodesObject.isPresent() && (nodesObject.get().getMapping() != null)) {
- Collection<Mapping> mappingList = nodesObject.get().nonnullMapping().values();
+ if (nodesObject.isPresent() && (nodesObject.orElseThrow().getMapping() != null)) {
+ Collection<Mapping> mappingList = nodesObject.orElseThrow().nonnullMapping().values();
mappingList = mappingList.stream().filter(mp -> mp.getLogicalConnectionPoint().contains("DEG"
+ degreeCounter)).collect(Collectors.toList());
if (mappingList.size() == 1) {
LOG.error("No service path found for service {}", service.getServiceName());
return null;
}
- ServicePaths servicePaths = optServicePaths.get();
+ ServicePaths servicePaths = optServicePaths.orElseThrow();
PathDescription pathDescription = servicePaths.getPathDescription();
LOG.info("Path description of service = {}", pathDescription);
org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceAEnd serviceAEnd
// 1 top connection DSR between the CLIENT xpdrs
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
-
+ String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
+ .orElseThrow();
ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
LayerProtocolName.DSR);
putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
cepMapDsr.put(netCep1.key(), netCep1);
}
String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().get();
+ .get(0))).findFirst().orElseThrow();
String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().get();
+ .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
// DSR top connection between edge xpdr CLIENT DSR
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
// 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
-
+ String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
+ .orElseThrow();
ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
LayerProtocolName.DSR);
putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
// DSR top connection between edge xpdr CLIENT DSR
String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().get();
+ .get(0))).findFirst().orElseThrow();
String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().get();
+ .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
connectionOdu = createTopConnection(spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
// connection iODU between the xpdrs
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
-
+ String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
+ .orElseThrow();
ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
TapiStringConstants.DSR, LayerProtocolName.ODU);
putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.DSR,
// ODU top connection between edge xpdr i_ODU
String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().get();
+ .get(0))).findFirst().orElseThrow();
String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().get();
+ .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU,
LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrPhtn);
// create ceps and x connections within xpdr
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
+ String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
+ .orElseThrow();
// There should be 1 network tp per xpdr
// TODO photonic media model should be updated to have the corresponding CEPs. I will just create
// 3 different MC CEPs giving different IDs to show that they are different
}
// OTSi top connection between edge I_OTSI Xpdr
String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().get();
+ .get(0))).findFirst().orElseThrow();
String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().get();
+ .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_OTSI,
LayerProtocolName.PHOTONICMEDIA, xcMap, this.topConnRdmRdm);
LOG.info("Creating ceps and xc for roadm {}", roadm);
if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) {
LOG.info("EDGE ROADM, cross connections needed between SRG and DEG");
- String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
+ String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst()
+ .orElseThrow();
LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
// There should be only 1 AD and 1 DEG per roadm
// TODO photonic media model should be updated to have the corresponding CEPs. I will just create
cepMap.put(adCep2.key(), adCep2);
cepMap.put(adCep3.key(), adCep3);
- String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
+ String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA);
xcLowerMap.put(conn2.key(), conn2);
} else {
LOG.info("MIDDLE ROADM, cross connections needed between DEG and DEG");
- String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
+ String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
LOG.info("Degree 1 port of ROADm {} = {}", roadm, spcRdmDEG1);
ConnectionEndPoint deg1Cep1 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA);
cepMap.put(deg1Cep2.key(), deg1Cep2);
cepMap.put(deg1Cep3.key(), deg1Cep3);
- String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst().get();
+ String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst()
+ .orElseThrow();
LOG.info("Degree 2 port of ROADm {} = {}", roadm, spcRdmDEG2);
ConnectionEndPoint deg2Cep1 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA);
}
}
LOG.info("Going to create top connections between roadms");
- String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().get();
- String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().get();
+ String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().orElseThrow();
+ String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().orElseThrow();
// MC top connection between edge roadms
LOG.info("Going to created top connection between MC");
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
new org.opendaylight.yang.gen.v1.urn
.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
.setNodeEdgePointUuid(adCep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeEdgePointUuid())
+ .values().stream().findFirst().orElseThrow().getNodeEdgePointUuid())
.setTopologyUuid(adCep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getTopologyUuid())
+ .values().stream().findFirst().orElseThrow().getTopologyUuid())
.setNodeUuid(adCep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeUuid())
+ .values().stream().findFirst().orElseThrow().getNodeUuid())
.setConnectionEndPointUuid(adCep1.getUuid())
.build();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep2 =
new org.opendaylight.yang.gen.v1.urn
.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
.setNodeEdgePointUuid(adCep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeEdgePointUuid())
+ .values().stream().findFirst().orElseThrow().getNodeEdgePointUuid())
.setTopologyUuid(adCep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getTopologyUuid())
+ .values().stream().findFirst().orElseThrow().getTopologyUuid())
.setNodeUuid(adCep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeUuid())
+ .values().stream().findFirst().orElseThrow().getNodeUuid())
.setConnectionEndPointUuid(adCep1.getUuid())
.build();
Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
new org.opendaylight.yang.gen.v1.urn
.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
.setNodeEdgePointUuid(cep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeEdgePointUuid())
+ .values().stream().findFirst().orElseThrow().getNodeEdgePointUuid())
.setTopologyUuid(cep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getTopologyUuid())
+ .values().stream().findFirst().orElseThrow().getTopologyUuid())
.setNodeUuid(cep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeUuid())
+ .values().stream().findFirst().orElseThrow().getNodeUuid())
.setConnectionEndPointUuid(cep1.getUuid())
.build();
org.opendaylight.yang.gen.v1.urn
new org.opendaylight.yang.gen.v1.urn
.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
.setNodeEdgePointUuid(cep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeEdgePointUuid())
+ .values().stream().findFirst().orElseThrow().getNodeEdgePointUuid())
.setTopologyUuid(cep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getTopologyUuid())
+ .values().stream().findFirst().orElseThrow().getTopologyUuid())
.setNodeUuid(cep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeUuid())
+ .values().stream().findFirst().orElseThrow().getNodeUuid())
.setConnectionEndPointUuid(cep2.getUuid())
.build();
Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
.setValueName("OpenROADM info")
.setValue(String.join("-", serviceZEnd.getClli(),
- serviceZEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortDeviceName(),
- serviceZEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortName()))
+ serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
+ .getPortDeviceName(),
+ serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName()))
.build();
return endPointBuilder
.setServiceInterfacePoint(new ServiceInterfacePointBuilder()
.build())
.setProtectionRole(ProtectionRole.WORK)
.setRole(PortRole.SYMMETRIC)
- .setLocalId(serviceZEnd.getTxDirection().values().stream().findFirst().get()
+ .setLocalId(serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow()
.getPort().getPortDeviceName())
.build();
}
new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
.setValueName("OpenROADM info")
.setValue(String.join("-", serviceAEnd.getClli(),
- serviceAEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortDeviceName(),
- serviceAEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortName()))
+ serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
+ .getPortDeviceName(),
+ serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName()))
.build();
return endPointBuilder
.setServiceInterfacePoint(new ServiceInterfacePointBuilder()
.build())
.setProtectionRole(ProtectionRole.WORK)
.setRole(PortRole.SYMMETRIC)
- .setLocalId(serviceAEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortDeviceName())
+ .setLocalId(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
+ .getPortDeviceName())
.build();
}
if (serviceNodeId.contains("ROADM")) {
// Service from ROADM to ROADM
// AddDrop-AddDrop ports --> MC layer SIPs
- ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
+ ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst()
+ .orElseThrow();
TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
Uuid sipUuid;
switch (serviceFormat) {
case ODU:
- firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
+ firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst()
+ .orElseThrow();
tp = (TerminationPoint) firstElement.getResource().getResource();
// Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
tp.getTpId()));
break;
case OTU:
- firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
+ firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst()
+ .orElseThrow();
tp = (TerminationPoint) firstElement.getResource().getResource();
// Network-Network ports --> iOTSi layer SIPs
sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
break;
case Ethernet:
LOG.info("Elements ZA = {}", mapztoa.values().toString());
- firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
+ firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst()
+ .orElseThrow();
tp = (TerminationPoint) firstElement.getResource().getResource();
// Client-client ports --> DSR layer SIPs
sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
if (serviceNodeId.contains("ROADM")) {
// Service from ROADM to ROADM
// AddDrop-AddDrop ports --> MC layer SIPs
- AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
+ AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst()
+ .orElseThrow();
LOG.info("First element of service path = {}", firstElement.getResource().getResource());
TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
Uuid sipUuid;
switch (serviceFormat) {
case ODU:
- firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
+ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst()
+ .orElseThrow();
tp = (TerminationPoint) firstElement.getResource().getResource();
// Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
TapiStringConstants.I_ODU, tp.getTpId()));
break;
case OTU:
- firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
+ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst()
+ .orElseThrow();
tp = (TerminationPoint) firstElement.getResource().getResource();
// Network-Network ports --> iOTSi layer SIPs
sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
break;
case Ethernet:
LOG.info("Elements AZ = {}", mapatoz.values().toString());
- firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
+ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst()
+ .orElseThrow();
tp = (TerminationPoint) firstElement.getResource().getResource();
// Client-client ports --> DSR layer SIPs
sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
ConnectivityConstraint constraint = input.getConnectivityConstraint();
ConnectionType connType = null;
ServiceFormat serviceFormat = null;
- String nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
+ String nodeAid = String.join("+", endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
TapiStringConstants.DSR);
- String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
+ String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().orElseThrow().getLocalId(),
TapiStringConstants.DSR);
LOG.debug("Node a = {}", nodeAid);
LOG.debug("Node z = {}", nodeZid);
connType = getConnectionTypePhtnc(endPointMap.values());
serviceFormat = getServiceFormatPhtnc(endPointMap.values());
if (serviceFormat.equals(ServiceFormat.OC)) {
- nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
- TapiStringConstants.PHTNC_MEDIA);
- nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
+ nodeAid = String.join("+", endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
TapiStringConstants.PHTNC_MEDIA);
+ nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().orElseThrow()
+ .getLocalId(), TapiStringConstants.PHTNC_MEDIA);
} else {
- nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
- TapiStringConstants.OTSI);
- nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
+ nodeAid = String.join("+", endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
TapiStringConstants.OTSI);
+ nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().orElseThrow()
+ .getLocalId(), TapiStringConstants.OTSI);
}
LOG.debug("Node a photonic = {}", nodeAid);
LOG.debug("Node z photonic = {}", nodeZid);
// Requested Capacity for connectivity service
Uint64 capacity = input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue();
// map endpoints into service end points. Map the type of service from TAPI to OR
- ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().get(),
+ ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().orElseThrow(),
serviceFormat, nodeAid, capacity, constraint.getServiceLayer());
- ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst().get(),
- serviceFormat, nodeZid, capacity, constraint.getServiceLayer());
+ ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst()
+ .orElseThrow(), serviceFormat, nodeZid, capacity, constraint.getServiceLayer());
if (serviceAEnd == null || serviceZEnd == null) {
LOG.error("Couldnt map endpoints to service end");
return null;
LOG.error("Nep not found in datastore");
return null;
}
- String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
+ String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue();
String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
- String nepName = nep.getName().values().stream().findFirst().get().getValue();
+ String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue();
String txPortDeviceName = nepName.split("\\+")[0];
String txPortName = nepName.split("\\+")[2];
String rxPortDeviceName = txPortDeviceName;
LOG.error("Nep not found in datastore");
return null;
}
- String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
+ String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue();
String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
- String nepName = nep.getName().values().stream().findFirst().get().getValue();
+ String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue();
String txPortDeviceName = nepName.split("\\+")[0];
String txPortName = nepName.split("\\+")[2];
String rxPortDeviceName = txPortDeviceName;
if (!optMapping.isPresent()) {
LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
}
- Mapping mapping = optMapping.get();
+ Mapping mapping = optMapping.orElseThrow();
LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]),
mapping.getConnectionMapLcp());
if (!optNode.isPresent()) {
return null;
}
- OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.get().getName().get(
+ OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.orElseThrow().getName().get(
new NameKey("Node Type")).getValue());
if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
openroadmNodeTypeList.add(openroadmNodeType);
.withError(ErrorType.RPC, "SIP list is empty")
.buildFuture();
}
- if (sipMap.containsKey(new ServiceInterfacePointKey(input.getEndPoint().values().stream().findFirst().get()
- .getServiceInterfacePoint().getServiceInterfacePointUuid()))
+ if (sipMap.containsKey(new ServiceInterfacePointKey(input.getEndPoint().values().stream().findFirst()
+ .orElseThrow().getServiceInterfacePoint().getServiceInterfacePointUuid()))
&& sipMap.containsKey(new ServiceInterfacePointKey(input.getEndPoint().values().stream().skip(1)
- .findFirst().get().getServiceInterfacePoint().getServiceInterfacePointUuid()))) {
+ .findFirst().orElseThrow().getServiceInterfacePoint().getServiceInterfacePointUuid()))) {
LOG.info("SIPs found in sipMap");
// TODO: differentiate between OTN service and GbE service in TAPI
ServiceCreateInput sci = this.connectivityUtils.createORServiceInput(input, serviceUuid);
LOG.error("Could not update TAPI connectivity services");
return;
}
- ConnectivityContext connContext = optConnContext.get();
+ ConnectivityContext connContext = optConnContext.orElseThrow();
Map<Uuid, EnumTypeObject[]> states = new HashMap<>();
if (connContext.getConnectivityService() == null) {
return;
LOG.error("Could not get state for a TAPI connection");
continue;
}
- LOG.info("State of connection {} of connectivity service {} = {}", optConn.get().getUuid().getValue(),
- connService.getUuid().getValue(), optConn.get().getOperationalState().getName());
- if (optConn.get().getOperationalState() == OperationalState.DISABLED) {
+ LOG.info("State of connection {} of connectivity service {} = {}", optConn.orElseThrow().getUuid()
+ .getValue(), connService.getUuid().getValue(), optConn.orElseThrow().getOperationalState().getName());
+ if (optConn.orElseThrow().getOperationalState() == OperationalState.DISABLED) {
adminState = AdministrativeState.LOCKED;
operState = OperationalState.DISABLED;
}
LOG.error(TapiStringConstants.TAPI_CONNECTION_UPDATE_ERROR);
return;
}
- if (optConnContext.get().getConnectivityService() == null) {
+ if (optConnContext.orElseThrow().getConnectivityService() == null) {
LOG.info("No TAPI connectivity service to update");
return;
}
// TODO: order services from lower layer to upper layer
Map<ConnectivityServiceKey, ConnectivityService> connServMap
- = optConnContext.get().getConnectivityService();
+ = optConnContext.orElseThrow().getConnectivityService();
if (connServMap == null) {
LOG.info("No connections to update");
return;
LOG.error(TapiStringConstants.TAPI_CONNECTION_READ_ERROR);
continue;
}
- Connection newConn = optConn.get();
+ Connection newConn = optConn.orElseThrow();
// Check LowerConnection states and if any of the lower connection is disabled then we can put
// the connection out of service. And based on the connection previous state we decide
// the update necessary
LOG.error(TapiStringConstants.TAPI_CONNECTION_READ_ERROR);
continue;
}
- Connection newConn = optConn.get(); // Current state of connection
+ Connection newConn = optConn.orElseThrow(); // Current state of connection
if (newConn.getLowerConnection() != null) {
// TODO: we can receive disable here because the lower connection haven been yet looped through and
// therefore it is disabled but it has to be changed to enable before returning disable.
InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
.augmentation(Context1.class).child(TopologyContext.class)
.child(Topology.class, new TopologyKey(tapiTopoUuid))
- .child(Node.class, new NodeKey(ocep.get().getNodeUuid()))
+ .child(Node.class, new NodeKey(ocep.orElseThrow().getNodeUuid()))
.child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(connectionNep))
.build();
Optional<OwnedNodeEdgePoint> onep =
this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, onepIID).get();
- if (onep.isEmpty() || onep.get().augmentation(OwnedNodeEdgePoint1.class) == null
- || onep.get().augmentation(OwnedNodeEdgePoint1.class).getCepList() == null) {
+ if (onep.isEmpty() || onep.orElseThrow().augmentation(OwnedNodeEdgePoint1.class) == null
+ || onep.orElseThrow().augmentation(OwnedNodeEdgePoint1.class).getCepList() == null) {
continue;
}
- if (onep.get().getOperationalState() == OperationalState.DISABLED
- && !changedOneps.contains(onep.get().getUuid())) {
+ if (onep.orElseThrow().getOperationalState() == OperationalState.DISABLED
+ && !changedOneps.contains(onep.orElseThrow().getUuid())) {
return OperationalState.DISABLED;
}
}
LOG.error(TapiStringConstants.TAPI_CONNECTION_READ_ERROR);
continue;
}
- Connection newConn = optConn.get(); // Current state of connection
+ Connection newConn = optConn.orElseThrow(); // Current state of connection
// updated connection state if it contains a nep that has changed
if (newConn.getOperationalState().equals(OperationalState.DISABLED)) {
LOG.info("LowerConnection state is disable");
LOG.error("Could not update TAPI connectivity service");
continue;
}
- ConnectivityService newConnService = optNewConnService.get();
+ ConnectivityService newConnService = optNewConnService.orElseThrow();
if (supportedConnService.getServiceLevel() != null
&& supportedConnService.getServiceLevel().equals(supportingConnService.getValue())
&& newConnService.getAdministrativeState() != AdministrativeState.LOCKED
// - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
edgeRoadm1, edgeRoadm2));
- if (!pathDescription.getAToZDirection().getAToZ().values().stream().findFirst().get().getId()
+ if (!pathDescription.getAToZDirection().getAToZ().values().stream().findFirst().orElseThrow().getId()
.contains("ROADM")) {
// - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
// - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
// 1 top connection DSR between the CLIENT xpdrs
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
-
+ String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
+ .orElseThrow();
ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
LayerProtocolName.DSR);
putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
cepMapDsr.put(netCep1.key(), netCep1);
}
String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().get();
+ .get(0))).findFirst().orElseThrow();
String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().get();
+ .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
// DSR top connection between edge xpdr CLIENT DSR
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
// 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
-
+ String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
+ .orElseThrow();
ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
LayerProtocolName.DSR);
putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
}
String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().get();
+ .get(0))).findFirst().orElseThrow();
String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().get();
+ .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
// eODU top connection between edge xpdr CLIENT eODU
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
// connection iODU between the xpdrs
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
-
+ String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
+ .orElseThrow();
ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
TapiStringConstants.DSR, LayerProtocolName.ODU);
putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.DSR,
// ODU top connection between edge xpdr i_ODU
String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().get();
+ .get(0))).findFirst().orElseThrow();
String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().get();
+ .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU,
LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrPhtn);
// create ceps and xc connections within xpdr
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
+ String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
+ .orElseThrow();
// There should be 1 network tp per xpdr
// TODO photonic media model should be updated to have the corresponding CEPs. I will just create
// 3 different MC CEPs giving different IDs to show that they are different
}
// OTSi top connection between edge I_OTSI Xpdr
String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().get();
+ .get(0))).findFirst().orElseThrow();
String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().get();
+ .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_OTSI,
LayerProtocolName.PHOTONICMEDIA, xcMap, this.topConnRdmRdm);
LOG.info("Creating ceps and xc for roadm {}", roadm);
if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) {
LOG.info("EDGE ROADM, cross connections needed between SRG and DEG");
- String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
+ String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst()
+ .orElseThrow();
LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
// There should be only 1 AD and 1 DEG per roadm
// TODO photonic media model should be updated to have the corresponding CEPs. I will just create
cepMap.put(adCep2.key(), adCep2);
cepMap.put(adCep3.key(), adCep3);
- String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
+ String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA);
xcLowerMap.put(conn2.key(), conn2);
} else {
LOG.info("MIDDLE ROADM, cross connections needed between DEG and DEG");
- String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
+ String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
LOG.info("Degree 1 port of ROADm {} = {}", roadm, spcRdmDEG1);
ConnectionEndPoint deg1Cep1 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA);
cepMap.put(deg1Cep2.key(), deg1Cep2);
cepMap.put(deg1Cep3.key(), deg1Cep3);
- String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst().get();
+ String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst()
+ .orElseThrow();
LOG.info("Degree 2 port of ROADm {} = {}", roadm, spcRdmDEG2);
ConnectionEndPoint deg2Cep1 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA);
}
}
LOG.info("Going to create top connections between roadms");
- String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().get();
- String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().get();
+ String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().orElseThrow();
+ String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().orElseThrow();
// MC top connection between edge roadms
LOG.info("Going to created top connection between MC");
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
new org.opendaylight.yang.gen.v1.urn
.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
.setNodeEdgePointUuid(adCep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeEdgePointUuid())
+ .values().stream().findFirst().orElseThrow().getNodeEdgePointUuid())
.setTopologyUuid(adCep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getTopologyUuid())
+ .values().stream().findFirst().orElseThrow().getTopologyUuid())
.setNodeUuid(adCep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeUuid())
+ .values().stream().findFirst().orElseThrow().getNodeUuid())
.setConnectionEndPointUuid(adCep1.getUuid())
.build();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep2 =
new org.opendaylight.yang.gen.v1.urn
.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
.setNodeEdgePointUuid(adCep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeEdgePointUuid())
+ .values().stream().findFirst().orElseThrow().getNodeEdgePointUuid())
.setTopologyUuid(adCep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getTopologyUuid())
+ .values().stream().findFirst().orElseThrow().getTopologyUuid())
.setNodeUuid(adCep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeUuid())
+ .values().stream().findFirst().orElseThrow().getNodeUuid())
.setConnectionEndPointUuid(adCep1.getUuid())
.build();
Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
new org.opendaylight.yang.gen.v1.urn
.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
.setNodeEdgePointUuid(cep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeEdgePointUuid())
+ .values().stream().findFirst().orElseThrow().getNodeEdgePointUuid())
.setTopologyUuid(cep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getTopologyUuid())
+ .values().stream().findFirst().orElseThrow().getTopologyUuid())
.setNodeUuid(cep1.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeUuid())
+ .values().stream().findFirst().orElseThrow().getNodeUuid())
.setConnectionEndPointUuid(cep1.getUuid())
.build();
org.opendaylight.yang.gen.v1.urn
new org.opendaylight.yang.gen.v1.urn
.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
.setNodeEdgePointUuid(cep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeEdgePointUuid())
+ .values().stream().findFirst().orElseThrow().getNodeEdgePointUuid())
.setTopologyUuid(cep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getTopologyUuid())
+ .values().stream().findFirst().orElseThrow().getTopologyUuid())
.setNodeUuid(cep2.getClientNodeEdgePoint()
- .values().stream().findFirst().get().getNodeUuid())
+ .values().stream().findFirst().orElseThrow().getNodeUuid())
.setConnectionEndPointUuid(cep2.getUuid())
.build();
Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
LOG.error("ONEP is not present in datastore");
return;
}
- OwnedNodeEdgePoint onep = optionalOnep.get();
+ OwnedNodeEdgePoint onep = optionalOnep.orElseThrow();
LOG.info("ONEP found = {}", onep.toString());
// TODO -> If cep exists -> skip merging to datasore
OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class);
LOG.error("Connectivity service not found in tapi context");
return null;
}
- return optConnServ.get();
+ return optConnServ.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Connectivity service not found in tapi context. Error:", e);
return null;
LOG.error("Node is not present in datastore");
return null;
}
- if (optNode.get().augmentation(OwnedNodeEdgePoint1.class) == null) {
+ if (optNode.orElseThrow().augmentation(OwnedNodeEdgePoint1.class) == null) {
LOG.error("Node doesnt have ceps");
return null;
}
- return optNode.get().augmentation(OwnedNodeEdgePoint1.class).getCepList().getConnectionEndPoint()
+ return optNode.orElseThrow().augmentation(OwnedNodeEdgePoint1.class).getCepList().getConnectionEndPoint()
.get(new org.opendaylight.yang.gen.v1.urn
.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(cepUuid));
} catch (InterruptedException | ExecutionException e) {
if (!optNode.isPresent()) {
return null;
}
- OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.get().getName().get(
+ OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.orElseThrow().getName().get(
new NameKey("Node Type")).getValue());
if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
openroadmNodeTypeList.add(openroadmNodeType);
if (!optMapping.isPresent()) {
LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
}
- Mapping mapping = optMapping.get();
+ Mapping mapping = optMapping.orElseThrow();
LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]),
mapping.getConnectionMapLcp());
LOG.error("Connectivity service not found in tapi context");
return null;
}
- return optConnServ.get();
+ return optConnServ.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed to merge TAPI connectivity", e);
return null;
return;
}
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
- newConnection = new ConnectionBuilder(optConn.get()).setLifecycleState(LifecycleState.INSTALLED)
+ newConnection = new ConnectionBuilder(optConn.orElseThrow()).setLifecycleState(LifecycleState.INSTALLED)
.setOperationalState(OperationalState.ENABLED).build();
// merge in datastore
this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID,
.collect(Collectors.toList());
if (!OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
- .values().stream().findFirst().get();
+ .values().stream().findFirst().orElseThrow();
this.oorClientPortList = ietfNode.augmentation(
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
.getTerminationPoint().values().stream()
.collect(Collectors.toList());
if (!OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
- .values().stream().findFirst().get();
+ .values().stream().findFirst().orElseThrow();
this.oorClientPortList = ietfNode.augmentation(
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
.getTerminationPoint().values().stream()
prunedTapiPhotonicNodes = new ArrayList<>();
List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiPhotonicNodes
= this.tapiNodes.values().stream()
- .filter(n -> LayerProtocolName.PHOTONICMEDIA.equals(n.getLayerProtocolName().stream().findFirst().get()))
+ .filter(n -> LayerProtocolName.PHOTONICMEDIA.equals(n.getLayerProtocolName().stream().findFirst()
+ .orElseThrow()))
.collect(Collectors.toList());
for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node
: tapiPhotonicNodes) {
String nodeUuid = node.getUuid().getValue();
String nepUuid = nep.getUuid().getValue();
String nodeName = node.getName().get(new NameKey("otsi node name")).getValue();
- String nepName = nep.getName().get(new NameKey(nep.getName().keySet().stream().findFirst().get()))
+ String nepName = nep.getName().get(new NameKey(nep.getName().keySet().stream().findFirst()
+ .orElseThrow()))
.getValue();
uuidNameMap.put(String.join("--", nodeUuid, nepUuid), String.join("--", nodeName, nepName));
}
LOG.error("Could not update TAPI links");
return;
}
- for (Link link : optTopology.get().nonnullLink().values()) {
+ for (Link link : optTopology.orElseThrow().nonnullLink().values()) {
List<Uuid> linkNeps = Objects.requireNonNull(link.getNodeEdgePoint()).values().stream()
.map(NodeEdgePointRef::getNodeEdgePointUuid).collect(Collectors.toList());
if (!Collections.disjoint(changedOneps, linkNeps)) {
Optional<Node> optionalNode = this.networkTransactionService.read(
LogicalDatastoreType.OPERATIONAL, nodeIID).get();
if (optionalNode.isPresent()) {
- Node node = optionalNode.get();
+ Node node = optionalNode.orElseThrow();
List<OwnedNodeEdgePoint> oneps = node.getOwnedNodeEdgePoint().values().stream()
.filter(onep -> ((Name) onep.getName().values().toArray()[0]).getValue()
.contains(mapping.getLogicalConnectionPoint())).collect(Collectors.toList());
LOG.error("No topology object present. Error deleting node {}", nodeId);
return;
}
- topology = optTopology.get();
+ topology = optTopology.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Couldnt read tapi topology from datastore", e);
}
LOG.error("No context object present in datastore.");
return;
}
- context = optContext.get();
+ context = optContext.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Couldnt read tapi context from datastore", e);
}
LOG.error("Couldnt retrieve connectivity context from datastore");
return;
}
- connContext = optConnContext.get();
+ connContext = optConnContext.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Couldnt read connectivity context from datastore", e);
}
FluentFuture<Optional<Network>> topologyFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, networkIID);
try {
- topology = topologyFuture.get().get();
+ topology = topologyFuture.get().orElseThrow();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new TapiTopologyException("Unable to get from mdsal topology: " + networkIID
String portMappingNodeId = entry.getValue().getSupportingNode().values().stream()
.filter(sn -> sn.getNetworkRef().getValue().equals(NetworkUtils.UNDERLAY_NETWORK_ID))
.findFirst()
- .get().getNodeRef().getValue();
+ .orElseThrow().getNodeRef().getValue();
List<String> networkPortList = new ArrayList<>();
for (TerminationPoint tp: entry.getValue().augmentation(Node1.class).getTerminationPoint().values()) {
if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)
Mapping mapping = null;
if (mappingOpt.isDone()) {
try {
- mapping = mappingOpt.get().get();
+ mapping = mappingOpt.get().orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error getting mapping for {}", networkLcp, e);
return false;
ListenableFuture<Optional<Network>> topologyFuture =
this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, networkIID);
try {
- topology = topologyFuture.get().get();
+ topology = topologyFuture.get().orElseThrow();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new TapiTopologyException("Unable to get from mdsal topology: " + networkIID
String portMappingNodeId = entry.getValue().getSupportingNode().values().stream()
.filter(sn -> sn.getNetworkRef().getValue().equals(NetworkUtils.UNDERLAY_NETWORK_ID))
.findFirst()
- .get().getNodeRef().getValue();
+ .orElseThrow().getNodeRef().getValue();
List<String> networkPortList = new ArrayList<>();
for (TerminationPoint tp: entry.getValue().augmentation(Node1.class).getTerminationPoint().values()) {
// TODO -> why are we checking with respect to XPDR links?? Is there a real purpose on doing that?
Mapping mapping = null;
if (mappingOpt.isDone()) {
try {
- mapping = mappingOpt.get().get();
+ mapping = mappingOpt.get().orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error getting mapping for {}", networkLcp,e);
return false;
if (sep.getEndPoint().getServiceEndPointType().equals(EndPointType.Aend)) {
ServiceAEnd sepG = ConnectivityUtils.buildServiceAEnd(sep.getEndPoint().getNodeId().getValue(),
sep.getEndPoint().getClli(),
- sep.getEndPoint().getTxDirection().values().stream().findFirst().get().getPort()
+ sep.getEndPoint().getTxDirection().values().stream().findFirst().orElseThrow().getPort()
.getPortDeviceName(),
- sep.getEndPoint().getTxDirection().values().stream().findFirst().get().getPort().getPortName(),
- sep.getEndPoint().getRxDirection().values().stream().findFirst().get().getPort()
+ sep.getEndPoint().getTxDirection().values().stream().findFirst().orElseThrow().getPort()
+ .getPortName(),
+ sep.getEndPoint().getRxDirection().values().stream().findFirst().orElseThrow().getPort()
.getPortDeviceName(),
- sep.getEndPoint().getRxDirection().values().stream().findFirst().get().getPort().getPortName());
+ sep.getEndPoint().getRxDirection().values().stream().findFirst().orElseThrow().getPort()
+ .getPortName());
return new GenericServiceEndpoint(sepG, ServiceEndpointType.SERVICEAEND);
} else {
ServiceZEnd sepG = ConnectivityUtils.buildServiceZEnd(sep.getEndPoint().getNodeId().getValue(),
sep.getEndPoint().getClli(),
- sep.getEndPoint().getTxDirection().values().stream().findFirst().get().getPort()
+ sep.getEndPoint().getTxDirection().values().stream().findFirst().orElseThrow().getPort()
.getPortDeviceName(),
- sep.getEndPoint().getTxDirection().values().stream().findFirst().get().getPort().getPortName(),
- sep.getEndPoint().getRxDirection().values().stream().findFirst().get().getPort()
+ sep.getEndPoint().getTxDirection().values().stream().findFirst().orElseThrow().getPort()
+ .getPortName(),
+ sep.getEndPoint().getRxDirection().values().stream().findFirst().orElseThrow().getPort()
.getPortDeviceName(),
- sep.getEndPoint().getRxDirection().values().stream().findFirst().get().getPort().getPortName());
+ sep.getEndPoint().getRxDirection().values().stream().findFirst().orElseThrow().getPort()
+ .getPortName());
return new GenericServiceEndpoint(sepG, ServiceEndpointType.SERVICEZEND);
}
}
LOG.error("Tapi context is not present in datastore");
return null;
}
- return optionalContext.get();
+ return optionalContext.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Couldnt read tapi context from datastore", e);
return null;
LOG.error("ONEP is not present in datastore");
return;
}
- OwnedNodeEdgePoint onep = optionalOnep.get();
+ OwnedNodeEdgePoint onep = optionalOnep.orElseThrow();
LOG.info("ONEP found = {}", onep);
// TODO -> If cep exists -> skip merging to datasore
OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class);
return null;
}
// TODO -> Need to remove CEPs from NEPs. If not error from get Topology details output
- Node node = optNode.get();
+ Node node = optNode.orElseThrow();
LOG.debug("NEPs of node before creating map to be returned to the getTapiNode function = {}",
node.getOwnedNodeEdgePoint().size());
Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
LOG.error(NODE_NOT_PRESENT);
return null;
}
- return optNode.get();
+ return optNode.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Couldnt read NEP in topology", e);
return null;
LOG.error(NODE_NOT_PRESENT);
return null;
}
- return optLink.get();
+ return optLink.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Couldnt read link in topology", e);
return null;
LOG.error("Topology context is not present in datastore");
return null;
}
- return optTopoContext.get().getTopology();
+ return optTopoContext.orElseThrow().getTopology();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Couldnt read topology context", e);
return null;
LOG.error("Connectivity service not found in tapi context");
return null;
}
- return optConnServ.get();
+ return optConnServ.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Connectivity service not found in tapi context. Error:", e);
return null;
LOG.error("Connection not found in tapi context");
return null;
}
- return optConn.get();
+ return optConn.orElseThrow();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Connection not found in tapi context. Error:", e);
return null;
LOG.error("Connectivity context not found in tapi context");
return null;
}
- return optConnContext.get().getConnectivityService();
+ return optConnContext.orElseThrow().getConnectivityService();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Connectivity context not found in tapi context. Error:", e);
return null;
LOG.error(NODE_NOT_PRESENT);
return null;
}
- if (optNode.get().augmentation(OwnedNodeEdgePoint1.class) == null) {
+ if (optNode.orElseThrow().augmentation(OwnedNodeEdgePoint1.class) == null) {
LOG.error("Node doesnt have ceps");
return null;
}
- return optNode.get().augmentation(OwnedNodeEdgePoint1.class).getCepList().getConnectionEndPoint()
+ return optNode.orElseThrow().augmentation(OwnedNodeEdgePoint1.class).getCepList().getConnectionEndPoint()
.get(new ConnectionEndPointKey(cepUuid));
} catch (InterruptedException | ExecutionException e) {
LOG.error("Couldnt read node in topology", e);
LOG.error("Couldnt obtain OR services from datastore");
return;
}
- ServiceList orServices = optOrServices.get();
+ ServiceList orServices = optOrServices.orElseThrow();
if (orServices.getServices() == null) {
LOG.info("No services in datastore. No mapping needed");
return;
LOG.error("One of the 2 neps doesnt exist in the datastore: {} OR {}", nepUuid, nep1Uuid);
return null;
}
- return optionalOnep.get().getOperationalState().equals(optionalOnep1.get().getOperationalState())
- ? optionalOnep.get().getOperationalState().getName() : OperationalState.DISABLED.getName();
+ return optionalOnep.orElseThrow().getOperationalState().equals(
+ optionalOnep1.orElseThrow().getOperationalState())
+ ? optionalOnep.orElseThrow().getOperationalState().getName() : OperationalState.DISABLED.getName();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed getting Mapping data from portMapping",e);
return null;
LOG.error("One of the 2 neps doesnt exist in the datastore: {} OR {}", nepUuid, nep1Uuid);
return null;
}
- return optionalOnep.get().getAdministrativeState().equals(optionalOnep1.get().getAdministrativeState())
- ? optionalOnep.get().getAdministrativeState().getName() : AdministrativeState.UNLOCKED.getName();
+ return optionalOnep.orElseThrow().getAdministrativeState().equals(
+ optionalOnep1.orElseThrow().getAdministrativeState())
+ ? optionalOnep.orElseThrow().getAdministrativeState().getName()
+ : AdministrativeState.UNLOCKED.getName();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed getting Mapping data from portMapping",e);
return null;
.child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR1")));
FluentFuture<Optional<Node>> muxAFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, muxAIID);
- otnMuxA = muxAFuture.get().get();
+ otnMuxA = muxAFuture.get().orElseThrow();
KeyedInstanceIdentifier<Node, NodeKey> muxCIID = InstanceIdentifier.create(Networks.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
.class, new NetworkKey(new NetworkId("otn-topology")))
.child(Node.class, new NodeKey(new NodeId("SPDR-SC1-XPDR1")));
FluentFuture<Optional<Node>> muxCFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, muxCIID);
- muxCFuture.get().get();
+ muxCFuture.get().orElseThrow();
KeyedInstanceIdentifier<Node, NodeKey> switchIID = InstanceIdentifier.create(Networks.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
.class, new NetworkKey(new NetworkId("otn-topology")))
.child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR2")));
FluentFuture<Optional<Node>> switchFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, switchIID);
- otnSwitch = switchFuture.get().get();
+ otnSwitch = switchFuture.get().orElseThrow();
KeyedInstanceIdentifier<Node, NodeKey> roadmaIID = InstanceIdentifier.create(Networks.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
.class, new NetworkKey(new NetworkId("openroadm-network")))
.child(Node.class, new NodeKey(new NodeId("ROADM-A1")));
FluentFuture<Optional<Node>> roadmaFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, roadmaIID);
- roadmA = roadmaFuture.get().get();
+ roadmA = roadmaFuture.get().orElseThrow();
KeyedInstanceIdentifier<Node, NodeKey> roadmcIID = InstanceIdentifier.create(Networks.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
.class, new NetworkKey(new NetworkId("openroadm-network")))
.child(Node.class, new NodeKey(new NodeId("ROADM-C1")));
FluentFuture<Optional<Node>> roadmcFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, roadmcIID);
- roadmC = roadmcFuture.get().get();
+ roadmC = roadmcFuture.get().orElseThrow();
KeyedInstanceIdentifier<Node, NodeKey> tpdrIID = InstanceIdentifier.create(Networks.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
.child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1")));
FluentFuture<Optional<Node>> tpdrFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, tpdrIID);
- tpdr100G = tpdrFuture.get().get();
+ tpdr100G = tpdrFuture.get().orElseThrow();
InstanceIdentifier<Network1> linksIID = InstanceIdentifier.create(Networks.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
.augmentation(Network1.class);
FluentFuture<Optional<Network1>> linksFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, linksIID);
- linksFuture.get().get().getLink();
+ linksFuture.get().orElseThrow().getLink();
InstanceIdentifier<Network1> links1IID = InstanceIdentifier.create(Networks.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
.augmentation(Network1.class);
FluentFuture<Optional<Network1>> links1Future = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, links1IID);
- ortopoLinks = links1Future.get().get().getLink();
+ ortopoLinks = links1Future.get().orElseThrow().getLink();
InstanceIdentifier<Network> ortopo1IID = InstanceIdentifier.create(Networks.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
.class, new NetworkKey(new NetworkId("openroadm-topology")));
FluentFuture<Optional<Network>> ortopoFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, ortopo1IID);
- openroadmNet = ortopoFuture.get().get();
+ openroadmNet = ortopoFuture.get().orElseThrow();
topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
Charset.forName("UTF-8"))).toString());
assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
assertEquals(1, node.getLayerProtocolName().size(),
"otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
- assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().get(),
+ assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().orElseThrow(),
"otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
switch (otsiNodeType) {
assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
assertEquals(
LayerProtocolName.PHOTONICMEDIA.getName(),
- link.getLayerProtocolName().stream().findFirst().get().getName(),
+ link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
"oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),"otn tapi link should be BIDIRECTIONAL");
List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
assertEquals(
LayerProtocolName.PHOTONICMEDIA.getName(),
- link.getLayerProtocolName().stream().findFirst().get().getName(),
+ link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
"oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
"otn tapi link should be BIDIRECTIONAL");
FluentFuture<Optional<Node>> switchFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, switchIID);
- otnMuxA = muxAFuture.get().get();
- otnMuxC = muxCFuture.get().get();
- otnSwitch = switchFuture.get().get();
+ otnMuxA = muxAFuture.get().orElseThrow();
+ otnMuxC = muxCFuture.get().orElseThrow();
+ otnSwitch = switchFuture.get().orElseThrow();
KeyedInstanceIdentifier<Node, NodeKey> tpdrIID = InstanceIdentifier.create(Networks.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
.child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1")));
FluentFuture<Optional<Node>> tpdrFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, tpdrIID);
- tpdr100G = tpdrFuture.get().get();
+ tpdr100G = tpdrFuture.get().orElseThrow();
InstanceIdentifier<Network1> linksIID = InstanceIdentifier.create(Networks.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
.augmentation(Network1.class);
FluentFuture<Optional<Network1>> linksFuture = dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.CONFIGURATION, linksIID);
- otnLinks = linksFuture.get().get().getLink();
+ otnLinks = linksFuture.get().orElseThrow().getLink();
topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
Charset.forName("UTF-8"))).toString());
new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("otsi node name")));
assertEquals(1, node.getLayerProtocolName().size(),
"otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
- assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().get(),
+ assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().orElseThrow(),
"otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
List<OwnedNodeEdgePoint> nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
.filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
if ("OTU4".equals(prefix)) {
assertEquals(
LayerProtocolName.PHOTONICMEDIA.getName(),
- link.getLayerProtocolName().stream().findFirst().get().getName(),
+ link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
"otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
} else if ("ODTU4".equals(prefix)) {
assertEquals(
LayerProtocolName.ODU.getName(),
- link.getLayerProtocolName().stream().findFirst().get().getName(),
+ link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
"otn link should be between 2 nodes of protocol layers ODU");
}
assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(), "otn tapi link should be BIDIRECTIONAL");
assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
assertEquals(
LayerProtocolName.PHOTONICMEDIA.getName(),
- link.getLayerProtocolName().stream().findFirst().get().getName(),
+ link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
"oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(), "otn tapi link should be BIDIRECTIONAL");
List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
.toString());
assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
assertEquals(1, topology.getNode().size(), "Node list size should be 1");
- Name nodeName = topology.getNode().values().stream().findFirst().get().getName()
+ Name nodeName = topology.getNode().values().stream().findFirst().orElseThrow().getName()
.get(new NameKey("Tpdr100g node name"));
assertEquals("Tpdr100g over WDM node", nodeName.getValue(), "Node name should be 'Tpdr100g over WDM node'");
Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeName.getValue().getBytes(StandardCharsets.UTF_8))
.toString());
- assertEquals(nodeUuid, topology.getNode().values().stream().findFirst().get().getUuid(), "incorrect node uuid");
- long nb = topology.getNode().values().stream().findFirst().get().getOwnedNodeEdgePoint().size();
+ assertEquals(nodeUuid, topology.getNode().values().stream().findFirst().orElseThrow().getUuid(),
+ "incorrect node uuid");
+ long nb = topology.getNode().values().stream().findFirst().orElseThrow().getOwnedNodeEdgePoint().size();
assertEquals(2, nb, "'Transponder 100GE' node should have 2 neps");
- List<NodeRuleGroup> nrgList = topology.getNode().values().stream().findFirst().get().nonnullNodeRuleGroup()
- .values().stream().sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
+ List<NodeRuleGroup> nrgList = topology.getNode().values().stream().findFirst().orElseThrow()
+ .nonnullNodeRuleGroup().values().stream()
+ .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
.collect(Collectors.toList());
assertEquals(1, nrgList.size(), "'Transponder 100GE' node should contain a single node rule groups");
List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
assertEquals(
"T0 - Multi-layer topology",
- topology.nonnullName().values().stream().findFirst().get().getValue(),
+ topology.nonnullName().values().stream().findFirst().orElseThrow().getValue(),
"topology name should be T0 - Multi-layer topology");
long nbDsrOduNodes = topology.nonnullNode().values().stream()
assertEquals(18, topology.getNode().size(), "Node list size should be 18");
long nb1 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+DSR"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("XPDR-A1-XPDR1+DSR"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
.count();
assertEquals(2, nb1, "XPDR-A1-XPDR1+DSR should only have two client neps");
long inb1 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+DSR"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("XPDR-A1-XPDR1+DSR"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
.count();
assertEquals(2, inb1, "XPDR-A1-XPDR1+DSR should only have two internal network neps");
long enb1 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+DSR"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("XPDR-A1-XPDR1+DSR"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
.count();
assertEquals(2, enb1, "XPDR-A1-XPDR1+DSR should only have two external network neps");
long nb2 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+DSR"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR1+DSR"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
.count();
assertEquals(4, nb2, "SPDR-SA1-XPDR1+DSR (mux) should have 4 client neps");
long inb3 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+DSR"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR1+DSR"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
.count();
assertEquals(1, inb3, "SPDR-SA1-XPDR1+DSR (mux) should have a single internal network nep");
long enb3 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+DSR"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR1+DSR"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
.count();
assertEquals(4, enb3, "SPDR-SA1-XPDR1+DSR (mux) should have 4 external network nep");
long nb4 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+DSR"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR2+DSR"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
.count();
assertEquals(4, nb4, "SPDR-SA1-XPDR2+DSR (switch) should have 4 client neps");
long inb5 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+DSR"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR2+DSR"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
.count();
assertEquals(4, inb5, "SPDR-SA1-XPDR2+DSR (switch) should have 4 internal network neps");
long enb5 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+DSR"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR2+DSR"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
.count();
// Now lets check for the Photonic media nodes (same nodes as for DSR + 1 Roadm node)
nb1 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+OTSi"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("XPDR-A1-XPDR1+OTSi"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint"))))
.count();
assertEquals(2, nb1, "XPDR-A1-XPDR1+OTSi should only have two internal network neps");
inb1 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+OTSi"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("XPDR-A1-XPDR1+OTSi"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
.count();
assertEquals(2, inb1, "XPDR-A1-XPDR1+OTSi should only have two external network neps");
enb1 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+OTSi"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("XPDR-A1-XPDR1+OTSi"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("PhotMedNodeEdgePoint"))))
.count();
assertEquals(2, enb1, "XPDR-A1-XPDR1+OTSi should only have two photonic network neps");
nb2 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+OTSi"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR1+OTSi"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint"))))
.count();
assertEquals(1, nb2, "SPDR-SA1-XPDR1+OTSi (mux) should have a single internal network nep");
inb3 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+OTSi"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR1+OTSi"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
.count();
assertEquals(1, inb3, "SPDR-SA1-XPDR1+OTSi (mux) should have a single external network nep");
enb3 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+OTSi"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR1+OTSi"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("PhotMedNodeEdgePoint"))))
.count();
assertEquals(1, enb3, "SPDR-SA1-XPDR1+OTSi (mux) should have a single photonic network nep");
nb4 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+OTSi"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR2+OTSi"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint"))))
.count();
assertEquals(4, nb4, "SPDR-SA1-XPDR2+OTSi (switch) should have 4 internal network neps");
inb5 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+OTSi"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR2+OTSi"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
.count();
assertEquals(4, inb5, "SPDR-SA1-XPDR2+OTSi (switch) should have 4 external network neps");
enb5 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+OTSi"))
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue()
+ .equals("SPDR-SA1-XPDR2+OTSi"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getName().containsKey(new NameKey("PhotMedNodeEdgePoint"))))
.count();
// We should have 3 neps per DEGREE-TTP port and 3 neps per SRG-PP port
long inb6 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals(
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue().equals(
"ROADM-A1+PHOTONIC_MEDIA"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
- .filter(nep -> nep.getName().values().stream().findFirst().get().getValue().contains("DEG")))
+ .filter(nep -> nep.getName().values().stream().findFirst().orElseThrow().getValue().contains("DEG")))
.count();
assertEquals(6, inb6, "ROADM-A1+PHOTONIC_MEDIA (DEGREE) should have 6 network neps");
long enb6 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
- .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals(
+ .filter(node -> node.getName().values().stream().findFirst().orElseThrow().getValue().equals(
"ROADM-A1+PHOTONIC_MEDIA"))
.flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
- .filter(nep -> nep.getName().values().stream().findFirst().get().getValue().contains("SRG")))
+ .filter(nep -> nep.getName().values().stream().findFirst().orElseThrow().getValue().contains("SRG")))
.count();
assertEquals(24, enb6, "ROADM-A1+PHOTONIC_MEDIA (SRG) should have 24 network neps");
assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
assertEquals(
"T0 - Full Multi-layer topology",
- topology.nonnullName().values().stream().findFirst().get().getValue(),
+ topology.nonnullName().values().stream().findFirst().orElseThrow().getValue(),
"topology name should be T0 - Full Multi-layer topology");
long nbDsrOduNodes = topology.nonnullNode().values().stream()
@Nullable
Topology topology = rpcResult.getResult().getTopology();
for (Node node:topology.getNode().values()) {
- String nodeName = node.getName().values().stream().findFirst().get().getValue();
+ String nodeName = node.getName().values().stream().findFirst().orElseThrow().getValue();
GetNodeDetailsInput input1 = TapiTopologyDataUtils.buildGetNodeDetailsInput(
TapiStringConstants.T0_FULL_MULTILAYER, nodeName);
ListenableFuture<RpcResult<GetNodeDetailsOutput>> result1 = tapiTopoImpl.getNodeDetails(input1);
Node node1 = rpcResult1.getResult().getNode();
assertNotNull(node1, "Node should not be null");
for (OwnedNodeEdgePoint onep:node1.getOwnedNodeEdgePoint().values()) {
- String onepName = onep.getName().values().stream().findFirst().get().getValue();
+ String onepName = onep.getName().values().stream().findFirst().orElseThrow().getValue();
GetNodeEdgePointDetailsInput input2 = TapiTopologyDataUtils.buildGetNodeEdgePointDetailsInput(
TapiStringConstants.T0_FULL_MULTILAYER, nodeName, onepName);
ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> result2
@Nullable
Topology topology = rpcResult.getResult().getTopology();
for (Link link:topology.getLink().values()) {
- String linkName = link.getName().values().stream().findFirst().get().getValue();
+ String linkName = link.getName().values().stream().findFirst().orElseThrow().getValue();
GetLinkDetailsInput input1 = TapiTopologyDataUtils.buildGetLinkDetailsInput(
TapiStringConstants.T0_FULL_MULTILAYER, linkName);
ListenableFuture<RpcResult<GetLinkDetailsOutput>> result1 = tapiTopoImpl.getLinkDetails(input1);
if ("OTU4".equals(prefix)) {
assertEquals("otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA",
LayerProtocolName.PHOTONICMEDIA.getName(),
- link.getLayerProtocolName().stream().findFirst().get().getName());
+ link.getLayerProtocolName().stream().findFirst().orElseThrow().getName());
} else if ("ODTU4".equals(prefix)) {
assertEquals("otn link should be between 2 nodes of protocol layers ODU",
LayerProtocolName.ODU.getName(),
- link.getLayerProtocolName().stream().findFirst().get().getName());
+ link.getLayerProtocolName().stream().findFirst().orElseThrow().getName());
}
assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
"transitional link should be BIDIRECTIONAL");
LOG.debug("Input data converted into normalizedNodes");
YangInstanceIdentifier initialDataIi = YangInstanceIdentifier.of(dataQName);
- LOG.debug("Searching for {} inside {}", initialDataIi, initialDataNormalizedNodes.get());
+ LOG.debug("Searching for {} inside {}", initialDataIi, initialDataNormalizedNodes.orElseThrow());
Optional<NormalizedNode> dataNormalizedNodes =
- NormalizedNodes.findNode(initialDataNormalizedNodes.get(), initialDataIi);
+ NormalizedNodes.findNode(initialDataNormalizedNodes.orElseThrow(), initialDataIi);
Preconditions.checkArgument(dataNormalizedNodes.isPresent());
LOG.info("Initial data was successfully stored into ds");
DOMDataTreeWriteTransaction writeOnlyTransaction = domDataBroker.newWriteOnlyTransaction();
- writeOnlyTransaction.put(LogicalDatastoreType.OPERATIONAL, initialDataIi, dataNormalizedNodes.get());
+ writeOnlyTransaction.put(LogicalDatastoreType.OPERATIONAL, initialDataIi, dataNormalizedNodes.orElseThrow());
try {
writeOnlyTransaction.commit().get();
} catch (InterruptedException | ExecutionException e) {
if (!directChild.isPresent()) {
throw new IllegalStateException(String.format("Could not get the direct child of %s", rootNode));
}
- normalizedNode = directChild.get();
+ normalizedNode = directChild.orElseThrow();
}
YangInstanceIdentifier rootNodeYangInstanceIdentifier = YangInstanceIdentifier.of(rootNode);
jsonCodecFactory, rootNode, EffectiveModelContext.NAME.getNamespace(), jsonWriter);
try (NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(create);) {
normalizedNodeWriter
- .write(convertType.toNormalizedNodes(dataObjectClass.cast(object), dataObjectClass).get());
+ .write(convertType.toNormalizedNodes(dataObjectClass.cast(object), dataObjectClass).orElseThrow());
} catch (IOException ioe) {
throw new IllegalStateException(ioe);
}
rpcOutputQName.getLocalName(), rpcOutputQName.getNamespace().toString());
xmlStreamWriter.writeDefaultNamespace(rpcOutputQName.getNamespace().toString());
NormalizedNode rpcOutputNormalizedNode =
- convertType.toNormalizedNodes(dataObjectClass.cast(object), dataObjectClass).get();
+ convertType.toNormalizedNodes(dataObjectClass.cast(object), dataObjectClass).orElseThrow();
for (final NormalizedNode child : ((ContainerNode)rpcOutputNormalizedNode).body()) {
normalizedNodeWriter.write(child);
}
}
try (NormalizedNodeWriter normalizedNodeWriter = createWriterBackedNormalizedNodeWriter(writer)) {
- normalizedNodeWriter.write(normalizedNode.get());
+ normalizedNodeWriter.write(normalizedNode.orElseThrow());
normalizedNodeWriter.flush();
} catch (IOException ioe) {
throw new IllegalStateException(ioe);
"Could not transform the input %s into normalized nodes", fileName));
}
Optional<DataObject> dataObject = XMLDataObjectConverter.createWithDataStoreUtil(dataStoreContextUtil)
- .getDataObject(transformIntoNormalizedNode.get(), Networks.QNAME);
+ .getDataObject(transformIntoNormalizedNode.orElseThrow(), Networks.QNAME);
if (!dataObject.isPresent()) {
throw new IllegalStateException("Could not transform normalized nodes into data object");
} else {
- networks = (Networks) dataObject.get();
+ networks = (Networks) dataObject.orElseThrow();
}
} catch (IOException e) {
LOG.error("An error occured while reading file {}", file, e);
throw new IllegalStateException("Network is null cannot write it to datastore");
}
FluentFuture<? extends CommitInfo> commitFuture = writeTransaction(dataStoreContextUtil.getDataBroker(), ii,
- networks.nonnullNetwork().values().stream().findFirst().get());
+ networks.nonnullNetwork().values().stream().findFirst().orElseThrow());
commitFuture.get();
LOG.info("extraction from {} stored with success in datastore", topoFile.getName());
}
"Could not transform the input %s into normalized nodes", fileName));
}
Optional<DataObject> dataObject = XMLDataObjectConverter.createWithDataStoreUtil(dataStoreContextUtil)
- .getDataObject(transformIntoNormalizedNode.get(), Network.QNAME);
+ .getDataObject(transformIntoNormalizedNode.orElseThrow(), Network.QNAME);
if (!dataObject.isPresent()) {
throw new IllegalStateException("Could not transform normalized nodes into data object");
} else {
- result = (Network) dataObject.get();
+ result = (Network) dataObject.orElseThrow();
}
} catch (IOException e) {
LOG.error("An error occured while reading file {}", file, e);