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 goldengate.ftp.exec.control;
22  
23  import org.jboss.netty.handler.traffic.GlobalTrafficShapingHandler;
24  
25  import goldengate.common.cpu.GgConstraintLimitHandler;
26  import goldengate.ftp.exec.config.FileBasedConfiguration;
27  
28  /**
29   * Constraint Limit (CPU and connection - network and local -) handler.
30   * @author Frederic Bregier
31   *
32   */
33  public class FtpConstraintLimitHandler extends GgConstraintLimitHandler {
34  
35      /**
36       * @param useJdkCpuLimit True to use JDK Cpu native or False for JavaSysMon
37       * @param lowcpuLimit for proactive cpu limitation (throttling bandwidth) (0<= x < 1 & highcpulimit) 
38       * @param highcpuLimit for proactive cpu limitation (throttling bandwidth) (0<= x <= 1) 0 meaning no throttle activated
39       * @param percentageDecrease for proactive cpu limitation, throttling bandwidth reduction (0 < x < 1) as 0.25 for 25% of reduction
40       * @param handler the GlobalTrafficShapingHandler associated (null to have no proactive cpu limitation)
41       * @param delay the delay between 2 tests for proactive cpu limitation
42       * @param limitLowBandwidth the minimal bandwidth (read or write) to apply when decreasing bandwidth (low limit = 4096)
43       */
44      public FtpConstraintLimitHandler(long timeoutcon,
45              boolean useJdkCpuLimit, double lowcpuLimit, double highcpuLimit,
46              double percentageDecrease, GlobalTrafficShapingHandler handler,
47              long delay, long limitLowBandwidth) {
48          super(1000, timeoutcon, 
49                  useJdkCpuLimit, lowcpuLimit,
50                  highcpuLimit, percentageDecrease, handler, delay,
51                  limitLowBandwidth);
52      }
53  
54      /**
55       * @param useCpuLimit True to enable cpuLimit on connection check
56       * @param useJdKCpuLimit True to use JDK Cpu native or False for JavaSysMon
57       * @param cpulimit high cpu limit (0<= x < 1) to refuse new connections
58       * @param channellimit number of connection limit (0<= x)
59       */
60      public FtpConstraintLimitHandler(long timeoutcon, boolean useCpuLimit,
61              boolean useJdKCpuLimit, double cpulimit, int channellimit) {
62          super(1000, timeoutcon, useCpuLimit, useJdKCpuLimit, cpulimit, channellimit);
63      }
64  
65      /**
66       * @param useCpuLimit True to enable cpuLimit on connection check
67       * @param useJdKCpuLimit True to use JDK Cpu native or False for JavaSysMon
68       * @param cpulimit high cpu limit (0<= x < 1) to refuse new connections
69       * @param channellimit number of connection limit (0<= x)
70       * @param lowcpuLimit for proactive cpu limitation (throttling bandwidth) (0<= x < 1 & highcpulimit) 
71       * @param highcpuLimit for proactive cpu limitation (throttling bandwidth) (0<= x <= 1) 0 meaning no throttle activated
72       * @param percentageDecrease for proactive cpu limitation, throttling bandwidth reduction (0 < x < 1) as 0.25 for 25% of reduction
73       * @param handler the GlobalTrafficShapingHandler associated (null to have no proactive cpu limitation)
74       * @param delay the delay between 2 tests for proactive cpu limitation
75       * @param limitLowBandwidth the minimal bandwidth (read or write) to apply when decreasing bandwidth (low limit = 4096)
76       */
77      public FtpConstraintLimitHandler(long timeoutcon,
78              boolean useCpuLimit, boolean useJdKCpuLimit, double cpulimit,
79              int channellimit, double lowcpuLimit, double highcpuLimit,
80              double percentageDecrease, GlobalTrafficShapingHandler handler,
81              long delay, long limitLowBandwidth) {
82          super(1000, timeoutcon,
83                  useCpuLimit, useJdKCpuLimit,
84                  cpulimit, channellimit, lowcpuLimit, highcpuLimit,
85                  percentageDecrease, handler, delay, limitLowBandwidth);
86      }
87  
88      /* (non-Javadoc)
89       * @see goldengate.common.cpu.GgConstraintLimitHandler#getNumberLocalChannel()
90       */
91      @Override
92      protected int getNumberLocalChannel() {
93          return FileBasedConfiguration.fileBasedConfiguration.getFtpInternalConfiguration().getNumberSessions();
94      }
95  
96      /* (non-Javadoc)
97       * @see goldengate.common.cpu.GgConstraintLimitHandler#getReadLimit()
98       */
99      @Override
100     protected long getReadLimit() {
101         return FileBasedConfiguration.fileBasedConfiguration.getServerGlobalReadLimit();
102     }
103 
104     /* (non-Javadoc)
105      * @see goldengate.common.cpu.GgConstraintLimitHandler#getWriteLimit()
106      */
107     @Override
108     protected long getWriteLimit() {
109         return FileBasedConfiguration.fileBasedConfiguration.getServerGlobalWriteLimit();
110     }
111 
112 }