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 org.waarp.common.file.DataBlock;
21
22 import io.netty.handler.traffic.ChannelTrafficShapingHandler;
23
24 /**
25 * Channel Traffic Shaping Handler for FTP
26 * @author "Frederic Bregier"
27 *
28 */
29 public class FtpChannelTrafficShapingHandler extends ChannelTrafficShapingHandler {
30
31 /**
32 * @param checkInterval
33 */
34 public FtpChannelTrafficShapingHandler(long checkInterval) {
35 super(checkInterval);
36 }
37
38 /**
39 * @param writeLimit
40 * @param readLimit
41 */
42 public FtpChannelTrafficShapingHandler(long writeLimit, long readLimit) {
43 super(writeLimit, readLimit);
44 }
45
46 /**
47 * @param writeLimit
48 * @param readLimit
49 * @param checkInterval
50 */
51 public FtpChannelTrafficShapingHandler(long writeLimit, long readLimit, long checkInterval) {
52 super(writeLimit, readLimit, checkInterval);
53 }
54
55 /**
56 * @param writeLimit
57 * @param readLimit
58 * @param checkInterval
59 * @param maxTime
60 */
61 public FtpChannelTrafficShapingHandler(long writeLimit, long readLimit, long checkInterval, long maxTime) {
62 super(writeLimit, readLimit, checkInterval, maxTime);
63 }
64
65 @Override
66 protected long calculateSize(Object msg) {
67 if (msg instanceof DataBlock) {
68 return ((DataBlock) msg).getByteCount();
69 }
70 return super.calculateSize(msg);
71 }
72
73 }