• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GlobalTrafficShapingHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.netty.handler.traffic.GlobalTrafficShapingHandler的典型用法代码示例。如果您正苦于以下问题:Java GlobalTrafficShapingHandler类的具体用法?Java GlobalTrafficShapingHandler怎么用?Java GlobalTrafficShapingHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GlobalTrafficShapingHandler类属于io.netty.handler.traffic包,在下文中一共展示了GlobalTrafficShapingHandler类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
public static void init() throws Exception {
    if (INSTANCE != null) {
        return;
    }
    log.info("\tLoading configuration file...");
    load();
    log.info("\tChecking configuration items...");
    check();
    if (INSTANCE.relayPort.length > 0) {
        log.info("\tStarting Relays...");
        startupRelays();
    }
    log.info("\tInitializing dns cache...");
    DnsCache.init(INSTANCE.dnsCacheCapacity);
    log.info("\tInitializing global network traffic handler...");
    TRAFFIC_HANDLER = new GlobalTrafficShapingHandler(Executors.newScheduledThreadPool(1), 1000);
    TRAFFIC_HANDLER.setWriteLimit(INSTANCE.writeLimit);
    TRAFFIC_HANDLER.setReadLimit(INSTANCE.readLimit);
    log.info("\tEnd of configuration");
}
 
开发者ID:ZhangJiupeng,项目名称:AgentX,代码行数:21,代码来源:Configuration.java


示例2: execute

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
@Override
public boolean execute(String[] args) {

    logger.info("Connections: {}", Apex.getChannelGroup().size());
    if (Apex.getInstance().getConnectionsPerSecondTask() != null) {
        logger.info("Connections per second: {}", Apex.getInstance().getConnectionsPerSecondTask().getPerSecond());
    }
    logger.info("Online backend servers: {}", Apex.getBalancingStrategy().size());

    GlobalTrafficShapingHandler trafficShapingHandler = Apex.getInstance().getTrafficShapingHandler();
    if (trafficShapingHandler != null) {
        TrafficCounter trafficCounter = trafficShapingHandler.trafficCounter();

        logger.info("Current bytes read: {}", trafficCounter.currentReadBytes());
        logger.info("Current bytes written: {}", trafficCounter.currentWrittenBytes());
        logger.info("Last read throughput: {}", trafficCounter.lastReadThroughput());
        logger.info("Last write throughput: {}", trafficCounter.lastWrittenBytes());
        logger.info("Total bytes read: {}", trafficCounter.cumulativeReadBytes());
        logger.info("Total bytes written: {}", trafficCounter.cumulativeWrittenBytes());
    }

    return true;
}
 
开发者ID:JackWhite20,项目名称:Apex,代码行数:24,代码来源:StatsCommand.java


