Skip to content

Commit

Permalink
fix #617 Charts of http/sql stats can not be viewed after restarting …
Browse files Browse the repository at this point in the history
…the application
  • Loading branch information
evernat committed Mar 17, 2017
1 parent 5fe1018 commit e5df3b1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -851,15 +851,18 @@ private JRobin getOtherJRobin(String name) throws IOException {
return jrobin;
}

JRobin getJRobin(String graphName) {
JRobin getJRobin(String graphName) throws IOException {
JRobin jrobin = counterJRobins.get(graphName);
if (jrobin == null) {
jrobin = otherJRobins.get(graphName);
if (jrobin == null) {
jrobin = requestJRobinsById.get(graphName);
if (jrobin == null) {
// un graph n'est pas toujours de suite dans jrobin
return null;
// Use a temporary JRobin instance to create the graph.
// The real request name can not be got at this point, passing the graphName as the request name.
jrobin = JRobin.createInstanceIfFileExists(getApplication(), graphName,
graphName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ private void writeStackTrace(CounterRequest request) throws IOException {
}
}

private boolean isGraphDisplayed(Collector collector, CounterRequest request) {
private boolean isGraphDisplayed(Collector collector, CounterRequest request)
throws IOException {
return request == null || getCounterByRequestId(request) != null
&& isRequestGraphDisplayed(getCounterByRequestId(request))
// on vérifie aussi que l'instance de jrobin existe pour faire le graph,
Expand Down
22 changes: 20 additions & 2 deletions javamelody-core/src/main/java/net/bull/javamelody/JRobin.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ static void initBackendFactory(Timer timer) throws IOException {

static JRobin createInstance(String application, String name, String requestName)
throws IOException {
final File dir = Parameters.getStorageDirectory(application);
final File rrdFile = new File(dir, name + ".rrd");
final File rrdFile = getRrdFile(application, name);
final int step = Parameters.getResolutionSeconds();
try {
return new JRobin(application, name, rrdFile, step, requestName);
Expand All @@ -153,6 +152,25 @@ static JRobin createInstance(String application, String name, String requestName
}
}

static JRobin createInstanceIfFileExists(String application, String name, String requestName)
throws IOException {
final File rrdFile = getRrdFile(application, name);
if (rrdFile.exists()) {
final int step = Parameters.getResolutionSeconds();
try {
return new JRobin(application, name, rrdFile, step, requestName);
} catch (final RrdException e) {
throw createIOException(e);
}
}
return null;
}

private static File getRrdFile(String application, String name) {
final File dir = Parameters.getStorageDirectory(application);
return new File(dir, name + ".rrd");
}

private void init() throws IOException, RrdException {
final File rrdFile = new File(rrdFileName);
final File rrdDirectory = rrdFile.getParentFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private Counter getCounterByRequestId(CounterRequest aRequest) {
return null;
}

private boolean isGraphDisplayed() {
private boolean isGraphDisplayed() throws IOException {
return request == null || getCounterByRequestId(request) != null
&& HtmlCounterReport.isRequestGraphDisplayed(getCounterByRequestId(request))
// on vérifie aussi que l'instance de jrobin existe pour faire le graph,
Expand Down

0 comments on commit e5df3b1

Please sign in to comment.