Skip to content
Snippets Groups Projects
Commit ff562cee authored by nitsanw's avatar nitsanw
Browse files

[core] Fix recorder/logger initialization timing issue.

The HdrHistogramReader makes some problematic assumptions on the roles
played by start time, base time and histogram start/end times. This is
to be revisited in a future release of HdrHistogram (see
https://github.com/HdrHistogram/HdrHistogram/issues/69). In the meantime
this change will make YCSB record as expected by the reader:
a. Set histogram log base time (same as start time)
b. Only create the recorder after the log has been setup
parent 593c2625
No related branches found
No related tags found
No related merge requests found
...@@ -46,8 +46,7 @@ public class OneMeasurementHdrHistogram extends OneMeasurement { ...@@ -46,8 +46,7 @@ public class OneMeasurementHdrHistogram extends OneMeasurement {
final PrintStream log; final PrintStream log;
final HistogramLogWriter histogramLogWriter; final HistogramLogWriter histogramLogWriter;
final Recorder histogram = new Recorder(3); final Recorder histogram;
Histogram totalHistogram; Histogram totalHistogram;
public OneMeasurementHdrHistogram(String name, Properties props) { public OneMeasurementHdrHistogram(String name, Properties props) {
...@@ -56,19 +55,22 @@ public class OneMeasurementHdrHistogram extends OneMeasurement { ...@@ -56,19 +55,22 @@ public class OneMeasurementHdrHistogram extends OneMeasurement {
if (!shouldLog) { if (!shouldLog) {
log = null; log = null;
histogramLogWriter = null; histogramLogWriter = null;
return; } else {
} try {
try { final String hdrOutputFilename = props.getProperty("hdrhistogram.output.path", "") + name + ".hdr";
final String hdrOutputFilename = props.getProperty("hdrhistogram.output.path", "") +name+".hdr"; log = new PrintStream(new FileOutputStream(hdrOutputFilename), false);
log = new PrintStream(new FileOutputStream(hdrOutputFilename), false); } catch (FileNotFoundException e) {
} catch (FileNotFoundException e) { throw new RuntimeException("Failed to open hdr histogram output file", e);
throw new RuntimeException("Failed to open hdr histogram output file", e); }
histogramLogWriter = new HistogramLogWriter(log);
histogramLogWriter.outputComment("[Logging for: " + name + "]");
histogramLogWriter.outputLogFormatVersion();
long now = System.currentTimeMillis();
histogramLogWriter.outputStartTime(now);
histogramLogWriter.setBaseTime(now);
histogramLogWriter.outputLegend();
} }
histogramLogWriter = new HistogramLogWriter(log); histogram = new Recorder(3);
histogramLogWriter.outputComment("[Logging for: " + name + "]");
histogramLogWriter.outputLogFormatVersion();
histogramLogWriter.outputStartTime(System.currentTimeMillis());
histogramLogWriter.outputLegend();
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment