[NO ISSUE][OTH] Logging clean up

- user model changes: no
- storage format changes: no
- interface changes: no

Change-Id: If5ed90c07d94083aad653847436afe1964dc9b42
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17702
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Al Hubail <mhubail@apache.org>
Reviewed-by: Peeyush Gupta <peeyush.gupta@couchbase.com>
Tested-by: Murtadha Al Hubail <mhubail@apache.org>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobCommitMessage.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobCommitMessage.java
index 55ae225..fac023c 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobCommitMessage.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobCommitMessage.java
@@ -28,15 +28,12 @@
 import org.apache.asterix.messaging.NCMessageBroker;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.job.JobId;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
 
 /**
  * Message sent from CC to all NCs asking to commit an atomic statement/job.
  */
 public class AtomicJobCommitMessage implements INcAddressedMessage {
 
-    private static final Logger LOGGER = LogManager.getLogger();
     private static final long serialVersionUID = 1L;
     private final JobId jobId;
     private final List<Integer> datasetIds;
@@ -65,4 +62,9 @@
             throw HyracksDataException.create(e);
         }
     }
+
+    @Override
+    public String toString() {
+        return "AtomicJobCommitMessage{" + "jobId=" + jobId + ", datasetIds=" + datasetIds + '}';
+    }
 }
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobCompletionMessage.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobCompletionMessage.java
index 869e5d2..a2a1e51 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobCompletionMessage.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobCompletionMessage.java
@@ -22,15 +22,12 @@
 import org.apache.asterix.common.messaging.api.ICcAddressedMessage;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.job.JobId;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
 
 /**
  * Message sent from NC to CC on successful local commit of an atomic statement/job.
  */
 public class AtomicJobCompletionMessage implements ICcAddressedMessage {
 
-    private static final Logger LOGGER = LogManager.getLogger();
     private static final long serialVersionUID = 1L;
     private final String nodeId;
     private final JobId jobId;
@@ -44,4 +41,9 @@
     public void handle(ICcApplicationContext appCtx) throws HyracksDataException, InterruptedException {
         appCtx.getGlobalTxManager().handleJobCompletionMessage(jobId, nodeId);
     }
+
+    @Override
+    public String toString() {
+        return "AtomicJobCompletionMessage{" + "jobId=" + jobId + ", nodeId='" + nodeId + '\'' + '}';
+    }
 }
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobRollbackCompleteMessage.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobRollbackCompleteMessage.java
index 90e1fbd..85f9cf4 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobRollbackCompleteMessage.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobRollbackCompleteMessage.java
@@ -22,15 +22,12 @@
 import org.apache.asterix.common.messaging.api.ICcAddressedMessage;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.job.JobId;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
 
 /**
  * Message sent from an NC to CC after successful local rollback of an atomic statement/job.
  */
 public class AtomicJobRollbackCompleteMessage implements ICcAddressedMessage {
 
-    private static final Logger LOGGER = LogManager.getLogger();
     private static final long serialVersionUID = 1L;
     private final String nodeId;
     private final JobId jobId;
@@ -45,4 +42,8 @@
         appCtx.getGlobalTxManager().handleJobRollbackCompletionMessage(jobId, nodeId);
     }
 
+    @Override
+    public String toString() {
+        return "AtomicJobRollbackCompleteMessage{" + "jobId=" + jobId + ", nodeId='" + nodeId + '\'' + '}';
+    }
 }
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobRollbackMessage.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobRollbackMessage.java
index aeb6be2..71a641e 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobRollbackMessage.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/AtomicJobRollbackMessage.java
@@ -32,15 +32,12 @@
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.job.JobId;
 import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponentId;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
 
 /**
  * Message sent from CC to all NCs to rollback an atomic statement/job.
  */
 public class AtomicJobRollbackMessage implements INcAddressedMessage {
 
-    private static final Logger LOGGER = LogManager.getLogger();
     private static final long serialVersionUID = 1L;
     private final JobId jobId;
     private final List<Integer> datasetIds;
@@ -80,4 +77,9 @@
             throw new RuntimeException(e);
         }
     }
