From eb01f458a38bfd681cf6551c5f33572ad3035e72 Mon Sep 17 00:00:00 2001 From: manuedelf Date: Mon, 23 Mar 2020 21:40:03 +0100 Subject: [PATCH] Fix spotbugs issues of the renderer module Fix following categories: - NP_LOAD_OF_KNOWN_NULL_VALUE - PZLA_PREFER_ZERO_LENGTH_ARRAYS - RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE - SLF4J_ILLEGAL_PASSED_CLASS - DM_CONVERT_CASE - NM_CONFUSING - SLF4J_FORMAT_SHOULD_BE_CONST - UPM_UNCALLED_PRIVATE_METHOD - EC_UNRELATED_TYPES - NP_ALWAYS_NULL - NP_LOAD_OF_KNOWN_NULL_VALUE JIRA: TRNSPRTPCE-213 Signed-off-by: manuedelf Change-Id: I19b1654ad5ac6f4ea3a8c1ef468a2e69016b69cc --- renderer/pom.xml | 6 - .../renderer/ModelMappingUtils.java | 72 +++--- .../OpenRoadmInterface121.java | 18 +- .../OpenRoadmInterface221.java | 3 +- .../OpenRoadmInterfaceFactory.java | 18 +- .../OpenRoadmOtnInterface221.java | 221 +++++++++--------- .../DeviceRendererServiceImpl.java | 106 +++++---- .../OtnDeviceRendererServiceImpl.java | 9 +- .../RendererServiceOperationsImpl.java | 49 +++- .../otn/OtnDeviceOperations.java | 16 +- .../otn/OtnDeviceOperationsImpl.java | 66 +++--- .../tasks/DeviceRenderingTask.java | 3 +- .../renderer/rpcs/DeviceRendererRPCImpl.java | 35 ++- .../rpcs/TransportPCEServicePathRPCImpl.java | 4 +- .../renderer/stub/MountPointStub.java | 13 +- 15 files changed, 347 insertions(+), 292 deletions(-) diff --git a/renderer/pom.xml b/renderer/pom.xml index ad1a6efed..b4838f218 100644 --- a/renderer/pom.xml +++ b/renderer/pom.xml @@ -46,10 +46,4 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - - - - false - - diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/ModelMappingUtils.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/ModelMappingUtils.java index 048c9dcdc..8c83cddb6 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/ModelMappingUtils.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/ModelMappingUtils.java @@ -8,6 +8,7 @@ package org.opendaylight.transportpce.renderer; import com.google.common.util.concurrent.ListenableFuture; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -39,6 +40,8 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + + public final class ModelMappingUtils { private static final Logger LOG = LoggerFactory.getLogger(ModelMappingUtils.class); @@ -50,8 +53,12 @@ public final class ModelMappingUtils { public static ServicePowerSetupInput createServicePowerSetupInput(List olmList, ServiceImplementationRequestInput input) { ServicePowerSetupInputBuilder olmSetupBldr = new ServicePowerSetupInputBuilder() - .setNodes(olmList) - .setWaveNumber(input.getPathDescription().getAToZDirection().getAToZWavelengthNumber()); + .setNodes(olmList); + if (input != null && input.getPathDescription() != null + && input.getPathDescription().getAToZDirection() != null) { + olmSetupBldr.setWaveNumber( + input.getPathDescription().getAToZDirection().getAToZWavelengthNumber()); + } return olmSetupBldr.build(); } @@ -147,44 +154,22 @@ public final class ModelMappingUtils { } int[] pos = findTheLongestSubstring(nodeID, tpID); - //TODO: do not rely on nodeId to be integer - int id = Integer.parseInt(sortId); - treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID)); - } else if (resourceType.equals("Link")) { + if (pos != null) { + //TODO: do not rely on nodeId to be integer + int id = Integer.parseInt(sortId); + treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID)); + } + } else if ("Link".equals(resourceType)) { LOG.info("The type is link"); } else { LOG.info("The type is not indentified: {}", resourceType); } } catch (IllegalArgumentException | SecurityException e) { - // TODO Auto-generated catch block LOG.error("Dont find the getResource method", e); } } - String desID = null; - String srcID = null; - for (NodeIdPair values : treeMap.values()) { - if (srcID == null) { - srcID = values.getTpID(); - } else if (desID == null) { - desID = values.getTpID(); - NodesBuilder nb = new NodesBuilder() - .withKey(new NodesKey(values.getNodeID())) - .setDestTp(desID) - .setSrcTp(srcID); - list.add(nb.build()); - - NodesBuilder olmNb = new NodesBuilder() - .setNodeId(values.getNodeID()) - .setDestTp(desID) - .setSrcTp(srcID); - olmList.add(olmNb.build()); - srcID = null; - desID = null; - } else { - LOG.warn("both, the source and destination id are null!"); - } - } + populateNodeLists(treeMap, list, olmList); return new NodeLists(olmList, list); } @@ -223,10 +208,12 @@ public final class ModelMappingUtils { } int[] pos = findTheLongestSubstring(nodeID, tpID); - //TODO: do not rely on nodeId to be integer - int id = Integer.parseInt(sortId); - treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID)); - } else if (resourceType.equals("Link")) { + if (pos != null) { + //TODO: do not rely on nodeId to be integer + int id = Integer.parseInt(sortId); + treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID)); + } + } else if ("Link".equals(resourceType)) { LOG.info("The type is link"); } else { LOG.info("The type is not indentified: {}", resourceType); @@ -237,6 +224,16 @@ public final class ModelMappingUtils { } } + populateNodeLists(treeMap, list, olmList); + return new NodeLists(olmList, list); + } + + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + value = {"NP_LOAD_OF_KNOWN_NULL_VALUE","RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"}, + justification = "loop when value is not always null - " + + "TODO: check if something exists in Java lib") + private static void populateNodeLists(Map treeMap, + List list, List olmList) { String desID = null; String srcID = null; for (NodeIdPair values : treeMap.values()) { @@ -261,9 +258,12 @@ public final class ModelMappingUtils { LOG.warn("both, the source and destination id are null!"); } } - return new NodeLists(olmList, list); } + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + value = "PZLA_PREFER_ZERO_LENGTH_ARRAYS", + justification = "not relevant to return and zero length array" + + " as we need real pos") public static int[] findTheLongestSubstring(String s1, String s2) { if ((s1 == null) || (s2 == null)) { return null; diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface121.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface121.java index 3f6bf10ca..b20ef8e24 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface121.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface121.java @@ -22,7 +22,6 @@ import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfa import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.Mapping; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.PowerDBm; - import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice; @@ -33,7 +32,6 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev16 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.Interface1; import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.Interface1Builder; import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.ethernet.container.EthernetBuilder; - import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.EthernetCsmacd; import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.InterfaceType; import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OpenROADMOpticalMultiplex; @@ -59,9 +57,11 @@ import org.slf4j.LoggerFactory; public class OpenRoadmInterface121 { + private static final String MAPPING_MSG_ERROR = + "Unable to get mapping from PortMapping for node % and logical connection port %s"; private final PortMapping portMapping; private final OpenRoadmInterfaces openRoadmInterfaces; - private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterfaceFactory.class); + private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterface121.class); public OpenRoadmInterface121(PortMapping portMapping, OpenRoadmInterfaces openRoadmInterfaces) { this.portMapping = portMapping; @@ -72,9 +72,7 @@ public class OpenRoadmInterface121 { throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format( - "Unable to get mapping from PortMapping for node % and logical connection port %s", - nodeId, logicalConnPoint)); + throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint)); } // Ethernet interface specific data @@ -129,9 +127,7 @@ public class OpenRoadmInterface121 { throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format( - "Unable to get mapping from PortMapping for node % and logical connection port %s", - nodeId, logicalConnPoint)); + throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint)); } // Create generic interface InterfaceBuilder otuInterfaceBldr = createGenericInterfaceBuilder(portMap, OtnOtu.class, logicalConnPoint @@ -171,9 +167,7 @@ public class OpenRoadmInterface121 { throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format( - "Unable to get mapping from PortMapping for node % and logical connection port %s", - nodeId, logicalConnPoint)); + throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint)); } InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint + "-ODU"); diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface221.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface221.java index 6d798f2fb..56da91256 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface221.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface221.java @@ -11,6 +11,7 @@ package org.opendaylight.transportpce.renderer.openroadminterface; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Optional; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; @@ -449,7 +450,7 @@ public class OpenRoadmInterface221 { OduBuilder oduIfBuilder = new OduBuilder() .setRate(ODU4.class) .setMonitoringMode(OduAttributes.MonitoringMode.Terminated); - if (!nodeId.toLowerCase().contains("eci")) { + if (!nodeId.toLowerCase(Locale.getDefault()).contains("eci")) { oduIfBuilder.setTxDapi(""); oduIfBuilder.setTxSapi(""); } diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java index cf8380386..4f43adc39 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java @@ -21,6 +21,8 @@ import org.slf4j.LoggerFactory; public class OpenRoadmInterfaceFactory { + private static final String OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG = + "OTN funtions are not supported by Openroadm models 1.2.1"; private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterfaceFactory.class); private final MappingUtils mappingUtils; private final OpenRoadmInterface121 openRoadmInterface121; @@ -161,7 +163,7 @@ public class OpenRoadmInterfaceFactory { } } - public boolean isUsedbyXc(String nodeId, String interfaceName, String xc, + public boolean isUsedByXc(String nodeId, String interfaceName, String xc, DeviceTransactionManager deviceTransactionManager) { switch (mappingUtils.getOpenRoadmVersion(nodeId)) { case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1: @@ -173,11 +175,11 @@ public class OpenRoadmInterfaceFactory { } } - public boolean isUsedbyOtnXc(String nodeId, String interfaceName, String xc, + public boolean isUsedByOtnXc(String nodeId, String interfaceName, String xc, DeviceTransactionManager deviceTransactionManager) { switch (mappingUtils.getOpenRoadmVersion(nodeId)) { case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1: - LOG.error("OTN funtions are not supported by Openroadm models 1.2.1"); + LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG); return false; case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1: return openRoadmInterface221.isUsedByOtnXc(nodeId, interfaceName, xc, deviceTransactionManager); @@ -190,7 +192,7 @@ public class OpenRoadmInterfaceFactory { String logicalConnPoint) throws OpenRoadmInterfaceException { switch (mappingUtils.getOpenRoadmVersion(nodeId)) { case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1: - LOG.error("OTN funtions are not supported by Openroadm models 1.2.1"); + LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG); return null; case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1: return openRoadmOtnInterface.createOpenRoadmEth1GInterface(nodeId, logicalConnPoint); @@ -203,7 +205,7 @@ public class OpenRoadmInterfaceFactory { String logicalConnPoint) throws OpenRoadmInterfaceException { switch (mappingUtils.getOpenRoadmVersion(nodeId)) { case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1: - LOG.error("OTN funtions are not supported by Openroadm models 1.2.1"); + LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG); return null; case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1: return openRoadmOtnInterface.createOpenRoadmEth10GInterface(nodeId, logicalConnPoint); @@ -218,7 +220,7 @@ public class OpenRoadmInterfaceFactory { throws OpenRoadmInterfaceException { switch (mappingUtils.getOpenRoadmVersion(nodeId)) { case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1: - LOG.error("OTN funtions are not supported by Openroadm models 1.2.1"); + LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG); return null; case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1: return openRoadmOtnInterface.createOpenRoadmOdu0Interface( @@ -233,7 +235,7 @@ public class OpenRoadmInterfaceFactory { throws OpenRoadmInterfaceException { switch (mappingUtils.getOpenRoadmVersion(nodeId)) { case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1: - LOG.error("OTN funtions are not supported by Openroadm models 1.2.1"); + LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG); return null; case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1: return openRoadmOtnInterface.createOpenRoadmOdu2Interface( @@ -248,7 +250,7 @@ public class OpenRoadmInterfaceFactory { throws OpenRoadmInterfaceException { switch (mappingUtils.getOpenRoadmVersion(nodeId)) { case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1: - LOG.error("OTN funtions are not supported by Openroadm models 1.2.1"); + LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG); return null; case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1: return openRoadmOtnInterface.createOpenRoadmOdu2eInterface( diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmOtnInterface221.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmOtnInterface221.java index a20f833ba..538bd2ee8 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmOtnInterface221.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmOtnInterface221.java @@ -43,98 +43,98 @@ public class OpenRoadmOtnInterface221 { private final PortMapping portMapping; private final OpenRoadmInterfaces openRoadmInterfaces; - private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnInterface221.class); + private static final Logger LOG = LoggerFactory + .getLogger(OpenRoadmOtnInterface221.class); - public OpenRoadmOtnInterface221(PortMapping portMapping, OpenRoadmInterfaces openRoadmInterfaces) { + public OpenRoadmOtnInterface221(PortMapping portMapping, + OpenRoadmInterfaces openRoadmInterfaces) { this.portMapping = portMapping; this.openRoadmInterfaces = openRoadmInterfaces; } - public String createOpenRoadmEth1GInterface(String nodeId, String logicalConnPoint) - throws OpenRoadmInterfaceException { + public String createOpenRoadmEth1GInterface(String nodeId, + String logicalConnPoint) throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format( - "Unable to get mapping from PortMapping for node % and logical connection port %s", - nodeId, logicalConnPoint)); + throwException(nodeId, logicalConnPoint); } // Ethernet interface specific data EthernetBuilder ethIfBuilder = new EthernetBuilder(); - //ethIfBuilder.setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled); ethIfBuilder.setSpeed(1000L); - InterfaceBuilder ethInterfaceBldr = - createGenericInterfaceBuilder(portMap, EthernetCsmacd.class, logicalConnPoint + "-ETHERNET1G"); + InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder( + portMap, EthernetCsmacd.class, + logicalConnPoint + "-ETHERNET1G"); // Create Interface1 type object required for adding as augmentation - Interface1Builder ethIf1Builder = new Interface1Builder(); - ethInterfaceBldr.addAugmentation(Interface1.class, ethIf1Builder.setEthernet(ethIfBuilder.build()).build()); + Interface1Builder ethIf1Builder = new Interface1Builder(); + ethInterfaceBldr.addAugmentation(Interface1.class, + ethIf1Builder.setEthernet(ethIfBuilder.build()).build()); // Post interface on the device this.openRoadmInterfaces.postOTNInterface(nodeId, ethInterfaceBldr); // Post the equipment-state change on the device circuit-pack - this.openRoadmInterfaces.postOTNEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true); - this.portMapping.updateMapping(nodeId,portMap); + this.openRoadmInterfaces.postOTNEquipmentState(nodeId, + portMap.getSupportingCircuitPackName(), true); + this.portMapping.updateMapping(nodeId, portMap); String ethernetInterfaceName = ethInterfaceBldr.getName(); return ethernetInterfaceName; } + private void throwException(String nodeId, String logicalConnPoint) + throws OpenRoadmInterfaceException { + throw new OpenRoadmInterfaceException(String.format( + "Unable to get mapping from PortMapping for node % and logical connection port %s", + nodeId, logicalConnPoint)); + } + private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap, Class type, String key) { InterfaceBuilder interfaceBuilder = new InterfaceBuilder() - //.setDescription(" TBD ") - //.setCircuitId(" TBD ") - .setSupportingCircuitPackName(portMap.getSupportingCircuitPackName()) - .setSupportingPort(portMap.getSupportingPort()) - .setAdministrativeState(AdminStates.InService) - //TODO get rid of unchecked cast warning - .setType( - (Class) - type - ) - .setName(key) - .withKey(new InterfaceKey(key)); + // .setDescription(" TBD ") + // .setCircuitId(" TBD ") + .setSupportingCircuitPackName( + portMap.getSupportingCircuitPackName()) + .setSupportingPort(portMap.getSupportingPort()) + .setAdministrativeState(AdminStates.InService) + // TODO get rid of unchecked cast warning + .setType(type).setName(key).withKey(new InterfaceKey(key)); return interfaceBuilder; } - public String createOpenRoadmEth10GInterface(String nodeId, String logicalConnPoint) - throws OpenRoadmInterfaceException { + public String createOpenRoadmEth10GInterface(String nodeId, + String logicalConnPoint) throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException( - String.format( - "Unable to get mapping from PortMapping for node % and logical connection port %s", - nodeId, logicalConnPoint)); + throwException(nodeId, logicalConnPoint); } // Ethernet interface specific data EthernetBuilder ethIfBuilder = new EthernetBuilder() - //.setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled) - .setSpeed(10000L); + // .setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled) + .setSpeed(10000L); // Create Interface1 type object required for adding as augmentation - Interface1Builder ethIf1Builder = new Interface1Builder(); - InterfaceBuilder ethInterfaceBldr = - createGenericInterfaceBuilder(portMap, EthernetCsmacd.class, logicalConnPoint + "-ETHERNET10G") - .addAugmentation(Interface1.class, ethIf1Builder.setEthernet(ethIfBuilder.build()).build()); + Interface1Builder ethIf1Builder = new Interface1Builder(); + InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder(portMap, EthernetCsmacd.class, + logicalConnPoint + "-ETHERNET10G").addAugmentation(Interface1.class, + ethIf1Builder.setEthernet(ethIfBuilder.build()).build()); // Post interface on the device this.openRoadmInterfaces.postOTNInterface(nodeId, ethInterfaceBldr); // Post the equipment-state change on the device circuit-pack - this.openRoadmInterfaces.postOTNEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true); - this.portMapping.updateMapping(nodeId,portMap); + this.openRoadmInterfaces.postOTNEquipmentState(nodeId, + portMap.getSupportingCircuitPackName(), true); + this.portMapping.updateMapping(nodeId, portMap); String ethernetInterfaceName = ethInterfaceBldr.getName(); return ethernetInterfaceName; } - - public String createOpenRoadmOdu2eInterface( - String nodeId, String logicalConnPoint, String serviceName, - String payLoad, boolean isNetworkPort, int tribPortNumber, int tribSlotIndex) + public String createOpenRoadmOdu2eInterface(String nodeId, + String logicalConnPoint, String serviceName, String payLoad, + boolean isNetworkPort, int tribPortNumber, int tribSlotIndex) throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format( - "Unable to get mapping from PortMapping for node % and logical connection port %s", - nodeId, logicalConnPoint)); + throwException(nodeId, logicalConnPoint); } String supportingInterface = null; @@ -146,34 +146,33 @@ public class OpenRoadmOtnInterface221 { if (supportingInterface == null) { throw new OpenRoadmInterfaceException( - "Interface Creation failed because of missing supported ODU4 on network end or Eth iface on client"); + "Interface Creation failed because of missing supported " + + "ODU4 on network end or Eth iface on client"); } - InterfaceBuilder oduInterfaceBldr = - createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint + "-ODU2e-" + serviceName) - .setSupportingInterface(supportingInterface); + InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder( + portMap, OtnOdu.class, + logicalConnPoint + "-ODU2e-" + serviceName) + .setSupportingInterface(supportingInterface); // ODU interface specific data - OduBuilder oduIfBuilder = new OduBuilder() - .setRate(ODU2e.class) - .setOduFunction(ODUTTPCTP.class) - .setMonitoringMode(OduAttributes.MonitoringMode.Terminated); - LOG.debug("Inside the ODU2e creation {} {} {}",isNetworkPort,tribPortNumber,tribSlotIndex); + OduBuilder oduIfBuilder = new OduBuilder().setRate(ODU2e.class) + .setOduFunction(ODUTTPCTP.class) + .setMonitoringMode(OduAttributes.MonitoringMode.Terminated); + LOG.debug("Inside the ODU2e creation {} {} {}", isNetworkPort, + tribPortNumber, tribSlotIndex); if (isNetworkPort) { List tribSlots = new ArrayList<>(); Uint16 newIdx = Uint16.valueOf(tribSlotIndex); tribSlots.add(newIdx); - IntStream.range(tribSlotIndex, tribSlotIndex + 8).forEach( - nbr -> tribSlots.add(Uint16.valueOf(nbr)) - ); + IntStream.range(tribSlotIndex, tribSlotIndex + 8) + .forEach(nbr -> tribSlots.add(Uint16.valueOf(nbr))); ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder() - .setTribPortNumber(tribPortNumber) - .setTribSlots(tribSlots); + .setTribPortNumber(tribPortNumber).setTribSlots(tribSlots); oduIfBuilder.setOduFunction(ODUCTP.class) .setMonitoringMode(OduAttributes.MonitoringMode.Monitored) .setParentOduAllocation(parentOduAllocationBuilder.build()); - } - else { + } else { // Set Opu attributes OpuBuilder opuBldr = new OpuBuilder() .setPayloadType(new PayloadTypeDef(payLoad)) @@ -182,8 +181,9 @@ public class OpenRoadmOtnInterface221 { } // Create Interface1 type object required for adding as augmentation // TODO look at imports of different versions of class - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder oduIf1Builder = - new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder(); + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder + oduIf1Builder = new + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder(); oduInterfaceBldr.addAugmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class, oduIf1Builder.setOdu(oduIfBuilder.build()).build()); @@ -194,8 +194,9 @@ public class OpenRoadmOtnInterface221 { return oduInterfaceBldr.getName(); } - public String createOpenRoadmOdu0Interface(String nodeId, String logicalConnPoint, - String serviceName, String payLoad, boolean isNetworkPort, int tribPortNumber, int tribSlot) + public String createOpenRoadmOdu0Interface(String nodeId, + String logicalConnPoint, String serviceName, String payLoad, + boolean isNetworkPort, int tribPortNumber, int tribSlot) throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); String supportingInterface = null; @@ -206,27 +207,25 @@ public class OpenRoadmOtnInterface221 { supportingInterface = logicalConnPoint + "-ETHERNET1G"; } if (portMap == null) { - throw new OpenRoadmInterfaceException(String.format( - "Unable to get mapping from PortMapping for node % and logical connection port %s", - nodeId, logicalConnPoint)); + throwException(nodeId, logicalConnPoint); } - InterfaceBuilder oduInterfaceBldr = - createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint + "-ODU0-" + serviceName); + InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder( + portMap, OtnOdu.class, + logicalConnPoint + "-ODU0-" + serviceName); oduInterfaceBldr.setSupportingInterface(supportingInterface); // ODU interface specific data - OduBuilder oduIfBuilder = new OduBuilder() - .setRate(ODU0.class) - .setOduFunction(ODUTTPCTP.class) - .setMonitoringMode(OduAttributes.MonitoringMode.Terminated); + OduBuilder oduIfBuilder = new OduBuilder().setRate(ODU0.class) + .setOduFunction(ODUTTPCTP.class) + .setMonitoringMode(OduAttributes.MonitoringMode.Terminated); if (isNetworkPort) { LOG.debug("Network port is true"); List tribSlots = new ArrayList<>(); - tribSlots.add(Uint16.valueOf(tribSlot)); //add trib slots + // add trib slots + tribSlots.add(Uint16.valueOf(tribSlot)); ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder() - //set trib port numbers - .setTribPortNumber(tribPortNumber) - .setTribSlots(tribSlots); + // set trib port numbers + .setTribPortNumber(tribPortNumber).setTribSlots(tribSlots); oduIfBuilder.setOduFunction(ODUCTP.class) .setMonitoringMode(OduAttributes.MonitoringMode.Monitored) .setParentOduAllocation(parentOduAllocationBuilder.build()); @@ -234,8 +233,7 @@ public class OpenRoadmOtnInterface221 { oduIfBuilder.getParentOduAllocation().getTribSlots(), oduIfBuilder.getRate(), oduIfBuilder.getParentOduAllocation().getTribPortNumber()); - } - else { + } else { LOG.debug("Current port is a client port"); OpuBuilder opuBldr = new OpuBuilder() .setPayloadType(new PayloadTypeDef(payLoad)) @@ -244,8 +242,9 @@ public class OpenRoadmOtnInterface221 { } // Create Interface1 type object required for adding as augmentation // TODO look at imports of different versions of class - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder oduIf1Builder = - new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder(); + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder + oduIf1Builder = new + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder(); oduInterfaceBldr.addAugmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class, oduIf1Builder.setOdu(oduIfBuilder.build()).build()); @@ -256,46 +255,41 @@ public class OpenRoadmOtnInterface221 { return oduInterfaceBldr.getName(); } - - public String createOpenRoadmOdu2Interface( - String nodeId, String logicalConnPoint, String serviceName, - String payLoad, boolean isNetworkPort, int tribPortNumber, int tribSlotIndex) + public String createOpenRoadmOdu2Interface(String nodeId, + String logicalConnPoint, String serviceName, String payLoad, + boolean isNetworkPort, int tribPortNumber, int tribSlotIndex) throws OpenRoadmInterfaceException { Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint); String supportingInterface = null; - if (isNetworkPort) { - supportingInterface = portMap.getSupportingOdu4(); + if (portMap != null) { + if (isNetworkPort) { + supportingInterface = portMap.getSupportingOdu4(); + } else { + supportingInterface = portMap.getSupportingEthernet(); + } } else { - supportingInterface = portMap.getSupportingEthernet(); - } - if (portMap == null) { - throw new OpenRoadmInterfaceException( - String.format("Unable to get mapping from PortMapping for node % and logical connection port %s", - nodeId, logicalConnPoint)); + throwException(nodeId, logicalConnPoint); } - InterfaceBuilder oduInterfaceBldr = - createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint + "-ODU2-" + serviceName) - .setSupportingInterface(supportingInterface); + InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder( + portMap, OtnOdu.class, + logicalConnPoint + "-ODU2-" + serviceName) + .setSupportingInterface(supportingInterface); - OduBuilder oduIfBuilder = new OduBuilder() - .setRate(ODU2.class) - .setOduFunction(ODUTTPCTP.class) - .setMonitoringMode(OduAttributes.MonitoringMode.Terminated); + OduBuilder oduIfBuilder = new OduBuilder().setRate(ODU2.class) + .setOduFunction(ODUTTPCTP.class) + .setMonitoringMode(OduAttributes.MonitoringMode.Terminated); if (isNetworkPort) { List tribSlots = new ArrayList<>(); - IntStream.range(tribSlotIndex, tribSlotIndex + 8).forEach( - nbr -> tribSlots.add(Uint16.valueOf(nbr)) - ); + IntStream.range(tribSlotIndex, tribSlotIndex + 8) + .forEach(nbr -> tribSlots.add(Uint16.valueOf(nbr))); ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder() - //set trib port numbers - .setTribPortNumber(tribPortNumber) - .setTribSlots(tribSlots); + // set trib port numbers + .setTribPortNumber(tribPortNumber).setTribSlots(tribSlots); oduIfBuilder.setOduFunction(ODUCTP.class) .setMonitoringMode(OduAttributes.MonitoringMode.Monitored) .setParentOduAllocation(parentOduAllocationBuilder.build()); - } - else { + } else { // Set Opu attributes OpuBuilder opuBldr = new OpuBuilder() .setPayloadType(new PayloadTypeDef(payLoad)) @@ -307,8 +301,9 @@ public class OpenRoadmOtnInterface221 { // TODO look at imports of different versions of class // Create Interface1 type object required for adding as augmentation // TODO look at imports of different versions of class - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder oduIf1Builder = - new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder(); + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder + oduIf1Builder = new + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder(); oduInterfaceBldr.addAugmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class, oduIf1Builder.setOdu(oduIfBuilder.build()).build()); diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java index cf24125a9..bbac76c26 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java @@ -9,6 +9,7 @@ package org.opendaylight.transportpce.renderer.provisiondevice; import com.google.common.collect.Sets; import com.google.common.util.concurrent.FluentFuture; + import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -22,6 +23,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; + import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.ReadTransaction; @@ -68,7 +70,10 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + + public class DeviceRendererServiceImpl implements DeviceRendererService { + private static final String ODU4 = "-ODU4"; private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererServiceImpl.class); private final DataBroker dataBroker; private final DeviceTransactionManager deviceTransactionManager; @@ -241,7 +246,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { private ConcurrentLinkedQueue processErrorMessage(String message, ForkJoinPool forkJoinPool, ConcurrentLinkedQueue messages) { - LOG.warn(message); + LOG.warn("Received error message {}", message); messages.add(message); forkJoinPool.shutdown(); return messages; @@ -276,51 +281,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { } // if the node is currently mounted then proceed. if (this.deviceTransactionManager.isDeviceMounted(nodeId)) { - if (destTp.contains(StringConstants.NETWORK_TOKEN) - || srcTp.contains(StringConstants.CLIENT_TOKEN) - || srcTp.contains(StringConstants.NETWORK_TOKEN) - || destTp.contains(StringConstants.CLIENT_TOKEN)) { - if (destTp.contains(StringConstants.NETWORK_TOKEN)) { - try { - if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODU").isPresent()) { - interfacesToDelete.add(destTp + "-ODU"); - } - if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODU4").isPresent()) { - interfacesToDelete.add(destTp + "-ODU4"); - } - } - catch (OpenRoadmInterfaceException e) { - LOG.error("impossible to get interface {} or {}", destTp + "-ODU", destTp + "-ODU4", e); - } - interfacesToDelete.add(destTp + "-OTU"); - interfacesToDelete.add( - this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber)); - } - if (srcTp.contains(StringConstants.NETWORK_TOKEN)) { - interfacesToDelete.add(srcTp + "-ODU"); - interfacesToDelete.add(srcTp + "-OTU"); - interfacesToDelete - .add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber)); - } - if (srcTp.contains(StringConstants.CLIENT_TOKEN)) { - interfacesToDelete.add(srcTp + "-ETHERNET"); - } - if (destTp.contains(StringConstants.CLIENT_TOKEN)) { - interfacesToDelete.add(destTp + "-ETHERNET"); - } - } else { - String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber; - List intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, false); - connectionNumber = destTp + "-" + srcTp + "-" + waveNumber; - if (intToDelete != null) { - for (String interf : intToDelete) { - if (!this.openRoadmInterfaceFactory.isUsedbyXc(nodeId, interf, connectionNumber, - this.deviceTransactionManager)) { - interfacesToDelete.add(interf); - } - } - } - } + interfacesToDelete.addAll(getInterfaces2delete(nodeId, srcTp, destTp, waveNumber)); } else { String result = nodeId + " is not mounted on the controller"; results.add(result); @@ -359,6 +320,57 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { } } + private List getInterfaces2delete( + String nodeId, String srcTp, String destTp, Long waveNumber) { + List interfacesToDelete = new LinkedList<>(); + if (destTp.contains(StringConstants.NETWORK_TOKEN) + || srcTp.contains(StringConstants.CLIENT_TOKEN) + || srcTp.contains(StringConstants.NETWORK_TOKEN) + || destTp.contains(StringConstants.CLIENT_TOKEN)) { + if (destTp.contains(StringConstants.NETWORK_TOKEN)) { + try { + if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODU").isPresent()) { + interfacesToDelete.add(destTp + "-ODU"); + } + if (this.openRoadmInterfaces.getInterface(nodeId, destTp + ODU4).isPresent()) { + interfacesToDelete.add(destTp + ODU4); + } + } + catch (OpenRoadmInterfaceException e) { + LOG.error("impossible to get interface {} or {}", destTp + "-ODU", destTp + ODU4, e); + } + interfacesToDelete.add(destTp + "-OTU"); + interfacesToDelete.add( + this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber)); + } + if (srcTp.contains(StringConstants.NETWORK_TOKEN)) { + interfacesToDelete.add(srcTp + "-ODU"); + interfacesToDelete.add(srcTp + "-OTU"); + interfacesToDelete + .add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber)); + } + if (srcTp.contains(StringConstants.CLIENT_TOKEN)) { + interfacesToDelete.add(srcTp + "-ETHERNET"); + } + if (destTp.contains(StringConstants.CLIENT_TOKEN)) { + interfacesToDelete.add(destTp + "-ETHERNET"); + } + } else { + String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber; + List intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, false); + connectionNumber = destTp + "-" + srcTp + "-" + waveNumber; + if (intToDelete != null) { + for (String interf : intToDelete) { + if (!this.openRoadmInterfaceFactory.isUsedByXc(nodeId, interf, connectionNumber, + this.deviceTransactionManager)) { + interfacesToDelete.add(interf); + } + } + } + } + return interfacesToDelete; + } + @Override public RendererRollbackOutput rendererRollback(RendererRollbackInput input) { boolean success = true; @@ -543,7 +555,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { } } else { result = input.getNodeId() + " is not mounted on the controller"; - LOG.warn(result); + LOG.warn("{} is not mounted on the controller",input.getNodeId()); } return output.setResult(result).setSuccess(success).build(); } diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/OtnDeviceRendererServiceImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/OtnDeviceRendererServiceImpl.java index 8bb68e95c..191b1998a 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/OtnDeviceRendererServiceImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/OtnDeviceRendererServiceImpl.java @@ -34,6 +34,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class OtnDeviceRendererServiceImpl implements OtnDeviceRendererService { + private static final String ODU2E = "-ODU2e-"; private static final Logger LOG = LoggerFactory.getLogger(OtnDeviceRendererServiceImpl.class); private final OpenRoadmInterfaceFactory openRoadmInterfaceFactory; private final CrossConnect crossConnect; @@ -107,12 +108,12 @@ public class OtnDeviceRendererServiceImpl implements OtnDeviceRendererService { String connectionNumber = ""; switch (input.getServiceRate()) { case("10G"): - connectionNumber = srcTp + "-ODU2e-" + input.getServiceName() + "-x-" + destTp - + "-ODU2e-" + input.getServiceName(); + connectionNumber = srcTp + ODU2E + input.getServiceName() + "-x-" + destTp + + ODU2E + input.getServiceName(); break; case("1G"): connectionNumber = srcTp + "-ODU0-" + input.getServiceName() + "-x-" + destTp - + "-ODU2e-" + input.getServiceName(); + + ODU2E + input.getServiceName(); break; default: LOG.error("service rate {} not managed yet", input.getServiceRate()); @@ -124,7 +125,7 @@ public class OtnDeviceRendererServiceImpl implements OtnDeviceRendererService { List intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, true); if (intToDelete != null) { for (String interf : intToDelete) { - if (!this.openRoadmInterfaceFactory.isUsedbyOtnXc(nodeId, interf, connectionNumber, + if (!this.openRoadmInterfaceFactory.isUsedByOtnXc(nodeId, interf, connectionNumber, this.deviceTransactionManager)) { interfacesToDelete.add(interf); if (!getSupportedInterface(nodeId, interf).contains("ODU4")) { diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java index cfcb2abc3..3e34805ed 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java @@ -11,6 +11,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; + import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -20,6 +21,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; + import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.ReadTransaction; @@ -68,6 +70,12 @@ import org.slf4j.LoggerFactory; public class RendererServiceOperationsImpl implements RendererServiceOperations { + private static final String DEVICE_RENDERING_ROLL_BACK_MSG = + "Device rendering was not successful! Rendering will be rolled back."; + private static final String OLM_ROLL_BACK_MSG = + "OLM power setup was not successful! Rendering and OLM will be rolled back."; + private static final String RENDERING_DEVICES_A_Z_MSG = "Rendering devices A-Z"; + private static final String TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG = "Turning down power on A-to-Z path"; private static final Logger LOG = LoggerFactory.getLogger(RendererServiceOperationsImpl.class); private static final String FAILED = "Failed"; private static final String OPERATION_FAILED = "Operation Failed"; @@ -127,7 +135,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations deviceRendering(rollbackProcessor, servicePathInputDataAtoZ, servicePathInputDataZtoA); if (rollbackProcessor.rollbackAllIfNecessary() > 0) { sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(), - RpcStatusEx.Failed, "Device rendering was not successful! Rendering will be rolled back."); + RpcStatusEx.Failed, DEVICE_RENDERING_ROLL_BACK_MSG); return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED); } ServicePowerSetupInput olmPowerSetupInputAtoZ = @@ -138,7 +146,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations if (rollbackProcessor.rollbackAllIfNecessary() > 0) { sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(), RpcStatusEx.Failed, - "OLM power setup was not successful! Rendering and OLM will be rolled back."); + OLM_ROLL_BACK_MSG); return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED); } // run service activation test twice - once on source node and once on @@ -174,6 +182,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations }); } + @Override @SuppressWarnings("checkstyle:IllegalCatch") public OperationResult reserveResource(PathDescription pathDescription) { @@ -187,6 +196,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations return OperationResult.ok("Resources reserved successfully in network model"); } + @Override @SuppressWarnings("checkstyle:IllegalCatch") public OperationResult freeResource(PathDescription pathDescription) { @@ -226,9 +236,9 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations ModelMappingUtils.rendererCreateServiceInputZToA(serviceName, pathDescription); // OLM turn down power try { - LOG.debug("Turning down power on A-to-Z path"); + LOG.debug(TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG); sendNotifications(ServicePathNotificationTypes.ServiceDelete, - input.getServiceName(), RpcStatusEx.Pending, "Turning down power on A-to-Z path"); + input.getServiceName(), RpcStatusEx.Pending, TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG); ServicePowerTurndownOutput atozPowerTurndownOutput = olmPowerTurndown(servicePathInputDataAtoZ); // TODO add some flag rather than string if (FAILED.equals(atozPowerTurndownOutput.getResult())) { @@ -273,14 +283,20 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations } + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "call in call() method") private ServicePowerTurndownOutput olmPowerTurndown(ServicePathInputData servicePathInputData) throws InterruptedException, ExecutionException, TimeoutException { - LOG.debug("Turning down power on A-to-Z path"); + LOG.debug(TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG); Future> powerTurndownFuture = this.olmService.servicePowerTurndown( new ServicePowerTurndownInputBuilder(servicePathInputData.getServicePathInput()).build()); return powerTurndownFuture.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).getResult(); } + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "call in call() method") private Optional getPathDescriptionFromDatastore(String serviceName) { InstanceIdentifier pathDescriptionIID = InstanceIdentifier.create(ServicePathList.class) .child(ServicePaths.class, new ServicePathsKey(serviceName)).child(PathDescription.class); @@ -296,12 +312,15 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations } } + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "call in call() method") private List deviceRendering(RollbackProcessor rollbackProcessor, ServicePathInputData servicePathDataAtoZ, ServicePathInputData servicePathDataZtoA) { - LOG.info("Rendering devices A-Z"); + LOG.info(RENDERING_DEVICES_A_Z_MSG); sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending, - "Rendering devices A-Z"); + RENDERING_DEVICES_A_Z_MSG); ListenableFuture atozrenderingFuture = this.executor.submit(new DeviceRenderingTask(this.deviceRenderer, servicePathDataAtoZ, ServicePathDirection.A_TO_Z)); @@ -309,7 +328,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations LOG.info("Rendering devices Z-A"); sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending, - "Rendering devices A-Z"); + RENDERING_DEVICES_A_Z_MSG); ListenableFuture ztoarenderingFuture = this.executor.submit(new DeviceRenderingTask(this.deviceRenderer, servicePathDataZtoA, ServicePathDirection.Z_TO_A)); @@ -321,10 +340,10 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations LOG.info("Waiting for A-Z and Z-A device renderers ..."); renderingResults = renderingCombinedFuture.get(Timeouts.RENDERING_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - LOG.warn("Device rendering was not successful! Rendering will be rolled back.", e); + LOG.warn(DEVICE_RENDERING_ROLL_BACK_MSG, e); sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending, - "Device rendering was not successful! Rendering will be rolled back."); + DEVICE_RENDERING_ROLL_BACK_MSG); //FIXME we can't do rollback here, because we don't have rendering results. return renderingResults; } @@ -338,6 +357,9 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations return renderingResults; } + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "call in call() method") private void olmPowerSetup(RollbackProcessor rollbackProcessor, ServicePowerSetupInput powerSetupInputAtoZ, ServicePowerSetupInput powerSetupInputZtoA) { LOG.info("Olm power setup A-Z"); @@ -359,10 +381,10 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations LOG.info("Waiting for A-Z and Z-A OLM power setup ..."); olmResults = olmFutures.get(Timeouts.OLM_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - LOG.warn("OLM power setup was not successful! Rendering and OLM will be rolled back.", e); + LOG.warn(OLM_ROLL_BACK_MSG, e); sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, powerSetupInputAtoZ.getServiceName(), RpcStatusEx.Pending, - "OLM power setup was not successful! Rendering and OLM will be rolled back."); + OLM_ROLL_BACK_MSG); rollbackProcessor.addTask(new OlmPowerSetupRollbackTask("AtoZOLMTask", true, this.olmService, powerSetupInputAtoZ)); rollbackProcessor.addTask(new OlmPowerSetupRollbackTask("ZtoAOLMTask", true, @@ -376,6 +398,9 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations this.olmService, powerSetupInputZtoA)); } + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "call in call() method") private boolean isServiceActivated(String nodeId, String tpId) { LOG.info("Starting service activation test on node {} and tp {}", nodeId, tpId); for (int i = 0; i < 3; i++) { diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/otn/OtnDeviceOperations.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/otn/OtnDeviceOperations.java index 1fa0da6dc..0914b1362 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/otn/OtnDeviceOperations.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/otn/OtnDeviceOperations.java @@ -8,20 +8,25 @@ package org.opendaylight.transportpce.renderer.provisiondevice.otn; import java.util.List; + +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.CircuitPacks; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.OduSwitchingPools; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.odu.switching.pools.non.blocking.list.PortList; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.capability.rev181019.port.group.restriction.grp.PortGroupRestriction; public interface OtnDeviceOperations { /** * This method checks if the client port can be used or not. - * - * @param nodeID unique identifier of a device * @param circuitPackName circuit pack name of the client port * @param portName port name of the client port * @param capacity rate of the service needed + * @param portGroupRestriction TODO + * * @return String which states whether the client port is valid or not */ - String validateClientPort(String nodeID, String circuitPackName, String portName, String capacity); + String validateClientPort(String circuitPackName, String portName, String capacity, + PortGroupRestriction portGroupRestriction); /** * This method retrieves the possible network ports. @@ -31,9 +36,12 @@ public interface OtnDeviceOperations { *

* @param circuitPackName Circuit pack name of the client port * @param portName port name of the client port + * @param oduSwitchingPools TODO + * @param circuitPacks TODO * @return List of all possible network ports */ - List getPossibleNetworkPorts(String circuitPackName, String portName); + List getPossibleNetworkPorts(String circuitPackName, String portName, + OduSwitchingPools oduSwitchingPools, CircuitPacks circuitPacks); } diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/otn/OtnDeviceOperationsImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/otn/OtnDeviceOperationsImpl.java index 02a45d953..1ff6acb72 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/otn/OtnDeviceOperationsImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/otn/OtnDeviceOperationsImpl.java @@ -7,7 +7,9 @@ */ package org.opendaylight.transportpce.renderer.provisiondevice.otn; +import java.util.ArrayList; import java.util.List; + import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.CircuitPacks; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.pack.Ports; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.OduSwitchingPools; @@ -22,25 +24,30 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.port.capability.rev181019 public class OtnDeviceOperationsImpl implements OtnDeviceOperations { @Override - public String validateClientPort(String nodeID, String circuitPackName, String portName, String capacity) { - - PortGroupRestriction portGroupRestriction = null; //should not be initiated as null - List portBandwidthSharingList = portGroupRestriction.getPortBandwidthSharing(); - for (PortBandwidthSharing portBandwidthSharing: portBandwidthSharingList) { - List portLists = portBandwidthSharing.getPortList(); - for (PortList portList: portLists) { - if (portList.getCircuitPackName().equals(circuitPackName) && portList.getPortName().equals(portName)) { - if (!usageOfOtherPorts(portBandwidthSharing, - getConfigID(portBandwidthSharing, circuitPackName, portName))) { - return "valid port"; - } - else { - return "not a valid port"; + public String validateClientPort(String circuitPackName, String portName, String capacity, + PortGroupRestriction portGroupRestriction) { + + List portBandwidthSharingList = portGroupRestriction + .getPortBandwidthSharing(); + if (portGroupRestriction.getPortBandwidthSharing() != null) { + for (PortBandwidthSharing portBandwidthSharing : portBandwidthSharingList) { + List portLists = portBandwidthSharing.getPortList(); + for (PortList portList : portLists) { + if (portList.getCircuitPackName().equals(circuitPackName) + && portList.getPortName().equals(portName)) { + if (!usageOfOtherPorts(portBandwidthSharing, + getConfigID(portBandwidthSharing, + circuitPackName, portName))) { + return "valid port"; + } else { + return "not a valid port"; + } } } } } - return "not valid circuitPackName or portName"; // if the client port is not found at all throw exception + // if the client port is not found at all throw exception + return "not valid circuitPackName or portName"; } private Integer getConfigID(PortBandwidthSharing portBandwidthSharing, String circuitPackName, String portName) { @@ -55,7 +62,8 @@ public class OtnDeviceOperationsImpl implements OtnDeviceOperations { } } } - return null; // throw exception if not able to get config id + // throw exception if not able to get config id + return null; } @@ -66,14 +74,11 @@ public class OtnDeviceOperationsImpl implements OtnDeviceOperations { @Override public List - getPossibleNetworkPorts(String circuitPackName, String portName) { + getPossibleNetworkPorts(String circuitPackName, String portName, OduSwitchingPools oduSwitchingPools, + CircuitPacks circuitPacks) { List networkPortList = null; - - //need a method to get swtiching pool object from device - - OduSwitchingPools oduSwitchingPools = null; // should not be initiated as null + .pools.non.blocking.list.PortList> networkPortList = new ArrayList<>(); List nonBlockingLists = oduSwitchingPools.getNonBlockingList(); @@ -86,7 +91,7 @@ public class OtnDeviceOperationsImpl implements OtnDeviceOperations { if (port.getCircuitPackName().equals(circuitPackName) && port.getPortName().equals(portName)) { org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device .container.org.openroadm.device.odu.switching.pools.non.blocking.list - .PortList networkPort = checkNetworkPorts(nonBlockingList.getPortList()); + .PortList networkPort = checkNetworkPorts(nonBlockingList.getPortList(), circuitPacks); if (networkPort != null) { networkPortList.add(networkPort); } @@ -100,9 +105,8 @@ public class OtnDeviceOperationsImpl implements OtnDeviceOperations { private org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device .container.org.openroadm.device.odu.switching.pools.non.blocking.list.PortList checkNetworkPorts(List portList) { - CircuitPacks circuitPacks = null; - + .openroadm.device.container.org.openroadm.device.odu.switching.pools.non.blocking.list.PortList> portList, + CircuitPacks circuitPacks) { List circuitPackList = circuitPacks.getCircuitPacks(); @@ -113,7 +117,8 @@ public class OtnDeviceOperationsImpl implements OtnDeviceOperations { return searchNetworkPort(port, circuitPack); } } - return null; // throw exception if no available network ports + // TODO: throw exception if no available network ports + return null; } private org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container @@ -123,12 +128,15 @@ public class OtnDeviceOperationsImpl implements OtnDeviceOperations { org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.packs.CircuitPacks circuitPack) { if (port.getCircuitPackName().equals(circuitPack.getCircuitPackName())) { for (Ports prt : circuitPack.getPorts()) { - if (port.getPortName().equals(prt.getPortName()) && prt.getPortQual().equals("xpdr-network")) { + if (prt.getPortQual() != null + && port.getPortName().equals(prt.getPortName()) + && "xpdr-network".equals(prt.getPortQual().getName())) { return port; } } } - return null; // throw exception + // TODO: throw exception + return null; } diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/DeviceRenderingTask.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/DeviceRenderingTask.java index 018279f43..37fa8e096 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/DeviceRenderingTask.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/DeviceRenderingTask.java @@ -9,6 +9,7 @@ package org.opendaylight.transportpce.renderer.provisiondevice.tasks; import java.util.List; import java.util.concurrent.Callable; + import org.opendaylight.transportpce.renderer.ServicePathInputData; import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService; import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRenderingResult; @@ -37,7 +38,7 @@ public class DeviceRenderingTask implements Callable { public DeviceRenderingResult call() throws Exception { ServicePathOutput output = this.deviceRenderer.setupServicePath(this.servicePathInputData.getServicePathInput(), this.direction); - if (! output.isSuccess()) { + if (!output.isSuccess()) { LOG.warn("Device rendering not successfully finished."); return DeviceRenderingResult.failed("Operation Failed"); } diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java index 6f8df0ddb..2caf1571a 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java @@ -9,6 +9,7 @@ package org.opendaylight.transportpce.renderer.rpcs; import com.google.common.util.concurrent.ListenableFuture; + import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException; import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService; import org.opendaylight.transportpce.renderer.provisiondevice.OtnDeviceRendererService; @@ -66,24 +67,34 @@ public class DeviceRendererRPCImpl implements TransportpceDeviceRendererService */ @Override public ListenableFuture> servicePath(ServicePathInput input) { - if (input.getOperation().getIntValue() == 1) { - LOG.info("Create operation request received"); - return RpcResultBuilder.success(this.deviceRenderer.setupServicePath(input, null)).buildFuture(); - } else if (input.getOperation().getIntValue() == 2) { - LOG.info("Delete operation request received"); - return RpcResultBuilder.success(this.deviceRenderer.deleteServicePath(input)).buildFuture(); + if (input.getOperation() != null) { + if (input.getOperation().getIntValue() == 1) { + LOG.info("Create operation request received"); + return RpcResultBuilder.success( + this.deviceRenderer.setupServicePath(input, null)) + .buildFuture(); + } else if (input.getOperation().getIntValue() == 2) { + LOG.info("Delete operation request received"); + return RpcResultBuilder + .success(this.deviceRenderer.deleteServicePath(input)) + .buildFuture(); + } } return RpcResultBuilder.success(new ServicePathOutputBuilder().setResult("Invalid operation")).buildFuture(); } @Override public ListenableFuture> otnServicePath(OtnServicePathInput input) { - if (input.getOperation().getIntValue() == 1) { - LOG.info("Create operation request received"); - return RpcResultBuilder.success(this.otnDeviceRendererService.setupOtnServicePath(input)).buildFuture(); - } else if (input.getOperation().getIntValue() == 2) { - LOG.info("Delete operation request received"); - return RpcResultBuilder.success(this.otnDeviceRendererService.deleteOtnServicePath(input)).buildFuture(); + if (input.getOperation() != null) { + if (input.getOperation().getIntValue() == 1) { + LOG.info("Create operation request received"); + return RpcResultBuilder.success(this.otnDeviceRendererService + .setupOtnServicePath(input)).buildFuture(); + } else if (input.getOperation().getIntValue() == 2) { + LOG.info("Delete operation request received"); + return RpcResultBuilder.success(this.otnDeviceRendererService + .deleteOtnServicePath(input)).buildFuture(); + } } return RpcResultBuilder.success(new OtnServicePathOutputBuilder().setResult("Invalid operation")).buildFuture(); } diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/TransportPCEServicePathRPCImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/TransportPCEServicePathRPCImpl.java index aa36fc506..b38781ec3 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/TransportPCEServicePathRPCImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/TransportPCEServicePathRPCImpl.java @@ -40,7 +40,7 @@ public class TransportPCEServicePathRPCImpl implements TransportpceRendererServi try { output = this.rendererServiceOperations.serviceDelete(input).get(); } catch (InterruptedException | ExecutionException e) { - LOG.error("RPC service delete failed !"); + LOG.error("RPC service delete failed !", e); } return ModelMappingUtils.createServiceDeleteRpcResponse(output); } @@ -54,7 +54,7 @@ public class TransportPCEServicePathRPCImpl implements TransportpceRendererServi try { output = this.rendererServiceOperations.serviceImplementation(input).get(); } catch (InterruptedException | ExecutionException e) { - LOG.error("RPC service implementation failed !"); + LOG.error("RPC service implementation failed !", e); } return ModelMappingUtils.createServiceImplementationRpcResponse(output); } diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/stub/MountPointStub.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/stub/MountPointStub.java index 11fe43349..639a4d9c3 100644 --- a/renderer/src/test/java/org/opendaylight/transportpce/renderer/stub/MountPointStub.java +++ b/renderer/src/test/java/org/opendaylight/transportpce/renderer/stub/MountPointStub.java @@ -9,14 +9,16 @@ package org.opendaylight.transportpce.renderer.stub; import java.util.Optional; + import javax.annotation.Nonnull; + import org.opendaylight.mdsal.binding.api.BindingService; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.MountPoint; import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class MountPointStub implements MountPoint { +public class MountPointStub implements MountPoint { private DataBroker dataBroker; @@ -26,7 +28,8 @@ public class MountPointStub implements MountPoint { this.dataBroker = dataBroker; } - public void setRpcConsumerRegistry(RpcConsumerRegistry rpcConsumerRegistry) { + public void setRpcConsumerRegistry( + RpcConsumerRegistry rpcConsumerRegistry) { this.rpcConsumerRegistry = rpcConsumerRegistry; } @@ -34,10 +37,10 @@ public class MountPointStub implements MountPoint { @SuppressWarnings("unchecked") public Optional getService(Class service) { if (service.isInstance(dataBroker)) { - return Optional.ofNullable((T)dataBroker); + return Optional.ofNullable((T) dataBroker); } if (service.isInstance(rpcConsumerRegistry)) { - return Optional.ofNullable((T)rpcConsumerRegistry); + return Optional.ofNullable((T) rpcConsumerRegistry); } return Optional.empty(); } @@ -45,6 +48,6 @@ public class MountPointStub implements MountPoint { @Nonnull @Override public InstanceIdentifier getIdentifier() { - return null; + throw new UnsupportedOperationException(); } } -- 2.36.6