Example usage for io.netty.util ResourceLeakDetector setLevel

List of usage examples for io.netty.util ResourceLeakDetector setLevel

Introduction

In this page you can find the example usage for io.netty.util ResourceLeakDetector setLevel.

Prototype

public static void setLevel(Level level) 

Source Link

Document

Sets the resource leak detection level.

Usage

From source file:alluxio.worker.grpc.BlockReadHandlerTest.java

License:Apache License

@Before
public void before() throws Exception {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
    mBlockWorker = mock(BlockWorker.class);
    doNothing().when(mBlockWorker).accessBlock(anyLong(), anyLong());
    mResponseObserver = Mockito.mock(ServerCallStreamObserver.class);
    Mockito.when(mResponseObserver.isReady()).thenReturn(true);
    doAnswer(args -> {//from  w  w  w. j  av  a2  s. c om
        mResponseCompleted = true;
        return null;
    }).when(mResponseObserver).onCompleted();
    doAnswer(args -> {
        mResponseCompleted = true;
        mError = args.getArgumentAt(0, Throwable.class);
        return null;
    }).when(mResponseObserver).onError(any(Throwable.class));
    doAnswer((args) -> {
        // make a copy of response data before it is released
        mResponses.add(ReadResponse.parseFrom(args.getArgumentAt(0, ReadResponse.class).toByteString()));
        return null;
    }).when(mResponseObserver).onNext(any(ReadResponse.class));
    mReadHandler = new BlockReadHandler(GrpcExecutors.BLOCK_READER_EXECUTOR, mBlockWorker, mResponseObserver,
            new AuthenticatedUserInfo(), false);
    mReadHandlerNoException = new BlockReadHandler(GrpcExecutors.BLOCK_READER_EXECUTOR, mBlockWorker,
            mResponseObserver, new AuthenticatedUserInfo(), false);
}

From source file:alluxio.worker.netty.BlockReadHandlerTest.java

License:Apache License

@Before
public void before() throws Exception {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
    mBlockWorker = mock(BlockWorker.class);
    doNothing().when(mBlockWorker).accessBlock(anyLong(), anyLong());
    mChannel = new EmbeddedChannel(
            new BlockReadHandler(NettyExecutors.BLOCK_READER_EXECUTOR, mBlockWorker, FileTransferType.MAPPED));
    mChannelNoException = new EmbeddedNoExceptionChannel(
            new BlockReadHandler(NettyExecutors.BLOCK_READER_EXECUTOR, mBlockWorker, FileTransferType.MAPPED));
}

From source file:alluxio.worker.netty.CodecTest.java

License:Apache License

@Before
public void before() throws Exception {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
    mChannel = new EmbeddedChannel(RPCMessage.createFrameDecoder(), new RPCMessageDecoder(),
            new RPCMessageEncoder());
}

From source file:alluxio.worker.netty.DataServerBlockReadHandlerTest.java

License:Apache License

@Before
public void before() throws Exception {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
    mBlockWorker = Mockito.mock(BlockWorker.class);
    Mockito.doNothing().when(mBlockWorker).accessBlock(Mockito.anyLong(), Mockito.anyLong());
    mChannel = new EmbeddedChannel(new DataServerBlockReadHandler(NettyExecutors.BLOCK_READER_EXECUTOR,
            mBlockWorker, FileTransferType.MAPPED));
    mChannelNoException = new EmbeddedNoExceptionChannel(new DataServerBlockReadHandler(
            NettyExecutors.BLOCK_READER_EXECUTOR, mBlockWorker, FileTransferType.MAPPED));
}

From source file:alluxio.worker.netty.DataServerUFSFileReadHandlerTest.java

License:Apache License

@Before
public void before() throws Exception {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
    mFileSystemWorker = Mockito.mock(FileSystemWorker.class);
    mChannel = new EmbeddedChannel(
            new DataServerUFSFileReadHandler(NettyExecutors.UFS_BLOCK_READER_EXECUTOR, mFileSystemWorker));
    mChannelNoException = new EmbeddedNoExceptionChannel(
            new DataServerUFSFileReadHandler(NettyExecutors.UFS_BLOCK_READER_EXECUTOR, mFileSystemWorker));
}

From source file:com.ibasco.agql.core.transport.NettyTransport.java

License:Open Source License

public NettyTransport(ChannelType channelType, ExecutorService executor) {
    executorService = executor;/*from  ww  w  .  j  a  v  a 2s  .c o m*/
    bootstrap = new Bootstrap();

    //Make sure we have a type set
    if (channelType == null)
        throw new IllegalStateException("No channel type has been specified");

    //Pick the proper event loop group
    if (eventLoopGroup == null) {
        eventLoopGroup = createEventLoopGroup(channelType);
    }

    //Default Channel Options
    addChannelOption(ChannelOption.ALLOCATOR, allocator);
    addChannelOption(ChannelOption.WRITE_BUFFER_WATER_MARK, WriteBufferWaterMark.DEFAULT);
    addChannelOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000);

    //Set resource leak detection if debugging is enabled
    if (log.isDebugEnabled())
        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);

    //Initialize bootstrap
    bootstrap.group(eventLoopGroup).channel(channelType.getChannelClass());
}