+
+    @Override
+    public String toString() {
+        return "AtomicJobRollbackMessage{" + "jobId=" + jobId + ", datasetIds=" + datasetIds + '}';
+    }
 }
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/EnableMergeMessage.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/EnableMergeMessage.java
index 900da82..050ca38 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/EnableMergeMessage.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/message/EnableMergeMessage.java
@@ -24,12 +24,9 @@
 import org.apache.asterix.common.messaging.api.INcAddressedMessage;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.job.JobId;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
 
 public class EnableMergeMessage implements INcAddressedMessage {
 
-    private static final Logger LOGGER = LogManager.getLogger();
     private static final long serialVersionUID = 1L;
     private final JobId jobId;
     private final int datasetId;
@@ -48,4 +45,9 @@
             }
         }
     }
+
+    @Override
+    public String toString() {
+        return "EnableMergeMessage{" + "jobId=" + jobId + ", datasetId=" + datasetId + '}';
+    }
 }
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
index 2e32fb3..7e38b8b 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
@@ -148,7 +148,7 @@
                 for (ILSMIndex lsmIndex : indexes) {
                     if (lsmIndex.isPrimaryIndex()) {
                         if (lsmIndex.isCurrentMutableComponentEmpty()) {
-                            LOGGER.debug("Primary index on dataset {} and partition {} is empty... skipping flush",
+                            LOGGER.trace("Primary index on dataset {} and partition {} is empty... skipping flush",
                                     dsInfo.getDatasetID(), partition);
                             return;
                         }
@@ -228,17 +228,18 @@
             }
             idGenerator.refresh();
             long flushLsn = logRecord.getLSN();
-            if (flushLsn == 0) {
-                LOGGER.warn("flushing an index with LSN 0. Flush log record: {}", logRecord::getLogRecordForDisplay);
-            }
             ILSMComponentId nextComponentId = idGenerator.getId();
             Map<String, Object> flushMap = new HashMap<>();
             flushMap.put(LSMIOOperationCallback.KEY_FLUSH_LOG_LSN, flushLsn);
             flushMap.put(LSMIOOperationCallback.KEY_NEXT_COMPONENT_ID, nextComponentId);
             for (ILSMIndex lsmIndex : dsInfo.getDatasetPartitionOpenIndexes(partition)) {
                 if (lsmIndex.isPrimaryIndex()) {
+                    if (!lsmIndex.isAtomic() && flushLsn == 0) {
+                        LOGGER.warn("flushing an index {} with LSN 0. Flush log record: {}", () -> lsmIndex,
+                                logRecord::getLogRecordForDisplay);
+                    }
                     if (lsmIndex.isCurrentMutableComponentEmpty()) {
-                        LOGGER.debug("Primary index on dataset {} and partition {} is empty... skipping flush",
+                        LOGGER.trace("Primary index on dataset {} and partition {} is empty... skipping flush",
                                 dsInfo.getDatasetID(), partition);
                         return;
                     }
@@ -379,7 +380,7 @@
         for (ILSMIndex lsmIndex : indexes) {
             if (lsmIndex.isPrimaryIndex()) {
                 if (lsmIndex.isCurrentMutableComponentEmpty()) {
-                    LOGGER.info("Primary index on dataset {} and partition {} is empty... skipping delete",
+                    LOGGER.trace("Primary index on dataset {} and partition {} is empty... skipping delete",
                             dsInfo.getDatasetID(), partition);
                     return;
                 }
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/messaging/AtomicJobPreparedMessage.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/messaging/AtomicJobPreparedMessage.java
index b4832ff..d00b531 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/messaging/AtomicJobPreparedMessage.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/messaging/AtomicJobPreparedMessage.java
@@ -25,8 +25,6 @@
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.job.JobId;
 import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponentId;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
 
 /**
  * Message sent from an NC to CC for every partition handled by it after all
@@ -34,7 +32,6 @@
  */
 public class AtomicJobPreparedMessage implements ICcAddressedMessage {
 
-    private static final Logger LOGGER = LogManager.getLogger();
     private static final long serialVersionUID = 1L;
     private final JobId jobId;
     private final String nodeId;
@@ -51,4 +48,8 @@
         appCtx.getGlobalTxManager().handleJobPreparedMessage(jobId, nodeId, componentIdMap);
     }
 
+    @Override
+    public String toString() {
+        return "AtomicJobPreparedMessage{" + "jobId=" + jobId + ", nodeId='" + nodeId + '\'' + '}';
+    }
 }