import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import javax.sql.DataSource;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.Timeouts;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
import org.opendaylight.transportpce.inventory.query.Queries;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlots;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlotsKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacksKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.ConnectionPorts;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.ConnectionPortsKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.external.links.ExternalLink;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.external.links.ExternalLinkKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
+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.internal.links.InternalLink;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.internal.links.InternalLinkKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.ConnectionMap;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.ConnectionMapKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Degree;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.DegreeKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Info;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Protocols;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroupKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.physical.links.PhysicalLink;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.physical.links.PhysicalLinkKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelf.Slots;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelf.SlotsKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelves.Shelves;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelves.ShelvesKey;
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.ethernet.container.EthernetBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.Protocols1;
import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfig;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfigKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.nbr.list.IfName;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.nbr.list.IfNameKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.och.container.OchBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.ots.container.OtsBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.attributes.Tcm;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.attributes.TcmKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.container.OduBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.ExpMsi;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.ExpMsiKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.RxMsi;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.RxMsiKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.TxMsi;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.TxMsiKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.otu.container.OtuBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.bridge.port.attr.RstpBridgePortTable;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.container.rstp.RstpBridgeInstance;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING",
+ justification = "TODO review the SQL statement generation process")
public class INode221 {
private static final Logger LOG = LoggerFactory.getLogger(INode221.class);
String query = Queries.getQuery().deviceInfoInsert().get();
LOG.info("Running {} query ", query);
try (Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(query)) {
+ PreparedStatement preparedStatement = connection.prepareStatement(query)) {
Object[] prepareParameters = prepareDeviceInfoParameters(deviceInfo);
for (int i = 0; i < prepareParameters.length; i++) {
LOG.debug("Parameter {} has value {}", i + 1, prepareParameters[i]);
persistDevConnectionMap(deviceId, connection);
LOG.debug("iNode persist Connection Map call complete");
- } catch (SQLException e) {
- LOG.error(e.getMessage(), e);
- } catch (InterruptedException e) {
- LOG.error(e.getMessage(), e);
- } catch (ExecutionException e) {
- LOG.error(e.getMessage(), e);
+ } catch (SQLException | InterruptedException | ExecutionException e) {
+ LOG.error("Something wrong when storing node into DB", e);
}
return sqlResult;
}
}
}
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when fetching node in DB", e);
}
return nodeExists == 0 ? false : true;
}
Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-
- LOG.info("Shelves size {}", deviceObject.get().getShelves().size());
+ if (!deviceObject.isPresent()) {
+ LOG.error("No device found in operational datastore for nodeId {}", nodeId);
+ return;
+ }
+ @NonNull
+ Map<ShelvesKey, Shelves> shelvesMap = deviceObject.get().nonnullShelves();
+ LOG.info("Shelves size {}", shelvesMap.size());
try (Connection connection = requireNonNull(dataSource.getConnection())) {
- for (int i = 0; i < deviceObject.get().getShelves().size(); i++) {
- Shelves shelve = deviceObject.get().getShelves().get(i);
+ for (Map.Entry<ShelvesKey, Shelves> entry : shelvesMap.entrySet()) {
+ Shelves shelve = entry.getValue();
String shelfName = shelve.getShelfName();
LOG.info("Getting Shelve Details of {}", shelfName);
persistShelves(nodeId, connection, shelve);
}
} catch (SQLException e1) {
- LOG.error(e1.getMessage(), e1);
+ LOG.error("Something wrong when fetching ROADM shelves in DB", e1);
}
}
LOG.warn("Device object {} was not found", nodeId);
return;
}
- LOG.info("Circuit pack size {}", deviceObject.get().getCircuitPacks().size());
+ @NonNull
+ Map<CircuitPacksKey, CircuitPacks> circuitPacksMap = deviceObject.get().nonnullCircuitPacks();
+ LOG.info("Circuit pack size {}", circuitPacksMap.size());
try (Connection connection = requireNonNull(dataSource.getConnection())) {
- for (int i = 0; i < deviceObject.get().getCircuitPacks().size(); i++) {
- CircuitPacks cp = deviceObject.get().getCircuitPacks().get(i);
+
+ for (Map.Entry<CircuitPacksKey, CircuitPacks> entry : circuitPacksMap.entrySet()) {
+ CircuitPacks cp = entry.getValue();
if (cp.getCpSlots() != null) {
persistCircuitPacksSlots(nodeId, cp, connection);
persistCircuitPacks(nodeId, connection, cp);
}
} catch (SQLException e1) {
- LOG.error(e1.getMessage(), e1);
+ LOG.error("Something wrong when fetching Circuit Packs in DB", e1);
}
}
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing Circuit Packs in DB", e);
}
}
preparedStmt.execute();
preparedStmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing shelves in DB", e);
}
}
private void persistShelveSlots(String nodeId, Shelves shelves, Connection connection) {
String startTimetampStr = getCurrentTimestamp();
- for (int i = 0; i < shelves.getSlots().size(); i++) {
- Slots slot = shelves.getSlots().get(i);
+ @NonNull
+ Map<SlotsKey, Slots> slotsMap = shelves.nonnullSlots();
+ for (Map.Entry<SlotsKey, Slots> entry : slotsMap.entrySet()) {
+ Slots slot = entry.getValue();
LOG.info("Getting Slot Details of {}", slot.getSlotName());
Object[] parameters = new Object[]{nodeId,
shelves.getShelfName(),
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing shelves slots in DB", e);
}
}
}
private void persistCircuitPacksSlots(String nodeId, CircuitPacks circuitPacks, Connection connection) {
String startTimetampStr = getCurrentTimestamp();
- for (int i = 0; i < circuitPacks.getCpSlots().size(); i++) {
- CpSlots cpSlot = circuitPacks.getCpSlots().get(i);
+ @NonNull
+ Map<CpSlotsKey, CpSlots> cpSlotsMap = circuitPacks.nonnullCpSlots();
+ for (Map.Entry<CpSlotsKey, CpSlots> entry : cpSlotsMap.entrySet()) {
+ CpSlots cpSlot = entry.getValue();
Object[] parameters = new Object[]{nodeId,
circuitPacks.getCircuitPackName(),
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing Cirtcuits Packs slots in DB", e);
}
}
}
startTimestamp};
}
-
- private static Object[] prepareCPPortsParameters(String nodeId, CircuitPacks circuitPacks, Ports cpPort) {
-
- String circuitPackName = circuitPacks.getCircuitPackName();
- String portName = cpPort.getPortName();
- String portType = cpPort.getPortType();
- String portQualEnu = String.valueOf(cpPort.getPortQual().getIntValue());
- String portWavelengthTypeEnu = String.valueOf(cpPort.getPortWavelengthType().getIntValue());
- String portDirectionEnu = String.valueOf(cpPort.getPortDirection().getIntValue());
- String label = cpPort.getLabel();
- String circuitId = cpPort.getCircuitId();
- String administrativeStateEnu =
- (cpPort.getAdministrativeState() == null ? "" :
- String.valueOf(cpPort.getAdministrativeState().getIntValue()));
- String operationalStateEnu =
- (cpPort.getOperationalState() == null ? "" : String.valueOf(cpPort.getOperationalState().getIntValue()));
- String logicalConnectionPoint = cpPort.getLogicalConnectionPoint();
- String partnerPortCircuitPackName = cpPort.getPartnerPort().getCircuitPackName();
- String partnerPortPortName = cpPort.getPartnerPort().getPortName().toString();
- String parentPortCircuitPackName = cpPort.getParentPort().getCircuitPackName();
- String parentPortPortName = cpPort.getParentPort().getPortName().toString();
- String roadmPortPortPowerCapabilityMinRx = cpPort.getRoadmPort().getPortPowerCapabilityMinRx().toString();
- String roadmPortPortPowerCapabilityMinTx = cpPort.getRoadmPort().getPortPowerCapabilityMinTx().toString();
- String roadmPortPortPowerCapabilityMaxRx = cpPort.getRoadmPort().getPortPowerCapabilityMaxRx().toString();
- String roadmPortPortPowerCapabilityMaxTx = cpPort.getRoadmPort().getPortPowerCapabilityMaxTx().toString();
- //String roadmPortCapableWavelengths = "";
- //String roadmPortAvailableWavelengths = "";
- //String roadmPortUsedWavelengths = "";
- String transponderPortPortPowerCapabilityMinRx =
- cpPort.getTransponderPort().getPortPowerCapabilityMinRx().toString();
- String transponderPortPortPowerCapabilityMinTx =
- cpPort.getTransponderPort().getPortPowerCapabilityMinTx().toString();
- String transponderPortPortPowerCapabilityMaxRx =
- cpPort.getTransponderPort().getPortPowerCapabilityMaxRx().toString();
- String transponderPortPortPowerCapabilityMaxTx =
- cpPort.getTransponderPort().getPortPowerCapabilityMaxTx().toString();
- //String transponderPortCapableWavelengths = "";
- String otdrPortLaunchCableLength = cpPort.getOtdrPort().getLaunchCableLength().toString();
- String otdrPortPortDirection = String.valueOf(cpPort.getOtdrPort().getPortDirection().getIntValue());
- //String ilaPortPortPowerCapabilityMixRx = "";
- //String ilaPortPortPowerCapabilityMixTx = "";
- //String ilaPortPortPowerCapabilityMaxRx = "";
- //String ilaPortPortPowerCapabilityMaxTx = "";
-
- String startTimestamp = getCurrentTimestamp();
-
- return new Object[]{nodeId,
- circuitPackName,
- portName,
- portType,
- portQualEnu,
- portWavelengthTypeEnu,
- portDirectionEnu,
- label,
- circuitId,
- administrativeStateEnu,
- operationalStateEnu,
- logicalConnectionPoint,
- partnerPortCircuitPackName,
- partnerPortPortName,
- parentPortCircuitPackName,
- parentPortPortName,
- roadmPortPortPowerCapabilityMinRx,
- roadmPortPortPowerCapabilityMinTx,
- roadmPortPortPowerCapabilityMaxRx,
- roadmPortPortPowerCapabilityMaxTx,
- //roadmPortCapableWavelengths,
- //roadmPortAvailableWavelengths,
- //roadmPortUsedWavelengths,
- "", "", "",
- transponderPortPortPowerCapabilityMinRx,
- transponderPortPortPowerCapabilityMinTx,
- transponderPortPortPowerCapabilityMaxRx,
- transponderPortPortPowerCapabilityMaxTx,
- //transponderPortCapableWavelengths,
- "",
- otdrPortLaunchCableLength,
- otdrPortPortDirection,
- //ilaPortPortPowerCapabilityMixRx,
- //ilaPortPortPowerCapabilityMixTx,
- //ilaPortPortPowerCapabilityMaxRx,
- //ilaPortPortPowerCapabilityMaxTx,
- "", "", "", "",
- startTimestamp,
- startTimestamp
- };
- }
-
-
private static Object[] prepareCircuitPacksParameters(String nodeId, CircuitPacks cpack) {
String startTimestamp = getCurrentTimestamp();
return new Object[]{nodeId,
startTimestamp};
}
-
- private void persistCPPorts(String nodeId, Connection connection, CircuitPacks circuitPacks) {
- for (int i = 0; i < circuitPacks.getPorts().size(); i++) {
- Object[] cpPortsParameters = prepareCPPortsParameters(nodeId, circuitPacks, circuitPacks.getPorts().get(i));
- String query = Queries.getQuery().deviceCPPortInsert().get();
- LOG.info("Running {} query ", query);
- try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
- for (int j = 0; j < cpPortsParameters.length; j++) {
- preparedStmt.setObject(j + 1, cpPortsParameters[j]);
- }
- preparedStmt.execute();
- preparedStmt.clearParameters();
- } catch (SQLException e) {
- LOG.error(e.getMessage(), e);
- }
- }
- }
-
-
private Object[] prepareDevInterfaceParameters(String nodeId, Interface deviceInterface, Connection connection) {
int administrativeStateEnu = deviceInterface.getAdministrativeState().getIntValue();
org.opendaylight.yang.gen.v1
.http.org.openroadm.optical.transport.interfaces.rev161014.Interface1.class)
.getOts());
- int otsFiberTypeEnu = otsIfBuilder.getFiberType().getIntValue();
+ //otsFiberTypeEnu = otsIfBuilder.getFiberType().getIntValue();
otsSpanLossReceive = otsIfBuilder.getSpanLossReceive().toString();
otsSpanLossTransmit = otsIfBuilder.getSpanLossTransmit().toString();
break;
persistDevInterfaceOtnOduRxMsi(nodeId, name, oduIfBuilder, connection);
persistDevInterfaceOtnOduExpMsi(nodeId, name, oduIfBuilder, connection);
- opuPayloadType = oduIfBuilder.getOpu().getPayloadType().toString();
- opuRxPayloadType = oduIfBuilder.getOpu().getRxPayloadType().toString();
- opuExpPayloadType = oduIfBuilder.getOpu().getExpPayloadType().toString();
+ opuPayloadType = oduIfBuilder.getOpu().getPayloadType();
+ opuRxPayloadType = oduIfBuilder.getOpu().getRxPayloadType();
+ opuExpPayloadType = oduIfBuilder.getOpu().getExpPayloadType();
opuPayloadInterface = oduIfBuilder.getOpu().getPayloadInterface();
/*persistDevInterfaceOtnOduTxMsi(nodeId,name,oduIfBuilder,connection);
persistDevInterfaceOtnOduRxMsi(nodeId,name,oduIfBuilder,connection);
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, interfaceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); */
- for (int i = 0; i < deviceObject.get().getInterface().size(); i++) {
+ @NonNull
+ Map<InterfaceKey, Interface> interfaceMap = deviceObject.get().nonnullInterface();
+ for (Map.Entry<InterfaceKey, Interface> entry : interfaceMap.entrySet()) {
Interface deviceInterface;
- deviceInterface = deviceObject.get().getInterface().get(i);
+ deviceInterface = entry.getValue();
/*if (interfaceOpt.isPresent()) {
deviceInterface = interfaceOpt.get();
} else {
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices interfaces in DB", e);
}
}
}
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
LOG.error("LLDP subtree is missing");
-
+ return;
}
int adminstatusEnu =
protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getAdminStatus()
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices protocols in DB", e);
}
}
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
LOG.error("LLDP subtree is missing");
-
+ return;
}
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().size(); i++) {
+ @NonNull
+ Map<PortConfigKey, PortConfig> portConfigMap = protocolObject.get()
+ .augmentation(Protocols1.class).getLldp().nonnullPortConfig();
+ for (Map.Entry<PortConfigKey, PortConfig> entry : portConfigMap.entrySet()) {
- PortConfig portConfig =
- protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().get(i);
+ PortConfig portConfig = entry.getValue();
String ifName = portConfig.getIfName();
int adminStatusEnu = portConfig.getAdminStatus().getIntValue();
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices protocols LLDP Port config in DB", e);
}
}
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
LOG.error("LLDP subtree is missing");
-
+ return;
}
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().getIfName()
- .size(); i++) {
+ @NonNull
+ Map<IfNameKey, IfName> ifNameMap = protocolObject.get()
+ .augmentation(Protocols1.class).getLldp().getNbrList().nonnullIfName();
+ for (Map.Entry<IfNameKey, IfName> entry : ifNameMap.entrySet()) {
- IfName ifNameObj =
- protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().getIfName().get(i);
+ IfName ifNameObj = entry.getValue();
String ifName = ifNameObj.getIfName();
String remotesysname = ifNameObj.getRemoteSysName();
String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices protocols LLDP list number in DB", e);
}
}
}
- private void persistDevProtocolRstp(String nodeId, Connection connection) {
-
- InstanceIdentifier<Protocols> protocolsIID =
- InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
- 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) {
- LOG.error("LLDP subtree is missing");
-
- }
- String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < protocolObject.get()
- .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.Protocols1.class)
- .getRstp().getRstpBridgeInstance().size(); i++) {
-
- RstpBridgeInstance rstpBridgeInstance = protocolObject.get()
- .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.Protocols1.class)
- .getRstp().getRstpBridgeInstance().get(i);
- String bridgeName = rstpBridgeInstance.getBridgeName();
- String bridgePriority = rstpBridgeInstance.getRstpConfig().getBridgePriority().toString();
- String shutdown = rstpBridgeInstance.getRstpConfig().getShutdown().toString();
- String holdTime = rstpBridgeInstance.getRstpConfig().getHoldTime().toString();
- String helloTime = rstpBridgeInstance.getRstpConfig().getHelloTime().toString();
- String maxAge = rstpBridgeInstance.getRstpConfig().getMaxAge().toString();
- String forwardDelay = rstpBridgeInstance.getRstpConfig().getForwardDelay().toString();
- String transmitHoldCount = rstpBridgeInstance.getRstpConfig().getTransmitHoldCount().toString();
- String rootBridgePort =
- rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgePort().toString();
- String rootPathCost = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootPathCost().toString();
- String rootBridgePriority =
- rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgePriority().toString();
- String rootBridgeId = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgeId().toString();
- String rootHoldTime = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootHoldTime().toString();
- String rootHelloTime = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootHelloTime().toString();
- String rootMaxAge = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootMaxAge().toString();
- String rootForwardDelay =
- rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootForwardDelay().toString();
- String bridgeId = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getBridgeId().toString();
- String topoChangeCount =
- rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getTopoChangeCount().toString();
- String timeSinceTopoChange =
- rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getTimeSinceTopoChange().toString();
-
- persistDevProtocolRstpBridgePort(nodeId, bridgeName, rstpBridgeInstance, connection);
- persistDevProtocolRstpBridgePortAttr(nodeId, bridgeName, rstpBridgeInstance, connection);
-
- Object[] parameters = {nodeId,
- bridgeName,
- bridgePriority,
- shutdown,
- holdTime,
- helloTime,
- maxAge,
- forwardDelay,
- transmitHoldCount,
- rootBridgePort,
- rootPathCost,
- rootBridgePriority,
- rootBridgeId,
- rootHoldTime,
- rootHelloTime,
- rootMaxAge,
- rootForwardDelay,
- bridgeId,
- topoChangeCount,
- timeSinceTopoChange,
- startTimestamp,
- startTimestamp
- };
-
- String query = Queries.getQuery().deviceProtocolRstpInsert().get();
- LOG.info("Running {} query ", query);
- try (PreparedStatement stmt = connection.prepareStatement(query)) {
- for (int j = 0; j < parameters.length; j++) {
- stmt.setObject(j + 1, parameters[j]);
- }
- stmt.execute();
- stmt.clearParameters();
- } catch (SQLException e) {
- LOG.error(e.getMessage(), e);
- }
-
- }
- }
-
- private void persistDevProtocolRstpBridgePort(String nodeId, String bridgeName,
- RstpBridgeInstance rstpBridgeInstance, Connection connection) {
-
- String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < rstpBridgeInstance.getRstpConfig().getRstpBridgePortTable().size(); i++) {
- RstpBridgePortTable rstpBridgePortTable =
- rstpBridgeInstance.getRstpConfig().getRstpBridgePortTable().get(i);
-
- String ifName = rstpBridgePortTable.getIfname();
- String cost = rstpBridgePortTable.getCost().toString();
- String priority = rstpBridgePortTable.getPriority().toString();
-
- Object[] parameters = {nodeId,
- bridgeName,
- ifName,
- cost,
- priority,
- startTimestamp,
- startTimestamp
- };
-
- String query = Queries.getQuery().deviceProtocolRstpBridgePortInsert().get();
- LOG.info("Running {} query ", query);
- try (PreparedStatement stmt = connection.prepareStatement(query)) {
- for (int j = 0; j < parameters.length; j++) {
- stmt.setObject(j + 1, parameters[j]);
- }
- stmt.execute();
- stmt.clearParameters();
- } catch (SQLException e) {
- LOG.error(e.getMessage(), e);
- }
-
- }
- }
-
- private void persistDevProtocolRstpBridgePortAttr(String nodeId, String bridgeName,
- RstpBridgeInstance rstpBridgeInstance, Connection connection) {
-
- String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < rstpBridgeInstance.getRstpState().getRstpBridgePortAttr().getRstpBridgePortTable().size();
- i++) {
-
- org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.bridge.port.state.attr
- .RstpBridgePortTable rstpBridgePortTableAttr =
- rstpBridgeInstance.getRstpState().getRstpBridgePortAttr().getRstpBridgePortTable().get(i);
-
- String ifName = rstpBridgePortTableAttr.getIfname();
- String bridgePortState = rstpBridgePortTableAttr.getBridgePortState().getName();
- String bridgePortRole = rstpBridgePortTableAttr.getBridgePortRole().getName();
- String bridgePortId = rstpBridgePortTableAttr.getBridgePortId().toString();
- String openEdgeBridgePort = rstpBridgePortTableAttr.getOperEdgeBridgePort().toString();
- String designatedBridgePort = rstpBridgePortTableAttr.getDesignatedBridgePort().toString();
- String designatedBridgeId = rstpBridgePortTableAttr.getDesignatedBridgeid().toString();
-
- Object[] parameters = {nodeId,
- bridgeName,
- ifName,
- bridgePortState,
- bridgePortRole,
- bridgePortId,
- openEdgeBridgePort,
- designatedBridgePort,
- designatedBridgeId,
- startTimestamp,
- startTimestamp
- };
-
- String query = Queries.getQuery().deviceProtocolRstpBridgePortAttrInsert().get();
- LOG.info("Running {} query ", query);
- try (PreparedStatement stmt = connection.prepareStatement(query)) {
- for (int j = 0; j < parameters.length; j++) {
- stmt.setObject(j + 1, parameters[j]);
- }
- stmt.execute();
- stmt.clearParameters();
- } catch (SQLException e) {
- LOG.error(e.getMessage(), e);
- }
-
- }
- }
-
-
private void persistDevInternalLinks(String nodeId, Connection connection) {
InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
Optional<OrgOpenroadmDevice> deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-
+ if (!deviceObject.isPresent()) {
+ LOG.error("Device with node id {} not found", nodeId);
+ return;
+ }
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getInternalLink().size(); i++) {
- InternalLink internalLink = deviceObject.get().getInternalLink().get(i);
+ @NonNull
+ Map<InternalLinkKey, InternalLink> internalLinkMap = deviceObject.get().nonnullInternalLink();
+ for (Map.Entry<InternalLinkKey, InternalLink> entry : internalLinkMap.entrySet()) {
+ InternalLink internalLink = entry.getValue();
String internalLinkName = internalLink.getInternalLinkName();
String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
String sourcePortName = internalLink.getSource().getPortName().toString();
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices internal links", e);
}
}
Optional<OrgOpenroadmDevice> deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-
+ if (!deviceObject.isPresent()) {
+ LOG.error("Device with node id {} not found", nodeId);
+ return;
+ }
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getExternalLink().size(); i++) {
- ExternalLink externalLink = deviceObject.get().getExternalLink().get(i);
+ @NonNull
+ Map<ExternalLinkKey, ExternalLink> externalLinkMap = deviceObject.get().nonnullExternalLink();
+ for (Map.Entry<ExternalLinkKey, ExternalLink> entry : externalLinkMap.entrySet()) {
+ ExternalLink externalLink = entry.getValue();
String externalLinkName = externalLink.getExternalLinkName();
- String sourceNodeId = externalLink.getSource().getNodeId().toString();
+ String sourceNodeId = externalLink.getSource().getNodeId();
String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
- String sourcePortName = externalLink.getSource().getPortName().toString();
- String destinationNodeId = externalLink.getDestination().getNodeId().toString();
+ String sourcePortName = externalLink.getSource().getPortName();
+ String destinationNodeId = externalLink.getDestination().getNodeId();
String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
- String destinationPortName = externalLink.getDestination().getPortName().toString();
+ String destinationPortName = externalLink.getDestination().getPortName();
Object[] parameters = {nodeId,
externalLinkName,
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices external links", e);
}
}
Optional<OrgOpenroadmDevice> deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (!deviceObject.isPresent()) {
+ LOG.error("Device with node id {} not found", nodeId);
+ return;
+ }
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getPhysicalLink().size(); i++) {
- PhysicalLink physicalLink = deviceObject.get().getPhysicalLink().get(i);
+ @NonNull
+ Map<PhysicalLinkKey, PhysicalLink> physicalLinkMap = deviceObject.get().nonnullPhysicalLink();
+ for (Map.Entry<PhysicalLinkKey, PhysicalLink> entry : physicalLinkMap.entrySet()) {
+ PhysicalLink physicalLink = entry.getValue();
String physicalLinkName = physicalLink.getPhysicalLinkName();
String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
String sourcePortName = physicalLink.getSource().getPortName().toString();
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices physical links", e);
}
}
Optional<OrgOpenroadmDevice> deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-
+ if (!deviceObject.isPresent()) {
+ LOG.error("Device with node id {} not found", nodeId);
+ return;
+ }
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getDegree().size(); i++) {
- Degree degree = deviceObject.get().getDegree().get(i);
+ @NonNull
+ Map<DegreeKey, Degree> degreeMap = deviceObject.get().nonnullDegree();
+ for (Map.Entry<DegreeKey, Degree> entry : degreeMap.entrySet()) {
+ Degree degree = entry.getValue();
String degreeNumber = degree.getDegreeNumber().toString();
String maxWavelengths = degree.getMaxWavelengths().toString();
String otdrPortCircuitPackName = degree.getOtdrPort().getCircuitPackName();
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices degrees", e);
}
}
private void persistDevDegreeCircuitPack(String nodeId, Degree degree, String degreeNumber, Connection connection) {
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < degree.getCircuitPacks().size(); i++) {
+ @NonNull
+ Map<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacksKey,
+ org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks>
+ circuitPacksMap = degree.nonnullCircuitPacks();
+ for (Map.Entry<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacksKey,
+ org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks> entry :
+ circuitPacksMap.entrySet()) {
+
- String circuitPackIndex = degree.getCircuitPacks().get(i).getIndex().toString();
- String circuitPackName = degree.getCircuitPacks().get(i).getCircuitPackName();
+ String circuitPackIndex = entry.getValue().getIndex().toString();
+ String circuitPackName = entry.getValue().getCircuitPackName();
Object[] parameters = {nodeId,
degreeNumber,
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices degrees circuit packs", e);
}
}
Connection connection) {
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < degree.getConnectionPorts().size(); i++) {
+ @NonNull
+ Map<ConnectionPortsKey, ConnectionPorts> connectionPortsMap = degree.nonnullConnectionPorts();
+ for (Map.Entry<ConnectionPortsKey, ConnectionPorts> entry : connectionPortsMap.entrySet()) {
- String connectionPortIndex = degree.getConnectionPorts().get(i).getIndex().toString();
- String circuitPackName = degree.getConnectionPorts().get(i).getCircuitPackName();
- String portName = degree.getConnectionPorts().get(i).getPortName().toString();
+ ConnectionPorts connectionPorts = entry.getValue();
+ String connectionPortIndex = connectionPorts.getIndex().toString();
+ String circuitPackName = connectionPorts.getCircuitPackName();
+ String portName = connectionPorts.getPortName().toString();
Object[] parameters = {nodeId,
degreeNumber,
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices degrees connection ports", e);
}
}
Optional<OrgOpenroadmDevice> deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (!deviceObject.isPresent()) {
+ LOG.error("Device with node id {} not found", nodeId);
+ return;
+ }
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getSharedRiskGroup().size(); i++) {
- SharedRiskGroup sharedRiskGroup = deviceObject.get().getSharedRiskGroup().get(i);
+ @NonNull
+ Map<SharedRiskGroupKey, SharedRiskGroup> sharedRiskGroupMap = deviceObject.get().nonnullSharedRiskGroup();
+ for (Map.Entry<SharedRiskGroupKey, SharedRiskGroup> entry : sharedRiskGroupMap.entrySet()) {
+ SharedRiskGroup sharedRiskGroup = entry.getValue();
String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
String srgNumber = sharedRiskGroup.getSrgNumber().toString();
- int wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getIntValue();
+ //int wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getIntValue();
persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
//String currentProvisionedAddDropPorts = "";
//String mcCapSlotWidthGranularity = "";
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices SRG", e);
}
}
Connection connection) {
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < sharedRiskGroup.getCircuitPacks().size(); i++) {
-
- String circuitPackindex = sharedRiskGroup.getCircuitPacks().get(i).getIndex().toString();
- String circuitPackName = sharedRiskGroup.getCircuitPacks().get(i).getCircuitPackName();
+ @NonNull
+ Map<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksKey,
+ org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks>
+ circuitPacksMap = sharedRiskGroup.nonnullCircuitPacks();
+ for (Map.Entry<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksKey,
+ org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks> entry :
+ circuitPacksMap.entrySet()) {
+
+ org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks circuitPack =
+ entry.getValue();
+ String circuitPackindex = circuitPack.getIndex().toString();
+ String circuitPackName = circuitPack.getCircuitPackName();
Object[] parameters = {nodeId,
srgNumber,
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices SRG circuit packs", e);
}
}
Optional<OrgOpenroadmDevice> deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-
+ if (!deviceObject.isPresent()) {
+ LOG.error("Device with node id {} not found", nodeId);
+ return;
+ }
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getRoadmConnections().size(); i++) {
- RoadmConnections roadmConnections = deviceObject.get().getRoadmConnections().get(i);
+ @NonNull
+ Map<RoadmConnectionsKey, RoadmConnections> roadmConnectionsMap = deviceObject.get().nonnullRoadmConnections();
+ for (Map.Entry<RoadmConnectionsKey, RoadmConnections> entry : roadmConnectionsMap.entrySet()) {
+ RoadmConnections roadmConnections = entry.getValue();
int opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getIntValue();
//String connectionName = "";
//String connectionNumber = "";
startTimestamp
};
+
String query = Queries.getQuery().deviceRoadmConnectionsInsert().get();
LOG.info("Running {} query ", query);
try (PreparedStatement stmt = connection.prepareStatement(query)) {
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices ROADM connection ", e);
}
}
Optional<OrgOpenroadmDevice> deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-
+ if (!deviceObject.isPresent()) {
+ LOG.error("Device with node id {} not found", nodeId);
+ return;
+ }
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getConnectionMap().size(); i++) {
- ConnectionMap connectionMap = deviceObject.get().getConnectionMap().get(i);
+ @NonNull
+ Map<ConnectionMapKey, ConnectionMap> connectionMapMap = deviceObject.get().nonnullConnectionMap();
+ for (Map.Entry<ConnectionMapKey, ConnectionMap> entry : connectionMapMap.entrySet()) {
+ ConnectionMap connectionMap = entry.getValue();
String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
String sourceCircuitPackName = connectionMap.getSource().getCircuitPackName();
String sourcePortName = connectionMap.getSource().getCircuitPackName();
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices connection map", e);
}
}
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices wavelength map", e);
}
}
private void persistDevInterfaceTcm(String nodeId, String interfaceName, OduBuilder oduBuilder,
Connection connection) {
- for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
- Tcm tcm;
-
- tcm = oduBuilder.getTcm().get(i);
+ Map<TcmKey, Tcm> tcmMap = oduBuilder.getTcm();
+ for (Map.Entry<TcmKey, Tcm> entry : tcmMap.entrySet()) {
+ Tcm tcm = entry.getValue();
Object[] parameters = prepareDevInterfaceTcmParameters(nodeId, interfaceName, tcm);
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices interface tcm", e);
}
}
}
private void persistDevInterfaceOtnOduTxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
Connection connection) {
-
- for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
- TxMsi txMsi;
-
- txMsi = oduBuilder.getOpu().getMsi().getTxMsi().get(i);
-
+ @Nullable
+ Map<TxMsiKey, TxMsi> txMsi2Map = oduBuilder.getOpu().getMsi().getTxMsi();
+ if (txMsi2Map == null) {
+ LOG.error("Null txMsi2Map for node {}", nodeId);
+ return;
+ }
+ for (Map.Entry<TxMsiKey, TxMsi> entry : txMsi2Map.entrySet()) {
+ TxMsi txMsi = entry.getValue();
Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
String query = Queries.getQuery().deviceInterfaceOtnOduTxMsiInsert().get();
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices interface OTN ODU Tx MSI", e);
}
}
}
private void persistDevInterfaceOtnOduRxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
Connection connection) {
-
- for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
- RxMsi rxMsi;
-
- rxMsi = oduBuilder.getOpu().getMsi().getRxMsi().get(i);
+ @Nullable
+ Map<RxMsiKey, RxMsi> rxMsi2Map = oduBuilder.getOpu().getMsi().getRxMsi();
+ if (rxMsi2Map == null) {
+ LOG.error("Null rxMsi2Map for node {}", nodeId);
+ return;
+ }
+ for (Map.Entry<RxMsiKey, RxMsi> entry : rxMsi2Map.entrySet()) {
+ RxMsi rxMsi = entry.getValue();
Object[] parameters = prepareDevInterfaceOtnOduRxMsiParameters(nodeId, interfaceName, rxMsi);
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices interface OTN ODU Rx MSI", e);
}
}
}
private void persistDevInterfaceOtnOduExpMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
Connection connection) {
-
- for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
- ExpMsi expMsi;
-
- expMsi = oduBuilder.getOpu().getMsi().getExpMsi().get(i);
+ @Nullable
+ Map<ExpMsiKey, ExpMsi> expMsi2Map = oduBuilder.getOpu().getMsi().getExpMsi();
+ if (expMsi2Map == null) {
+ LOG.error("Null expMsi2Map for node {}", nodeId);
+ return;
+ }
+ for (Map.Entry<ExpMsiKey, ExpMsi> entry : expMsi2Map.entrySet()) {
+ ExpMsi expMsi = entry.getValue();
Object[] parameters = prepareDevInterfaceOtnOduExpMsiParameters(nodeId, interfaceName, expMsi);
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices interface OTN ODU Exp MSI", e);
}
}
}