io.netty.util.ResourceLeakDetector.Level Java Examples
The following examples show how to use
io.netty.util.ResourceLeakDetector.Level.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestClientBenchmark.java From turbo-rpc with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { ResourceLeakDetector.setLevel(Level.DISABLED); // CtClass.debugDump = "d:/debugDump"; // RestClientBenchmark clientBenchmark = new RestClientBenchmark(); // System.out.println(clientBenchmark.createUser()); // clientBenchmark.close(); Options opt = new OptionsBuilder()// .include(RestClientBenchmark.class.getSimpleName())// .warmupIterations(5)// .measurementIterations(5)// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); }
Example #2
Source File: AltsTsiTest.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { ResourceLeakDetector.setLevel(Level.PARANOID); // Use MockAltsHandshakerStub for all the tests. AltsHandshakerOptions handshakerOptions = new AltsHandshakerOptions(null); MockAltsHandshakerStub clientStub = new MockAltsHandshakerStub(); MockAltsHandshakerStub serverStub = new MockAltsHandshakerStub(); client = new AltsHandshakerClient(clientStub, handshakerOptions); server = new AltsHandshakerClient(serverStub, handshakerOptions); }
Example #3
Source File: AltsTsiTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { ResourceLeakDetector.setLevel(Level.PARANOID); // Use MockAltsHandshakerStub for all the tests. AltsHandshakerOptions handshakerOptions = new AltsHandshakerOptions(null); MockAltsHandshakerStub clientStub = new MockAltsHandshakerStub(); MockAltsHandshakerStub serverStub = new MockAltsHandshakerStub(); client = new AltsHandshakerClient(clientStub, handshakerOptions); server = new AltsHandshakerClient(serverStub, handshakerOptions); }
Example #4
Source File: RpcServerBenchmark.java From turbo-rpc with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { ResourceLeakDetector.setLevel(Level.DISABLED); // CtClass.debugDump = "d:/debugDump"; try (TurboServer server = new TurboServer("shop", "auth");) { Map<Class<?>, Object> services = Map.of(UserService.class, new UserServiceServerImpl()); server.registerService(services); /* * server.addFirst(new RpcServerFilter() { * * @Override public void onSend(Request request, Response response) { try { * Tracer tracer = request.getTracer(); * * if (tracer != null) { response.setTracer(tracer); } * * } catch (Exception e) { e.printStackTrace(); } } * * @Override public boolean onRecive(Request request) { try { Tracer tracer = * request.getTracer(); * * if (tracer != null) { RemoteContext.getClientAddress().toString(); * RemoteContext.getServerAddress().toString(); * RemoteContext.getServiceMethodName(); * * TracerContext.setTracer(tracer); } } catch (Exception e) { * e.printStackTrace(); } * * return true; } * * @Override public void onError(Request request, Response response, Throwable * throwable) { } }); */ server.startRpcServer(new HostPort("127.0.0.1", 8080)); server.waitUntilShutdown(); } }
Example #5
Source File: RestServerBenchmark.java From turbo-rpc with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { ResourceLeakDetector.setLevel(Level.DISABLED); // CtClass.debugDump = "d:/debugDump"; try (TurboServer server = new TurboServer("shop", "auth");) { Map<Class<?>, Object> services = Map.of(UserService.class, new UserServiceServerImpl()); server.registerService(services); server.startRestServer(new HostPort("0.0.0.0", 8080)); server.waitUntilShutdown(); } }
Example #6
Source File: Server.java From rpc-benchmark with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { ResourceLeakDetector.setLevel(Level.DISABLED); try (TurboServer server = new TurboServer("shop", "auth");) { Map<Class<?>, Object> services = Map.of(TurboUserService.class, new TurboUserServiceServerImpl()); server.registerService(services); server.startRestServer(new HostPort("benchmark-server", 8080)); server.waitUntilShutdown(); } }
Example #7
Source File: Client.java From rpc-benchmark with Apache License 2.0 | 5 votes |
public Client() { ResourceLeakDetector.setLevel(Level.DISABLED); client = new TurboClient("turbo-client.conf"); try { client.register(TurboUserService.class); userService = client.getService(TurboUserService.class); } catch (Exception e) { throw new RuntimeException(e); } }
Example #8
Source File: NettyTcpTransportTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@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, 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.writeAndFlush(sendBuffer); fail("Should throw on send of closed transport"); } catch (IOException ex) { } } System.gc(); } }
Example #9
Source File: LeakDetectorSubCommand.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@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; }
Example #10
Source File: LunaSettings.java From luna with MIT License | 5 votes |
/** * Please note as the leak detection levels get higher, the tradeoff is a <strong>substantial</strong> * performance loss. {@code PARANOID} should <strong>never</strong> be used in a production environment. */ public Level resourceLeakDetection() { switch (runtimeMode) { case PRODUCTION: return Level.DISABLED; case BENCHMARK: return Level.SIMPLE; case DEVELOPMENT: return Level.PARANOID; default: throw new IllegalStateException("Invalid runtime mode!"); } }
Example #11
Source File: NetworkBuilder.java From asteria-3.0 with GNU General Public License v3.0 | 5 votes |
/** * 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(); }
Example #12
Source File: FakeTsiTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Before public void setUp() { ResourceLeakDetector.setLevel(Level.PARANOID); }
Example #13
Source File: AltsTsiFrameProtectorTest.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@Before public void setUp() { ResourceLeakDetector.setLevel(Level.PARANOID); }
Example #14
Source File: AltsChannelCrypterTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Before public void setUp() throws GeneralSecurityException { ResourceLeakDetector.setLevel(Level.PARANOID); client = new AltsChannelCrypter(new byte[AltsChannelCrypter.getKeyLength()], true); server = new AltsChannelCrypter(new byte[AltsChannelCrypter.getKeyLength()], false); }
Example #15
Source File: AltsTsiFrameProtectorTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Before public void setUp() { ResourceLeakDetector.setLevel(Level.PARANOID); }
Example #16
Source File: MainClassUtilsTest.java From riposte with Apache License 2.0 | 4 votes |
@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); } }
Example #17
Source File: MainClassUtilsTest.java From riposte with Apache License 2.0 | 4 votes |
private void resetNettyLeakDetectionLevel() { System.clearProperty(NETTY_LEAK_DETECTION_LEVEL_SYSTEM_PROP_KEY); ResourceLeakDetector.setLevel(Level.SIMPLE); }
Example #18
Source File: Server.java From rpc-benchmark with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { ResourceLeakDetector.setLevel(Level.DISABLED); SpringApplication.run(Server.class, args); }
Example #19
Source File: HttpDownSpringBoot.java From proxyee-down with Apache License 2.0 | 4 votes |
@Override public void afterPropertiesSet() throws Exception { if ("dev".equalsIgnoreCase(active.trim())) { ResourceLeakDetector.setLevel(Level.ADVANCED); } }
Example #20
Source File: FakeTsiTest.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@Before public void setUp() { ResourceLeakDetector.setLevel(Level.PARANOID); }
Example #21
Source File: AltsChannelCrypterTest.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@Before public void setUp() throws GeneralSecurityException { ResourceLeakDetector.setLevel(Level.PARANOID); client = new AltsChannelCrypter(new byte[AltsChannelCrypter.getKeyLength()], true); server = new AltsChannelCrypter(new byte[AltsChannelCrypter.getKeyLength()], false); }