Author: indika
Date: Thu Nov 29 01:26:08 2007
New Revision: 599354

URL: http://svn.apache.org/viewvc?rev=599354&view=rev
Log:
optimize the replication in the throttling 

Modified:
    
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/MessageHelper.java
    
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/throttle/ThrottleMediator.java

Modified: 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/MessageHelper.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/MessageHelper.java?rev=599354&r1=599353&r2=599354&view=diff
==============================================================================
--- 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/MessageHelper.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/MessageHelper.java
 Thu Nov 29 01:26:08 2007
@@ -15,6 +15,7 @@
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.wso2.throttle.ThrottleConstants;
 
 import java.util.Iterator;
 import java.util.ArrayList;
@@ -177,7 +178,16 @@
 
         for (Object o1 : ori.getProperties().keySet()) {
             String key = (String) o1;
-            newMC.setProperty(key, ori.getProperty(key));
+            if (key != null) {
+                //In clustered environment, all the properties related to the 
throttle ,
+                //will be replicated explicitly  by throttling Mediator ,
+                //therefore It should avoid any implicitly replication from 
any other component 
+                if 
(key.startsWith(ThrottleConstants.THROTTLE_PROPERTY_PREFIX)) {
+                    newMC.setNonReplicableProperty(key, 
ori.getPropertyNonReplicable(key));
+                } else {
+                    newMC.setProperty(key, ori.getProperty(key));
+                }
+            }
         }
 
         newMC.setServerSide(false);

Modified: 
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/throttle/ThrottleMediator.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/throttle/ThrottleMediator.java?rev=599354&r1=599353&r2=599354&view=diff
==============================================================================
--- 
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/throttle/ThrottleMediator.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/throttle/ThrottleMediator.java
 Thu Nov 29 01:26:08 2007
@@ -122,7 +122,6 @@
                             trace.trace("Initializing using static throttling 
policy : "
                                                                                
     + inLinePolicy);
                         }
-
                         try {
                             // process the policy
                             throttle = ThrottlePolicyProcessor.processPolicy(
@@ -225,13 +224,18 @@
         if (throttle != null && !isResponse && canAccess) {
             canAccess = throttleByAccessRate(synCtx, axisMC, cc, 
traceOrDebugOn, traceOn);
         }
-        //replicate the current state
-        if (isClusteringEnable) {
+        // all the replication functionality of the access rate based 
throttling handles by itself 
+        // Just replicate the current state of ConcurrentAccessController
+        if (isClusteringEnable && concurrentAccessController != null) {
             if (cc != null) {
                 try {
+                    if (traceOrDebugOn) {
+                        traceOrDebug(traceOn, "Going to replicates the  " +
+                            "states of the ConcurrentAccessController with key 
: " + key);
+                    }
                     Replicator.replicate(cc);
                 } catch (ClusteringFault clusteringFault) {
-                    handleException("Error during replicate states ", 
clusteringFault, synCtx);
+                    handleException("Error during the replicating  states ", 
clusteringFault, synCtx);
                 }
             }
         }
@@ -293,13 +297,13 @@
                 available = concurrentAccessController.getAndDecrement();
                 canAcess = available > 0;
                 if (traceOrDebugOn) {
-                    traceOrDebug(traceOn, "Access " + (canAcess ? "allowed" : 
"denied") +
+                    traceOrDebug(traceOn, "Concurrency Throttle : Access " + 
(canAcess ? "allowed" : "denied") +
                         " :: " + available + " of available of " + 
concurrentLimit + " connections");
                 }
             } else {
                 available = concurrentAccessController.incrementAndGet();
                 if (traceOrDebugOn) {
-                    traceOrDebug(traceOn, "Connection returned" +
+                    traceOrDebug(traceOn, "Concurrency Throttle : Connection 
returned" +
                         " :: " + available + " of available of " + 
concurrentLimit + " connections");
                 }
             }
@@ -366,7 +370,10 @@
                             //then it is possible to occur death situation.To 
avoid that reset,
                             //if the access has denied by rate based throttling
                             if (!canAccess && concurrentAccessController != 
null) {
-                                
concurrentAccessController.set(concurrentAccessController.getLimit());
+                                concurrentAccessController.incrementAndGet();
+                                if (isClusteringEnable) {
+                                    cc.setProperty(key, 
concurrentAccessController);
+                                }
                             }
                         } catch (ThrottleException e) {
                             handleException("Error occurd during throttling", 
e, synCtx);
@@ -425,8 +432,10 @@
                                 //then it is possible to occur death 
situation.To avoid that reset,
                                 //if the access has denied by rate based 
throttling
                                 if (!canAccess && concurrentAccessController 
!= null) {
-                                    concurrentAccessController.set(
-                                                              
concurrentAccessController.getLimit());
+                                    
concurrentAccessController.incrementAndGet();
+                                    if (isClusteringEnable) {
+                                        cc.setProperty(key, 
concurrentAccessController);
+                                    }
                                 }
                             }
                         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to