当前位置: 首页>>代码示例>>Java>>正文


Java Level类代码示例

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


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

示例1: testExecuteMultiThreadRpc

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Test
public void testExecuteMultiThreadRpc()
{
	Random rand = new Random(System.currentTimeMillis());
	ResourceLeakDetector.setLevel(Level.PARANOID);
       GridConfiguration config = GridConfigFactory.configure(this.getClass().getResourceAsStream("/grid-config.xml"));
	GridRuntime.initialize(config);
	RpcExecutor.registerMethod("print", RemoteObject.class, new RemoteObject());
	RpcExecutor.registerMethod("add", RemoteObject.class, new RemoteObject());
	ThreadUtils.threadSleep(5000);
	for (int i = 1; i <= 100; i++)
	{
		int a = rand.nextInt(100);
		int b = rand.nextInt(100);
		long st = System.currentTimeMillis();
		RpcResult result = RpcExecutor.callMethod("add", new Object[]{a, b}, new ExecuteConfig());
		System.out.println("==========>" + i + " " + result + " cost:" + (System.currentTimeMillis() - st));
		ThreadUtils.threadSleep(10);
	}
	while(true)
	{
		ThreadUtils.threadSleep(10000);
	}
}
 
开发者ID:liulhdarks,项目名称:darks-grid,代码行数:25,代码来源:RpcTest.java

示例2: afterPropertiesSet

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
  ACTIVE = active;
  if (isDev()) {
    VIEW_SERVER_PORT = viewServerPort;
    ResourceLeakDetector.setLevel(Level.ADVANCED);
  } else {
    VIEW_SERVER_PORT = OsUtil.getFreePort();
  }
}
 
开发者ID:monkeyWie,项目名称:proxyee-down,代码行数:11,代码来源:HttpDownServer.java

示例3: bind

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
/**
 * Builds the network by creating the netty server bootstrap and binding to a specified port.
 * 
 * @return The instance of this bootstrap.
 */
public Bootstrap bind() throws InterruptedException {
  logger.info("Building network");
  ResourceLeakDetector.setLevel(Level.DISABLED);
  EventLoopGroup loopGroup = new NioEventLoopGroup();

  ServerBootstrap bootstrap = new ServerBootstrap();

  bootstrap.group(loopGroup).channel(NioServerSocketChannel.class)
      .childHandler(new ChannelPiplineInitializer()).bind(43593 + world.getId()).syncUninterruptibly();

  Server.serverStarted = true;
  logger.info(String.format("World %d has been bound to port %d", world.getId(), world.getPort()));    
  return this;
}
 
开发者ID:nshusa,项目名称:astraeus-legacy,代码行数:20,代码来源:Bootstrap.java

示例4: setup

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    originalLevel = ResourceLeakDetector.getLevel();
    ResourceLeakDetector.setLevel(Level.PARANOID);
    InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
    this.serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    this.serviceBuilder.initialize();
}
 
开发者ID:pravega,项目名称:pravega,代码行数:9,代码来源:TransactionTest.java

示例5: initialize

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
/**
 * Initializes this network handler effectively preparing the server to
 * listen for connections and handle network events.
 *
 * @param port
 *            the port that this network will be bound to.
 * @throws Exception
 *             if any issues occur while starting the network.
 */
public void initialize(int port) throws IOException {
    if (port != 43594 && port != 5555 && port != 43595)
        logger.warning("The preferred ports for Runescape servers are 43594, 5555, and 43595!");
    ResourceLeakDetector.setLevel(Server.DEBUG ? Level.PARANOID : NetworkConstants.RESOURCE_DETECTION);
    bootstrap.group(loopGroup);
    bootstrap.channel(NioServerSocketChannel.class);
    bootstrap.childHandler(channelInitializer);
    bootstrap.bind(port).syncUninterruptibly();
}
 
开发者ID:lare96,项目名称:asteria-3.0,代码行数:19,代码来源:NetworkBuilder.java

示例6: testStartup

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Test
public void testStartup()
{
	ResourceLeakDetector.setLevel(Level.PARANOID);
       GridConfiguration config = GridConfigFactory.configure(this.getClass().getResourceAsStream("/grid-config.xml"));
	GridRuntime.initialize(config);
	while(true)
	{
		ThreadUtils.threadSleep(10000);
	}
}
 
开发者ID:liulhdarks,项目名称:darks-grid,代码行数:12,代码来源:GridServerTest.java

示例7: testStartRpcNode

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Test
public void testStartRpcNode()
{
	ResourceLeakDetector.setLevel(Level.PARANOID);
       GridConfiguration config = GridConfigFactory.configure(this.getClass().getResourceAsStream("/grid-config.xml"));
	GridRuntime.initialize(config);
	RpcExecutor.registerMethod("print", RemoteObject.class, new RemoteObject());
	RpcExecutor.registerMethod("add", RemoteObject.class, new RemoteObject());
	while(true)
	{
		ThreadUtils.threadSleep(10000);
	}
}
 
