Skip to content

Commit

Permalink
Exposes a way to count stack traces of same kind in StackTracer debug…
Browse files Browse the repository at this point in the history
… util
  • Loading branch information
tinwelint committed Oct 25, 2015
1 parent 18f1399 commit 3c4fc29
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -19,8 +19,6 @@
*/ */
package org.neo4j.kernel.impl.util; package org.neo4j.kernel.impl.util;


import org.neo4j.function.Predicate;

import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
Expand All @@ -33,6 +31,8 @@
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;


import org.neo4j.function.Predicate;

import static java.lang.reflect.Modifier.isPublic; import static java.lang.reflect.Modifier.isPublic;
import static java.lang.reflect.Modifier.isStatic; import static java.lang.reflect.Modifier.isStatic;


Expand Down Expand Up @@ -146,7 +146,11 @@ public static class StackTracer
private final Map<Stack, AtomicInteger> uniqueStackTraces = new HashMap<>(); private final Map<Stack, AtomicInteger> uniqueStackTraces = new HashMap<>();
private boolean considerMessages = true; private boolean considerMessages = true;


public void add( Throwable t ) /**
* Returns {@link AtomicInteger} for the unique stack trace provided. It gets updated
* as more are added.
*/
public AtomicInteger add( Throwable t )
{ {
Stack key = new Stack( t, considerMessages ); Stack key = new Stack( t, considerMessages );
AtomicInteger count = uniqueStackTraces.get( key ); AtomicInteger count = uniqueStackTraces.get( key );
Expand All @@ -156,6 +160,7 @@ public void add( Throwable t )
uniqueStackTraces.put( key, count ); uniqueStackTraces.put( key, count );
} }
count.incrementAndGet(); count.incrementAndGet();
return count;
} }


public void print( PrintStream out, int interestThreshold ) public void print( PrintStream out, int interestThreshold )
Expand Down

0 comments on commit 3c4fc29

Please sign in to comment.