Changeset 1119 for raptor-client


Ignore:
Timestamp:
09/19/11 18:13:30 (9 years ago)
Author:
philsmart
Message:
 
Location:
raptor-client/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • raptor-client/trunk/pom.xml

    r1111 r1119  
    2727 
    2828        <properties> 
    29                 <apache.cxf.version>2.2.7</apache.cxf.version> 
     29                <apache.cxf.version>2.2.8</apache.cxf.version> 
    3030                <spring.version>3.0.3.RELEASE</spring.version> 
    3131        </properties> 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/remoting/policy/EntryNoElapsedTimePushPolicy.java

    r1043 r1119  
    1414 * limitations under the License. 
    1515 */ 
     16 
    1617package uk.ac.cardiff.raptor.remoting.policy; 
    1718 
     
    2425 
    2526/** 
    26  * This class combines both the number of events needed before release ( 
    27  * <code>pushOnOrAfterNoEntries</code>) with a duration to wait before release. 
    28  * In this way, if the number of events threshold is met before the duration 
    29  * elapses, the <code>lastReleasedTime</code> is updated. In effect, the 
    30  * <code>pushInterval</code> is only effective if the number of entries does not 
    31  * suppress the threshold in the given time interval. However, the elapsed time will 
    32  * only send events if there are more than 0 events to send. 
    33  * 
     27 * This class combines both the number of events needed before release ( <code>pushOnOrAfterNoEntries</code>) with a 
     28 * duration to wait before release. In this way, if the number of events threshold is met before the duration elapses, 
     29 * the <code>lastReleasedTime</code> is updated. In effect, the <code>pushInterval</code> is only effective if the 
     30 * number of entries does not suppress the threshold in the given time interval. However, the elapsed time will only 
     31 * send events if there are more than 0 events to send. 
     32 *  
    3433 * @author philsmart 
    35  * 
     34 *  
    3635 */ 
    3736public class EntryNoElapsedTimePushPolicy extends AbstractPushPolicy { 
    3837 
    39         /** Class logger */ 
    40         private final Logger log = LoggerFactory.getLogger(EntryNoElapsedTimePushPolicy.class); 
     38    /** Class logger */ 
     39    private final Logger log = LoggerFactory.getLogger(EntryNoElapsedTimePushPolicy.class); 
    4140 
    42         /** The time, in milliseconds, that this policy was last evaluated */ 
    43         private long lastReleasedTime; 
     41    /** The time, in milliseconds, that this policy was last evaluated */ 
     42    private long lastReleasedTime; 
    4443 
    45         /** How long, in milliseconds, should elapse before release */ 
    46         private long pushInterval; 
     44    /** How long, in milliseconds, should elapse before release */ 
     45    private long pushInterval; 
    4746 
    48         /** The threshold on the number of events needed before release */ 
    49         private int pushOnOrAfterNoEntries; 
     47    /** The threshold on the number of events needed before release */ 
     48    private int pushOnOrAfterNoEntries; 
    5049 
    51         /** 
    52         * Default constructor, which sets the last evaluated time on initialisation 
    53         */ 
    54         public EntryNoElapsedTimePushPolicy() { 
    55                 super(); 
    56                 lastReleasedTime = System.currentTimeMillis(); 
    57         } 
     50    /** 
     51    * Default constructor, which sets the last evaluated time on initialisation 
     52    */ 
     53    public EntryNoElapsedTimePushPolicy() { 
     54        super(); 
     55        lastReleasedTime = System.currentTimeMillis(); 
     56    } 
    5857 
    59         /** 
    60          * Evaluates this push policy based on both time interval since last release, and number of events. 
    61          *  
    62          * @param events the events with which to evaluate the push policy. 
    63          * @return true if the number of <code>events</code> are >= <code>pushOnOrAfterNoEntries</code>, or true if  
    64          *     the time since the last release exceeds <code>pushInterval</code> and the number of <code>events</code 
    65          *     is greater than 0, false otherwise.  
    66          */ 
    67         public boolean evaluatePolicy(List<Event> events) { 
    68                 long currentTime = System.currentTimeMillis(); 
    69                 if (pushOnOrAfterNoEntries <= events.size()) { 
    70                         lastReleasedTime = currentTime; 
    71                         return true; 
    72                 } else { 
    73                         long difference = currentTime - lastReleasedTime; 
    74                         log.trace("ElapsedTime difference {}, pushInterval {}", difference, pushInterval); 
    75                         if (difference >= getPushInterval() && events.size()>0) { 
    76                                 log.trace("Elapsed time passed and {} events to send",events.size()); 
    77                                 lastReleasedTime = currentTime; 
    78                                 return true; 
    79                         } 
    80                         else if (difference >= getPushInterval() && events.size()==0){ 
    81                             log.trace("Elapsed time passed but no events to send",events.size()); 
    82                             lastReleasedTime = currentTime; 
    83                             return false; 
    84                         } 
    85                 } 
    86                 return false; 
    87                  
    88         } 
     58    /** 
     59     * Evaluates this push policy based on both time interval since last release, and number of events. 
     60     *  
     61     * @param events the events with which to evaluate the push policy. 
     62     * @return true if the number of <code>events</code> are >= <code>pushOnOrAfterNoEntries</code>, or true if the time 
     63     *         since the last release exceeds <code>pushInterval</code> and the number of <code>events</code> is greater 
     64     *         than 0, false otherwise. 
     65     */ 
     66    public boolean evaluatePolicy(List<Event> events) { 
     67        long currentTime = System.currentTimeMillis(); 
     68        if (pushOnOrAfterNoEntries <= events.size()) { 
     69            lastReleasedTime = currentTime; 
     70            return true; 
     71        } else { 
     72            long difference = currentTime - lastReleasedTime; 
     73            log.trace("ElapsedTime difference {}, pushInterval {}", difference, pushInterval); 
     74            if (difference >= getPushInterval() && events.size() > 0) { 
     75                log.trace("Elapsed time passed and {} events to send", events.size()); 
     76                lastReleasedTime = currentTime; 
     77                return true; 
     78            } else if (difference >= getPushInterval() && events.size() == 0) { 
     79                log.trace("Elapsed time passed but no events to send", events.size()); 
     80                lastReleasedTime = currentTime; 
     81                return false; 
     82            } 
     83        } 
     84        return false; 
    8985 
    90         public void setPushInterval(long pushInterval) { 
    91                 this.pushInterval = pushInterval; 
    92         } 
     86    } 
    9387 
    94         public long getPushInterval() { 
    95                 return pushInterval; 
    96         } 
     88    public void setPushInterval(long pushInterval) { 
     89        this.pushInterval = pushInterval; 
     90    } 
    9791 
    98         public void setPushOnOrAfterNoEntries(int pushOnOrAfterNoEntries) { 
    99                 this.pushOnOrAfterNoEntries = pushOnOrAfterNoEntries; 
    100         } 
     92    public long getPushInterval() { 
     93        return pushInterval; 
     94    } 
    10195 
    102         public int getPushOnOrAfterNoEntries() { 
    103                 return pushOnOrAfterNoEntries; 
    104         } 
     96    public void setPushOnOrAfterNoEntries(int pushOnOrAfterNoEntries) { 
     97        this.pushOnOrAfterNoEntries = pushOnOrAfterNoEntries; 
     98    } 
     99 
     100    public int getPushOnOrAfterNoEntries() { 
     101        return pushOnOrAfterNoEntries; 
     102    } 
    105103 
    106104} 
Note: See TracChangeset for help on using the changeset viewer.