當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceLeakDetector類代碼示例

本文整理匯總了Java中io.netty.util.ResourceLeakDetector的典型用法代碼示例。如果您正苦於以下問題:Java ResourceLeakDetector類的具體用法?Java ResourceLeakDetector怎麽用?Java ResourceLeakDetector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ResourceLeakDetector類屬於io.netty.util包,在下文中一共展示了ResourceLeakDetector類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
@PostConstruct
public void init() throws Exception {
  log.info("Setting resource leak detector level to {}", leakDetectorLevel);
  ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.valueOf(leakDetectorLevel.toUpperCase()));

  log.info("Starting MQTT transport...");
  log.info("Lookup MQTT transport adaptor {}", adaptorName);
  // this.adaptor = (MqttTransportAdaptor) appContext.getBean(adaptorName);

  log.info("Starting MQTT transport server");
  bossGroup = new NioEventLoopGroup(bossGroupThreadCount);
  workerGroup = new NioEventLoopGroup(workerGroupThreadCount);
  ServerBootstrap b = new ServerBootstrap();
  b.group(bossGroup, workerGroup).option(ChannelOption.SO_BACKLOG, 1000).option(ChannelOption.TCP_NODELAY, true)
      .childOption(ChannelOption.SO_KEEPALIVE, true).channel(NioServerSocketChannel.class)
      .childHandler(new MqttTransportServerInitializer(msgProducer, deviceService, authService, assetService,
          assetAuthService, relationService, sslHandlerProvider));

  serverChannel = b.bind(host, port).sync().channel();
  log.info("Mqtt transport started: {}:{}!", host, port);
}
 
開發者ID:osswangxining,項目名稱:iothub,代碼行數:22,代碼來源:MqttTransportService.java

示例2: verify_essential_behavior

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
@Test
public void verify_essential_behavior() throws Exception {
    // given
    setAppAndEnvironment("typesafeconfigserver", "compiletimetest");
    int port = findFreePort();
    TypesafeConfigServer server = generateTypesafeConfigServer(port);
    assertThat(System.getProperty("org.jboss.logging.provider")).isNull();

    // when
    server.launchServer(null);
    ExtractableResponse<Response> response =
        given()
            .baseUri("http://localhost")
            .port(port)
        .when()
            .get(SomeEndpoint.MATCHING_PATH)
        .then()
            .extract();

    // then
    assertThat(response.statusCode()).isEqualTo(200);
    assertThat(response.asString()).isEqualTo("overridevalue");
    assertThat(System.getProperty("org.jboss.logging.provider")).isEqualTo("slf4j");
    assertThat(ResourceLeakDetector.getLevel()).isEqualTo(ResourceLeakDetector.Level.PARANOID);
}
 
開發者ID:Nike-Inc,項目名稱:riposte,代碼行數:26,代碼來源:TypesafeConfigServerTest.java

示例3: verify_essential_behavior

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
@Test
public void verify_essential_behavior() throws Exception {
    // given
    setAppAndEnvironment("archaiusserver", "compiletimetest");
    int port = findFreePort();
    ArchaiusServer server = generateArchaiusServer(port);
    assertThat(System.getProperty("org.jboss.logging.provider")).isNull();

    // when
    server.launchServer(null);
    ExtractableResponse<Response> response =
        given()
            .baseUri("http://localhost")
            .port(port)
            .when()
            .get(SomeEndpoint.MATCHING_PATH)
            .then()
            .extract();

    // then
    assertThat(response.statusCode()).isEqualTo(200);
    assertThat(response.asString()).isEqualTo("overridevalue");
    assertThat(System.getProperty("org.jboss.logging.provider")).isEqualTo("slf4j");
    assertThat(ResourceLeakDetector.getLevel()).isEqualTo(ResourceLeakDetector.Level.PARANOID);
}
 
開發者ID:Nike-Inc,項目名稱:riposte,代碼行數:26,代碼來源:ArchaiusServerTest.java

示例4: NettyTransport

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
public NettyTransport(ChannelType channelType, ExecutorService executor) {
    executorService = executor;
    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());
}
 
開發者ID:ribasco,項目名稱:async-gamequery-lib,代碼行數:26,代碼來源:NettyTransport.java

示例5: init

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
@PostConstruct
public void init() throws Exception {
    log.info("Setting resource leak detector level to {}", leakDetectorLevel);
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.valueOf(leakDetectorLevel.toUpperCase()));

    log.info("Starting MQTT transport...");
    log.info("Lookup MQTT transport adaptor {}", adaptorName);
    this.adaptor = (MqttTransportAdaptor) appContext.getBean(adaptorName);

    log.info("Starting MQTT transport server");
    bossGroup = new NioEventLoopGroup(bossGroupThreadCount);
    workerGroup = new NioEventLoopGroup(workerGroupThreadCount);
    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup, workerGroup)
            .channel(NioServerSocketChannel.class)
            .childHandler(new MqttTransportServerInitializer(processor, deviceService, authService, relationService, adaptor, sslHandlerProvider));

    serverChannel = b.bind(host, port).sync().channel();
    log.info("Mqtt transport started!");
}
 
開發者ID:thingsboard,項目名稱:thingsboard,代碼行數:21,代碼來源:MqttTransportService.java

示例6: main

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
public static void main(String... args) throws Exception {
    // RakNet doesn't really like IPv6
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
    System.setProperty("java.net.preferIPv4Stack", "true");

    // Load native libraries early.
    boolean partiallySupportedLinux = Epoll.isAvailable();
    boolean fullySupportedLinux = NativeCodeFactory.cipher.load();

    if (partiallySupportedLinux) {
        NativeCodeFactory.zlib.load();
        if (fullySupportedLinux) {
            NativeCodeFactory.hash.load();
        } else {
            LOGGER.warn("You are running x64 Linux, but you are not using a fully-supported distribution. Server throughput and performance will be affected. Visit https://wiki.voxelwind.com/why_linux for more information.");
        }
    } else {
        LOGGER.warn("You are not running x64 Linux. Server throughput and performance will be affected. Visit https://wiki.voxelwind.com/why_linux for more information.");
    }

    VoxelwindServer server = new VoxelwindServer();
    server.boot();
}
 
