[유치수] [NOBTS]

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@576 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Chisu Yu
2012-09-04 09:52:01 +00:00
parent e200f83d4d
commit ee0b2d1e36
4 changed files with 44 additions and 28 deletions
@@ -21,7 +21,10 @@ public class DeadlineSpanMap {
span = new Span(traceId, null, null);
map.put(traceIdKey, span);
timer.schedule(new FlushTimedoutSpanTask(span), FLUSH_TIMEOUT);
TimerTask task = new FlushTimedoutSpanTask(span);
span.setTimerTask(task);
timer.schedule(task, FLUSH_TIMEOUT);
}
return spanUpdater.updateSpan(span);
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TimerTask;
/**
*
@@ -23,6 +24,16 @@ public class Span {
private final List<HippoAnnotation> annotations = new ArrayList<HippoAnnotation>(5);
private final Set<String> annotationValues = new HashSet<String>(5);
private TimerTask timerTask;
public void setTimerTask(TimerTask task) {
this.timerTask = task;
}
public boolean cancelTimer() {
return timerTask.cancel();
}
public Span(TraceID traceId, String name, EndPoint endPoint) {
this.traceID = traceId;
this.name = name;
+15 -18
View File
@@ -42,14 +42,14 @@ public final class Trace {
return id;
}
public static boolean removeTraceId() {
TraceID traceID = traceId.get();
if(traceID != null) {
traceId.remove();
return true;
}
return false;
}
public static boolean removeTraceId() {
TraceID traceID = traceId.get();
if (traceID != null) {
traceId.remove();
return true;
}
return false;
}
/**
* Get current TraceID. If it was not set this will return null.
@@ -92,9 +92,10 @@ public final class Trace {
System.out.println("\n\nWrite span hash=" + span.hashCode() + ", value=" + span + ", spanMap.size=" + spanMap.size() + ", threadid=" + Thread.currentThread().getId() + "\n\n");
DataSender.getInstance().addDataToSend(span.toThrift());
span.cancelTimer();
} catch (Exception e) {
e.printStackTrace();
logger.log(Level.SEVERE, e.getMessage());
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
@@ -125,8 +126,7 @@ public final class Trace {
}
});
} catch (Exception e) {
e.printStackTrace();
logger.log(Level.SEVERE, e.getMessage());
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
@@ -150,8 +150,7 @@ public final class Trace {
}
});
} catch (Exception e) {
e.printStackTrace();
logger.log(Level.SEVERE, e.getMessage());
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
@@ -169,8 +168,7 @@ public final class Trace {
}
});
} catch (Exception e) {
e.printStackTrace();
logger.log(Level.SEVERE, e.getMessage());
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
@@ -187,8 +185,7 @@ public final class Trace {
}
});
} catch (Exception e) {
e.printStackTrace();
logger.log(Level.SEVERE, e.getMessage());
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}