View Javadoc

1   /**
2    * This file is part of Waarp Project.
3    * 
4    * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the
5    * COPYRIGHT.txt in the distribution for a full listing of individual contributors.
6    * 
7    * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of
8    * the GNU General Public License as published by the Free Software Foundation, either version 3 of
9    * the License, or (at your option) any later version.
10   * 
11   * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
12   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13   * Public License for more details.
14   * 
15   * You should have received a copy of the GNU General Public License along with Waarp . If not, see
16   * <http://www.gnu.org/licenses/>.
17   */
18  package org.waarp.ftp.core.config;
19  
20  import java.util.concurrent.ScheduledExecutorService;
21  
22  import org.waarp.common.file.DataBlock;
23  
24  import io.netty.handler.traffic.GlobalChannelTrafficShapingHandler;
25  
26  /**
27   * Global Traffic Shaping Handler for FTP
28   * @author "Frederic Bregier"
29   *
30   */
31  public class FtpGlobalTrafficShapingHandler extends GlobalChannelTrafficShapingHandler {
32  
33      public FtpGlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeGlobalLimit,
34              long readGlobalLimit, long writeChannelLimit, long readChannelLimit, long checkInterval, long maxTime) {
35          super(executor, writeGlobalLimit, readGlobalLimit, writeChannelLimit, readChannelLimit, checkInterval, maxTime);
36      }
37  
38      public FtpGlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeGlobalLimit,
39              long readGlobalLimit, long writeChannelLimit, long readChannelLimit, long checkInterval) {
40          super(executor, writeGlobalLimit, readGlobalLimit, writeChannelLimit, readChannelLimit, checkInterval);
41      }
42  
43      public FtpGlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeGlobalLimit,
44              long readGlobalLimit, long writeChannelLimit, long readChannelLimit) {
45          super(executor, writeGlobalLimit, readGlobalLimit, writeChannelLimit, readChannelLimit);
46      }
47  
48      public FtpGlobalTrafficShapingHandler(ScheduledExecutorService executor, long checkInterval) {
49          super(executor, checkInterval);
50      }
51  
52      public FtpGlobalTrafficShapingHandler(ScheduledExecutorService executor) {
53          super(executor);
54      }
55  
56      @Override
57      protected long calculateSize(Object msg) {
58          if (msg instanceof DataBlock) {
59              return ((DataBlock) msg).getByteCount();
60          }
61          return super.calculateSize(msg);
62      }
63  
64  }