Author: indika
Date: Wed Dec  5 20:15:16 2007
New Revision: 10571

Log:

clean up the api , improve perf


Modified:
   trunk/commons/throttle/modules/core/pom.xml
   
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/CallerContext.java
   
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/ThrottleConstants.java
   
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/ThrottleContext.java
   trunk/commons/throttle/modules/mar/pom.xml
   
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/GlobalThrottleHandler.java
   
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/OperationLevelThrottleHandler.java
   
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/ServiceLevelThrottleHandler.java
   
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/ThrottleHandler.java
   trunk/commons/throttle/pom.xml

Modified: trunk/commons/throttle/modules/core/pom.xml
==============================================================================
--- trunk/commons/throttle/modules/core/pom.xml (original)
+++ trunk/commons/throttle/modules/core/pom.xml Wed Dec  5 20:15:16 2007
@@ -5,7 +5,7 @@
 
     <parent>
         <groupId>org.wso2.throttle</groupId>
-        <artifactId>wso2-throttle</artifactId>
+        <artifactId>wso2throttle-parent</artifactId>
         <version>SNAPSHOT</version>
     </parent>
 
@@ -15,22 +15,22 @@
     <version>SNAPSHOT</version>
     <name>WSO2 Throttling module - core</name>
     <build>
-            <plugins>
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-compiler-plugin</artifactId>
-                    <version>2.0</version>
-                    <configuration>
-                        <source>1.4</source>
-                        <target>1.4</target>
-                    </configuration>
-                </plugin>
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-surefire-plugin</artifactId>
-                    <version>2.2</version>
-                </plugin>
-            </plugins>
-        </build>
-    
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.0</version>
+                <configuration>
+                    <source>1.4</source>
+                    <target>1.4</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.2</version>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>

Modified: 
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/CallerContext.java
==============================================================================
--- 
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/CallerContext.java
      (original)
+++ 
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/CallerContext.java
      Wed Dec  5 20:15:16 2007
@@ -27,7 +27,6 @@
  * Contains all runtime data for a particular remote caller.
  * provides the default rate based access controller algorithm implementation.
  * This is not thread-safe
