cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1154896 - in /cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering: AbstractStaticFailoverStrategy.java FailoverTargetSelector.java
Date Mon, 08 Aug 2011 09:53:48 GMT
Author: sergeyb
Date: Mon Aug  8 09:53:48 2011
New Revision: 1154896

URL: http://svn.apache.org/viewvc?rev=1154896&view=rev
Log:
[CXF-3596] Updating FailoverTargetSelector to check strategy specific delays between retries

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java?rev=1154896&r1=1154895&r2=1154896&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
Mon Aug  8 09:53:48 2011
@@ -42,8 +42,16 @@ public abstract class AbstractStaticFail
         LogUtils.getL7dLogger(AbstractStaticFailoverStrategy.class);
 
     private List<String> alternateAddresses;
+    private long delayBetweenRetries;
 
-
+    public void setDelayBetweenRetries(long delay) {
+        this.delayBetweenRetries = delay;
+    }
+    
+    public long getDelayBetweenRetries() {
+        return this.delayBetweenRetries;
+    }
+    
     public void setAlternateAddresses(List<String> alternateAddresses) {
         this.alternateAddresses = alternateAddresses;
     }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java?rev=1154896&r1=1154895&r2=1154896&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
Mon Aug  8 09:53:48 2011
@@ -132,6 +132,10 @@ public class FailoverTargetSelector exte
                 if (retry != null) {
                     try {
                         failover = true;
+                        long delay = getDelayBetweenRetries();
+                        if (delay > 0) {
+                            Thread.sleep(delay);
+                        }
                         retry.invoke(invocation.getBindingOperationInfo(),
                                      invocation.getParams(),
                                      invocation.getContext(),
@@ -188,6 +192,19 @@ public class FailoverTargetSelector exte
     }
 
     /**
+     * Returns delay (in milliseconds) between retries
+     * @return delay, 0 means no delay
+     */
+    protected long getDelayBetweenRetries() {
+        FailoverStrategy strategy = getStrategy();
+        if (strategy instanceof AbstractStaticFailoverStrategy) {
+            return ((AbstractStaticFailoverStrategy)strategy).getDelayBetweenRetries();
+        }
+        //perhaps supporting FailoverTargetSelector specific property can make sense too
+        return 0;
+    }
+    
+    /**
      * Check if the exchange is suitable for a failover.
      * 
      * @param exchange the current Exchange



Mime
View raw message