networkOptional;
try (ReadOnlyTransaction rtx = this.dataBroker.newReadOnlyTransaction()) {
- // TODO change to constant from Timeouts class when it will be
- // merged.
+ //TODO change to constant from Timeouts class when it will be merged.
networkOptional = rtx.read(LogicalDatastoreType.CONFIGURATION, networkIID).get(Timeouts.DATASTORE_READ,
- TimeUnit.MILLISECONDS).toJavaUtil();
+ TimeUnit.MILLISECONDS).toJavaUtil();
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.warn("Read of {} topology failed", NetworkUtils.OVERLAY_NETWORK_ID);
return Collections.emptyList();
}
- if (!networkOptional.isPresent()) {
+ if (! networkOptional.isPresent()) {
LOG.warn("Network augmentation with links data is not present in {} topology.",
- NetworkUtils.OVERLAY_NETWORK_ID);
+ NetworkUtils.OVERLAY_NETWORK_ID);
return Collections.emptyList();
}
@@ -280,21 +280,16 @@ public class OlmPowerServiceImpl implements OlmPowerService {
}
/**
- * This method retrieves OTS PM from current PM list by nodeId and TPId:
- * Steps:
+ * This method retrieves OTS PM from current PM list by nodeId and TPId: Steps:
*
*
- * 1. Get OTS interface name from port mapping by TPId 2. Call getPm RPC to
- * get OTS PM
+ * 1. Get OTS interface name from port mapping by TPId 2. Call getPm RPC to get OTS PM
*
*
*
- * @param nodeId
- * Node-id of the NE.
- * @param tpID
- * Termination point Name.
- * @param pmName
- * PM name which need to be retrieved
+ * @param nodeId Node-id of the NE.
+ * @param tpID Termination point Name.
+ * @param pmName PM name which need to be retrieved
* @return reference to OtsPmHolder
*/
private OtsPmHolder getPmMeasurements(String nodeId, String tpID, String pmName) {
@@ -304,10 +299,10 @@ public class OlmPowerServiceImpl implements OlmPowerService {
return null;
}
GetPmInput getPmInput = new GetPmInputBuilder().setNodeId(realNodeId)
- .setResourceType(ResourceTypeEnum.Interface).setGranularity(PmGranularity._15min)
- .setResourceIdentifier(
- new ResourceIdentifierBuilder().setResourceName(mapping.getSupportingOts()).build())
- .build();
+ .setResourceType(ResourceTypeEnum.Interface).setGranularity(PmGranularity._15min)
+ .setResourceIdentifier(
+ new ResourceIdentifierBuilder().setResourceName(mapping.getSupportingOts()).build())
+ .build();
GetPmOutput otsPmOutput = getPm(getPmInput);
if (otsPmOutput == null) {
@@ -318,7 +313,7 @@ public class OlmPowerServiceImpl implements OlmPowerService {
for (Measurements measurement : otsPmOutput.getMeasurements()) {
if (pmName.equals(measurement.getPmparameterName())) {
return new OtsPmHolder(pmName, Double.parseDouble(measurement.getPmparameterValue()),
- mapping.getSupportingOts());
+ mapping.getSupportingOts());
}
}
} catch (NumberFormatException e) {
@@ -336,18 +331,15 @@ public class OlmPowerServiceImpl implements OlmPowerService {
*
* 2. Set spanloss
*
- * @param nodeId
- * nodeId of NE on which spanloss need to be updated
- * @param interfaceName
- * OTS interface for NE on which spanloss is cacluated
- * @param spanLoss
- * calculated spanloss value
- * @param direction
- * for which spanloss is calculated.It can be either Tx or Rx
+ * @param nodeId nodeId of NE on which spanloss need to be updated
+ * @param interfaceName OTS interface for NE on which spanloss is cacluated
+ * @param spanLoss calculated spanloss value
+ * @param direction for which spanloss is calculated.It can be either Tx or Rx
* @return true/false
*/
private boolean setSpanLoss(String nodeId, String interfaceName, BigDecimal spanLoss, String direction) {
String realNodeId = getRealNodeId(nodeId);
+ LOG.info("Setting Spanloss in device for {}, InterfaceName: {}", realNodeId, interfaceName);
switch (direction) {
case "TX":
LOG.info("Setting 'span-loss-transmit' in device: {}, Interface: {}", realNodeId, interfaceName);
@@ -360,11 +352,11 @@ public class OlmPowerServiceImpl implements OlmPowerService {
break;
}
InstanceIdentifier interfacesIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(Interface.class, new InterfaceKey(interfaceName));
+ .child(Interface.class, new InterfaceKey(interfaceName));
com.google.common.base.Optional interfaceObject;
try {
Future> deviceTxFuture =
- this.deviceTransactionManager.getDeviceTransaction(realNodeId);
+ this.deviceTransactionManager.getDeviceTransaction(realNodeId);
java.util.Optional deviceTxOpt = deviceTxFuture.get();
DeviceTransaction deviceTx;
if (deviceTxOpt.isPresent()) {
@@ -401,7 +393,7 @@ public class OlmPowerServiceImpl implements OlmPowerService {
interfaceBuilder.addAugmentation(Interface1.class, intf1Builder.setOts(otsBuilder.build()).build());
deviceTx.put(LogicalDatastoreType.CONFIGURATION, interfacesIID, interfaceBuilder.build());
ListenableFuture submit =
- deviceTx.submit(Timeouts.DEVICE_WRITE_TIMEOUT, Timeouts.DEVICE_WRITE_TIMEOUT_UNIT);
+ deviceTx.submit(Timeouts.DEVICE_WRITE_TIMEOUT, Timeouts.DEVICE_WRITE_TIMEOUT_UNIT);
submit.get();
LOG.info("Spanloss Value update completed successfully");
return true;
@@ -457,7 +449,7 @@ public class OlmPowerServiceImpl implements OlmPowerService {
private String getRealNodeId(String mappedNodeId) {
KeyedInstanceIdentifier mappedNodeII =
- InstanceIdentifiers.OVERLAY_NETWORK_II.child(Node.class, new NodeKey(new NodeId(mappedNodeId)));
+ InstanceIdentifiers.OVERLAY_NETWORK_II.child(Node.class, new NodeKey(new NodeId(mappedNodeId)));
com.google.common.base.Optional realNode;
try (ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction()) {
realNode = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, mappedNodeII).get();
@@ -467,16 +459,16 @@ public class OlmPowerServiceImpl implements OlmPowerService {
}
if (!realNode.isPresent() || (realNode.get().getSupportingNode() == null)) {
throw new IllegalArgumentException(
- String.format("Could not find node %s, or supporting node is not present", mappedNodeId));
+ String.format("Could not find node %s, or supporting node is not present", mappedNodeId));
}
List collect = realNode.get().getSupportingNode().stream()
- .filter(node -> (node.getNetworkRef() != null)
- && NetworkUtils.UNDERLAY_NETWORK_ID.equals(node.getNetworkRef().getValue())
- && (node.getNodeRef() != null) && !Strings.isNullOrEmpty(node.getNodeRef().getValue()))
- .collect(Collectors.toList());
+ .filter(node -> (node.getNetworkRef() != null)
+ && NetworkUtils.UNDERLAY_NETWORK_ID.equals(node.getNetworkRef().getValue())
+ && (node.getNodeRef() != null) && !Strings.isNullOrEmpty(node.getNodeRef().getValue()))
+ .collect(Collectors.toList());
if (collect.isEmpty() || (collect.size() > 1)) {
throw new IllegalArgumentException(String.format("Invalid support node count [%d] was found for node %s",
- collect.size(), mappedNodeId));
+ collect.size(), mappedNodeId));
}
return collect.iterator().next().getNodeRef().getValue();
}