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.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.CpSlotsKey;
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.PortsKey;
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.yang.gen.v1.http.org.openroadm.wavelength.map.rev161014.wavelength.map.g.Wavelengths;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.wavelength.map.rev161014.wavelength.map.g.WavelengthsKey;
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 INode121 {
private static final Logger LOG = LoggerFactory.getLogger(INode121.class);
deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, infoIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
Info deviceInfo;
- if (infoOpt.isPresent()) {
- deviceInfo = infoOpt.get();
- } else {
+ if (!infoOpt.isPresent()) {
LOG.warn("Could not get device info from DataBroker");
return false;
}
+ deviceInfo = infoOpt.get();
boolean sqlResult = false;
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()) {
+ return;
+ }
+ 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> shelveEntry : shelvesMap.entrySet()) {
+ Shelves shelve = shelveEntry.getValue();
String shelfName = shelve.getShelfName();
-
LOG.info("Getting Shelve Details of {}", shelfName);
if (shelve.getSlots() != null) {
LOG.info("Slot Size {} ", shelve.getSlots().size());
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());
+ 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> circuitPackEntry : circuitPacksMap.entrySet()) {
+ CircuitPacks cp = circuitPackEntry.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);
+ Map<SlotsKey, Slots> slotsMap = shelves.nonnullSlots();
+ for (Map.Entry<SlotsKey, Slots> slotEntry : slotsMap.entrySet()) {
+ Slots slot = slotEntry.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);
+ Map<CpSlotsKey, CpSlots> cpSlotsMap = circuitPacks.nonnullCpSlots();
+ for (Map.Entry<CpSlotsKey, CpSlots> cpSlotEntry: cpSlotsMap.entrySet()) {
+ CpSlots cpSlot = cpSlotEntry.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);
}
}
}
- private void persistPorts(CircuitPacks circuitPacks, Connection connection) {
- LOG.warn("Ports are not persisted yet");
- }
-
-
/**
* Prepares parameters for device insert query.
*
cpPort.getOtdrPort().getLaunchCableLength().toString()));
String otdrPortPortDirection = (cpPort.getOtdrPort() == null ? "-1" :
(cpPort.getOtdrPort().getPortDirection() == null ? "-1" :
- Integer.valueOf(cpPort.getOtdrPort().getPortDirection().getIntValue()).toString()));
+ Integer.toString(cpPort.getOtdrPort().getPortDirection().getIntValue())));
//String ilaPortPortPowerCapabilityMixRx = "";
//String ilaPortPortPowerCapabilityMixTx = "";
//String ilaPortPortPowerCapabilityMaxRx = "";
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));
+ @NonNull
+ Map<PortsKey, Ports> nonnullPorts = circuitPacks.nonnullPorts();
+ for (Map.Entry<PortsKey, Ports> entry : nonnullPorts.entrySet()) {
+ Object[] cpPortsParameters = prepareCPPortsParameters(nodeId, circuitPacks, entry.getValue());
String query = Queries.getQuery().deviceCPPortInsert().get();
LOG.info("Running {} query ", query);
try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
preparedStmt.execute();
preparedStmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing Cirtcuits Packs Ports in DB", e);
}
}
}
String maintTestsignalTypeEnu = "";
String otuFecEnu = "";
String otuMaintTypeEnu = "";
- String otsFiberTypeEnu = "";
+ //String otsFiberTypeEnu = "";
String ethernetSpeed = "-1";
String ethernetFec = "";
String ethernetMtu = "-1";
EthernetBuilder ethIfBuilder = new EthernetBuilder(deviceInterface.augmentation(Interface1.class)
.getEthernet());
ethernetSpeed = (ethIfBuilder.getSpeed() == null ? "-1" :
- Integer.valueOf(ethIfBuilder.getSpeed().intValue()).toString());
+ Integer.toString(ethIfBuilder.getSpeed().intValue()));
ethernetFec = ethIfBuilder.getFec().getName();
ethernetDuplexEnu = (ethIfBuilder.getDuplex() == null ? "" : ethIfBuilder.getDuplex().getName());
ethernetMtu = ethIfBuilder.getMtu().toString();
org.opendaylight.yang.gen.v1
.http.org.openroadm.optical.transport.interfaces.rev161014.Interface1.class)
.getOts());
- otsFiberTypeEnu = String.valueOf(otsIfBuilder.getFiberType().getIntValue());
+ //otsFiberTypeEnu = String.valueOf(otsIfBuilder.getFiberType().getIntValue());
otsSpanLossReceive = otsIfBuilder.getSpanLossReceive().toString();
otsSpanLossTransmit = otsIfBuilder.getSpanLossTransmit().toString();
break;
.getOdu());
oduRate = String.valueOf(oduIfBuilder.getRate());
oduMonitoringMode = oduIfBuilder.getMonitoringMode().getName();
- oduProactiveDelayMeasurementEnabled = oduIfBuilder.isProactiveDelayMeasurementEnabled().toString();
+ oduProactiveDelayMeasurementEnabled = oduIfBuilder.getProactiveDelayMeasurementEnabled().toString();
persistDevInterfaceTcm(nodeId, name, oduIfBuilder, connection);
persistDevInterfaceOtnOduTxMsi(nodeId, name, oduIfBuilder, connection);
/*persistDevInterfaceOtnOduTxMsi(nodeId,name,oduIfBuilder,connection);
persistDevInterfaceOtnOduRxMsi(nodeId,name,oduIfBuilder,connection);
persistDevInterfaceOtnOduExpMsi(nodeId,name,oduIfBuilder,connection); */
- maintTestsignalEnabled = oduIfBuilder.getMaintTestsignal().isEnabled().toString();
+ maintTestsignalEnabled = oduIfBuilder.getMaintTestsignal().getEnabled().toString();
maintTestsignalTestpatternEnu = oduIfBuilder.getMaintTestsignal().getTestPattern().getName();
maintTestsignalTypeEnu = oduIfBuilder.getMaintTestsignal().getType().getName();
- maintTestsignalBiterrors = Integer.valueOf(oduIfBuilder.getMaintTestsignal().getBitErrors().intValue())
- .toString();
+ maintTestsignalBiterrors = Integer.toString(
+ oduIfBuilder.getMaintTestsignal().getBitErrors().intValue());
maintTestsignalBiterrorsterminal = oduIfBuilder.getMaintTestsignal().getBitErrorsTerminal().toString();
maintTestsignalSyncseconds = oduIfBuilder.getMaintTestsignal().getSyncSeconds();
maintTestsignalSyncsecondsterminal = oduIfBuilder.getMaintTestsignal().getSyncSecondsTerminal();
.getOtu());
otuRate = otuIfBuilder.getRate().getName();
otuFecEnu = otuIfBuilder.getFec().getName();
- otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().isEnabled().toString();
+ otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().getEnabled().toString();
otuMaintTypeEnu = otuIfBuilder.getMaintLoopback().getType().getName();
break;
String layer = tcm.getLayer().toString();
String monitoringModeEnu = tcm.getMonitoringMode().getName();
- String ltcActEnabled = tcm.isLtcActEnabled().toString();
- String proactiveDelayMeasurementEnabled = tcm.isProactiveDelayMeasurementEnabled().toString();
+ String ltcActEnabled = tcm.getLtcActEnabled().toString();
+ String proactiveDelayMeasurementEnabled = tcm.getProactiveDelayMeasurementEnabled().toString();
//String tcmDirectionEnu = "";
//String timDetectModeEnu = "";
//String txSapi = "";
Optional<OrgOpenroadmDevice> deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-
- /*InstanceIdentifier<Interface> interfaceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(Interface.class);
- Optional<Interface> interfaceOpt =
- 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++) {
- Interface deviceInterface;
-
- deviceInterface = deviceObject.get().getInterface().get(i);
- /*if (interfaceOpt.isPresent()) {
- deviceInterface = interfaceOpt.get();
- } else {
- LOG.warn("Could not get interface info");
- return false;
- }*/
+ if (!deviceObject.isPresent()) {
+ return;
+ }
+ Map<InterfaceKey, Interface> interfaceMap = deviceObject.get().nonnullInterface();
+ for (Map.Entry<InterfaceKey, Interface> interfaceEntrySet : interfaceMap.entrySet()) {
+ Interface deviceInterface = interfaceEntrySet.getValue();
Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
String query = Queries.getQuery().deviceInterfacesInsert().get();
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;
+ }
+ String adminstatusEnu = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
+ .getAdminStatus().getName();
+ String msgTxtInterval = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
+ .getMsgTxInterval().toString();
+ String mxgTxHoldMultiplier = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
+ .getMsgTxHoldMultiplier().toString();
+ String startTimestamp = getCurrentTimestamp();
+ persistDevProtocolLldpPortConfig(nodeId, connection);
+ persistDevProtocolLldpNbrList(nodeId, connection);
- } else {
- String adminstatusEnu = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
- .getAdminStatus().getName();
- String msgTxtInterval = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
- .getMsgTxInterval().toString();
- String mxgTxHoldMultiplier = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
- .getMsgTxHoldMultiplier().toString();
- String startTimestamp = getCurrentTimestamp();
- persistDevProtocolLldpPortConfig(nodeId, connection);
- persistDevProtocolLldpNbrList(nodeId, connection);
-
- Object[] parameters = {nodeId,
- adminstatusEnu,
- msgTxtInterval,
- mxgTxHoldMultiplier,
- startTimestamp,
- startTimestamp
- };
+ Object[] parameters = {nodeId,
+ adminstatusEnu,
+ msgTxtInterval,
+ mxgTxHoldMultiplier,
+ startTimestamp,
+ startTimestamp
+ };
- String query = Queries.getQuery().deviceProtocolInsert().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);
+ String query = Queries.getQuery().deviceProtocolInsert().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("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++) {
- PortConfig portConfig =
- protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().get(i);
+ @NonNull
+ Map<PortConfigKey, PortConfig> portConfigMap = protocolObject.get()
+ .augmentation(Protocols1.class).getLldp().nonnullPortConfig();
+ for (Map.Entry<PortConfigKey, PortConfig> entry : portConfigMap.entrySet()) {
+ PortConfig portConfig = entry.getValue();
String ifName = portConfig.getIfName();
String adminStatusEnu = portConfig.getAdminStatus().getName();
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);
}
}
Optional<Protocols> protocolObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (!protocolObject.isPresent()) {
+ LOG.error("Protocols is missing");
+ return;
+ }
if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
protocolObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, protocolsIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-
- }
- if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
- LOG.error("LLDP nbrlist subtree is missing for {}", nodeId);
-
- } else {
- String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < protocolObject.get()
- .augmentation(Protocols1.class).getLldp().getNbrList().getIfName().size(); i++) {
-
- IfName ifNameObj = protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList()
- .getIfName().get(i);
- String ifName = ifNameObj.getIfName();
- String remotesysname = ifNameObj.getRemoteSysName();
- String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
- String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
- String remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getName();
- String remoteportid = ifNameObj.getRemotePortId();
- String remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getName();
- String remotechassisid = ifNameObj.getRemoteChassisId();
-
- Object[] parameters = {nodeId,
- ifName,
- remotesysname,
- remotemgmtaddresssubtype,
- remotemgmtaddress,
- remoteportidsubtypeEnu,
- remoteportid,
- remotechassisidsubtypeEnu,
- remotechassisid,
- startTimestamp,
- startTimestamp
- };
-
- String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().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);
- }
-
+ if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
+ LOG.error("LLDP nbrlist subtree is missing for {}", nodeId);
+ return;
}
}
- }
-
- 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);
+ Map<IfNameKey, IfName> ifNameMap =
+ protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().nonnullIfName();
+ for (Map.Entry<IfNameKey, IfName> ifNameEntry : ifNameMap.entrySet()) {
+
+ IfName ifNameObj = ifNameEntry.getValue();
+ String ifName = ifNameObj.getIfName();
+ String remotesysname = ifNameObj.getRemoteSysName();
+ String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
+ String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
+ String remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getName();
+ String remoteportid = ifNameObj.getRemotePortId();
+ String remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getName();
+ String remotechassisid = ifNameObj.getRemoteChassisId();
Object[] parameters = {nodeId,
- bridgeName,
- bridgePriority,
- shutdown,
- holdTime,
- helloTime,
- maxAge,
- forwardDelay,
- transmitHoldCount,
- rootBridgePort,
- rootPathCost,
- rootBridgePriority,
- rootBridgeId,
- rootHoldTime,
- rootHelloTime,
- rootMaxAge,
- rootForwardDelay,
- bridgeId,
- topoChangeCount,
- timeSinceTopoChange,
+ ifName,
+ remotesysname,
+ remotemgmtaddresssubtype,
+ remotemgmtaddress,
+ remoteportidsubtypeEnu,
+ remoteportid,
+ remotechassisidsubtypeEnu,
+ remotechassisid,
startTimestamp,
startTimestamp
};
- String query = Queries.getQuery().deviceProtocolRstpInsert().get();
+ String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().get();
LOG.info("Running {} query ", query);
try (PreparedStatement stmt = connection.prepareStatement(query)) {
for (int j = 0; j < parameters.length; j++) {
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 persistDevProtocolRstpBridgePort(String nodeId, String bridgeName,
- RstpBridgeInstance rstpBridgeInstance, Connection connection) {
+ 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()) {
+ return;
+ }
+ if (deviceObject.get().getInternalLink() == null) {
+ deviceObject = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION,
+ deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (deviceObject.get().getInternalLink() == null) {
+ LOG.info("External links not found for {}", nodeId);
+ return;
+ }
+ }
+ @NonNull
+ Map<InternalLinkKey, InternalLink> internalLinkMap = deviceObject.get().nonnullInternalLink();
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();
+ for (Map.Entry<InternalLinkKey, InternalLink> internalLinkEntry: internalLinkMap.entrySet()) {
+ InternalLink internalLink = internalLinkEntry.getValue();
+ String internalLinkName = internalLink.getInternalLinkName();
+ String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
+ String sourcePortName = internalLink.getSource().getPortName().toString();
+ String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
+ String destinationPortName = internalLink.getDestination().getPortName().toString();
+
+ Object[] parameters = { nodeId, internalLinkName, sourceCircuitPackName, sourcePortName,
+ destinationCircuitPackName, destinationPortName, startTimestamp, startTimestamp };
+ String query = Queries.getQuery().deviceInternalLinkInsert().get();
LOG.info("Running {} query ", query);
try (PreparedStatement stmt = connection.prepareStatement(query)) {
for (int j = 0; j < parameters.length; j++) {
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices internal links", 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
- };
+ private void persistDevExternalLinks(String nodeId, Connection connection) {
- String query = Queries.getQuery().deviceProtocolRstpBridgePortAttrInsert().get();
+ 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()) {
+ return;
+ }
+ if (deviceObject.get().getExternalLink() == null) {
+ deviceObject = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION,
+ deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (deviceObject.get().getExternalLink() == null) {
+ LOG.info("External links not found for {}", nodeId);
+ return;
+ }
+ }
+ String startTimestamp = getCurrentTimestamp();
+ @NonNull
+ Map<ExternalLinkKey, ExternalLink> externalLinkMap = deviceObject.get().nonnullExternalLink();
+ for (Map.Entry<ExternalLinkKey, ExternalLink> externalLinkEntry: externalLinkMap.entrySet()) {
+ ExternalLink externalLink = externalLinkEntry.getValue();
+ String externalLinkName = externalLink.getExternalLinkName();
+ String sourceNodeId = externalLink.getSource().getNodeId();
+ String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
+ String sourcePortName = externalLink.getSource().getPortName();
+ String destinationNodeId = externalLink.getDestination().getNodeId();
+ String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
+ String destinationPortName = externalLink.getDestination().getPortName();
+
+ Object[] parameters = { nodeId, externalLinkName, sourceNodeId, sourceCircuitPackName,
+ sourcePortName, destinationNodeId, destinationCircuitPackName, destinationPortName,
+ startTimestamp, startTimestamp };
+
+ String query = Queries.getQuery().deviceExternalLinkInsert().get();
LOG.info("Running {} query ", query);
try (PreparedStatement stmt = connection.prepareStatement(query)) {
for (int j = 0; j < parameters.length; j++) {
stmt.execute();
stmt.clearParameters();
} catch (SQLException e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("Something wrong when storing devices external links", e);
}
-
}
}
-
- private void persistDevInternalLinks(String nodeId, Connection connection) {
+ private void persistDevPhysicalLinks(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.get().getInternalLink() == null) {
+ if (!deviceObject.isPresent()) {
+ LOG.error("No device with node Id {}", nodeId);
+ return;
+ }
+ if (deviceObject.get().getPhysicalLink() == null) {
deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- }
- if (deviceObject.get().getInternalLink() == null) {
- LOG.info("External links not found for {}", nodeId);
- } else {
-
-
- String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getInternalLink().size(); i++) {
- InternalLink internalLink = deviceObject.get().getInternalLink().get(i);
- String internalLinkName = internalLink.getInternalLinkName();
- String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
- String sourcePortName = internalLink.getSource().getPortName().toString();
- String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
- String destinationPortName = internalLink.getDestination().getPortName().toString();
-
- Object[] parameters = {nodeId,
- internalLinkName,
- sourceCircuitPackName,
- sourcePortName,
- destinationCircuitPackName,
- destinationPortName,
- startTimestamp,
- startTimestamp
- };
-
- String query = Queries.getQuery().deviceInternalLinkInsert().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);
- }
-
+ if (!deviceObject.isPresent()) {
+ LOG.error("No device with node Id {}", nodeId);
+ return;
+ }
+ if (deviceObject.get().getPhysicalLink() == null) {
+ LOG.info("Physical links not found for {}", nodeId);
+ return;
}
}
- }
+ String startTimestamp = getCurrentTimestamp();
+ @NonNull
+ Map<PhysicalLinkKey, PhysicalLink> physicalLinkMap = deviceObject.get().nonnullPhysicalLink();
+ for (Map.Entry<PhysicalLinkKey, PhysicalLink> physicalLinkEntry : physicalLinkMap.entrySet()) {
+ PhysicalLink physicalLink = physicalLinkEntry.getValue();
+ String physicalLinkName = physicalLink.getPhysicalLinkName();
+ String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
+ String sourcePortName = physicalLink.getSource().getPortName().toString();
+ String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
+ String destinationPortName = physicalLink.getDestination().getPortName().toString();
- private void persistDevExternalLinks(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);
+ Object[] parameters = {nodeId,
+ physicalLinkName,
+ sourceCircuitPackName,
+ sourcePortName,
+ destinationCircuitPackName,
+ destinationPortName,
+ startTimestamp,
+ startTimestamp
+ };
- if (deviceObject.get().getExternalLink() == null) {
- deviceObject =
- deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
- Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- }
- if (deviceObject.get().getExternalLink() == null) {
- LOG.info("External links not found for {}", nodeId);
- } else {
- String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getExternalLink().size(); i++) {
- ExternalLink externalLink = deviceObject.get().getExternalLink().get(i);
- String externalLinkName = externalLink.getExternalLinkName();
- String sourceNodeId = externalLink.getSource().getNodeId();
- String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
- String sourcePortName = externalLink.getSource().getPortName().toString();
- String destinationNodeId = externalLink.getDestination().getNodeId();
- String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
- String destinationPortName = externalLink.getDestination().getPortName().toString();
-
- Object[] parameters = {nodeId,
- externalLinkName,
- sourceNodeId,
- sourceCircuitPackName,
- sourcePortName,
- destinationNodeId,
- destinationCircuitPackName,
- destinationPortName,
- startTimestamp,
- startTimestamp
- };
-
- String query = Queries.getQuery().deviceExternalLinkInsert().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);
+ String query = Queries.getQuery().devicePhysicalLinkInsert().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("Something wrong when storing devices physical links", e);
}
- }
- }
-
- private void persistDevPhysicalLinks(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.get().getPhysicalLink() == null) {
- deviceObject =
- deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
- Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- }
- if (deviceObject.get().getPhysicalLink() == null) {
- LOG.info("Physical links not found for {}", nodeId);
- } else {
-
- String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getPhysicalLink().size(); i++) {
- PhysicalLink physicalLink = deviceObject.get().getPhysicalLink().get(i);
- String physicalLinkName = physicalLink.getPhysicalLinkName();
- String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
- String sourcePortName = physicalLink.getSource().getPortName().toString();
- String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
- String destinationPortName = physicalLink.getDestination().getPortName().toString();
-
- Object[] parameters = {nodeId,
- physicalLinkName,
- sourceCircuitPackName,
- sourcePortName,
- destinationCircuitPackName,
- destinationPortName,
- startTimestamp,
- startTimestamp
- };
-
- String query = Queries.getQuery().devicePhysicalLinkInsert().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);
- }
-
- }
}
}
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
} */
- if (deviceObject.get().getDegree() == null) {
- LOG.warn("Degree info not found for {}", nodeId);
- } else {
-
- String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getDegree().size(); i++) {
- Degree degree = deviceObject.get().getDegree().get(i);
- String degreeNumber = degree.getDegreeNumber().toString();
- String maxWavelengths = degree.getMaxWavelengths().toString();
- String otdrPortCircuitPackName =
+ if (!deviceObject.isPresent()) {
+ LOG.error("Cannot get device for node {}", nodeId);
+ return;
+ }
+ String startTimestamp = getCurrentTimestamp();
+ @NonNull
+ Map<DegreeKey, Degree> degreeMap = deviceObject.get().nonnullDegree();
+ for (Map.Entry<DegreeKey, Degree> degreeEntry : degreeMap.entrySet()) {
+ Degree degree = degreeEntry.getValue();
+ String degreeNumber = degree.getDegreeNumber().toString();
+ String maxWavelengths = degree.getMaxWavelengths().toString();
+ String otdrPortCircuitPackName =
(degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getCircuitPackName());
- String otdrPortPortName =
+ String otdrPortPortName =
(degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getPortName().toString());
- //String mcCapabilitiesSlotWidthGranularity = "";
- //String mcCapabilitiesCenterFreqGranularity = "";
- //String mcCapabilitiesMinSlots = "-1";
- //String mcCapabilitiesMaxSlots = "-1";
- persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
- persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
-
- Object[] parameters = {nodeId,
- degreeNumber,
- maxWavelengths,
- otdrPortCircuitPackName,
- otdrPortPortName,
- //mcCapabilitiesSlotWidthGranularity,
- //mcCapabilitiesCenterFreqGranularity,
- //mcCapabilitiesMinSlots,
- //mcCapabilitiesMaxSlots,
- "", "", "-1", "-1",
- startTimestamp,
- startTimestamp
- };
-
- String query = Queries.getQuery().deviceDegreeInsert().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);
+ // String mcCapabilitiesSlotWidthGranularity = "";
+ // String mcCapabilitiesCenterFreqGranularity = "";
+ // String mcCapabilitiesMinSlots = "-1";
+ // String mcCapabilitiesMaxSlots = "-1";
+ persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
+ persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
+
+ Object[] parameters = { nodeId, degreeNumber, maxWavelengths, otdrPortCircuitPackName, otdrPortPortName,
+ // mcCapabilitiesSlotWidthGranularity,
+ // mcCapabilitiesCenterFreqGranularity,
+ // mcCapabilitiesMinSlots,
+ // mcCapabilitiesMaxSlots,
+ "", "", "-1", "-1", startTimestamp, startTimestamp };
+
+ String query = Queries.getQuery().deviceDegreeInsert().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("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> circuitPackEntry :
+ circuitPacksMap.entrySet()) {
- String circuitPackIndex = degree.getCircuitPacks().get(i).getIndex().toString();
- String circuitPackName = degree.getCircuitPacks().get(i).getCircuitPackName();
+ String circuitPackIndex = circuitPackEntry.getValue().getIndex().toString();
+ String circuitPackName = circuitPackEntry.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++) {
-
- String connectionPortIndex = degree.getConnectionPorts().get(i).getIndex().toString();
- String circuitPackName = degree.getConnectionPorts().get(i).getCircuitPackName();
- String portName = degree.getConnectionPorts().get(i).getPortName().toString();
+ @NonNull
+ Map<ConnectionPortsKey, ConnectionPorts> connectionPortsMap = degree.nonnullConnectionPorts();
+ for (Map.Entry<ConnectionPortsKey, ConnectionPorts> portEntry : connectionPortsMap.entrySet()) {
+ String connectionPortIndex = portEntry.getValue().getIndex().toString();
+ String circuitPackName = portEntry.getValue().getCircuitPackName();
+ String portName = portEntry.getValue().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("No device found in operational datastore for node {}", nodeId);
+ return;
+ }
if (deviceObject.get().getSharedRiskGroup() == null) {
deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (!deviceObject.isPresent()) {
+ LOG.error("No device found in configuration datastore for node {}", nodeId);
+ return;
+ }
}
- if (deviceObject.get().getSharedRiskGroup() == null) {
+
+ @NonNull
+ Map<SharedRiskGroupKey, SharedRiskGroup> sharedRiskGroupMap = deviceObject.get().nonnullSharedRiskGroup();
+ if (sharedRiskGroupMap.isEmpty()) {
LOG.info("no srg found for node {} ", nodeId);
- } else {
- String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getSharedRiskGroup().size(); i++) {
- SharedRiskGroup sharedRiskGroup = deviceObject.get().getSharedRiskGroup().get(i);
- //String currentProvisionedAddDropPorts = "-1";
- //String mcCapSlotWidthGranularity = "";
- //String mcCapCenterFreqGranularity = "";
- //String mcCapMinSlots = "-1";
- //String mcCapMaxSlots = "-1";
- String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
- String srgNumber = sharedRiskGroup.getSrgNumber().toString();
- String wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getName();
- persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
-
- Object[] parameters = {nodeId,
- maxAddDropPorts,
- //currentProvisionedAddDropPorts,
- "-1",
- srgNumber,
- wavelengthDuplicationEnu,
- //mcCapSlotWidthGranularity,
- //mcCapCenterFreqGranularity,
- //mcCapMinSlots,
- //mcCapMaxSlots,
- "", "", "", "",
- startTimestamp,
- startTimestamp
- };
-
- String query = Queries.getQuery().deviceSharedRiskGroupInsert().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);
- }
+ return;
+ }
+ String startTimestamp = getCurrentTimestamp();
+ for (Map.Entry<SharedRiskGroupKey, SharedRiskGroup> groupEntry : sharedRiskGroupMap.entrySet()) {
+ SharedRiskGroup sharedRiskGroup = groupEntry.getValue();
+ //String currentProvisionedAddDropPorts = "-1";
+ //String mcCapSlotWidthGranularity = "";
+ //String mcCapCenterFreqGranularity = "";
+ //String mcCapMinSlots = "-1";
+ //String mcCapMaxSlots = "-1";
+ String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
+ String srgNumber = sharedRiskGroup.getSrgNumber().toString();
+ String wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getName();
+ persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
+ Object[] parameters = {nodeId,
+ maxAddDropPorts,
+ //currentProvisionedAddDropPorts,
+ "-1",
+ srgNumber,
+ wavelengthDuplicationEnu,
+ //mcCapSlotWidthGranularity,
+ //mcCapCenterFreqGranularity,
+ //mcCapMinSlots,
+ //mcCapMaxSlots,
+ "", "", "", "",
+ startTimestamp,
+ startTimestamp
+ };
+
+ String query = Queries.getQuery().deviceSharedRiskGroupInsert().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("Something wrong when storing devices SRG", e);
}
+
}
}
Connection connection) {
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < sharedRiskGroup.getCircuitPacks().size(); i++) {
+ @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()) {
- String circuitPackindex = sharedRiskGroup.getCircuitPacks().get(i).getIndex().toString();
- String circuitPackName = sharedRiskGroup.getCircuitPacks().get(i).getCircuitPackName();
+ String circuitPackindex = entry.getValue().getIndex().toString();
+ String circuitPackName = entry.getValue().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("No device found in operational datastore for node {}", nodeId);
+ return;
+ }
if (deviceObject.get().getRoadmConnections() == null) {
deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (!deviceObject.isPresent()) {
+ LOG.error("No device found in configuration datastore for node {}", nodeId);
+ return;
+ }
}
- if (deviceObject.get().getRoadmConnections() != null) {
- String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getRoadmConnections().size(); i++) {
- RoadmConnections roadmConnections = deviceObject.get().getRoadmConnections().get(i);
- String connectionNumber = roadmConnections.getConnectionNumber();
- //String connectionName = "";
- String wavelengthNumber = roadmConnections.getWavelengthNumber().toString();
- String opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getName();
- String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
- String srcIf = roadmConnections.getSource().getSrcIf();
- String dstIf = roadmConnections.getDestination().getDstIf();
-
- Object[] parameters = {nodeId,
- //connectionName,
- "",
- connectionNumber,
- wavelengthNumber,
- opticalcontrolmodeEnu,
- targetOutputPower,
- srcIf,
- dstIf,
- startTimestamp,
- startTimestamp
- };
-
- String query = Queries.getQuery().deviceRoadmConnectionsInsert().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);
- }
+ @NonNull
+ Map<RoadmConnectionsKey, RoadmConnections> connectionsMap = deviceObject.get().nonnullRoadmConnections();
+ if (connectionsMap.isEmpty()) {
+ LOG.info("ROADM Dev Connections not found!! for {}", nodeId);
+ return;
+ }
+ String startTimestamp = getCurrentTimestamp();
+ for (Map.Entry<RoadmConnectionsKey, RoadmConnections> entry : connectionsMap.entrySet()) {
+ RoadmConnections roadmConnections = entry.getValue();
+ String connectionNumber = roadmConnections.getConnectionNumber();
+ //String connectionName = "";
+ String wavelengthNumber = roadmConnections.getWavelengthNumber().toString();
+ String opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getName();
+ String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
+ String srcIf = roadmConnections.getSource().getSrcIf();
+ String dstIf = roadmConnections.getDestination().getDstIf();
+ Object[] parameters = {nodeId,
+ //connectionName,
+ "",
+ connectionNumber,
+ wavelengthNumber,
+ opticalcontrolmodeEnu,
+ targetOutputPower,
+ srcIf,
+ dstIf,
+ startTimestamp,
+ startTimestamp
+ };
+
+ String query = Queries.getQuery().deviceRoadmConnectionsInsert().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("Something wrong when storing devices ROADM connection ", e);
}
- } else {
- LOG.info("ROADM Dev Connections not found!! for {}", nodeId);
}
}
Optional<OrgOpenroadmDevice> deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-
+ if (!deviceObject.isPresent()) {
+ LOG.error("No device found in operational datastore for node {}", 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> connectionsMap = deviceObject.get().nonnullConnectionMap();
+ for (Map.Entry<ConnectionMapKey, ConnectionMap> entry : connectionsMap.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);
}
}
Optional<OrgOpenroadmDevice> deviceObject =
deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (!deviceObject.isPresent()) {
+ LOG.error("No device found in operational datastore for node {}", nodeId);
+ return;
+ }
String startTimestamp = getCurrentTimestamp();
- for (int i = 0; i < deviceObject.get().getWavelengthMap().getWavelengths().size(); i++) {
- Wavelengths wavelengths = deviceObject.get().getWavelengthMap().getWavelengths().get(i);
+ @NonNull
+ Map<WavelengthsKey, Wavelengths> wavelengthsMap = deviceObject.get().getWavelengthMap().nonnullWavelengths();
+ for (Map.Entry<WavelengthsKey, Wavelengths> entry : wavelengthsMap.entrySet()) {
+ Wavelengths wavelengths = entry.getValue();
String wavelengthNumber = wavelengths.getWavelengthNumber().toString();
String centerFrequency = wavelengths.getCenterFrequency().toString();
String wavelength = wavelengths.getWavelength().toString();
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;
+ Map<TxMsiKey, TxMsi> txMsiMap = oduBuilder.getOpu().getMsi().nonnullTxMsi();
+ for (Map.Entry<TxMsiKey, TxMsi> entry : txMsiMap.entrySet()) {
- txMsi = oduBuilder.getOpu().getMsi().getTxMsi().get(i);
+ TxMsi txMsi = entry.getValue();
Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
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);
+ Map<RxMsiKey, RxMsi> rxMsiMap = oduBuilder.getOpu().getMsi().nonnullRxMsi();
+ for (Map.Entry<RxMsiKey, RxMsi> entry : rxMsiMap.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);
+ @NonNull
+ Map<ExpMsiKey, ExpMsi> expMsiMap = oduBuilder.getOpu().getMsi().nonnullExpMsi();
+ for (Map.Entry<ExpMsiKey, ExpMsi> entry : expMsiMap.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);
}
}
}