示例3: ProxyToServerConnection

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
private ProxyToServerConnection(
        DefaultHttpProxyServer proxyServer,
        ClientToProxyConnection clientConnection,
        String serverHostAndPort,
        ChainedProxy chainedProxy,
        Queue<ChainedProxy> availableChainedProxies,
        HttpFilters initialFilters,
        GlobalTrafficShapingHandler globalTrafficShapingHandler)
        throws UnknownHostException {
    super(DISCONNECTED, proxyServer, true);
    this.clientConnection = clientConnection;
    this.serverHostAndPort = serverHostAndPort;
    this.chainedProxy = chainedProxy;
    this.availableChainedProxies = availableChainedProxies;
    this.trafficHandler = globalTrafficShapingHandler;
    this.currentFilters = initialFilters;

    // Report connection status to HttpFilters
    currentFilters.proxyToServerConnectionQueued();

    setupConnectionParameters();
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:23,代码来源:ProxyToServerConnection.java


示例4: ProxyToServerConnection

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
private ProxyToServerConnection(
        DefaultHttpProxyServer proxyServer,
        ClientToProxyConnection clientConnection,
        String serverHostAndPort,
        ChainedProxy chainedProxy,
        Queue<ChainedProxy> availableChainedProxies,
        HttpFilters initialFilters,
        GlobalTrafficShapingHandler globalTrafficShapingHandler)
        throws UnknownHostException {
    super(DISCONNECTED, proxyServer, true);
    this.clientConnection = clientConnection;
    this.serverHostAndPort = serverHostAndPort;
    this.chainedProxy = chainedProxy;
    this.availableChainedProxies = availableChainedProxies;
    this.trafficHandler = globalTrafficShapingHandler;
    this.currentFilters = initialFilters;

    // Report connection status to HttpFilters
    this.currentFilters.proxyToServerConnectionQueued();

    setupConnectionParameters();
}
 
开发者ID:Elitward,项目名称:LittleProxy,代码行数:23,代码来源:ProxyToServerConnection.java


示例5: start

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
public void start() {
    Configuration config = Configuration.INSTANCE;
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap bootstrap = new ServerBootstrap();
        bootstrap.group(bossGroup, workerGroup)
                .channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    protected void initChannel(SocketChannel socketChannel) throws Exception {
                        socketChannel.pipeline()
                                .addLast("logging", new LoggingHandler(LogLevel.DEBUG))
                                .addLast(new XConnectHandler());
                        if (config.getReadLimit() != 0 || config.getWriteLimit() != 0) {
                            socketChannel.pipeline().addLast(
                                    new GlobalTrafficShapingHandler(Executors.newScheduledThreadPool(1), config.getWriteLimit(), config.getReadLimit())
                            );
                        }
                    }
                });
        log.info("\tStartup {}-{}-server [{}]", Constants.APP_NAME, Constants.APP_VERSION, config.getProtocol());
        new Thread(() -> new UdpServer().start()).start();
        ChannelFuture future = bootstrap.bind(config.getHost(), config.getPort()).sync();
        future.addListener(future1 -> log.info("\tTCP listening at {}:{}...", config.getHost(), config.getPort()));
        future.channel().closeFuture().sync();
    } catch (Exception e) {
        log.error("\tSocket bind failure ({})", e.getMessage());
    } finally {
        log.info("\tShutting down and recycling...");
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
        Configuration.shutdownRelays();
    }
    System.exit(0);
}
 
开发者ID:ZhangJiupeng,项目名称:AgentX,代码行数:37,代码来源:XServer.java