開發者ID:voxelwind,項目名稱:voxelwind,代碼行數:24,代碼來源:VoxelwindServer.java

示例7: init

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
/**
 * Init timeouts and the connection registry and start the netty IO server synchronously
 */
@Override
public void init(Container container) {
    super.init(container);
    try {
        // Configure netty
        InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory() {
            @Override
            public InternalLogger newInstance(String name) {
                return new NettyInternalLogger(name);
            }
        });
        ResourceLeakDetector.setLevel(CoreConstants.NettyConstants.RESOURCE_LEAK_DETECTION);
        // Start server
        startServer();
    } catch (InterruptedException e) {
        throw new StartupException("Could not start netty server", e);
    }
}
 
開發者ID:SecureSmartHome,項目名稱:SecureSmartHome,代碼行數:22,代碼來源:Server.java

示例8: init

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
/**
 * Configure netty and initialize related Components.
 * Afterwards call {@link #initClient()} method to start the netty IO client asynchronously.
 */
@Override
public void init(Container container) {
    super.init(container);
    // Configure netty
    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory() {
        @Override
        public InternalLogger newInstance(String name) {
            return new NettyInternalLogger(name);
        }
    });
    ResourceLeakDetector.setLevel(CoreConstants.NettyConstants.RESOURCE_LEAK_DETECTION);
    // And try to connect
    isActive = true;
    initClient();
    // register BroadcastListener
    IntentFilter filter = new IntentFilter();
    filter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
    filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    requireComponent(ContainerService.KEY_CONTEXT).registerReceiver(broadcastReceiver, filter);
}
 
開發者ID:SecureSmartHome,項目名稱:SecureSmartHome,代碼行數:27,代碼來源:Client.java

示例9: main

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
/**
 * tcpdump udp port 2225 -x -vv -s0 -w 1112.pcap
 *
 * @param args
 * @throws java.lang.InterruptedException
 */
public static void main(String[] args) throws InterruptedException
{
  ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED);
  TestClient tc = new TestClient();
  tc.noDelay(1, 20, 2, 1);
  tc.setMinRto(10);
  tc.wndSize(32, 32);
  tc.setTimeout(10 * 1000);
  tc.setMtu(512);
  // tc.setConv(121106);//默認conv隨機

  tc.connect(new InetSocketAddress("localhost", 2222));
  tc.start();
  String content = "sdfkasd你好。。。。。。。";
  ByteBuf bb = PooledByteBufAllocator.DEFAULT.buffer(1500);
  bb.writeBytes(content.getBytes(Charset.forName("utf-8")));
  tc.send(bb);
}
 
開發者ID:beykery,項目名稱:jkcp,代碼行數:25,代碼來源:TestClient.java

示例10: toLeakAwareBuffer

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
protected static ByteBuf toLeakAwareBuffer(ByteBuf buf) {
    ResourceLeak leak;
    switch (ResourceLeakDetector.getLevel()) {
        case SIMPLE:
            leak = AbstractByteBuf.leakDetector.open(buf);
            if (leak != null) {
                buf = new SimpleLeakAwareByteBuf(buf, leak);
            }
            break;
        case ADVANCED:
        case PARANOID:
            leak = AbstractByteBuf.leakDetector.open(buf);
            if (leak != null) {
                buf = new AdvancedLeakAwareByteBuf(buf, leak);
            }
            break;
    }
    return buf;
}
 
開發者ID:wuyinxian124,項目名稱:netty4.0.27Learn,代碼行數:20,代碼來源:AbstractByteBufAllocator.java

示例11: testExecuteMultiThreadRpc

import io.netty.util.ResourceLeakDetector; //導入依賴的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

示例12: main

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
public static void main(String... args) throws Exception {
    ResourceLeakDetector.setEnabled(true);

    final int port = Integer.parseInt(args[0]);

    int iscsiPort = 3260 + port;

    SocketAddress iscsiSocketAddress = new InetSocketAddress(iscsiPort);
    File basePath = new File("data" + port);
    final BlockStoreServer server = new BlockStoreServer(iscsiSocketAddress, basePath);
    server.start();

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            try {
                server.stop();
            } catch (Exception e) {
                log.error("Error stopping server", e);
            }
        }
    });
}
 
開發者ID:justinsb,項目名稱:cloudata,代碼行數:24,代碼來源:BlockStoreServer.java

示例13: afterPropertiesSet

import io.netty.util.ResourceLeakDetector; //導入依賴的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

示例14: execute

import io.netty.util.ResourceLeakDetector; //導入依賴的package包/類
@Override
public boolean execute(ViaCommandSender sender, String[] args) {
    if (ResourceLeakDetector.getLevel() != ResourceLeakDetector.Level.ADVANCED)
        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
    else
        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED);

    sendMessage(sender, "&6Leak detector is now %s", (ResourceLeakDetector.getLevel() == ResourceLeakDetector.Level.ADVANCED ? "&aenabled" : "&cdisabled"));
    return true;
}
 
開發者ID:MylesIsCool,項目名稱:ViaVersion,代碼行數:11,代碼來源:DisplayLeaksSubCmd.java

示例15: bind

import io.netty.util.ResourceLeakDetector; //導入依賴的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


注:本文中的io.netty.util.ResourceLeakDetector類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。