Search in sources :

Example 1 with BundleDumpProvider

use of org.apache.karaf.diagnostic.core.providers.BundleDumpProvider in project karaf by apache.

the class Dump method dump.

public static void dump(BundleContext bundleContext, DumpDestination destination, boolean noThreadDump, boolean noHeapDump) {
    List<DumpProvider> providers = new ArrayList<>();
    providers.add(new EnvironmentDumpProvider(bundleContext));
    providers.add(new MemoryDumpProvider());
    if (!noThreadDump)
        providers.add(new ThreadDumpProvider());
    if (!noHeapDump)
        providers.add(new HeapDumpProvider());
    providers.add(new BundleDumpProvider(bundleContext));
    for (DumpProvider provider : providers) {
        try {
            provider.createDump(destination);
        } catch (Throwable t) {
        // Ignore
        }
    }
    try {
        for (ServiceReference<DumpProvider> ref : bundleContext.getServiceReferences(DumpProvider.class, null)) {
            DumpProvider provider = bundleContext.getService(ref);
            try {
                provider.createDump(destination);
            } catch (Throwable t) {
            // Ignore
            } finally {
                bundleContext.ungetService(ref);
            }
        }
    } catch (InvalidSyntaxException e) {
    // Ignore
    }
    try {
        destination.save();
    } catch (Throwable t) {
    // Ignore
    }
}
Also used : ArrayList(java.util.ArrayList) ThreadDumpProvider(org.apache.karaf.diagnostic.core.providers.ThreadDumpProvider) MemoryDumpProvider(org.apache.karaf.diagnostic.core.providers.MemoryDumpProvider) BundleDumpProvider(org.apache.karaf.diagnostic.core.providers.BundleDumpProvider) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) HeapDumpProvider(org.apache.karaf.diagnostic.core.providers.HeapDumpProvider) BundleDumpProvider(org.apache.karaf.diagnostic.core.providers.BundleDumpProvider) ThreadDumpProvider(org.apache.karaf.diagnostic.core.providers.ThreadDumpProvider) EnvironmentDumpProvider(org.apache.karaf.diagnostic.core.providers.EnvironmentDumpProvider) MemoryDumpProvider(org.apache.karaf.diagnostic.core.providers.MemoryDumpProvider) HeapDumpProvider(org.apache.karaf.diagnostic.core.providers.HeapDumpProvider) EnvironmentDumpProvider(org.apache.karaf.diagnostic.core.providers.EnvironmentDumpProvider)

Aggregations

ArrayList (java.util.ArrayList)1 BundleDumpProvider (org.apache.karaf.diagnostic.core.providers.BundleDumpProvider)1 EnvironmentDumpProvider (org.apache.karaf.diagnostic.core.providers.EnvironmentDumpProvider)1 HeapDumpProvider (org.apache.karaf.diagnostic.core.providers.HeapDumpProvider)1 MemoryDumpProvider (org.apache.karaf.diagnostic.core.providers.MemoryDumpProvider)1 ThreadDumpProvider (org.apache.karaf.diagnostic.core.providers.ThreadDumpProvider)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1