cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5586] Let custom strategies ovverride the default log level
Date Fri, 28 Feb 2014 17:09:01 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes b5a449b72 -> 119c07d0b


[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/119c07d0
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/119c07d0
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/119c07d0

Branch: refs/heads/2.7.x-fixes
Commit: 119c07d0b05c0f5f4229b1006b0a57b0116088c5
Parents: b5a449b
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Feb 28 17:06:43 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Feb 28 17:08:30 2014 +0000

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/119c07d0/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;    
+    }
 }


Mime
View raw message