开发者ID:liulhdarks,项目名称:darks-grid,代码行数:14,代码来源:RpcTest.java

示例8: handle

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Override
public boolean handle(CommandSender sender, String[] args) {
	if (ResourceLeakDetector.isEnabled()) {
		ResourceLeakDetector.setLevel(Level.DISABLED);
		sender.sendMessage(ChatColor.YELLOW + "Disabled leak detector");
	} else {
		ResourceLeakDetector.setLevel(Level.PARANOID);
		sender.sendMessage(ChatColor.YELLOW + "Enabled leak detector");
	}
	return true;
}
 
开发者ID:ProtocolSupport,项目名称:ProtocolSupport,代码行数:12,代码来源:LeakDetectorSubCommand.java

示例9: testAsyncSocketServer

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Test
public void testAsyncSocketServer() throws Exception {
	ResourceLeakDetector.setLevel(Level.ADVANCED);
	TransientMockNetworkOfNodes mockNetworkOfNodes=new TransientMockNetworkOfNodes();
	final CountDownLatch serverDoneBarrier = new CountDownLatch(NB_CLIENTS*NUMBER_OF_MESSAGE);
	MessageEchoApp serverSideCountingHandler=new MessageEchoApp(mockNetworkOfNodes.server1, serverDoneBarrier);
	
	final CountDownLatch clientsDoneBarrier = new CountDownLatch(NB_CLIENTS);
	for(int i=0; i<NB_CLIENTS; i++){
		new Thread(){ @Override public void run() {
				try {
					doNettyClientWrite(mockNetworkOfNodes.client1ToServer1Connection);
					clientsDoneBarrier.countDown();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}.start();
	}
	clientsDoneBarrier.await();
	mockNetworkOfNodes.client1ToServer1Connection.close();
	serverDoneBarrier.await();
	
	mockNetworkOfNodes.server1.networkServer.stopAcceptingConnections();

	assertEquals(NB_CLIENTS*NUMBER_OF_MESSAGE, serverSideCountingHandler.numberOfMessagesReceived.intValue());
}
 
开发者ID:pmarches,项目名称:peercentrum-core,代码行数:28,代码来源:AsyncSocketServerTest.java

示例10: testSendToClosedTransportFailsButDoesNotLeak

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Ignore("Used for checking for transport level leaks, my be unstable on CI.")
@Test(timeout = 60 * 1000)
public void testSendToClosedTransportFailsButDoesNotLeak() throws Exception {
    Transport transport = null;

    ResourceLeakDetector.setLevel(Level.PARANOID);

    try (NettyEchoServer server = createEchoServer(createServerOptions())) {
        server.start();

        int port = server.getServerPort();
        URI serverLocation = new URI("tcp://localhost:" + port);

        for (int i = 0; i < 256; ++i) {
            transport = createTransport(serverLocation, testListener, createClientOptions());
            try {
                transport.connect(null);
                LOG.info("Connected to server:{} as expected.", serverLocation);
            } catch (Exception e) {
                fail("Should have connected to the server at " + serverLocation + " but got exception: " + e);
            }

            assertTrue(transport.isConnected());

            ByteBuf sendBuffer = transport.allocateSendBuffer(10 * 1024 * 1024);
            sendBuffer.writeBytes(new byte[] {0, 1, 2, 3, 4});

            transport.close();

            try {
                transport.send(sendBuffer);
                fail("Should throw on send of closed transport");
            } catch (IOException ex) {
            }
        }

        System.gc();
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:40,代码来源:NettyTcpTransportTest.java

示例11: resetNettyLeakDetectionLevel

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
private void resetNettyLeakDetectionLevel() {
    System.clearProperty(NETTY_LEAK_DETECTION_LEVEL_SYSTEM_PROP_KEY);
    ResourceLeakDetector.setLevel(Level.SIMPLE);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:5,代码来源:MainClassUtilsTest.java

示例12: setupNettyLeakDetectionLevel_works_as_expected

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@DataProvider(value = {
    // no-op case
    "null       |   null        |   null        |   null",
    // cases showing that system property takes precedence over everything
    "PARANOID   |   null        |   null        |   PARANOID",
    "disabled   |   PARANOID    |   null        |   DISABLED", // also - lowercase works
    "aDvAnCeD   |   PARANOID    |   DISABLED    |   ADVANCED", // also - mixed case works
    // cases showing that NETTY_LEAK_DETECTION_LEVEL_SYSTEM_PROP_KEY takes precedence
    //      over NETTY_LEAK_DETECTION_LEVEL_APP_PROP_KEY if the system property is absent
    "null       |   ADVANCED    |   null        |   ADVANCED",
    "null       |   aDvAnCeD    |   PARANOID    |   ADVANCED", // yes, lower/mixed case still works here too
    // cases showing NETTY_LEAK_DETECTION_LEVEL_APP_PROP_KEY will be used if the other
    //      options are not available
    "null       |   null        |   DISABLED    |   DISABLED",
    "null       |   null        |   pArAnOiD    |   PARANOID", // yes, lower/mixed case still works here too
}, splitBy = "\\|")
@Test
public void setupNettyLeakDetectionLevel_works_as_expected(
    String systemPropValue, String configValueForSystemPropKey, String configValueForAppPropKey, Level expectedFinalLevel
) {
    // given
    assertThat(ResourceLeakDetector.getLevel()).isEqualTo(Level.SIMPLE);
    assertThat(expectedFinalLevel).isNotEqualTo(Level.SIMPLE);

    setSystemPropWithNullSupport(NETTY_LEAK_DETECTION_LEVEL_SYSTEM_PROP_KEY, systemPropValue);
    Function<String, String> propertyExtractionFunction = (key) -> {
        switch(key) {
            case NETTY_LEAK_DETECTION_LEVEL_SYSTEM_PROP_KEY:
                return configValueForSystemPropKey;
            case NETTY_LEAK_DETECTION_LEVEL_APP_PROP_KEY:
                return configValueForAppPropKey;
            default:
                throw new IllegalArgumentException("Unhandled config key: " + key);
        }
    };
    Function<String, Boolean> hasPropertyFunction = (key) -> (propertyExtractionFunction.apply(key) != null);

    // when
    MainClassUtils.setupNettyLeakDetectionLevel(hasPropertyFunction, propertyExtractionFunction);

    // then
    if (expectedFinalLevel == null) {
        // We expect that the method did nothing since it couldn't find anything to set
        assertThat(System.getProperty(NETTY_LEAK_DETECTION_LEVEL_SYSTEM_PROP_KEY)).isNull();
        assertThat(ResourceLeakDetector.getLevel()).isEqualTo(Level.SIMPLE);
    }
    else {
        assertThat(System.getProperty(NETTY_LEAK_DETECTION_LEVEL_SYSTEM_PROP_KEY))
            .isEqualTo(expectedFinalLevel.name());
        assertThat(ResourceLeakDetector.getLevel()).isEqualTo(expectedFinalLevel);
    }
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:53,代码来源:MainClassUtilsTest.java

示例13: testByteBufsReleasedWhenTimeout

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Test
public void testByteBufsReleasedWhenTimeout() {
	ResourceLeakDetector.setLevel(Level.PARANOID);

	byte[] content = new byte[1024*8];
	Random rndm = new Random();
	rndm.nextBytes(content);

	NettyContext server1 =
			HttpServer.create(0)
			          .newRouter(routes ->
			                     routes.get("/target", (req, res) ->
			                           res.sendByteArray(Flux.just(content)
			                                                 .delayElements(Duration.ofMillis(100)))))
			          .block(Duration.ofSeconds(30));

	NettyContext server2 =
			HttpServer.create(0)
			          .newRouter(routes ->
			                     routes.get("/forward", (req, res) ->
			                           HttpClient.create(server1.address().getPort())
			                                     .get("/target")
			                                     .log()
			                                     .delayElement(Duration.ofMillis(50))
			                                     .flatMap(response -> response.receive().aggregate().asString())
			                                     .timeout(Duration.ofMillis(50))
			                                     .then()))
			          .block(Duration.ofSeconds(30));

	Flux.range(0, 50)
	    .flatMap(i -> HttpClient.create(server2.address().getPort())
	                            .get("/forward")
	                            .log()
	                            .onErrorResume(t -> Mono.empty()))
	    .blockLast(Duration.ofSeconds(30));

	server1.dispose();
	server2.dispose();

	ResourceLeakDetector.setLevel(Level.SIMPLE);
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:42,代码来源:FluxReceiveTest.java

示例14: initChannel

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Override
public void initChannel(SocketChannel ch) throws Exception {

	IConfig cfg = Config.getInstance();
	
	//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);
	}

}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:43,代码来源:WebSocketServerInitializer.java

示例15: setup

import io.netty.util.ResourceLeakDetector.Level; //导入依赖的package包/类
@Before
public void setup() {
    origionalLogLevel = ResourceLeakDetector.getLevel();
    ResourceLeakDetector.setLevel(Level.PARANOID);
}
 
开发者ID:pravega,项目名称:pravega,代码行数:6,代码来源:AppendEncodeDecodeTest.java


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