cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1154901 - in /cxf/branches/2.4.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
Date Mon, 08 Aug 2011 10:12:47 GMT
Author: sergeyb
Date: Mon Aug  8 10:12:47 2011
New Revision: 1154901

URL: http://svn.apache.org/viewvc?rev=1154901&view=rev
Log:
Merged revisions 1154900 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1154900 | sergeyb | 2011-08-08 11:11:42 +0100 (Mon, 08 Aug 2011) | 1 line
  
  [CXF-3596] Updating RetryStrategy to optionally move to the next address after specific
number of retries
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  8 10:12:47 2011
@@ -1 +1 @@
-/cxf/trunk:1154143,1154149,1154158,1154229,1154232,1154466,1154870,1154896
+/cxf/trunk:1154143,1154149,1154158,1154229,1154232,1154466,1154870,1154896,1154900

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java?rev=1154901&r1=1154900&r2=1154901&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
Mon Aug  8 10:12:47 2011
@@ -32,13 +32,46 @@ import org.apache.cxf.message.Exchange;
  */
 public class RetryStrategy extends SequentialStrategy {
 
+    private int maxNumberOfRetries;
+    private int counter;
+    
     /* (non-Javadoc)
      * @see org.apache.cxf.clustering.AbstractStaticFailoverStrategy#getAlternateEndpoints(
      * org.apache.cxf.message.Exchange)
      */
     @Override
     public List<Endpoint> getAlternateEndpoints(Exchange exchange) {
-        return getEndpoints(exchange, true);
+        return getEndpoints(exchange, stillTheSameAddress());
+    }
+
+    protected boolean stillTheSameAddress() {
+        if (maxNumberOfRetries == 0) {
+            return true;
+        }
+        // let the target selector move to the next address
+        // and then stay on the same address for maxNumberOfRetries
+        synchronized (this) {
+            if (++counter <= maxNumberOfRetries) {
+                return true;    
+            } else {
+                counter = 0;
+                return false;
+            }
+        }
+        
+    }
+    
+
+    public void setMaxNumberOfRetries(int maxNumberOfRetries) {
+        if (maxNumberOfRetries < 0) {
+            throw new IllegalArgumentException();
+        }
+        this.maxNumberOfRetries = maxNumberOfRetries;
+    }
+
+
+    public int getMaxNumberOfRetries() {
+        return maxNumberOfRetries;
     }
 
 }
\ No newline at end of file



Mime
View raw message