From source file:com.king.platform.net.http.integration.HttpGetFile.java

License:Apache License

@Before
public void setUp() throws Exception {
    temporaryFile = new TemporaryFile(folder);

    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);

    integrationServer = new JettyIntegrationServer();
    integrationServer.start();//w w w  . j a v a 2  s  . c o m
    port = integrationServer.getPort();

    httpClient = new TestingHttpClientFactory().create();
    httpClient.setConf(ConfKeys.TOTAL_REQUEST_TIMEOUT_MILLIS, 0);
    httpClient.setConf(ConfKeys.IDLE_TIMEOUT_MILLIS, 100);

    httpClient.start();

}

From source file:com.king.platform.net.http.integration.HttpPutChunkedFile.java

License:Apache License

@Before
public void setUp() throws Exception {

    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);

    temporaryFile = new TemporaryFile(folder);

    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);

    integrationServer = new JettyIntegrationServer();
    integrationServer.start();//from ww w  . ja  v a2  s  .c  om
    port = integrationServer.getPort();

    httpClient = new TestingHttpClientFactory().create();

    httpClient.setConf(ConfKeys.IDLE_TIMEOUT_MILLIS, 300);

    httpClient.start();

}

From source file:com.slyak.services.proxy.server.NettyProxyServer.java

License:Apache License

@SneakyThrows(InterruptedException.class)
public void start() {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
    ServerBootstrap bootstrap = new ServerBootstrap();
    bossGroup = new NioEventLoopGroup(proxyProperties.getBoss());
    workerGroup = new NioEventLoopGroup(proxyProperties.getWorker());
    clientGroup = new NioEventLoopGroup(proxyProperties.getClient());
    try {//from w  w  w.j ava 2  s .com
        bootstrap.group(bossGroup, workerGroup).channel(getChannelClass())
                .option(ChannelOption.SO_BACKLOG, proxyProperties.getBackLog())
                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, proxyProperties.getConnectTimeout())

                .childOption(ChannelOption.TCP_NODELAY, true).childOption(ChannelOption.SO_REUSEADDR, true)

                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    protected void initChannel(SocketChannel ch) throws Exception {
                        ChannelPipeline pipeline = ch.pipeline();
                        //channel time out handler
                        pipeline.addLast(new IdleStateHandler(0, 0, 30));
                        pipeline.addLast(new IdleEventHandler());
                        //logging
                        pipeline.addLast(new LoggingHandler());

                        if (isRouter()) {
                            pipeline.addLast(getProxyHandler(proxyProperties));
                        } else {
                            pipeline.addLast(getCustomChannelHandlers(clientGroup));
                        }
                        pipeline.addLast(ExceptionHandler.INSTANCE);
                    }
                });
        //start server
        ChannelFuture future = bootstrap.bind(proxyProperties.getPort()).sync();
        log.debug("Starting proxy server , port is {}", proxyProperties.getPort());
        future.channel().closeFuture().sync();
    } finally {
        stop();
    }
}

From source file:com.tc.websocket.server.WebSocketServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {

    IConfig cfg = Config.getInstance();/*  ww  w .  ja  va2s .c o  m*/

    //if we need to check for ByteBuf leaks.
    if (cfg.isLeakDetector()) {
        ResourceLeakDetector.setLevel(Level.ADVANCED);
    }

    //so we get enough data to build our pipeline
    ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(1024));

    ChannelPipeline pipeline = ch.pipeline();

    int incomingPort = ch.localAddress().getPort();

    //if users are coming in on a different port than the proxy port we need to redirect them.
    if (cfg.isProxy() && cfg.getPort() != incomingPort) {
        redirectBuilder.apply(pipeline);
        return;
    }

    if (cfg.isEncrypted()) {
        SslContext sslContext = factory.createSslContext(Config.getInstance());
        SSLEngine engine = sslContext.newEngine(ch.alloc());
        engine.setUseClientMode(false);
        engine.setNeedClientAuth(cfg.isCertAuth());
        ch.pipeline().addFirst("ssl", new SslHandler(engine));
    }

    if (cfg.isProxy()) {
        pipeline.channel().config().setAutoRead(false);
        pipeline.addLast(
                guicer.inject(new ProxyFrontendHandler(cfg.getProxyBackendHost(), cfg.getProxyBackendPort())));

    } else {
        websocketBuilder.apply(pipeline);
    }

}