本文整理匯總了Java中io.netty.util.ResourceLeakDetector.setLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceLeakDetector.setLevel方法的具體用法?Java ResourceLeakDetector.setLevel怎麽用?Java ResourceLeakDetector.setLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.util.ResourceLeakDetector
的用法示例。
在下文中一共展示了ResourceLeakDetector.setLevel方法的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);
}
示例2: 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();
}
示例3: 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);
}
示例4: 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);
}
示例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!");
}
示例6: 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);
}
}
示例7: 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();
}
}
示例8: 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;
}
示例9: 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;
}
示例10: setup
import io.netty.util.ResourceLeakDetector; //導入方法依賴的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();
}
示例11: initialize
import io.netty.util.ResourceLeakDetector; //導入方法依賴的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();
}
示例12: testStartup
import io.netty.util.ResourceLeakDetector; //導入方法依賴的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);
}
}
示例13: testStartRpcNode
import io.netty.util.ResourceLeakDetector; //導入方法依賴的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);
}
}
示例14: handle
import io.netty.util.ResourceLeakDetector; //導入方法依賴的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;
}
示例15: testAsyncSocketServer
import io.netty.util.ResourceLeakDetector; //導入方法依賴的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());
}