fix some sonar issues 35/82535/6
authorguillaume.lambert <guillaume.lambert@orange.com>
Tue, 18 Jun 2019 08:33:26 +0000 (10:33 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Wed, 19 Jun 2019 13:17:40 +0000 (15:17 +0200)
JIRA: TRNSPRTPCE-133

Change-Id: Idd9ff2a296c5e9c066d3bdfcb149a9f1fffa5d22
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransactionManagerImpl.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceLink.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceResult.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java
pce/src/main/java/org/opendaylight/transportpce/pce/gnpy/ExtractTopoDataStoreImpl.java

index ca0e91976260ed811aaea50b063f990af66c0eae..160e0e147a3bf724a155fb79154f80b17f7a6a10 100644 (file)
@@ -48,13 +48,14 @@ public class DeviceTransactionManagerImpl implements DeviceTransactionManager {
     private static final int NUMBER_OF_THREADS = 4;
     private static final long GET_DATA_SUBMIT_TIMEOUT = 3000;
     private static final TimeUnit GET_DATA_SUBMIT_TIME_UNIT = TimeUnit.MILLISECONDS;
     private static final int NUMBER_OF_THREADS = 4;
     private static final long GET_DATA_SUBMIT_TIMEOUT = 3000;
     private static final TimeUnit GET_DATA_SUBMIT_TIME_UNIT = TimeUnit.MILLISECONDS;
+    private static final TimeUnit MAX_DURATION_TO_SUBMIT_TIMEUNIT = TimeUnit.MILLISECONDS;
 
     private final MountPointService mountPointService;
     private final ScheduledExecutorService checkingExecutor;
     private final ListeningExecutorService listeningExecutor;
     private final ConcurrentMap<String, CountDownLatch> deviceLocks;
 
     private final MountPointService mountPointService;
     private final ScheduledExecutorService checkingExecutor;
     private final ListeningExecutorService listeningExecutor;
     private final ConcurrentMap<String, CountDownLatch> deviceLocks;
-    private final long maxDurationToSubmitTransaction; // TODO set reasonable value in blueprint
-    private final TimeUnit maxDurationToSubmitTransactionTimeUnit = TimeUnit.MILLISECONDS;
+    // TODO set reasonable value in blueprint for maxDurationToSubmitTransaction
+    private final long maxDurationToSubmitTransaction;
 
     public DeviceTransactionManagerImpl(MountPointService mountPointService, long maxDurationToSubmitTransaction) {
         this.mountPointService = mountPointService;
 
     public DeviceTransactionManagerImpl(MountPointService mountPointService, long maxDurationToSubmitTransaction) {
         this.mountPointService = mountPointService;
@@ -66,7 +67,7 @@ public class DeviceTransactionManagerImpl implements DeviceTransactionManager {
 
     @Override
     public Future<Optional<DeviceTransaction>> getDeviceTransaction(String deviceId) {
 
     @Override
     public Future<Optional<DeviceTransaction>> getDeviceTransaction(String deviceId) {
-        return getDeviceTransaction(deviceId, maxDurationToSubmitTransaction, maxDurationToSubmitTransactionTimeUnit);
+        return getDeviceTransaction(deviceId, maxDurationToSubmitTransaction, MAX_DURATION_TO_SUBMIT_TIMEUNIT);
     }
 
     @Override
     }
 
     @Override
index 2fb29265b5c165d54f9e85cd208da24499458b79..44e3fad451f48100d7eb60239a4ac16a55b18338 100644 (file)
@@ -135,14 +135,22 @@ public class PceLink {
 
     @SuppressWarnings("checkstyle:VariableDeclarationUsageDistance")
     public double retrieveOSNR() {
 
     @SuppressWarnings("checkstyle:VariableDeclarationUsageDistance")
     public double retrieveOSNR() {
-        double sum = 0;        // sum of 1 over the span OSNRs (linear units)
-        double linkOsnrDb;     // link OSNR, in dB
-        double linkOsnrLu;     // link OSNR, in dB
-        double spanOsnrDb;     // span OSNR, in dB
-        double spanOsnrLu;     // span OSNR, in linear units
-        double ampNoise = 5.5; // default amplifier noise value, in dB
-        double loss;           // fiber span measured loss, in dB
-        double power;          // launch power, in dB
+        // sum of 1 over the span OSNRs (linear units)
+        double sum = 0;
+        // link OSNR, in dB
+        double linkOsnrDb;
+        // link OSNR, in dB
+        double linkOsnrLu;
+        // span OSNR, in dB
+        double spanOsnrDb;
+        // span OSNR, in linear units
+        double spanOsnrLu;
+        // default amplifier noise value, in dB
+        double ampNoise = 5.5;
+        // fiber span measured loss, in dB
+        double loss;
+        // launch power, in dB
+        double power;
         double constantA = 38.97293;
         double constantB = 0.72782;
         double constantC = -0.532331;
         double constantA = 38.97293;
         double constantB = 0.72782;
         double constantC = -0.532331;
@@ -151,7 +159,8 @@ public class PceLink {
         double lowerBoundOSNR = 0.1;
 
         if (omsAttributesSpan ==  null) {
         double lowerBoundOSNR = 0.1;
 
         if (omsAttributesSpan ==  null) {
-            return 0L; // indicates no data or N/A
+            // indicates no data or N/A
+            return 0L;
         }
         loss = omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue();
         switch (omsAttributesSpan.getLinkConcatenation().get(0).getFiberType()) {
         }
         loss = omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue();
         switch (omsAttributesSpan.getLinkConcatenation().get(0).getFiberType()) {
index 3a340616b895beece0a848fe32998f91dd44f9a5..b7119d898968455bd1c213fcf04e741939ba6c4b 100644 (file)
@@ -21,7 +21,8 @@ public class PceResult {
     private boolean calcStatus = false;
     private String responseCode = ResponseCodes.RESPONSE_FAILED;
     private long resultWavelength = -1;
     private boolean calcStatus = false;
     private String responseCode = ResponseCodes.RESPONSE_FAILED;
     private long resultWavelength = -1;
-    private long rate = -1; // for now it is constant returned as received from A-end
+    // for now it is constant returned as received from A-end
+    private long rate = -1;
 
     public enum LocalCause {
         NONE, TOO_HIGH_LATENCY, NO_PATH_EXISTS, INT_PROBLEM;
 
     public enum LocalCause {
         NONE, TOO_HIGH_LATENCY, NO_PATH_EXISTS, INT_PROBLEM;
@@ -48,7 +49,7 @@ public class PceResult {
                 this.calcMessage = "No path available";
                 break;
             default:
                 this.calcMessage = "No path available";
                 break;
             default:
-                LOG.error("setRC: RespondeCodes unknown");//requires sl4j but not imported
+                LOG.error("setRC: RespondeCodes unknown");
         }
     }
 
         }
     }
 
index bada4cb4b0cd626f560e104724419de6aede3396..bd1afea073307a2179428a52c06249c5bb26f00e 100644 (file)
@@ -76,7 +76,8 @@ public class PceSendingPceRPCs {
     public void cancelResourceReserve() {
         LOG.info("Wait for 10s til beginning the PCE cancelResourceReserve request");
         try {
     public void cancelResourceReserve() {
         LOG.info("Wait for 10s til beginning the PCE cancelResourceReserve request");
         try {
-            Thread.sleep(10000); // sleep for 10s
+            // sleep for 10s
+            Thread.sleep(10000);
         } catch (InterruptedException e) {
             LOG.error(e.toString());
         }
         } catch (InterruptedException e) {
             LOG.error(e.toString());
         }
index 31417baf83a647bc6128084931b4189bdc3862e2..000f055a89779708d30954515f1915b034758d6e 100644 (file)
@@ -331,12 +331,13 @@ public class ExtractTopoDataStoreImpl {
                                         double connOut = 0;
                                         String typeVariety = "SSMF";
 
                                         double connOut = 0;
                                         String typeVariety = "SSMF";
 
-                                        double length = 0; //convert to kilometer
+                                        double length = 0;
                                         // Compute the length of the link
                                         List<LinkConcatenation> linkConcatenationList = span.getLinkConcatenation();
                                         for (LinkConcatenation linkConcatenation : linkConcatenationList) {
                                             double srlgLength = linkConcatenation.getSRLGLength();
                                         // Compute the length of the link
                                         List<LinkConcatenation> linkConcatenationList = span.getLinkConcatenation();
                                         for (LinkConcatenation linkConcatenation : linkConcatenationList) {
                                             double srlgLength = linkConcatenation.getSRLGLength();
-                                            length += srlgLength / convertKmM; //convert to kilometer
+                                            //convert to kilometer
+                                            length += srlgLength / convertKmM;
                                         }
 
                                         Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
                                         }
 
                                         Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
@@ -701,9 +702,8 @@ public class ExtractTopoDataStoreImpl {
         Edfa edfa = new EdfaBuilder()
                 // .setTypeVariety(typeVariety)
                 .setOperational(operational).build();
         Edfa edfa = new EdfaBuilder()
                 // .setTypeVariety(typeVariety)
                 .setOperational(operational).build();
-        Elements element1 = new ElementsBuilder().setUid(uidEdfa) // Choose an
-                                                                  // ip
-                                                                  // address
+        Elements element1 = new ElementsBuilder().setUid(uidEdfa)
+                // Choose an ip address
                 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Edfa.class)
                 .setMetadata(metadata1).setElementType(edfa).setTypeVariety(typeVariety).build();
         return element1;
                 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Edfa.class)
                 .setMetadata(metadata1).setElementType(edfa).setTypeVariety(typeVariety).build();
         return element1;