This is an automated email from the ASF dual-hosted git repository.

ddanielr pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new 75140d8965 Add Message Prefix for File deletion actions in GCRun 
(#3745)
75140d8965 is described below

commit 75140d8965009d9a9cbc5b59e704ea9f7e8826b7
Author: Daniel Roberts <ddani...@gmail.com>
AuthorDate: Mon Sep 18 14:12:58 2023 -0400

    Add Message Prefix for File deletion actions in GCRun (#3745)
    
    * Changes the logger name and removes the space and "class" info from the
        name.
    
    * Moves datalevel to the end of the logger name to ensure it shows up
       in log messages.
    
    * Add comment regarding logger creation
    
    Co-authored-by: EdColeman <d...@etcoleman.com>
    
    * Adds a message prefix which can be picked up by a regexFilter.
    
    * Update log error message in GCRun.java
       Remove redundant `e.getMessage()` in log message
    
    Co-authored-by: Christopher Tubbs <ctubb...@apache.org>
    
    * Makes fileActionPrefix final
    
    Co-authored-by: Christopher Tubbs <ctubb...@apache.org>
    
    * Update non-descriptive log message
    
    ---------
    
    Co-authored-by: EdColeman <d...@etcoleman.com>
    Co-authored-by: Christopher Tubbs <ctubb...@apache.org>
---
 .../main/java/org/apache/accumulo/gc/GCRun.java    | 24 +++++++++++++---------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java 
b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
index 515feb6fbc..4af97d3a25 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
@@ -87,7 +87,9 @@ import com.google.protobuf.InvalidProtocolBufferException;
  * A single garbage collection performed on a table (Root, MD) or all User 
tables.
  */
 public class GCRun implements GarbageCollectionEnvironment {
+  // loggers are not static to support unique naming by level
   private final Logger log;
+  private static final String fileActionPrefix = "FILE-ACTION:";
   private final Ample.DataLevel level;
   private final ServerContext context;
   private final AccumuloConfiguration config;
@@ -97,7 +99,7 @@ public class GCRun implements GarbageCollectionEnvironment {
   private long errors = 0;
 
   public GCRun(Ample.DataLevel level, ServerContext context) {
-    this.log = LoggerFactory.getLogger(level.name() + GCRun.class);
+    this.log = LoggerFactory.getLogger(GCRun.class.getName() + "." + 
level.name());
     this.level = level;
     this.context = context;
     this.config = context.getConfiguration();
@@ -236,9 +238,9 @@ public class GCRun implements GarbageCollectionEnvironment {
       System.out.println("SAFEMODE: There are " + confirmedDeletes.size()
           + " data file candidates marked for deletion in " + metadataLocation 
+ ".\n"
           + "          Examine the log files to identify them.\n");
-      log.info("SAFEMODE: Listing all data file candidates for deletion");
+      log.info("{} SAFEMODE: Listing all data file candidates for deletion", 
fileActionPrefix);
       for (String s : confirmedDeletes.values()) {
-        log.info("SAFEMODE: {}", s);
+        log.info("{} SAFEMODE: {}", fileActionPrefix, s);
       }
       log.info("SAFEMODE: End candidates for deletion");
       return;
@@ -278,7 +280,7 @@ public class GCRun implements GarbageCollectionEnvironment {
           }
 
           for (Path pathToDel : GcVolumeUtil.expandAllVolumesUri(fs, 
fullPath)) {
-            log.debug("Deleting {}", pathToDel);
+            log.debug("{} Deleting {}", fileActionPrefix, pathToDel);
 
             if (moveToTrash(pathToDel) || fs.deleteRecursively(pathToDel)) {
               // delete succeeded, still want to delete
@@ -288,7 +290,8 @@ public class GCRun implements GarbageCollectionEnvironment {
               // leave the entry in the metadata; we'll try again later
               removeFlag = false;
               errors++;
-              log.warn("File exists, but was not deleted for an unknown 
reason: {}", pathToDel);
+              log.warn("{} File exists, but was not deleted for an unknown 
reason: {}",
+                  fileActionPrefix, pathToDel);
               break;
             } else {
               // this failure, we still want to remove the metadata entry
@@ -303,11 +306,11 @@ public class GCRun implements 
GarbageCollectionEnvironment {
                 if (tableState != null && tableState != TableState.DELETING) {
                   // clone directories don't always exist
                   if (!tabletDir.startsWith(Constants.CLONE_PREFIX)) {
-                    log.debug("File doesn't exist: {}", pathToDel);
+                    log.debug("{} File doesn't exist: {}", fileActionPrefix, 
pathToDel);
                   }
                 }
               } else {
-                log.warn("Very strange path name: {}", delete);
+                log.warn("{} Invalid file path format: {}", fileActionPrefix, 
delete);
               }
             }
           }
@@ -318,7 +321,7 @@ public class GCRun implements GarbageCollectionEnvironment {
             processedDeletes.add(delete);
           }
         } catch (Exception e) {
-          log.error("{}", e.getMessage(), e);
+          log.error("{} Exception while deleting files ", fileActionPrefix, e);
         }
 
       };
@@ -353,7 +356,7 @@ public class GCRun implements GarbageCollectionEnvironment {
 
       if (tabletDirs.length == 0) {
         Path p = new Path(dir + "/" + tableID);
-        log.debug("Removing table dir {}", p);
+        log.debug("{} Removing table dir {}", fileActionPrefix, p);
         if (!moveToTrash(p)) {
           fs.delete(p);
         }
@@ -437,7 +440,8 @@ public class GCRun implements GarbageCollectionEnvironment {
           }
 
           if (sameVol) {
-            logger.info("Ignoring {} because {} exist", entry.getValue(), 
lastDirAbs);
+            logger.info("{} Ignoring {} because {} exist", fileActionPrefix, 
entry.getValue(),
+                lastDirAbs);
             processedDeletes.add(entry.getValue());
             cdIter.remove();
           }

Reply via email to