Example usage for io.netty.util ResourceLeakDetector getLevel

List of usage examples for io.netty.util ResourceLeakDetector getLevel

Introduction

In this page you can find the example usage for io.netty.util ResourceLeakDetector getLevel.

Prototype

public static Level getLevel() 

Source Link

Document

Returns the current resource leak detection level.

Usage

From source file:com.vmware.xenon.common.TestEventStreams.java

License:Open Source License

@Test
public void testWithLoad() throws Throwable {
    Level level = ResourceLeakDetector.getLevel();
    ResourceLeakDetector.setLevel(Level.PARANOID);
    try {//from w  w  w  .ja v a  2  s . c o m
        doTestWithLoad();
    } finally {
        ResourceLeakDetector.setLevel(level);
    }
}

From source file:com.yahoo.pulsar.common.api.DoubleByteBuf.java

License:Apache License

private static ByteBuf toLeakAwareBuffer(DoubleByteBuf buf) {
    try {//from  w  ww  . j  a va 2  s .  c o  m
        ResourceLeak leak;
        switch (ResourceLeakDetector.getLevel()) {
        case DISABLED:
            break;

        case SIMPLE:
            leak = leakDetector.open(buf);
            if (leak != null) {
                return (ByteBuf) simpleLeakAwareByteBufConstructor.newInstance(buf, leak);
            }
            break;
        case ADVANCED:
        case PARANOID:
            leak = leakDetector.open(buf);
            if (leak != null) {
                return (ByteBuf) advancedLeakAwareByteBufConstructor.newInstance(buf, leak);
            }
            break;
        }
        return buf;
    } catch (Throwable t) {
        // Catch reflection exception
        throw new RuntimeException(t);
    }
}

From source file:divconq.log.Logger.java

License:Open Source License

/**
 * Called from Hub.start this method configures the logging features.
 * /* ww w .  j a va2 s. com*/
 * @param config xml holding the configuration
 */
static public void init(XElement config) {
    Logger.config = config;

    // TODO return operation result

    // TODO load levels, path etc
    // include a setting for startup logging - if present set the TC log level directly

    Logger.startNewLogFile();

    // set by operation context init 
    //Logger.locale = LocaleUtil.getDefaultLocale();

    // From here on we can use netty and so we need the logger setup

    InternalLoggerFactory.setDefaultFactory(new divconq.log.netty.LoggerFactory());

    if (Logger.config != null) {
        // set by operation context init 
        //if (Logger.config.hasAttribute("Level"))
        //   Logger.globalLevel = DebugLevel.parse(Logger.config.getAttribute("Level"));

        if (Logger.config.hasAttribute("NettyLevel")) {
            ResourceLeakDetector.setLevel(Level.valueOf(Logger.config.getAttribute("NettyLevel")));

            Logger.debug("Netty Level set to: " + ResourceLeakDetector.getLevel());
        } else if (!"none".equals(System.getenv("dcnet"))) {
            // TODO anything more we should do here?  maybe paranoid isn't helpful?
        }

        // set by operation context init 
        //if (Logger.config.hasAttribute("Locale"))
        //   Logger.locale = Logger.config.getAttribute("Locale");
    }
}

From source file:io.airlift.drift.transport.netty.buffer.TestingPooledByteBufAllocator.java

License:Apache License

private static ResourceLeakDetector.Level getAndSetResourceLeakDetectorLevel(
        ResourceLeakDetector.Level newLevel) {
    ResourceLeakDetector.Level oldLevel = ResourceLeakDetector.getLevel();
    ResourceLeakDetector.setLevel(newLevel);
    return oldLevel;
}

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.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:org.apache.pulsar.common.api.DoubleByteBuf.java

License:Apache License

private static ByteBuf toLeakAwareBuffer(DoubleByteBuf buf) {
    try {//from  w  w  w  .j a  v  a 2 s.  co  m
        ResourceLeakTracker<DoubleByteBuf> leak;
        switch (ResourceLeakDetector.getLevel()) {
        case DISABLED:
            break;

        case SIMPLE:
            leak = leakDetector.track(buf);
            if (leak != null) {
                return simpleLeakAwareByteBufConstructor.newInstance(buf, leak);
            }
            break;
        case ADVANCED:
        case PARANOID:
            leak = leakDetector.track(buf);
            if (leak != null) {
                return advancedLeakAwareByteBufConstructor.newInstance(buf, leak);
            }
            break;
        }
        return buf;
    } catch (Throwable t) {
        // Catch reflection exception
        throw new RuntimeException(t);
    }
}

From source file:org.apache.zookeeper.test.TestByteBufAllocator.java

License:Apache License

/**
 * Get the singleton testing allocator.//from   w w w.j a  v a2s  .c o  m
 * @return the singleton allocator, creating it if one does not exist.
 */
public static TestByteBufAllocator getInstance() {
    TestByteBufAllocator result = INSTANCE.get();
    if (result == null) {
        ResourceLeakDetector.Level oldLevel = ResourceLeakDetector.getLevel();
        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
        INSTANCE.compareAndSet(null, new TestByteBufAllocator(oldLevel));
        result = INSTANCE.get();
    }
    return result;
}