use of io.engineblock.activityapi.cyclelog.buffers.results.CycleResult in project engineblock by engineblock.
the class CycleLogDumperUtility method dumpData.
private void dumpData(String filename, DisplayType displayType) {
File filepath = new File(filename);
MappedByteBuffer mbb = null;
if (!filepath.exists()) {
if (!filepath.getPath().endsWith(".cyclelog")) {
filepath = new File(filename + ".cyclelog");
if (!filepath.exists()) {
throw new RuntimeException("neither '" + filename + "' nor '" + filename + ".cyclelog' exists!");
}
}
}
try {
RandomAccessFile raf = new RandomAccessFile(filepath, "rw");
mbb = raf.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, raf.length());
} catch (Exception e) {
throw new RuntimeException(e);
}
int readsize = 100;
if (mbb.remaining() > 0) {
CycleResultsRLEBufferReadable readable = null;
while (mbb.remaining() > 0) {
readable = new CycleResultsRLEBufferReadable(readsize, mbb);
for (CycleResultsSegment segment : readable) {
switch(displayType) {
case cycles:
for (CycleResult cycleResult : segment) {
System.out.println(cycleResult);
}
break;
case spans:
System.out.println(segment.toString());
break;
}
}
}
}
}
use of io.engineblock.activityapi.cyclelog.buffers.results.CycleResult in project engineblock by engineblock.
the class CycleLogOutput method onCycleResultSegment.
@Override
public void onCycleResultSegment(CycleResultsSegment segment) {
for (CycleResult cycleResult : segment) {
if (filter == null || filter.test(cycleResult)) {
boolean buffered = targetBuffer.onCycleResult(cycleResult);
if (!buffered) {
flush();
targetBuffer = new CycleResultsRLEBufferTarget(extentSizeInSpans);
boolean bufferedAfterFlush = targetBuffer.onCycleResult(cycleResult);
if (!bufferedAfterFlush) {
throw new RuntimeException("Failed to record result in new target buffer");
}
}
}
}
}
Aggregations