tephra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From poo...@apache.org
Subject incubator-tephra git commit: TEPHRA-266 Identify log messages when multiple instances of Tephra run on a single HBase cluster
Date Wed, 02 May 2018 01:17:54 GMT
Repository: incubator-tephra
Updated Branches:
  refs/heads/master 84edc08cc -> 40817bfa1


TEPHRA-266 Identify log messages when multiple instances of Tephra run on a single HBase cluster

Signed-off-by: poorna <poorna@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-tephra/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tephra/commit/40817bfa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tephra/tree/40817bfa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tephra/diff/40817bfa

Branch: refs/heads/master
Commit: 40817bfa1f76f4bc081359b335e7d743ac6e5960
Parents: 84edc08
Author: poorna <poorna@apache.org>
Authored: Wed Apr 25 18:58:52 2018 -0700
Committer: poorna <poorna@apache.org>
Committed: Tue May 1 16:53:51 2018 -0700

----------------------------------------------------------------------
 .../coprocessor/TransactionStateCache.java      | 27 ++++++++++++++------
 1 file changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tephra/blob/40817bfa/tephra-core/src/main/java/org/apache/tephra/coprocessor/TransactionStateCache.java
----------------------------------------------------------------------
diff --git a/tephra-core/src/main/java/org/apache/tephra/coprocessor/TransactionStateCache.java
b/tephra-core/src/main/java/org/apache/tephra/coprocessor/TransactionStateCache.java
index ac329f9..95d15ae 100644
--- a/tephra-core/src/main/java/org/apache/tephra/coprocessor/TransactionStateCache.java
+++ b/tephra-core/src/main/java/org/apache/tephra/coprocessor/TransactionStateCache.java
@@ -55,6 +55,7 @@ public class TransactionStateCache extends AbstractIdleService implements
Config
   // snapshot refresh frequency in milliseconds
   private long snapshotRefreshFrequency;
   private boolean initialized;
+  private String logPrefix = "";
 
   public TransactionStateCache() {
   }
@@ -103,10 +104,10 @@ public class TransactionStateCache extends AbstractIdleService implements
Config
                                                      TxConstants.Manager.DEFAULT_TX_SNAPSHOT_INTERVAL)
* 1000;
         this.initialized = true;
       } else {
-        LOG.info("Could not load configuration");
+        LOG.info(prefixLog("Could not load configuration"));
       }
     } catch (Exception e) {
-      LOG.info("Failed to initialize TransactionStateCache due to: ", e);
+      LOG.info(prefixLog("Failed to initialize TransactionStateCache due to: "), e);
     }
   }
 
@@ -131,7 +132,7 @@ public class TransactionStateCache extends AbstractIdleService implements
Config
             try {
               refreshState();
             } catch (IOException ioe) {
-              LOG.info("Error refreshing transaction state cache.", ioe);
+              LOG.info(prefixLog("Error refreshing transaction state cache."), ioe);
             }
           }
           try {
@@ -142,7 +143,7 @@ public class TransactionStateCache extends AbstractIdleService implements
Config
             break;
           }
         }
-        LOG.info("Exiting thread " + getName());
+        LOG.info(prefixLog("Exiting thread " + getName()));
       }
     };
     this.refreshService.setDaemon(true);
@@ -160,18 +161,18 @@ public class TransactionStateCache extends AbstractIdleService implements
Config
       TransactionVisibilityState currentState = storage.getLatestTransactionVisibilityState();
       if (currentState != null) {
         if (currentState.getTimestamp() < (now - 2 * snapshotRefreshFrequency)) {
-          LOG.info("Current snapshot is old, will force a refresh on next run.");
+          LOG.info(prefixLog("Current snapshot is old, will force a refresh on next run."));
           reset();
         } else {
           latestState = currentState;
-          LOG.info("Transaction state reloaded with snapshot from " + latestState.getTimestamp());
+          LOG.info(prefixLog("Transaction state reloaded with snapshot from " + latestState.getTimestamp()));
           if (LOG.isDebugEnabled()) {
-            LOG.debug("Latest transaction snapshot: " + latestState.toString());
+            LOG.debug(prefixLog("Latest transaction snapshot: " + latestState.toString()));
           }
           lastRefresh = now;
         }
       } else {
-        LOG.info("No transaction state found.");
+        LOG.info(prefixLog("No transaction state found."));
       }
     }
   }
@@ -180,4 +181,14 @@ public class TransactionStateCache extends AbstractIdleService implements
Config
   public TransactionVisibilityState getLatestState() {
     return latestState;
   }
+
+  protected void setId(@Nullable String id) {
+    if (id != null) {
+      this.logPrefix = "[" + id + "] ";
+    }
+  }
+
+  private String prefixLog(String message) {
+    return logPrefix + message;
+  }
 }


Mime
View raw message