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:io.gomint.proxprox.ProxProxProxy.java

License:BSD License

/**
 * Entrypoint to ProxProxProxy. This should be only called from the Bootstrap so we can
 * be sure we have all Libs loaded which we need.
 *
 * @param args optional arguments given via CLI arguments
 *//*from  w  w  w  . j  av a 2s  .  com*/
public ProxProxProxy(String[] args) {
    ProxProx.setProxy(this);
    ProxProxProxy.instance = this;

    LOGGER.info("Starting ProxProxProxy v1.0.0");

    System.setProperty("java.net.preferIPv4Stack", "true"); // We currently don't use ipv6
    System.setProperty("io.netty.selectorAutoRebuildThreshold", "0"); // Never rebuild selectors
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED); // Eats performance

    // ------------------------------------ //
    // Executor Initialization
    // ------------------------------------ //
    this.executorService = MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(4));
    this.processExecutorService = new PostProcessExecutorService(this.executorService);

    // Build up watchdog
    this.watchdog = new Watchdog(this.executorService, this.running);

    // We target 100 TPS
    long skipMillis = TimeUnit.SECONDS.toMillis(1) / 100;
    this.syncTaskManager = new SyncTaskManager(this);

    // Load config first so we can override
    this.config = new ProxyConfig();

    try {
        this.config.init(new File("config.yml"));
    } catch (InvalidConfigurationException e) {
        LOGGER.error("Could not init config.cfg. Please check for corruption.", e);
        System.exit(-1);
    }

    // Parse optional arguments
    if (!parseCommandLineArguments(args)) {
        System.exit(-1);
    }

    // Load plugins
    File pluginDir = new File("plugins/");
    if (!pluginDir.exists()) {
        pluginDir.mkdirs();
    }

    this.pluginManager = new PluginManager(this, pluginDir);
    this.pluginManager.detectPlugins();
    this.pluginManager.loadPlugins();
    this.pluginManager.enablePlugins();

    // Register default commands
    this.pluginManager.registerCommand(null, new Commandend(this));
    this.pluginManager.registerCommand(null, new Commandplugins(this.pluginManager));

    // Bind upstream UDP Raknet
    this.serverSocket = new ServerSocket(LoggerFactory.getLogger("jRaknet"), this.config.getMaxPlayers());
    this.serverSocket.setMojangModificationEnabled(true);

    this.socketEventListener = new SocketEventListener(this);
    this.serverSocket.setEventHandler(this.socketEventListener);

    try {
        this.serverSocket.bind(this.config.getIp(), this.config.getPort());
        LOGGER.info("Bound to " + this.config.getIp() + ":" + this.config.getPort());
    } catch (SocketException e) {
        LOGGER.error("Failed to bind to " + this.config.getIp() + ":" + this.config.getPort(), e);
        System.exit(-1);
    }

    // Read stdin
    if (Objects.equals(System.getProperty("disableStdin", "false"), "false")) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                Thread.currentThread().setName("STDIN Read");
                ConsoleCommandSender consoleCommandSender = new ConsoleCommandSender();

                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                String s;
                try {
                    while (running.get()) {
                        s = in.readLine();
                        if (s != null && s.length() != 0) {
                            pluginManager.dispatchCommand(consoleCommandSender, s);
                        }
                    }
                } catch (IOException e) {
                    LOGGER.warn("Reading from console gave an exception", e);
                }
            }
        }).start();
    }

    // Tick loop
    float lastTickTime = Float.MIN_NORMAL;

    while (this.running.get()) {
        try {
            long start = System.currentTimeMillis();

            // Tick all major subsystems:
            this.syncTaskManager.update(start, lastTickTime);

            this.socketEventListener.update();
            for (Map.Entry<UUID, Player> entry : this.players.entrySet()) {
                ((UpstreamConnection) entry.getValue()).update(lastTickTime);
            }

            long diff = System.currentTimeMillis() - start;
            if (diff < skipMillis) {
                Thread.sleep(skipMillis - diff);

                lastTickTime = (float) skipMillis / TimeUnit.SECONDS.toMillis(1);
            } else {
                lastTickTime = (float) diff / TimeUnit.SECONDS.toMillis(1);
            }
        } catch (Exception e) {
            LOGGER.error("Exception in main run", e);
        }
    }
}

From source file:io.grpc.alts.internal.AltsChannelCrypterTest.java

License:Apache License

@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);
}

From source file:io.grpc.alts.internal.AltsTsiFrameProtectorTest.java

License:Apache License

@Before
public void setUp() {
    ResourceLeakDetector.setLevel(Level.PARANOID);
}

From source file:io.grpc.alts.internal.AltsTsiTest.java

License:Apache License

@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);
}

From source file:io.pravega.shared.protocol.netty.AppendEncodeDecodeTest.java

License:Open Source License

@Before
public void setup() {
    origionalLogLevel = ResourceLeakDetector.getLevel();
    ResourceLeakDetector.setLevel(Level.PARANOID);
}

From source file:io.pravega.shared.protocol.netty.AppendEncodeDecodeTest.java

License:Open Source License

@After
public void teardown() {
    ResourceLeakDetector.setLevel(origionalLogLevel);
}

From source file:io.pravega.test.integration.AppendTest.java

License:Open Source License

@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();
}

From source file:io.pravega.test.integration.AppendTest.java

License:Open Source License

@After
public void teardown() {
    this.serviceBuilder.close();
    ResourceLeakDetector.setLevel(originalLevel);
}

From source file:jgnash.engine.DistributedLockTest.java

License:Open Source License

@Before
public void setUp() {
    final char[] password = new char[] {};

    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);

    server = new DistributedLockServer(PORT);
    assertTrue(server.startServer(password));

    manager = new DistributedLockManager("localhost", PORT);
    manager.connectToServer(password);//  w w  w . j  a  v a  2  s . c  o  m
}

From source file:jgnash.engine.EncryptedDistributedLockTest.java

License:Open Source License

@Before
@Override/*  w ww  .ja  v  a 2  s .co  m*/
public void setUp() {
    final char[] password = new char[] { 'P', 'a', 's', 's', 'w', 'o', 'r', 'd' };

    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);

    //System.setProperty(EncryptionManager.ENCRYPTION_FLAG, "true");
    //System.setProperty("ssl", "true");

    server = new DistributedLockServer(PORT);
    assertTrue(server.startServer(password));

    manager = new DistributedLockManager("localhost", PORT);
    manager.connectToServer(password);
}