- *
  */
 
 public abstract class CallerContext implements Serializable {
@@ -48,6 +47,9 @@
     private static final long serialVersionUID = 1652165180220263492L;
 
     public CallerContext(String ID) {
+        if (ID == null || "".equals(ID)) {
+            throw new InstantiationError("Couldn't create a CallContext for an 
empty remote caller ID");
+        }
         this.ID = ID;
     }
 
@@ -61,26 +63,25 @@
     /**
      * Init the access for a particular caller , caller will registered with 
context
      *
-     * @param configuration        -The Configuration for this caller
-     * @param throttleContext      -The Throttle Context
-     * @param currentTime          -The system current time in milliseconds
+     * @param configuration   -The Configuration for this caller
+     * @param throttleContext -The Throttle Context
+     * @param currentTime     -The system current time in milliseconds
      */
     private void initAccess(CallerConfiguration configuration, ThrottleContext 
throttleContext, long currentTime) {
         this.firstAccessTime = currentTime;  // set the first access time
-        // the end of this time window
-        this.nextTimeWindow = currentTime + configuration.getUnitTime();
-        throttleContext.addCallerContext(this); // register this in the 
throttle
+        this.nextTimeWindow = currentTime + configuration.getUnitTime();  // 
the end of this time window
+        throttleContext.addCallerContext(this, ID); // register this in the 
throttle
     }
 
     /**
      * To verify access if the unit time has already not overred
      *
-     * @param configuration -      -The Configuration for this caller
-     * @param throttleContext      -The Throttle Context
-     * @param currentTime          -The system current time
+     * @param configuration   -      -The Configuration for this caller
+     * @param throttleContext -The Throttle Context
+     * @param currentTime     -The system current time
      * @return boolean             -The boolean value which say access will 
allolw or not
      */
-    private boolean canAccessIfUnitTimeNotOver(CallerConfiguration 
configuration, ThrottleContext throttleContext,long currentTime) {
+    private boolean canAccessIfUnitTimeNotOver(CallerConfiguration 
configuration, ThrottleContext throttleContext, long currentTime) {
         boolean canAcess = false;
         int maxRequest = configuration.getMaximumRequestPerUnitTime();
         if (!(maxRequest == 0)) {
@@ -91,8 +92,8 @@
                 }
                 canAcess = true;     // can continue access
                 this.count++;
-
-                throttleContext.flushCaller(this); // Send the current state 
to others (clustered env)
+                // Send the current state to others (clustered env)
+                throttleContext.flushCallerContext(this, ID);
                 // can complete access
 
             } else {
@@ -115,7 +116,7 @@
                         log.debug("Maximum Number of requests are reached for 
caller with "
                             + type + " - " + this.ID);
                     }
-                    throttleContext.flushCaller(this); // Send the current 
state to others (clustered env)
+                    throttleContext.flushCallerContext(this, ID); // Send the 
current state to others (clustered env)
 
                 } else {
                     // else , if the caller has already prohabit and prohabit
@@ -127,8 +128,8 @@
                                 + " of available of " + maxRequest + " 
connections");
                         }
                         // remove previous caller context
-                        if(this.nextTimeWindow!= 0){
-                            throttleContext.removeCallerContext((new 
Long(this.nextTimeWindow)));
+                        if (this.nextTimeWindow != 0) {
+                            throttleContext.removeCallerContext(ID);
                         }
                         // reset the states so that, this is the first access
                         this.nextAccessTime = 0;
@@ -136,10 +137,8 @@
                         this.count = 1;// can access the system   and this is 
same as fristAccess
                         this.firstAccessTime = currentTime;
                         this.nextTimeWindow = currentTime + 
configuration.getUnitTime();
-                        // registers caller
-                        throttleContext.addCallerContext(this);
-                        throttleContext.flush();// Send the current state to 
others (clustered env)
-
+                        // registers caller and send the current state to 
others (clustered env)
+                        throttleContext.addAndFlushCallerContext(this, ID);
                     } else {
                         if (log.isDebugEnabled()) {
                             String type = ThrottleConstants.IP_BASE == 
configuration.getType() ?
@@ -158,9 +157,9 @@
     /**
      * To verify access if unit time has already overred
      *
-     * @param configuration -The Configuration for this caller
-     * @param throttleContext      -The Throttle that caller having pass
-     * @param currentTime          -The system current time
+     * @param configuration   -The Configuration for this caller
+     * @param throttleContext -The Throttle that caller having pass
+     * @param currentTime     -The system current time
      * @return boolean          -The boolean value which say access will 
allolw or not
      */
     private boolean canAccessIfUnitTimeOver(CallerConfiguration configuration, 
ThrottleContext throttleContext, long currentTime) {
@@ -172,8 +171,8 @@
         if (!(maxRequest == 0)) {
             if (this.count <= maxRequest - 1) {
                 if (this.nextTimeWindow != 0) {
-                    throttleContext.removeCallerContext(new 
Long(this.nextTimeWindow));
-                    throttleContext.flush();// Send the current state to 
others  (clustered env)
+                    // Removes and sends the current state to others  
(clustered env)
+                    throttleContext.removeAndFlushCaller(ID);
                 }
                 canAcess = true; // this is bounus access
                 //next time callers can access as a new one
@@ -190,7 +189,7 @@
                     }
                     //remove previous callercontext instance
                     if (this.nextTimeWindow != 0) {
-                        throttleContext.removeCallerContext(new 
Long(this.nextTimeWindow));
+                        throttleContext.removeCallerContext(ID);
                     }
                     // reset the states so that, this is the first access
                     this.nextAccessTime = 0;
@@ -198,10 +197,8 @@
                     this.count = 1;// can access the system   and this is same 
as frist Access
                     this.firstAccessTime = currentTime;
                     this.nextTimeWindow = currentTime + 
configuration.getUnitTime();
-                    // registers caller
-                    throttleContext.addCallerContext(this);
-                    throttleContext.flush();// Send the current state to 
others  (clustered env)
-
+                    // registers caller and send the current state to others 
(clustered env)
+                    throttleContext.addAndFlushCallerContext(this, ID);
                 } else {
                     // if  caller in prohabit session  and prohabit period has 
not  overed
                     if (log.isDebugEnabled()) {
@@ -220,9 +217,10 @@
 
     /**
      * Clean up the callers - remove all callers that have expired their time 
window
-     * @param configuration        -The Configuration for this caller
-     * @param throttleContext      -The Throttle that caller having pass
-     * @param currentTime          -The system current time
+     *
+     * @param configuration   -The Configuration for this caller
+     * @param throttleContext -The Throttle that caller having pass
+     * @param currentTime     -The system current time
      */
     public void cleanUpCallers(CallerConfiguration configuration, 
ThrottleContext throttleContext, long currentTime) {
 
@@ -230,7 +228,7 @@
             log.debug("Cleaning up the inactive caller's states ... ");
         }
         if (configuration == null) {
-            if(log.isDebugEnabled()){
+            if (log.isDebugEnabled()) {
                 log.debug("Couldn't find the configuration .");
             }
             return;
@@ -242,12 +240,11 @@
         if (!(maxRequest == 0)) {
             if (this.count <= maxRequest - 1) {
                 if (this.nextTimeWindow != 0) {
-                    if(log.isDebugEnabled()){
-                        log.debug("Removing caller with id "+this.ID);
+                    if (log.isDebugEnabled()) {
+                        log.debug("Removing caller with id " + this.ID);
                     }
-                    //remove the previous callercontext
-                    throttleContext.removeCallerContext(new 
Long(nextTimeWindow));
-                    throttleContext.flush();// Sends the current state to 
others (clustered env)
+                    //Removes the previous callercontext and Sends the current 
state to others (clustered env)
+                    throttleContext.removeAndFlushCaller(ID);
                 }
             } else {
                 // if number of access for a unit time has just been greater 
than MAX
@@ -260,9 +257,8 @@
                         if (log.isDebugEnabled()) {
                             log.debug("Removing caller with id " + this.ID);
                         }
-                         //remove the previous callercontext
-                        throttleContext.removeCallerContext(new 
Long(this.nextTimeWindow));
-                        throttleContext.flush();// Sends the current state to 
others (clustered env)
+                        //Removes the previous callercontext and Sends the 
current state to others (clustered env)
+                        throttleContext.removeAndFlushCaller(ID);
                     }
                 }
             }
@@ -298,7 +294,7 @@
         }
         // if unit time period (session time) is not over
         if (this.nextTimeWindow > currentTime) {
-            canAcess = 
canAccessIfUnitTimeNotOver(configuration,throttleContext, currentTime);
+            canAcess = canAccessIfUnitTimeNotOver(configuration, 
throttleContext, currentTime);
         } else {
             canAcess = canAccessIfUnitTimeOver(configuration, throttleContext, 
currentTime);
         }
@@ -318,6 +314,7 @@
 
     /**
      * Gets type of throttle that this caller belong  ex : ip/domain
+     *
      * @return Returns the type of the throttle
      */
     public abstract int getType();

Modified: 
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/ThrottleConstants.java
==============================================================================
--- 
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/ThrottleConstants.java
  (original)
+++ 
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/ThrottleConstants.java
  Wed Dec  5 20:15:16 2007
@@ -24,6 +24,10 @@
     private ThrottleConstants() {
 
     }
+    
+    /* Throttle module name */
+
+    public static final String THROTTLE_MODULE_NAME = "wso2throttle";
 
     /* Throttle namespace */
 

Modified: 
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/ThrottleContext.java
==============================================================================
--- 
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/ThrottleContext.java
    (original)
+++ 
trunk/commons/throttle/modules/core/src/main/java/org/wso2/throttle/ThrottleContext.java
    Wed Dec  5 20:15:16 2007
@@ -50,7 +50,7 @@
     /* The pre-prix of key for any caller */
     private String keyPrefix;
     /*is log level has set to debug */
-    private boolean debugOn ;
+    private boolean debugOn;
 
     /**
      * default constructor – expects a throttle configuration.
@@ -81,22 +81,22 @@
     /**
      * To get the runtime states of a remote caller
      *
-     * @param ID the remote caller id ex: domain , ip
+     * @param id the remote caller id ex: domain , ip
      * @return Returns the CallerContext which holds runtime state of a remote 
caller
      */
-    public CallerContext getCallerContext(String ID) {
+    public CallerContext getCallerContext(String id) {
+
+        if (id != null) {
 
-        String key = (String) 
throttleConfiguration.getConfigurationKeyOfCaller(ID);
-        if (key != null) {
             if (debugOn) {
-                log.debug("Found a configuration with id :" + key + " for the 
remote caller : " + ID);
+                log.debug("Found a configuration with id :" + id);
             }
             // for cluster env , caller state is contained in the axis 
configuration context
-            if (configctx != null && throttleId != null) {
-                return (CallerContext) 
configctx.getPropertyNonReplicable(keyPrefix + key);
+            if (configctx != null && keyPrefix != null) {
+                return (CallerContext) 
configctx.getPropertyNonReplicable(keyPrefix + id);
             }
             // for non - clustered  env
-            Long timeKey = (Long) keyToTimeStampMap.get(key);
+            Long timeKey = (Long) keyToTimeStampMap.get(id);
             if (timeKey != null) {
                 Object co = callersMap.get(timeKey);
                 if (co != null) {
@@ -106,18 +106,16 @@
                         LinkedList callers = (LinkedList) co;
                         for (Iterator it = callers.iterator(); it.hasNext();) {
                             CallerContext cc = (CallerContext) it.next();
-                            if (cc != null
-                                && key.equals(
-                                
throttleConfiguration.getConfigurationKeyOfCaller(cc.getID()))) {
+                            if (cc != null && id.equals(cc.getID())) {
                                 return cc;
                             }
                         }
                     }
                 }
             }
-        }  else {
-            if(debugOn){
-                log.debug("Couldn't find a configuration for the remote caller 
: "+ID);
+        } else {
+            if (debugOn) {
+                log.debug("Couldn't find a configuration for the remote caller 
: " + id);
             }
         }
         return null;
@@ -128,31 +126,28 @@
      * put time against remote caller id (ip/domain)
      *
      * @param callerContext - The remote caller's runtime data.
+     * @param id            - The id of the remote caller
      */
-    public void addCallerContext(CallerContext callerContext) {
-        if (callerContext != null) {
-            String keyOfConfiguration =
-                (String) 
throttleConfiguration.getConfigurationKeyOfCaller(callerContext.getID());
-            if (keyOfConfiguration != null) {
-                setCaller(callerContext, keyOfConfiguration);
-            }
+    public void addCallerContext(CallerContext callerContext, String id) {
+        if (callerContext != null && id != null) {
+            addCaller(callerContext, id);
         }
     }
 
     /**
-     * helper method to set a CallerContex Object
+     * Helper method to add a caller context
      *
-     * @param callerContext      - The CallerContext object
-     * @param keyOfConfiguration - The configuration key for caller
+     * @param callerContext The CallerContext
+     * @param id            The id of the remote caller
      */
-    private void setCaller(CallerContext callerContext, String 
keyOfConfiguration) {
+    private void addCaller(CallerContext callerContext, String id) {
 
         if (debugOn) {
-            log.debug("Setting the caller with an id " + 
callerContext.getID());
+            log.debug("Setting the caller with an id " + id);
         }
         //if this is a cluster env.,put the context into axis configuration 
contex
-        if (configctx != null && throttleId != null) {
-            configctx.setProperty(keyPrefix + keyOfConfiguration, 
callerContext);
+        if (configctx != null && keyPrefix != null) {
+            configctx.setProperty(keyPrefix + id, callerContext);
         }
 
         // for clean up list
@@ -161,80 +156,64 @@
             callersMap.put(time, callerContext);
         } else {
             //if there are callersMap with same timewindow ,then use 
linkedList to hold those
-            LinkedList callersWithSameTimeStampList = null;
             Object callerObject = callersMap.get(time);
             if (callerObject != null) {
                 if (callerObject instanceof CallerContext) {
-                    callersWithSameTimeStampList = new LinkedList();
-                    callersWithSameTimeStampList.add(callerObject);
-                    callersWithSameTimeStampList.add(callerContext);
+                    LinkedList callersWithSameTimeStamp = new LinkedList();
+                    callersWithSameTimeStamp.add(callerObject);
+                    callersWithSameTimeStamp.add(callerContext);
                     callersMap.remove(time);
+                    callersMap.put(time, callersWithSameTimeStamp);
                 } else if (callerObject instanceof LinkedList) {
-                    callersWithSameTimeStampList = (LinkedList) callerObject;
-                    callersWithSameTimeStampList.add(callerContext);
-                }
-                if (callersWithSameTimeStampList != null) {
-                    callersMap.put(time, callersWithSameTimeStampList);
+                    LinkedList callersWithSameTimeStamp = (LinkedList) 
callerObject;
+                    callersWithSameTimeStamp.add(callerContext);
                 }
             }
         }
         //set Time Vs key
-        keyToTimeStampMap.put(keyOfConfiguration, time);
+        keyToTimeStampMap.put(id, time);
     }
 
     /**
      * removing a caller with a given id - caller will remove from clean list
      *
-     * @param ID Caller ID
+     * @param id Caller ID
      */
-    public void removeCallerContext(Object ID) {
-        if (ID instanceof Long) {
-            removeCaller((Long) ID);
-        } else if (ID instanceof String) {
-            String key = 
throttleConfiguration.getConfigurationKeyOfCaller((String) ID);
-            Long time;
-            if (key != null) {
-                time = (Long) keyToTimeStampMap.get(key);
-                removeCaller(time);
-                keyToTimeStampMap.remove(key);
-            }
-
+    public void removeCallerContext(String id) {
+        if (id != null) {
+            removeCaller(id);
         }
     }
 
     /**
-     * To remove CallerContext by providing  the timeKey
+     * Helper method to remove a caller
      *
-     * @param timeKey the timestamp
+     * @param id The id of the caller
      */
-    private void removeCaller(Long timeKey) {
-        if (callersMap.containsKey(timeKey)) {
-            if (configctx != null && throttleId != null) {
-                CallerContext c = (CallerContext) callersMap.get(timeKey);
-                if (c != null) {
-                    String key =
-                        (String) 
throttleConfiguration.getConfigurationKeyOfCaller(c.getID());
-                    if (key != null) {
-                        if(debugOn){
-                            log.debug("Removing the caller with the 
configuration id "+ key);
-                        }
-                        configctx.removeProperty(keyPrefix + key);
-                    }
+    private void removeCaller(String id) {
+        Long time = (Long) keyToTimeStampMap.get(id);
+        if (time != null) {
+            if (configctx != null && keyPrefix != null) {
+                if (debugOn) {
+                    log.debug("Removing the caller with the configuration id " 
+ id);
                 }
+                configctx.removeProperty(keyPrefix + id);
             }
-            callersMap.remove(timeKey);
+            callersMap.remove(time);
+            keyToTimeStampMap.remove(id);
         }
     }
 
     /**
+     * /**
      * processing cleaning list- only process callerContexts which unit time 
already had overed
      *
-     * @param time - Current System Time
+     * @param time - the current System Time
      * @throws ThrottleException
      */
 
     public void processCleanList(long time) throws ThrottleException {
-        if(debugOn){
+        if (debugOn) {
             log.debug("Cleaning up process is executing");
         }
         if (time > nextCleanTime) {
@@ -247,7 +226,7 @@
                             CallerContext c = ((CallerContext) o);
                             String key = c.getID();
                             if (key != null) {
-                                if (configctx != null && throttleId != null) {
+                                if (configctx != null && keyPrefix != null) {
                                     c = (CallerContext) 
configctx.getPropertyNonReplicable(
                                         keyPrefix + key);
                                 }
@@ -265,7 +244,7 @@
                                 CallerContext c = (CallerContext) ite.next();
                                 String key = c.getID();
                                 if (key != null) {
-                                    if (configctx != null && throttleId != 
null) {
+                                    if (configctx != null && keyPrefix != 
null) {
                                         c = (CallerContext) 
configctx.getPropertyNonReplicable(
                                             keyPrefix + key);
                                     }
@@ -286,6 +265,9 @@
     }
 
     public void setThrottleId(String throttleId) {
+        if (throttleId == null) {
+            throw new IllegalArgumentException("The throttle id cann't be 
null");
+        }
         this.throttleId = throttleId;
         this.keyPrefix = ThrottleConstants.THROTTLE_PROPERTY_PREFIX + 
throttleId;
     }
@@ -308,33 +290,57 @@
     public abstract int getType();
 
     /**
-     * To replicates states of all callers
+     * To add the caller and replicates the states of the given caller
+     *
+     * @param callerContext The states of the caller
+     * @param id            The id of the caller
      */
-    public void flush() {
-        if (configctx != null) {
-            try {
-                if (debugOn) {
-                    log.debug("Going to replicate the states of all " +
-                        "calleres in the throttle : " + throttleId);
-                }
-                Replicator.replicate(configctx);
-            } catch (ClusteringFault clusteringFault) {
-                log.error("Error during the replicating states ", 
clusteringFault);
-            }
+    public void addAndFlushCallerContext(CallerContext callerContext, String 
id) {
+        if (callerContext != null && id != null) {
+            addCaller(callerContext, id);
+            replicateCaller(id);
         }
     }
 
     /**
-     * To replicates the states of the given caller
+     * To replicates the states of the already exist caller
+     *
      * @param callerContext The states of the caller
+     * @param id            The id of the remote caller
      */
-    public void flushCaller(CallerContext callerContext) {
-        if (configctx != null && callerContext != null) {
+    public void flushCallerContext(CallerContext callerContext, String id) {
+        if (configctx != null && callerContext != null && id != null) {
+            String key = keyPrefix + id;
+            configctx.setProperty(key, callerContext); // have to do ,because 
we always gets any propery as non-replicable
+            replicateCaller(id);
+        }
+    }
+
+    /**
+     * Removes the caller and repicate the states
+     *
+     * @param id The Id of the caller
+     */
+    public void removeAndFlushCaller(String id) {
+        if (id != null) {
+            removeCaller(id);
+            replicateCaller(id);
+        }
+    }
+
+    /**
+     * Helper method to replicates satates of the caller with given key
+     *
+     * @param id The id of the caller
+     */
+    private void replicateCaller(String id) {
+
+        if (configctx != null && keyPrefix != null) {
             try {
                 if (debugOn) {
-                    log.debug("Going to replicate the states of the caller : " 
+ callerContext.getID());
+                    log.debug("Going to replicate the states of the caller : " 
+ id);
                 }
-                configctx.setProperty(keyPrefix + callerContext.getID(), 
callerContext);
+//                Replicator.replicate(configctx, new String[]{keyPrefix + 
id});
                 Replicator.replicate(configctx);
             } catch (ClusteringFault clusteringFault) {
                 log.error("Error during the replicating states ", 
clusteringFault);

Modified: trunk/commons/throttle/modules/mar/pom.xml
==============================================================================
--- trunk/commons/throttle/modules/mar/pom.xml  (original)
+++ trunk/commons/throttle/modules/mar/pom.xml  Wed Dec  5 20:15:16 2007
@@ -5,7 +5,7 @@
 
     <parent>
         <groupId>org.wso2.throttle</groupId>
-        <artifactId>wso2-throttle</artifactId>
+        <artifactId>wso2throttle-parent</artifactId>
         <version>SNAPSHOT</version>
     </parent>
 
@@ -17,7 +17,6 @@
 
     <build>
         <plugins>
-
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-antrun-plugin</artifactId>

Modified: 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/GlobalThrottleHandler.java
==============================================================================
--- 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/GlobalThrottleHandler.java
        (original)
+++ 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/GlobalThrottleHandler.java
        Wed Dec  5 20:15:16 2007
@@ -31,7 +31,7 @@
     }
 
     public InvocationResponse invoke(MessageContext msgContext) throws 
AxisFault {
-        if (msgContext.isEngaged("wso2throttle")) {
+        if (msgContext.isEngaged(ThrottleConstants.THROTTLE_MODULE_NAME)) {
             return super.invoke(msgContext);
         }
         return InvocationResponse.CONTINUE;

Modified: 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/OperationLevelThrottleHandler.java
==============================================================================
--- 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/OperationLevelThrottleHandler.java
        (original)
+++ 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/OperationLevelThrottleHandler.java
        Wed Dec  5 20:15:16 2007
@@ -30,7 +30,7 @@
     }
 
     public InvocationResponse invoke(MessageContext msgContext) throws 
AxisFault {
-        if (msgContext.isEngaged("wso2throttle")) {
+        if (msgContext.isEngaged(ThrottleConstants.THROTTLE_MODULE_NAME)) {
             return super.invoke(msgContext);
         }
         return InvocationResponse.CONTINUE;

Modified: 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/ServiceLevelThrottleHandler.java
==============================================================================
--- 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/ServiceLevelThrottleHandler.java
  (original)
+++ 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/ServiceLevelThrottleHandler.java
  Wed Dec  5 20:15:16 2007
@@ -31,7 +31,7 @@
     }
 
     public InvocationResponse invoke(MessageContext msgContext) throws 
AxisFault {
-        if (msgContext.isEngaged("wso2throttle")) {
+        if (msgContext.isEngaged(ThrottleConstants.THROTTLE_MODULE_NAME)) {
             return super.invoke(msgContext);
         }
         return InvocationResponse.CONTINUE;

Modified: 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/ThrottleHandler.java
==============================================================================
--- 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/ThrottleHandler.java
      (original)
+++ 
trunk/commons/throttle/modules/mar/src/main/java/org/wso2/throttle/module/handler/ThrottleHandler.java
      Wed Dec  5 20:15:16 2007
@@ -52,7 +52,7 @@
     }
 
     /**
-     * @return int - indicates the type of the throttle according to the scope 
+     * @return int - indicates the type of the throttle according to the scope
      */
     protected abstract int getThrottleType();
 
@@ -154,9 +154,10 @@
 
         // Get the concurrent access controller
         ConcurrentAccessController cac;
+        String key = null;
         if (isClusteringEnable) {
             // for clustered  env.,gets it from axis configuration context
-            String key = ThrottleConstants.THROTTLE_PROPERTY_PREFIX + 
throttleId
+            key = ThrottleConstants.THROTTLE_PROPERTY_PREFIX + throttleId
                 + ThrottleConstants.CAC_SUFFIX;
             cac = (ConcurrentAccessController) cc.getProperty(key);
         } else {
@@ -202,7 +203,7 @@
                                 }
                                 //check for the permission for access
                                 if (!accessRateController.canAccess(context, 
callerId,
-                                                                
ThrottleConstants.DOMAIN_BASE)) {
+                                    ThrottleConstants.DOMAIN_BASE)) {
 
                                     //In the case of both of concurrency 
throttling and
                                     //rate based throttling have enabled ,
@@ -213,18 +214,15 @@
                                         cac.incrementAndGet();
                                         // set back if this is a clustered env
                                         if (isClusteringEnable) {
-                                            String key =
-                                                
ThrottleConstants.THROTTLE_PROPERTY_PREFIX
-                                                    + throttleId + 
ThrottleConstants.CAC_SUFFIX;
                                             cc.setProperty(key, cac);
-                                            
-                                             //replicate the current state of 
ConcurrentAccessController
+                                            //replicate the current state of 
ConcurrentAccessController
                                             try {
                                                 if (debugOn) {
                                                     log.debug("Going to 
replicates the " +
                                                         "states of the 
ConcurrentAccessController" +
                                                         " with key : " + key);
                                                 }
+//                                                Replicator.replicate(cc, new 
String[]{key});
                                                 Replicator.replicate(cc);
                                             } catch (ClusteringFault 
clusteringFault) {
                                                 log.error("Error during 
replicating states ",
@@ -284,11 +282,7 @@
                                             cac.incrementAndGet();
                                             // set back if this is a clustered 
env
                                             if (isClusteringEnable) {
-                                                String key =
-                                                    
ThrottleConstants.THROTTLE_PROPERTY_PREFIX
-                                                        + throttleId + 
ThrottleConstants.CAC_SUFFIX;
                                                 cc.setProperty(key, cac);
-
                                                 //replicate the current state 
of ConcurrentAccessController
                                                 try {
                                                     if (debugOn) {
@@ -296,10 +290,11 @@
                                                             "states of the 
ConcurrentAccessController" +
                                                             " with key : " + 
key);
                                                     }
+//                                                    Replicator.replicate(cc, 
new String[]{key});
                                                     Replicator.replicate(cc);
                                                 } catch (ClusteringFault 
clusteringFault) {
                                                     log.error("Error during 
replicating states ",
-                                                                               
 clusteringFault);
+                                                        clusteringFault);
                                                 }
                                             }
                                         }
@@ -327,12 +322,10 @@
             if (isClusteringEnable && cac != null) {
                 try {
                     if (debugOn) {
-                        String key =
-                            ThrottleConstants.THROTTLE_PROPERTY_PREFIX
-                                + throttleId + ThrottleConstants.CAC_SUFFIX;
                         log.debug("Going to replicates the states of the 
ConcurrentAccessController" +
                             " with key : " + key);
                     }
+//                    Replicator.replicate(cc, new String[]{key});
                     Replicator.replicate(cc);
                 } catch (ClusteringFault clusteringFault) {
                     log.error("Error during replicating states ", 
clusteringFault);
@@ -344,12 +337,10 @@
             if (isClusteringEnable) {
                 try {
                     if (debugOn) {
-                        String key =
-                            ThrottleConstants.THROTTLE_PROPERTY_PREFIX
-                                + throttleId + ThrottleConstants.CAC_SUFFIX;
                         log.debug("Going to replicates the states of the 
ConcurrentAccessController" +
                             " with key : " + key);
                     }
+//                    Replicator.replicate(cc, new String[]{key});
                     Replicator.replicate(cc);
                 } catch (ClusteringFault clusteringFault) {
                     log.error("Error during replicating states ", 
clusteringFault);
@@ -363,8 +354,9 @@
 
     /**
      * Helper method for handling concurrent throttling
+     *
      * @param concurrentAccessController ConcurrentAccessController
-     * @param messageContext  MessageContext - message lavel states
+     * @param messageContext             MessageContext - message lavel states
      * @return true if access is allowed through concurrent throttling ,o.w 
false
      */
     private boolean doConcurrentThrottling(ConcurrentAccessController 
concurrentAccessController, MessageContext messageContext) {

Modified: trunk/commons/throttle/pom.xml
==============================================================================
--- trunk/commons/throttle/pom.xml      (original)
+++ trunk/commons/throttle/pom.xml      Wed Dec  5 20:15:16 2007
@@ -4,7 +4,7 @@
 
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.wso2.throttle</groupId>
-    <artifactId>wso2-throttle</artifactId>
+    <artifactId>wso2throttle-parent</artifactId>
     <packaging>pom</packaging>
     <version>SNAPSHOT</version>
     <name>WSO2 throttle module</name>
@@ -43,12 +43,6 @@
             <version>${axiom.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.ws.commons.axiom</groupId>
-            <artifactId>axiom-dom</artifactId>
-            <version>${axiom.version}</version>
-        </dependency>
-
         <!-- Thrid party dependencies -->
         <dependency>
             <groupId>commons-logging</groupId>
@@ -83,6 +77,11 @@
             <version>${neethi.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport.util.concurrent.version}</version>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.ant</groupId>
@@ -90,7 +89,7 @@
             <version>${ant.version}</version>
         </dependency>
 
-       <dependency>
+        <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>
             <version>${servlet-api.version}</version>
@@ -196,5 +195,6 @@
         <log4j.version>1.2.13</log4j.version>
         <ant.version>1.7.0</ant.version>
         <servlet-api.version>2.3</servlet-api.version>
+        
<backport.util.concurrent.version>2.2</backport.util.concurrent.version>        
   
     </properties>
 </project>

_______________________________________________
Commons-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/commons-dev

Reply via email to