View Javadoc

1   /**
2      This file is part of GoldenGate Project (named also GoldenGate or GG).
3   
4      Copyright 2009, Frederic Bregier, and individual contributors by the @author
5      tags. See the COPYRIGHT.txt in the distribution for a full listing of
6      individual contributors.
7   
8      All GoldenGate Project is free software: you can redistribute it and/or 
9      modify it under the terms of the GNU General Public License as published 
10     by the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12  
13     GoldenGate is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17  
18     You should have received a copy of the GNU General Public License
19     along with GoldenGate .  If not, see <http://www.gnu.org/licenses/>.
20   */
21  package openr66.protocol.networkhandler;
22  
23  import openr66.protocol.configuration.Configuration;
24  
25  import org.jboss.netty.handler.traffic.GlobalTrafficShapingHandler;
26  
27  import goldengate.common.cpu.GgConstraintLimitHandler;
28  
29  /**
30   * R66 Constraint Limit Handler
31   * 
32   * Constraint Limit (CPU and connection - network and local -) handler, 
33   * only for server side (requested or requester).
34   * 
35   * @author Frederic Bregier
36   *
37   */
38  public class R66ConstraintLimitHandler extends GgConstraintLimitHandler {
39      public R66ConstraintLimitHandler() {
40          super();
41      }
42  
43      /**
44       * @param useJdKCpuLimit True to use JDK Cpu native or False for JavaSysMon
45       * @param lowcpuLimit for proactive cpu limitation (throttling bandwidth) (0<= x < 1 & highcpulimit) 
46       * @param highcpuLimit for proactive cpu limitation (throttling bandwidth) (0<= x <= 1) 0 meaning no throttle activated
47       * @param percentageDecrease for proactive cpu limitation, throttling bandwidth reduction (0 < x < 1) as 0.25 for 25% of reduction
48       * @param handler the GlobalTrafficShapingHandler associated (null to have no proactive cpu limitation)
49       * @param delay the delay between 2 tests for proactive cpu limitation
50       * @param limitLowBandwidth the minimal bandwidth (read or write) to apply when decreasing bandwidth (low limit = 4096)
51       */
52      public R66ConstraintLimitHandler(boolean useJdKCpuLimit,
53              double lowcpuLimit, double highcpuLimit, double percentageDecrease,
54              GlobalTrafficShapingHandler handler, long delay,
55              long limitLowBandwidth) {
56          super(Configuration.WAITFORNETOP, Configuration.configuration.TIMEOUTCON,
57                  useJdKCpuLimit,
58                  lowcpuLimit, highcpuLimit,
59                  percentageDecrease, handler, delay, limitLowBandwidth);
60      }
61  
62      /**
63       * @param useCpuLimit True to enable cpuLimit on connection check
64       * @param useJdKCpuLimit True to use JDK Cpu native or False for JavaSysMon
65       * @param cpulimit high cpu limit (0<= x < 1) to refuse new connections
66       * @param channellimit number of connection limit (0<= x)
67       */
68      public R66ConstraintLimitHandler(boolean useCpuLimit,
69              boolean useJdKCpuLimit, double cpulimit, int channellimit) {
70          super(Configuration.WAITFORNETOP, Configuration.configuration != null ? 
71                  Configuration.configuration.TIMEOUTCON : 30000, 
72                  useCpuLimit, useJdKCpuLimit, cpulimit, channellimit);
73      }
74  
75      /**
76       * @param useCpuLimit True to enable cpuLimit on connection check
77       * @param useJdKCpuLimit True to use JDK Cpu native or False for JavaSysMon
78       * @param cpulimit high cpu limit (0<= x < 1) to refuse new connections
79       * @param channellimit number of connection limit (0<= x)
80       * @param lowcpuLimit for proactive cpu limitation (throttling bandwidth) (0<= x < 1 & highcpulimit) 
81       * @param highcpuLimit for proactive cpu limitation (throttling bandwidth) (0<= x <= 1) 0 meaning no throttle activated
82       * @param percentageDecrease for proactive cpu limitation, throttling bandwidth reduction (0 < x < 1) as 0.25 for 25% of reduction
83       * @param handler the GlobalTrafficShapingHandler associated (null to have no proactive cpu limitation)
84       * @param delay the delay between 2 tests for proactive cpu limitation
85       * @param limitLowBandwidth the minimal bandwidth (read or write) to apply when decreasing bandwidth (low limit = 4096)
86       */
87      public R66ConstraintLimitHandler(
88              boolean useCpuLimit, boolean useJdKCpuLimit, double cpulimit,
89              int channellimit, double lowcpuLimit, double highcpuLimit,
90              double percentageDecrease, GlobalTrafficShapingHandler handler,
91              long delay, long limitLowBandwidth) {
92          super(Configuration.WAITFORNETOP, Configuration.configuration.TIMEOUTCON,
93                  useCpuLimit, useJdKCpuLimit,
94                  cpulimit, channellimit, lowcpuLimit, highcpuLimit,
95                  percentageDecrease, handler, delay, limitLowBandwidth);
96      }
97  
98      /* (non-Javadoc)
99       * @see goldengate.common.cpu.GgConstraintLimitHandler#getNumberLocalChannel()
100      */
101     @Override
102     protected int getNumberLocalChannel() {
103         return Configuration.configuration.getLocalTransaction().getNumberLocalChannel();
104     }
105 
106     /* (non-Javadoc)
107      * @see goldengate.common.cpu.GgConstraintLimitHandler#getReadLimit()
108      */
109     @Override
110     protected long getReadLimit() {
111         return Configuration.configuration.serverGlobalReadLimit;
112     }
113 
114     /* (non-Javadoc)
115      * @see goldengate.common.cpu.GgConstraintLimitHandler#getWriteLimit()
116      */
117     @Override
118     protected long getWriteLimit() {
119         return Configuration.configuration.serverGlobalWriteLimit;
120     }
121 
122 }