You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2014/02/28 18:07:02 UTC

git commit: [CXF-5586] Let custom strategies ovverride the default log level

Repository: cxf
Updated Branches:
  refs/heads/master 9423ee7e1 -> c58518d61


[CXF-5586] Let custom strategies ovverride the default log level


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/c58518d6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c58518d6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c58518d6

Branch: refs/heads/master
Commit: c58518d61280c8ac4ee805730a888cb2ea831eda
Parents: 9423ee7
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Fri Feb 28 17:06:43 2014 +0000
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Fri Feb 28 17:06:43 2014 +0000

----------------------------------------------------------------------
 .../AbstractStaticFailoverStrategy.java         | 36 ++++++++++++++------
 1 file changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c58518d6/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
----------------------------------------------------------------------
diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
index 6d8b044..5b2ade9 100644
--- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
+++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
@@ -78,9 +78,12 @@ public abstract class AbstractStaticFailoverStrategy implements FailoverStrategy
         String selected = null;
         if (alternates != null && alternates.size() > 0) {
             selected = getNextAlternate(alternates);
-            LOG.log(Level.WARNING,
-                    "FAILING_OVER_TO_ADDRESS_OVERRIDE",
-                    selected);
+            Level level = getLogLevel();
+            if (LOG.isLoggable(level)) {
+                LOG.log(level,
+                        "FAILING_OVER_TO_ADDRESS_OVERRIDE",
+                        selected);
+            }
         } else {
             LOG.warning("NO_ALTERNATE_TARGETS_REMAIN");
         }
@@ -107,10 +110,13 @@ public abstract class AbstractStaticFailoverStrategy implements FailoverStrategy
         Endpoint selected = null;
         if (alternates != null && alternates.size() > 0) {
             selected = getNextAlternate(alternates);
-            LOG.log(Level.WARNING,
-                    "FAILING_OVER_TO_ALTERNATE_ENDPOINT",
-                     new Object[] {selected.getEndpointInfo().getName(),
-                                   selected.getEndpointInfo().getAddress()});
+            Level level = getLogLevel();
+            if (LOG.isLoggable(level)) {
+                LOG.log(level,
+                        "FAILING_OVER_TO_ALTERNATE_ENDPOINT",
+                         new Object[] {selected.getEndpointInfo().getName(),
+                                       selected.getEndpointInfo().getAddress()});
+            }
         } else {
             LOG.warning("NO_ALTERNATE_TARGETS_REMAIN");
         }
@@ -138,15 +144,15 @@ public abstract class AbstractStaticFailoverStrategy implements FailoverStrategy
                              endpoint.getEndpointInfo().getAddress())) {
                         Endpoint alternate =
                             endpoint.getService().getEndpoints().get(candidate.getName());
-                        if (alternate != null) {
-                            LOG.log(Level.INFO,
+                        if (alternate != null && LOG.isLoggable(Level.FINE)) {
+                            LOG.log(Level.FINE,
                                     "FAILOVER_CANDIDATE_ACCEPTED",
                                     candidate.getName());
                             alternates.add(alternate);
                         }
                     }
-                } else {
-                    LOG.log(Level.INFO,
+                } else if (LOG.isLoggable(Level.FINE)) {
+                    LOG.log(Level.FINE,
                             "FAILOVER_CANDIDATE_REJECTED",
                             new Object[] {candidate.getName(), candidateBinding});
                 }
@@ -162,4 +168,12 @@ public abstract class AbstractStaticFailoverStrategy implements FailoverStrategy
      * @return
      */
     protected abstract <T> T getNextAlternate(List<T> alternates);
+    
+    /**
+     * Get the log level for reporting the selection of the new alternative address or endpoint 
+     * @return the log level
+     */
+    protected Level getLogLevel() {
+        return Level.WARNING;    
+    }
 }