[NO ISSUE][OTH] Log level / SonarQube fixes

Change-Id: I8e9a31ebea1eac6bed26c57666db1fd4b1208295
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2891
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/work/CleanupJobletWork.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/work/CleanupJobletWork.java
index d415da1..ae2cfa0 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/work/CleanupJobletWork.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/work/CleanupJobletWork.java
@@ -45,9 +45,7 @@
 
     @Override
     public void run() {
-        if (LOGGER.isInfoEnabled()) {
-            LOGGER.info("Cleaning up after job: " + jobId);
-        }
+        LOGGER.debug("cleaning up after job: {}", jobId);
         ncs.removeJobParameterByteStore(jobId);
         ncs.getPartitionManager().jobCompleted(jobId, status);
         Map<JobId, Joblet> jobletMap = ncs.getJobletMap();
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMMemoryComponent.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMMemoryComponent.java
index 278098f..9440648 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMMemoryComponent.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMMemoryComponent.java
@@ -30,7 +30,6 @@
 import org.apache.hyracks.storage.am.lsm.common.api.LSMOperationType;
 import org.apache.hyracks.storage.am.lsm.common.util.LSMComponentIdUtils;
 import org.apache.hyracks.storage.common.buffercache.IBufferCache;
-import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -276,7 +275,7 @@
             allocated = true;
         } finally {
             if (!allocated) {
-                ((IVirtualBufferCache) getIndex().getBufferCache()).close();
+                getIndex().getBufferCache().close();
             }
         }
     }
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/ComponentReplacementContext.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/ComponentReplacementContext.java
index dad3bdc..35edcc5 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/ComponentReplacementContext.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/ComponentReplacementContext.java
@@ -37,7 +37,6 @@
 import org.apache.hyracks.storage.common.ISearchOperationCallback;
 import org.apache.hyracks.storage.common.ISearchPredicate;
 import org.apache.hyracks.storage.common.MultiComparator;
-import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -48,7 +47,7 @@
     private final List<ILSMComponentId> replacedComponentIds;
     private final int[] swapIndexes;
     private int count = 0;
-    boolean accessingComponent = true;
+    private boolean accessingComponent = true;
 
     public ComponentReplacementContext(ILSMIndex lsmIndex) {
         components = new ArrayList<>(lsmIndex.getNumberOfAllMemoryComponents());
@@ -156,12 +155,12 @@
             replacedComponentIds.add(components.get(i).getId());
             // ensure that disk component exists
             boolean found = false;
-            LOGGER.log(Level.INFO, "Looking for a component with the id: " + replacedComponentIds.get(i));
-            for (int j = 0; j < allDiskComponents.size(); j++) {
-                ILSMDiskComponent dc = allDiskComponents.get(j);
+            final ILSMComponentId replacedComponentId = replacedComponentIds.get(i);
+            LOGGER.trace("looking for a component with the id: {}", replacedComponentId);
+            for (ILSMDiskComponent dc : allDiskComponents) {
                 ILSMComponentId diskComponentId = dc.getId();
-                LOGGER.log(Level.INFO, "Next disk component id: " + diskComponentId);
-                if (diskComponentId.equals(replacedComponentIds.get(i))) {
+                LOGGER.trace("next disk component id: {}", diskComponentId);
+                if (diskComponentId.equals(replacedComponentId)) {
                     found = true;
                     diskComponents.add(dc);
                     break;
@@ -169,8 +168,8 @@
             }
             if (!found) {
                 // component has been merged?
-                LOGGER.log(Level.WARN, "Memory Component with id = " + replacedComponentIds.get(i)
-                        + " was flushed and merged before search cursor replaces it");
+                LOGGER.warn("memory component {} was flushed and merged before search cursor replaces it",
+                        replacedComponentId);
                 return false;
             }
         }
@@ -194,14 +193,14 @@
             for (int i = 0; i < count; i++) {
                 ILSMComponent removed = ctx.getComponentHolder().remove(swapIndexes[i]);
                 if (removed.getType() == LSMComponentType.MEMORY) {
-                    LOGGER.log(Level.INFO, "Removed a memory component from the search operation");
+                    LOGGER.info("Removed a memory component from the search operation");
                 } else {
                     throw new IllegalStateException("Disk components can't be removed from the search operation");
                 }
                 ctx.getComponentHolder().add(swapIndexes[i], diskComponents.get(i));
             }
         } catch (Exception e) {
-            LOGGER.log(Level.WARN, "Failure replacing memory components with disk components", e);
+            LOGGER.warn("Failure replacing memory components with disk components", e);
             throw e;
         }
     }