示例6: start

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
public void start() {
	try {

		FSClient.start();

		Config config = ConfigXmlLoader.load(CONFIG);
		PacLoader.load(PAC);

		bossGroup = new NioEventLoopGroup(1);
		workerGroup = new NioEventLoopGroup();
		bootstrap = new ServerBootstrap();
		trafficHandler = new GlobalTrafficShapingHandler(
				Executors.newScheduledThreadPool(2), 1000);

		bootstrap
				.group(bossGroup, workerGroup)
				.channel(NioServerSocketChannel.class)
				.childHandler(
						new SocksServerInitializer(config, trafficHandler));

		logger.info("Start At Port " + config.get_localPort());
		startMBean();
		bootstrap.bind(config.get_localPort()).sync().channel()
				.closeFuture().sync();
	} catch (Exception e) {
		logger.error("start error", e);
	} finally {
		stop();
	}
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:31,代码来源:SocksServer.java


示例7: initChannel

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
@Override
protected void initChannel(SocketChannel channel) throws Exception {

    BackendInfo backendInfo = Apex.getBalancingStrategy()
            .selectBackend(channel.remoteAddress().getHostName(), channel.remoteAddress().getPort());

    if (backendInfo == null) {
        // Gracefully close the channel
        channel.close();

        logger.error("Unable to select a backend server. All down?");
        return;
    }

    channel.pipeline()
            .addLast(new ReadTimeoutHandler(readTimeout))
            .addLast(new WriteTimeoutHandler(writeTimeout));

    GlobalTrafficShapingHandler trafficShapingHandler = Apex.getInstance().getTrafficShapingHandler();
    if (trafficShapingHandler != null) {
        channel.pipeline().addLast(trafficShapingHandler);
    }

    channel.pipeline().addLast(new SocketUpstreamHandler(backendInfo));

    // Keep track of connections per second
    if (connectionsPerSecondTask != null) {
        connectionsPerSecondTask.inc();
    }

    logger.debug("Connected [{}] <-> [{}:{} ({})]", channel.remoteAddress(), backendInfo.getHost(), backendInfo.getPort(), backendInfo.getName());
}
 
开发者ID:JackWhite20,项目名称:Apex,代码行数:33,代码来源:ApexSocketChannelInitializer.java


示例8: ClientToProxyConnection

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
ClientToProxyConnection(
        final DefaultHttpProxyServer proxyServer,
        SslEngineSource sslEngineSource,
        boolean authenticateClients,
        ChannelPipeline pipeline,
        GlobalTrafficShapingHandler globalTrafficShapingHandler) {
    super(AWAITING_INITIAL, proxyServer, false);

    initChannelPipeline(pipeline);

    if (sslEngineSource != null) {
        LOG.debug("Enabling encryption of traffic from client to proxy");
        encrypt(pipeline, sslEngineSource.newSslEngine(),
                authenticateClients)
                .addListener(
                        new GenericFutureListener<Future<? super Channel>>() {
                            @Override
                            public void operationComplete(
                                    Future<? super Channel> future)
                                    throws Exception {
                                if (future.isSuccess()) {
                                    clientSslSession = sslEngine
                                            .getSession();
                                    recordClientSSLHandshakeSucceeded();
                                }
                            }
                        });
    }
    this.globalTrafficShapingHandler = globalTrafficShapingHandler;

    LOG.debug("Created ClientToProxyConnection");
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:33,代码来源:ClientToProxyConnection.java


示例9: create

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
/**
 * Create a new ProxyToServerConnection.
 * 
 * @param proxyServer
 * @param clientConnection
 * @param serverHostAndPort
 * @param initialFilters
 * @param initialHttpRequest
 * @return
 * @throws UnknownHostException
 */
static ProxyToServerConnection create(DefaultHttpProxyServer proxyServer,
        ClientToProxyConnection clientConnection,
        String serverHostAndPort,
        HttpFilters initialFilters,
        HttpRequest initialHttpRequest,
        GlobalTrafficShapingHandler globalTrafficShapingHandler)
        throws UnknownHostException {
    Queue<ChainedProxy> chainedProxies = new ConcurrentLinkedQueue<ChainedProxy>();
    ChainedProxyManager chainedProxyManager = proxyServer
            .getChainProxyManager();
    if (chainedProxyManager != null) {
        chainedProxyManager.lookupChainedProxies(initialHttpRequest,
                chainedProxies);
        if (chainedProxies.size() == 0) {
            // ChainedProxyManager returned no proxies, can't connect
            return null;
        }
    }
    return new ProxyToServerConnection(proxyServer,
            clientConnection,
            serverHostAndPort,
            chainedProxies.poll(),
            chainedProxies,
            initialFilters,
            globalTrafficShapingHandler);
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:38,代码来源:ProxyToServerConnection.java


示例10: SocksServerInitializer

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
public SocksServerInitializer(Config config,
		GlobalTrafficShapingHandler trafficHandler) {
	this.trafficHandler = trafficHandler;
	socksMessageEncoder = new SocksMessageEncoder();
	socksServerHandler = new SocksServerHandler(config);
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:7,代码来源:SocksServerInitializer.java


示例11: getShaper

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
public static GlobalTrafficShapingHandler getShaper() {
  initIfNecessary();
  return shaper;
}
 
开发者ID:selendroid,项目名称:selendroid,代码行数:5,代码来源:TrafficCounter.java


示例12: createGlobalTrafficShapingHandler

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
/**
 * Creates a new GlobalTrafficShapingHandler for this HttpProxyServer, using this proxy's proxyToServerEventLoop.
 *
 * @param transportProtocol
 * @param readThrottleBytesPerSecond
 * @param writeThrottleBytesPerSecond
 *
 * @return
 */
private GlobalTrafficShapingHandler createGlobalTrafficShapingHandler(TransportProtocol transportProtocol, long readThrottleBytesPerSecond, long writeThrottleBytesPerSecond) {
    EventLoopGroup proxyToServerEventLoop = this.getProxyToServerWorkerFor(transportProtocol);
    return new GlobalTrafficShapingHandler(proxyToServerEventLoop,
            writeThrottleBytesPerSecond,
            readThrottleBytesPerSecond,
            TRAFFIC_SHAPING_CHECK_INTERVAL_MS,
            Long.MAX_VALUE);
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:18,代码来源:DefaultHttpProxyServer.java


示例13: getTrafficShapingHandler

import io.netty.handler.traffic.GlobalTrafficShapingHandler; //导入依赖的package包/类
public GlobalTrafficShapingHandler getTrafficShapingHandler() {

        return trafficShapingHandler;
    }
 
开发者ID:JackWhite20,项目名称:Apex,代码行数:5,代码来源:Apex.java



注:本文中的io.netty.handler.traffic.GlobalTrafficShapingHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IReferenceDescription类代码示例发布时间:2022-05-23
下一篇:
Java RefreshLogRetentionSettingsRequestProto类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap