From 1d5d1a6a4a0a58d6bb4803527dacb6641c027816 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Tue, 28 Jan 2014 13:34:12 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1288 :    Migrate I18n and logging support to i18n framework and SLF4J

---
 opendj3-server-dev/src/server/org/opends/server/replication/protocol/HeartbeatThread.java |   49 ++++++++++++++++++++-----------------------------
 1 files changed, 20 insertions(+), 29 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/protocol/HeartbeatThread.java b/opendj3-server-dev/src/server/org/opends/server/replication/protocol/HeartbeatThread.java
index 940844c..7a7e4ab 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/protocol/HeartbeatThread.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/protocol/HeartbeatThread.java
@@ -22,19 +22,16 @@
  *
  *
  *      Copyright 2008 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2013 ForgeRock AS
+ *      Portions Copyright 2011-2014 ForgeRock AS
  */
 package org.opends.server.replication.protocol;
 
 import java.io.IOException;
 
 import org.opends.server.api.DirectoryThread;
-import org.opends.server.loggers.debug.DebugTracer;
-import org.opends.server.types.DebugLogLevel;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.opends.server.util.StaticUtils;
 
-import static org.opends.server.loggers.debug.DebugLogger.*;
-
 /**
  * This thread publishes a {@link HeartbeatMsg} on a given protocol session at
  * regular intervals when there are no other replication messages being
@@ -44,10 +41,7 @@
  */
 public class HeartbeatThread extends DirectoryThread
 {
-  /**
-   * The tracer object for the debug logger.
-   */
-  private static final DebugTracer TRACER = getTracer();
+  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
 
   /**
@@ -97,9 +91,9 @@
   {
     try
     {
-      if (debugEnabled())
+      if (logger.isTraceEnabled())
       {
-        TRACER.debugInfo("Heartbeat thread is starting, interval is %d",
+        logger.trace("Heartbeat thread is starting, interval is %d",
                   heartbeatInterval);
       }
       HeartbeatMsg heartbeatMessage = new HeartbeatMsg();
@@ -107,9 +101,9 @@
       while (!shutdown)
       {
         long now = System.currentTimeMillis();
-        if (debugEnabled())
+        if (logger.isTraceEnabled())
         {
-          TRACER.debugVerbose("Heartbeat thread awoke at %d, last message " +
+          logger.trace("Heartbeat thread awoke at %d, last message " +
               "was sent at %d", now, session.getLastPublishTime());
         }
 
@@ -117,9 +111,9 @@
         {
           if (!heartbeatsDisabled)
           {
-            if (debugEnabled())
+            if (logger.isTraceEnabled())
             {
-              TRACER.debugVerbose("Heartbeat sent at %d", now);
+              logger.trace("Heartbeat sent at %d", now);
             }
             session.publish(heartbeatMessage);
           }
@@ -131,9 +125,9 @@
           sleepTime = heartbeatInterval;
         }
 
-        if (debugEnabled())
+        if (logger.isTraceEnabled())
         {
-          TRACER.debugVerbose("Heartbeat thread sleeping for %d", sleepTime);
+          logger.trace("Heartbeat thread sleeping for %d", sleepTime);
         }
 
         synchronized (shutdownLock)
@@ -147,10 +141,7 @@
             catch (InterruptedException e)
             {
               // Server shutdown monitor may interrupt slow threads.
-              if (debugEnabled())
-              {
-                TRACER.debugCaught(DebugLogLevel.ERROR, e);
-              }
+              logger.traceException(e);
               shutdown = true;
             }
           }
@@ -159,17 +150,17 @@
     }
     catch (IOException e)
     {
-      if (debugEnabled())
+      if (logger.isTraceEnabled())
       {
-        TRACER.debugInfo("Heartbeat thread could not send a heartbeat."
+        logger.trace("Heartbeat thread could not send a heartbeat."
             + StaticUtils.stackTraceToSingleLineString(e));
       }
     }
     finally
     {
-      if (debugEnabled())
+      if (logger.isTraceEnabled())
       {
-        TRACER.debugInfo("Heartbeat thread is exiting.");
+        logger.trace("Heartbeat thread is exiting.");
       }
     }
   }
@@ -185,14 +176,14 @@
     {
       shutdown = true;
       shutdownLock.notifyAll();
-      if (debugEnabled())
+      if (logger.isTraceEnabled())
       {
-        TRACER.debugInfo("Going to notify Heartbeat thread.");
+        logger.trace("Going to notify Heartbeat thread.");
       }
     }
-    if (debugEnabled())
+    if (logger.isTraceEnabled())
     {
-      TRACER.debugInfo("Returning from Heartbeat shutdown.");
+      logger.trace("Returning from Heartbeat shutdown.");
     }
   }
 

--
Gitblit v1.10.0